diff options
| author | Jonathan Bradley <jcb@pikum.xyz> | 2025-07-24 11:41:01 -0400 |
|---|---|---|
| committer | Jonathan Bradley <jcb@pikum.xyz> | 2025-07-24 11:41:01 -0400 |
| commit | 13bb74998afda740bf61df8ddd14c76539937a3b (patch) | |
| tree | 2f28c733810b5aa8dcb262178834623b11b6d76a /src/serialization-input.cpp | |
| parent | 5e341340de5259acdb119866dc6819a81ed0ca84 (diff) | |
pke: pke_input_event fat struct refactor
Diffstat (limited to 'src/serialization-input.cpp')
| -rw-r--r-- | src/serialization-input.cpp | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/src/serialization-input.cpp b/src/serialization-input.cpp index eb44389..c4c5cc3 100644 --- a/src/serialization-input.cpp +++ b/src/serialization-input.cpp @@ -7,7 +7,7 @@ #include <cstring> -pk_handle pke_serialize_input_action(srlztn_serialize_helper *h, PkeInputAction *action) { +pk_handle pke_serialize_input_action(srlztn_serialize_helper *h, pke_input_action *action) { char *s; int len; pke_kve kve{}; @@ -21,7 +21,7 @@ pk_handle pke_serialize_input_action(srlztn_serialize_helper *h, PkeInputAction kvec.child_handles.bkt = h->bkt; h->handle_head.itemIndex++; - compt_a<40==sizeof(PkeInputAction)>(); + compt_a<40==sizeof(pke_input_action)>(); { kve.key = SRLZTN_INPUT_ACTION_NAME; len = strlen(action->name)+1; @@ -32,14 +32,14 @@ pk_handle pke_serialize_input_action(srlztn_serialize_helper *h, PkeInputAction pk_arr_append_t(&kvec.arr, kve); } for (int i = 0; i < PKE_INPUT_ACTION_MASK_INDEX_COUNT; ++i) { - if (action->masks[i].computedHash == InputEventHash{0}) { + if (action->masks[i].computedHash == pke_input_event_hash{0}) { continue; } { kve.key = SRLZTN_INPUT_ACTION_MASK_HASH; - len = snprintf(NULL, 0, "0x%.4hX", static_cast<InputEventHash_T>(action->masks[i].computedHash)); + len = snprintf(NULL, 0, "0x%.4hX", static_cast<pke_input_event_hash_T>(action->masks[i].computedHash)); s = pk_new_arr<char>(len+1, h->bkt); - sprintf(s, "0x%.4hX", static_cast<InputEventHash_T>(action->masks[i].computedHash)); + sprintf(s, "0x%.4hX", static_cast<pke_input_event_hash_T>(action->masks[i].computedHash)); kve.val = s; kve.end = SRLZTN_KVE_END; pk_arr_append_t(&kvec.arr, kve); @@ -68,7 +68,7 @@ pk_handle pke_serialize_input_action(srlztn_serialize_helper *h, PkeInputAction return kvec.srlztn_handle; } -void pke_deserialize_input_action(srlztn_deserialize_helper *h, pke_kve_container *kvec, PkeInputAction &action) { +void pke_deserialize_input_action(srlztn_deserialize_helper *h, pke_kve_container *kvec, pke_input_action &action) { (void)h; uint32_t i; int32_t mask_index = -1; @@ -76,7 +76,7 @@ void pke_deserialize_input_action(srlztn_deserialize_helper *h, pke_kve_containe pke_kve *kve = nullptr; PK_STN_RES stn_res = PK_STN_RES(0); - compt_a<40==sizeof(PkeInputAction)>(); + compt_a<40==sizeof(pke_input_action)>(); for (i = 0; i < kvec->arr.next; ++i) { kve = &kvec->arr[i]; if (strncmp(kve->key, SRLZTN_INPUT_ACTION_NAME, strlen(SRLZTN_INPUT_ACTION_NAME)) == 0) { @@ -89,13 +89,13 @@ void pke_deserialize_input_action(srlztn_deserialize_helper *h, pke_kve_containe if (strncmp(kve->key, SRLZTN_INPUT_ACTION_MASK_HASH, strlen(SRLZTN_INPUT_ACTION_MASK_HASH)) == 0) { mask_index += 1; assert(mask_index < PKE_INPUT_ACTION_MASK_INDEX_COUNT); - InputEventHash_T hash; + pke_input_event_hash_T hash; stn_res = pk_stn(&hash, kve->val, NULL, 16); if (stn_res != PK_STN_RES_SUCCESS) { fprintf(stderr, "[%s] Err '%u' parsing '%s' primary from: '%s'\n", __FILE__, stn_res, SRLZTN_INPUT_ACTION_MASK_HASH, kve->val); continue; } - action.masks[mask_index].computedHash = InputEventHash{hash}; + action.masks[mask_index].computedHash = pke_input_event_hash{hash}; continue; } if (strncmp(kve->key, SRLZTN_INPUT_ACTION_MASK_BUTTON, strlen(SRLZTN_INPUT_ACTION_MASK_BUTTON)) == 0) { @@ -119,7 +119,7 @@ void pke_deserialize_input_action(srlztn_deserialize_helper *h, pke_kve_containe } } -pk_handle pke_serialize_input_set(srlztn_serialize_helper *h, PkeInputSet *input_set) { +pk_handle pke_serialize_input_set(srlztn_serialize_helper *h, pke_input_set *input_set) { char *s; int len; pke_kve kve{}; @@ -138,7 +138,7 @@ pk_handle pke_serialize_input_set(srlztn_serialize_helper *h, PkeInputSet *input pk_arr_append_t(&kvec.child_handles, child_handle); } - compt_a<32==sizeof(PkeInputSet)>(); + compt_a<32==sizeof(pke_input_set)>(); { kve.key = SRLZTN_INPUT_SET_TITLE; len = strlen(input_set->title)+1; @@ -150,9 +150,9 @@ pk_handle pke_serialize_input_set(srlztn_serialize_helper *h, PkeInputSet *input } { kve.key = SRLZTN_INPUT_SET_FLAGS; - len = snprintf(NULL, 0, "0x%.04X", static_cast<InputActionSetFlags_T>(input_set->flags)); + len = snprintf(NULL, 0, "0x%.04X", static_cast<pke_input_action_set_flag_T>(input_set->flags)); s = pk_new_arr<char>(len+1, h->bkt); - sprintf(s, "0x%.04X", static_cast<InputActionSetFlags_T>(input_set->flags)); + sprintf(s, "0x%.04X", static_cast<pke_input_action_set_flag_T>(input_set->flags)); kve.val = s; kve.end = SRLZTN_KVE_END; pk_arr_append_t(&kvec.arr, kve); @@ -167,17 +167,17 @@ void pke_deserialize_input_set(srlztn_deserialize_helper *h, pke_kve_container * uint32_t i, k; char *s; pke_kve *kve = nullptr; - PkeInputSet set{}; + pke_input_set set{}; PK_STN_RES stn_res = PK_STN_RES(0); // TODO specific bucket set.actionCount = kvec->children.next; - set.actions = pk_new_arr<PkeInputAction>(kvec->children.next, NULL); + set.actions = pk_new_arr<pke_input_action>(kvec->children.next, NULL); for (k = 0; k < set.actionCount; ++k) { pke_deserialize_input_action(h, kvec->children[k], set.actions[k]); } - compt_a<40==sizeof(PkeInputAction)>(); + compt_a<40==sizeof(pke_input_action)>(); for (i = 0; i < kvec->arr.next; ++i) { kve = &kvec->arr[i]; if (strncmp(kve->key, SRLZTN_INPUT_SET_TITLE, strlen(SRLZTN_INPUT_SET_TITLE)) == 0) { @@ -188,20 +188,20 @@ void pke_deserialize_input_set(srlztn_deserialize_helper *h, pke_kve_container * continue; } if (strncmp(kve->key, SRLZTN_INPUT_SET_FLAGS, strlen(SRLZTN_INPUT_SET_FLAGS)) == 0) { - InputActionSetFlags_T flags; + pke_input_action_set_flag_T flags; stn_res = pk_stn(&flags, kve->val, NULL, 16); if (stn_res != PK_STN_RES_SUCCESS) { fprintf(stderr, "[%s] Err '%u' parsing '%s' primary from: '%s'\n", __FILE__, stn_res, SRLZTN_INPUT_SET_FLAGS, kve->val); continue; } - set.flags = InputActionSetFlags{flags}; + set.flags = pke_input_action_set_flag{flags}; continue; } } - InputActionSetHandle action_set_handle = PkeInput_RegisterSet(set); + pke_input_action_set_handle action_set_handle = pke_input_register_set(set); pke_scene_register_input_action_set(h->scene->scene_handle, action_set_handle); if (PK_HAS_FLAG(set.flags, PKE_INPUT_ACTION_SET_FLAG_AUTO_ENABLE)) { - PkeInput_ActivateSet(action_set_handle); + pke_input_activate_set(action_set_handle); } } |
