summaryrefslogtreecommitdiff
path: root/src/player-input.hpp
diff options
context:
space:
mode:
authorJonathan Bradley <jcb@pikum.xyz>2023-10-11 13:03:35 -0400
committerJonathan Bradley <jcb@pikum.xyz>2023-10-11 13:03:35 -0400
commitfb5c06777557fc28c0d8e919d9a82bdf51adeea7 (patch)
tree2b80595cf3d286a3d72619102d0df06582de41dd /src/player-input.hpp
parent40ab6886e72c660d424fec9140feb8685db7d363 (diff)
checkpoint for handling player input
Diffstat (limited to 'src/player-input.hpp')
-rw-r--r--src/player-input.hpp57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/player-input.hpp b/src/player-input.hpp
new file mode 100644
index 0000000..c6429eb
--- /dev/null
+++ b/src/player-input.hpp
@@ -0,0 +1,57 @@
+#ifndef PKE_PLAYER_INPUT_HPP
+#define PKE_PLAYER_INPUT_HPP
+
+#include "dynamic-array.hpp"
+#include "game-type-defs.hpp"
+#include "macros.hpp"
+
+TypeSafeInt_H(InputEventHash, int16_t, 255);
+TypeSafeInt_H(InputEventType, int16_t, 255);
+TypeSafeInt_H(InputCursorEntered, int16_t, 255);
+TypeSafeInt_H(InputKeyboardKeyAction, int16_t, 255);
+TypeSafeInt_H(InputMouseButtonAction, int16_t, 255);
+TypeSafeInt_H(InputWindowFocused, int16_t, 255);
+
+const InputEventType PKE_INPUT_EVENT_TYPE_CURSOR_ENTER = InputEventType{0};
+const InputEventType PKE_INPUT_EVENT_TYPE_CURSOR_POS = InputEventType{1};
+const InputEventType PKE_INPUT_EVENT_TYPE_KEY = InputEventType{2};
+const InputEventType PKE_INPUT_EVENT_TYPE_MOUSE_BUTTON = InputEventType{3};
+const InputEventType PKE_INPUT_EVENT_TYPE_SCROLL = InputEventType{4};
+const InputEventType PKE_INPUT_EVENT_TYPE_WINDOW_FOCUS = InputEventType{5};
+
+const InputCursorEntered PKE_INPUT_CURSOR_ENTERED_UNSET = InputCursorEntered{-1};
+const InputCursorEntered PKE_INPUT_CURSOR_ENTERED_FALSE = InputCursorEntered{0};
+const InputCursorEntered PKE_INPUT_CURSOR_ENTERED_TRUE = InputCursorEntered{1};
+
+const InputKeyboardKeyAction PKE_INPUT_KEYBOARD_KEY_ACTION_UNSET = InputKeyboardKeyAction{-1};
+const InputKeyboardKeyAction PKE_INPUT_KEYBOARD_KEY_ACTION_RELEASE = InputKeyboardKeyAction{0};
+const InputKeyboardKeyAction PKE_INPUT_KEYBOARD_KEY_ACTION_PRESS = InputKeyboardKeyAction{1};
+const InputKeyboardKeyAction PKE_INPUT_KEYBOARD_KEY_ACTION_REPEAT = InputKeyboardKeyAction{2};
+
+const InputMouseButtonAction PKE_INPUT_MOUSE_BUTTON_ACTION_UNSET = InputMouseButtonAction{-1};
+const InputMouseButtonAction PKE_INPUT_MOUSE_BUTTON_ACTION_RELEASE = InputMouseButtonAction{0};
+const InputMouseButtonAction PKE_INPUT_MOUSE_BUTTON_ACTION_PRESS = InputMouseButtonAction{1};
+
+const InputWindowFocused PKE_INPUT_WINDOW_FOCUSED_UNSET = InputWindowFocused{-1};
+const InputWindowFocused PKE_INPUT_WINDOW_FOCUSED_FALSE = InputWindowFocused{0};
+const InputWindowFocused PKE_INPUT_WINDOW_FOCUSED_TRUE = InputWindowFocused{1};
+
+struct PkeInputEvent {
+ InputEventType type;
+ GameTimePoint timePoint;
+ InputCursorEntered cursorEntered;
+ InputKeyboardKeyAction keyboardKeyAction;
+ InputMouseButtonAction mouseButtonAction;
+ InputWindowFocused windowFocused;
+ double x;
+ double y;
+ int32_t button;
+ int32_t scanCode;
+ int32_t mods;
+};
+
+void PkeInput_Tick();
+void PkeInput_Init();
+void PkeInput_Teardown();
+
+#endif /* PKE_PLAYER_INPUT_HPP */