Skip to content

Commit af01ffb

Browse files
authored
Merge pull request 86Box#5389 from lemondrops/pedals
Add variants of the CH Flightstick Pro and Thrustmaster FCS with rudder pedals attached
2 parents e44a347 + 0a5fa0d commit af01ffb

File tree

4 files changed

+102
-12
lines changed

4 files changed

+102
-12
lines changed

src/game/gameport.c

+14-12
Original file line numberDiff line numberDiff line change
@@ -88,18 +88,20 @@ static const joystick_if_t joystick_none = {
8888
static const struct {
8989
const joystick_if_t *joystick;
9090
} joysticks[] = {
91-
{ &joystick_none },
92-
{ &joystick_2axis_2button },
93-
{ &joystick_2axis_4button },
94-
{ &joystick_2axis_6button },
95-
{ &joystick_2axis_8button },
96-
{ &joystick_3axis_2button },
97-
{ &joystick_3axis_4button },
98-
{ &joystick_4axis_4button },
99-
{ &joystick_ch_flightstick_pro },
100-
{ &joystick_sw_pad },
101-
{ &joystick_tm_fcs },
102-
{ NULL }
91+
{ &joystick_none },
92+
{ &joystick_2axis_2button },
93+
{ &joystick_2axis_4button },
94+
{ &joystick_2axis_6button },
95+
{ &joystick_2axis_8button },
96+
{ &joystick_3axis_2button },
97+
{ &joystick_3axis_4button },
98+
{ &joystick_4axis_4button },
99+
{ &joystick_ch_flightstick_pro },
100+
{ &joystick_ch_flightstick_pro_ch_pedals },
101+
{ &joystick_sw_pad },
102+
{ &joystick_tm_fcs },
103+
{ &joystick_tm_fcs_rcs },
104+
{ NULL }
103105
};
104106

105107
static joystick_instance_t *joystick_instance[GAMEPORT_MAX] = { NULL, NULL };

src/game/joystick_ch_flightstick_pro.c

+38
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,26 @@ ch_flightstick_pro_read_axis(UNUSED(void *priv), int axis)
112112
}
113113
}
114114

115+
static int
116+
ch_flightstick_pro_ch_pedals_read_axis(UNUSED(void *priv), int axis)
117+
{
118+
if (!JOYSTICK_PRESENT(0, 0))
119+
return AXIS_NOT_PRESENT;
120+
121+
switch (axis) {
122+
case 0:
123+
return joystick_state[0][0].axis[0];
124+
case 1:
125+
return joystick_state[0][0].axis[1];
126+
case 2:
127+
return joystick_state[0][0].axis[3];
128+
case 3:
129+
return joystick_state[0][0].axis[2];
130+
default:
131+
return 0;
132+
}
133+
}
134+
115135
static void
116136
ch_flightstick_pro_a0_over(UNUSED(void *priv))
117137
{
@@ -135,3 +155,21 @@ const joystick_if_t joystick_ch_flightstick_pro = {
135155
.button_names = { "Button 1", "Button 2", "Button 3", "Button 4" },
136156
.pov_names = { "POV" }
137157
};
158+
159+
const joystick_if_t joystick_ch_flightstick_pro_ch_pedals = {
160+
.name = "CH Flightstick Pro + CH Pedals",
161+
.internal_name = "ch_flightstick_pro_ch_pedals",
162+
.init = ch_flightstick_pro_init,
163+
.close = ch_flightstick_pro_close,
164+
.read = ch_flightstick_pro_read,
165+
.write = ch_flightstick_pro_write,
166+
.read_axis = ch_flightstick_pro_ch_pedals_read_axis,
167+
.a0_over = ch_flightstick_pro_a0_over,
168+
.axis_count = 4,
169+
.button_count = 4,
170+
.pov_count = 1,
171+
.max_joysticks = 1,
172+
.axis_names = { "X axis", "Y axis", "Throttle", "Rudder" },
173+
.button_names = { "Button 1", "Button 2", "Button 3", "Button 4" },
174+
.pov_names = { "POV" }
175+
};

src/game/joystick_tm_fcs.c

+48
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,36 @@ tm_fcs_read_axis(UNUSED(void *priv), int axis)
112112
}
113113
}
114114

115+
static int
116+
tm_fcs_rcs_read_axis(UNUSED(void *priv), int axis)
117+
{
118+
if (!JOYSTICK_PRESENT(0, 0))
119+
return AXIS_NOT_PRESENT;
120+
121+
switch (axis) {
122+
case 0:
123+
return joystick_state[0][0].axis[0];
124+
case 1:
125+
return joystick_state[0][0].axis[1];
126+
case 2:
127+
return joystick_state[0][0].axis[2];
128+
case 3:
129+
if (joystick_state[0][0].pov[0] == -1)
130+
return 32767;
131+
if (joystick_state[0][0].pov[0] > 315 || joystick_state[0][0].pov[0] < 45)
132+
return -32768;
133+
if (joystick_state[0][0].pov[0] >= 45 && joystick_state[0][0].pov[0] < 135)
134+
return -16384;
135+
if (joystick_state[0][0].pov[0] >= 135 && joystick_state[0][0].pov[0] < 225)
136+
return 0;
137+
if (joystick_state[0][0].pov[0] >= 225 && joystick_state[0][0].pov[0] < 315)
138+
return 16384;
139+
return 0;
140+
default:
141+
return 0;
142+
}
143+
}
144+
115145
static void
116146
tm_fcs_a0_over(UNUSED(void *priv))
117147
{
@@ -135,3 +165,21 @@ const joystick_if_t joystick_tm_fcs = {
135165
.button_names = { "Button 1", "Button 2", "Button 3", "Button 4" },
136166
.pov_names = { "POV" }
137167
};
168+
169+
const joystick_if_t joystick_tm_fcs_rcs = {
170+
.name = "Thrustmaster FCS + Rudder Control System",
171+
.internal_name = "thrustmaster_fcs_rcs",
172+
.init = tm_fcs_init,
173+
.close = tm_fcs_close,
174+
.read = tm_fcs_read,
175+
.write = tm_fcs_write,
176+
.read_axis = tm_fcs_rcs_read_axis,
177+
.a0_over = tm_fcs_a0_over,
178+
.axis_count = 3,
179+
.button_count = 4,
180+
.pov_count = 1,
181+
.max_joysticks = 1,
182+
.axis_names = { "X axis", "Y axis", "Rudder" },
183+
.button_names = { "Button 1", "Button 2", "Button 3", "Button 4" },
184+
.pov_names = { "POV" }
185+
};

src/include/86box/gameport.h

+2
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,12 @@ extern const joystick_if_t joystick_2axis_6button;
179179
extern const joystick_if_t joystick_2axis_8button;
180180

181181
extern const joystick_if_t joystick_ch_flightstick_pro;
182+
extern const joystick_if_t joystick_ch_flightstick_pro_ch_pedals;
182183

183184
extern const joystick_if_t joystick_sw_pad;
184185

185186
extern const joystick_if_t joystick_tm_fcs;
187+
extern const joystick_if_t joystick_tm_fcs_rcs;
186188

187189
extern int gameport_available(int);
188190
extern int gameport_has_config(int);

0 commit comments

Comments
 (0)