SDL Input :
- Added the ability to change the default keymap - A bit of cleanup GTK : The SDL Input is working great. Though the config dialog is not updated yet, so it is disabled by default.
This commit is contained in:
parent
6feda5d3a0
commit
ee1234f278
|
@ -25,6 +25,7 @@
|
||||||
#include "../dmg/gbGlobals.h"
|
#include "../dmg/gbGlobals.h"
|
||||||
#include "../Util.h"
|
#include "../Util.h"
|
||||||
#include "../Sound.h"
|
#include "../Sound.h"
|
||||||
|
#include "../sdl/inputSDL.h"
|
||||||
|
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
#include "intl.h"
|
#include "intl.h"
|
||||||
|
@ -79,8 +80,9 @@ bool systemReadJoypads()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 systemReadJoypad(int)
|
u32 systemReadJoypad(int joy)
|
||||||
{
|
{
|
||||||
|
//return inputReadJoypad(joy);
|
||||||
return GUI()->uiReadJoypad();
|
return GUI()->uiReadJoypad();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -907,6 +907,21 @@ void Window::vInitSDL()
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inputSetKeymap(PAD_DEFAULT, KEY_LEFT, GDK_Left);
|
||||||
|
inputSetKeymap(PAD_DEFAULT, KEY_RIGHT, GDK_Right);
|
||||||
|
inputSetKeymap(PAD_DEFAULT, KEY_UP, GDK_Up);
|
||||||
|
inputSetKeymap(PAD_DEFAULT, KEY_DOWN, GDK_Down);
|
||||||
|
inputSetKeymap(PAD_DEFAULT, KEY_BUTTON_A, GDK_z);
|
||||||
|
inputSetKeymap(PAD_DEFAULT, KEY_BUTTON_B, GDK_x);
|
||||||
|
inputSetKeymap(PAD_DEFAULT, KEY_BUTTON_START, GDK_Return);
|
||||||
|
inputSetKeymap(PAD_DEFAULT, KEY_BUTTON_SELECT, GDK_BackSpace);
|
||||||
|
inputSetKeymap(PAD_DEFAULT, KEY_BUTTON_L, GDK_a);
|
||||||
|
inputSetKeymap(PAD_DEFAULT, KEY_BUTTON_R, GDK_s);
|
||||||
|
inputSetKeymap(PAD_DEFAULT, KEY_BUTTON_SPEED, GDK_space);
|
||||||
|
inputSetKeymap(PAD_DEFAULT, KEY_BUTTON_CAPTURE, GDK_F12);
|
||||||
|
inputSetKeymap(PAD_DEFAULT, KEY_BUTTON_AUTO_A, GDK_q);
|
||||||
|
inputSetKeymap(PAD_DEFAULT, KEY_BUTTON_AUTO_B, GDK_w);
|
||||||
|
|
||||||
// TODO : remove
|
// TODO : remove
|
||||||
int sdlNumDevices = SDL_NumJoysticks();
|
int sdlNumDevices = SDL_NumJoysticks();
|
||||||
for (int i = 0; i < sdlNumDevices; i++)
|
for (int i = 0; i < sdlNumDevices; i++)
|
||||||
|
|
|
@ -1241,7 +1241,7 @@ bool Window::on_key_release_event(GdkEventKey * _pstEvent)
|
||||||
{
|
{
|
||||||
// Forward the keyboard event to the input module by faking a SDL event
|
// Forward the keyboard event to the input module by faking a SDL event
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
event.type = SDL_KEYDOWN;
|
event.type = SDL_KEYUP;
|
||||||
event.key.keysym.sym = (SDLKey)_pstEvent->keyval;
|
event.key.keysym.sym = (SDLKey)_pstEvent->keyval;
|
||||||
inputProcessSDLEvent(event);
|
inputProcessSDLEvent(event);
|
||||||
|
|
||||||
|
|
114
src/sdl/SDL.cpp
114
src/sdl/SDL.cpp
|
@ -546,117 +546,117 @@ void sdlReadPreferences(FILE *f)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!strcmp(key,"Joy0_Left")) {
|
if(!strcmp(key,"Joy0_Left")) {
|
||||||
inputSetKeymap(0, KEY_LEFT, sdlFromHex(value));
|
inputSetKeymap(PAD_1, KEY_LEFT, sdlFromHex(value));
|
||||||
} else if(!strcmp(key, "Joy0_Right")) {
|
} else if(!strcmp(key, "Joy0_Right")) {
|
||||||
inputSetKeymap(0, KEY_RIGHT, sdlFromHex(value));
|
inputSetKeymap(PAD_1, KEY_RIGHT, sdlFromHex(value));
|
||||||
} else if(!strcmp(key, "Joy0_Up")) {
|
} else if(!strcmp(key, "Joy0_Up")) {
|
||||||
inputSetKeymap(0, KEY_UP, sdlFromHex(value));
|
inputSetKeymap(PAD_1, KEY_UP, sdlFromHex(value));
|
||||||
} else if(!strcmp(key, "Joy0_Down")) {
|
} else if(!strcmp(key, "Joy0_Down")) {
|
||||||
inputSetKeymap(0, KEY_DOWN, sdlFromHex(value));
|
inputSetKeymap(PAD_1, KEY_DOWN, sdlFromHex(value));
|
||||||
} else if(!strcmp(key, "Joy0_A")) {
|
} else if(!strcmp(key, "Joy0_A")) {
|
||||||
inputSetKeymap(0, KEY_BUTTON_A, sdlFromHex(value));
|
inputSetKeymap(PAD_1, KEY_BUTTON_A, sdlFromHex(value));
|
||||||
} else if(!strcmp(key, "Joy0_B")) {
|
} else if(!strcmp(key, "Joy0_B")) {
|
||||||
inputSetKeymap(0, KEY_BUTTON_B, sdlFromHex(value));
|
inputSetKeymap(PAD_1, KEY_BUTTON_B, sdlFromHex(value));
|
||||||
} else if(!strcmp(key, "Joy0_L")) {
|
} else if(!strcmp(key, "Joy0_L")) {
|
||||||
inputSetKeymap(0, KEY_BUTTON_L, sdlFromHex(value));
|
inputSetKeymap(PAD_1, KEY_BUTTON_L, sdlFromHex(value));
|
||||||
} else if(!strcmp(key, "Joy0_R")) {
|
} else if(!strcmp(key, "Joy0_R")) {
|
||||||
inputSetKeymap(0, KEY_BUTTON_R, sdlFromHex(value));
|
inputSetKeymap(PAD_1, KEY_BUTTON_R, sdlFromHex(value));
|
||||||
} else if(!strcmp(key, "Joy0_Start")) {
|
} else if(!strcmp(key, "Joy0_Start")) {
|
||||||
inputSetKeymap(0, KEY_BUTTON_START, sdlFromHex(value));
|
inputSetKeymap(PAD_1, KEY_BUTTON_START, sdlFromHex(value));
|
||||||
} else if(!strcmp(key, "Joy0_Select")) {
|
} else if(!strcmp(key, "Joy0_Select")) {
|
||||||
inputSetKeymap(0, KEY_BUTTON_SELECT, sdlFromHex(value));
|
inputSetKeymap(PAD_1, KEY_BUTTON_SELECT, sdlFromHex(value));
|
||||||
} else if(!strcmp(key, "Joy0_Speed")) {
|
} else if(!strcmp(key, "Joy0_Speed")) {
|
||||||
inputSetKeymap(0, KEY_BUTTON_SPEED, sdlFromHex(value));
|
inputSetKeymap(PAD_1, KEY_BUTTON_SPEED, sdlFromHex(value));
|
||||||
} else if(!strcmp(key, "Joy0_Capture")) {
|
} else if(!strcmp(key, "Joy0_Capture")) {
|
||||||
inputSetKeymap(0, KEY_BUTTON_CAPTURE, sdlFromHex(value));
|
inputSetKeymap(PAD_1, KEY_BUTTON_CAPTURE, sdlFromHex(value));
|
||||||
} else if(!strcmp(key,"Joy1_Left")) {
|
} else if(!strcmp(key,"Joy1_Left")) {
|
||||||
inputSetKeymap(1, KEY_LEFT, sdlFromHex(value));
|
inputSetKeymap(PAD_2, KEY_LEFT, sdlFromHex(value));
|
||||||
} else if(!strcmp(key, "Joy1_Right")) {
|
} else if(!strcmp(key, "Joy1_Right")) {
|
||||||
inputSetKeymap(1, KEY_RIGHT, sdlFromHex(value));
|
inputSetKeymap(PAD_2, KEY_RIGHT, sdlFromHex(value));
|
||||||
} else if(!strcmp(key, "Joy1_Up")) {
|
} else if(!strcmp(key, "Joy1_Up")) {
|
||||||
inputSetKeymap(1, KEY_UP, sdlFromHex(value));
|
inputSetKeymap(PAD_2, KEY_UP, sdlFromHex(value));
|
||||||
} else if(!strcmp(key, "Joy1_Down")) {
|
} else if(!strcmp(key, "Joy1_Down")) {
|
||||||
inputSetKeymap(1, KEY_DOWN, sdlFromHex(value));
|
inputSetKeymap(PAD_2, KEY_DOWN, sdlFromHex(value));
|
||||||
} else if(!strcmp(key, "Joy1_A")) {
|
} else if(!strcmp(key, "Joy1_A")) {
|
||||||
inputSetKeymap(1, KEY_BUTTON_A, sdlFromHex(value));
|
inputSetKeymap(PAD_2, KEY_BUTTON_A, sdlFromHex(value));
|
||||||
} else if(!strcmp(key, "Joy1_B")) {
|
} else if(!strcmp(key, "Joy1_B")) {
|
||||||
inputSetKeymap(1, KEY_BUTTON_B, sdlFromHex(value));
|
inputSetKeymap(PAD_2, KEY_BUTTON_B, sdlFromHex(value));
|
||||||
} else if(!strcmp(key, "Joy1_L")) {
|
} else if(!strcmp(key, "Joy1_L")) {
|
||||||
inputSetKeymap(1, KEY_BUTTON_L, sdlFromHex(value));
|
inputSetKeymap(PAD_2, KEY_BUTTON_L, sdlFromHex(value));
|
||||||
} else if(!strcmp(key, "Joy1_R")) {
|
} else if(!strcmp(key, "Joy1_R")) {
|
||||||
inputSetKeymap(1, KEY_BUTTON_R, sdlFromHex(value));
|
inputSetKeymap(PAD_2, KEY_BUTTON_R, sdlFromHex(value));
|
||||||
} else if(!strcmp(key, "Joy1_Start")) {
|
} else if(!strcmp(key, "Joy1_Start")) {
|
||||||
inputSetKeymap(1, KEY_BUTTON_START, sdlFromHex(value));
|
inputSetKeymap(PAD_2, KEY_BUTTON_START, sdlFromHex(value));
|
||||||
} else if(!strcmp(key, "Joy1_Select")) {
|
} else if(!strcmp(key, "Joy1_Select")) {
|
||||||
inputSetKeymap(1, KEY_BUTTON_SELECT, sdlFromHex(value));
|
inputSetKeymap(PAD_2, KEY_BUTTON_SELECT, sdlFromHex(value));
|
||||||
} else if(!strcmp(key, "Joy1_Speed")) {
|
} else if(!strcmp(key, "Joy1_Speed")) {
|
||||||
inputSetKeymap(1, KEY_BUTTON_SPEED, sdlFromHex(value));
|
inputSetKeymap(PAD_2, KEY_BUTTON_SPEED, sdlFromHex(value));
|
||||||
} else if(!strcmp(key, "Joy1_Capture")) {
|
} else if(!strcmp(key, "Joy1_Capture")) {
|
||||||
inputSetKeymap(1, KEY_BUTTON_CAPTURE, sdlFromHex(value));
|
inputSetKeymap(PAD_2, KEY_BUTTON_CAPTURE, sdlFromHex(value));
|
||||||
} else if(!strcmp(key,"Joy2_Left")) {
|
} else if(!strcmp(key,"Joy2_Left")) {
|
||||||
inputSetKeymap(2, KEY_LEFT, sdlFromHex(value));
|
inputSetKeymap(PAD_3, KEY_LEFT, sdlFromHex(value));
|
||||||
} else if(!strcmp(key, "Joy2_Right")) {
|
} else if(!strcmp(key, "Joy2_Right")) {
|
||||||
inputSetKeymap(2, KEY_RIGHT, sdlFromHex(value));
|
inputSetKeymap(PAD_3, KEY_RIGHT, sdlFromHex(value));
|
||||||
} else if(!strcmp(key, "Joy2_Up")) {
|
} else if(!strcmp(key, "Joy2_Up")) {
|
||||||
inputSetKeymap(2, KEY_UP, sdlFromHex(value));
|
inputSetKeymap(PAD_3, KEY_UP, sdlFromHex(value));
|
||||||
} else if(!strcmp(key, "Joy2_Down")) {
|
} else if(!strcmp(key, "Joy2_Down")) {
|
||||||
inputSetKeymap(2, KEY_DOWN, sdlFromHex(value));
|
inputSetKeymap(PAD_3, KEY_DOWN, sdlFromHex(value));
|
||||||
} else if(!strcmp(key, "Joy2_A")) {
|
} else if(!strcmp(key, "Joy2_A")) {
|
||||||
inputSetKeymap(2, KEY_BUTTON_A, sdlFromHex(value));
|
inputSetKeymap(PAD_3, KEY_BUTTON_A, sdlFromHex(value));
|
||||||
} else if(!strcmp(key, "Joy2_B")) {
|
} else if(!strcmp(key, "Joy2_B")) {
|
||||||
inputSetKeymap(2, KEY_BUTTON_B, sdlFromHex(value));
|
inputSetKeymap(PAD_3, KEY_BUTTON_B, sdlFromHex(value));
|
||||||
} else if(!strcmp(key, "Joy2_L")) {
|
} else if(!strcmp(key, "Joy2_L")) {
|
||||||
inputSetKeymap(2, KEY_BUTTON_L, sdlFromHex(value));
|
inputSetKeymap(PAD_3, KEY_BUTTON_L, sdlFromHex(value));
|
||||||
} else if(!strcmp(key, "Joy2_R")) {
|
} else if(!strcmp(key, "Joy2_R")) {
|
||||||
inputSetKeymap(2, KEY_BUTTON_R, sdlFromHex(value));
|
inputSetKeymap(PAD_3, KEY_BUTTON_R, sdlFromHex(value));
|
||||||
} else if(!strcmp(key, "Joy2_Start")) {
|
} else if(!strcmp(key, "Joy2_Start")) {
|
||||||
inputSetKeymap(2, KEY_BUTTON_START, sdlFromHex(value));
|
inputSetKeymap(PAD_3, KEY_BUTTON_START, sdlFromHex(value));
|
||||||
} else if(!strcmp(key, "Joy2_Select")) {
|
} else if(!strcmp(key, "Joy2_Select")) {
|
||||||
inputSetKeymap(2, KEY_BUTTON_SELECT, sdlFromHex(value));
|
inputSetKeymap(PAD_3, KEY_BUTTON_SELECT, sdlFromHex(value));
|
||||||
} else if(!strcmp(key, "Joy2_Speed")) {
|
} else if(!strcmp(key, "Joy2_Speed")) {
|
||||||
inputSetKeymap(2, KEY_BUTTON_SPEED, sdlFromHex(value));
|
inputSetKeymap(PAD_3, KEY_BUTTON_SPEED, sdlFromHex(value));
|
||||||
} else if(!strcmp(key, "Joy2_Capture")) {
|
} else if(!strcmp(key, "Joy2_Capture")) {
|
||||||
inputSetKeymap(2, KEY_BUTTON_CAPTURE, sdlFromHex(value));
|
inputSetKeymap(PAD_3, KEY_BUTTON_CAPTURE, sdlFromHex(value));
|
||||||
} else if(!strcmp(key,"Joy3_Left")) {
|
} else if(!strcmp(key,"Joy3_Left")) {
|
||||||
inputSetKeymap(3, KEY_LEFT, sdlFromHex(value));
|
inputSetKeymap(PAD_4, KEY_LEFT, sdlFromHex(value));
|
||||||
} else if(!strcmp(key, "Joy3_Right")) {
|
} else if(!strcmp(key, "Joy3_Right")) {
|
||||||
inputSetKeymap(3, KEY_RIGHT, sdlFromHex(value));
|
inputSetKeymap(PAD_4, KEY_RIGHT, sdlFromHex(value));
|
||||||
} else if(!strcmp(key, "Joy3_Up")) {
|
} else if(!strcmp(key, "Joy3_Up")) {
|
||||||
inputSetKeymap(3, KEY_UP, sdlFromHex(value));
|
inputSetKeymap(PAD_4, KEY_UP, sdlFromHex(value));
|
||||||
} else if(!strcmp(key, "Joy3_Down")) {
|
} else if(!strcmp(key, "Joy3_Down")) {
|
||||||
inputSetKeymap(3, KEY_DOWN, sdlFromHex(value));
|
inputSetKeymap(PAD_4, KEY_DOWN, sdlFromHex(value));
|
||||||
} else if(!strcmp(key, "Joy3_A")) {
|
} else if(!strcmp(key, "Joy3_A")) {
|
||||||
inputSetKeymap(3, KEY_BUTTON_A, sdlFromHex(value));
|
inputSetKeymap(PAD_4, KEY_BUTTON_A, sdlFromHex(value));
|
||||||
} else if(!strcmp(key, "Joy3_B")) {
|
} else if(!strcmp(key, "Joy3_B")) {
|
||||||
inputSetKeymap(3, KEY_BUTTON_B, sdlFromHex(value));
|
inputSetKeymap(PAD_4, KEY_BUTTON_B, sdlFromHex(value));
|
||||||
} else if(!strcmp(key, "Joy3_L")) {
|
} else if(!strcmp(key, "Joy3_L")) {
|
||||||
inputSetKeymap(3, KEY_BUTTON_L, sdlFromHex(value));
|
inputSetKeymap(PAD_4, KEY_BUTTON_L, sdlFromHex(value));
|
||||||
} else if(!strcmp(key, "Joy3_R")) {
|
} else if(!strcmp(key, "Joy3_R")) {
|
||||||
inputSetKeymap(3, KEY_BUTTON_R, sdlFromHex(value));
|
inputSetKeymap(PAD_4, KEY_BUTTON_R, sdlFromHex(value));
|
||||||
} else if(!strcmp(key, "Joy3_Start")) {
|
} else if(!strcmp(key, "Joy3_Start")) {
|
||||||
inputSetKeymap(3, KEY_BUTTON_START, sdlFromHex(value));
|
inputSetKeymap(PAD_4, KEY_BUTTON_START, sdlFromHex(value));
|
||||||
} else if(!strcmp(key, "Joy3_Select")) {
|
} else if(!strcmp(key, "Joy3_Select")) {
|
||||||
inputSetKeymap(3, KEY_BUTTON_SELECT, sdlFromHex(value));
|
inputSetKeymap(PAD_4, KEY_BUTTON_SELECT, sdlFromHex(value));
|
||||||
} else if(!strcmp(key, "Joy3_Speed")) {
|
} else if(!strcmp(key, "Joy3_Speed")) {
|
||||||
inputSetKeymap(3, KEY_BUTTON_SPEED, sdlFromHex(value));
|
inputSetKeymap(PAD_4, KEY_BUTTON_SPEED, sdlFromHex(value));
|
||||||
} else if(!strcmp(key, "Joy3_Capture")) {
|
} else if(!strcmp(key, "Joy3_Capture")) {
|
||||||
inputSetKeymap(3, KEY_BUTTON_CAPTURE, sdlFromHex(value));
|
inputSetKeymap(PAD_4, KEY_BUTTON_CAPTURE, sdlFromHex(value));
|
||||||
} else if(!strcmp(key, "Joy0_AutoA")) {
|
} else if(!strcmp(key, "Joy0_AutoA")) {
|
||||||
inputSetKeymap(0, KEY_BUTTON_AUTO_A, sdlFromHex(value));
|
inputSetKeymap(PAD_1, KEY_BUTTON_AUTO_A, sdlFromHex(value));
|
||||||
} else if(!strcmp(key, "Joy0_AutoB")) {
|
} else if(!strcmp(key, "Joy0_AutoB")) {
|
||||||
inputSetKeymap(0, KEY_BUTTON_AUTO_B, sdlFromHex(value));
|
inputSetKeymap(PAD_1, KEY_BUTTON_AUTO_B, sdlFromHex(value));
|
||||||
} else if(!strcmp(key, "Joy1_AutoA")) {
|
} else if(!strcmp(key, "Joy1_AutoA")) {
|
||||||
inputSetKeymap(1, KEY_BUTTON_AUTO_A, sdlFromHex(value));
|
inputSetKeymap(PAD_2, KEY_BUTTON_AUTO_A, sdlFromHex(value));
|
||||||
} else if(!strcmp(key, "Joy1_AutoB")) {
|
} else if(!strcmp(key, "Joy1_AutoB")) {
|
||||||
inputSetKeymap(1, KEY_BUTTON_AUTO_B, sdlFromHex(value));
|
inputSetKeymap(PAD_2, KEY_BUTTON_AUTO_B, sdlFromHex(value));
|
||||||
} else if(!strcmp(key, "Joy2_AutoA")) {
|
} else if(!strcmp(key, "Joy2_AutoA")) {
|
||||||
inputSetKeymap(2, KEY_BUTTON_AUTO_A, sdlFromHex(value));
|
inputSetKeymap(PAD_3, KEY_BUTTON_AUTO_A, sdlFromHex(value));
|
||||||
} else if(!strcmp(key, "Joy2_AutoB")) {
|
} else if(!strcmp(key, "Joy2_AutoB")) {
|
||||||
inputSetKeymap(2, KEY_BUTTON_AUTO_B, sdlFromHex(value));
|
inputSetKeymap(PAD_3, KEY_BUTTON_AUTO_B, sdlFromHex(value));
|
||||||
} else if(!strcmp(key, "Joy3_AutoA")) {
|
} else if(!strcmp(key, "Joy3_AutoA")) {
|
||||||
inputSetKeymap(3, KEY_BUTTON_AUTO_A, sdlFromHex(value));
|
inputSetKeymap(PAD_4, KEY_BUTTON_AUTO_A, sdlFromHex(value));
|
||||||
} else if(!strcmp(key, "Joy3_AutoB")) {
|
} else if(!strcmp(key, "Joy3_AutoB")) {
|
||||||
inputSetKeymap(3, KEY_BUTTON_AUTO_B, sdlFromHex(value));
|
inputSetKeymap(PAD_4, KEY_BUTTON_AUTO_B, sdlFromHex(value));
|
||||||
} else if(!strcmp(key, "openGL")) {
|
} else if(!strcmp(key, "openGL")) {
|
||||||
openGL = sdlFromHex(value);
|
openGL = sdlFromHex(value);
|
||||||
} else if(!strcmp(key, "Motion_Left")) {
|
} else if(!strcmp(key, "Motion_Left")) {
|
||||||
|
@ -1620,7 +1620,7 @@ void lircCheckInput(void)
|
||||||
if (!sdlSoundToggledOff) {
|
if (!sdlSoundToggledOff) {
|
||||||
sdlSoundToggledOff = 0x3ff;
|
sdlSoundToggledOff = 0x3ff;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if( strcmp( CmdLIRC, "VOLUP" ) == 0 ) {
|
} else if( strcmp( CmdLIRC, "VOLUP" ) == 0 ) {
|
||||||
sdlChangeVolume(0.1);
|
sdlChangeVolume(0.1);
|
||||||
} else if( strcmp( CmdLIRC, "VOLDOWN" ) == 0 ) {
|
} else if( strcmp( CmdLIRC, "VOLDOWN" ) == 0 ) {
|
||||||
|
|
|
@ -54,7 +54,11 @@ static int sdlDefaultJoypad = 0;
|
||||||
static int autoFire = 0;
|
static int autoFire = 0;
|
||||||
static bool autoFireToggle = false;
|
static bool autoFireToggle = false;
|
||||||
|
|
||||||
static uint32_t joypad[4][SDLBUTTONS_NUM] = {
|
static uint32_t joypad[5][SDLBUTTONS_NUM] = {
|
||||||
|
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||||
{ SDLK_LEFT, SDLK_RIGHT,
|
{ SDLK_LEFT, SDLK_RIGHT,
|
||||||
SDLK_UP, SDLK_DOWN,
|
SDLK_UP, SDLK_DOWN,
|
||||||
SDLK_z, SDLK_x,
|
SDLK_z, SDLK_x,
|
||||||
|
@ -62,20 +66,7 @@ static uint32_t joypad[4][SDLBUTTONS_NUM] = {
|
||||||
SDLK_a, SDLK_s,
|
SDLK_a, SDLK_s,
|
||||||
SDLK_SPACE, SDLK_F12,
|
SDLK_SPACE, SDLK_F12,
|
||||||
SDLK_q, SDLK_w,
|
SDLK_q, SDLK_w,
|
||||||
},
|
}
|
||||||
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
|
||||||
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
|
||||||
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
|
|
||||||
};
|
|
||||||
|
|
||||||
static uint32_t defaultJoypad[SDLBUTTONS_NUM] = {
|
|
||||||
SDLK_LEFT, SDLK_RIGHT,
|
|
||||||
SDLK_UP, SDLK_DOWN,
|
|
||||||
SDLK_z, SDLK_x,
|
|
||||||
SDLK_RETURN,SDLK_BACKSPACE,
|
|
||||||
SDLK_a, SDLK_s,
|
|
||||||
SDLK_SPACE, SDLK_F12,
|
|
||||||
SDLK_q, SDLK_w
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static uint32_t motion[4] = {
|
static uint32_t motion[4] = {
|
||||||
|
@ -147,9 +138,9 @@ uint32_t inputGetEventCode(const SDL_Event &event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void inputSetKeymap(int joy, EKey key, uint32_t code)
|
void inputSetKeymap(EPad pad, EKey key, uint32_t code)
|
||||||
{
|
{
|
||||||
joypad[joy][key] = code;
|
joypad[pad][key] = code;
|
||||||
}
|
}
|
||||||
|
|
||||||
void inputSetMotionKeymap(EKey key, uint32_t code)
|
void inputSetMotionKeymap(EKey key, uint32_t code)
|
||||||
|
@ -365,17 +356,21 @@ static bool sdlCheckJoyKey(int key)
|
||||||
|
|
||||||
void inputInitJoysticks()
|
void inputInitJoysticks()
|
||||||
{
|
{
|
||||||
|
// The main joypad has to be entirely defined
|
||||||
|
for(int i = 0; i < SDLBUTTONS_NUM; i++) {
|
||||||
|
if (!joypad[PAD_MAIN][i])
|
||||||
|
joypad[PAD_MAIN][i] = joypad[PAD_DEFAULT][i];
|
||||||
|
}
|
||||||
|
|
||||||
sdlNumDevices = SDL_NumJoysticks();
|
sdlNumDevices = SDL_NumJoysticks();
|
||||||
|
|
||||||
if(sdlNumDevices)
|
if(sdlNumDevices)
|
||||||
sdlDevices = (SDL_Joystick **)calloc(1,sdlNumDevices *
|
sdlDevices = (SDL_Joystick **)calloc(1,sdlNumDevices *
|
||||||
sizeof(SDL_Joystick **));
|
sizeof(SDL_Joystick **));
|
||||||
int i;
|
|
||||||
|
|
||||||
bool usesJoy = false;
|
bool usesJoy = false;
|
||||||
|
|
||||||
for(int j = 0; j < 4; j++) {
|
for(int j = 0; j < 4; j++) {
|
||||||
for(i = 0; i < SDLBUTTONS_NUM; i++) {
|
for(int i = 0; i < SDLBUTTONS_NUM; i++) {
|
||||||
int dev = joypad[j][i] >> 16;
|
int dev = joypad[j][i] >> 16;
|
||||||
if(dev) {
|
if(dev) {
|
||||||
dev--;
|
dev--;
|
||||||
|
@ -393,14 +388,14 @@ void inputInitJoysticks()
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!ok)
|
if(!ok)
|
||||||
joypad[j][i] = defaultJoypad[i];
|
joypad[j][i] = joypad[PAD_DEFAULT][i];
|
||||||
else
|
else
|
||||||
usesJoy = true;
|
usesJoy = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i = 0; i < 4; i++) {
|
for(int i = 0; i < 4; i++) {
|
||||||
int dev = motion[i] >> 16;
|
int dev = motion[i] >> 16;
|
||||||
if(dev) {
|
if(dev) {
|
||||||
dev--;
|
dev--;
|
||||||
|
@ -430,6 +425,8 @@ void inputInitJoysticks()
|
||||||
|
|
||||||
void inputProcessSDLEvent(const SDL_Event &event)
|
void inputProcessSDLEvent(const SDL_Event &event)
|
||||||
{
|
{
|
||||||
|
// fprintf(stdout, "%x\n", inputGetEventCode(event));
|
||||||
|
|
||||||
switch(event.type)
|
switch(event.type)
|
||||||
{
|
{
|
||||||
case SDL_KEYDOWN:
|
case SDL_KEYDOWN:
|
||||||
|
|
|
@ -37,6 +37,15 @@ enum EKey {
|
||||||
KEY_BUTTON_AUTO_B
|
KEY_BUTTON_AUTO_B
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum EPad {
|
||||||
|
PAD_MAIN,
|
||||||
|
PAD_1 = PAD_MAIN,
|
||||||
|
PAD_2,
|
||||||
|
PAD_3,
|
||||||
|
PAD_4,
|
||||||
|
PAD_DEFAULT
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init the joysticks needed by the keymap. Verify that the keymap is compatible
|
* Init the joysticks needed by the keymap. Verify that the keymap is compatible
|
||||||
* with the joysticks. If it's not the case, revert to the default keymap.
|
* with the joysticks. If it's not the case, revert to the default keymap.
|
||||||
|
@ -49,7 +58,7 @@ void inputInitJoysticks();
|
||||||
* @param key Emulated joypad button
|
* @param key Emulated joypad button
|
||||||
* @param code Code defining an actual joypad / keyboard button
|
* @param code Code defining an actual joypad / keyboard button
|
||||||
*/
|
*/
|
||||||
void inputSetKeymap(int joy, EKey key, uint32_t code);
|
void inputSetKeymap(EPad pad, EKey key, uint32_t code);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Define which keys control motion detection emulation
|
* Define which keys control motion detection emulation
|
||||||
|
|
Loading…
Reference in New Issue