added SDL_SetRelativeMouseMode
authormatthew <matthew@owens.tech>
Sat, 3 Nov 2018 21:38:17 +0000 (21:38 +0000)
committermatthew <matthew@owens.tech>
Sat, 3 Nov 2018 21:38:17 +0000 (21:38 +0000)
gl/input.c

index c8a3575..e1d7111 100644 (file)
@@ -88,9 +88,12 @@ void crpgInputInit()
        kb.binds = malloc(sizeof(Uint8) * INPUT_LAST);
        loadKeybinds();
 
-       // Init the last frame array to 0
        memset(kb.prevState, 0, sizeof(Uint8)*SDL_NUM_SCANCODES);
        memcpy(kb.state, SDL_GetKeyboardState(NULL), sizeof(Uint8)*SDL_NUM_SCANCODES);
+
+       // constraining the mouse to the window
+       // TODO: only set relative mouse mode once the mouse is in the window, disable input otherwise
+       SDL_SetRelativeMouseMode(SDL_TRUE);
 }
 
 void crpgInputCleanup()