shithub: qk2

Download patch

ref: 468277a38c028f5f00c89379c1cc705d127e9e84
parent: cc89ba80b3f821fdff89ff66f3541a17959e7ea2
author: Konstantinn Bonnet <qu7uux@gmail.com>
date: Thu Mar 19 19:36:03 EDT 2015

recognize mwheelup, mwheeldown and swap middle and right buttons

in quake 2, as in many other games, mouse2 is the right button, and mouse3 is the
middle one. this preserves compatibility for cfg's and such.

--- a/client/keys.h
+++ b/client/keys.h
@@ -72,62 +72,61 @@
 #define K_KP_MINUS		173
 #define K_KP_PLUS		174
 
-#define K_PAUSE			255
-
 //
 // mouse buttons generate virtual keys
 //
 #define	K_MOUSE1		200
-#define	K_MOUSE2		201
-#define	K_MOUSE3		202
+#define	K_MOUSE3		201
+#define	K_MOUSE2		202
+#define K_MWHEELUP		203
+#define K_MWHEELDOWN		204
 
 //
 // joystick buttons
 //
-#define	K_JOY1			203
-#define	K_JOY2			204
-#define	K_JOY3			205
-#define	K_JOY4			206
+#define	K_JOY1			205
+#define	K_JOY2			206
+#define	K_JOY3			207
+#define	K_JOY4			208
 
 //
 // aux keys are for multi-buttoned joysticks to generate so they can use
 // the normal binding process
 //
-#define	K_AUX1			207
-#define	K_AUX2			208
-#define	K_AUX3			209
-#define	K_AUX4			210
-#define	K_AUX5			211
-#define	K_AUX6			212
-#define	K_AUX7			213
-#define	K_AUX8			214
-#define	K_AUX9			215
-#define	K_AUX10			216
-#define	K_AUX11			217
-#define	K_AUX12			218
-#define	K_AUX13			219
-#define	K_AUX14			220
-#define	K_AUX15			221
-#define	K_AUX16			222
-#define	K_AUX17			223
-#define	K_AUX18			224
-#define	K_AUX19			225
-#define	K_AUX20			226
-#define	K_AUX21			227
-#define	K_AUX22			228
-#define	K_AUX23			229
-#define	K_AUX24			230
-#define	K_AUX25			231
-#define	K_AUX26			232
-#define	K_AUX27			233
-#define	K_AUX28			234
-#define	K_AUX29			235
-#define	K_AUX30			236
-#define	K_AUX31			237
-#define	K_AUX32			238
+#define	K_AUX1			209
+#define	K_AUX2			210
+#define	K_AUX3			211
+#define	K_AUX4			212
+#define	K_AUX5			213
+#define	K_AUX6			214
+#define	K_AUX7			215
+#define	K_AUX8			216
+#define	K_AUX9			217
+#define	K_AUX10			218
+#define	K_AUX11			219
+#define	K_AUX12			220
+#define	K_AUX13			221
+#define	K_AUX14			222
+#define	K_AUX15			223
+#define	K_AUX16			224
+#define	K_AUX17			225
+#define	K_AUX18			226
+#define	K_AUX19			227
+#define	K_AUX20			228
+#define	K_AUX21			229
+#define	K_AUX22			230
+#define	K_AUX23			231
+#define	K_AUX24			232
+#define	K_AUX25			233
+#define	K_AUX26			234
+#define	K_AUX27			235
+#define	K_AUX28			236
+#define	K_AUX29			237
+#define	K_AUX30			238
+#define	K_AUX31			239
+#define	K_AUX32			240
 
-#define K_MWHEELDOWN	239
-#define K_MWHEELUP		240
+#define K_PAUSE			255
 
 extern char		*keybindings[256];
 extern	int		key_repeats[256];
--- a/plan9/in_9.c
+++ b/plan9/in_9.c
@@ -66,7 +66,7 @@
 
 	if(!mouseon)
 		return;
-	for(i = 0; i < 3; i++){
+	for(i = 0; i < 5; i++){
 		if(mbtn & 1<<i && ~oldmbtn & 1<<i)
 			Key_Event(K_MOUSE1+i, true, Sys_Milliseconds());
 		if(~mbtn & 1<<i && oldmbtn & 1<<i)
@@ -243,7 +243,7 @@
 
 void mproc (void *)
 {
-	int b, n, nerr = 0, fd;
+	int n, nerr = 0, fd;
 	char buf[1+5*12];
 	int x, y;
 
@@ -268,9 +268,7 @@
 
 			x = atoi(buf+1+0*12) - center.x;
 			y = atoi(buf+1+1*12) - center.y;
-			b = atoi(buf+1+2*12);
-
-			mbtn = b&1 | (b&2)<<1 | (b&4)>>1;
+			mbtn = atoi(buf+1+2*12);
 			dx += x;
 			dy += y;
 			if(x != 0 || y != 0)