projects
/
rocksndiamonds.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
improved support for game controllers and joysticks
[rocksndiamonds.git]
/
src
/
libgame
/
joystick.c
diff --git
a/src/libgame/joystick.c
b/src/libgame/joystick.c
index 92eec0e352e9f13e84115756556f818d1b0fe2eb..a6a065cddc318a4322279fb8dd20b85d3328b973 100644
(file)
--- a/
src/libgame/joystick.c
+++ b/
src/libgame/joystick.c
@@
-159,7
+159,7
@@
void CheckJoystickData()
}
}
}
}
-int Joystick
(int player
_nr)
+int Joystick
Ext(int player_nr, boolean use_as_joystick
_nr)
{
int joystick_fd = joystick.fd[player_nr];
int js_x, js_y;
{
int joystick_fd = joystick.fd[player_nr];
int js_x, js_y;
@@
-167,10
+167,13
@@
int Joystick(int player_nr)
int left, right, up, down;
int result = JOY_NO_ACTION;
int left, right, up, down;
int result = JOY_NO_ACTION;
+ if (use_as_joystick_nr)
+ joystick_fd = player_nr;
+
if (joystick.status != JOYSTICK_ACTIVATED)
return JOY_NO_ACTION;
if (joystick.status != JOYSTICK_ACTIVATED)
return JOY_NO_ACTION;
- if (joystick_fd < 0
|| !setup.input[player_nr].use_joystick
)
+ if (joystick_fd < 0)
return JOY_NO_ACTION;
if (!ReadJoystick(joystick_fd, &js_x, &js_y, &js_b1, &js_b2))
return JOY_NO_ACTION;
if (!ReadJoystick(joystick_fd, &js_x, &js_y, &js_b1, &js_b2))
@@
-208,10
+211,15
@@
int Joystick(int player_nr)
return result;
}
return result;
}
-int JoystickButton(int player_nr)
+int Joystick(int player_nr)
+{
+ return JoystickExt(player_nr, FALSE);
+}
+
+int JoystickButtonExt(int player_nr, boolean use_as_joystick_nr)
{
static int last_joy_button[MAX_PLAYERS] = { 0, 0, 0, 0 };
{
static int last_joy_button[MAX_PLAYERS] = { 0, 0, 0, 0 };
- int joy_button = (Joystick
(player
_nr) & JOY_BUTTON);
+ int joy_button = (Joystick
Ext(player_nr, use_as_joystick
_nr) & JOY_BUTTON);
int result;
if (joy_button)
int result;
if (joy_button)
@@
-233,13
+241,18
@@
int JoystickButton(int player_nr)
return result;
}
return result;
}
+int JoystickButton(int player_nr)
+{
+ return JoystickButtonExt(player_nr, FALSE);
+}
+
int AnyJoystick()
{
int i;
int result = 0;
for (i = 0; i < MAX_PLAYERS; i++)
int AnyJoystick()
{
int i;
int result = 0;
for (i = 0; i < MAX_PLAYERS; i++)
- result |= Joystick
(i
);
+ result |= Joystick
Ext(i, TRUE
);
return result;
}
return result;
}
@@
-251,7
+264,7
@@
int AnyJoystickButton()
for (i = 0; i < MAX_PLAYERS; i++)
{
for (i = 0; i < MAX_PLAYERS; i++)
{
- result = JoystickButton
(i
);
+ result = JoystickButton
Ext(i, TRUE
);
if (result != JOY_BUTTON_NOT_PRESSED)
break;
}
if (result != JOY_BUTTON_NOT_PRESSED)
break;
}