103 |
|
void C64::c64_ctor1(void) |
104 |
|
{ |
105 |
|
// Initialize joystick variables |
106 |
< |
joyfd[0] = joyfd[1] = -1; |
107 |
< |
joy_minx = joy_miny = 32767; |
108 |
< |
joy_maxx = joy_maxy = -32768; |
106 |
> |
joy_minx[0] = joy_miny[0] = 32767; |
107 |
> |
joy_maxx[0] = joy_maxy[0] = -32768; |
108 |
> |
joy_minx[1] = joy_miny[1] = 32767; |
109 |
> |
joy_maxx[1] = joy_maxy[1] = -32768; |
110 |
|
|
111 |
|
// we need to create a potential GUI subprocess here, because we don't want |
112 |
|
// it to inherit file-descriptors (such as for the audio-device and alike..) |
114 |
|
gui = 0; |
115 |
|
#else |
116 |
|
// try to start up Tk gui. |
117 |
< |
gui = new CmdPipe("wish", "TkGui.tcl"); |
117 |
> |
gui = new CmdPipe("wish", BINDIR "Frodo_GUI.tcl"); |
118 |
|
if (gui) { |
119 |
|
if (gui->fail) { |
120 |
|
delete gui; gui = 0; |
258 |
|
} |
259 |
|
|
260 |
|
|
260 |
– |
/* |
261 |
– |
* Open/close joystick drivers given old and new state of |
262 |
– |
* joystick preferences |
263 |
– |
*/ |
264 |
– |
|
265 |
– |
void C64::open_close_joysticks(bool oldjoy1, bool oldjoy2, bool newjoy1, bool newjoy2) |
266 |
– |
{ |
267 |
– |
#ifdef HAVE_LINUX_JOYSTICK_H |
268 |
– |
if (oldjoy1 != newjoy1) { |
269 |
– |
joy_minx = joy_miny = 32767; // Reset calibration |
270 |
– |
joy_maxx = joy_maxy = -32768; |
271 |
– |
if (newjoy1) { |
272 |
– |
joyfd[0] = open("/dev/js0", O_RDONLY); |
273 |
– |
if (joyfd[0] < 0) |
274 |
– |
fprintf(stderr, "Couldn't open joystick 1\n"); |
275 |
– |
} else { |
276 |
– |
close(joyfd[0]); |
277 |
– |
joyfd[0] = -1; |
278 |
– |
} |
279 |
– |
} |
280 |
– |
|
281 |
– |
if (oldjoy2 != newjoy2) { |
282 |
– |
joy_minx = joy_miny = 32767; // Reset calibration |
283 |
– |
joy_maxx = joy_maxy = -32768; |
284 |
– |
if (newjoy2) { |
285 |
– |
joyfd[1] = open("/dev/js1", O_RDONLY); |
286 |
– |
if (joyfd[1] < 0) |
287 |
– |
fprintf(stderr, "Couldn't open joystick 2\n"); |
288 |
– |
} else { |
289 |
– |
close(joyfd[1]); |
290 |
– |
joyfd[1] = -1; |
291 |
– |
} |
292 |
– |
} |
293 |
– |
#endif |
294 |
– |
} |
295 |
– |
|
296 |
– |
|
297 |
– |
/* |
298 |
– |
* Poll joystick port, return CIA mask |
299 |
– |
*/ |
300 |
– |
|
301 |
– |
uint8 C64::poll_joystick(int port) |
302 |
– |
{ |
303 |
– |
#ifdef HAVE_LINUX_JOYSTICK_H |
304 |
– |
JS_DATA_TYPE js; |
305 |
– |
uint8 j = 0xff; |
306 |
– |
|
307 |
– |
if (joyfd[port] >= 0) { |
308 |
– |
if (read(joyfd[port], &js, JS_RETURN) == JS_RETURN) { |
309 |
– |
if (js.x > joy_maxx) |
310 |
– |
joy_maxx = js.x; |
311 |
– |
if (js.x < joy_minx) |
312 |
– |
joy_minx = js.x; |
313 |
– |
if (js.y > joy_maxy) |
314 |
– |
joy_maxy = js.y; |
315 |
– |
if (js.y < joy_miny) |
316 |
– |
joy_miny = js.y; |
317 |
– |
|
318 |
– |
if (joy_maxx-joy_minx < 100 || joy_maxy-joy_miny < 100) |
319 |
– |
return 0xff; |
320 |
– |
|
321 |
– |
if (js.x < (joy_minx + (joy_maxx-joy_minx)/3)) |
322 |
– |
j &= 0xfb; // Left |
323 |
– |
else if (js.x > (joy_minx + 2*(joy_maxx-joy_minx)/3)) |
324 |
– |
j &= 0xf7; // Right |
325 |
– |
|
326 |
– |
if (js.y < (joy_miny + (joy_maxy-joy_miny)/3)) |
327 |
– |
j &= 0xfe; // Up |
328 |
– |
else if (js.y > (joy_miny + 2*(joy_maxy-joy_miny)/3)) |
329 |
– |
j &= 0xfd; // Down |
330 |
– |
|
331 |
– |
if (js.buttons & 1) |
332 |
– |
j &= 0xef; // Button |
333 |
– |
} |
334 |
– |
} |
335 |
– |
return j; |
336 |
– |
#else |
337 |
– |
return 0xff; |
338 |
– |
#endif |
339 |
– |
} |
340 |
– |
|
341 |
– |
|
261 |
|
/* |
262 |
|
* The emulation's main loop |
263 |
|
*/ |