diff options
| author | 2lag <96544487+2lag@users.noreply.github.com> | 2026-08-08 17:33:36 +0200 |
|---|---|---|
| committer | 2lag <96544487+2lag@users.noreply.github.com> | 2026-08-08 17:33:36 +0200 |
| commit | 2973df584978d9aae6f164ce0204179c8a28b3ae (patch) | |
| tree | c1b793c8e0d17aeb66c5197bc28acca84b2c98ab /src/util/input.cpp | |
| parent | e540910745aad31378452eec25aacfb3f346191a (diff) | |
console, textbox changes, some other shit
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 ) { |
