small bit of cleanup in gameport.c
This commit is contained in:
@@ -36,7 +36,6 @@
|
|||||||
#include <86box/joystick_sw_pad.h>
|
#include <86box/joystick_sw_pad.h>
|
||||||
#include <86box/joystick_tm_fcs.h>
|
#include <86box/joystick_tm_fcs.h>
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
pc_timer_t timer;
|
pc_timer_t timer;
|
||||||
int axis_nr;
|
int axis_nr;
|
||||||
@@ -58,10 +57,8 @@ typedef struct _joystick_instance_ {
|
|||||||
void *dat;
|
void *dat;
|
||||||
} joystick_instance_t;
|
} joystick_instance_t;
|
||||||
|
|
||||||
|
|
||||||
int joystick_type = 0;
|
int joystick_type = 0;
|
||||||
|
|
||||||
|
|
||||||
static const joystick_if_t joystick_none = {
|
static const joystick_if_t joystick_none = {
|
||||||
"None",
|
"None",
|
||||||
"none",
|
"none",
|
||||||
@@ -76,25 +73,24 @@ static const joystick_if_t joystick_none = {
|
|||||||
0
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static const struct {
|
static const struct {
|
||||||
const joystick_if_t *joystick;
|
const joystick_if_t *joystick;
|
||||||
} joysticks[] = {
|
} joysticks[] = {
|
||||||
{ &joystick_none },
|
{ &joystick_none },
|
||||||
{ &joystick_2axis_2button },
|
{ &joystick_2axis_2button },
|
||||||
{ &joystick_2axis_4button },
|
{ &joystick_2axis_4button },
|
||||||
{ &joystick_2axis_6button },
|
{ &joystick_2axis_6button },
|
||||||
{ &joystick_2axis_8button },
|
{ &joystick_2axis_8button },
|
||||||
{ &joystick_3axis_2button },
|
{ &joystick_3axis_2button },
|
||||||
{ &joystick_3axis_4button },
|
{ &joystick_3axis_4button },
|
||||||
{ &joystick_4axis_4button },
|
{ &joystick_4axis_4button },
|
||||||
{ &joystick_ch_flightstick_pro },
|
{ &joystick_ch_flightstick_pro },
|
||||||
{ &joystick_sw_pad },
|
{ &joystick_sw_pad },
|
||||||
{ &joystick_tm_fcs },
|
{ &joystick_tm_fcs },
|
||||||
{ NULL }
|
{ NULL }
|
||||||
};
|
};
|
||||||
static joystick_instance_t *joystick_instance = NULL;
|
|
||||||
|
|
||||||
|
static joystick_instance_t *joystick_instance = 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) */
|
0x09, 0xf8, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, /* BOX0002, dummy checksum (filled in by isapnp_add_card) */
|
||||||
@@ -120,14 +116,12 @@ static const isapnp_device_config_t gameport_pnp_defaults[] = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const device_t *standalone_gameport_type;
|
const device_t *standalone_gameport_type;
|
||||||
int gameport_instance_id = 0;
|
int gameport_instance_id = 0;
|
||||||
/* Linked list of active game ports. Only the top port responds to reads
|
/* Linked list of active game ports. Only the top port responds to reads
|
||||||
or writes, and ports at the standard 200h location are prioritized. */
|
or writes, and ports at the standard 200h location are prioritized. */
|
||||||
static gameport_t *active_gameports = NULL;
|
static gameport_t *active_gameports = NULL;
|
||||||
|
|
||||||
|
|
||||||
char *
|
char *
|
||||||
joystick_get_name(int js)
|
joystick_get_name(int js)
|
||||||
{
|
{
|
||||||
@@ -136,7 +130,6 @@ joystick_get_name(int js)
|
|||||||
return (char *) joysticks[js].joystick->name;
|
return (char *) joysticks[js].joystick->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char *
|
char *
|
||||||
joystick_get_internal_name(int js)
|
joystick_get_internal_name(int js)
|
||||||
{
|
{
|
||||||
@@ -146,7 +139,6 @@ joystick_get_internal_name(int js)
|
|||||||
return (char *) joysticks[js].joystick->internal_name;
|
return (char *) joysticks[js].joystick->internal_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
joystick_get_from_internal_name(char *s)
|
joystick_get_from_internal_name(char *s)
|
||||||
{
|
{
|
||||||
@@ -161,56 +153,48 @@ joystick_get_from_internal_name(char *s)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
joystick_get_max_joysticks(int js)
|
joystick_get_max_joysticks(int js)
|
||||||
{
|
{
|
||||||
return joysticks[js].joystick->max_joysticks;
|
return joysticks[js].joystick->max_joysticks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
joystick_get_axis_count(int js)
|
joystick_get_axis_count(int js)
|
||||||
{
|
{
|
||||||
return joysticks[js].joystick->axis_count;
|
return joysticks[js].joystick->axis_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
joystick_get_button_count(int js)
|
joystick_get_button_count(int js)
|
||||||
{
|
{
|
||||||
return joysticks[js].joystick->button_count;
|
return joysticks[js].joystick->button_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
joystick_get_pov_count(int js)
|
joystick_get_pov_count(int js)
|
||||||
{
|
{
|
||||||
return joysticks[js].joystick->pov_count;
|
return joysticks[js].joystick->pov_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char *
|
char *
|
||||||
joystick_get_axis_name(int js, int id)
|
joystick_get_axis_name(int js, int id)
|
||||||
{
|
{
|
||||||
return (char *) joysticks[js].joystick->axis_names[id];
|
return (char *) joysticks[js].joystick->axis_names[id];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char *
|
char *
|
||||||
joystick_get_button_name(int js, int id)
|
joystick_get_button_name(int js, int id)
|
||||||
{
|
{
|
||||||
return (char *) joysticks[js].joystick->button_names[id];
|
return (char *) joysticks[js].joystick->button_names[id];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char *
|
char *
|
||||||
joystick_get_pov_name(int js, int id)
|
joystick_get_pov_name(int js, int id)
|
||||||
{
|
{
|
||||||
return (char *) joysticks[js].joystick->pov_names[id];
|
return (char *) joysticks[js].joystick->pov_names[id];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gameport_time(joystick_instance_t *joystick, int nr, int axis)
|
gameport_time(joystick_instance_t *joystick, int nr, int axis)
|
||||||
{
|
{
|
||||||
@@ -225,7 +209,6 @@ gameport_time(joystick_instance_t *joystick, int nr, int axis)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gameport_write(uint16_t addr, uint8_t val, void *priv)
|
gameport_write(uint16_t addr, uint8_t val, void *priv)
|
||||||
{
|
{
|
||||||
@@ -250,7 +233,6 @@ gameport_write(uint16_t addr, uint8_t val, void *priv)
|
|||||||
cycles -= ISA_CYCLES(8);
|
cycles -= ISA_CYCLES(8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static uint8_t
|
static uint8_t
|
||||||
gameport_read(uint16_t addr, void *priv)
|
gameport_read(uint16_t addr, void *priv)
|
||||||
{
|
{
|
||||||
@@ -269,7 +251,6 @@ gameport_read(uint16_t addr, void *priv)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
timer_over(void *priv)
|
timer_over(void *priv)
|
||||||
{
|
{
|
||||||
@@ -282,7 +263,6 @@ timer_over(void *priv)
|
|||||||
axis->joystick->intf->a0_over(axis->joystick->dat);
|
axis->joystick->intf->a0_over(axis->joystick->dat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
gameport_update_joystick_type(void)
|
gameport_update_joystick_type(void)
|
||||||
{
|
{
|
||||||
@@ -298,7 +278,6 @@ gameport_update_joystick_type(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
gameport_remap(void *priv, uint16_t address)
|
gameport_remap(void *priv, uint16_t address)
|
||||||
{
|
{
|
||||||
@@ -346,7 +325,6 @@ gameport_remap(void *priv, uint16_t address)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gameport_pnp_config_changed(uint8_t ld, isapnp_device_config_t *config, void *priv)
|
gameport_pnp_config_changed(uint8_t ld, isapnp_device_config_t *config, void *priv)
|
||||||
{
|
{
|
||||||
@@ -359,7 +337,6 @@ gameport_pnp_config_changed(uint8_t ld, isapnp_device_config_t *config, void *pr
|
|||||||
gameport_remap(dev, (config->activate && (config->io[0].base != ISAPNP_IO_DISABLED)) ? config->io[0].base : 0);
|
gameport_remap(dev, (config->activate && (config->io[0].base != ISAPNP_IO_DISABLED)) ? config->io[0].base : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void *
|
void *
|
||||||
gameport_add(const device_t *gameport_type)
|
gameport_add(const device_t *gameport_type)
|
||||||
{
|
{
|
||||||
@@ -372,7 +349,6 @@ gameport_add(const device_t *gameport_type)
|
|||||||
return device_add_inst(gameport_type, gameport_instance_id++);
|
return device_add_inst(gameport_type, gameport_instance_id++);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void *
|
static void *
|
||||||
gameport_init(const device_t *info)
|
gameport_init(const device_t *info)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user