cscg22-gearboy

CSCG 2022 Challenge 'Gearboy'
git clone https://git.sinitax.com/sinitax/cscg22-gearboy
Log | Files | Refs | sfeed.txt

relative_mode.markdown (1269B)


      1Relative mode testing
      2=====================
      3
      4See test program at the bottom of this file.
      5
      6Initial tests:
      7
      8 - When in relative mode, the mouse shouldn't be moveable outside of the window.
      9 - When the cursor is outside the window when relative mode is enabled, mouse
     10   clicks should not go to whatever app was under the cursor previously.
     11 - When alt/cmd-tabbing between a relative mode app and another app, clicks when
     12   in the relative mode app should also not go to whatever app was under the
     13   cursor previously.
     14
     15
     16Code
     17====
     18
     19    #include <SDL.h>
     20
     21    int PollEvents()
     22    {
     23        SDL_Event event;
     24        while (SDL_PollEvent(&event))
     25        {
     26            switch (event.type)
     27            {
     28                case SDL_QUIT:
     29                    return 1;
     30                default:
     31                    break;
     32            }
     33        }
     34
     35        return 0;
     36    }
     37
     38    int main(int argc, char *argv[])
     39    {
     40        SDL_Init(SDL_INIT_VIDEO);
     41
     42        SDL_Window *win = SDL_CreateWindow("Test", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 800, 600, 0);
     43        SDL_SetRelativeMouseMode(SDL_TRUE);
     44
     45        while (1)
     46        {
     47            if (PollEvents())
     48                break;
     49        }
     50
     51        SDL_DestroyWindow(win);
     52
     53        SDL_Quit();
     54
     55        return 0;
     56    }