MCPcopy Create free account
hub / github.com/StereoKit/StereoKit / input_keyboard_update

Function input_keyboard_update

StereoKitC/systems/input_keyboard.cpp:62–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

60///////////////////////////////////////////
61
62void input_keyboard_update() {
63 input_text_reset();
64
65 // Clear any just_in/active flags that were set on the last frame
66 array_t<keyboard_event_t> &evts = local.key_data.events;
67 for (int32_t i = 0; i < evts.count; i++) {
68 if (evts[i].down)
69 local.key_data.keys[evts[i].key] &= ~button_state_just_active;
70 else
71 local.key_data.keys[evts[i].key] &= ~button_state_just_inactive;
72 }
73
74 // Thread safe copy new key events into the main thread
75 local.key_data.events .clear();
76 local.key_data.characters.clear();
77 ft_mutex_lock(local.key_pending_mtx);
78 local.key_data.events .add_range(local.key_pending .data, local.key_pending .count);
79 local.key_data.characters.add_range(local.chars_pending.data, local.chars_pending.count);
80 local.key_pending .clear();
81 local.chars_pending.clear();
82 ft_mutex_unlock(local.key_pending_mtx);
83
84 // Set key activity flags based on the new event queue
85 evts = local.key_data.events;
86 for (int32_t i = 0; i < evts.count; i++) {
87 keyboard_event_t &evt = evts.get(i);
88 if (evt.down) {
89 local.key_data.keys[evt.key] |= button_state_just_active | button_state_active;
90 } else {
91 local.key_data.keys[evt.key] &= ~button_state_active;
92 local.key_data.keys[evt.key] |= button_state_just_inactive;
93 }
94 }
95}
96
97///////////////////////////////////////////
98

Callers 1

input_stepFunction · 0.85

Calls 6

input_text_resetFunction · 0.85
ft_mutex_lockFunction · 0.85
ft_mutex_unlockFunction · 0.85
clearMethod · 0.80
add_rangeMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected