diff options
| author | navewindre <boneyaard@gmail.com> | 2025-11-28 14:41:22 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-11-28 14:41:22 +0100 |
| commit | 9c05c795d7b59c5ab94fb769f315c712b37df0cd (patch) | |
| tree | 16cccf8cbb88703de798066a06f94013f89a8a5a /src/util/input.cpp | |
| parent | f8b92ce3aa08b1445c9f956d8166830946562d12 (diff) | |
| parent | 3e094f20d4dda90e0356aba3f0abc4b7c7015844 (diff) | |
Merge pull request #1 from navewindre/windows-compat
Windows compat
Diffstat (limited to 'src/util/input.cpp')
| -rw-r--r-- | src/util/input.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/util/input.cpp b/src/util/input.cpp index 4a786aa..284ebfe 100644 --- a/src/util/input.cpp +++ b/src/util/input.cpp @@ -27,6 +27,8 @@ void input_on_event( SDL_Event* e ) { case SDL_MOUSEMOTION: { input.mouse.pos.x = (F32)e->motion.x; input.mouse.pos.y = (F32)e->motion.y; + input.mouse.pos_delta.x += (F32)e->motion.xrel * input.mpitch; + input.mouse.pos_delta.y += (F32)e->motion.yrel * input.myaw; } break; case SDL_KEYDOWN: { input.keys[e->key.keysym.sym & 0xff] = 1; @@ -37,6 +39,10 @@ void input_on_event( SDL_Event* e ) { } } +extern void input_reset_mouse_accumulator() { + input.mouse.pos_delta.x = 0; + input.mouse.pos_delta.y = 0; +} void input_on_mouse( I32 type, I32 x, I32 y ) { if( type == MOUSEEV_MOVE ) { @@ -72,3 +78,13 @@ void input_on_mouse( I32 type, I32 x, I32 y ) { void input_frame_end() { input.mouse.wheel = 0; } + +U8 input_is_key_down( U32 key ) { + return input.keys[key]; +} + +void input_capture_mouse( bool capture ) { + input_reset_mouse_accumulator(); + input.mouselock = capture; + SDL_SetRelativeMouseMode( capture ? SDL_TRUE : SDL_FALSE ); +} |
