mirror of
https://github.com/OpenDriver2/REDRIVER2.git
synced 2024-11-22 18:32:42 +01:00
- [Psy-X] support keyboard remapping
This commit is contained in:
parent
eed356479c
commit
6a6a0fe595
@ -55,6 +55,7 @@ int g_pgxpTextureCorrection = 1;
|
||||
int g_pgxpZBuffer = 1;
|
||||
int g_bilinearFiltering = 0;
|
||||
TextureID g_lastBoundTexture;
|
||||
KeyboardMapping g_keyboard_mapping;
|
||||
|
||||
// Remap a value in the range [A,B] to [C,D].
|
||||
#define RemapVal( val, A, B, C, D) \
|
||||
@ -387,6 +388,30 @@ static int Emulator_InitialiseCore()
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void Emulator_InitialiseInput()
|
||||
{
|
||||
g_keyboard_mapping.kc_square = SDL_SCANCODE_X;
|
||||
g_keyboard_mapping.kc_circle = SDL_SCANCODE_V;
|
||||
g_keyboard_mapping.kc_triangle = SDL_SCANCODE_Z;
|
||||
g_keyboard_mapping.kc_cross = SDL_SCANCODE_C;
|
||||
|
||||
g_keyboard_mapping.kc_l1 = SDL_SCANCODE_LSHIFT;
|
||||
g_keyboard_mapping.kc_l2 = SDL_SCANCODE_LCTRL;
|
||||
g_keyboard_mapping.kc_l3 = SDL_SCANCODE_LEFTBRACKET;
|
||||
|
||||
g_keyboard_mapping.kc_r1 = SDL_SCANCODE_RSHIFT;
|
||||
g_keyboard_mapping.kc_r2 = SDL_SCANCODE_RCTRL;
|
||||
g_keyboard_mapping.kc_r3 = SDL_SCANCODE_RIGHTBRACKET;
|
||||
|
||||
g_keyboard_mapping.kc_dpad_up = SDL_SCANCODE_UP;
|
||||
g_keyboard_mapping.kc_dpad_down = SDL_SCANCODE_DOWN;
|
||||
g_keyboard_mapping.kc_dpad_left = SDL_SCANCODE_LEFT;
|
||||
g_keyboard_mapping.kc_dpad_right = SDL_SCANCODE_RIGHT;
|
||||
|
||||
g_keyboard_mapping.kc_select = SDL_SCANCODE_SPACE;
|
||||
g_keyboard_mapping.kc_start = SDL_SCANCODE_RETURN;
|
||||
}
|
||||
|
||||
void Emulator_Initialise(char* windowName, int width, int height, int fullscreen)
|
||||
{
|
||||
eprintf("Initialising Psy-X %d.%d\n", EMULATOR_MAJOR_VERSION, EMULATOR_MINOR_VERSION);
|
||||
@ -418,6 +443,7 @@ void Emulator_Initialise(char* windowName, int width, int height, int fullscreen
|
||||
Emulator_ShutDown();
|
||||
}
|
||||
|
||||
Emulator_InitialiseInput();
|
||||
}
|
||||
|
||||
void Emulator_GetScreenSize(int& screenWidth, int& screenHeight)
|
||||
|
@ -167,6 +167,32 @@ enum TexFormat
|
||||
TF_16_BIT
|
||||
};
|
||||
|
||||
struct KeyboardMapping
|
||||
{
|
||||
int id;
|
||||
|
||||
int kc_square;
|
||||
int kc_circle;
|
||||
int kc_triangle;
|
||||
int kc_cross;
|
||||
|
||||
int kc_l1;
|
||||
int kc_l2;
|
||||
int kc_l3;
|
||||
|
||||
int kc_r1;
|
||||
int kc_r2;
|
||||
int kc_r3;
|
||||
|
||||
int kc_start;
|
||||
int kc_select;
|
||||
|
||||
int kc_dpad_left;
|
||||
int kc_dpad_right;
|
||||
int kc_dpad_up;
|
||||
int kc_dpad_down;
|
||||
};
|
||||
|
||||
#define MAX_NUM_POLY_BUFFER_VERTICES (32768)
|
||||
#define MAX_NUM_INDEX_BUFFERS (4096)
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "LIBPAD.H"
|
||||
#include "LIBETC.H"
|
||||
|
||||
#include "EMULATOR.H"
|
||||
|
||||
@ -169,84 +170,52 @@ void UpdateGameControllerInput(SDL_GameController* cont, PADRAW* pad)
|
||||
unsigned short ret = 0xFFFF;
|
||||
|
||||
if (SDL_GameControllerGetButton(cont, SDL_CONTROLLER_BUTTON_X))//Square
|
||||
{
|
||||
ret &= ~0x8000;
|
||||
}
|
||||
|
||||
if (SDL_GameControllerGetButton(cont, SDL_CONTROLLER_BUTTON_B))//Circle
|
||||
{
|
||||
ret &= ~0x2000;
|
||||
}
|
||||
|
||||
if (SDL_GameControllerGetButton(cont, SDL_CONTROLLER_BUTTON_Y))//Triangle
|
||||
{
|
||||
ret &= ~0x1000;
|
||||
}
|
||||
|
||||
if (SDL_GameControllerGetButton(cont, SDL_CONTROLLER_BUTTON_A))//Cross
|
||||
{
|
||||
ret &= ~0x4000;
|
||||
}
|
||||
|
||||
if (SDL_GameControllerGetButton(cont, SDL_CONTROLLER_BUTTON_LEFTSHOULDER))//L1
|
||||
{
|
||||
ret &= ~0x400;
|
||||
}
|
||||
|
||||
if (SDL_GameControllerGetButton(cont, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER))//R1
|
||||
{
|
||||
ret &= ~0x800;
|
||||
}
|
||||
|
||||
if (SDL_GameControllerGetButton(cont, SDL_CONTROLLER_BUTTON_DPAD_UP))//UP
|
||||
{
|
||||
ret &= ~0x10;
|
||||
}
|
||||
|
||||
if (SDL_GameControllerGetButton(cont, SDL_CONTROLLER_BUTTON_DPAD_DOWN))//DOWN
|
||||
{
|
||||
ret &= ~0x40;
|
||||
}
|
||||
|
||||
if (SDL_GameControllerGetButton(cont, SDL_CONTROLLER_BUTTON_DPAD_LEFT))//LEFT
|
||||
{
|
||||
ret &= ~0x80;
|
||||
}
|
||||
|
||||
if (SDL_GameControllerGetButton(cont, SDL_CONTROLLER_BUTTON_DPAD_RIGHT))//RIGHT
|
||||
{
|
||||
ret &= ~0x20;
|
||||
}
|
||||
|
||||
if (SDL_GameControllerGetAxis(cont, SDL_CONTROLLER_AXIS_TRIGGERLEFT))//L2
|
||||
{
|
||||
ret &= ~0x100;
|
||||
}
|
||||
|
||||
if (SDL_GameControllerGetAxis(cont, SDL_CONTROLLER_AXIS_TRIGGERRIGHT))//R2
|
||||
{
|
||||
ret &= ~0x200;
|
||||
}
|
||||
|
||||
if (SDL_GameControllerGetButton(cont, SDL_CONTROLLER_BUTTON_DPAD_UP))//UP
|
||||
ret &= ~0x10;
|
||||
|
||||
if (SDL_GameControllerGetButton(cont, SDL_CONTROLLER_BUTTON_DPAD_DOWN))//DOWN
|
||||
ret &= ~0x40;
|
||||
|
||||
if (SDL_GameControllerGetButton(cont, SDL_CONTROLLER_BUTTON_DPAD_LEFT))//LEFT
|
||||
ret &= ~0x80;
|
||||
|
||||
if (SDL_GameControllerGetButton(cont, SDL_CONTROLLER_BUTTON_DPAD_RIGHT))//RIGHT
|
||||
ret &= ~0x20;
|
||||
|
||||
if (SDL_GameControllerGetButton(cont, SDL_CONTROLLER_BUTTON_LEFTSTICK))//L3
|
||||
{
|
||||
ret &= ~0x2;
|
||||
}
|
||||
|
||||
if (SDL_GameControllerGetButton(cont, SDL_CONTROLLER_BUTTON_RIGHTSTICK))//R3
|
||||
{
|
||||
ret &= ~0x4;
|
||||
}
|
||||
|
||||
if (SDL_GameControllerGetButton(cont, SDL_CONTROLLER_BUTTON_BACK))//SELECT
|
||||
{
|
||||
ret &= ~0x1;
|
||||
}
|
||||
|
||||
if (SDL_GameControllerGetButton(cont, SDL_CONTROLLER_BUTTON_START))//START
|
||||
{
|
||||
ret &= ~0x8;
|
||||
}
|
||||
|
||||
short leftX = SDL_GameControllerGetAxis(cont, SDL_CONTROLLER_AXIS_LEFTX);
|
||||
short leftY = SDL_GameControllerGetAxis(cont, SDL_CONTROLLER_AXIS_LEFTY);
|
||||
@ -265,85 +234,62 @@ void UpdateGameControllerInput(SDL_GameController* cont, PADRAW* pad)
|
||||
|
||||
unsigned short UpdateKeyboardInput()
|
||||
{
|
||||
extern KeyboardMapping g_keyboard_mapping;
|
||||
unsigned short ret = 0xFFFF;
|
||||
|
||||
//Not initialised yet
|
||||
if (keyboardState == NULL)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
SDL_PumpEvents();
|
||||
|
||||
if (keyboardState[SDL_SCANCODE_X])//Square
|
||||
{
|
||||
if (keyboardState[g_keyboard_mapping.kc_square])//Square
|
||||
ret &= ~0x8000;
|
||||
}
|
||||
|
||||
if (keyboardState[SDL_SCANCODE_V])//Circle
|
||||
{
|
||||
if (keyboardState[g_keyboard_mapping.kc_circle])//Circle
|
||||
ret &= ~0x2000;
|
||||
}
|
||||
|
||||
if (keyboardState[SDL_SCANCODE_Z])//Triangle
|
||||
{
|
||||
if (keyboardState[g_keyboard_mapping.kc_triangle])//Triangle
|
||||
ret &= ~0x1000;
|
||||
}
|
||||
|
||||
if (keyboardState[SDL_SCANCODE_C])//Cross
|
||||
{
|
||||
if (keyboardState[g_keyboard_mapping.kc_cross])//Cross
|
||||
ret &= ~0x4000;
|
||||
}
|
||||
|
||||
if (keyboardState[SDL_SCANCODE_LSHIFT])//L1
|
||||
{
|
||||
if (keyboardState[g_keyboard_mapping.kc_l1])//L1
|
||||
ret &= ~0x400;
|
||||
}
|
||||
|
||||
if (keyboardState[SDL_SCANCODE_RSHIFT])//R1
|
||||
{
|
||||
ret &= ~0x800;
|
||||
}
|
||||
|
||||
if (keyboardState[SDL_SCANCODE_UP])//UP
|
||||
{
|
||||
ret &= ~0x10;
|
||||
}
|
||||
|
||||
if (keyboardState[SDL_SCANCODE_DOWN])//DOWN
|
||||
{
|
||||
ret &= ~0x40;
|
||||
}
|
||||
|
||||
if (keyboardState[SDL_SCANCODE_LEFT])//LEFT
|
||||
{
|
||||
ret &= ~0x80;
|
||||
}
|
||||
|
||||
if (keyboardState[SDL_SCANCODE_RIGHT])//RIGHT
|
||||
{
|
||||
ret &= ~0x20;
|
||||
}
|
||||
|
||||
if (keyboardState[SDL_SCANCODE_LCTRL])//L2
|
||||
{
|
||||
if (keyboardState[g_keyboard_mapping.kc_l2])//L2
|
||||
ret &= ~0x100;
|
||||
}
|
||||
|
||||
if (keyboardState[SDL_SCANCODE_RCTRL])//R2
|
||||
{
|
||||
if (keyboardState[g_keyboard_mapping.kc_l3])//L3
|
||||
ret &= ~0x2;
|
||||
|
||||
if (keyboardState[g_keyboard_mapping.kc_r1])//R1
|
||||
ret &= ~0x800;
|
||||
|
||||
if (keyboardState[g_keyboard_mapping.kc_r2])//R2
|
||||
ret &= ~0x200;
|
||||
}
|
||||
|
||||
if (keyboardState[SDL_SCANCODE_SPACE])//SELECT
|
||||
{
|
||||
if (keyboardState[g_keyboard_mapping.kc_r3])//R3
|
||||
ret &= ~0x4;
|
||||
|
||||
if (keyboardState[g_keyboard_mapping.kc_dpad_up])//UP
|
||||
ret &= ~0x10;
|
||||
|
||||
if (keyboardState[g_keyboard_mapping.kc_dpad_down])//DOWN
|
||||
ret &= ~0x40;
|
||||
|
||||
if (keyboardState[g_keyboard_mapping.kc_dpad_left])//LEFT
|
||||
ret &= ~0x80;
|
||||
|
||||
if (keyboardState[g_keyboard_mapping.kc_dpad_right])//RIGHT
|
||||
ret &= ~0x20;
|
||||
|
||||
if (keyboardState[g_keyboard_mapping.kc_select])//SELECT
|
||||
ret &= ~0x1;
|
||||
}
|
||||
|
||||
if (keyboardState[SDL_SCANCODE_RETURN])//START
|
||||
{
|
||||
if (keyboardState[g_keyboard_mapping.kc_start])//START
|
||||
ret &= ~0x8;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user