Merge branch 'Caviar-X/master'
This commit is contained in:
commit
b733693808
@ -67,3 +67,18 @@
|
|||||||
|
|
||||||
# Set if you want to see debug messages in the console
|
# Set if you want to see debug messages in the console
|
||||||
# DEBUG_MSGS 1
|
# DEBUG_MSGS 1
|
||||||
|
|
||||||
|
# Set the different keys used to control the games.
|
||||||
|
# You can find out the key numbers by running `xev` on linux.
|
||||||
|
# TEST_KEY 28
|
||||||
|
# PLAYER_1_START_KEY 10
|
||||||
|
# PLAYER_1_SERVICE_KEY 39
|
||||||
|
# PLAYER_1_COIN_KEY 14
|
||||||
|
# PLAYER_1_UP_KEY 111
|
||||||
|
# PLAYER_1_DOWN_KEY 116
|
||||||
|
# PLAYER_1_LEFT_KEY 113
|
||||||
|
# PLAYER_1_RIGHT_KEY 114
|
||||||
|
# PLAYER_1_BUTTON_1_KEY 24
|
||||||
|
# PLAYER_1_BUTTON_2_KEY 25
|
||||||
|
# PLAYER_1_BUTTON_3_KEY 26
|
||||||
|
# PLAYER_1_BUTTON_4_KEY 27
|
||||||
|
@ -416,6 +416,42 @@ int readConfig(FILE *configFile, EmulatorConfig *config)
|
|||||||
else if (strcmp(command, "DEBUG_MSGS") == 0)
|
else if (strcmp(command, "DEBUG_MSGS") == 0)
|
||||||
config->showDebugMessages = atoi(getNextToken(NULL, " ", &saveptr));
|
config->showDebugMessages = atoi(getNextToken(NULL, " ", &saveptr));
|
||||||
|
|
||||||
|
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)
|
||||||
|
config->keymap.player1.start = atoi(getNextToken(NULL, " ", &saveptr));
|
||||||
|
|
||||||
|
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)
|
||||||
|
config->keymap.player1.coin = atoi(getNextToken(NULL, " ", &saveptr));
|
||||||
|
|
||||||
|
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)
|
||||||
|
config->keymap.player1.down = atoi(getNextToken(NULL, " ", &saveptr));
|
||||||
|
|
||||||
|
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)
|
||||||
|
config->keymap.player1.right = atoi(getNextToken(NULL, " ", &saveptr));
|
||||||
|
|
||||||
|
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)
|
||||||
|
config->keymap.player1.button2 = atoi(getNextToken(NULL, " ", &saveptr));
|
||||||
|
|
||||||
|
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)
|
||||||
|
config->keymap.player1.button4 = atoi(getNextToken(NULL, " ", &saveptr));
|
||||||
|
|
||||||
else
|
else
|
||||||
printf("Error: Unknown settings command %s\n", command);
|
printf("Error: Unknown settings command %s\n", command);
|
||||||
}
|
}
|
||||||
@ -423,6 +459,36 @@ int readConfig(FILE *configFile, EmulatorConfig *config)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
KeyMapping getDefualtKeymap()
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
int initConfig()
|
int initConfig()
|
||||||
{
|
{
|
||||||
config.emulateRideboard = 0;
|
config.emulateRideboard = 0;
|
||||||
@ -446,6 +512,7 @@ int initConfig()
|
|||||||
config.gameID = "XXXX";
|
config.gameID = "XXXX";
|
||||||
config.gameDVP = "DVP-XXXX";
|
config.gameDVP = "DVP-XXXX";
|
||||||
config.gameType = SHOOTING;
|
config.gameType = SHOOTING;
|
||||||
|
config.keymap = getDefualtKeymap();
|
||||||
if (detectGame(config.crc32) != 0)
|
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);
|
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);
|
||||||
|
@ -83,6 +83,30 @@ typedef enum
|
|||||||
FIGHTING
|
FIGHTING
|
||||||
} GameType;
|
} GameType;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
unsigned int service;
|
||||||
|
unsigned int start;
|
||||||
|
unsigned int coin;
|
||||||
|
unsigned int up;
|
||||||
|
unsigned int down;
|
||||||
|
unsigned int left;
|
||||||
|
unsigned int right;
|
||||||
|
unsigned int button1;
|
||||||
|
unsigned int button2;
|
||||||
|
unsigned int button3;
|
||||||
|
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;
|
||||||
|
PlayerKeyMapping player1;
|
||||||
|
PlayerKeyMapping player2;
|
||||||
|
} KeyMapping;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int emulateRideboard;
|
int emulateRideboard;
|
||||||
@ -100,6 +124,7 @@ typedef struct
|
|||||||
Colour lindberghColour;
|
Colour lindberghColour;
|
||||||
GameStatus gameStatus;
|
GameStatus gameStatus;
|
||||||
GameType gameType;
|
GameType gameType;
|
||||||
|
KeyMapping keymap;
|
||||||
uint32_t crc32;
|
uint32_t crc32;
|
||||||
GameRegion region;
|
GameRegion region;
|
||||||
int freeplay;
|
int freeplay;
|
||||||
@ -109,6 +134,7 @@ typedef struct
|
|||||||
char* gameDVP;
|
char* gameDVP;
|
||||||
} EmulatorConfig;
|
} EmulatorConfig;
|
||||||
|
|
||||||
|
KeyMapping getDefualtKeymap();
|
||||||
int initConfig();
|
int initConfig();
|
||||||
EmulatorConfig *getConfig();
|
EmulatorConfig *getConfig();
|
||||||
char *getGameName();
|
char *getGameName();
|
||||||
|
@ -28,72 +28,50 @@ int initInput()
|
|||||||
*/
|
*/
|
||||||
int XNextEventDriving(Display *display, XEvent *event_return, int returnValue)
|
int XNextEventDriving(Display *display, XEvent *event_return, int returnValue)
|
||||||
{
|
{
|
||||||
switch (event_return->type)
|
KeyMapping keymap = getConfig()->keymap;
|
||||||
|
if (event_return->type == KeyPress || event_return->type == KeyRelease)
|
||||||
{
|
{
|
||||||
|
if (event_return->xkey.keycode == keymap.test)
|
||||||
case KeyRelease:
|
|
||||||
case KeyPress:
|
|
||||||
{
|
|
||||||
switch (event_return->xkey.keycode)
|
|
||||||
{
|
|
||||||
case 28:
|
|
||||||
setSwitch(SYSTEM, BUTTON_TEST, event_return->type == KeyPress);
|
setSwitch(SYSTEM, BUTTON_TEST, event_return->type == KeyPress);
|
||||||
break;
|
else if (event_return->xkey.keycode == keymap.player1.service)
|
||||||
case 39:
|
|
||||||
setSwitch(PLAYER_1, BUTTON_SERVICE, event_return->type == KeyPress);
|
setSwitch(PLAYER_1, BUTTON_SERVICE, event_return->type == KeyPress);
|
||||||
break;
|
else if (event_return->xkey.keycode == keymap.player1.coin)
|
||||||
case 14:
|
|
||||||
incrementCoin(PLAYER_1, event_return->type == KeyPress);
|
incrementCoin(PLAYER_1, event_return->type == KeyPress);
|
||||||
break;
|
else if (event_return->xkey.keycode == keymap.player2.coin)
|
||||||
case 15:
|
|
||||||
incrementCoin(PLAYER_2, event_return->type == KeyPress);
|
incrementCoin(PLAYER_2, event_return->type == KeyPress);
|
||||||
break;
|
else if (event_return->xkey.keycode == keymap.player1.up)
|
||||||
case 111: // Up
|
setAnalogue(ANALOGUE_2,
|
||||||
setAnalogue(ANALOGUE_2, event_return->type == KeyPress ? pow(2, 10) - 1 : 0);
|
event_return->type == KeyPress ? pow(2, 10) - 1 : 0);
|
||||||
break;
|
else if (event_return->xkey.keycode == keymap.player1.down)
|
||||||
case 116: // Down
|
setAnalogue(ANALOGUE_3,
|
||||||
setAnalogue(ANALOGUE_3, event_return->type == KeyPress ? pow(2, 10) - 1 : 0);
|
event_return->type == KeyPress ? pow(2, 10) - 1 : 0);
|
||||||
break;
|
else if (event_return->xkey.keycode == keymap.player1.left)
|
||||||
case 113: // Left
|
setAnalogue(ANALOGUE_1, event_return->type == KeyPress
|
||||||
setAnalogue(ANALOGUE_1, event_return->type == KeyPress ? pow(2, 10) * 0.2 : pow(2, 10) * 0.5);
|
? pow(2, 10) * 0.2
|
||||||
break;
|
: pow(2, 10) * 0.5);
|
||||||
case 114: // Right
|
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
|
||||||
break;
|
? pow(2, 10) * 0.8
|
||||||
case 10:
|
: pow(2, 10) * 0.5);
|
||||||
|
else if (event_return->xkey.keycode == keymap.player1.start)
|
||||||
setSwitch(PLAYER_1, BUTTON_START, event_return->type == KeyPress);
|
setSwitch(PLAYER_1, BUTTON_START, event_return->type == KeyPress);
|
||||||
break;
|
else if (event_return->xkey.keycode == keymap.player1.button1)
|
||||||
case 24:
|
|
||||||
setSwitch(PLAYER_1, BUTTON_1, event_return->type == KeyPress);
|
setSwitch(PLAYER_1, BUTTON_1, event_return->type == KeyPress);
|
||||||
break;
|
else if (event_return->xkey.keycode == keymap.player1.button2)
|
||||||
case 25:
|
|
||||||
setSwitch(PLAYER_1, BUTTON_2, event_return->type == KeyPress);
|
setSwitch(PLAYER_1, BUTTON_2, event_return->type == KeyPress);
|
||||||
break;
|
else if (event_return->xkey.keycode == keymap.player1.button3)
|
||||||
case 26:
|
|
||||||
setSwitch(PLAYER_1, BUTTON_3, event_return->type == KeyPress);
|
setSwitch(PLAYER_1, BUTTON_3, event_return->type == KeyPress);
|
||||||
break;
|
else if (event_return->xkey.keycode == keymap.player1.button4)
|
||||||
case 27:
|
|
||||||
setSwitch(PLAYER_1, BUTTON_4, event_return->type == KeyPress);
|
setSwitch(PLAYER_1, BUTTON_4, event_return->type == KeyPress);
|
||||||
break;
|
else if (event_return->xkey.keycode == keymap.player1.up)
|
||||||
case 29:
|
|
||||||
setSwitch(PLAYER_1, BUTTON_UP, event_return->type == KeyPress);
|
setSwitch(PLAYER_1, BUTTON_UP, event_return->type == KeyPress);
|
||||||
break;
|
else if (event_return->xkey.keycode == keymap.player1.down)
|
||||||
case 30:
|
|
||||||
setSwitch(PLAYER_1, BUTTON_DOWN, event_return->type == KeyPress);
|
setSwitch(PLAYER_1, BUTTON_DOWN, event_return->type == KeyPress);
|
||||||
break;
|
else if (event_return->xkey.keycode == keymap.player1.left)
|
||||||
case 31:
|
|
||||||
setSwitch(PLAYER_1, BUTTON_LEFT, event_return->type == KeyPress);
|
setSwitch(PLAYER_1, BUTTON_LEFT, event_return->type == KeyPress);
|
||||||
break;
|
else if (event_return->xkey.keycode == keymap.player1.right)
|
||||||
case 32:
|
|
||||||
setSwitch(PLAYER_1, BUTTON_RIGHT, event_return->type == KeyPress);
|
setSwitch(PLAYER_1, BUTTON_RIGHT, event_return->type == KeyPress);
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return returnValue;
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,87 +80,57 @@ int XNextEventDriving(Display *display, XEvent *event_return, int returnValue)
|
|||||||
*/
|
*/
|
||||||
int XNextEventShooting(Display *display, XEvent *event_return, int returnValue)
|
int XNextEventShooting(Display *display, XEvent *event_return, int returnValue)
|
||||||
{
|
{
|
||||||
switch (event_return->type)
|
KeyMapping keymap = getConfig()->keymap;
|
||||||
|
if (event_return->type == KeyPress || event_return->type == KeyRelease)
|
||||||
{
|
{
|
||||||
|
if (event_return->xkey.keycode == keymap.test)
|
||||||
case KeyRelease:
|
|
||||||
case KeyPress:
|
|
||||||
{
|
|
||||||
switch (event_return->xkey.keycode)
|
|
||||||
{
|
|
||||||
case 28:
|
|
||||||
setSwitch(SYSTEM, BUTTON_TEST, event_return->type == KeyPress);
|
setSwitch(SYSTEM, BUTTON_TEST, event_return->type == KeyPress);
|
||||||
break;
|
else if (event_return->xkey.keycode == keymap.player1.service)
|
||||||
case 39:
|
|
||||||
setSwitch(PLAYER_1, BUTTON_SERVICE, event_return->type == KeyPress);
|
setSwitch(PLAYER_1, BUTTON_SERVICE, event_return->type == KeyPress);
|
||||||
break;
|
else if (event_return->xkey.keycode == keymap.player1.coin)
|
||||||
case 14:
|
|
||||||
incrementCoin(PLAYER_1, event_return->type == KeyPress);
|
incrementCoin(PLAYER_1, event_return->type == KeyPress);
|
||||||
break;
|
else if (event_return->xkey.keycode == keymap.player2.coin)
|
||||||
case 15:
|
|
||||||
incrementCoin(PLAYER_2, event_return->type == KeyPress);
|
incrementCoin(PLAYER_2, event_return->type == KeyPress);
|
||||||
break;
|
else if (event_return->xkey.keycode == keymap.player1.start)
|
||||||
case 111:
|
|
||||||
setSwitch(PLAYER_1, BUTTON_UP, event_return->type == KeyPress);
|
|
||||||
break;
|
|
||||||
case 116:
|
|
||||||
setSwitch(PLAYER_1, BUTTON_DOWN, event_return->type == KeyPress);
|
|
||||||
break;
|
|
||||||
case 113:
|
|
||||||
setSwitch(PLAYER_1, BUTTON_LEFT, event_return->type == KeyPress);
|
|
||||||
break;
|
|
||||||
case 114:
|
|
||||||
setSwitch(PLAYER_1, BUTTON_RIGHT, event_return->type == KeyPress);
|
|
||||||
break;
|
|
||||||
case 10:
|
|
||||||
setSwitch(PLAYER_1, BUTTON_START, event_return->type == KeyPress);
|
setSwitch(PLAYER_1, BUTTON_START, event_return->type == KeyPress);
|
||||||
break;
|
else if (event_return->xkey.keycode == keymap.player1.button1)
|
||||||
case 24:
|
|
||||||
setSwitch(PLAYER_1, BUTTON_1, event_return->type == KeyPress);
|
setSwitch(PLAYER_1, BUTTON_1, event_return->type == KeyPress);
|
||||||
break;
|
else if (event_return->xkey.keycode == keymap.player1.button2)
|
||||||
case 25:
|
|
||||||
setSwitch(PLAYER_1, BUTTON_2, event_return->type == KeyPress);
|
setSwitch(PLAYER_1, BUTTON_2, event_return->type == KeyPress);
|
||||||
break;
|
else if (event_return->xkey.keycode == keymap.player1.button3)
|
||||||
case 26:
|
|
||||||
setSwitch(PLAYER_1, BUTTON_3, event_return->type == KeyPress);
|
setSwitch(PLAYER_1, BUTTON_3, event_return->type == KeyPress);
|
||||||
break;
|
else if (event_return->xkey.keycode == keymap.player1.button4)
|
||||||
case 27:
|
|
||||||
setSwitch(PLAYER_1, BUTTON_4, event_return->type == KeyPress);
|
setSwitch(PLAYER_1, BUTTON_4, event_return->type == KeyPress);
|
||||||
break;
|
else if (event_return->xkey.keycode == keymap.player1.up)
|
||||||
default:
|
setSwitch(PLAYER_1, BUTTON_UP, event_return->type == KeyPress);
|
||||||
break;
|
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)
|
||||||
|
{
|
||||||
|
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));
|
||||||
}
|
}
|
||||||
break;
|
else if (event_return->type == ButtonPress || event_return->type == ButtonRelease)
|
||||||
|
|
||||||
case MotionNotify:
|
|
||||||
{
|
{
|
||||||
setAnalogue(ANALOGUE_1, ((double)event_return->xmotion.x / (double)getConfig()->width) * pow(2, 10));
|
// Trigger
|
||||||
setAnalogue(ANALOGUE_2, ((double)event_return->xmotion.y / (double)getConfig()->height) * pow(2, 10));
|
if (event_return->xbutton.button == 1)
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ButtonPress:
|
|
||||||
case ButtonRelease:
|
|
||||||
{
|
|
||||||
switch (event_return->xbutton.button)
|
|
||||||
{
|
|
||||||
case 1: // Trigger
|
|
||||||
setSwitch(PLAYER_1, BUTTON_1, event_return->type == ButtonPress);
|
setSwitch(PLAYER_1, BUTTON_1, event_return->type == ButtonPress);
|
||||||
break;
|
// Reload
|
||||||
case 3: // Reload
|
else if (event_return->xbutton.button == 3)
|
||||||
setSwitch(PLAYER_1, BUTTON_2, event_return->type == ButtonPress);
|
setSwitch(PLAYER_1, BUTTON_2, event_return->type == ButtonPress);
|
||||||
break;
|
// Gun button
|
||||||
case 9: // Gun Button
|
else if (event_return->xbutton.button == 2)
|
||||||
setSwitch(PLAYER_1, BUTTON_3, event_return->type == ButtonPress);
|
setSwitch(PLAYER_1, BUTTON_3, event_return->type == ButtonPress);
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return returnValue;
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user