aboutsummaryrefslogtreecommitdiff
path: root/src/skhd.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/skhd.c')
-rw-r--r--src/skhd.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/skhd.c b/src/skhd.c
index d67f74c..536ca03 100644
--- a/src/skhd.c
+++ b/src/skhd.c
@@ -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();