Created
September 7, 2013 23:22
-
-
Save delqn/6480303 to your computer and use it in GitHub Desktop.
Logitech T400 middle mouse button working as B2 in Plan9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
changeset: 3459:62c46799f75a | |
tag: tip | |
user: delyan@raychev.org | |
date: Sat Sep 07 16:14:14 2013 -0700 | |
files: src/cmd/devdraw/cocoa-screen.m | |
description: | |
Convert Logitech T400 L_Meta mouse button to middle mouse button | |
diff -r 8c459ad6cc84 -r 62c46799f75a src/cmd/devdraw/cocoa-screen.m | |
--- a/src/cmd/devdraw/cocoa-screen.m Tue Aug 06 23:44:06 2013 -0400 | |
+++ b/src/cmd/devdraw/cocoa-screen.m Sat Sep 07 16:14:14 2013 -0700 | |
@@ -820,9 +820,18 @@ | |
NSString *s; | |
char c; | |
int k, m; | |
+ bool mouse_meta_key; | |
uint code; | |
+ enum | |
+ { | |
+ // NSEvent flags when mouse's Meta (fancy middle) button is pressed | |
+ MouseMetaKeyClickMask = 1048584, | |
+ L_META = 55, | |
+ }; | |
+ code = [e keyCode]; | |
m = [e modifierFlags]; | |
+ mouse_meta_key = (m&MouseMetaKeyClickMask && code == L_META); | |
switch([e type]){ | |
case NSKeyDown: | |
@@ -837,7 +846,6 @@ | |
break; | |
} | |
k = c; | |
- code = [e keyCode]; | |
if(code<nelem(keycvt) && keycvt[code]) | |
k = keycvt[code]; | |
if(k==0) | |
@@ -849,9 +857,9 @@ | |
break; | |
case NSFlagsChanged: | |
- if(in.mbuttons || in.kbuttons){ | |
+ if(in.mbuttons || in.kbuttons || mouse_meta_key){ | |
in.kbuttons = 0; | |
- if(m & NSAlternateKeyMask) | |
+ if(m & NSAlternateKeyMask || mouse_meta_key) | |
in.kbuttons |= 2; | |
if(m & NSCommandKeyMask) | |
in.kbuttons |= 4; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment