test/relative_mode.markdown
author Ryan C. Gordon <icculus@icculus.org>
Fri, 12 Aug 2016 19:59:00 -0400
changeset 10266 c09f06c4e8c8
parent 9337 7e5940a2cda6
permissions -rw-r--r--
emscripten: send fake mouse events for touches, like other targets do. (This really should be handled at the higher level and not in the individual targets, but this fixes the immediate bug.)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7105
0de0f099cfd6 Test plan for relative mode.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
     1
Relative mode testing
0de0f099cfd6 Test plan for relative mode.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
     2
=====================
0de0f099cfd6 Test plan for relative mode.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
     3
0de0f099cfd6 Test plan for relative mode.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
     4
See test program at the bottom of this file.
0de0f099cfd6 Test plan for relative mode.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
     5
0de0f099cfd6 Test plan for relative mode.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
     6
Initial tests:
0de0f099cfd6 Test plan for relative mode.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
     7
0de0f099cfd6 Test plan for relative mode.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
     8
 - When in relative mode, the mouse shouldn't be moveable outside of the window.
0de0f099cfd6 Test plan for relative mode.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
     9
 - When the cursor is outside the window when relative mode is enabled, mouse
0de0f099cfd6 Test plan for relative mode.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    10
   clicks should not go to whatever app was under the cursor previously.
0de0f099cfd6 Test plan for relative mode.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    11
 - When alt/cmd-tabbing between a relative mode app and another app, clicks when
0de0f099cfd6 Test plan for relative mode.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    12
   in the relative mode app should also not go to whatever app was under the
0de0f099cfd6 Test plan for relative mode.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    13
   cursor previously.
0de0f099cfd6 Test plan for relative mode.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    14
0de0f099cfd6 Test plan for relative mode.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    15
0de0f099cfd6 Test plan for relative mode.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    16
Code
0de0f099cfd6 Test plan for relative mode.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    17
====
0de0f099cfd6 Test plan for relative mode.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    18
0de0f099cfd6 Test plan for relative mode.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    19
    #include <SDL.h>
0de0f099cfd6 Test plan for relative mode.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    20
0de0f099cfd6 Test plan for relative mode.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    21
    int PollEvents()
0de0f099cfd6 Test plan for relative mode.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    22
    {
0de0f099cfd6 Test plan for relative mode.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    23
        SDL_Event event;
0de0f099cfd6 Test plan for relative mode.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    24
        while (SDL_PollEvent(&event))
0de0f099cfd6 Test plan for relative mode.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    25
        {
0de0f099cfd6 Test plan for relative mode.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    26
            switch (event.type)
0de0f099cfd6 Test plan for relative mode.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    27
            {
0de0f099cfd6 Test plan for relative mode.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    28
                case SDL_QUIT:
0de0f099cfd6 Test plan for relative mode.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    29
                    return 1;
0de0f099cfd6 Test plan for relative mode.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    30
                default:
0de0f099cfd6 Test plan for relative mode.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    31
                    break;
0de0f099cfd6 Test plan for relative mode.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    32
            }
0de0f099cfd6 Test plan for relative mode.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    33
        }
0de0f099cfd6 Test plan for relative mode.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    34
0de0f099cfd6 Test plan for relative mode.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    35
        return 0;
0de0f099cfd6 Test plan for relative mode.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    36
    }
0de0f099cfd6 Test plan for relative mode.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    37
0de0f099cfd6 Test plan for relative mode.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    38
    int main(int argc, char *argv[])
0de0f099cfd6 Test plan for relative mode.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    39
    {
9337
7e5940a2cda6 Fixed compiling test with older C.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 7105
diff changeset
    40
        SDL_Window *win;
7e5940a2cda6 Fixed compiling test with older C.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 7105
diff changeset
    41
7105
0de0f099cfd6 Test plan for relative mode.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    42
        SDL_Init(SDL_INIT_VIDEO);
0de0f099cfd6 Test plan for relative mode.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    43
9337
7e5940a2cda6 Fixed compiling test with older C.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 7105
diff changeset
    44
        win = SDL_CreateWindow("Test", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 800, 600, 0);
7105
0de0f099cfd6 Test plan for relative mode.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    45
        SDL_SetRelativeMouseMode(SDL_TRUE);
0de0f099cfd6 Test plan for relative mode.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    46
0de0f099cfd6 Test plan for relative mode.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    47
        while (1)
0de0f099cfd6 Test plan for relative mode.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    48
        {
0de0f099cfd6 Test plan for relative mode.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    49
            if (PollEvents())
0de0f099cfd6 Test plan for relative mode.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    50
                break;
0de0f099cfd6 Test plan for relative mode.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    51
        }
0de0f099cfd6 Test plan for relative mode.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    52
0de0f099cfd6 Test plan for relative mode.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    53
        SDL_DestroyWindow(win);
0de0f099cfd6 Test plan for relative mode.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    54
0de0f099cfd6 Test plan for relative mode.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    55
        SDL_Quit();
0de0f099cfd6 Test plan for relative mode.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    56
0de0f099cfd6 Test plan for relative mode.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    57
        return 0;
0de0f099cfd6 Test plan for relative mode.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    58
    }