Fix up inputs MR!
This commit is contained in:
parent
b733693808
commit
82341fcd29
@ -416,40 +416,40 @@ int readConfig(FILE *configFile, EmulatorConfig *config)
|
||||
else if (strcmp(command, "DEBUG_MSGS") == 0)
|
||||
config->showDebugMessages = atoi(getNextToken(NULL, " ", &saveptr));
|
||||
|
||||
else if (strcmp(command,"TEST_KEY") == 0)
|
||||
else if (strcmp(command, "TEST_KEY") == 0)
|
||||
config->keymap.test = atoi(getNextToken(NULL, " ", &saveptr));
|
||||
//TODO: add config when supporting player2
|
||||
else if (strcmp(command,"PLAYER_1_START_KEY") == 0)
|
||||
// TODO: add config when supporting player2
|
||||
else if (strcmp(command, "PLAYER_1_START_KEY") == 0)
|
||||
config->keymap.player1.start = atoi(getNextToken(NULL, " ", &saveptr));
|
||||
|
||||
else if (strcmp(command,"PLAYER_1_SERVICE_KEY") == 0)
|
||||
else if (strcmp(command, "PLAYER_1_SERVICE_KEY") == 0)
|
||||
config->keymap.player1.service = atoi(getNextToken(NULL, " ", &saveptr));
|
||||
|
||||
else if (strcmp(command,"PLAYER_1_COIN_KEY") == 0)
|
||||
else if (strcmp(command, "PLAYER_1_COIN_KEY") == 0)
|
||||
config->keymap.player1.coin = atoi(getNextToken(NULL, " ", &saveptr));
|
||||
|
||||
else if (strcmp(command,"PLAYER_1_UP_KEY") == 0)
|
||||
else if (strcmp(command, "PLAYER_1_UP_KEY") == 0)
|
||||
config->keymap.player1.up = atoi(getNextToken(NULL, " ", &saveptr));
|
||||
|
||||
else if (strcmp(command,"PLAYER_1_DOWN_KEY") == 0)
|
||||
else if (strcmp(command, "PLAYER_1_DOWN_KEY") == 0)
|
||||
config->keymap.player1.down = atoi(getNextToken(NULL, " ", &saveptr));
|
||||
|
||||
else if (strcmp(command,"PLAYER_1_LEFT_KEY") == 0)
|
||||
else if (strcmp(command, "PLAYER_1_LEFT_KEY") == 0)
|
||||
config->keymap.player1.left = atoi(getNextToken(NULL, " ", &saveptr));
|
||||
|
||||
else if (strcmp(command,"PLAYER_1_RIGHT_KEY") == 0)
|
||||
else if (strcmp(command, "PLAYER_1_RIGHT_KEY") == 0)
|
||||
config->keymap.player1.right = atoi(getNextToken(NULL, " ", &saveptr));
|
||||
|
||||
else if (strcmp(command,"PLAYER_1_BUTTON_1_KEY") == 0)
|
||||
else if (strcmp(command, "PLAYER_1_BUTTON_1_KEY") == 0)
|
||||
config->keymap.player1.button1 = atoi(getNextToken(NULL, " ", &saveptr));
|
||||
|
||||
else if (strcmp(command,"PLAYER_1_BUTTON_2_KEY") == 0)
|
||||
else if (strcmp(command, "PLAYER_1_BUTTON_2_KEY") == 0)
|
||||
config->keymap.player1.button2 = atoi(getNextToken(NULL, " ", &saveptr));
|
||||
|
||||
else if (strcmp(command,"PLAYER_1_BUTTON_3_KEY") == 0)
|
||||
else if (strcmp(command, "PLAYER_1_BUTTON_3_KEY") == 0)
|
||||
config->keymap.player1.button3 = atoi(getNextToken(NULL, " ", &saveptr));
|
||||
|
||||
else if (strcmp(command,"PLAYER_1_BUTTON_4_KEY") == 0)
|
||||
else if (strcmp(command, "PLAYER_1_BUTTON_4_KEY") == 0)
|
||||
config->keymap.player1.button4 = atoi(getNextToken(NULL, " ", &saveptr));
|
||||
|
||||
else
|
||||
@ -459,34 +459,33 @@ int readConfig(FILE *configFile, EmulatorConfig *config)
|
||||
return 0;
|
||||
}
|
||||
|
||||
KeyMapping getDefualtKeymap()
|
||||
KeyMapping getDefaultKeymap()
|
||||
{
|
||||
KeyMapping a;
|
||||
a.test = 28;
|
||||
a.player1.start = 10;
|
||||
a.player1.service = 39;
|
||||
a.player1.coin = 14;
|
||||
a.player1.up = 111;
|
||||
a.player1.down = 116;
|
||||
a.player1.left = 113;
|
||||
a.player1.right = 114;
|
||||
a.player1.button1 = 24;
|
||||
a.player1.button2 = 25;
|
||||
a.player1.button3 = 26;
|
||||
a.player1.button4 = 27;
|
||||
//TODO: Add keys when supporting player2
|
||||
a.player2.start = -1;
|
||||
a.player2.service = -1;
|
||||
a.player2.coin = -1;
|
||||
a.player2.up = -1;
|
||||
a.player2.down = -1;
|
||||
a.player2.left = -1;
|
||||
a.player2.right = -1;
|
||||
a.player2.button1 = -1;
|
||||
a.player2.button2 = -1;
|
||||
a.player2.button3 = -1;
|
||||
a.player2.button4 = -1;
|
||||
return a;
|
||||
KeyMapping defaultKeyMapping;
|
||||
defaultKeyMapping.test = 28;
|
||||
defaultKeyMapping.player1.start = 10;
|
||||
defaultKeyMapping.player1.service = 39;
|
||||
defaultKeyMapping.player1.coin = 14;
|
||||
defaultKeyMapping.player1.up = 111;
|
||||
defaultKeyMapping.player1.down = 116;
|
||||
defaultKeyMapping.player1.left = 113;
|
||||
defaultKeyMapping.player1.right = 114;
|
||||
defaultKeyMapping.player1.button1 = 24;
|
||||
defaultKeyMapping.player1.button2 = 25;
|
||||
defaultKeyMapping.player1.button3 = 26;
|
||||
defaultKeyMapping.player1.button4 = 27;
|
||||
defaultKeyMapping.player2.start = -1;
|
||||
defaultKeyMapping.player2.service = -1;
|
||||
defaultKeyMapping.player2.coin = -1;
|
||||
defaultKeyMapping.player2.up = -1;
|
||||
defaultKeyMapping.player2.down = -1;
|
||||
defaultKeyMapping.player2.left = -1;
|
||||
defaultKeyMapping.player2.right = -1;
|
||||
defaultKeyMapping.player2.button1 = -1;
|
||||
defaultKeyMapping.player2.button2 = -1;
|
||||
defaultKeyMapping.player2.button3 = -1;
|
||||
defaultKeyMapping.player2.button4 = -1;
|
||||
return defaultKeyMapping;
|
||||
}
|
||||
|
||||
int initConfig()
|
||||
@ -512,7 +511,7 @@ int initConfig()
|
||||
config.gameID = "XXXX";
|
||||
config.gameDVP = "DVP-XXXX";
|
||||
config.gameType = SHOOTING;
|
||||
config.keymap = getDefualtKeymap();
|
||||
config.keymap = getDefaultKeymap();
|
||||
if (detectGame(config.crc32) != 0)
|
||||
{
|
||||
printf("Warning: Unsure what game with CRC 0x%X is. Please submit this new game to the GitHub repository: https://github.com/bobbydilley/lindbergh-loader/issues/new?title=Please+add+new+game+0x%X&body=I+tried+to+launch+the+following+game:\n", config.crc32, config.crc32);
|
||||
|
@ -56,7 +56,6 @@
|
||||
#define VIRTUA_TENNIS_3 0xc4b7e89
|
||||
#define VIRTUA_TENNIS_3_TEST 0xffe3b0fd
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
YELLOW,
|
||||
@ -98,8 +97,6 @@ typedef struct
|
||||
unsigned int button4;
|
||||
} PlayerKeyMapping;
|
||||
|
||||
// All keycode can be found using `xev` binary's debug output
|
||||
// NOTE: Maybe using tagged union for driving and shooting games
|
||||
typedef struct
|
||||
{
|
||||
unsigned int test;
|
||||
@ -131,10 +128,10 @@ typedef struct
|
||||
int showDebugMessages;
|
||||
char *gameID;
|
||||
char *gameTitle;
|
||||
char* gameDVP;
|
||||
char *gameDVP;
|
||||
} EmulatorConfig;
|
||||
|
||||
KeyMapping getDefualtKeymap();
|
||||
KeyMapping getDefaultKeymap();
|
||||
int initConfig();
|
||||
EmulatorConfig *getConfig();
|
||||
char *getGameName();
|
||||
|
@ -29,49 +29,53 @@ int initInput()
|
||||
int XNextEventDriving(Display *display, XEvent *event_return, int returnValue)
|
||||
{
|
||||
KeyMapping keymap = getConfig()->keymap;
|
||||
if (event_return->type == KeyPress || event_return->type == KeyRelease)
|
||||
switch (event_return->type)
|
||||
{
|
||||
case KeyPress:
|
||||
case KeyRelease:
|
||||
{
|
||||
if (event_return->xkey.keycode == keymap.test)
|
||||
setSwitch(SYSTEM, BUTTON_TEST, event_return->type == KeyPress);
|
||||
|
||||
else if (event_return->xkey.keycode == keymap.player1.service)
|
||||
setSwitch(PLAYER_1, BUTTON_SERVICE, event_return->type == KeyPress);
|
||||
|
||||
else if (event_return->xkey.keycode == keymap.player1.coin)
|
||||
incrementCoin(PLAYER_1, event_return->type == KeyPress);
|
||||
else if (event_return->xkey.keycode == keymap.player2.coin)
|
||||
incrementCoin(PLAYER_2, event_return->type == KeyPress);
|
||||
|
||||
else if (event_return->xkey.keycode == keymap.player1.up)
|
||||
setAnalogue(ANALOGUE_2,
|
||||
event_return->type == KeyPress ? pow(2, 10) - 1 : 0);
|
||||
setAnalogue(ANALOGUE_2, event_return->type == KeyPress ? pow(2, 10) - 1 : 0);
|
||||
|
||||
else if (event_return->xkey.keycode == keymap.player1.down)
|
||||
setAnalogue(ANALOGUE_3,
|
||||
event_return->type == KeyPress ? pow(2, 10) - 1 : 0);
|
||||
setAnalogue(ANALOGUE_3, event_return->type == KeyPress ? pow(2, 10) - 1 : 0);
|
||||
|
||||
else if (event_return->xkey.keycode == keymap.player1.left)
|
||||
setAnalogue(ANALOGUE_1, event_return->type == KeyPress
|
||||
? pow(2, 10) * 0.2
|
||||
: pow(2, 10) * 0.5);
|
||||
setAnalogue(ANALOGUE_1, event_return->type == KeyPress ? pow(2, 10) * 0.2 : pow(2, 10) * 0.5);
|
||||
|
||||
else if (event_return->xkey.keycode == keymap.player1.right)
|
||||
setAnalogue(ANALOGUE_1, event_return->type == KeyPress
|
||||
? pow(2, 10) * 0.8
|
||||
: pow(2, 10) * 0.5);
|
||||
setAnalogue(ANALOGUE_1, event_return->type == KeyPress ? pow(2, 10) * 0.8 : pow(2, 10) * 0.5);
|
||||
|
||||
else if (event_return->xkey.keycode == keymap.player1.start)
|
||||
setSwitch(PLAYER_1, BUTTON_START, event_return->type == KeyPress);
|
||||
|
||||
else if (event_return->xkey.keycode == keymap.player1.button1)
|
||||
setSwitch(PLAYER_1, BUTTON_1, event_return->type == KeyPress);
|
||||
|
||||
else if (event_return->xkey.keycode == keymap.player1.button2)
|
||||
setSwitch(PLAYER_1, BUTTON_2, event_return->type == KeyPress);
|
||||
|
||||
else if (event_return->xkey.keycode == keymap.player1.button3)
|
||||
setSwitch(PLAYER_1, BUTTON_3, event_return->type == KeyPress);
|
||||
|
||||
else if (event_return->xkey.keycode == keymap.player1.button4)
|
||||
setSwitch(PLAYER_1, BUTTON_4, event_return->type == KeyPress);
|
||||
else if (event_return->xkey.keycode == keymap.player1.up)
|
||||
setSwitch(PLAYER_1, BUTTON_UP, event_return->type == KeyPress);
|
||||
else if (event_return->xkey.keycode == keymap.player1.down)
|
||||
setSwitch(PLAYER_1, BUTTON_DOWN, event_return->type == KeyPress);
|
||||
else if (event_return->xkey.keycode == keymap.player1.left)
|
||||
setSwitch(PLAYER_1, BUTTON_LEFT, event_return->type == KeyPress);
|
||||
else if (event_return->xkey.keycode == keymap.player1.right)
|
||||
setSwitch(PLAYER_1, BUTTON_RIGHT, event_return->type == KeyPress);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
@ -81,56 +85,74 @@ int XNextEventDriving(Display *display, XEvent *event_return, int returnValue)
|
||||
int XNextEventShooting(Display *display, XEvent *event_return, int returnValue)
|
||||
{
|
||||
KeyMapping keymap = getConfig()->keymap;
|
||||
if (event_return->type == KeyPress || event_return->type == KeyRelease)
|
||||
switch (event_return->type)
|
||||
{
|
||||
case KeyPress:
|
||||
case KeyRelease:
|
||||
{
|
||||
if (event_return->xkey.keycode == keymap.test)
|
||||
setSwitch(SYSTEM, BUTTON_TEST, event_return->type == KeyPress);
|
||||
|
||||
else if (event_return->xkey.keycode == keymap.player1.service)
|
||||
setSwitch(PLAYER_1, BUTTON_SERVICE, event_return->type == KeyPress);
|
||||
|
||||
else if (event_return->xkey.keycode == keymap.player1.coin)
|
||||
incrementCoin(PLAYER_1, event_return->type == KeyPress);
|
||||
else if (event_return->xkey.keycode == keymap.player2.coin)
|
||||
incrementCoin(PLAYER_2, event_return->type == KeyPress);
|
||||
|
||||
else if (event_return->xkey.keycode == keymap.player1.start)
|
||||
setSwitch(PLAYER_1, BUTTON_START, event_return->type == KeyPress);
|
||||
|
||||
else if (event_return->xkey.keycode == keymap.player1.button1)
|
||||
setSwitch(PLAYER_1, BUTTON_1, event_return->type == KeyPress);
|
||||
|
||||
else if (event_return->xkey.keycode == keymap.player1.button2)
|
||||
setSwitch(PLAYER_1, BUTTON_2, event_return->type == KeyPress);
|
||||
|
||||
else if (event_return->xkey.keycode == keymap.player1.button3)
|
||||
setSwitch(PLAYER_1, BUTTON_3, event_return->type == KeyPress);
|
||||
|
||||
else if (event_return->xkey.keycode == keymap.player1.button4)
|
||||
setSwitch(PLAYER_1, BUTTON_4, event_return->type == KeyPress);
|
||||
|
||||
else if (event_return->xkey.keycode == keymap.player1.up)
|
||||
setSwitch(PLAYER_1, BUTTON_UP, event_return->type == KeyPress);
|
||||
|
||||
else if (event_return->xkey.keycode == keymap.player1.down)
|
||||
setSwitch(PLAYER_1, BUTTON_DOWN, event_return->type == KeyPress);
|
||||
|
||||
else if (event_return->xkey.keycode == keymap.player1.left)
|
||||
setSwitch(PLAYER_1, BUTTON_LEFT, event_return->type == KeyPress);
|
||||
|
||||
else if (event_return->xkey.keycode == keymap.player1.right)
|
||||
setSwitch(PLAYER_1, BUTTON_RIGHT, event_return->type == KeyPress);
|
||||
}
|
||||
else if (event_return->type == MotionNotify)
|
||||
break;
|
||||
|
||||
case MotionNotify:
|
||||
{
|
||||
setAnalogue(ANALOGUE_1,
|
||||
((double)event_return->xmotion.x / (double)getConfig()->width) *
|
||||
pow(2, 10));
|
||||
setAnalogue(ANALOGUE_2, ((double)event_return->xmotion.y /
|
||||
(double)getConfig()->height) *
|
||||
pow(2, 10));
|
||||
setAnalogue(ANALOGUE_1, ((double)event_return->xmotion.x / (double)getConfig()->width) * pow(2, 10));
|
||||
setAnalogue(ANALOGUE_2, ((double)event_return->xmotion.y / (double)getConfig()->height) * pow(2, 10));
|
||||
}
|
||||
else if (event_return->type == ButtonPress || event_return->type == ButtonRelease)
|
||||
break;
|
||||
|
||||
case ButtonPress:
|
||||
case ButtonRelease:
|
||||
{
|
||||
// Trigger
|
||||
if (event_return->xbutton.button == 1)
|
||||
if (event_return->xbutton.button == 1) // Trigger
|
||||
setSwitch(PLAYER_1, BUTTON_1, event_return->type == ButtonPress);
|
||||
// Reload
|
||||
else if (event_return->xbutton.button == 3)
|
||||
|
||||
else if (event_return->xbutton.button == 3) // Reload
|
||||
setSwitch(PLAYER_1, BUTTON_2, event_return->type == ButtonPress);
|
||||
// Gun button
|
||||
else if (event_return->xbutton.button == 2)
|
||||
|
||||
else if (event_return->xbutton.button == 2) // Extra Gun Button
|
||||
setSwitch(PLAYER_1, BUTTON_3, event_return->type == ButtonPress);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user