clang-format in src/game/
This commit is contained in:
@@ -37,100 +37,100 @@
|
||||
#include <86box/joystick_tm_fcs.h>
|
||||
|
||||
typedef struct {
|
||||
pc_timer_t timer;
|
||||
int axis_nr;
|
||||
pc_timer_t timer;
|
||||
int axis_nr;
|
||||
struct _joystick_instance_ *joystick;
|
||||
} g_axis_t;
|
||||
|
||||
typedef struct _gameport_ {
|
||||
uint16_t addr;
|
||||
uint8_t len;
|
||||
uint16_t addr;
|
||||
uint8_t len;
|
||||
struct _joystick_instance_ *joystick;
|
||||
struct _gameport_ *next;
|
||||
struct _gameport_ *next;
|
||||
} gameport_t;
|
||||
|
||||
typedef struct _joystick_instance_ {
|
||||
uint8_t state;
|
||||
g_axis_t axis[4];
|
||||
uint8_t state;
|
||||
g_axis_t axis[4];
|
||||
|
||||
const joystick_if_t *intf;
|
||||
void *dat;
|
||||
void *dat;
|
||||
} joystick_instance_t;
|
||||
|
||||
int joystick_type = 0;
|
||||
int joystick_type = 0;
|
||||
|
||||
static const joystick_if_t joystick_none = {
|
||||
.name = "None",
|
||||
.name = "None",
|
||||
.internal_name = "none",
|
||||
.init = NULL,
|
||||
.close = NULL,
|
||||
.read = NULL,
|
||||
.write = NULL,
|
||||
.read_axis = NULL,
|
||||
.a0_over = NULL,
|
||||
.axis_count = 0,
|
||||
.button_count = 0,
|
||||
.pov_count = 0,
|
||||
.init = NULL,
|
||||
.close = NULL,
|
||||
.read = NULL,
|
||||
.write = NULL,
|
||||
.read_axis = NULL,
|
||||
.a0_over = NULL,
|
||||
.axis_count = 0,
|
||||
.button_count = 0,
|
||||
.pov_count = 0,
|
||||
.max_joysticks = 0,
|
||||
.axis_names = { NULL },
|
||||
.button_names = { NULL },
|
||||
.pov_names = { NULL }
|
||||
.axis_names = { NULL },
|
||||
.button_names = { NULL },
|
||||
.pov_names = { NULL }
|
||||
};
|
||||
|
||||
static const struct {
|
||||
const joystick_if_t *joystick;
|
||||
const joystick_if_t *joystick;
|
||||
} joysticks[] = {
|
||||
{ &joystick_none },
|
||||
{ &joystick_2axis_2button },
|
||||
{ &joystick_2axis_4button },
|
||||
{ &joystick_2axis_6button },
|
||||
{ &joystick_2axis_8button },
|
||||
{ &joystick_3axis_2button },
|
||||
{ &joystick_3axis_4button },
|
||||
{ &joystick_4axis_4button },
|
||||
{ &joystick_none },
|
||||
{ &joystick_2axis_2button },
|
||||
{ &joystick_2axis_4button },
|
||||
{ &joystick_2axis_6button },
|
||||
{ &joystick_2axis_8button },
|
||||
{ &joystick_3axis_2button },
|
||||
{ &joystick_3axis_4button },
|
||||
{ &joystick_4axis_4button },
|
||||
{ &joystick_ch_flightstick_pro },
|
||||
{ &joystick_sw_pad },
|
||||
{ &joystick_tm_fcs },
|
||||
{ NULL }
|
||||
{ &joystick_sw_pad },
|
||||
{ &joystick_tm_fcs },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
static joystick_instance_t *joystick_instance = NULL;
|
||||
|
||||
static uint8_t gameport_pnp_rom[] = {
|
||||
0x09, 0xf8, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, /* BOX0002, 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, /* BOX0002, dummy checksum (filled in by isapnp_add_card) */
|
||||
0x0a, 0x10, 0x10, /* PnP version 1.0, vendor version 1.0 */
|
||||
0x82, 0x09, 0x00, 'G', 'a', 'm', 'e', ' ', 'P', 'o', 'r', 't', /* ANSI identifier */
|
||||
|
||||
0x15, 0x09, 0xf8, 0x00, 0x02, 0x01, /* logical device BOX0002, can participate in boot */
|
||||
0x1c, 0x41, 0xd0, 0xb0, 0x2f, /* compatible device PNPB02F */
|
||||
0x31, 0x00, /* start dependent functions, preferred */
|
||||
0x47, 0x01, 0x00, 0x02, 0x00, 0x02, 0x08, 0x08, /* I/O 0x200, decodes 16-bit, 8-byte alignment, 8 addresses */
|
||||
0x30, /* start dependent functions, acceptable */
|
||||
0x47, 0x01, 0x08, 0x02, 0x08, 0x02, 0x08, 0x08, /* I/O 0x208, decodes 16-bit, 8-byte alignment, 8 addresses */
|
||||
0x31, 0x02, /* start dependent functions, sub-optimal */
|
||||
0x47, 0x01, 0x00, 0x01, 0xf8, 0xff, 0x08, 0x08, /* I/O 0x100-0xFFF8, decodes 16-bit, 8-byte alignment, 8 addresses */
|
||||
0x38, /* end dependent functions */
|
||||
0x15, 0x09, 0xf8, 0x00, 0x02, 0x01, /* logical device BOX0002, can participate in boot */
|
||||
0x1c, 0x41, 0xd0, 0xb0, 0x2f, /* compatible device PNPB02F */
|
||||
0x31, 0x00, /* start dependent functions, preferred */
|
||||
0x47, 0x01, 0x00, 0x02, 0x00, 0x02, 0x08, 0x08, /* I/O 0x200, decodes 16-bit, 8-byte alignment, 8 addresses */
|
||||
0x30, /* start dependent functions, acceptable */
|
||||
0x47, 0x01, 0x08, 0x02, 0x08, 0x02, 0x08, 0x08, /* I/O 0x208, decodes 16-bit, 8-byte alignment, 8 addresses */
|
||||
0x31, 0x02, /* start dependent functions, sub-optimal */
|
||||
0x47, 0x01, 0x00, 0x01, 0xf8, 0xff, 0x08, 0x08, /* I/O 0x100-0xFFF8, decodes 16-bit, 8-byte alignment, 8 addresses */
|
||||
0x38, /* end dependent functions */
|
||||
|
||||
0x79, 0x00 /* end tag, dummy checksum (filled in by isapnp_add_card) */
|
||||
};
|
||||
static const isapnp_device_config_t gameport_pnp_defaults[] = {
|
||||
{
|
||||
.activate = 1,
|
||||
.io = { { .base = 0x200 }, }
|
||||
}
|
||||
{.activate = 1,
|
||||
.io = {
|
||||
{ .base = 0x200 },
|
||||
}}
|
||||
};
|
||||
|
||||
const device_t *standalone_gameport_type;
|
||||
int gameport_instance_id = 0;
|
||||
const device_t *standalone_gameport_type;
|
||||
int gameport_instance_id = 0;
|
||||
/* Linked list of active game ports. Only the top port responds to reads
|
||||
or writes, and ports at the standard 200h location are prioritized. */
|
||||
static gameport_t *active_gameports = NULL;
|
||||
static gameport_t *active_gameports = NULL;
|
||||
|
||||
char *
|
||||
joystick_get_name(int js)
|
||||
{
|
||||
if (!joysticks[js].joystick)
|
||||
return NULL;
|
||||
return NULL;
|
||||
return (char *) joysticks[js].joystick->name;
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ char *
|
||||
joystick_get_internal_name(int js)
|
||||
{
|
||||
if (joysticks[js].joystick == NULL)
|
||||
return "";
|
||||
return "";
|
||||
|
||||
return (char *) joysticks[js].joystick->internal_name;
|
||||
}
|
||||
@@ -149,9 +149,9 @@ joystick_get_from_internal_name(char *s)
|
||||
int c = 0;
|
||||
|
||||
while (joysticks[c].joystick != NULL) {
|
||||
if (!strcmp((char *) joysticks[c].joystick->internal_name, s))
|
||||
return c;
|
||||
c++;
|
||||
if (!strcmp((char *) joysticks[c].joystick->internal_name, s))
|
||||
return c;
|
||||
c++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -203,25 +203,25 @@ static void
|
||||
gameport_time(joystick_instance_t *joystick, int nr, int axis)
|
||||
{
|
||||
if (axis == AXIS_NOT_PRESENT)
|
||||
timer_disable(&joystick->axis[nr].timer);
|
||||
timer_disable(&joystick->axis[nr].timer);
|
||||
else {
|
||||
/* Convert axis value to 555 timing. */
|
||||
axis += 32768;
|
||||
axis = (axis * 100) / 65; /* axis now in ohms */
|
||||
axis = (axis * 11) / 1000;
|
||||
timer_set_delay_u64(&joystick->axis[nr].timer, TIMER_USEC * (axis + 24)); /* max = 11.115 ms */
|
||||
/* Convert axis value to 555 timing. */
|
||||
axis += 32768;
|
||||
axis = (axis * 100) / 65; /* axis now in ohms */
|
||||
axis = (axis * 11) / 1000;
|
||||
timer_set_delay_u64(&joystick->axis[nr].timer, TIMER_USEC * (axis + 24)); /* max = 11.115 ms */
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gameport_write(uint16_t addr, uint8_t val, void *priv)
|
||||
{
|
||||
gameport_t *dev = (gameport_t *) priv;
|
||||
gameport_t *dev = (gameport_t *) priv;
|
||||
joystick_instance_t *joystick = dev->joystick;
|
||||
|
||||
/* Respond only if a joystick is present and this port is at the top of the active ports list. */
|
||||
if (!joystick || (active_gameports != dev))
|
||||
return;
|
||||
return;
|
||||
|
||||
/* Read all axes. */
|
||||
joystick->state |= 0x0f;
|
||||
@@ -240,12 +240,12 @@ gameport_write(uint16_t addr, uint8_t val, void *priv)
|
||||
static uint8_t
|
||||
gameport_read(uint16_t addr, void *priv)
|
||||
{
|
||||
gameport_t *dev = (gameport_t *) priv;
|
||||
gameport_t *dev = (gameport_t *) priv;
|
||||
joystick_instance_t *joystick = dev->joystick;
|
||||
|
||||
/* Respond only if a joystick is present and this port is at the top of the active ports list. */
|
||||
if (!joystick || (active_gameports != dev))
|
||||
return 0xff;
|
||||
return 0xff;
|
||||
|
||||
/* Merge axis state with button state. */
|
||||
uint8_t ret = joystick->state | joystick->intf->read(joystick->dat);
|
||||
@@ -264,7 +264,7 @@ timer_over(void *priv)
|
||||
|
||||
/* Notify the joystick when the first axis' period is finished. */
|
||||
if (axis == &axis->joystick->axis[0])
|
||||
axis->joystick->intf->a0_over(axis->joystick->dat);
|
||||
axis->joystick->intf->a0_over(axis->joystick->dat);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -272,13 +272,13 @@ gameport_update_joystick_type(void)
|
||||
{
|
||||
/* Add a standalone game port if a joystick is enabled but no other game ports exist. */
|
||||
if (standalone_gameport_type)
|
||||
gameport_add(standalone_gameport_type);
|
||||
gameport_add(standalone_gameport_type);
|
||||
|
||||
/* Reset the joystick interface. */
|
||||
if (joystick_instance) {
|
||||
joystick_instance->intf->close(joystick_instance->dat);
|
||||
joystick_instance->intf = joysticks[joystick_type].joystick;
|
||||
joystick_instance->dat = joystick_instance->intf->init();
|
||||
joystick_instance->intf->close(joystick_instance->dat);
|
||||
joystick_instance->intf = joysticks[joystick_type].joystick;
|
||||
joystick_instance->dat = joystick_instance->intf->init();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -288,44 +288,44 @@ gameport_remap(void *priv, uint16_t address)
|
||||
gameport_t *dev = (gameport_t *) priv, *other_dev;
|
||||
|
||||
if (dev->addr) {
|
||||
/* Remove this port from the active ports list. */
|
||||
if (active_gameports == dev) {
|
||||
active_gameports = dev->next;
|
||||
dev->next = NULL;
|
||||
} else {
|
||||
other_dev = active_gameports;
|
||||
while (other_dev) {
|
||||
if (other_dev->next == dev) {
|
||||
other_dev->next = dev->next;
|
||||
dev->next = NULL;
|
||||
break;
|
||||
}
|
||||
other_dev = other_dev->next;
|
||||
}
|
||||
}
|
||||
/* Remove this port from the active ports list. */
|
||||
if (active_gameports == dev) {
|
||||
active_gameports = dev->next;
|
||||
dev->next = NULL;
|
||||
} else {
|
||||
other_dev = active_gameports;
|
||||
while (other_dev) {
|
||||
if (other_dev->next == dev) {
|
||||
other_dev->next = dev->next;
|
||||
dev->next = NULL;
|
||||
break;
|
||||
}
|
||||
other_dev = other_dev->next;
|
||||
}
|
||||
}
|
||||
|
||||
io_removehandler(dev->addr, dev->len,
|
||||
gameport_read, NULL, NULL, gameport_write, NULL, NULL, dev);
|
||||
io_removehandler(dev->addr, dev->len,
|
||||
gameport_read, NULL, NULL, gameport_write, NULL, NULL, dev);
|
||||
}
|
||||
|
||||
dev->addr = address;
|
||||
|
||||
if (dev->addr) {
|
||||
/* Add this port to the active ports list. */
|
||||
if (!active_gameports || ((dev->addr & 0xfff8) == 0x200)) {
|
||||
/* No ports have been added yet, or port within 200-207h: add to top. */
|
||||
dev->next = active_gameports;
|
||||
active_gameports = dev;
|
||||
} else {
|
||||
/* Port at other addresses: add to bottom. */
|
||||
other_dev = active_gameports;
|
||||
while (other_dev->next)
|
||||
other_dev = other_dev->next;
|
||||
other_dev->next = dev;
|
||||
}
|
||||
/* Add this port to the active ports list. */
|
||||
if (!active_gameports || ((dev->addr & 0xfff8) == 0x200)) {
|
||||
/* No ports have been added yet, or port within 200-207h: add to top. */
|
||||
dev->next = active_gameports;
|
||||
active_gameports = dev;
|
||||
} else {
|
||||
/* Port at other addresses: add to bottom. */
|
||||
other_dev = active_gameports;
|
||||
while (other_dev->next)
|
||||
other_dev = other_dev->next;
|
||||
other_dev->next = dev;
|
||||
}
|
||||
|
||||
io_sethandler(dev->addr, dev->len,
|
||||
gameport_read, NULL, NULL, gameport_write, NULL, NULL, dev);
|
||||
io_sethandler(dev->addr, dev->len,
|
||||
gameport_read, NULL, NULL, gameport_write, NULL, NULL, dev);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -333,7 +333,7 @@ static void
|
||||
gameport_pnp_config_changed(uint8_t ld, isapnp_device_config_t *config, void *priv)
|
||||
{
|
||||
if (ld > 0)
|
||||
return;
|
||||
return;
|
||||
|
||||
gameport_t *dev = (gameport_t *) priv;
|
||||
|
||||
@@ -347,7 +347,7 @@ gameport_add(const device_t *gameport_type)
|
||||
/* Prevent a standalone game port from being added later on, unless this
|
||||
is an unused Super I/O game port (no MACHINE_GAMEPORT machine flag). */
|
||||
if (!(gameport_type->local & GAMEPORT_SIO) || machine_has_flags(machine, MACHINE_GAMEPORT))
|
||||
standalone_gameport_type = NULL;
|
||||
standalone_gameport_type = NULL;
|
||||
|
||||
/* Add game port device. */
|
||||
return device_add_inst(gameport_type, gameport_instance_id++);
|
||||
@@ -363,26 +363,26 @@ gameport_init(const device_t *info)
|
||||
|
||||
/* Allocate global instance. */
|
||||
if (!joystick_instance && joystick_type) {
|
||||
joystick_instance = malloc(sizeof(joystick_instance_t));
|
||||
memset(joystick_instance, 0x00, sizeof(joystick_instance_t));
|
||||
joystick_instance = malloc(sizeof(joystick_instance_t));
|
||||
memset(joystick_instance, 0x00, sizeof(joystick_instance_t));
|
||||
|
||||
joystick_instance->axis[0].joystick = joystick_instance;
|
||||
joystick_instance->axis[1].joystick = joystick_instance;
|
||||
joystick_instance->axis[2].joystick = joystick_instance;
|
||||
joystick_instance->axis[3].joystick = joystick_instance;
|
||||
joystick_instance->axis[0].joystick = joystick_instance;
|
||||
joystick_instance->axis[1].joystick = joystick_instance;
|
||||
joystick_instance->axis[2].joystick = joystick_instance;
|
||||
joystick_instance->axis[3].joystick = joystick_instance;
|
||||
|
||||
joystick_instance->axis[0].axis_nr = 0;
|
||||
joystick_instance->axis[1].axis_nr = 1;
|
||||
joystick_instance->axis[2].axis_nr = 2;
|
||||
joystick_instance->axis[3].axis_nr = 3;
|
||||
joystick_instance->axis[0].axis_nr = 0;
|
||||
joystick_instance->axis[1].axis_nr = 1;
|
||||
joystick_instance->axis[2].axis_nr = 2;
|
||||
joystick_instance->axis[3].axis_nr = 3;
|
||||
|
||||
timer_add(&joystick_instance->axis[0].timer, timer_over, &joystick_instance->axis[0], 0);
|
||||
timer_add(&joystick_instance->axis[1].timer, timer_over, &joystick_instance->axis[1], 0);
|
||||
timer_add(&joystick_instance->axis[2].timer, timer_over, &joystick_instance->axis[2], 0);
|
||||
timer_add(&joystick_instance->axis[3].timer, timer_over, &joystick_instance->axis[3], 0);
|
||||
timer_add(&joystick_instance->axis[0].timer, timer_over, &joystick_instance->axis[0], 0);
|
||||
timer_add(&joystick_instance->axis[1].timer, timer_over, &joystick_instance->axis[1], 0);
|
||||
timer_add(&joystick_instance->axis[2].timer, timer_over, &joystick_instance->axis[2], 0);
|
||||
timer_add(&joystick_instance->axis[3].timer, timer_over, &joystick_instance->axis[3], 0);
|
||||
|
||||
joystick_instance->intf = joysticks[joystick_type].joystick;
|
||||
joystick_instance->dat = joystick_instance->intf->init();
|
||||
joystick_instance->intf = joysticks[joystick_type].joystick;
|
||||
joystick_instance->dat = joystick_instance->intf->init();
|
||||
}
|
||||
|
||||
dev->joystick = joystick_instance;
|
||||
@@ -393,7 +393,7 @@ gameport_init(const device_t *info)
|
||||
|
||||
/* Register ISAPnP if this is a standard game port card. */
|
||||
if ((info->local & 0xffff) == 0x200)
|
||||
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;
|
||||
}
|
||||
@@ -401,14 +401,14 @@ gameport_init(const device_t *info)
|
||||
static void *
|
||||
tmacm_init(const device_t *info)
|
||||
{
|
||||
uint16_t port = 0x0000;
|
||||
gameport_t *dev = NULL;
|
||||
uint16_t port = 0x0000;
|
||||
gameport_t *dev = NULL;
|
||||
|
||||
dev = malloc(sizeof(gameport_t));
|
||||
memset(dev, 0x00, sizeof(gameport_t));
|
||||
|
||||
port = device_get_config_hex16("port1_addr");
|
||||
switch(port) {
|
||||
switch (port) {
|
||||
case 0x201:
|
||||
dev = gameport_add(&gameport_201_device);
|
||||
break;
|
||||
@@ -426,7 +426,7 @@ tmacm_init(const device_t *info)
|
||||
}
|
||||
|
||||
port = device_get_config_hex16("port2_addr");
|
||||
switch(port) {
|
||||
switch (port) {
|
||||
case 0x201:
|
||||
dev = gameport_add(&gameport_209_device);
|
||||
break;
|
||||
@@ -456,156 +456,157 @@ gameport_close(void *priv)
|
||||
|
||||
/* Free the global instance here, if it wasn't already freed. */
|
||||
if (joystick_instance) {
|
||||
joystick_instance->intf->close(joystick_instance->dat);
|
||||
joystick_instance->intf->close(joystick_instance->dat);
|
||||
|
||||
free(joystick_instance);
|
||||
joystick_instance = NULL;
|
||||
free(joystick_instance);
|
||||
joystick_instance = NULL;
|
||||
}
|
||||
|
||||
free(dev);
|
||||
}
|
||||
|
||||
const device_t gameport_device = {
|
||||
.name = "Game port",
|
||||
.name = "Game port",
|
||||
.internal_name = "gameport",
|
||||
.flags = 0,
|
||||
.local = 0x080200,
|
||||
.init = gameport_init,
|
||||
.close = gameport_close,
|
||||
.reset = NULL,
|
||||
.flags = 0,
|
||||
.local = 0x080200,
|
||||
.init = gameport_init,
|
||||
.close = gameport_close,
|
||||
.reset = NULL,
|
||||
{ .available = NULL },
|
||||
.speed_changed = NULL,
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t gameport_201_device = {
|
||||
.name = "Game port (Port 201h only)",
|
||||
.name = "Game port (Port 201h only)",
|
||||
.internal_name = "gameport_201",
|
||||
.flags = 0,
|
||||
.local = 0x010201,
|
||||
.init = gameport_init,
|
||||
.close = gameport_close,
|
||||
.reset = NULL,
|
||||
.flags = 0,
|
||||
.local = 0x010201,
|
||||
.init = gameport_init,
|
||||
.close = gameport_close,
|
||||
.reset = NULL,
|
||||
{ .available = NULL },
|
||||
.speed_changed = NULL,
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t gameport_203_device = {
|
||||
.name = "Game port (Port 203h only)",
|
||||
.name = "Game port (Port 203h only)",
|
||||
.internal_name = "gameport_203",
|
||||
.flags = 0,
|
||||
.local = 0x010203,
|
||||
.init = gameport_init,
|
||||
.close = gameport_close,
|
||||
.reset = NULL,
|
||||
.flags = 0,
|
||||
.local = 0x010203,
|
||||
.init = gameport_init,
|
||||
.close = gameport_close,
|
||||
.reset = NULL,
|
||||
{ .available = NULL },
|
||||
.speed_changed = NULL,
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t gameport_205_device = {
|
||||
.name = "Game port (Port 205h only)",
|
||||
.name = "Game port (Port 205h only)",
|
||||
.internal_name = "gameport_205",
|
||||
.flags = 0,
|
||||
.local = 0x010205,
|
||||
.init = gameport_init,
|
||||
.close = gameport_close,
|
||||
.reset = NULL,
|
||||
.flags = 0,
|
||||
.local = 0x010205,
|
||||
.init = gameport_init,
|
||||
.close = gameport_close,
|
||||
.reset = NULL,
|
||||
{ .available = NULL },
|
||||
.speed_changed = NULL,
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t gameport_207_device = {
|
||||
.name = "Game port (Port 207h only)",
|
||||
.name = "Game port (Port 207h only)",
|
||||
.internal_name = "gameport_207",
|
||||
.flags = 0,
|
||||
.local = 0x010207,
|
||||
.init = gameport_init,
|
||||
.close = gameport_close,
|
||||
.reset = NULL,
|
||||
.flags = 0,
|
||||
.local = 0x010207,
|
||||
.init = gameport_init,
|
||||
.close = gameport_close,
|
||||
.reset = NULL,
|
||||
{ .available = NULL },
|
||||
.speed_changed = NULL,
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t gameport_208_device = {
|
||||
.name = "Game port (Port 208h-20fh)",
|
||||
.name = "Game port (Port 208h-20fh)",
|
||||
.internal_name = "gameport_208",
|
||||
.flags = 0,
|
||||
.local = 0x080208,
|
||||
.init = gameport_init,
|
||||
.close = gameport_close,
|
||||
.reset = NULL,
|
||||
.flags = 0,
|
||||
.local = 0x080208,
|
||||
.init = gameport_init,
|
||||
.close = gameport_close,
|
||||
.reset = NULL,
|
||||
{ .available = NULL },
|
||||
.speed_changed = NULL,
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t gameport_209_device = {
|
||||
.name = "Game port (Port 209h only)",
|
||||
.name = "Game port (Port 209h only)",
|
||||
.internal_name = "gameport_209",
|
||||
.flags = 0,
|
||||
.local = 0x010209,
|
||||
.init = gameport_init,
|
||||
.close = gameport_close,
|
||||
.reset = NULL,
|
||||
.flags = 0,
|
||||
.local = 0x010209,
|
||||
.init = gameport_init,
|
||||
.close = gameport_close,
|
||||
.reset = NULL,
|
||||
{ .available = NULL },
|
||||
.speed_changed = NULL,
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t gameport_20b_device = {
|
||||
.name = "Game port (Port 20Bh only)",
|
||||
.name = "Game port (Port 20Bh only)",
|
||||
.internal_name = "gameport_20b",
|
||||
.flags = 0,
|
||||
.local = 0x01020B,
|
||||
.init = gameport_init,
|
||||
.close = gameport_close,
|
||||
.reset = NULL,
|
||||
.flags = 0,
|
||||
.local = 0x01020B,
|
||||
.init = gameport_init,
|
||||
.close = gameport_close,
|
||||
.reset = NULL,
|
||||
{ .available = NULL },
|
||||
.speed_changed = NULL,
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t gameport_20d_device = {
|
||||
.name = "Game port (Port 20Dh only)",
|
||||
.name = "Game port (Port 20Dh only)",
|
||||
.internal_name = "gameport_20d",
|
||||
.flags = 0,
|
||||
.local = 0x01020D,
|
||||
.init = gameport_init,
|
||||
.close = gameport_close,
|
||||
.reset = NULL,
|
||||
.flags = 0,
|
||||
.local = 0x01020D,
|
||||
.init = gameport_init,
|
||||
.close = gameport_close,
|
||||
.reset = NULL,
|
||||
{ .available = NULL },
|
||||
.speed_changed = NULL,
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t gameport_20f_device = {
|
||||
.name = "Game port (Port 20Fh only)",
|
||||
.name = "Game port (Port 20Fh only)",
|
||||
.internal_name = "gameport_20f",
|
||||
.flags = 0,
|
||||
.local = 0x01020F,
|
||||
.init = gameport_init,
|
||||
.close = gameport_close,
|
||||
.reset = NULL,
|
||||
.flags = 0,
|
||||
.local = 0x01020F,
|
||||
.init = gameport_init,
|
||||
.close = gameport_close,
|
||||
.reset = NULL,
|
||||
{ .available = NULL },
|
||||
.speed_changed = NULL,
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
static const device_config_t tmacm_config[] = {
|
||||
// clang-format off
|
||||
{
|
||||
.name = "port1_addr",
|
||||
.description = "Port 1 Address",
|
||||
@@ -641,74 +642,75 @@ static const device_config_t tmacm_config[] = {
|
||||
}
|
||||
},
|
||||
{ "", "", -1 }
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
const device_t gameport_tm_acm_device = {
|
||||
.name = "Game port (ThrustMaster ACM)",
|
||||
.name = "Game port (ThrustMaster ACM)",
|
||||
.internal_name = "gameport_tmacm",
|
||||
.flags = DEVICE_ISA,
|
||||
.local = 0,
|
||||
.init = tmacm_init,
|
||||
.close = NULL,
|
||||
.reset = NULL,
|
||||
.flags = DEVICE_ISA,
|
||||
.local = 0,
|
||||
.init = tmacm_init,
|
||||
.close = NULL,
|
||||
.reset = NULL,
|
||||
{ .available = NULL },
|
||||
.speed_changed = NULL,
|
||||
.force_redraw = NULL,
|
||||
.config = tmacm_config
|
||||
.force_redraw = NULL,
|
||||
.config = tmacm_config
|
||||
};
|
||||
|
||||
const device_t gameport_pnp_device = {
|
||||
.name = "Game port (Plug and Play only)",
|
||||
.name = "Game port (Plug and Play only)",
|
||||
.internal_name = "gameport_pnp",
|
||||
.flags = 0,
|
||||
.local = 0x080000,
|
||||
.init = gameport_init,
|
||||
.close = gameport_close,
|
||||
.reset = NULL,
|
||||
.flags = 0,
|
||||
.local = 0x080000,
|
||||
.init = gameport_init,
|
||||
.close = gameport_close,
|
||||
.reset = NULL,
|
||||
{ .available = NULL },
|
||||
.speed_changed = NULL,
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t gameport_pnp_6io_device = {
|
||||
.name = "Game port (Plug and Play only, 6 I/O ports)",
|
||||
.name = "Game port (Plug and Play only, 6 I/O ports)",
|
||||
.internal_name = "gameport_pnp_6io",
|
||||
.flags = 0,
|
||||
.local = 0x060000,
|
||||
.init = gameport_init,
|
||||
.close = gameport_close,
|
||||
.reset = NULL,
|
||||
.flags = 0,
|
||||
.local = 0x060000,
|
||||
.init = gameport_init,
|
||||
.close = gameport_close,
|
||||
.reset = NULL,
|
||||
{ .available = NULL },
|
||||
.speed_changed = NULL,
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
const device_t gameport_sio_device = {
|
||||
.name = "Game port (Super I/O)",
|
||||
.name = "Game port (Super I/O)",
|
||||
.internal_name = "gameport_sio",
|
||||
.flags = 0,
|
||||
.local = 0x1080000,
|
||||
.init = gameport_init,
|
||||
.close = gameport_close,
|
||||
.reset = NULL,
|
||||
.flags = 0,
|
||||
.local = 0x1080000,
|
||||
.init = gameport_init,
|
||||
.close = gameport_close,
|
||||
.reset = NULL,
|
||||
{ .available = NULL },
|
||||
.speed_changed = NULL,
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
};
|
||||
|
||||
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",
|
||||
.flags = 0,
|
||||
.local = 0x1010000,
|
||||
.init = gameport_init,
|
||||
.close = gameport_close,
|
||||
.reset = NULL,
|
||||
.flags = 0,
|
||||
.local = 0x1010000,
|
||||
.init = gameport_init,
|
||||
.close = gameport_close,
|
||||
.reset = NULL,
|
||||
{ .available = NULL },
|
||||
.speed_changed = NULL,
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
.force_redraw = NULL,
|
||||
.config = NULL
|
||||
};
|
||||
|
@@ -45,89 +45,90 @@
|
||||
#include <86box/gameport.h>
|
||||
#include <86box/joystick_standard.h>
|
||||
|
||||
|
||||
static void *ch_flightstick_pro_init(void)
|
||||
static void *
|
||||
ch_flightstick_pro_init(void)
|
||||
{
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void ch_flightstick_pro_close(void *p)
|
||||
static void
|
||||
ch_flightstick_pro_close(void *p)
|
||||
{
|
||||
}
|
||||
|
||||
static uint8_t ch_flightstick_pro_read(void *p)
|
||||
static uint8_t
|
||||
ch_flightstick_pro_read(void *p)
|
||||
{
|
||||
uint8_t ret = 0xf0;
|
||||
uint8_t ret = 0xf0;
|
||||
|
||||
if (JOYSTICK_PRESENT(0))
|
||||
{
|
||||
if (joystick_state[0].button[0])
|
||||
ret &= ~0x10;
|
||||
if (joystick_state[0].button[1])
|
||||
ret &= ~0x20;
|
||||
if (joystick_state[0].button[2])
|
||||
ret &= ~0x40;
|
||||
if (joystick_state[0].button[3])
|
||||
ret &= ~0x80;
|
||||
if (joystick_state[0].pov[0] != -1)
|
||||
{
|
||||
if (joystick_state[0].pov[0] > 315 || joystick_state[0].pov[0] < 45)
|
||||
ret &= ~0xf0;
|
||||
else if (joystick_state[0].pov[0] >= 45 && joystick_state[0].pov[0] < 135)
|
||||
ret &= ~0xb0;
|
||||
else if (joystick_state[0].pov[0] >= 135 && joystick_state[0].pov[0] < 225)
|
||||
ret &= ~0x70;
|
||||
else if (joystick_state[0].pov[0] >= 225 && joystick_state[0].pov[0] < 315)
|
||||
ret &= ~0x30;
|
||||
}
|
||||
if (JOYSTICK_PRESENT(0)) {
|
||||
if (joystick_state[0].button[0])
|
||||
ret &= ~0x10;
|
||||
if (joystick_state[0].button[1])
|
||||
ret &= ~0x20;
|
||||
if (joystick_state[0].button[2])
|
||||
ret &= ~0x40;
|
||||
if (joystick_state[0].button[3])
|
||||
ret &= ~0x80;
|
||||
if (joystick_state[0].pov[0] != -1) {
|
||||
if (joystick_state[0].pov[0] > 315 || joystick_state[0].pov[0] < 45)
|
||||
ret &= ~0xf0;
|
||||
else if (joystick_state[0].pov[0] >= 45 && joystick_state[0].pov[0] < 135)
|
||||
ret &= ~0xb0;
|
||||
else if (joystick_state[0].pov[0] >= 135 && joystick_state[0].pov[0] < 225)
|
||||
ret &= ~0x70;
|
||||
else if (joystick_state[0].pov[0] >= 225 && joystick_state[0].pov[0] < 315)
|
||||
ret &= ~0x30;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void ch_flightstick_pro_write(void *p)
|
||||
static void
|
||||
ch_flightstick_pro_write(void *p)
|
||||
{
|
||||
}
|
||||
|
||||
static int ch_flightstick_pro_read_axis(void *p, int axis)
|
||||
static int
|
||||
ch_flightstick_pro_read_axis(void *p, int axis)
|
||||
{
|
||||
if (!JOYSTICK_PRESENT(0))
|
||||
return AXIS_NOT_PRESENT;
|
||||
if (!JOYSTICK_PRESENT(0))
|
||||
return AXIS_NOT_PRESENT;
|
||||
|
||||
switch (axis)
|
||||
{
|
||||
case 0:
|
||||
return joystick_state[0].axis[0];
|
||||
case 1:
|
||||
return joystick_state[0].axis[1];
|
||||
case 2:
|
||||
return 0;
|
||||
case 3:
|
||||
return joystick_state[0].axis[2];
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
switch (axis) {
|
||||
case 0:
|
||||
return joystick_state[0].axis[0];
|
||||
case 1:
|
||||
return joystick_state[0].axis[1];
|
||||
case 2:
|
||||
return 0;
|
||||
case 3:
|
||||
return joystick_state[0].axis[2];
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void ch_flightstick_pro_a0_over(void *p)
|
||||
static void
|
||||
ch_flightstick_pro_a0_over(void *p)
|
||||
{
|
||||
}
|
||||
|
||||
const joystick_if_t joystick_ch_flightstick_pro =
|
||||
{
|
||||
.name = "CH Flightstick Pro",
|
||||
const joystick_if_t joystick_ch_flightstick_pro = {
|
||||
.name = "CH Flightstick Pro",
|
||||
.internal_name = "ch_flightstick_pro",
|
||||
.init = ch_flightstick_pro_init,
|
||||
.close = ch_flightstick_pro_close,
|
||||
.read = ch_flightstick_pro_read,
|
||||
.write = ch_flightstick_pro_write,
|
||||
.read_axis = ch_flightstick_pro_read_axis,
|
||||
.a0_over = ch_flightstick_pro_a0_over,
|
||||
.axis_count = 3,
|
||||
.button_count = 4,
|
||||
.pov_count = 1,
|
||||
.init = ch_flightstick_pro_init,
|
||||
.close = ch_flightstick_pro_close,
|
||||
.read = ch_flightstick_pro_read,
|
||||
.write = ch_flightstick_pro_write,
|
||||
.read_axis = ch_flightstick_pro_read_axis,
|
||||
.a0_over = ch_flightstick_pro_a0_over,
|
||||
.axis_count = 3,
|
||||
.button_count = 4,
|
||||
.pov_count = 1,
|
||||
.max_joysticks = 1,
|
||||
.axis_names = { "X axis", "Y axis", "Throttle" },
|
||||
.button_names = { "Button 1", "Button 2", "Button 3", "Button 4" },
|
||||
.pov_names = { "POV" }
|
||||
.axis_names = {"X axis", "Y axis", "Throttle" },
|
||||
.button_names = { "Button 1", "Button 2", "Button 3", "Button 4" },
|
||||
.pov_names = { "POV"}
|
||||
};
|
||||
|
@@ -45,319 +45,321 @@
|
||||
#include <86box/gameport.h>
|
||||
#include <86box/joystick_standard.h>
|
||||
|
||||
|
||||
static void *joystick_standard_init(void)
|
||||
static void *
|
||||
joystick_standard_init(void)
|
||||
{
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void joystick_standard_close(void *p)
|
||||
static void
|
||||
joystick_standard_close(void *p)
|
||||
{
|
||||
}
|
||||
|
||||
static uint8_t joystick_standard_read(void *p)
|
||||
static uint8_t
|
||||
joystick_standard_read(void *p)
|
||||
{
|
||||
uint8_t ret = 0xf0;
|
||||
uint8_t ret = 0xf0;
|
||||
|
||||
if (JOYSTICK_PRESENT(0))
|
||||
{
|
||||
if (joystick_state[0].button[0])
|
||||
ret &= ~0x10;
|
||||
if (joystick_state[0].button[1])
|
||||
ret &= ~0x20;
|
||||
}
|
||||
if (JOYSTICK_PRESENT(1))
|
||||
{
|
||||
if (joystick_state[1].button[0])
|
||||
ret &= ~0x40;
|
||||
if (joystick_state[1].button[1])
|
||||
ret &= ~0x80;
|
||||
}
|
||||
if (JOYSTICK_PRESENT(0)) {
|
||||
if (joystick_state[0].button[0])
|
||||
ret &= ~0x10;
|
||||
if (joystick_state[0].button[1])
|
||||
ret &= ~0x20;
|
||||
}
|
||||
if (JOYSTICK_PRESENT(1)) {
|
||||
if (joystick_state[1].button[0])
|
||||
ret &= ~0x40;
|
||||
if (joystick_state[1].button[1])
|
||||
ret &= ~0x80;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static uint8_t joystick_standard_read_4button(void *p)
|
||||
static uint8_t
|
||||
joystick_standard_read_4button(void *p)
|
||||
{
|
||||
uint8_t ret = 0xf0;
|
||||
uint8_t ret = 0xf0;
|
||||
|
||||
if (JOYSTICK_PRESENT(0))
|
||||
{
|
||||
if (joystick_state[0].button[0])
|
||||
ret &= ~0x10;
|
||||
if (joystick_state[0].button[1])
|
||||
ret &= ~0x20;
|
||||
if (joystick_state[0].button[2])
|
||||
ret &= ~0x40;
|
||||
if (joystick_state[0].button[3])
|
||||
ret &= ~0x80;
|
||||
}
|
||||
if (JOYSTICK_PRESENT(0)) {
|
||||
if (joystick_state[0].button[0])
|
||||
ret &= ~0x10;
|
||||
if (joystick_state[0].button[1])
|
||||
ret &= ~0x20;
|
||||
if (joystick_state[0].button[2])
|
||||
ret &= ~0x40;
|
||||
if (joystick_state[0].button[3])
|
||||
ret &= ~0x80;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void joystick_standard_write(void *p)
|
||||
static void
|
||||
joystick_standard_write(void *p)
|
||||
{
|
||||
}
|
||||
|
||||
static int joystick_standard_read_axis(void *p, int axis)
|
||||
static int
|
||||
joystick_standard_read_axis(void *p, int axis)
|
||||
{
|
||||
switch (axis)
|
||||
{
|
||||
case 0:
|
||||
if (!JOYSTICK_PRESENT(0))
|
||||
return AXIS_NOT_PRESENT;
|
||||
return joystick_state[0].axis[0];
|
||||
case 1:
|
||||
if (!JOYSTICK_PRESENT(0))
|
||||
return AXIS_NOT_PRESENT;
|
||||
return joystick_state[0].axis[1];
|
||||
case 2:
|
||||
if (!JOYSTICK_PRESENT(1))
|
||||
return AXIS_NOT_PRESENT;
|
||||
return joystick_state[1].axis[0];
|
||||
case 3:
|
||||
if (!JOYSTICK_PRESENT(1))
|
||||
return AXIS_NOT_PRESENT;
|
||||
return joystick_state[1].axis[1];
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int joystick_standard_read_axis_4button(void *p, int axis)
|
||||
{
|
||||
if (!JOYSTICK_PRESENT(0))
|
||||
switch (axis) {
|
||||
case 0:
|
||||
if (!JOYSTICK_PRESENT(0))
|
||||
return AXIS_NOT_PRESENT;
|
||||
|
||||
switch (axis)
|
||||
{
|
||||
case 0:
|
||||
return joystick_state[0].axis[0];
|
||||
case 1:
|
||||
return joystick_state[0].axis[1];
|
||||
case 2:
|
||||
return 0;
|
||||
case 3:
|
||||
return 0;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int joystick_standard_read_axis_3axis(void *p, int axis)
|
||||
{
|
||||
if (!JOYSTICK_PRESENT(0))
|
||||
return joystick_state[0].axis[0];
|
||||
case 1:
|
||||
if (!JOYSTICK_PRESENT(0))
|
||||
return AXIS_NOT_PRESENT;
|
||||
|
||||
switch (axis)
|
||||
{
|
||||
case 0:
|
||||
return joystick_state[0].axis[0];
|
||||
case 1:
|
||||
return joystick_state[0].axis[1];
|
||||
case 2:
|
||||
return joystick_state[0].axis[2];
|
||||
case 3:
|
||||
return 0;
|
||||
return joystick_state[0].axis[1];
|
||||
case 2:
|
||||
if (!JOYSTICK_PRESENT(1))
|
||||
return AXIS_NOT_PRESENT;
|
||||
return joystick_state[1].axis[0];
|
||||
case 3:
|
||||
if (!JOYSTICK_PRESENT(1))
|
||||
return AXIS_NOT_PRESENT;
|
||||
return joystick_state[1].axis[1];
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int joystick_standard_read_axis_4axis(void *p, int axis)
|
||||
static int
|
||||
joystick_standard_read_axis_4button(void *p, int axis)
|
||||
{
|
||||
if (!JOYSTICK_PRESENT(0))
|
||||
return AXIS_NOT_PRESENT;
|
||||
if (!JOYSTICK_PRESENT(0))
|
||||
return AXIS_NOT_PRESENT;
|
||||
|
||||
switch (axis)
|
||||
{
|
||||
case 0:
|
||||
return joystick_state[0].axis[0];
|
||||
case 1:
|
||||
return joystick_state[0].axis[1];
|
||||
case 2:
|
||||
return joystick_state[0].axis[2];
|
||||
case 3:
|
||||
return joystick_state[0].axis[3];
|
||||
switch (axis) {
|
||||
case 0:
|
||||
return joystick_state[0].axis[0];
|
||||
case 1:
|
||||
return joystick_state[0].axis[1];
|
||||
case 2:
|
||||
return 0;
|
||||
case 3:
|
||||
return 0;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int joystick_standard_read_axis_6button(void *p, int axis)
|
||||
static int
|
||||
joystick_standard_read_axis_3axis(void *p, int axis)
|
||||
{
|
||||
if (!JOYSTICK_PRESENT(0))
|
||||
return AXIS_NOT_PRESENT;
|
||||
if (!JOYSTICK_PRESENT(0))
|
||||
return AXIS_NOT_PRESENT;
|
||||
|
||||
switch (axis)
|
||||
{
|
||||
case 0:
|
||||
return joystick_state[0].axis[0];
|
||||
case 1:
|
||||
return joystick_state[0].axis[1];
|
||||
case 2:
|
||||
return joystick_state[0].button[4] ? -32767 : 32768;
|
||||
case 3:
|
||||
return joystick_state[0].button[5] ? -32767 : 32768;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
switch (axis) {
|
||||
case 0:
|
||||
return joystick_state[0].axis[0];
|
||||
case 1:
|
||||
return joystick_state[0].axis[1];
|
||||
case 2:
|
||||
return joystick_state[0].axis[2];
|
||||
case 3:
|
||||
return 0;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
static int joystick_standard_read_axis_8button(void *p, int axis)
|
||||
|
||||
static int
|
||||
joystick_standard_read_axis_4axis(void *p, int axis)
|
||||
{
|
||||
if (!JOYSTICK_PRESENT(0))
|
||||
return AXIS_NOT_PRESENT;
|
||||
if (!JOYSTICK_PRESENT(0))
|
||||
return AXIS_NOT_PRESENT;
|
||||
|
||||
switch (axis)
|
||||
{
|
||||
case 0:
|
||||
return joystick_state[0].axis[0];
|
||||
case 1:
|
||||
return joystick_state[0].axis[1];
|
||||
case 2:
|
||||
if (joystick_state[0].button[4])
|
||||
return -32767;
|
||||
if (joystick_state[0].button[6])
|
||||
return 32768;
|
||||
return 0;
|
||||
case 3:
|
||||
if (joystick_state[0].button[5])
|
||||
return -32767;
|
||||
if (joystick_state[0].button[7])
|
||||
return 32768;
|
||||
return 0;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
switch (axis) {
|
||||
case 0:
|
||||
return joystick_state[0].axis[0];
|
||||
case 1:
|
||||
return joystick_state[0].axis[1];
|
||||
case 2:
|
||||
return joystick_state[0].axis[2];
|
||||
case 3:
|
||||
return joystick_state[0].axis[3];
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void joystick_standard_a0_over(void *p)
|
||||
static int
|
||||
joystick_standard_read_axis_6button(void *p, int axis)
|
||||
{
|
||||
if (!JOYSTICK_PRESENT(0))
|
||||
return AXIS_NOT_PRESENT;
|
||||
|
||||
switch (axis) {
|
||||
case 0:
|
||||
return joystick_state[0].axis[0];
|
||||
case 1:
|
||||
return joystick_state[0].axis[1];
|
||||
case 2:
|
||||
return joystick_state[0].button[4] ? -32767 : 32768;
|
||||
case 3:
|
||||
return joystick_state[0].button[5] ? -32767 : 32768;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
static int
|
||||
joystick_standard_read_axis_8button(void *p, int axis)
|
||||
{
|
||||
if (!JOYSTICK_PRESENT(0))
|
||||
return AXIS_NOT_PRESENT;
|
||||
|
||||
switch (axis) {
|
||||
case 0:
|
||||
return joystick_state[0].axis[0];
|
||||
case 1:
|
||||
return joystick_state[0].axis[1];
|
||||
case 2:
|
||||
if (joystick_state[0].button[4])
|
||||
return -32767;
|
||||
if (joystick_state[0].button[6])
|
||||
return 32768;
|
||||
return 0;
|
||||
case 3:
|
||||
if (joystick_state[0].button[5])
|
||||
return -32767;
|
||||
if (joystick_state[0].button[7])
|
||||
return 32768;
|
||||
return 0;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
joystick_standard_a0_over(void *p)
|
||||
{
|
||||
}
|
||||
|
||||
const joystick_if_t joystick_2axis_2button = {
|
||||
.name = "2-axis, 2-button joystick(s)",
|
||||
.name = "2-axis, 2-button joystick(s)",
|
||||
.internal_name = "2axis_2button",
|
||||
.init = joystick_standard_init,
|
||||
.close = joystick_standard_close,
|
||||
.read = joystick_standard_read,
|
||||
.write = joystick_standard_write,
|
||||
.read_axis = joystick_standard_read_axis,
|
||||
.a0_over = joystick_standard_a0_over,
|
||||
.axis_count = 2,
|
||||
.button_count = 2,
|
||||
.pov_count = 0,
|
||||
.init = joystick_standard_init,
|
||||
.close = joystick_standard_close,
|
||||
.read = joystick_standard_read,
|
||||
.write = joystick_standard_write,
|
||||
.read_axis = joystick_standard_read_axis,
|
||||
.a0_over = joystick_standard_a0_over,
|
||||
.axis_count = 2,
|
||||
.button_count = 2,
|
||||
.pov_count = 0,
|
||||
.max_joysticks = 2,
|
||||
.axis_names = { "X axis", "Y axis" },
|
||||
.button_names = { "Button 1", "Button 2" },
|
||||
.pov_names = { NULL }
|
||||
.axis_names = {"X axis", "Y axis" },
|
||||
.button_names = { "Button 1", "Button 2" },
|
||||
.pov_names = { NULL}
|
||||
};
|
||||
|
||||
const joystick_if_t joystick_2axis_4button = {
|
||||
.name = "2-axis, 4-button joystick",
|
||||
.name = "2-axis, 4-button joystick",
|
||||
.internal_name = "2axis_4button",
|
||||
.init = joystick_standard_init,
|
||||
.close = joystick_standard_close,
|
||||
.read = joystick_standard_read_4button,
|
||||
.write = joystick_standard_write,
|
||||
.read_axis = joystick_standard_read_axis_4button,
|
||||
.a0_over = joystick_standard_a0_over,
|
||||
.axis_count = 2,
|
||||
.button_count = 4,
|
||||
.pov_count = 0,
|
||||
.init = joystick_standard_init,
|
||||
.close = joystick_standard_close,
|
||||
.read = joystick_standard_read_4button,
|
||||
.write = joystick_standard_write,
|
||||
.read_axis = joystick_standard_read_axis_4button,
|
||||
.a0_over = joystick_standard_a0_over,
|
||||
.axis_count = 2,
|
||||
.button_count = 4,
|
||||
.pov_count = 0,
|
||||
.max_joysticks = 1,
|
||||
.axis_names = { "X axis", "Y axis" },
|
||||
.button_names = { "Button 1", "Button 2", "Button 3", "Button 4" },
|
||||
.pov_names = { NULL }
|
||||
.axis_names = {"X axis", "Y axis" },
|
||||
.button_names = { "Button 1", "Button 2", "Button 3", "Button 4" },
|
||||
.pov_names = { NULL}
|
||||
};
|
||||
|
||||
const joystick_if_t joystick_3axis_2button = {
|
||||
.name = "3-axis, 2-button joystick",
|
||||
.name = "3-axis, 2-button joystick",
|
||||
.internal_name = "3axis_2button",
|
||||
.init = joystick_standard_init,
|
||||
.close = joystick_standard_close,
|
||||
.read = joystick_standard_read,
|
||||
.write = joystick_standard_write,
|
||||
.read_axis = joystick_standard_read_axis_3axis,
|
||||
.a0_over = joystick_standard_a0_over,
|
||||
.axis_count = 3,
|
||||
.button_count = 2,
|
||||
.pov_count = 0,
|
||||
.init = joystick_standard_init,
|
||||
.close = joystick_standard_close,
|
||||
.read = joystick_standard_read,
|
||||
.write = joystick_standard_write,
|
||||
.read_axis = joystick_standard_read_axis_3axis,
|
||||
.a0_over = joystick_standard_a0_over,
|
||||
.axis_count = 3,
|
||||
.button_count = 2,
|
||||
.pov_count = 0,
|
||||
.max_joysticks = 1,
|
||||
.axis_names = { "X axis", "Y axis", "Z axis" },
|
||||
.button_names = { "Button 1", "Button 2" },
|
||||
.pov_names = { NULL }
|
||||
.axis_names = {"X axis", "Y axis", "Z axis" },
|
||||
.button_names = { "Button 1", "Button 2" },
|
||||
.pov_names = { NULL}
|
||||
};
|
||||
|
||||
const joystick_if_t joystick_3axis_4button = {
|
||||
.name = "3-axis, 4-button joystick",
|
||||
.name = "3-axis, 4-button joystick",
|
||||
.internal_name = "3axis_4button",
|
||||
.init = joystick_standard_init,
|
||||
.close = joystick_standard_close,
|
||||
.read = joystick_standard_read_4button,
|
||||
.write = joystick_standard_write,
|
||||
.read_axis = joystick_standard_read_axis_3axis,
|
||||
.a0_over = joystick_standard_a0_over,
|
||||
.axis_count = 3,
|
||||
.button_count = 4,
|
||||
.pov_count = 0,
|
||||
.init = joystick_standard_init,
|
||||
.close = joystick_standard_close,
|
||||
.read = joystick_standard_read_4button,
|
||||
.write = joystick_standard_write,
|
||||
.read_axis = joystick_standard_read_axis_3axis,
|
||||
.a0_over = joystick_standard_a0_over,
|
||||
.axis_count = 3,
|
||||
.button_count = 4,
|
||||
.pov_count = 0,
|
||||
.max_joysticks = 1,
|
||||
.axis_names = { "X axis", "Y axis", "Z axis" },
|
||||
.button_names = { "Button 1", "Button 2", "Button 3", "Button 4" },
|
||||
.pov_names = { NULL }
|
||||
.axis_names = {"X axis", "Y axis", "Z axis" },
|
||||
.button_names = { "Button 1", "Button 2", "Button 3", "Button 4" },
|
||||
.pov_names = { NULL}
|
||||
};
|
||||
|
||||
const joystick_if_t joystick_4axis_4button = {
|
||||
.name = "4-axis, 4-button joystick",
|
||||
.name = "4-axis, 4-button joystick",
|
||||
.internal_name = "4axis_4button",
|
||||
.init = joystick_standard_init,
|
||||
.close = joystick_standard_close,
|
||||
.read = joystick_standard_read_4button,
|
||||
.write = joystick_standard_write,
|
||||
.read_axis = joystick_standard_read_axis_4axis,
|
||||
.a0_over = joystick_standard_a0_over,
|
||||
.axis_count = 4,
|
||||
.button_count = 4,
|
||||
.pov_count = 0,
|
||||
.init = joystick_standard_init,
|
||||
.close = joystick_standard_close,
|
||||
.read = joystick_standard_read_4button,
|
||||
.write = joystick_standard_write,
|
||||
.read_axis = joystick_standard_read_axis_4axis,
|
||||
.a0_over = joystick_standard_a0_over,
|
||||
.axis_count = 4,
|
||||
.button_count = 4,
|
||||
.pov_count = 0,
|
||||
.max_joysticks = 1,
|
||||
.axis_names = { "X axis", "Y axis", "Z axis", "zX axis" },
|
||||
.button_names = { "Button 1", "Button 2", "Button 3", "Button 4" },
|
||||
.pov_names = { NULL }
|
||||
.axis_names = {"X axis", "Y axis", "Z axis", "zX axis" },
|
||||
.button_names = { "Button 1", "Button 2", "Button 3", "Button 4" },
|
||||
.pov_names = { NULL }
|
||||
};
|
||||
|
||||
const joystick_if_t joystick_2axis_6button = {
|
||||
.name = "2-axis, 6-button joystick",
|
||||
.name = "2-axis, 6-button joystick",
|
||||
.internal_name = "2axis_6button",
|
||||
.init = joystick_standard_init,
|
||||
.close = joystick_standard_close,
|
||||
.read = joystick_standard_read_4button,
|
||||
.write = joystick_standard_write,
|
||||
.read_axis = joystick_standard_read_axis_6button,
|
||||
.a0_over = joystick_standard_a0_over,
|
||||
.axis_count = 2,
|
||||
.button_count = 6,
|
||||
.pov_count = 0,
|
||||
.init = joystick_standard_init,
|
||||
.close = joystick_standard_close,
|
||||
.read = joystick_standard_read_4button,
|
||||
.write = joystick_standard_write,
|
||||
.read_axis = joystick_standard_read_axis_6button,
|
||||
.a0_over = joystick_standard_a0_over,
|
||||
.axis_count = 2,
|
||||
.button_count = 6,
|
||||
.pov_count = 0,
|
||||
.max_joysticks = 1,
|
||||
.axis_names = { "X axis", "Y axis" },
|
||||
.button_names = { "Button 1", "Button 2", "Button 3", "Button 4", "Button 5", "Button 6" },
|
||||
.pov_names = { NULL }
|
||||
.axis_names = {"X axis", "Y axis" },
|
||||
.button_names = { "Button 1", "Button 2", "Button 3", "Button 4", "Button 5", "Button 6" },
|
||||
.pov_names = { NULL}
|
||||
};
|
||||
|
||||
const joystick_if_t joystick_2axis_8button = {
|
||||
.name = "2-axis, 8-button joystick",
|
||||
.name = "2-axis, 8-button joystick",
|
||||
.internal_name = "2axis_8button",
|
||||
.init = joystick_standard_init,
|
||||
.close = joystick_standard_close,
|
||||
.read = joystick_standard_read_4button,
|
||||
.write = joystick_standard_write,
|
||||
.read_axis = joystick_standard_read_axis_8button,
|
||||
.a0_over = joystick_standard_a0_over,
|
||||
.axis_count = 2,
|
||||
.button_count = 8,
|
||||
.pov_count = 0,
|
||||
.init = joystick_standard_init,
|
||||
.close = joystick_standard_close,
|
||||
.read = joystick_standard_read_4button,
|
||||
.write = joystick_standard_write,
|
||||
.read_axis = joystick_standard_read_axis_8button,
|
||||
.a0_over = joystick_standard_a0_over,
|
||||
.axis_count = 2,
|
||||
.button_count = 8,
|
||||
.pov_count = 0,
|
||||
.max_joysticks = 1,
|
||||
.axis_names = { "X axis", "Y axis" },
|
||||
.button_names = { "Button 1", "Button 2", "Button 3", "Button 4", "Button 5", "Button 6", "Button 7", "Button 8" },
|
||||
.pov_names = { NULL }
|
||||
.axis_names = {"X axis", "Y axis" },
|
||||
.button_names = { "Button 1", "Button 2", "Button 3", "Button 4", "Button 5", "Button 6", "Button 7", "Button 8" },
|
||||
.pov_names = { NULL}
|
||||
};
|
||||
|
@@ -66,216 +66,207 @@
|
||||
#include <86box/gameport.h>
|
||||
#include <86box/joystick_sw_pad.h>
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
pc_timer_t poll_timer;
|
||||
int poll_left;
|
||||
int poll_clock;
|
||||
uint64_t poll_data;
|
||||
int poll_mode;
|
||||
pc_timer_t poll_timer;
|
||||
int poll_left;
|
||||
int poll_clock;
|
||||
uint64_t poll_data;
|
||||
int poll_mode;
|
||||
|
||||
pc_timer_t trigger_timer;
|
||||
int data_mode;
|
||||
pc_timer_t trigger_timer;
|
||||
int data_mode;
|
||||
} sw_data;
|
||||
|
||||
static void sw_timer_over(void *p)
|
||||
static void
|
||||
sw_timer_over(void *p)
|
||||
{
|
||||
sw_data *sw = (sw_data *)p;
|
||||
sw_data *sw = (sw_data *) p;
|
||||
|
||||
sw->poll_clock = !sw->poll_clock;
|
||||
sw->poll_clock = !sw->poll_clock;
|
||||
|
||||
if (sw->poll_clock)
|
||||
{
|
||||
sw->poll_data >>= (sw->poll_mode ? 3 : 1);
|
||||
sw->poll_left--;
|
||||
}
|
||||
if (sw->poll_clock) {
|
||||
sw->poll_data >>= (sw->poll_mode ? 3 : 1);
|
||||
sw->poll_left--;
|
||||
}
|
||||
|
||||
if (sw->poll_left == 1 && !sw->poll_clock)
|
||||
timer_advance_u64(&sw->poll_timer, TIMER_USEC * 160);
|
||||
else if (sw->poll_left)
|
||||
timer_advance_u64(&sw->poll_timer, TIMER_USEC * 5);
|
||||
else
|
||||
timer_disable(&sw->poll_timer);
|
||||
if (sw->poll_left == 1 && !sw->poll_clock)
|
||||
timer_advance_u64(&sw->poll_timer, TIMER_USEC * 160);
|
||||
else if (sw->poll_left)
|
||||
timer_advance_u64(&sw->poll_timer, TIMER_USEC * 5);
|
||||
else
|
||||
timer_disable(&sw->poll_timer);
|
||||
}
|
||||
|
||||
static void sw_trigger_timer_over(void *p)
|
||||
static void
|
||||
sw_trigger_timer_over(void *p)
|
||||
{
|
||||
sw_data *sw = (sw_data *)p;
|
||||
sw_data *sw = (sw_data *) p;
|
||||
|
||||
timer_disable(&sw->trigger_timer);
|
||||
timer_disable(&sw->trigger_timer);
|
||||
}
|
||||
|
||||
static int sw_parity(uint16_t data)
|
||||
static int
|
||||
sw_parity(uint16_t data)
|
||||
{
|
||||
int bits_set = 0;
|
||||
int bits_set = 0;
|
||||
|
||||
while (data)
|
||||
{
|
||||
bits_set++;
|
||||
data &= (data - 1);
|
||||
while (data) {
|
||||
bits_set++;
|
||||
data &= (data - 1);
|
||||
}
|
||||
|
||||
return bits_set & 1;
|
||||
}
|
||||
|
||||
static void *
|
||||
sw_init(void)
|
||||
{
|
||||
sw_data *sw = (sw_data *) malloc(sizeof(sw_data));
|
||||
memset(sw, 0, sizeof(sw_data));
|
||||
|
||||
timer_add(&sw->poll_timer, sw_timer_over, sw, 0);
|
||||
timer_add(&sw->trigger_timer, sw_trigger_timer_over, sw, 0);
|
||||
|
||||
return sw;
|
||||
}
|
||||
|
||||
static void
|
||||
sw_close(void *p)
|
||||
{
|
||||
sw_data *sw = (sw_data *) p;
|
||||
|
||||
free(sw);
|
||||
}
|
||||
|
||||
static uint8_t
|
||||
sw_read(void *p)
|
||||
{
|
||||
sw_data *sw = (sw_data *) p;
|
||||
uint8_t temp = 0;
|
||||
|
||||
if (!JOYSTICK_PRESENT(0))
|
||||
return 0xff;
|
||||
|
||||
if (timer_is_enabled(&sw->poll_timer)) {
|
||||
if (sw->poll_clock)
|
||||
temp |= 0x10;
|
||||
|
||||
if (sw->poll_mode)
|
||||
temp |= (sw->poll_data & 7) << 5;
|
||||
else {
|
||||
temp |= ((sw->poll_data & 1) << 5) | 0xc0;
|
||||
if (sw->poll_left > 31 && !(sw->poll_left & 1))
|
||||
temp &= ~0x80;
|
||||
}
|
||||
} else
|
||||
temp |= 0xf0;
|
||||
|
||||
return bits_set & 1;
|
||||
return temp;
|
||||
}
|
||||
|
||||
static void *sw_init(void)
|
||||
static void
|
||||
sw_write(void *p)
|
||||
{
|
||||
sw_data *sw = (sw_data *)malloc(sizeof(sw_data));
|
||||
memset(sw, 0, sizeof(sw_data));
|
||||
sw_data *sw = (sw_data *) p;
|
||||
int64_t time_since_last = timer_get_remaining_us(&sw->trigger_timer);
|
||||
|
||||
timer_add(&sw->poll_timer, sw_timer_over, sw, 0);
|
||||
timer_add(&sw->trigger_timer, sw_trigger_timer_over, sw, 0);
|
||||
if (!JOYSTICK_PRESENT(0))
|
||||
return;
|
||||
|
||||
return sw;
|
||||
}
|
||||
timer_process();
|
||||
|
||||
static void sw_close(void *p)
|
||||
{
|
||||
sw_data *sw = (sw_data *)p;
|
||||
if (!sw->poll_left) {
|
||||
sw->poll_clock = 1;
|
||||
timer_set_delay_u64(&sw->poll_timer, TIMER_USEC * 50);
|
||||
|
||||
free(sw);
|
||||
}
|
||||
if (time_since_last > 9900 && time_since_last < 9940) {
|
||||
sw->poll_mode = 0;
|
||||
sw->poll_left = 49;
|
||||
sw->poll_data = 0x2400ull | (0x1830ull << 15) | (0x19b0ull << 30);
|
||||
} else {
|
||||
int c;
|
||||
|
||||
static uint8_t sw_read(void *p)
|
||||
{
|
||||
sw_data *sw = (sw_data *)p;
|
||||
uint8_t temp = 0;
|
||||
sw->poll_mode = sw->data_mode;
|
||||
sw->data_mode = !sw->data_mode;
|
||||
|
||||
if (!JOYSTICK_PRESENT(0))
|
||||
return 0xff;
|
||||
if (sw->poll_mode) {
|
||||
sw->poll_left = 1;
|
||||
sw->poll_data = 7;
|
||||
} else {
|
||||
sw->poll_left = 1;
|
||||
sw->poll_data = 1;
|
||||
}
|
||||
|
||||
if (timer_is_enabled(&sw->poll_timer))
|
||||
{
|
||||
if (sw->poll_clock)
|
||||
temp |= 0x10;
|
||||
for (c = 0; c < 4; c++) {
|
||||
uint16_t data = 0x3fff;
|
||||
int b;
|
||||
|
||||
if (sw->poll_mode)
|
||||
temp |= (sw->poll_data & 7) << 5;
|
||||
else
|
||||
{
|
||||
temp |= ((sw->poll_data & 1) << 5) | 0xc0;
|
||||
if (sw->poll_left > 31 && !(sw->poll_left & 1))
|
||||
temp &= ~0x80;
|
||||
if (!JOYSTICK_PRESENT(c))
|
||||
break;
|
||||
|
||||
if (joystick_state[c].axis[1] < -16383)
|
||||
data &= ~1;
|
||||
if (joystick_state[c].axis[1] > 16383)
|
||||
data &= ~2;
|
||||
if (joystick_state[c].axis[0] > 16383)
|
||||
data &= ~4;
|
||||
if (joystick_state[c].axis[0] < -16383)
|
||||
data &= ~8;
|
||||
|
||||
for (b = 0; b < 10; b++) {
|
||||
if (joystick_state[c].button[b])
|
||||
data &= ~(1 << (b + 4));
|
||||
}
|
||||
|
||||
if (sw_parity(data))
|
||||
data |= 0x4000;
|
||||
|
||||
if (sw->poll_mode) {
|
||||
sw->poll_left += 5;
|
||||
sw->poll_data |= (data << (c * 15 + 3));
|
||||
} else {
|
||||
sw->poll_left += 15;
|
||||
sw->poll_data |= (data << (c * 15 + 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
temp |= 0xf0;
|
||||
}
|
||||
|
||||
return temp;
|
||||
timer_disable(&sw->trigger_timer);
|
||||
}
|
||||
|
||||
static void sw_write(void *p)
|
||||
static int
|
||||
sw_read_axis(void *p, int axis)
|
||||
{
|
||||
sw_data *sw = (sw_data *)p;
|
||||
int64_t time_since_last = timer_get_remaining_us(&sw->trigger_timer);
|
||||
if (!JOYSTICK_PRESENT(0))
|
||||
return AXIS_NOT_PRESENT;
|
||||
|
||||
if (!JOYSTICK_PRESENT(0))
|
||||
return;
|
||||
|
||||
timer_process();
|
||||
|
||||
if (!sw->poll_left)
|
||||
{
|
||||
sw->poll_clock = 1;
|
||||
timer_set_delay_u64(&sw->poll_timer, TIMER_USEC * 50);
|
||||
|
||||
if (time_since_last > 9900 && time_since_last < 9940)
|
||||
{
|
||||
sw->poll_mode = 0;
|
||||
sw->poll_left = 49;
|
||||
sw->poll_data = 0x2400ull | (0x1830ull << 15) | (0x19b0ull << 30);
|
||||
}
|
||||
else
|
||||
{
|
||||
int c;
|
||||
|
||||
sw->poll_mode = sw->data_mode;
|
||||
sw->data_mode = !sw->data_mode;
|
||||
|
||||
if (sw->poll_mode)
|
||||
{
|
||||
sw->poll_left = 1;
|
||||
sw->poll_data = 7;
|
||||
}
|
||||
else
|
||||
{
|
||||
sw->poll_left = 1;
|
||||
sw->poll_data = 1;
|
||||
}
|
||||
|
||||
for (c = 0; c < 4; c++)
|
||||
{
|
||||
uint16_t data = 0x3fff;
|
||||
int b;
|
||||
|
||||
if (!JOYSTICK_PRESENT(c))
|
||||
break;
|
||||
|
||||
if (joystick_state[c].axis[1] < -16383)
|
||||
data &= ~1;
|
||||
if (joystick_state[c].axis[1] > 16383)
|
||||
data &= ~2;
|
||||
if (joystick_state[c].axis[0] > 16383)
|
||||
data &= ~4;
|
||||
if (joystick_state[c].axis[0] < -16383)
|
||||
data &= ~8;
|
||||
|
||||
for (b = 0; b < 10; b++)
|
||||
{
|
||||
if (joystick_state[c].button[b])
|
||||
data &= ~(1 << (b + 4));
|
||||
}
|
||||
|
||||
if (sw_parity(data))
|
||||
data |= 0x4000;
|
||||
|
||||
if (sw->poll_mode)
|
||||
{
|
||||
sw->poll_left += 5;
|
||||
sw->poll_data |= (data << (c*15 + 3));
|
||||
}
|
||||
else
|
||||
{
|
||||
sw->poll_left += 15;
|
||||
sw->poll_data |= (data << (c*15 + 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
timer_disable(&sw->trigger_timer);
|
||||
return 0; /*No analogue support on Sidewinder game pad*/
|
||||
}
|
||||
|
||||
static int sw_read_axis(void *p, int axis)
|
||||
static void
|
||||
sw_a0_over(void *p)
|
||||
{
|
||||
if (!JOYSTICK_PRESENT(0))
|
||||
return AXIS_NOT_PRESENT;
|
||||
sw_data *sw = (sw_data *) p;
|
||||
|
||||
return 0; /*No analogue support on Sidewinder game pad*/
|
||||
}
|
||||
|
||||
static void sw_a0_over(void *p)
|
||||
{
|
||||
sw_data *sw = (sw_data *)p;
|
||||
|
||||
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 = {
|
||||
.name = "Microsoft SideWinder Pad",
|
||||
.name = "Microsoft SideWinder Pad",
|
||||
.internal_name = "sidewinder_pad",
|
||||
.init = sw_init,
|
||||
.close = sw_close,
|
||||
.read = sw_read,
|
||||
.write = sw_write,
|
||||
.read_axis = sw_read_axis,
|
||||
.a0_over = sw_a0_over,
|
||||
.axis_count = 2,
|
||||
.button_count = 10,
|
||||
.pov_count = 0,
|
||||
.init = sw_init,
|
||||
.close = sw_close,
|
||||
.read = sw_read,
|
||||
.write = sw_write,
|
||||
.read_axis = sw_read_axis,
|
||||
.a0_over = sw_a0_over,
|
||||
.axis_count = 2,
|
||||
.button_count = 10,
|
||||
.pov_count = 0,
|
||||
.max_joysticks = 4,
|
||||
.axis_names = { "X axis", "Y axis" },
|
||||
.button_names = { "A", "B", "C", "X", "Y", "Z", "L", "R", "Start", "M" },
|
||||
.pov_names = { NULL }
|
||||
.axis_names = {"X axis", "Y axis" },
|
||||
.button_names = { "A", "B", "C", "X", "Y", "Z", "L", "R", "Start", "M" },
|
||||
.pov_names = { NULL}
|
||||
};
|
||||
|
@@ -45,88 +45,90 @@
|
||||
#include <86box/gameport.h>
|
||||
#include <86box/joystick_standard.h>
|
||||
|
||||
|
||||
static void *tm_fcs_init(void)
|
||||
static void *
|
||||
tm_fcs_init(void)
|
||||
{
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void tm_fcs_close(void *p)
|
||||
static void
|
||||
tm_fcs_close(void *p)
|
||||
{
|
||||
}
|
||||
|
||||
static uint8_t tm_fcs_read(void *p)
|
||||
static uint8_t
|
||||
tm_fcs_read(void *p)
|
||||
{
|
||||
uint8_t ret = 0xf0;
|
||||
uint8_t ret = 0xf0;
|
||||
|
||||
if (JOYSTICK_PRESENT(0))
|
||||
{
|
||||
if (joystick_state[0].button[0])
|
||||
ret &= ~0x10;
|
||||
if (joystick_state[0].button[1])
|
||||
ret &= ~0x20;
|
||||
if (joystick_state[0].button[2])
|
||||
ret &= ~0x40;
|
||||
if (joystick_state[0].button[3])
|
||||
ret &= ~0x80;
|
||||
}
|
||||
if (JOYSTICK_PRESENT(0)) {
|
||||
if (joystick_state[0].button[0])
|
||||
ret &= ~0x10;
|
||||
if (joystick_state[0].button[1])
|
||||
ret &= ~0x20;
|
||||
if (joystick_state[0].button[2])
|
||||
ret &= ~0x40;
|
||||
if (joystick_state[0].button[3])
|
||||
ret &= ~0x80;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void tm_fcs_write(void *p)
|
||||
static void
|
||||
tm_fcs_write(void *p)
|
||||
{
|
||||
}
|
||||
|
||||
static int tm_fcs_read_axis(void *p, int axis)
|
||||
static int
|
||||
tm_fcs_read_axis(void *p, int axis)
|
||||
{
|
||||
if (!JOYSTICK_PRESENT(0))
|
||||
return AXIS_NOT_PRESENT;
|
||||
if (!JOYSTICK_PRESENT(0))
|
||||
return AXIS_NOT_PRESENT;
|
||||
|
||||
switch (axis)
|
||||
{
|
||||
case 0:
|
||||
return joystick_state[0].axis[0];
|
||||
case 1:
|
||||
return joystick_state[0].axis[1];
|
||||
case 2:
|
||||
switch (axis) {
|
||||
case 0:
|
||||
return joystick_state[0].axis[0];
|
||||
case 1:
|
||||
return joystick_state[0].axis[1];
|
||||
case 2:
|
||||
return 0;
|
||||
case 3:
|
||||
if (joystick_state[0].pov[0] == -1)
|
||||
return 32767;
|
||||
if (joystick_state[0].pov[0] > 315 || joystick_state[0].pov[0] < 45)
|
||||
return -32768;
|
||||
if (joystick_state[0].pov[0] >= 45 && joystick_state[0].pov[0] < 135)
|
||||
return -16384;
|
||||
if (joystick_state[0].pov[0] >= 135 && joystick_state[0].pov[0] < 225)
|
||||
return 0;
|
||||
case 3:
|
||||
if (joystick_state[0].pov[0] == -1)
|
||||
return 32767;
|
||||
if (joystick_state[0].pov[0] > 315 || joystick_state[0].pov[0] < 45)
|
||||
return -32768;
|
||||
if (joystick_state[0].pov[0] >= 45 && joystick_state[0].pov[0] < 135)
|
||||
return -16384;
|
||||
if (joystick_state[0].pov[0] >= 135 && joystick_state[0].pov[0] < 225)
|
||||
return 0;
|
||||
if (joystick_state[0].pov[0] >= 225 && joystick_state[0].pov[0] < 315)
|
||||
return 16384;
|
||||
return 0;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
if (joystick_state[0].pov[0] >= 225 && joystick_state[0].pov[0] < 315)
|
||||
return 16384;
|
||||
return 0;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void tm_fcs_a0_over(void *p)
|
||||
static void
|
||||
tm_fcs_a0_over(void *p)
|
||||
{
|
||||
}
|
||||
|
||||
const joystick_if_t joystick_tm_fcs =
|
||||
{
|
||||
.name = "Thrustmaster Flight Control System",
|
||||
const joystick_if_t joystick_tm_fcs = {
|
||||
.name = "Thrustmaster Flight Control System",
|
||||
.internal_name = "thrustmaster_fcs",
|
||||
.init = tm_fcs_init,
|
||||
.close = tm_fcs_close,
|
||||
.read = tm_fcs_read,
|
||||
.write = tm_fcs_write,
|
||||
.read_axis = tm_fcs_read_axis,
|
||||
.a0_over = tm_fcs_a0_over,
|
||||
.axis_count = 2,
|
||||
.button_count = 4,
|
||||
.pov_count = 1,
|
||||
.init = tm_fcs_init,
|
||||
.close = tm_fcs_close,
|
||||
.read = tm_fcs_read,
|
||||
.write = tm_fcs_write,
|
||||
.read_axis = tm_fcs_read_axis,
|
||||
.a0_over = tm_fcs_a0_over,
|
||||
.axis_count = 2,
|
||||
.button_count = 4,
|
||||
.pov_count = 1,
|
||||
.max_joysticks = 1,
|
||||
.axis_names = { "X axis", "Y axis" },
|
||||
.button_names = { "Button 1", "Button 2", "Button 3", "Button 4" },
|
||||
.pov_names = { "POV" }
|
||||
.axis_names = {"X axis", "Y axis" },
|
||||
.button_names = { "Button 1", "Button 2", "Button 3", "Button 4" },
|
||||
.pov_names = { "POV"}
|
||||
};
|
||||
|
Reference in New Issue
Block a user