summaryrefslogtreecommitdiffstats
path: root/emulators/vice/files/patch-ab
blob: d464178bdfa27a2e6ff3b3c5aa6e8a175f2cca50 (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
--- ./arch/unix/joystick.c.orig	Sat Mar  7 09:01:51 1998
+++ ./arch/unix/joystick.c	Sat Mar 28 09:19:42 1998
@@ -1,5 +1,5 @@
 /*
- * joystick.c - Joystick support for Linux.
+ * joystick.c - Joystick support for Linux and *BSD
  *
  * Written by
  *  Bernhard Kuhn    (kuhn@eikon.e-technik.tu-muenchen.de)
@@ -7,6 +7,7 @@
  *
  * Patches by
  *  Daniel Sladic    (sladic@eecg.toronto.edu)
+ *  Dave Chapeskie   <dchapes@ddm.on.ca>
  *
  * This file is part of VICE, the Versatile Commodore Emulator.
  * See README for copyright notice.
@@ -32,7 +33,13 @@
 
 #ifdef HAS_JOYSTICK
 
+#ifdef __linux__
 #include <linux/joystick.h>
+#else
+#include <machine/joystick.h>
+#define JS_DATA_TYPE	joystick
+#define JS_RETURN	(sizeof(struct joystick))
+#endif
 #include <unistd.h>
 #include <stdio.h>
 #include <sys/types.h>
@@ -89,7 +96,11 @@
   for(i=0;i<2;i++) {
     
     char* dev;
+#ifdef __linux__
     dev=(i==0)?"/dev/js0":"/dev/js1";
+#else
+    dev=(i==0)?"/dev/joy0":"/dev/joy1";
+#endif
     
     ajoyfd[i]=open(dev,O_RDONLY);
     if (ajoyfd[i] < 0) {
@@ -132,6 +143,7 @@
     }
   }
     
+#ifdef __linux__
   /* open device files for digital joystick */
   for(i=0;i<2;i++) {
     char* dev;
@@ -142,6 +154,7 @@
       fprintf(stderr, "Warning: couldn't open the joystick device %s!\n",dev);
     }
   }
+#endif
 }
 
 void joyclose(void)
@@ -195,7 +208,11 @@
 	  else joy[i] &= ~4;
 	  if (js.x>joyxmax[ajoyport]) joy[i] |= 8;
 	  else joy[i] &= ~8;
+#ifdef __linux__
 	  if(js.buttons) joy[i] |= 16;
+#else
+	  if(js.b1 | js.b2) joy[i] |= 16;
+#endif
 	  else joy[i] &= ~16;
 	}
       }
OpenPOWER on IntegriCloud