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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
|
diff -Nur reicast-emulator.orig/core/linux-dist/main.cpp reicast-emulator/core/linux-dist/main.cpp
--- reicast-emulator.orig/core/linux-dist/main.cpp 2015-06-29 21:42:22.674278849 -0300
+++ reicast-emulator/core/linux-dist/main.cpp 2015-06-29 22:08:38.780500620 -0300
@@ -22,6 +22,7 @@
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <X11/Xutil.h>
+ #include <X11/XKBlib.h>
#if !defined(GLES)
#include <GL/gl.h>
@@ -49,6 +50,34 @@
#endif
#define WINDOW_HEIGHT 480
+/*****************************************************************/
+/****************** Configure Controls ***************************/
+/*****************************************************************/
+
+// Use XEV in terminal window to find keycodes to configure buttons.
+#define XANA_UP (25)
+#define XANA_DOWN (39)
+#define XANA_LEFT (38)
+#define XANA_RIGHT (40)
+#define XANA_LT (79)
+#define XANA_RT (81)
+#define XDPAD_UP (31)
+#define XDPAD_DOWN (45)
+#define XDPAD_LEFT (44)
+#define XDPAD_RIGHT (46)
+#define XBTN_Y (80)
+#define XBTN_X (83)
+#define XBTN_B (85)
+#define XBTN_A (84)
+#define XBTN_START (36)
+
+/*******************************************************************/
+
+u8 temp_joyx = 0;
+u8 temp_joyy = 0;
+u8 temp_lt = 0;
+u8 temp_rt = 0;
+
void* x11_win=0,* x11_disp=0;
void* libPvr_GetRenderTarget()
{
@@ -124,8 +153,8 @@
{ Btn_A,Btn_B,Btn_X,Btn_Y,0,0,0,Btn_Start,0,0 };
const u32 JMapAxis_360[MAP_SIZE] =
- { Axis_X,Axis_Y,Axis_LT,0,0,Axis_RT,DPad_Left,DPad_Up,0,0 };
-
+ //{ Axis_X,Axis_Y,Axis_LT,0,0,Axis_RT,DPad_Left,DPad_Up,0,0 };
+ { Axis_X,Axis_Y,0,0,Axis_RT,Axis_LT,DPad_Left,DPad_Up,0,0 };
const u32* JMapBtn=JMapBtn_USB;
const u32* JMapAxis=JMapAxis_USB;
@@ -180,7 +209,7 @@
printf("SDK: Found '%s' joystick with %d axis and %d buttons\n",Name,AxisCount,ButtonCount);
- if (strcmp(Name,"Microsoft X-Box 360 pad")==0)
+ if (strcmp(Name,"Microsoft X-Box 360 pad")==0 || strcmp(Name,"Xbox Gamepad (userspace driver)")==0)
{
JMapBtn=JMapBtn_360;
JMapAxis=JMapAxis_360;
@@ -414,9 +443,20 @@
{
static char key = 0;
- kcode[port]= x11_dc_buttons;
- rt[port]=0;
- lt[port]=0;
+ if (cfgLoadInt("config","usejoypad",0)==1)
+ {
+ HandleJoystick(port);
+ return;
+ }
+ else
+ {
+ kcode[port]= x11_dc_buttons;
+ joyx[0] = temp_joyx;
+ joyy[0] = temp_joyy;
+ lt[0] = temp_lt;
+ rt[0] = temp_rt;
+ return;
+ }
#if defined(TARGET_GCW0) || defined(TARGET_PANDORA)
HandleJoystick(port);
@@ -472,7 +512,13 @@
void os_DoEvents()
{
#if defined(SUPPORT_X11)
- if (x11_win) {
+
+ static bool ana_up = false;
+ static bool ana_down = false;
+ static bool ana_left = false;
+ static bool ana_right = false;
+
+ if (x11_win) {
//Handle X11
XEvent e;
if(XCheckWindowEvent((Display*)x11_disp, (Window)x11_win, KeyPressMask | KeyReleaseMask, &e))
@@ -483,6 +529,103 @@
case KeyPress:
case KeyRelease:
{
+
+ //Detect up press
+ if(e.xkey.keycode == XANA_UP)
+ {
+ if(e.type == KeyPress)
+ {
+ ana_up = true;
+ }
+ else if(e.type == KeyRelease)
+ {
+ ana_up = false;
+ }
+ else
+ {
+ }
+ }
+
+ //Detect down Press
+ if(e.xkey.keycode == XANA_DOWN)
+ {
+ if(e.type == KeyPress)
+ {
+ ana_down = true;
+ }
+ else if(e.type == KeyRelease)
+ {
+ ana_down = false;
+ }
+ else
+ {
+ }
+ }
+
+ //Detect left press
+ if(e.xkey.keycode == XANA_LEFT)
+ {
+ if(e.type == KeyPress)
+ {
+ ana_left = true;
+ }
+ else if(e.type == KeyRelease)
+ {
+ ana_left = false;
+ }
+ else
+ {
+ }
+ }
+
+ //Detect right Press
+ if(e.xkey.keycode == XANA_RIGHT)
+ {
+ if(e.type == KeyPress)
+ {
+ ana_right = true;
+ }
+ else if(e.type == KeyRelease)
+ {
+ ana_right = false;
+ }
+ else
+ {
+ }
+ }
+
+ //detect LT press
+ if (e.xkey.keycode == XANA_LT)
+ {
+ if (e.type == KeyPress)
+ {
+ temp_lt = 255;
+ }
+ else if (e.type == KeyRelease)
+ {
+ temp_lt = 0;
+ }
+ else
+ {
+ }
+ }
+
+ //detect RT press
+ if (e.xkey.keycode == XANA_RT)
+ {
+ if (e.type == KeyPress)
+ {
+ temp_rt = 255;
+ }
+ else if (e.type == KeyRelease)
+ {
+ temp_rt = 0;
+ }
+ else
+ {
+ }
+ }
+
int dc_key = x11_keymap[e.xkey.keycode];
if (e.type == KeyPress)
@@ -494,14 +637,44 @@
}
break;
-
+ default:
{
printf("KEYRELEASE\n");
}
break;
}
- }
+ }
+
+ /* Check analogue control states (up/down) */
+ if((ana_up == true) && (ana_down == false))
+ {
+ temp_joyy = -127;
+ }
+ else if((ana_up == false) && (ana_down == true))
+ {
+ temp_joyy = 127;
+ }
+ else
+ {
+ /* Either both pressed simultaniously or neither pressed */
+ temp_joyy = 0;
+ }
+
+ /* Check analogue control states (left/right) */
+ if((ana_left == true) && (ana_right == false))
+ {
+ temp_joyx = -127;
+ }
+ else if((ana_left == false) && (ana_right == true))
+ {
+ temp_joyx = 127;
+ }
+ else
+ {
+ /* Either both pressed simultaniously or neither pressed */
+ temp_joyx = 0;
+ }
}
#endif
}
@@ -527,6 +700,9 @@
void os_CreateWindow()
{
#if defined(SUPPORT_X11)
+
+ Bool ar_set, ar_supp = false;
+
if (cfgLoadInt("pvr","nox11",0)==0)
{
XInitThreads();
@@ -636,7 +812,8 @@
int height=cfgLoadInt("x11","height", WINDOW_HEIGHT);
#endif
- if (width==-1)
+ //if (width==-1)
+ if (cfgLoadInt("x11","fullscreen",0)==1)
{
width=XDisplayWidth(x11Display,x11Screen);
height=XDisplayHeight(x11Display,x11Screen);
@@ -653,8 +830,21 @@
XMapRaised(x11Display, x11Window);
#else
- XMapWindow(x11Display, x11Window);
-
+
+ if (cfgLoadInt("x11","fullscreen",0)==1)
+ {
+ // fullscreen
+ Atom wmState = XInternAtom(x11Display, "_NET_WM_STATE", False);
+ Atom wmFullscreen = XInternAtom(x11Display, "_NET_WM_STATE_FULLSCREEN", False);
+ XChangeProperty(x11Display, x11Window, wmState, XA_ATOM, 32, PropModeReplace, (unsigned char *)&wmFullscreen, 1);
+ }
+
+ XMapWindow(x11Display, x11Window);
+
+ //This 1 second delay is important. Without it the GLX code can execute before the window
+ //resize completes causing a black border at the top of the screen....
+ sleep(1);
+
#if !defined(GLES)
#define GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091
@@ -690,6 +880,11 @@
//(EGLNativeDisplayType)x11Display;
x11_disp=(void*)x11Display;
x11_win=(void*)x11Window;
+
+ ar_set = XkbSetDetectableAutoRepeat(x11Display, True, &ar_supp);
+ printf("XkbSetDetectableAutoRepeat returns %u, supported = %u\n",ar_set, ar_supp);
+
+
}
else
printf("Not creating X11 window ..\n");
@@ -805,16 +1000,16 @@
#endif
#if defined(SUPPORT_X11)
- x11_keymap[113] = DPad_Left;
- x11_keymap[114] = DPad_Right;
+ x11_keymap[XDPAD_LEFT] = DPad_Left;
+ x11_keymap[XDPAD_RIGHT] = DPad_Right;
- x11_keymap[111] = DPad_Up;
- x11_keymap[116] = DPad_Down;
+ x11_keymap[XDPAD_UP] = DPad_Up;
+ x11_keymap[XDPAD_DOWN] = DPad_Down;
- x11_keymap[52] = Btn_Y;
- x11_keymap[53] = Btn_X;
- x11_keymap[54] = Btn_B;
- x11_keymap[55] = Btn_A;
+ x11_keymap[XBTN_Y] = Btn_Y;
+ x11_keymap[XBTN_X] = Btn_X;
+ x11_keymap[XBTN_B] = Btn_B;
+ x11_keymap[XBTN_A] = Btn_A;
/*
//TODO: Fix sliders
@@ -822,7 +1017,7 @@
x11_keymap[39] = DPad_Down;
*/
- x11_keymap[36] = Btn_Start;
+ x11_keymap[XBTN_START] = Btn_Start;
#endif
printf("Home dir is: %s\n",GetPath("/").c_str());
|