From fb5c06777557fc28c0d8e919d9a82bdf51adeea7 Mon Sep 17 00:00:00 2001 From: Jonathan Bradley Date: Wed, 11 Oct 2023 13:03:35 -0400 Subject: checkpoint for handling player input --- src/player-input.hpp | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 src/player-input.hpp (limited to 'src/player-input.hpp') 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 */ -- cgit v1.2.3