test/relative_mode.markdown
author Andreas Schiffler <aschiffler@ferzkopp.net>
Mon, 03 Jun 2013 19:24:18 -0700
changeset 7268 b399d0441810
parent 7105 0de0f099cfd6
child 9337 7e5940a2cda6
permissions -rw-r--r--
Add missing VS2012 test projects; update VS2010 and VS2012 solutions; update keybord suite for VS compiler warnings
jorgen@7105
     1
Relative mode testing
jorgen@7105
     2
=====================
jorgen@7105
     3
jorgen@7105
     4
See test program at the bottom of this file.
jorgen@7105
     5
jorgen@7105
     6
Initial tests:
jorgen@7105
     7
jorgen@7105
     8
 - When in relative mode, the mouse shouldn't be moveable outside of the window.
jorgen@7105
     9
 - When the cursor is outside the window when relative mode is enabled, mouse
jorgen@7105
    10
   clicks should not go to whatever app was under the cursor previously.
jorgen@7105
    11
 - When alt/cmd-tabbing between a relative mode app and another app, clicks when
jorgen@7105
    12
   in the relative mode app should also not go to whatever app was under the
jorgen@7105
    13
   cursor previously.
jorgen@7105
    14
jorgen@7105
    15
jorgen@7105
    16
Code
jorgen@7105
    17
====
jorgen@7105
    18
jorgen@7105
    19
    #include <SDL.h>
jorgen@7105
    20
jorgen@7105
    21
    int PollEvents()
jorgen@7105
    22
    {
jorgen@7105
    23
        SDL_Event event;
jorgen@7105
    24
        while (SDL_PollEvent(&event))
jorgen@7105
    25
        {
jorgen@7105
    26
            switch (event.type)
jorgen@7105
    27
            {
jorgen@7105
    28
                case SDL_QUIT:
jorgen@7105
    29
                    return 1;
jorgen@7105
    30
                default:
jorgen@7105
    31
                    break;
jorgen@7105
    32
            }
jorgen@7105
    33
        }
jorgen@7105
    34
jorgen@7105
    35
        return 0;
jorgen@7105
    36
    }
jorgen@7105
    37
jorgen@7105
    38
    int main(int argc, char *argv[])
jorgen@7105
    39
    {
jorgen@7105
    40
        SDL_Init(SDL_INIT_VIDEO);
jorgen@7105
    41
jorgen@7105
    42
        SDL_Window *win = SDL_CreateWindow("Test", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 800, 600, 0);
jorgen@7105
    43
        SDL_SetRelativeMouseMode(SDL_TRUE);
jorgen@7105
    44
jorgen@7105
    45
        while (1)
jorgen@7105
    46
        {
jorgen@7105
    47
            if (PollEvents())
jorgen@7105
    48
                break;
jorgen@7105
    49
        }
jorgen@7105
    50
jorgen@7105
    51
        SDL_DestroyWindow(win);
jorgen@7105
    52
jorgen@7105
    53
        SDL_Quit();
jorgen@7105
    54
jorgen@7105
    55
        return 0;
jorgen@7105
    56
    }