From f8b92ce3aa08b1445c9f956d8166830946562d12 Mon Sep 17 00:00:00 2001 From: navewindre Date: Wed, 3 Sep 2025 20:10:09 +0200 Subject: a --- src/util/input.h | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/util/input.h (limited to 'src/util/input.h') diff --git a/src/util/input.h b/src/util/input.h new file mode 100644 index 0000000..e174fe6 --- /dev/null +++ b/src/util/input.h @@ -0,0 +1,41 @@ +#pragma once + +#include +#include +#include "vector.h" +#include "allocator.h" + +const U32 MOUSEEV_MOVE = 0x0; +const U32 MOUSEEV_DOWN = 0x1; +const U32 MOUSEEV_UP = 0x2; + +const U32 MOUSE_LEFT = 0x1; +const U32 MOUSE_RIGHT = 0x2; +const U32 MOUSE_MIDDLE = 0x3; +const U32 MOUSE_WHEEL = 0x4; + +struct MOUSE_DATA { + VEC2 pos; + U8 left; + U8 right; + U8 middle; + U8 wheel; +}; + +using ON_INPUT_FN = std::function; + +struct INPUT_DATA { + MOUSE_DATA mouse; + U8 keys[0xff]; + + LIST on_input; +}; + +extern INPUT_DATA input; + +extern void input_frame_end(); +extern void input_on_event( SDL_Event* e ); +extern void input_on_mouse( I32 type, I32 x, I32 y ); +extern void input_is_key_down( U32 key ); + +#define kb_down( key ) input_is_key_down( key ) -- cgit v1.2.3