More Joystick/gameport related changes (#6285)

Fix a warning, correct a device name, formatting
This commit is contained in:
Jasmine Iwanek
2025-10-06 11:17:30 -04:00
committed by GitHub
parent ec86595d5d
commit 3f5b88ac8f
4 changed files with 18 additions and 12 deletions

View File

@@ -100,7 +100,7 @@ static const struct {
{ &joystick_3axis_2button },
{ &joystick_2button_yoke_throttle },
{ &joystick_3axis_4button },
{ &joystick_win95_steering_wheel },
{ &joystick_steering_wheel_4_button },
{ &joystick_4button_yoke_throttle },
{ &joystick_4axis_4button },
{ &joystick_ch_flightstick_pro },

View File

@@ -10,9 +10,11 @@
*
* Authors: Miran Grca, <mgrca8@gmail.com>
* Sarah Walker, <https://pcem-emulator.co.uk/>
* Jasmine Iwanek, <jriwanek@gmail.com>
*
* Copyright 2016-2018 Miran Grca.
* Copyright 2008-2018 Sarah Walker.
* Copyright 2021-2025 Jasmine Iwanek.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -70,14 +72,19 @@ ch_flightstick_pro_read(UNUSED(void *priv))
ret &= ~0x40;
if (joystick_state[gp][0].button[3])
ret &= ~0x80;
// POV Hat
if (joystick_state[gp][0].pov[0] != -1) {
if (joystick_state[gp][0].pov[0] > 315 || joystick_state[gp][0].pov[0] < 45)
// POV Up
if ((joystick_state[gp][0].pov[0] > 315) || (joystick_state[gp][0].pov[0] < 45))
ret &= ~0xf0;
else if (joystick_state[gp][0].pov[0] >= 45 && joystick_state[gp][0].pov[0] < 135)
// POV Right
else if ((joystick_state[gp][0].pov[0]) >= 45 && (joystick_state[gp][0].pov[0] < 135))
ret &= ~0xb0;
else if (joystick_state[gp][0].pov[0] >= 135 && joystick_state[gp][0].pov[0] < 225)
// POV Down
else if ((joystick_state[gp][0].pov[0]) >= 135 && (joystick_state[gp][0].pov[0] < 225))
ret &= ~0x70;
else if (joystick_state[gp][0].pov[0] >= 225 && joystick_state[gp][0].pov[0] < 315)
// POV Left
else if ((joystick_state[gp][0].pov[0]) >= 225 && (joystick_state[gp][0].pov[0] < 315))
ret &= ~0x30;
}
}
@@ -94,7 +101,7 @@ ch_flightstick_pro_write(UNUSED(void *priv))
static int
ch_flightstick_pro_read_axis(UNUSED(void *priv), int axis)
{
uint8_t gp = 0;
uint8_t gp = 0;
if (!JOYSTICK_PRESENT(gp, 0))
return AXIS_NOT_PRESENT;
@@ -116,7 +123,7 @@ ch_flightstick_pro_read_axis(UNUSED(void *priv), int axis)
static int
ch_flightstick_pro_ch_pedals_read_axis(UNUSED(void *priv), int axis)
{
uint8_t gp = 0;
uint8_t gp = 0;
if (!JOYSTICK_PRESENT(gp, 0))
return AXIS_NOT_PRESENT;

View File

@@ -193,7 +193,6 @@ static int
joystick_standard_read_axis_3axis(UNUSED(void *priv), int axis)
{
uint8_t gp = 0;
uint8_t js = 0;
if (!JOYSTICK_PRESENT(gp, 0))
return AXIS_NOT_PRESENT;
@@ -470,9 +469,9 @@ const joystick_t joystick_4button_yoke_throttle = {
.pov_names = { NULL }
};
const joystick_t joystick_win95_steering_wheel = {
.name = "Win95 Steering Wheel (3-axis, 4-button)",
.internal_name = "win95_steering_wheel",
const joystick_t joystick_steering_wheel_4_button = {
.name = "Steering Wheel (3-axis, 4-button)",
.internal_name = "steering_wheel_4_button",
.init = joystick_standard_init,
.close = joystick_standard_close,
.read = joystick_standard_read_4button,

View File

@@ -182,7 +182,7 @@ extern const joystick_t joystick_3axis_2button;
extern const joystick_t joystick_2button_yoke_throttle;
extern const joystick_t joystick_3axis_4button;
extern const joystick_t joystick_4button_yoke_throttle;
extern const joystick_t joystick_win95_steering_wheel;
extern const joystick_t joystick_steering_wheel_4_button;
extern const joystick_t joystick_4axis_4button;
extern const joystick_t joystick_2axis_6button;
extern const joystick_t joystick_2axis_8button;