Implement set_get_joy_key(), set_get_joy_axis() as wrapper

around a get only version of the same. These will be used
in the gtk frontend where we want to have the luxury of
discarding changes.
This commit is contained in:
riccardom 2010-01-28 16:19:20 +00:00
parent 45e95b1a8a
commit 16e047c8e9
2 changed files with 21 additions and 5 deletions

View File

@ -196,8 +196,8 @@ static void clear_events( void)
return;
}
/* Get and set a new joystick key */
u16 get_set_joy_key(int index) {
/* Get pressed joystick key */
u16 get_joy_key(int index) {
BOOL done = FALSE;
SDL_Event event;
u16 key = joypad_cfg[index];
@ -220,11 +220,17 @@ u16 get_set_joy_key(int index) {
if( SDL_JoystickEventState(SDL_QUERY) == SDL_ENABLE )
SDL_JoystickEventState(SDL_IGNORE);
joypad_cfg[index] = key;
return key;
}
/* Get and set a new joystick key */
u16 get_set_joy_key(int index) {
joypad_cfg[index] = get_joy_key(index);
return joypad_cfg[index];
}
/* Reset corresponding key and its twin axis key */
static u16 get_joy_axis_twin(u16 key)
{
@ -239,8 +245,8 @@ static u16 get_joy_axis_twin(u16 key)
}
}
/* Get and set a new joystick axis */
void get_set_joy_axis(int index, int index_o) {
/* Get a new joystick axis */
u16 get_joy_axis(int index, int index_o) {
BOOL done = FALSE;
SDL_Event event;
u16 key = joypad_cfg[index];
@ -267,6 +273,14 @@ void get_set_joy_axis(int index, int index_o) {
}
if( SDL_JoystickEventState(SDL_QUERY) == SDL_ENABLE )
SDL_JoystickEventState(SDL_IGNORE);
return key;
}
/* Get and set a new joystick axis */
void get_set_joy_axis(int index, int index_o) {
u16 key = get_joy_axis(index, index_o);
/* Update configuration */
joypad_cfg[index] = key;
joypad_cfg[index_o] = joypad_cfg[index];

View File

@ -82,7 +82,9 @@ BOOL init_joy( void);
void uninit_joy( void);
void set_joy_keys(const u16 joyCfg[]);
void set_kb_keys(const u16 kbCfg[]);
u16 get_joy_key(int index);
u16 get_set_joy_key(int index);
u16 get_joy_axis(int index, int index_opp);
void get_set_joy_axis(int index, int index_opp);
void update_keypad(u16 keys);
u16 get_keypad( void);