Merge pull request #5818 from jriwanek-forks/jsfix

Joystick/Gameport improvements part 1
This commit is contained in:
Miran Grča
2025-07-23 07:51:34 +02:00
committed by GitHub
18 changed files with 150 additions and 140 deletions

View File

@@ -61,13 +61,13 @@ typedef struct _joystick_instance_ {
uint8_t state; uint8_t state;
g_axis_t axis[4]; g_axis_t axis[4];
const joystick_if_t *intf; const joystick_t *intf;
void *dat; void *dat;
} joystick_instance_t; } joystick_instance_t;
int joystick_type = JS_TYPE_NONE; int joystick_type = JS_TYPE_NONE;
static const joystick_if_t joystick_none = { static const joystick_t joystick_none = {
.name = "None", .name = "None",
.internal_name = "none", .internal_name = "none",
.init = NULL, .init = NULL,
@@ -86,7 +86,7 @@ static const joystick_if_t joystick_none = {
}; };
static const struct { static const struct {
const joystick_if_t *joystick; const joystick_t *joystick;
} joysticks[] = { } joysticks[] = {
{ &joystick_none }, { &joystick_none },
{ &joystick_2axis_2button }, { &joystick_2axis_2button },
@@ -100,7 +100,7 @@ static const struct {
{ &joystick_3axis_2button }, { &joystick_3axis_2button },
{ &joystick_2button_yoke_throttle }, { &joystick_2button_yoke_throttle },
{ &joystick_3axis_4button }, { &joystick_3axis_4button },
{ &joystick_win95_steering_wheel }, // Temp { &joystick_win95_steering_wheel },
{ &joystick_4button_yoke_throttle }, { &joystick_4button_yoke_throttle },
{ &joystick_4axis_4button }, { &joystick_4axis_4button },
{ &joystick_ch_flightstick_pro }, { &joystick_ch_flightstick_pro },
@@ -114,24 +114,39 @@ static const struct {
static joystick_instance_t *joystick_instance[GAMEPORT_MAX] = { NULL, NULL }; static joystick_instance_t *joystick_instance[GAMEPORT_MAX] = { NULL, NULL };
static uint8_t gameport_pnp_rom[] = { static uint8_t gameport_pnp_rom[] = {
0x09, 0xf8, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, /* BOX0002, dummy checksum (filled in by isapnp_add_card) */ /* BOX0002, serial 0, dummy checksum (filled in by isapnp_add_card) */
0x0a, 0x10, 0x10, /* PnP version 1.0, vendor version 1.0 */ 0x09, 0xf8, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
0x82, 0x09, 0x00, 'G', 'a', 'm', 'e', ' ', 'P', 'o', 'r', 't', /* ANSI identifier */ /* PnP version 1.0, vendor version 1.0 */
0x0a, 0x10, 0x10,
/* ANSI identifier */
0x82, 0x09, 0x00, 'G', 'a', 'm', 'e', ' ', 'P', 'o', 'r', 't',
0x15, 0x09, 0xf8, 0x00, 0x02, 0x01, /* logical device BOX0002, can participate in boot */ /* Logical device BOX0002, can participate in boot */
0x1c, 0x41, 0xd0, 0xb0, 0x2f, /* compatible device PNPB02F */ 0x15, 0x09, 0xf8, 0x00, 0x02, 0x01,
0x31, 0x00, /* start dependent functions, preferred */ /* Compatible device PNPB02F */
0x47, 0x01, 0x00, 0x02, 0x00, 0x02, 0x08, 0x08, /* I/O 0x200, decodes 16-bit, 8-byte alignment, 8 addresses */ 0x1c, 0x41, 0xd0, 0xb0, 0x2f,
0x30, /* start dependent functions, acceptable */ /* Start dependent functions, preferred */
0x47, 0x01, 0x08, 0x02, 0x08, 0x02, 0x08, 0x08, /* I/O 0x208, decodes 16-bit, 8-byte alignment, 8 addresses */ 0x31, 0x00,
0x31, 0x02, /* start dependent functions, sub-optimal */ /* I/O 0x200, decodes 16-bit, 8-byte alignment, 8 addresses */
0x47, 0x01, 0x00, 0x01, 0xf8, 0xff, 0x08, 0x08, /* I/O 0x100-0xFFF8, decodes 16-bit, 8-byte alignment, 8 addresses */ 0x47, 0x01, 0x00, 0x02, 0x00, 0x02, 0x08, 0x08,
0x38, /* end dependent functions */ /* Start dependent functions, acceptable */
0x30,
/* I/O 0x208, decodes 16-bit, 8-byte alignment, 8 addresses */
0x47, 0x01, 0x08, 0x02, 0x08, 0x02, 0x08, 0x08,
/* Start dependent functions, sub-optimal */
0x31, 0x02,
/* I/O 0x100-0xFFF8, decodes 16-bit, 8-byte alignment, 8 addresses */
0x47, 0x01, 0x00, 0x01, 0xf8, 0xff, 0x08, 0x08,
/* End dependent functions */
0x38,
0x79, 0x00 /* end tag, dummy checksum (filled in by isapnp_add_card) */ /* End tag, dummy checksum (filled in by isapnp_add_card) */
0x79, 0x00
}; };
static const isapnp_device_config_t gameport_pnp_defaults[] = { static const isapnp_device_config_t gameport_pnp_defaults[] = {
{.activate = 1, {
.activate = 1,
.io = { .io = {
{ .base = 0x200 }, { .base = 0x200 },
} }
@@ -244,10 +259,8 @@ gameport_write(UNUSED(uint16_t addr), UNUSED(uint8_t val), void *priv)
/* Read all axes. */ /* Read all axes. */
joystick->state |= 0x0f; joystick->state |= 0x0f;
gameport_time(joystick, 0, joystick->intf->read_axis(joystick->dat, 0)); for (uint8_t i = 0; i < 4; i++)
gameport_time(joystick, 1, joystick->intf->read_axis(joystick->dat, 1)); gameport_time(joystick, i, joystick->intf->read_axis(joystick->dat, i));
gameport_time(joystick, 2, joystick->intf->read_axis(joystick->dat, 2));
gameport_time(joystick, 3, joystick->intf->read_axis(joystick->dat, 3));
/* Notify the interface. */ /* Notify the interface. */
joystick->intf->write(joystick->dat); joystick->intf->write(joystick->dat);
@@ -384,20 +397,14 @@ gameport_init(const device_t *info)
if (!joystick_instance[0] && joystick_type) { if (!joystick_instance[0] && joystick_type) {
joystick_instance[0] = calloc(1, sizeof(joystick_instance_t)); joystick_instance[0] = calloc(1, sizeof(joystick_instance_t));
joystick_instance[0]->axis[0].joystick = joystick_instance[0]; // For each analog joystick axis
joystick_instance[0]->axis[1].joystick = joystick_instance[0]; for (uint8_t i = 0; i < 4; i++) {
joystick_instance[0]->axis[2].joystick = joystick_instance[0]; joystick_instance[0]->axis[i].joystick = joystick_instance[0];
joystick_instance[0]->axis[3].joystick = joystick_instance[0];
joystick_instance[0]->axis[0].axis_nr = 0; joystick_instance[0]->axis[i].axis_nr = i;
joystick_instance[0]->axis[1].axis_nr = 1;
joystick_instance[0]->axis[2].axis_nr = 2;
joystick_instance[0]->axis[3].axis_nr = 3;
timer_add(&joystick_instance[0]->axis[0].timer, timer_over, &joystick_instance[0]->axis[0], 0); timer_add(&joystick_instance[0]->axis[i].timer, timer_over, &joystick_instance[0]->axis[i], 0);
timer_add(&joystick_instance[0]->axis[1].timer, timer_over, &joystick_instance[0]->axis[1], 0); }
timer_add(&joystick_instance[0]->axis[2].timer, timer_over, &joystick_instance[0]->axis[2], 0);
timer_add(&joystick_instance[0]->axis[3].timer, timer_over, &joystick_instance[0]->axis[3], 0);
joystick_instance[0]->intf = joysticks[joystick_type].joystick; joystick_instance[0]->intf = joysticks[joystick_type].joystick;
joystick_instance[0]->dat = joystick_instance[0]->intf->init(); joystick_instance[0]->dat = joystick_instance[0]->intf->init();
@@ -409,8 +416,8 @@ gameport_init(const device_t *info)
dev->len = (info->local >> 16) & 0xff; dev->len = (info->local >> 16) & 0xff;
gameport_remap(dev, info->local & 0xffff); gameport_remap(dev, info->local & 0xffff);
/* Register ISAPnP if this is a standard game port card. */ /* Register ISAPnP if this is a PNP game port card. */
if ((info->local & 0xffff) == 0x200) if (info->local & GAMEPORT_PNPROM)
isapnp_set_device_defaults(isapnp_add_card(gameport_pnp_rom, sizeof(gameport_pnp_rom), gameport_pnp_config_changed, NULL, NULL, NULL, dev), 0, gameport_pnp_defaults); isapnp_set_device_defaults(isapnp_add_card(gameport_pnp_rom, sizeof(gameport_pnp_rom), gameport_pnp_config_changed, NULL, NULL, NULL, dev), 0, gameport_pnp_defaults);
return dev; return dev;
@@ -483,9 +490,23 @@ gameport_close(void *priv)
} }
const device_t gameport_device = { const device_t gameport_device = {
.name = "Game port", .name = "86Box PNP Game port",
.internal_name = "gameport", .internal_name = "gameport",
.flags = 0, .flags = 0,
.local = GAMEPORT_PNPROM | GAMEPORT_8ADDR | 0x0200,
.init = gameport_init,
.close = gameport_close,
.reset = NULL,
.available = NULL,
.speed_changed = NULL,
.force_redraw = NULL,
.config = NULL
};
const device_t gameport_200_device = {
.name = "Game port (Port 200h-207h)",
.internal_name = "gameport_200",
.flags = 0,
.local = GAMEPORT_8ADDR | 0x0200, .local = GAMEPORT_8ADDR | 0x0200,
.init = gameport_init, .init = gameport_init,
.close = gameport_close, .close = gameport_close,
@@ -736,7 +757,7 @@ const device_t gameport_sio_device = {
const device_t gameport_sio_1io_device = { const device_t gameport_sio_1io_device = {
.name = "Game port (Super I/O, 1 I/O port)", .name = "Game port (Super I/O, 1 I/O port)",
.internal_name = "gameport_sio", .internal_name = "gameport_sio_1io",
.flags = 0, .flags = 0,
.local = GAMEPORT_SIO | GAMEPORT_1ADDR, .local = GAMEPORT_SIO | GAMEPORT_1ADDR,
.init = gameport_init, .init = gameport_init,
@@ -751,6 +772,7 @@ const device_t gameport_sio_1io_device = {
static const GAMEPORT gameports[] = { static const GAMEPORT gameports[] = {
{ &device_none }, { &device_none },
{ &device_internal }, { &device_internal },
{ &gameport_200_device },
{ &gameport_device }, { &gameport_device },
{ &gameport_208_device }, { &gameport_208_device },
{ &gameport_pnp_device }, { &gameport_pnp_device },
@@ -771,7 +793,7 @@ gameport_available(int port)
/* UI */ /* UI */
const device_t * const device_t *
gameports_getdevice(int port) gameport_getdevice(int port)
{ {
return (gameports[port].device); return (gameports[port].device);
} }

View File

@@ -8,8 +8,6 @@
* *
* Implementation of the Flight Stick Pro. * Implementation of the Flight Stick Pro.
* *
*
*
* Authors: Miran Grca, <mgrca8@gmail.com> * Authors: Miran Grca, <mgrca8@gmail.com>
* Sarah Walker, <https://pcem-emulator.co.uk/> * Sarah Walker, <https://pcem-emulator.co.uk/>
* *
@@ -138,7 +136,7 @@ ch_flightstick_pro_a0_over(UNUSED(void *priv))
// //
} }
const joystick_if_t joystick_ch_flightstick_pro = { const joystick_t joystick_ch_flightstick_pro = {
.name = "CH Flightstick Pro", .name = "CH Flightstick Pro",
.internal_name = "ch_flightstick_pro", .internal_name = "ch_flightstick_pro",
.init = ch_flightstick_pro_init, .init = ch_flightstick_pro_init,
@@ -156,7 +154,7 @@ const joystick_if_t joystick_ch_flightstick_pro = {
.pov_names = { "POV" } .pov_names = { "POV" }
}; };
const joystick_if_t joystick_ch_flightstick_pro_ch_pedals = { const joystick_t joystick_ch_flightstick_pro_ch_pedals = {
.name = "CH Flightstick Pro + CH Pedals", .name = "CH Flightstick Pro + CH Pedals",
.internal_name = "ch_flightstick_pro_ch_pedals", .internal_name = "ch_flightstick_pro_ch_pedals",
.init = ch_flightstick_pro_init, .init = ch_flightstick_pro_init,

View File

@@ -274,7 +274,7 @@ joystick_standard_a0_over(UNUSED(void *priv))
// //
} }
const joystick_if_t joystick_2axis_2button = { const joystick_t joystick_2axis_2button = {
.name = "2-axis, 2-button joystick(s)", .name = "2-axis, 2-button joystick(s)",
.internal_name = "2axis_2button", .internal_name = "2axis_2button",
.init = joystick_standard_init, .init = joystick_standard_init,
@@ -292,7 +292,7 @@ const joystick_if_t joystick_2axis_2button = {
.pov_names = { NULL } .pov_names = { NULL }
}; };
const joystick_if_t joystick_2button_gamepad = { const joystick_t joystick_2button_gamepad = {
.name = "2-button gamepad(s)", .name = "2-button gamepad(s)",
.internal_name = "2button_gamepad", .internal_name = "2button_gamepad",
.init = joystick_standard_init, .init = joystick_standard_init,
@@ -310,7 +310,7 @@ const joystick_if_t joystick_2button_gamepad = {
.pov_names = { NULL } .pov_names = { NULL }
}; };
const joystick_if_t joystick_2button_flight_yoke = { const joystick_t joystick_2button_flight_yoke = {
.name = "2-button flight yoke", .name = "2-button flight yoke",
.internal_name = "2button_flight_yoke", .internal_name = "2button_flight_yoke",
.init = joystick_standard_init, .init = joystick_standard_init,
@@ -328,7 +328,7 @@ const joystick_if_t joystick_2button_flight_yoke = {
.pov_names = { NULL } .pov_names = { NULL }
}; };
const joystick_if_t joystick_2axis_4button = { const joystick_t joystick_2axis_4button = {
.name = "2-axis, 4-button joystick", .name = "2-axis, 4-button joystick",
.internal_name = "2axis_4button", .internal_name = "2axis_4button",
.init = joystick_standard_init, .init = joystick_standard_init,
@@ -346,7 +346,7 @@ const joystick_if_t joystick_2axis_4button = {
.pov_names = { NULL } .pov_names = { NULL }
}; };
const joystick_if_t joystick_4button_gamepad = { const joystick_t joystick_4button_gamepad = {
.name = "4-button gamepad", .name = "4-button gamepad",
.internal_name = "4button_gamepad", .internal_name = "4button_gamepad",
.init = joystick_standard_init, .init = joystick_standard_init,
@@ -364,7 +364,7 @@ const joystick_if_t joystick_4button_gamepad = {
.pov_names = { NULL } .pov_names = { NULL }
}; };
const joystick_if_t joystick_4button_flight_yoke = { const joystick_t joystick_4button_flight_yoke = {
.name = "4-button flight yoke", .name = "4-button flight yoke",
.internal_name = "4button_flight_yoke", .internal_name = "4button_flight_yoke",
.init = joystick_standard_init, .init = joystick_standard_init,
@@ -382,7 +382,7 @@ const joystick_if_t joystick_4button_flight_yoke = {
.pov_names = { NULL } .pov_names = { NULL }
}; };
const joystick_if_t joystick_3axis_2button = { const joystick_t joystick_3axis_2button = {
.name = "3-axis, 2-button joystick", .name = "3-axis, 2-button joystick",
.internal_name = "3axis_2button", .internal_name = "3axis_2button",
.init = joystick_standard_init, .init = joystick_standard_init,
@@ -400,7 +400,7 @@ const joystick_if_t joystick_3axis_2button = {
.pov_names = { NULL } .pov_names = { NULL }
}; };
const joystick_if_t joystick_2button_yoke_throttle = { const joystick_t joystick_2button_yoke_throttle = {
.name = "2-button flight yoke with throttle", .name = "2-button flight yoke with throttle",
.internal_name = "2button_yoke_throttle", .internal_name = "2button_yoke_throttle",
.init = joystick_standard_init, .init = joystick_standard_init,
@@ -418,7 +418,7 @@ const joystick_if_t joystick_2button_yoke_throttle = {
.pov_names = { NULL } .pov_names = { NULL }
}; };
const joystick_if_t joystick_3axis_4button = { const joystick_t joystick_3axis_4button = {
.name = "3-axis, 4-button joystick", .name = "3-axis, 4-button joystick",
.internal_name = "3axis_4button", .internal_name = "3axis_4button",
.init = joystick_standard_init, .init = joystick_standard_init,
@@ -436,7 +436,7 @@ const joystick_if_t joystick_3axis_4button = {
.pov_names = { NULL } .pov_names = { NULL }
}; };
const joystick_if_t joystick_4button_yoke_throttle = { const joystick_t joystick_4button_yoke_throttle = {
.name = "4-button flight yoke with throttle", .name = "4-button flight yoke with throttle",
.internal_name = "4button_yoke_throttle", .internal_name = "4button_yoke_throttle",
.init = joystick_standard_init, .init = joystick_standard_init,
@@ -454,7 +454,7 @@ const joystick_if_t joystick_4button_yoke_throttle = {
.pov_names = { NULL } .pov_names = { NULL }
}; };
const joystick_if_t joystick_win95_steering_wheel = { const joystick_t joystick_win95_steering_wheel = {
.name = "Win95 Steering Wheel (3-axis, 4-button)", .name = "Win95 Steering Wheel (3-axis, 4-button)",
.internal_name = "win95_steering_wheel", .internal_name = "win95_steering_wheel",
.init = joystick_standard_init, .init = joystick_standard_init,
@@ -472,7 +472,7 @@ const joystick_if_t joystick_win95_steering_wheel = {
.pov_names = { NULL } .pov_names = { NULL }
}; };
const joystick_if_t joystick_4axis_4button = { const joystick_t joystick_4axis_4button = {
.name = "4-axis, 4-button joystick", .name = "4-axis, 4-button joystick",
.internal_name = "4axis_4button", .internal_name = "4axis_4button",
.init = joystick_standard_init, .init = joystick_standard_init,
@@ -490,7 +490,7 @@ const joystick_if_t joystick_4axis_4button = {
.pov_names = { NULL } .pov_names = { NULL }
}; };
const joystick_if_t joystick_2axis_6button = { const joystick_t joystick_2axis_6button = {
.name = "2-axis, 6-button joystick", .name = "2-axis, 6-button joystick",
.internal_name = "2axis_6button", .internal_name = "2axis_6button",
.init = joystick_standard_init, .init = joystick_standard_init,
@@ -508,7 +508,7 @@ const joystick_if_t joystick_2axis_6button = {
.pov_names = { NULL } .pov_names = { NULL }
}; };
const joystick_if_t joystick_2axis_8button = { const joystick_t joystick_2axis_8button = {
.name = "2-axis, 8-button joystick", .name = "2-axis, 8-button joystick",
.internal_name = "2axis_8button", .internal_name = "2axis_8button",
.init = joystick_standard_init, .init = joystick_standard_init,

View File

@@ -29,8 +29,6 @@
* - Some DOS stuff will write to 0x201 while a packet is * - Some DOS stuff will write to 0x201 while a packet is
* being transferred. This seems to be ignored. * being transferred. This seems to be ignored.
* *
*
*
* Authors: Miran Grca, <mgrca8@gmail.com> * Authors: Miran Grca, <mgrca8@gmail.com>
* Sarah Walker, <https://pcem-emulator.co.uk/> * Sarah Walker, <https://pcem-emulator.co.uk/>
* *
@@ -244,7 +242,7 @@ sw_a0_over(void *priv)
timer_set_delay_u64(&sw->trigger_timer, TIMER_USEC * 10000); timer_set_delay_u64(&sw->trigger_timer, TIMER_USEC * 10000);
} }
const joystick_if_t joystick_sw_pad = { const joystick_t joystick_sw_pad = {
.name = "Microsoft SideWinder Pad", .name = "Microsoft SideWinder Pad",
.internal_name = "sidewinder_pad", .internal_name = "sidewinder_pad",
.init = sw_init, .init = sw_init,

View File

@@ -8,8 +8,6 @@
* *
* Implementation of Thrust Master Flight Control System. * Implementation of Thrust Master Flight Control System.
* *
*
*
* Authors: Miran Grca, <mgrca8@gmail.com> * Authors: Miran Grca, <mgrca8@gmail.com>
* Sarah Walker, <https://pcem-emulator.co.uk/> * Sarah Walker, <https://pcem-emulator.co.uk/>
* *
@@ -148,7 +146,7 @@ tm_fcs_a0_over(UNUSED(void *priv))
// //
} }
const joystick_if_t joystick_tm_fcs = { const joystick_t joystick_tm_fcs = {
.name = "Thrustmaster Flight Control System", .name = "Thrustmaster Flight Control System",
.internal_name = "thrustmaster_fcs", .internal_name = "thrustmaster_fcs",
.init = tm_fcs_init, .init = tm_fcs_init,
@@ -166,7 +164,7 @@ const joystick_if_t joystick_tm_fcs = {
.pov_names = { "POV" } .pov_names = { "POV" }
}; };
const joystick_if_t joystick_tm_fcs_rcs = { const joystick_t joystick_tm_fcs_rcs = {
.name = "Thrustmaster FCS + Rudder Control System", .name = "Thrustmaster FCS + Rudder Control System",
.internal_name = "thrustmaster_fcs_rcs", .internal_name = "thrustmaster_fcs_rcs",
.init = tm_fcs_init, .init = tm_fcs_init,

View File

@@ -51,8 +51,9 @@
#define GAMEPORT_6ADDR 0x060000 #define GAMEPORT_6ADDR 0x060000
#define GAMEPORT_8ADDR 0x080000 #define GAMEPORT_8ADDR 0x080000
#define GAMEPORT_SIO 0x1000000 #define GAMEPORT_SIO 0x1000000
#define GAMEPORT_PNPROM 0x2000000
typedef struct joystick_if_t { typedef struct joystick_t {
const char *name; const char *name;
const char *internal_name; const char *internal_name;
@@ -70,9 +71,9 @@ typedef struct joystick_if_t {
const char *axis_names[MAX_JOY_AXES]; const char *axis_names[MAX_JOY_AXES];
const char *button_names[MAX_JOY_BUTTONS]; const char *button_names[MAX_JOY_BUTTONS];
const char *pov_names[MAX_JOY_POVS]; const char *pov_names[MAX_JOY_POVS];
} joystick_if_t; } joystick_t;
typedef struct plat_joystick_t { typedef struct plat_joystick_state_t {
char name[260]; char name[260];
int a[MAX_JOY_AXES]; int a[MAX_JOY_AXES];
@@ -97,9 +98,9 @@ typedef struct plat_joystick_t {
int nr_axes; int nr_axes;
int nr_buttons; int nr_buttons;
int nr_povs; int nr_povs;
} plat_joystick_t; } plat_joystick_state_t;
typedef struct joystick_t { typedef struct joystick_state_t {
int axis[MAX_JOY_AXES]; int axis[MAX_JOY_AXES];
int button[MAX_JOY_BUTTONS]; int button[MAX_JOY_BUTTONS];
int pov[MAX_JOY_POVS]; int pov[MAX_JOY_POVS];
@@ -108,7 +109,7 @@ typedef struct joystick_t {
int axis_mapping[MAX_JOY_AXES]; int axis_mapping[MAX_JOY_AXES];
int button_mapping[MAX_JOY_BUTTONS]; int button_mapping[MAX_JOY_BUTTONS];
int pov_mapping[MAX_JOY_POVS][2]; int pov_mapping[MAX_JOY_POVS][2];
} joystick_t; } joystick_state_t;
extern device_t game_ports[GAMEPORT_MAX]; extern device_t game_ports[GAMEPORT_MAX];
@@ -126,6 +127,7 @@ extern int gameport_get_from_internal_name(const char *str);
#ifdef EMU_DEVICE_H #ifdef EMU_DEVICE_H
extern const device_t gameport_device; extern const device_t gameport_device;
extern const device_t gameport_200_device;
extern const device_t gameport_201_device; extern const device_t gameport_201_device;
extern const device_t gameport_203_device; extern const device_t gameport_203_device;
extern const device_t gameport_205_device; extern const device_t gameport_205_device;
@@ -144,10 +146,10 @@ extern const device_t gameport_sio_1io_device;
extern const device_t *standalone_gameport_type; extern const device_t *standalone_gameport_type;
#endif #endif
extern int gameport_instance_id; extern int gameport_instance_id;
extern plat_joystick_t plat_joystick_state[MAX_PLAT_JOYSTICKS]; extern plat_joystick_state_t plat_joystick_state[MAX_PLAT_JOYSTICKS];
extern joystick_t joystick_state[GAMEPORT_MAX][MAX_JOYSTICKS]; extern joystick_state_t joystick_state[GAMEPORT_MAX][MAX_JOYSTICKS];
extern int joysticks_present; extern int joysticks_present;
extern int joystick_type; extern int joystick_type;
@@ -170,28 +172,28 @@ extern void gameport_update_joystick_type(void);
extern void gameport_remap(void *priv, uint16_t address); extern void gameport_remap(void *priv, uint16_t address);
extern void *gameport_add(const device_t *gameport_type); extern void *gameport_add(const device_t *gameport_type);
extern const joystick_if_t joystick_2axis_2button; extern const joystick_t joystick_2axis_2button;
extern const joystick_if_t joystick_2button_gamepad; extern const joystick_t joystick_2button_gamepad;
extern const joystick_if_t joystick_2button_flight_yoke; extern const joystick_t joystick_2button_flight_yoke;
extern const joystick_if_t joystick_2axis_4button; extern const joystick_t joystick_2axis_4button;
extern const joystick_if_t joystick_4button_gamepad; extern const joystick_t joystick_4button_gamepad;
extern const joystick_if_t joystick_4button_flight_yoke; extern const joystick_t joystick_4button_flight_yoke;
extern const joystick_if_t joystick_3axis_2button; extern const joystick_t joystick_3axis_2button;
extern const joystick_if_t joystick_2button_yoke_throttle; extern const joystick_t joystick_2button_yoke_throttle;
extern const joystick_if_t joystick_3axis_4button; extern const joystick_t joystick_3axis_4button;
extern const joystick_if_t joystick_4button_yoke_throttle; extern const joystick_t joystick_4button_yoke_throttle;
extern const joystick_if_t joystick_win95_steering_wheel; extern const joystick_t joystick_win95_steering_wheel;
extern const joystick_if_t joystick_4axis_4button; extern const joystick_t joystick_4axis_4button;
extern const joystick_if_t joystick_2axis_6button; extern const joystick_t joystick_2axis_6button;
extern const joystick_if_t joystick_2axis_8button; extern const joystick_t joystick_2axis_8button;
extern const joystick_if_t joystick_ch_flightstick_pro; extern const joystick_t joystick_ch_flightstick_pro;
extern const joystick_if_t joystick_ch_flightstick_pro_ch_pedals; extern const joystick_t joystick_ch_flightstick_pro_ch_pedals;
extern const joystick_if_t joystick_sw_pad; extern const joystick_t joystick_sw_pad;
extern const joystick_if_t joystick_tm_fcs; extern const joystick_t joystick_tm_fcs;
extern const joystick_if_t joystick_tm_fcs_rcs; extern const joystick_t joystick_tm_fcs_rcs;
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@@ -2997,7 +2997,7 @@ machine_amstrad_init(const machine_t *model, int type)
mouse_set_poll(ms_poll, ams); mouse_set_poll(ms_poll, ams);
} }
standalone_gameport_type = &gameport_device; standalone_gameport_type = &gameport_200_device;
} }
int int

View File

@@ -995,7 +995,7 @@ machine_tandy1k_init(const machine_t *model, int type)
break; break;
} }
standalone_gameport_type = &gameport_device; standalone_gameport_type = &gameport_200_device;
eep_data_out = 0x0000; eep_data_out = 0x0000;
} }

View File

@@ -57,7 +57,7 @@ machine_xt_common_init(const machine_t *model, int fixed_floppy)
pit_devs[0].set_out_func(pit_devs[0].data, 1, pit_refresh_timer_xt); pit_devs[0].set_out_func(pit_devs[0].data, 1, pit_refresh_timer_xt);
nmi_init(); nmi_init();
standalone_gameport_type = &gameport_device; standalone_gameport_type = &gameport_200_device;
} }
static const device_config_t ibmpc_config[] = { static const device_config_t ibmpc_config[] = {
@@ -690,7 +690,7 @@ machine_xt_tuliptc8_init(const machine_t *model)
pit_devs[0].set_out_func(pit_devs[0].data, 1, pit_refresh_timer_xt); pit_devs[0].set_out_func(pit_devs[0].data, 1, pit_refresh_timer_xt);
nmi_init(); nmi_init();
standalone_gameport_type = &gameport_device; standalone_gameport_type = &gameport_200_device;
device_add(&amstrad_megapc_nvr_device); device_add(&amstrad_megapc_nvr_device);

View File

@@ -56,7 +56,7 @@ machine_xt_compaq_deskpro_init(const machine_t *model)
if (fdc_current[0] == FDC_INTERNAL) if (fdc_current[0] == FDC_INTERNAL)
device_add(&fdc_xt_device); device_add(&fdc_xt_device);
nmi_init(); nmi_init();
standalone_gameport_type = &gameport_device; standalone_gameport_type = &gameport_200_device;
lpt1_remove(); lpt1_remove();
lpt1_setup(LPT_MDA_ADDR); lpt1_setup(LPT_MDA_ADDR);
@@ -84,7 +84,7 @@ machine_xt_compaq_portable_init(const machine_t *model)
device_add(&fdc_xt_device); device_add(&fdc_xt_device);
nmi_init(); nmi_init();
if (joystick_type) if (joystick_type)
device_add(&gameport_device); device_add(&gameport_200_device);
lpt1_remove(); lpt1_remove();
lpt1_setup(LPT_MDA_ADDR); lpt1_setup(LPT_MDA_ADDR);

View File

@@ -464,7 +464,7 @@ machine_xt_laserxt_common_init(const machine_t *model,int is_lxt3)
device_add(&fdc_xt_device); device_add(&fdc_xt_device);
nmi_init(); nmi_init();
standalone_gameport_type = &gameport_device; standalone_gameport_type = &gameport_200_device;
device_add(is_lxt3 ? &lxt3_device : &laserxt_device); device_add(is_lxt3 ? &lxt3_device : &laserxt_device);

View File

@@ -2325,7 +2325,7 @@ machine_xt_m24_init(const machine_t *model)
/* Address 66-67 = mainboard dip-switch settings */ /* Address 66-67 = mainboard dip-switch settings */
io_sethandler(0x0065, 3, m24_read, NULL, NULL, NULL, NULL, NULL, NULL); io_sethandler(0x0065, 3, m24_read, NULL, NULL, NULL, NULL, NULL, NULL);
standalone_gameport_type = &gameport_device; standalone_gameport_type = &gameport_200_device;
nmi_init(); nmi_init();
@@ -2397,7 +2397,7 @@ machine_xt_m240_init(const machine_t *model)
device_add(&fdc_at_device); /* io.c logs clearly show it using port 3F7 */ device_add(&fdc_at_device); /* io.c logs clearly show it using port 3F7 */
if (joystick_type) if (joystick_type)
device_add(&gameport_device); device_add(&gameport_200_device);
nmi_init(); nmi_init();

View File

@@ -158,7 +158,7 @@ machine_xt_philips_common_init(const machine_t *model)
nmi_init(); nmi_init();
standalone_gameport_type = &gameport_device; standalone_gameport_type = &gameport_200_device;
device_add(&keyboard_pc_device); device_add(&keyboard_pc_device);

View File

@@ -209,7 +209,7 @@ machine_xt_xi8088_init(const machine_t *model)
nmi_init(); nmi_init();
device_add(&ibmat_nvr_device); device_add(&ibmat_nvr_device);
pic2_init(); pic2_init();
standalone_gameport_type = &gameport_device; standalone_gameport_type = &gameport_200_device;
device_add(&sst_flash_39sf010_device); device_add(&sst_flash_39sf010_device);
return ret; return ret;

View File

@@ -33,10 +33,10 @@
#include <86box/gameport.h> #include <86box/gameport.h>
#include <86box/plat_unused.h> #include <86box/plat_unused.h>
int joysticks_present = 0; int joysticks_present = 0;
joystick_t joystick_state[GAMEPORT_MAX][MAX_JOYSTICKS]; joystick_state_t joystick_state[GAMEPORT_MAX][MAX_JOYSTICKS];
plat_joystick_t plat_joystick_state[MAX_PLAT_JOYSTICKS]; plat_joystick_state_t plat_joystick_state[MAX_PLAT_JOYSTICKS];
static SDL_Joystick *sdl_joy[MAX_PLAT_JOYSTICKS]; static SDL_Joystick *sdl_joy[MAX_PLAT_JOYSTICKS];
#ifndef M_PI #ifndef M_PI
# define M_PI 3.14159265358979323846 # define M_PI 3.14159265358979323846

View File

@@ -96,15 +96,15 @@ typedef struct {
} pov[MAX_JOY_POVS]; } pov[MAX_JOY_POVS];
} raw_joystick_t; } raw_joystick_t;
int joysticks_present = 0; int joysticks_present = 0;
joystick_t joystick_state[GAMEPORT_MAX][MAX_JOYSTICKS]; joystick_state_t joystick_state[GAMEPORT_MAX][MAX_JOYSTICKS];
plat_joystick_t plat_joystick_state[MAX_PLAT_JOYSTICKS]; plat_joystick_state_t plat_joystick_state[MAX_PLAT_JOYSTICKS];
raw_joystick_t raw_joystick_state[MAX_PLAT_JOYSTICKS]; raw_joystick_t raw_joystick_state[MAX_PLAT_JOYSTICKS];
/* We only use the first 32 buttons reported, from Usage ID 1-128 */ /* We only use the first 32 buttons reported, from Usage ID 1-128 */
void void
joystick_add_button(raw_joystick_t *rawjoy, plat_joystick_t *joy, USAGE usage) joystick_add_button(raw_joystick_t *rawjoy, plat_joystick_state_t *joy, USAGE usage)
{ {
if (joy->nr_buttons >= MAX_JOY_BUTTONS) if (joy->nr_buttons >= MAX_JOY_BUTTONS)
return; return;
@@ -117,7 +117,7 @@ joystick_add_button(raw_joystick_t *rawjoy, plat_joystick_t *joy, USAGE usage)
} }
void void
joystick_add_axis(raw_joystick_t *rawjoy, plat_joystick_t *joy, PHIDP_VALUE_CAPS prop) joystick_add_axis(raw_joystick_t *rawjoy, plat_joystick_state_t *joy, PHIDP_VALUE_CAPS prop)
{ {
if (joy->nr_axes >= MAX_JOY_AXES) if (joy->nr_axes >= MAX_JOY_AXES)
return; return;
@@ -202,7 +202,7 @@ joystick_add_axis(raw_joystick_t *rawjoy, plat_joystick_t *joy, PHIDP_VALUE_CAPS
} }
void void
joystick_add_pov(raw_joystick_t *rawjoy, plat_joystick_t *joy, PHIDP_VALUE_CAPS prop) joystick_add_pov(raw_joystick_t *rawjoy, plat_joystick_state_t *joy, PHIDP_VALUE_CAPS prop)
{ {
if (joy->nr_povs >= MAX_JOY_POVS) if (joy->nr_povs >= MAX_JOY_POVS)
return; return;
@@ -217,7 +217,7 @@ joystick_add_pov(raw_joystick_t *rawjoy, plat_joystick_t *joy, PHIDP_VALUE_CAPS
} }
void void
joystick_get_capabilities(raw_joystick_t *rawjoy, plat_joystick_t *joy) joystick_get_capabilities(raw_joystick_t *rawjoy, plat_joystick_state_t *joy)
{ {
UINT size = 0; UINT size = 0;
PHIDP_BUTTON_CAPS btn_caps = NULL; PHIDP_BUTTON_CAPS btn_caps = NULL;
@@ -276,7 +276,7 @@ end:
} }
void void
joystick_get_device_name(raw_joystick_t *rawjoy, plat_joystick_t *joy, PRID_DEVICE_INFO info) joystick_get_device_name(raw_joystick_t *rawjoy, plat_joystick_state_t *joy, PRID_DEVICE_INFO info)
{ {
UINT size = 0; UINT size = 0;
WCHAR *device_name = NULL; WCHAR *device_name = NULL;
@@ -340,9 +340,9 @@ joystick_init(void)
if (info->hid.usUsage != HID_USAGE_GENERIC_JOYSTICK && info->hid.usUsage != HID_USAGE_GENERIC_GAMEPAD) if (info->hid.usUsage != HID_USAGE_GENERIC_JOYSTICK && info->hid.usUsage != HID_USAGE_GENERIC_GAMEPAD)
goto end_loop; goto end_loop;
plat_joystick_t *joy = &plat_joystick_state[joysticks_present]; plat_joystick_state_t *joy = &plat_joystick_state[joysticks_present];
raw_joystick_t *rawjoy = &raw_joystick_state[joysticks_present]; raw_joystick_t *rawjoy = &raw_joystick_state[joysticks_present];
rawjoy->hdevice = deviceList[i].hDevice; rawjoy->hdevice = deviceList[i].hDevice;
joystick_get_capabilities(rawjoy, joy); joystick_get_capabilities(rawjoy, joy);
joystick_get_device_name(rawjoy, joy, info); joystick_get_device_name(rawjoy, joy, info);

View File

@@ -2874,9 +2874,8 @@ sb_init(UNUSED(const device_t *info))
sb_ct1335_mixer_reset(sb); sb_ct1335_mixer_reset(sb);
if (device_get_config_int("gameport")) { if (device_get_config_int("gameport")) {
sb->gameport = gameport_add(&gameport_device); sb->gameport = gameport_add(&gameport_200_device);
sb->gameport_addr = 0x200; sb->gameport_addr = 0x200;
gameport_remap(sb->gameport, sb->gameport_addr);
} }
/* DSP I/O handler is activated in sb_dsp_setaddr */ /* DSP I/O handler is activated in sb_dsp_setaddr */
@@ -2959,9 +2958,8 @@ sb_mcv_init(UNUSED(const device_t *info))
midi_in_handler(1, sb_dsp_input_msg, sb_dsp_input_sysex, &sb->dsp); midi_in_handler(1, sb_dsp_input_msg, sb_dsp_input_sysex, &sb->dsp);
if (device_get_config_int("gameport")) { if (device_get_config_int("gameport")) {
sb->gameport = gameport_add(&gameport_device); sb->gameport = gameport_add(&gameport_200_device);
sb->gameport_addr = 0x200; sb->gameport_addr = 0x200;
gameport_remap(sb->gameport, sb->gameport_addr);
} }
return sb; return sb;
@@ -3047,9 +3045,8 @@ sb_pro_v1_init(UNUSED(const device_t *info))
midi_in_handler(1, sb_dsp_input_msg, sb_dsp_input_sysex, &sb->dsp); midi_in_handler(1, sb_dsp_input_msg, sb_dsp_input_sysex, &sb->dsp);
if (device_get_config_int("gameport")) { if (device_get_config_int("gameport")) {
sb->gameport = gameport_add(&gameport_device); sb->gameport = gameport_add(&gameport_200_device);
sb->gameport_addr = 0x200; sb->gameport_addr = 0x200;
gameport_remap(sb->gameport, sb->gameport_addr);
} }
return sb; return sb;
@@ -3107,9 +3104,8 @@ sb_pro_v2_init(UNUSED(const device_t *info))
midi_in_handler(1, sb_dsp_input_msg, sb_dsp_input_sysex, &sb->dsp); midi_in_handler(1, sb_dsp_input_msg, sb_dsp_input_sysex, &sb->dsp);
if (device_get_config_int("gameport")) { if (device_get_config_int("gameport")) {
sb->gameport = gameport_add(&gameport_device); sb->gameport = gameport_add(&gameport_200_device);
sb->gameport_addr = 0x200; sb->gameport_addr = 0x200;
gameport_remap(sb->gameport, sb->gameport_addr);
} }
return sb; return sb;
@@ -3146,9 +3142,8 @@ sb_pro_mcv_init(UNUSED(const device_t *info))
midi_in_handler(1, sb_dsp_input_msg, sb_dsp_input_sysex, &sb->dsp); midi_in_handler(1, sb_dsp_input_msg, sb_dsp_input_sysex, &sb->dsp);
if (device_get_config_int("gameport")) { if (device_get_config_int("gameport")) {
sb->gameport = gameport_add(&gameport_device); sb->gameport = gameport_add(&gameport_200_device);
sb->gameport_addr = 0x200; sb->gameport_addr = 0x200;
gameport_remap(sb->gameport, sb->gameport_addr);
} }
return sb; return sb;
@@ -3241,9 +3236,8 @@ sb_16_init(UNUSED(const device_t *info))
gameport_remap(sb->gameport, sb->gameport_addr); gameport_remap(sb->gameport, sb->gameport_addr);
} else { } else {
if (device_get_config_int("gameport")) { if (device_get_config_int("gameport")) {
sb->gameport = gameport_add(&gameport_device); sb->gameport = gameport_add(&gameport_200_device);
sb->gameport_addr = 0x200; sb->gameport_addr = 0x200;
gameport_remap(sb->gameport, sb->gameport_addr);
} }
} }
@@ -3279,7 +3273,7 @@ sb_16_reply_mca_init(UNUSED(const device_t *info))
if (device_get_config_int("receive_input")) if (device_get_config_int("receive_input"))
midi_in_handler(1, sb_dsp_input_msg, sb_dsp_input_sysex, &sb->dsp); midi_in_handler(1, sb_dsp_input_msg, sb_dsp_input_sysex, &sb->dsp);
sb->gameport = gameport_add(&gameport_device); sb->gameport = gameport_add(&gameport_200_device);
/* I/O handlers activated in sb_pro_mcv_write */ /* I/O handlers activated in sb_pro_mcv_write */
mca_add(sb_16_reply_mca_read, sb_16_reply_mca_write, sb_mcv_feedb, NULL, sb); mca_add(sb_16_reply_mca_read, sb_16_reply_mca_write, sb_mcv_feedb, NULL, sb);
@@ -3645,9 +3639,8 @@ sb_awe32_init(UNUSED(const device_t *info))
midi_in_handler(1, sb_dsp_input_msg, sb_dsp_input_sysex, &sb->dsp); midi_in_handler(1, sb_dsp_input_msg, sb_dsp_input_sysex, &sb->dsp);
if (device_get_config_int("gameport")) { if (device_get_config_int("gameport")) {
sb->gameport = gameport_add(&gameport_device); sb->gameport = gameport_add(&gameport_200_device);
sb->gameport_addr = 0x200; sb->gameport_addr = 0x200;
gameport_remap(sb->gameport, sb->gameport_addr);
} }
return sb; return sb;
@@ -3911,9 +3904,8 @@ ess_x688_init(UNUSED(const device_t *info))
} }
if (device_get_config_int("gameport")) { if (device_get_config_int("gameport")) {
ess->gameport = gameport_add(&gameport_device); ess->gameport = gameport_add(&gameport_200_device);
ess->gameport_addr = 0x200; ess->gameport_addr = 0x200;
gameport_remap(ess->gameport, ess->gameport_addr);
} }
if (ide_base > 0x0000) { if (ide_base > 0x0000) {
@@ -4060,7 +4052,7 @@ ess_x688_mca_init(UNUSED(const device_t *info))
sb_dsp_set_mpu(&ess->dsp, ess->mpu); sb_dsp_set_mpu(&ess->dsp, ess->mpu);
} }
ess->gameport = gameport_add(&gameport_device); ess->gameport = gameport_add(&gameport_200_device);
mpu401_change_addr(ess->mpu, 0); mpu401_change_addr(ess->mpu, 0);

View File

@@ -64,8 +64,8 @@ int fixed_size_x = 640;
int fixed_size_y = 480; int fixed_size_y = 480;
extern int title_set; extern int title_set;
extern wchar_t sdl_win_title[512]; extern wchar_t sdl_win_title[512];
plat_joystick_t plat_joystick_state[MAX_PLAT_JOYSTICKS]; plat_joystick_state_t plat_joystick_state[MAX_PLAT_JOYSTICKS];
joystick_t joystick_state[GAMEPORT_MAX][MAX_JOYSTICKS]; joystick_state_t joystick_state[GAMEPORT_MAX][MAX_JOYSTICKS];
int joysticks_present; int joysticks_present;
SDL_mutex *blitmtx; SDL_mutex *blitmtx;
SDL_threadID eventthread; SDL_threadID eventthread;