diff options
| author | Jonathan Bradley <jcb@pikum.xyz> | 2025-06-11 16:04:48 -0400 |
|---|---|---|
| committer | Jonathan Bradley <jcb@pikum.xyz> | 2025-06-11 16:04:54 -0400 |
| commit | 0f89d12e747b380b35143815a2c8e87c6ee752d4 (patch) | |
| tree | 78617e7cb819093aa9c0ad107b5dc79891e8ff55 /src/player-input.hpp | |
| parent | e478bae42cf886a12433331937887de4c4e85ce2 (diff) | |
pke: serialize PkeInput first-pass
Diffstat (limited to 'src/player-input.hpp')
| -rw-r--r-- | src/player-input.hpp | 19 |
1 files changed, 12 insertions, 7 deletions
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 <cstdint> 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<PkeInputSet> &PkeInput_GetInputSets(); void PkeInput_Teardown(); #endif /* PKE_PLAYER_INPUT_HPP */ |
