summaryrefslogtreecommitdiff
path: root/joystick.h
diff options
context:
space:
mode:
authorFlorian Jung <florian.a.jung@web.de>2012-12-04 00:03:40 +0100
committerFlorian Jung <florian.a.jung@web.de>2012-12-04 00:03:40 +0100
commitdee7d241f8b20262aebe6344b752bb0905ede628 (patch)
tree212f7ead75f05f1755b7292f09aca27f24901b28 /joystick.h
parentb539476ec800eb1d7804fd8e9b73fa9bbb1f63bd (diff)
joystick und xorggrabber ausgelagert
Diffstat (limited to 'joystick.h')
-rw-r--r--joystick.h64
1 files changed, 64 insertions, 0 deletions
diff --git a/joystick.h b/joystick.h
new file mode 100644
index 0000000..2c55a2e
--- /dev/null
+++ b/joystick.h
@@ -0,0 +1,64 @@
+#ifndef __JOYSTICK_H__
+#define __JOYSTICK_H__
+
+#include "os.h"
+
+#ifdef FREEBSD
+typedef union {
+ unsigned int Value;
+ struct {
+ unsigned R_DPAD : 1;
+ unsigned L_DPAD : 1;
+ unsigned D_DPAD : 1;
+ unsigned U_DPAD : 1;
+ unsigned START_BUTTON : 1;
+ unsigned Z_TRIG : 1;
+ unsigned B_BUTTON : 1;
+ unsigned A_BUTTON : 1;
+
+ unsigned R_CBUTTON : 1;
+ unsigned L_CBUTTON : 1;
+ unsigned D_CBUTTON : 1;
+ unsigned U_CBUTTON : 1;
+ unsigned R_TRIG : 1;
+ unsigned L_TRIG : 1;
+ unsigned Reserved1 : 1;
+ unsigned Reserved2 : 1;
+
+ signed X_AXIS : 8;
+ signed Y_AXIS : 8;
+ };
+} BUTTONS;
+
+#endif // FREEBSD
+
+
+class Joystick
+{
+ public:
+ Joystick();
+ ~Joystick();
+ void steer(float dir, float dead_zone=0.0);
+ void throttle(float t);
+ void press_a(bool);
+
+
+ void process();
+ void reset();
+
+ private:
+#ifdef FREEBSD
+ BUTTONS buttons;
+ void send_data();
+ int fifo_fd;
+#endif
+#ifdef LINUX
+ int fd;
+#endif
+
+ float throt;
+ int throttle_cnt;
+
+};
+
+#endif // __JOYSTICK_H__