Add variants of the CH Flightstick Pro and Thrustmaster FCS

with rudder pedals (CH Pedals and Thrustmaster RCS respectively) attached
This commit is contained in:
Alexander Babikov
2025-01-18 15:47:41 +05:00
parent 4e4ad8913c
commit 0a5fa0da39
4 changed files with 102 additions and 12 deletions

View File

@@ -112,6 +112,36 @@ tm_fcs_read_axis(UNUSED(void *priv), int axis)
}
}
static int
tm_fcs_rcs_read_axis(UNUSED(void *priv), int axis)
{
if (!JOYSTICK_PRESENT(0, 0))
return AXIS_NOT_PRESENT;
switch (axis) {
case 0:
return joystick_state[0][0].axis[0];
case 1:
return joystick_state[0][0].axis[1];
case 2:
return joystick_state[0][0].axis[2];
case 3:
if (joystick_state[0][0].pov[0] == -1)
return 32767;
if (joystick_state[0][0].pov[0] > 315 || joystick_state[0][0].pov[0] < 45)
return -32768;
if (joystick_state[0][0].pov[0] >= 45 && joystick_state[0][0].pov[0] < 135)
return -16384;
if (joystick_state[0][0].pov[0] >= 135 && joystick_state[0][0].pov[0] < 225)
return 0;
if (joystick_state[0][0].pov[0] >= 225 && joystick_state[0][0].pov[0] < 315)
return 16384;
return 0;
default:
return 0;
}
}
static void
tm_fcs_a0_over(UNUSED(void *priv))
{
@@ -135,3 +165,21 @@ const joystick_if_t joystick_tm_fcs = {
.button_names = { "Button 1", "Button 2", "Button 3", "Button 4" },
.pov_names = { "POV" }
};
const joystick_if_t joystick_tm_fcs_rcs = {
.name = "Thrustmaster FCS + Rudder Control System",
.internal_name = "thrustmaster_fcs_rcs",
.init = tm_fcs_init,
.close = tm_fcs_close,
.read = tm_fcs_read,
.write = tm_fcs_write,
.read_axis = tm_fcs_rcs_read_axis,
.a0_over = tm_fcs_a0_over,
.axis_count = 3,
.button_count = 4,
.pov_count = 1,
.max_joysticks = 1,
.axis_names = { "X axis", "Y axis", "Rudder" },
.button_names = { "Button 1", "Button 2", "Button 3", "Button 4" },
.pov_names = { "POV" }
};