summaryrefslogtreecommitdiff
path: root/pcr/reicast-git/fix-x11-keyboard-support.patch
blob: 1c147c5e200dc2edc6afb56abaa769c205f67ae3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
diff -Nur a/core/linux-dist/x11.cpp b/core/linux-dist/x11.cpp
--- a/core/linux-dist/x11.cpp	2016-05-18 07:26:32.038142723 -0300
+++ b/core/linux-dist/x11.cpp	2016-05-18 11:50:02.625273688 -0300
@@ -3,6 +3,7 @@
 #include <X11/Xlib.h>
 #include <X11/Xatom.h>
 #include <X11/Xutil.h>
+#include <X11/XKBlib.h>
 
 #if !defined(GLES)
 	#include <GL/gl.h>
@@ -99,6 +100,114 @@
 					else
 					{
 						int dc_key = x11_keymap[e.xkey.keycode];
+						static bool ana_up = false;
+						static bool ana_down = false;
+						static bool ana_left = false;
+						static bool ana_right = false;
+						//Detect up press
+						if(e.xkey.keycode == 25)
+						{
+							if(e.type == KeyPress)
+							{
+								ana_up = true;
+							}
+							else if(e.type == KeyRelease)
+							{
+								ana_up = false;
+							}
+							else
+							{
+							}
+						}
+						//Detect down press
+						if(e.xkey.keycode == 39)
+						{
+							if(e.type == KeyPress)
+							{
+								ana_down = true;
+							}
+							else if(e.type == KeyRelease)
+							{
+								ana_down = false;
+							}
+							else
+							{
+							}
+						}
+						//Detect left press
+						if(e.xkey.keycode == 38)
+						{
+							if(e.type == KeyPress)
+							{
+								ana_left = true;
+							}
+							else if(e.type == KeyRelease)
+							{
+								ana_left = false;
+							}
+							else
+							{
+							}
+						}
+						//Detect right press
+						if(e.xkey.keycode == 40)
+						{
+							if(e.type == KeyPress)
+							{
+								ana_right = true;
+							}
+							else if(e.type == KeyRelease)
+							{
+								ana_right = false;
+							}
+							else
+							{
+							}
+						}
+						/* Check analogue control states (up/down) */
+						if((ana_up == true) && (ana_down == false))
+						{
+							joyy[0] = -127;
+						}
+						else if((ana_up == false) && (ana_down == true))
+						{
+							joyy[0] = 127;
+						}
+						else
+						{
+							/* Either both pressed simultaniously or neither pressed */
+							joyy[0] = 0;
+						}
+						/* Check analogue control states (left/right) */
+						if((ana_left == true) && (ana_right == false))
+						{
+							joyx[0] = -127;
+						}
+						else if((ana_left == false) && (ana_right == true))
+						{
+							joyx[0] = 127;
+						}
+						else
+						{
+							/* Either both pressed simultaniously or neither pressed */
+							joyx[0] = 0;
+						}
+						if (e.xkey.keycode == 24)
+						{
+							// Left shoulder button pressed (lt)
+							if (e.type == KeyPress)
+								lt[0] = 255;
+							else
+								lt[0] = 0;
+						}
+						else if (e.xkey.keycode == 26)
+						{
+							// Right shoulder button pressed (rt)
+							if (e.type == KeyPress)
+								rt[0] = 255;
+							else
+								rt[0] = 0;
+						}
 						if (e.type == KeyPress)
 						{
 							kcode[0] &= ~dc_key;
@@ -123,15 +232,14 @@
 	x11_keymap[111] = DC_DPAD_UP;
 	x11_keymap[116] = DC_DPAD_DOWN;
 
+	x11_keymap[52] = DC_BTN_Y;
 	x11_keymap[53] = DC_BTN_X;
 	x11_keymap[54] = DC_BTN_B;
 	x11_keymap[55] = DC_BTN_A;
 
-	/*
-	//TODO: Fix sliders
-	x11_keymap[38] = DPad_Down;
-	x11_keymap[39] = DPad_Down;
-	*/
+	x11_keymap[10] = DC_BTN_Z;
+	x11_keymap[11] = DC_BTN_C;
+	x11_keymap[12] = DC_BTN_D;
 
 	x11_keymap[36] = DC_BTN_START;
 
@@ -140,6 +248,9 @@
 
 void x11_window_create()
 {
+
+	Bool ar_set, ar_supp = false;
+
 	if (cfgLoadInt("pvr", "nox11", 0) == 0)
 	{
 		XInitThreads();
@@ -302,6 +413,9 @@
 		x11_disp = (void*)x11Display;
 		x11_win = (void*)x11Window;
 		x11_vis = (void*)x11Visual->visual;
+
+		ar_set = XkbSetDetectableAutoRepeat(x11Display, True, &ar_supp);
+	printf("XkbSetDetectableAutoRepeat returns %u, supported = %u\n", ar_set, ar_supp);
 	}
 	else
 	{