Assorted Joystick fixes
Implemented use of DirectInput sliders. They were previously lumped in with axis and then not read or used at all. Lots of use of joystick_type == 7 or joystick_type != 7 to detect if the joystick_type was none. Changed this to a define. The text to enumerate the types of joysticks was contained in a numbered LPARAM sheet. Switched to using the name listed in the joystick struct. Joysticks with more than 32 buttons would overflow the plat_joystick_state button array. Added overflow checks. Added a 4 axis 4 button joystick type that Win98 can pick up as a generic 4 axis 4 button controller.
This commit is contained in:
@@ -90,6 +90,7 @@ static const joystick_if_t *joystick_list[] = {
|
||||
&joystick_standard_4button,
|
||||
&joystick_standard_6button,
|
||||
&joystick_standard_8button,
|
||||
&joystick_4axis_4button,
|
||||
&joystick_ch_flightstick_pro,
|
||||
&joystick_sw_pad,
|
||||
&joystick_tm_fcs,
|
||||
@@ -265,7 +266,7 @@ gameport_init(const device_t *info)
|
||||
{
|
||||
gameport_t *p = NULL;
|
||||
|
||||
if (joystick_type == 7) {
|
||||
if (joystick_type == JOYSTICK_TYPE_NONE) {
|
||||
p = NULL;
|
||||
return(p);
|
||||
}
|
||||
@@ -284,7 +285,7 @@ gameport_201_init(const device_t *info)
|
||||
{
|
||||
gameport_t *p;
|
||||
|
||||
if (joystick_type == 7) {
|
||||
if (joystick_type == JOYSTICK_TYPE_NONE) {
|
||||
p = NULL;
|
||||
return(p);
|
||||
}
|
||||
|
||||
@@ -45,8 +45,10 @@
|
||||
|
||||
#define POV_X 0x80000000
|
||||
#define POV_Y 0x40000000
|
||||
#define SLIDER 0x20000000
|
||||
|
||||
#define AXIS_NOT_PRESENT -99999
|
||||
#define JOYSTICK_TYPE_NONE 8
|
||||
|
||||
#define JOYSTICK_PRESENT(n) (joystick_state[n].plat_joystick_nr != 0)
|
||||
|
||||
@@ -57,6 +59,7 @@ typedef struct {
|
||||
int a[8];
|
||||
int b[32];
|
||||
int p[4];
|
||||
int s[2];
|
||||
|
||||
struct {
|
||||
char name[260];
|
||||
@@ -73,9 +76,16 @@ typedef struct {
|
||||
int id;
|
||||
} pov[4];
|
||||
|
||||
struct
|
||||
{
|
||||
char name[260];
|
||||
int id;
|
||||
} slider[2];
|
||||
|
||||
int nr_axes;
|
||||
int nr_buttons;
|
||||
int nr_povs;
|
||||
int nr_sliders;
|
||||
} plat_joystick_t;
|
||||
|
||||
typedef struct {
|
||||
|
||||
@@ -144,6 +144,27 @@ static int joystick_standard_read_axis_4button(void *p, int axis)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int joystick_standard_read_axis_4axis(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 joystick_state[0].axis[3];
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int joystick_standard_read_axis_6button(void *p, int axis)
|
||||
{
|
||||
if (!JOYSTICK_PRESENT(0))
|
||||
@@ -227,6 +248,22 @@ const joystick_if_t joystick_standard_4button =
|
||||
{"X axis", "Y axis"},
|
||||
{"Button 1", "Button 2", "Button 3", "Button 4"}
|
||||
};
|
||||
const joystick_if_t joystick_4axis_4button =
|
||||
{
|
||||
"4-axis 4-button joystick",
|
||||
joystick_standard_init,
|
||||
joystick_standard_close,
|
||||
joystick_standard_read_4button,
|
||||
joystick_standard_write,
|
||||
joystick_standard_read_axis_4axis,
|
||||
joystick_standard_a0_over,
|
||||
4,
|
||||
4,
|
||||
0,
|
||||
1,
|
||||
{"X axis", "Y axis", "Z axis", "zX axis"},
|
||||
{"Button 1", "Button 2", "Button 3", "Button 4"}
|
||||
};
|
||||
const joystick_if_t joystick_standard_6button =
|
||||
{
|
||||
"Standard 6-button joystick",
|
||||
|
||||
@@ -37,5 +37,6 @@
|
||||
|
||||
extern const joystick_if_t joystick_standard;
|
||||
extern const joystick_if_t joystick_standard_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;
|
||||
|
||||
Reference in New Issue
Block a user