Merge pull request #1946 from jriwanek-forks/patch-joystick

More Joysticks
This commit is contained in:
Miran Grča
2021-12-20 01:13:26 +01:00
committed by GitHub
5 changed files with 89 additions and 23 deletions

View File

@@ -80,16 +80,18 @@ static const struct {
const char *internal_name;
const joystick_if_t *joystick;
} joysticks[] = {
{ "none", &joystick_none },
{ "standard_2button", &joystick_standard },
{ "standard_4button", &joystick_standard_4button },
{ "standard_6button", &joystick_standard_6button },
{ "standard_8button", &joystick_standard_8button },
{ "4axis_4button", &joystick_4axis_4button },
{ "none", &joystick_none },
{ "2axis_2button", &joystick_2axis_2button },
{ "2axis_4button", &joystick_2axis_4button },
{ "2axis_6button", &joystick_2axis_6button },
{ "2axis_8button", &joystick_2axis_8button },
{ "3axis_2button", &joystick_3axis_2button },
{ "3axis_4button", &joystick_3axis_4button },
{ "4axis_4button", &joystick_4axis_4button },
{ "ch_flighstick_pro", &joystick_ch_flightstick_pro },
{ "sidewinder_pad", &joystick_sw_pad },
{ "thrustmaster_fcs", &joystick_tm_fcs },
{ "", NULL }
{ "", NULL }
};
static joystick_instance_t *joystick_instance = NULL;
@@ -452,6 +454,15 @@ const device_t gameport_201_device = {
NULL
};
const device_t gameport_208_device = {
"Game port (Port 208h-20fh)",
0, 0x080208,
gameport_init,
gameport_close,
NULL, { NULL }, NULL,
NULL
};
const device_t gameport_pnp_device = {
"Game port (Plug and Play only)",
0, 0x080000,

View File

@@ -145,6 +145,26 @@ static int joystick_standard_read_axis_4button(void *p, int axis)
}
}
static int joystick_standard_read_axis_3axis(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].axis[2];
case 3:
return 0;
default:
return 0;
}
}
static int joystick_standard_read_axis_4axis(void *p, int axis)
{
if (!JOYSTICK_PRESENT(0))
@@ -216,9 +236,9 @@ static void joystick_standard_a0_over(void *p)
{
}
const joystick_if_t joystick_standard =
const joystick_if_t joystick_2axis_2button =
{
"Standard 2-button joystick(s)",
"2-axis, 2-button joystick(s)",
joystick_standard_init,
joystick_standard_close,
joystick_standard_read,
@@ -232,9 +252,9 @@ const joystick_if_t joystick_standard =
{"X axis", "Y axis"},
{"Button 1", "Button 2"}
};
const joystick_if_t joystick_standard_4button =
const joystick_if_t joystick_2axis_4button =
{
"Standard 4-button joystick",
"2-axis, 4-button joystick",
joystick_standard_init,
joystick_standard_close,
joystick_standard_read_4button,
@@ -248,9 +268,41 @@ const joystick_if_t joystick_standard_4button =
{"X axis", "Y axis"},
{"Button 1", "Button 2", "Button 3", "Button 4"}
};
const joystick_if_t joystick_3axis_2button =
{
"3-axis, 2-button joystick",
joystick_standard_init,
joystick_standard_close,
joystick_standard_read,
joystick_standard_write,
joystick_standard_read_axis_3axis,
joystick_standard_a0_over,
3,
2,
0,
1,
{"X axis", "Y axis", "Z axis"},
{"Button 1", "Button 2"}
};
const joystick_if_t joystick_3axis_4button =
{
"3-axis, 4-button joystick",
joystick_standard_init,
joystick_standard_close,
joystick_standard_read_4button,
joystick_standard_write,
joystick_standard_read_axis_3axis,
joystick_standard_a0_over,
3,
4,
0,
1,
{"X axis", "Y axis", "Z axis"},
{"Button 1", "Button 2", "Button 3", "Button 4"}
};
const joystick_if_t joystick_4axis_4button =
{
"4-axis 4-button joystick",
"4-axis, 4-button joystick",
joystick_standard_init,
joystick_standard_close,
joystick_standard_read_4button,
@@ -264,9 +316,9 @@ const joystick_if_t joystick_4axis_4button =
{"X axis", "Y axis", "Z axis", "zX axis"},
{"Button 1", "Button 2", "Button 3", "Button 4"}
};
const joystick_if_t joystick_standard_6button =
const joystick_if_t joystick_2axis_6button =
{
"Standard 6-button joystick",
"2-axis, 6-button joystick",
joystick_standard_init,
joystick_standard_close,
joystick_standard_read_4button,
@@ -280,9 +332,9 @@ const joystick_if_t joystick_standard_6button =
{"X axis", "Y axis"},
{"Button 1", "Button 2", "Button 3", "Button 4", "Button 5", "Button 6"}
};
const joystick_if_t joystick_standard_8button =
const joystick_if_t joystick_2axis_8button =
{
"Standard 8-button joystick",
"2-axis, 8-button joystick",
joystick_standard_init,
joystick_standard_close,
joystick_standard_read_4button,

View File

@@ -15,7 +15,7 @@
* connected
* - Packet preceeded by high data (currently 50us), and
* followed by low data (currently 160us) - timings are
* probably wrong, but good enoughfor everything I've tried
* probably wrong, but good enough for everything I've tried
* - Analog inputs are only used to time ID packet request.
* If A0 timing out is followed after ~64us by another 0x201
* write then an ID packet is triggered
@@ -259,7 +259,7 @@ 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 =
@@ -273,7 +273,7 @@ const joystick_if_t joystick_sw_pad =
sw_a0_over,
2,
10,
0,
0,
4,
{"X axis", "Y axis"},
{"A", "B", "C", "X", "Y", "Z", "L", "R", "Start", "M"}

View File

@@ -108,6 +108,7 @@ extern "C" {
#ifdef EMU_DEVICE_H
extern const device_t gameport_device;
extern const device_t gameport_201_device;
extern const device_t gameport_208_device;
extern const device_t gameport_pnp_device;
extern const device_t gameport_pnp_6io_device;
extern const device_t gameport_sio_device;

View File

@@ -35,8 +35,10 @@
* USA.
*/
extern const joystick_if_t joystick_standard;
extern const joystick_if_t joystick_standard_4button;
extern const joystick_if_t joystick_2axis_2button;
extern const joystick_if_t joystick_2axis_4button;
extern const joystick_if_t joystick_3axis_2button;
extern const joystick_if_t joystick_3axis_4button;
extern const joystick_if_t joystick_4axis_4button;
extern const joystick_if_t joystick_standard_6button;
extern const joystick_if_t joystick_standard_8button;
extern const joystick_if_t joystick_2axis_6button;
extern const joystick_if_t joystick_2axis_8button;