From 814d54494ff180214cc4c5a6f2d3f8dcf3cc2856 Mon Sep 17 00:00:00 2001 From: OBattler Date: Sat, 23 Jul 2016 01:50:18 +0200 Subject: [PATCH] Added the four Joystick-related files I forgot. --- src/joystick_ch_flightstick_pro.c | 89 +++++++++++++++++++++++++++++++ src/joystick_ch_flightstick_pro.h | 1 + src/joystick_tm_fcs.c | 88 ++++++++++++++++++++++++++++++ src/joystick_tm_fcs.h | 1 + 4 files changed, 179 insertions(+) create mode 100644 src/joystick_ch_flightstick_pro.c create mode 100644 src/joystick_ch_flightstick_pro.h create mode 100644 src/joystick_tm_fcs.c create mode 100644 src/joystick_tm_fcs.h diff --git a/src/joystick_ch_flightstick_pro.c b/src/joystick_ch_flightstick_pro.c new file mode 100644 index 000000000..3ced21653 --- /dev/null +++ b/src/joystick_ch_flightstick_pro.c @@ -0,0 +1,89 @@ +#include +#include "ibm.h" +#include "device.h" +#include "timer.h" +#include "gameport.h" +#include "joystick_standard.h" +#include "plat-joystick.h" + +static void *ch_flightstick_pro_init() +{ +} + +static void ch_flightstick_pro_close(void *p) +{ +} + +static uint8_t ch_flightstick_pro_read(void *p) +{ + uint8_t ret = 0xf0; + + if (JOYSTICK_PRESENT(0)) + { + if (joystick_state[0].button[0]) + ret &= ~0x10; + if (joystick_state[0].button[1]) + ret &= ~0x20; + if (joystick_state[0].button[2]) + ret &= ~0x40; + if (joystick_state[0].button[3]) + ret &= ~0x80; + if (joystick_state[0].pov[0] != -1) + { + if (joystick_state[0].pov[0] > 315 || joystick_state[0].pov[0] < 45) + ret &= ~0xf0; + else if (joystick_state[0].pov[0] >= 45 && joystick_state[0].pov[0] < 135) + ret &= ~0xb0; + else if (joystick_state[0].pov[0] >= 135 && joystick_state[0].pov[0] < 225) + ret &= ~0x70; + else if (joystick_state[0].pov[0] >= 225 && joystick_state[0].pov[0] < 315) + ret &= ~0x30; + } + } + + return ret; +} + +static void ch_flightstick_pro_write(void *p) +{ +} + +static int ch_flightstick_pro_read_axis(void *p, int axis) +{ + if (!JOYSTICK_PRESENT(0)) + return AXIS_NOT_PRESENT; + + switch (axis) + { + case 0: + return joystick_state[0].axis[0]; + case 1: + return joystick_state[0].axis[1]; + case 2: + return 0; + case 3: + return joystick_state[0].axis[2]; + } +} + +static void ch_flightstick_pro_a0_over(void *p) +{ +} + +joystick_if_t joystick_ch_flightstick_pro = +{ + .name = "CH Flightstick Pro", + .init = ch_flightstick_pro_init, + .close = ch_flightstick_pro_close, + .read = ch_flightstick_pro_read, + .write = ch_flightstick_pro_write, + .read_axis = ch_flightstick_pro_read_axis, + .a0_over = ch_flightstick_pro_a0_over, + .max_joysticks = 1, + .axis_count = 3, + .button_count = 4, + .pov_count = 1, + .axis_names = {"X axis", "Y axis", "Throttle"}, + .button_names = {"Button 1", "Button 2", "Button 3", "Button 4"}, + .pov_names = {"POV"} +}; diff --git a/src/joystick_ch_flightstick_pro.h b/src/joystick_ch_flightstick_pro.h new file mode 100644 index 000000000..291cb0bfa --- /dev/null +++ b/src/joystick_ch_flightstick_pro.h @@ -0,0 +1 @@ +extern joystick_if_t joystick_ch_flightstick_pro; diff --git a/src/joystick_tm_fcs.c b/src/joystick_tm_fcs.c new file mode 100644 index 000000000..02c153e49 --- /dev/null +++ b/src/joystick_tm_fcs.c @@ -0,0 +1,88 @@ +#include +#include "ibm.h" +#include "device.h" +#include "timer.h" +#include "gameport.h" +#include "joystick_standard.h" +#include "plat-joystick.h" + +static void *tm_fcs_init() +{ +} + +static void tm_fcs_close(void *p) +{ +} + +static uint8_t tm_fcs_read(void *p) +{ + uint8_t ret = 0xf0; + + if (JOYSTICK_PRESENT(0)) + { + if (joystick_state[0].button[0]) + ret &= ~0x10; + if (joystick_state[0].button[1]) + ret &= ~0x20; + if (joystick_state[0].button[2]) + ret &= ~0x40; + if (joystick_state[0].button[3]) + ret &= ~0x80; + } + + return ret; +} + +static void tm_fcs_write(void *p) +{ +} + +static int tm_fcs_read_axis(void *p, int axis) +{ + if (!JOYSTICK_PRESENT(0)) + return AXIS_NOT_PRESENT; + + switch (axis) + { + case 0: + return joystick_state[0].axis[0]; + case 1: + return joystick_state[0].axis[1]; + case 2: + return 0; + case 3: + if (joystick_state[0].pov[0] == -1) + return 32767; + if (joystick_state[0].pov[0] > 315 || joystick_state[0].pov[0] < 45) + return -32768; + if (joystick_state[0].pov[0] >= 45 && joystick_state[0].pov[0] < 135) + return -16384; + if (joystick_state[0].pov[0] >= 135 && joystick_state[0].pov[0] < 225) + return 0; + if (joystick_state[0].pov[0] >= 225 && joystick_state[0].pov[0] < 315) + return 16384; + return 0; + } +} + +static void tm_fcs_a0_over(void *p) +{ +} + +joystick_if_t joystick_tm_fcs = +{ + .name = "Thrustmaster Flight Control System", + .init = tm_fcs_init, + .close = tm_fcs_close, + .read = tm_fcs_read, + .write = tm_fcs_write, + .read_axis = tm_fcs_read_axis, + .a0_over = tm_fcs_a0_over, + .max_joysticks = 1, + .axis_count = 2, + .button_count = 4, + .pov_count = 1, + .axis_names = {"X axis", "Y axis"}, + .button_names = {"Button 1", "Button 2", "Button 3", "Button 4"}, + .pov_names = {"POV"} +}; diff --git a/src/joystick_tm_fcs.h b/src/joystick_tm_fcs.h new file mode 100644 index 000000000..9759cf897 --- /dev/null +++ b/src/joystick_tm_fcs.h @@ -0,0 +1 @@ +extern joystick_if_t joystick_tm_fcs;