Closed GrayHatter closed 9 years ago
ability to change the button, coming soon?
I have exams to do -- in the meantime, can you implement a stub get_ptt();
in cocoa/main.m so the build doesn't break?
@stal888 done
@GrayHatter
I'm still working on this one, just need to dive into Xinput as the fallback for linux, I could probably be merged now for windows while I add linux support
diff --git a/cocoa/main.m b/cocoa/main.m
index 16d3954..ed1fbe4 100644
--- a/cocoa/main.m
+++ b/cocoa/main.m
@@ -287,13 +287,18 @@ void postmessage(uint32_t msg, uint16_t param1, uint16_t param2, void *data) {
});
}
-void init_ptt(void){ push_to_talk = 0; /* OSX is unsupported */ }
+void init_ptt(void) {
+ push_to_talk = 1;
+}
+static _Bool is_ctrl_down = 0;
_Bool check_ptt_key(void){
- return 1; // @stal888 this is your job mate, good luck!
+ return push_to_talk? is_ctrl_down : 1;
}
-void exit_ptt(void){ push_to_talk = 0; /* OSX is unsupported */ }
+void exit_ptt(void) {
+ push_to_talk = 0;
+}
void redraw(void) {
uToxAppDelegate *ad = (uToxAppDelegate *)[NSApp delegate];
@@ -320,7 +325,10 @@ void launch_at_startup(int should) {
CFRelease(items);
}
-@implementation uToxAppDelegate
+@implementation uToxAppDelegate {
+ id global_event_listener;
+ id local_event_listener;
+}
- (void)applicationDidFinishLaunching:(NSNotification *)notification {
setup_cursors();
@@ -329,6 +337,15 @@ void launch_at_startup(int should) {
[NSApplication sharedApplication].dockTile.contentView = dock_icon;
[dock_icon release];
+ global_event_listener = [NSEvent addGlobalMonitorForEventsMatchingMask:NSFlagsChangedMask handler:^(NSEvent *e) {
+ is_ctrl_down = e.modifierFlags & NSControlKeyMask;
+ }];
+
+ local_event_listener = [NSEvent addLocalMonitorForEventsMatchingMask:NSFlagsChangedMask handler:^NSEvent *(NSEvent *e) {
+ is_ctrl_down = e.modifierFlags & NSControlKeyMask;
+ return e;
+ }];
+
ironclad = [[NSMutableDictionary alloc] init];
// hold COMMAND to start utox in portable mode
@@ -424,6 +441,9 @@ void launch_at_startup(int should) {
config_save(&d);
+ [NSEvent removeMonitor:global_event_listener];
+ [NSEvent removeMonitor:local_event_listener];
+
/* wait for threads to exit */
while(tox_thread_init) {
yieldcpu(1);
in develop
Linux is a bit complicated to get working. You have to
ln -s /dev/input/the_kbd_you_want ~/.config/tox/ptt-kbd
as root, then change the ownership of that file to your user, then if you're sane, you'll lock down permissions.@stal888 maybe you can implement this in OSX as well?