diff options
Diffstat (limited to 'src/skhd.c')
-rw-r--r-- | src/skhd.c | 33 |
1 files changed, 33 insertions, 0 deletions
@@ -25,6 +25,7 @@ #include "parse.h" #include "hotkey.h" #include "synthesize.h" +#include "mtouch.h" #include "hotload.c" #include "event_tap.c" @@ -34,6 +35,7 @@ #include "parse.c" #include "hotkey.c" #include "synthesize.c" +#include "mtouch.c" extern CFDictionaryRef CGSCopyCurrentSessionDictionary(void); extern bool CGSIsSecureEventInputSet(void); @@ -178,6 +180,34 @@ internal EVENT_TAP_CALLBACK(key_handler) return event; } +internal MULTITOUCH_CALLBACK(touch_handler) +{ + for (int i = 0; i < num_fingers; ++i) { + struct finger *finger = &data[i]; + struct cached_finger_data cached_data = { + .id = finger->identifier, + .pos = { + .x = finger->normalized.pos.x, + .y = finger->normalized.pos.y + }, + .pressure = finger->size + }; + + if (!cached_finger_data[finger->identifier]) { + printf("finger %d pressed\n", finger->identifier); + } + buf_push(cached_finger_data[finger->identifier], cached_data); + + if (finger->size == 0.0f) { + printf("finger %d released\n", finger->identifier); + process_cached_finger_data(finger->identifier); + buf_free(cached_finger_data[finger->identifier]); + cached_finger_data[finger->identifier] = NULL; + } + } + return 0; +} + internal void sigusr1_handler(int signal) { @@ -435,6 +465,9 @@ int main(int argc, char **argv) event_tap.mask = (1 << kCGEventKeyDown) | (1 << NX_SYSDEFINED); event_tap_begin(&event_tap, key_handler); END_SCOPED_TIMED_BLOCK(); + + struct multitouch multitouch; + multitouch_begin(&multitouch, touch_handler); END_SCOPED_TIMED_BLOCK(); CFRunLoopRun(); |