diff options
| author | Teddy Wing | 2018-10-14 16:47:16 +0200 |
|---|---|---|
| committer | Teddy Wing | 2018-10-14 16:47:16 +0200 |
| commit | 8e05e3a4a6e42912ed6bda97346ed55d239557eb (patch) | |
| tree | bd01f3825f606075395daa26f477648056aa5b0e | |
| parent | 8b0eea58989b3f4f103cfae7438d16724c0354e8 (diff) | |
| download | dome_key_event_source_simulator-8e05e3a4a6e42912ed6bda97346ed55d239557eb.tar.bz2 | |
Fix key down key up flags
When I consolidated the key down and key up code in
289639a636881d79b76d260b775b7a6cf0b51f7b the key simulation stopped
working.
Fix this by altering the type of the array used to store the flag values
and putting them in a single array literal.
| -rw-r--r-- | dome_key_event_source_simulator/dome_key_event_source_simulator.m | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/dome_key_event_source_simulator/dome_key_event_source_simulator.m b/dome_key_event_source_simulator/dome_key_event_source_simulator.m index 4ce1244..87dd63e 100644 --- a/dome_key_event_source_simulator/dome_key_event_source_simulator.m +++ b/dome_key_event_source_simulator/dome_key_event_source_simulator.m @@ -12,25 +12,22 @@ @end -const int key_down[] = {0xa00, 0xa}; -const int key_up[] = {0xb00, 0xb}; - -// #define KEY_DOWN {0xa00, 0xa} -// #define KEY_UP {0xb00, 0xb} +static const size_t key_down_up[][2] = { + {0xa00, 0xa}, // Down + {0xb00, 0xb} // Up +}; void dkess_press_key(int key, NSEventModifierFlags modifier_flags) { - const int flags[2][2] = {key_down, key_up}; - for (int i = 0; i < 2; i++) { NSEvent *event = [NSEvent otherEventWithType:NSSystemDefined location:NSZeroPoint - modifierFlags:flags[i][0] + modifierFlags:key_down_up[i][0] timestamp:0.0 windowNumber:0 context:nil subtype:NSScreenChangedEventType - data1:(NX_KEYTYPE_PLAY << 16) | (flags[i][1] << 8) + data1:(NX_KEYTYPE_PLAY << 16) | (key_down_up[i][1] << 8) data2:-1]; CGEventRef cg_event = [event CGEvent]; |
