From 0f89d12e747b380b35143815a2c8e87c6ee752d4 Mon Sep 17 00:00:00 2001 From: Jonathan Bradley Date: Wed, 11 Jun 2025 16:04:48 -0400 Subject: pke: serialize PkeInput first-pass --- src/player-input.hpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'src/player-input.hpp') diff --git a/src/player-input.hpp b/src/player-input.hpp index f67e966..abb8a40 100644 --- a/src/player-input.hpp +++ b/src/player-input.hpp @@ -6,9 +6,13 @@ #include TypeSafeInt_H(InputActionSetHandle, uint8_t, 0xFF); - +TypeSafeInt_constexpr(InputActionSetFlags, uint8_t, 0xFF); TypeSafeInt_constexpr(InputEventHash, uint16_t, 0xFFFF); +constexpr InputActionSetFlags PKE_INPUT_ACTION_SET_FLAG_NONE = InputActionSetFlags{0x00}; +constexpr InputActionSetFlags PKE_INPUT_ACTION_SET_FLAG_DO_NOT_SERIALIZE = InputActionSetFlags{0x01}; +constexpr InputActionSetFlags PKE_INPUT_ACTION_SET_FLAG_AUTO_ENABLE = InputActionSetFlags{0x02}; + const InputEventHash PKE_INPUT_HASH_EVENT_TYPE_CURSOR_ENTER = InputEventHash {0x0001}; const InputEventHash PKE_INPUT_HASH_EVENT_TYPE_CURSOR_POS = InputEventHash {0x0002}; const InputEventHash PKE_INPUT_HASH_EVENT_TYPE_KEY = InputEventHash {0x0004}; @@ -94,19 +98,19 @@ struct PkeInputEventMask { int32_t mods = 0; }; -constexpr int64_t PKE_INPUT_ACTION_MASK_COUNT = 1; +#define PKE_INPUT_ACTION_MASK_INDEX_PRIMARY 0 +#define PKE_INPUT_ACTION_MASK_INDEX_SECONDARY 1 +#define PKE_INPUT_ACTION_MASK_INDEX_COUNT 2 struct PkeInputAction { const char *name; - union { - PkeInputEventMask masks[PKE_INPUT_ACTION_MASK_COUNT] = {{}}; - PkeInputEventMask primaryHash; - }; - int32_t eventIndex; + PkeInputEventMask masks[2] = {{},{}}; + int32_t event_indices[2] = {-1,-1}; }; struct PkeInputSet { const char *title; int64_t actionCount; PkeInputAction *actions; + InputActionSetFlags flags; }; void PkeInput_Tick(double delta); @@ -116,6 +120,7 @@ InputActionSetHandle PkeInput_RegisterSet(const PkeInputSet &set); void PkeInput_ActivateSet(InputActionSetHandle handle); void PkeInput_DeactivateSet(InputActionSetHandle handle); void PkeInput_UnregisterSet(InputActionSetHandle handle); +pk_arr_t &PkeInput_GetInputSets(); void PkeInput_Teardown(); #endif /* PKE_PLAYER_INPUT_HPP */ -- cgit v1.2.3