Merge pull request #6381 from jriwanek-forks/jsfix2

More fixes to joystick axis names, and the throttle axis
This commit is contained in:
Miran Grča
2025-10-21 21:37:34 +02:00
committed by GitHub
2 changed files with 40 additions and 19 deletions

View File

@@ -256,7 +256,7 @@ const joystick_t joystick_ch_flightstick_ch_pedals = {
.button_count = 2,
.pov_count = 0,
.max_joysticks = 1,
.axis_names = { "X axis (Roll)", "Y axis (Pitch)", "Throttle", "Rudder (Yaw)" },
.axis_names = { "X axis (Roll)", "Y axis (Pitch)", "Rudder (Yaw)", "Throttle" },
.button_names = { "Trigger", "Button 2" },
.pov_names = { NULL }
};
@@ -274,7 +274,7 @@ const joystick_t joystick_ch_flightstick_ch_pedals_pro = {
.button_count = 2,
.pov_count = 0,
.max_joysticks = 1,
.axis_names = { "X axis (Roll)", "Y axis (Pitch)", "Right Pedal", "Left Pedal" },
.axis_names = { "X axis (Roll)", "Y axis (Pitch)", "Left Pedal", "Right Pedal" },
.button_names = { "Trigger", "Button 2" },
.pov_names = { NULL }
};
@@ -310,7 +310,7 @@ const joystick_t joystick_ch_flightstick_pro_ch_pedals = {
.button_count = 4,
.pov_count = 1,
.max_joysticks = 1,
.axis_names = { "X axis (Roll)", "Y axis (Pitch)", "Throttle", "Rudder (Yaw)" },
.axis_names = { "X axis (Roll)", "Y axis (Pitch)", "Rudder (Yaw)", "Throttle" },
.button_names = { "Trigger", "Button 2", "Button 3", "Button 4" },
.pov_names = { "POV" }
};
@@ -328,7 +328,7 @@ const joystick_t joystick_ch_flightstick_pro_ch_pedals_pro = {
.button_count = 4,
.pov_count = 1,
.max_joysticks = 1,
.axis_names = { "X axis (Roll)", "Y axis (Pitch)", "Right Pedal", "Left Pedal" },
.axis_names = { "X axis (Roll)", "Y axis (Pitch)", "Left Pedal", "Right Pedal" },
.button_names = { "Trigger", "Button 2", "Button 3", "Button 4" },
.pov_names = { "POV" }
};
@@ -364,7 +364,7 @@ const joystick_t joystick_ch_virtual_pilot_ch_pedals = {
.button_count = 2,
.pov_count = 0,
.max_joysticks = 1,
.axis_names = { "X axis (Roll)", "Y axis (Pitch)", "Throttle", "Rudder (Yaw)" },
.axis_names = { "X axis (Roll)", "Y axis (Pitch)", "Rudder (Yaw)", "Throttle" },
.button_names = { "Button 1", "Button 2" },
.pov_names = { NULL }
};
@@ -382,7 +382,7 @@ const joystick_t joystick_ch_virtual_pilot_ch_pedals_pro = {
.button_count = 2,
.pov_count = 0,
.max_joysticks = 1,
.axis_names = { "X axis (Roll)", "Y axis (Pitch)", "Right Pedal", "Left Pedal" },
.axis_names = { "X axis (Roll)", "Y axis (Pitch)", "Left Pedal", "Right Pedal" },
.button_names = { "Button 1", "Button 2" },
.pov_names = { NULL }
};
@@ -418,7 +418,7 @@ const joystick_t joystick_ch_virtual_pilot_pro_ch_pedals = {
.button_count = 6,
.pov_count = 2,
.max_joysticks = 1,
.axis_names = { "X axis (Roll)", "Y axis (Pitch)", "Throttle", "Rudder (Yaw)" },
.axis_names = { "X axis (Roll)", "Y axis (Pitch)", "Rudder (Yaw)", "Throttle" },
.button_names = { "Button 1", "Button 2", "Button 3", "Button 4", "Button 5", "Button 6" },
.pov_names = { "Right POV", "Left POV" }
};
@@ -436,7 +436,7 @@ const joystick_t joystick_ch_virtual_pilot_pro_ch_pedals_pro = {
.button_count = 6,
.pov_count = 2,
.max_joysticks = 1,
.axis_names = { "X axis (Roll)", "Y axis (Pitch)", "Right Pedal", "Left Pedal" },
.axis_names = { "X axis (Roll)", "Y axis (Pitch)", "Left Pedal", "Right Pedal" },
.button_names = { "Button 1", "Button 2", "Button 3", "Button 4", "Button 5", "Button 6" },
.pov_names = { "Right POV", "Left POV" }
};

