diff options
| author | aura <nw@moneybot.cc> | 2026-08-11 19:10:16 +0200 |
|---|---|---|
| committer | aura <nw@moneybot.cc> | 2026-08-11 19:10:16 +0200 |
| commit | 17c07b5f884453130d8be3a6d91d730d80d4f8ae (patch) | |
| tree | 6ec11e5e5f7f0be9ed899196c2897aa76a907de2 /src/util/input.cpp | |
| parent | 1aa17de9188790f049c0edc4281597cb4e535627 (diff) | |
| parent | 0a9d7ce6a0764a87766ebb23cc1ece4c26c8c678 (diff) | |
Merge remote-tracking branch 'origin/day'
Diffstat (limited to 'src/util/input.cpp')
| -rw-r--r-- | src/util/input.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/util/input.cpp b/src/util/input.cpp index fa308e2..46bc5f9 100644 --- a/src/util/input.cpp +++ b/src/util/input.cpp @@ -1,6 +1,8 @@ #include "input.h" #include "SDL_events.h" +#include <string.h> + INPUT_DATA input; void input_on_event( SDL_Event* e ) { @@ -30,6 +32,22 @@ void input_on_event( SDL_Event* e ) { 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_TEXTINPUT: { + U32 incoming = strlen( e->text.text ); + U32 available = (U32)sizeof( input.text ) - 1 - input.textlen; + U32 count = incoming < available + ? incoming + : available; + if( !count ) + break; + memcpy( + input.text + input.textlen, + e->text.text, + count + ); + input.textlen += count; + input.text[input.textlen] = 0; + } break; case SDL_KEYDOWN: { input.keys[e->key.keysym.sym & 0xff] = 1; } break; @@ -77,6 +95,8 @@ void input_on_mouse( I32 type, I32 x, I32 y ) { void input_frame_end() { input.mouse.wheel = 0; + input.textlen = 0; + input.text[0] = 0; } U8 input_is_key_down( U32 key ) { |
