diff options
| author | navewindre <boneyaard@gmail.com> | 2025-09-28 02:45:10 +0200 |
|---|---|---|
| committer | navewindre <boneyaard@gmail.com> | 2025-09-28 02:45:10 +0200 |
| commit | 0db9c91742a6ab17c3d8a8b86a34392c1797740b (patch) | |
| tree | c3b2595722f601c61b342cc470e9e7f8a13891d0 /src/util/input.cpp | |
| parent | ae694bc0da98e45c5def20ac1d92f9d8aad65fd5 (diff) | |
input bettr
Diffstat (limited to 'src/util/input.cpp')
| -rw-r--r-- | src/util/input.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/util/input.cpp b/src/util/input.cpp index 7e94c47..225b696 100644 --- a/src/util/input.cpp +++ b/src/util/input.cpp @@ -27,8 +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.mouse.pos_delta.y = (F32)e->motion.yrel; + input.mouse.pos_delta.x += (F32)e->motion.xrel; + input.mouse.pos_delta.y += (F32)e->motion.yrel; } break; case SDL_KEYDOWN: { input.keys[e->key.keysym.sym & 0xff] = 1; @@ -39,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 ) { @@ -73,11 +77,10 @@ void input_on_mouse( I32 type, I32 x, I32 y ) { void input_frame_end() { input.mouse.wheel = 0; - input.mouse.pos_delta.x = 0; - input.mouse.pos_delta.y = 0; } void input_capture_mouse( bool capture ) { + input_reset_mouse_accumulator(); input.mouse_captured = capture; SDL_SetRelativeMouseMode( capture ? SDL_TRUE : SDL_FALSE ); } |
