shithub: riscv

Download patch

ref: 12619cb9a59b292ca68b9eb5543fc6508a5f802b
parent: 3ab76015d7a8113dbf80658e7f6c90e793fd9dd9
author: cinap_lenrek <cinap_lenrek@localhost>
date: Sun Jul 17 14:15:29 EDT 2011

kbdfs: mouse button 2 emulation by changing mouse buttonmap when shift is pressed

--- a/sys/src/9/boot/bootrc
+++ b/sys/src/9/boot/bootrc
@@ -5,7 +5,7 @@
 unmount /root
 
 bind -q '#p' /proc
-for(i in S f k æ t)
+for(i in S f k æ t m)
 	bind -a '#'^$i /dev >/dev/null >[2=1]
 
 # make variables settable by copying them from #ec
--- a/sys/src/cmd/aux/kbdfs/kbdfs.c
+++ b/sys/src/cmd/aux/kbdfs/kbdfs.c
@@ -88,6 +88,7 @@
 int scanfd;
 int ledsfd;
 int consfd;
+int mctlfd;
 
 int kbdopen;
 int consctlopen;
@@ -391,10 +392,21 @@
 			}
 			rb[0] = 'k';
 		}
-		if(rb[0] && kbdopen){
-			s = utfconv(rb, nb+1);
-			if(nbsendp(kbdchan, s) <= 0)
-				free(s);
+		if(rb[0]){
+			if(key.r == Kshift && mctlfd >= 0){
+				if(key.down){
+					fprint(mctlfd, "buttonmap 132");
+				} else {
+					fprint(mctlfd, "swap");
+					fprint(mctlfd, "swap");
+				}
+			}
+
+			if(kbdopen){
+				s = utfconv(rb, nb+1);
+				if(nbsendp(kbdchan, s) <= 0)
+					free(s);
+			}
 		}
 	}
 }
@@ -1259,6 +1271,8 @@
 		fprint(2, "%s: warning: can't open /dev/scancode: %r\n", argv0);
 	if((ledsfd = open("/dev/leds", OWRITE)) < 0)
 		fprint(2, "%s: warning: can't open /dev/leds: %r\n", argv0);
+	if((mctlfd = open("/dev/mousectl", OWRITE)) < 0)
+		fprint(2, "%s: warning: can't open /dev/mousectl: %r\n", argv0);
 
 	if(*argv)
 		if((consfd = open(*argv, OREAD)) < 0)