View File

@@ -267,9 +267,30 @@ joystick_standard_read_axis_3axis(UNUSED(void *priv), int axis)
return joystick_state[gp][0].axis[0];
case 1:
return joystick_state[gp][0].axis[1];
case 2:
case 2: // Rudder Axis
return joystick_state[gp][0].axis[2];
case 3:
case 3: // Throttle Axis
default:
return 0;
}
}
static int
joystick_standard_read_axis_3axis_throttle(UNUSED(void *priv), int axis)
{
uint8_t gp = 0;
if (!JOYSTICK_PRESENT(gp, 0))
return AXIS_NOT_PRESENT;
switch (axis) {
case 0:
return joystick_state[gp][0].axis[0];
case 1:
return joystick_state[gp][0].axis[1];
case 3: // Throttle Axis
return joystick_state[gp][0].axis[2];
case 2: // Rudder Axis
default:
return 0;
}
@@ -288,10 +309,10 @@ joystick_standard_read_axis_4axis(UNUSED(void *priv), int axis)
return joystick_state[gp][0].axis[0];
case 1:
return joystick_state[gp][0].axis[1];
case 2:
return joystick_state[gp][0].axis[2];
case 3:
case 2: // Rudder Axis
return joystick_state[gp][0].axis[3];
case 3: // Throttle Axis
return joystick_state[gp][0].axis[2];
default:
return 0;
}
@@ -487,7 +508,7 @@ const joystick_t joystick_3axis_2button = {
.close = joystick_standard_close,
.read = joystick_standard_read,
.write = joystick_standard_write,
.read_axis = joystick_standard_read_axis_3axis,
.read_axis = joystick_standard_read_axis_3axis_throttle,
.a0_over = joystick_standard_a0_over,
.axis_count = 3,
.button_count = 2,
@@ -505,7 +526,7 @@ const joystick_t joystick_3axis_3button = {
.close = joystick_standard_close,
.read = joystick_standard_read_3button,
.write = joystick_standard_write,
.read_axis = joystick_standard_read_axis_3axis,
.read_axis = joystick_standard_read_axis_3axis_throttle,
.a0_over = joystick_standard_a0_over,
.axis_count = 3,
.button_count = 3,
@@ -523,7 +544,7 @@ const joystick_t joystick_3axis_4button = {
.close = joystick_standard_close,
.read = joystick_standard_read_4button,
.write = joystick_standard_write,
.read_axis = joystick_standard_read_axis_3axis,
.read_axis = joystick_standard_read_axis_3axis_throttle,
.a0_over = joystick_standard_a0_over,
.axis_count = 3,
.button_count = 4,
@@ -740,7 +761,7 @@ const joystick_t joystick_2button_yoke_throttle = {
.close = joystick_standard_close,
.read = joystick_standard_read,
.write = joystick_standard_write,
.read_axis = joystick_standard_read_axis_3axis,
.read_axis = joystick_standard_read_axis_3axis_throttle,
.a0_over = joystick_standard_a0_over,
.axis_count = 3,
.button_count = 2,
@@ -758,7 +779,7 @@ const joystick_t joystick_3button_yoke_throttle = {
.close = joystick_standard_close,
.read = joystick_standard_read_3button,
.write = joystick_standard_write,
.read_axis = joystick_standard_read_axis_3axis,
.read_axis = joystick_standard_read_axis_3axis_throttle,
.a0_over = joystick_standard_a0_over,
.axis_count = 3,
.button_count = 3,
@@ -776,7 +797,7 @@ const joystick_t joystick_4button_yoke_throttle = {
.close = joystick_standard_close,
.read = joystick_standard_read_4button,
.write = joystick_standard_write,
.read_axis = joystick_standard_read_axis_3axis,
.read_axis = joystick_standard_read_axis_3axis_throttle,
.a0_over = joystick_standard_a0_over,
.axis_count = 3,
.button_count = 4,