Removed unused button config arrays in preparation for implementing SDL2 game controller setup.
This commit is contained in:
parent
10b84fa47c
commit
e018b4b945
|
@ -24,7 +24,6 @@ GamePadConfDialog_t::GamePadConfDialog_t(QWidget *parent)
|
|||
InitJoysticks();
|
||||
|
||||
portNum = 0;
|
||||
configNo = 0;
|
||||
buttonConfigStatus = 1;
|
||||
|
||||
setWindowTitle( tr("GamePad Config") );
|
||||
|
@ -157,14 +156,14 @@ void GamePadConfDialog_t::updateCntrlrDpy(void)
|
|||
|
||||
for (int i=0; i<GAMEPAD_NUM_BUTTONS; i++)
|
||||
{
|
||||
if (GamePadConfig[portNum][i].ButtType[configNo] == BUTTC_KEYBOARD)
|
||||
if (GamePadConfig[portNum][i].ButtType == BUTTC_KEYBOARD)
|
||||
{
|
||||
snprintf( keyNameStr, sizeof (keyNameStr), "%s",
|
||||
SDL_GetKeyName (GamePadConfig[portNum][i].ButtonNum[configNo]));
|
||||
SDL_GetKeyName (GamePadConfig[portNum][i].ButtonNum));
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy( keyNameStr, ButtonName( &GamePadConfig[portNum][i], configNo ) );
|
||||
strcpy( keyNameStr, ButtonName( &GamePadConfig[portNum][i] ) );
|
||||
}
|
||||
keyName[i]->setText( tr(keyNameStr) );
|
||||
}
|
||||
|
@ -210,16 +209,16 @@ void GamePadConfDialog_t::changeButton(int padNo, int x)
|
|||
|
||||
snprintf (buf, sizeof(buf)-1, "SDL.Input.GamePad.%d.", padNo);
|
||||
prefix = buf;
|
||||
DWaitButton (NULL, &GamePadConfig[padNo][x], configNo, &buttonConfigStatus );
|
||||
DWaitButton (NULL, &GamePadConfig[padNo][x], &buttonConfigStatus );
|
||||
|
||||
g_config->setOption (prefix + GamePadNames[x],
|
||||
GamePadConfig[padNo][x].ButtonNum[configNo]);
|
||||
GamePadConfig[padNo][x].ButtonNum);
|
||||
|
||||
if (GamePadConfig[padNo][x].ButtType[configNo] == BUTTC_KEYBOARD)
|
||||
if (GamePadConfig[padNo][x].ButtType == BUTTC_KEYBOARD)
|
||||
{
|
||||
g_config->setOption (prefix + "DeviceType", "Keyboard");
|
||||
}
|
||||
else if (GamePadConfig[padNo][x].ButtType[configNo] == BUTTC_JOYSTICK)
|
||||
else if (GamePadConfig[padNo][x].ButtType == BUTTC_JOYSTICK)
|
||||
{
|
||||
g_config->setOption (prefix + "DeviceType", "Joystick");
|
||||
}
|
||||
|
@ -228,9 +227,9 @@ void GamePadConfDialog_t::changeButton(int padNo, int x)
|
|||
g_config->setOption (prefix + "DeviceType", "Unknown");
|
||||
}
|
||||
g_config->setOption (prefix + "DeviceNum",
|
||||
GamePadConfig[padNo][x].DeviceNum[configNo]);
|
||||
GamePadConfig[padNo][x].DeviceNum);
|
||||
|
||||
keyNameStr = ButtonName( &GamePadConfig[padNo][x], configNo );
|
||||
keyNameStr = ButtonName( &GamePadConfig[padNo][x] );
|
||||
|
||||
keyName[x]->setText( keyNameStr );
|
||||
button[x]->setText("Change");
|
||||
|
@ -245,7 +244,7 @@ void GamePadConfDialog_t::clearButton( int padNo, int x )
|
|||
char buf[256];
|
||||
std::string prefix;
|
||||
|
||||
GamePadConfig[padNo][x].ButtonNum[configNo] = -1;
|
||||
GamePadConfig[padNo][x].ButtonNum = -1;
|
||||
|
||||
keyName[x]->setText("");
|
||||
|
||||
|
@ -253,7 +252,7 @@ void GamePadConfDialog_t::clearButton( int padNo, int x )
|
|||
prefix = buf;
|
||||
|
||||
g_config->setOption (prefix + GamePadNames[x],
|
||||
GamePadConfig[padNo][x].ButtonNum[configNo]);
|
||||
GamePadConfig[padNo][x].ButtonNum);
|
||||
|
||||
}
|
||||
//----------------------------------------------------
|
||||
|
@ -396,19 +395,18 @@ void GamePadConfDialog_t::loadDefaults(void)
|
|||
|
||||
for (int x=0; x<GAMEPAD_NUM_BUTTONS; x++)
|
||||
{
|
||||
GamePadConfig[portNum][x].ButtType[configNo] = BUTTC_KEYBOARD;
|
||||
GamePadConfig[portNum][x].DeviceNum[configNo] = 0;
|
||||
GamePadConfig[portNum][x].ButtonNum[configNo] = DefaultGamePad[portNum][x];
|
||||
GamePadConfig[portNum][x].NumC = 1;
|
||||
GamePadConfig[portNum][x].ButtType = BUTTC_KEYBOARD;
|
||||
GamePadConfig[portNum][x].DeviceNum = 0;
|
||||
GamePadConfig[portNum][x].ButtonNum = DefaultGamePad[portNum][x];
|
||||
|
||||
g_config->setOption (prefix + GamePadNames[x],
|
||||
GamePadConfig[portNum][x].ButtonNum[configNo]);
|
||||
GamePadConfig[portNum][x].ButtonNum);
|
||||
|
||||
if (GamePadConfig[portNum][x].ButtType[configNo] == BUTTC_KEYBOARD)
|
||||
if (GamePadConfig[portNum][x].ButtType == BUTTC_KEYBOARD)
|
||||
{
|
||||
g_config->setOption (prefix + "DeviceType", "Keyboard");
|
||||
}
|
||||
else if (GamePadConfig[portNum][x].ButtType[configNo] == BUTTC_JOYSTICK)
|
||||
else if (GamePadConfig[portNum][x].ButtType == BUTTC_JOYSTICK)
|
||||
{
|
||||
g_config->setOption (prefix + "DeviceType", "Joystick");
|
||||
}
|
||||
|
@ -417,7 +415,7 @@ void GamePadConfDialog_t::loadDefaults(void)
|
|||
g_config->setOption (prefix + "DeviceType", "Unknown");
|
||||
}
|
||||
g_config->setOption (prefix + "DeviceNum",
|
||||
GamePadConfig[portNum][x].DeviceNum[configNo]);
|
||||
GamePadConfig[portNum][x].DeviceNum);
|
||||
}
|
||||
updateCntrlrDpy();
|
||||
}
|
||||
|
|
|
@ -1002,32 +1002,28 @@ ButtonConfigEnd ()
|
|||
static int
|
||||
DTestButton (ButtConfig * bc)
|
||||
{
|
||||
int x;
|
||||
|
||||
for (x = 0; x < bc->NumC; x++)
|
||||
if (bc->ButtType == BUTTC_KEYBOARD)
|
||||
{
|
||||
if (bc->ButtType[x] == BUTTC_KEYBOARD)
|
||||
{
|
||||
if (g_keyState[SDL_GetScancodeFromKey (bc->ButtonNum[x])])
|
||||
if (g_keyState[SDL_GetScancodeFromKey (bc->ButtonNum)])
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if (bc->ButtType[x] == BUTTC_JOYSTICK)
|
||||
else if (bc->ButtType == BUTTC_JOYSTICK)
|
||||
{
|
||||
if (DTestButtonJoy (bc))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#define MK(x) {{BUTTC_KEYBOARD},{0},{MKK(x)},1}
|
||||
#define MK2(x1,x2) {{BUTTC_KEYBOARD},{0},{MKK(x1),MKK(x2)},2}
|
||||
#define MKZ() {{0},{0},{-1},0}
|
||||
#define MK(x) {BUTTC_KEYBOARD,0,MKK(x)}
|
||||
//#define MK2(x1,x2) {BUTTC_KEYBOARD,0,MKK(x1)}
|
||||
#define MKZ() {0,0,-1}
|
||||
#define GPZ() {MKZ(), MKZ(), MKZ(), MKZ()}
|
||||
|
||||
ButtConfig GamePadConfig[ GAMEPAD_NUM_DEVICES ][ GAMEPAD_NUM_BUTTONS ] =
|
||||
|
@ -1549,42 +1545,42 @@ UpdateFTrainer ()
|
|||
* @param bc the NES gamepad's button config
|
||||
* @param which the index of the button
|
||||
*/
|
||||
const char * ButtonName (const ButtConfig * bc, int which)
|
||||
const char * ButtonName (const ButtConfig * bc)
|
||||
{
|
||||
static char name[256];
|
||||
|
||||
name[0] = 0;
|
||||
|
||||
if (bc->ButtonNum[which] == -1)
|
||||
if (bc->ButtonNum == -1)
|
||||
{
|
||||
return name;
|
||||
}
|
||||
switch (bc->ButtType[which])
|
||||
switch (bc->ButtType)
|
||||
{
|
||||
case BUTTC_KEYBOARD:
|
||||
return SDL_GetKeyName (bc->ButtonNum[which]);
|
||||
return SDL_GetKeyName (bc->ButtonNum);
|
||||
break;
|
||||
case BUTTC_JOYSTICK:
|
||||
{
|
||||
int joyNum, inputNum;
|
||||
const char *inputType, *inputDirection;
|
||||
|
||||
joyNum = bc->DeviceNum[which];
|
||||
joyNum = bc->DeviceNum;
|
||||
|
||||
if (bc->ButtonNum[which] & 0x8000)
|
||||
if (bc->ButtonNum & 0x8000)
|
||||
{
|
||||
inputType = "Axis";
|
||||
inputNum = bc->ButtonNum[which] & 0x3FFF;
|
||||
inputDirection = bc->ButtonNum[which] & 0x4000 ? "-" : "+";
|
||||
inputNum = bc->ButtonNum & 0x3FFF;
|
||||
inputDirection = bc->ButtonNum & 0x4000 ? "-" : "+";
|
||||
}
|
||||
else if (bc->ButtonNum[which] & 0x2000)
|
||||
else if (bc->ButtonNum & 0x2000)
|
||||
{
|
||||
int inputValue;
|
||||
char direction[128] = "";
|
||||
|
||||
inputType = "Hat";
|
||||
inputNum = (bc->ButtonNum[which] >> 8) & 0x1F;
|
||||
inputValue = bc->ButtonNum[which] & 0xF;
|
||||
inputNum = (bc->ButtonNum >> 8) & 0x1F;
|
||||
inputValue = bc->ButtonNum & 0xF;
|
||||
|
||||
if (inputValue & SDL_HAT_UP)
|
||||
strncat (direction, "Up ", sizeof (direction)-1);
|
||||
|
@ -1603,7 +1599,7 @@ const char * ButtonName (const ButtConfig * bc, int which)
|
|||
else
|
||||
{
|
||||
inputType = "Button";
|
||||
inputNum = bc->ButtonNum[which];
|
||||
inputNum = bc->ButtonNum;
|
||||
inputDirection = "";
|
||||
}
|
||||
sprintf( name, "js%i:%s%i%s", joyNum, inputType, inputNum, inputDirection );
|
||||
|
@ -1618,7 +1614,7 @@ const char * ButtonName (const ButtConfig * bc, int which)
|
|||
* Waits for a button input and returns the information as to which
|
||||
* button was pressed. Used in button configuration.
|
||||
*/
|
||||
int DWaitButton (const uint8_t * text, ButtConfig * bc, int wb, int *buttonConfigStatus )
|
||||
int DWaitButton (const uint8_t * text, ButtConfig * bc, int *buttonConfigStatus )
|
||||
{
|
||||
SDL_Event event;
|
||||
static int32 LastAx[64][64];
|
||||
|
@ -1670,23 +1666,23 @@ int DWaitButton (const uint8_t * text, ButtConfig * bc, int wb, int *buttonConfi
|
|||
{
|
||||
case SDL_KEYDOWN:
|
||||
//printf("SDL KeyDown:%i \n", event.key.keysym.sym );
|
||||
bc->ButtType[wb] = BUTTC_KEYBOARD;
|
||||
bc->DeviceNum[wb] = 0;
|
||||
bc->ButtonNum[wb] = event.key.keysym.sym;
|
||||
bc->ButtType = BUTTC_KEYBOARD;
|
||||
bc->DeviceNum = 0;
|
||||
bc->ButtonNum = event.key.keysym.sym;
|
||||
return (1);
|
||||
case SDL_JOYBUTTONDOWN:
|
||||
bc->ButtType[wb] = BUTTC_JOYSTICK;
|
||||
bc->DeviceNum[wb] = event.jbutton.which;
|
||||
bc->ButtonNum[wb] = event.jbutton.button;
|
||||
bc->ButtType = BUTTC_JOYSTICK;
|
||||
bc->DeviceNum = event.jbutton.which;
|
||||
bc->ButtonNum = event.jbutton.button;
|
||||
return (1);
|
||||
case SDL_JOYHATMOTION:
|
||||
if (event.jhat.value == SDL_HAT_CENTERED)
|
||||
done--;
|
||||
else
|
||||
{
|
||||
bc->ButtType[wb] = BUTTC_JOYSTICK;
|
||||
bc->DeviceNum[wb] = event.jhat.which;
|
||||
bc->ButtonNum[wb] =
|
||||
bc->ButtType = BUTTC_JOYSTICK;
|
||||
bc->DeviceNum = event.jhat.which;
|
||||
bc->ButtonNum =
|
||||
(0x2000 | ((event.jhat.hat & 0x1F) << 8) | event.
|
||||
jhat.value);
|
||||
return (1);
|
||||
|
@ -1708,9 +1704,9 @@ int DWaitButton (const uint8_t * text, ButtConfig * bc, int wb, int *buttonConfi
|
|||
(LastAx[event.jaxis.which][event.jaxis.axis] -
|
||||
event.jaxis.value) >= 8192)
|
||||
{
|
||||
bc->ButtType[wb] = BUTTC_JOYSTICK;
|
||||
bc->DeviceNum[wb] = event.jaxis.which;
|
||||
bc->ButtonNum[wb] = (0x8000 | event.jaxis.axis |
|
||||
bc->ButtType = BUTTC_JOYSTICK;
|
||||
bc->DeviceNum = event.jaxis.which;
|
||||
bc->ButtonNum = (0x8000 | event.jaxis.axis |
|
||||
((event.jaxis.value < 0)
|
||||
? 0x4000 : 0));
|
||||
return (1);
|
||||
|
@ -1747,162 +1743,161 @@ int DWaitButton (const uint8_t * text, ButtConfig * bc, int wb, int *buttonConfi
|
|||
* used as input for the specified button, thus allowing up to four
|
||||
* possible settings for each input button.
|
||||
*/
|
||||
void
|
||||
ConfigButton (char *text, ButtConfig * bc)
|
||||
{
|
||||
uint8 buf[256];
|
||||
int wc;
|
||||
|
||||
for (wc = 0; wc < MAXBUTTCONFIG; wc++)
|
||||
{
|
||||
sprintf ((char *) buf, "%s (%d)", text, wc + 1);
|
||||
DWaitButton (buf, bc, wc, NULL);
|
||||
|
||||
if (wc &&
|
||||
bc->ButtType[wc] == bc->ButtType[wc - 1] &&
|
||||
bc->DeviceNum[wc] == bc->DeviceNum[wc - 1] &&
|
||||
bc->ButtonNum[wc] == bc->ButtonNum[wc - 1])
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
bc->NumC = wc;
|
||||
}
|
||||
// void
|
||||
//ConfigButton (char *text, ButtConfig * bc)
|
||||
//{
|
||||
// uint8 buf[256];
|
||||
// int wc;
|
||||
//
|
||||
// for (wc = 0; wc < MAXBUTTCONFIG; wc++)
|
||||
// {
|
||||
// sprintf ((char *) buf, "%s (%d)", text, wc + 1);
|
||||
// DWaitButton (buf, bc, wc, NULL);
|
||||
//
|
||||
// if (wc &&
|
||||
// bc->ButtType[wc] == bc->ButtType[wc - 1] &&
|
||||
// bc->DeviceNum[wc] == bc->DeviceNum[wc - 1] &&
|
||||
// bc->ButtonNum[wc] == bc->ButtonNum[wc - 1])
|
||||
// {
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
/**
|
||||
* Update the button configuration for a specified device.
|
||||
*/
|
||||
extern Config *g_config;
|
||||
|
||||
void ConfigDevice (int which, int arg)
|
||||
{
|
||||
char buf[256];
|
||||
int x;
|
||||
std::string prefix;
|
||||
const char *str[10] =
|
||||
{ "A", "B", "SELECT", "START", "UP", "DOWN", "LEFT", "RIGHT", "Rapid A",
|
||||
"Rapid B"
|
||||
};
|
||||
|
||||
// XXX soules - set the configuration options so that later calls
|
||||
// don't override these. This is a temp hack until I
|
||||
// can clean up this file.
|
||||
|
||||
ButtonConfigBegin ();
|
||||
switch (which)
|
||||
{
|
||||
case FCFGD_QUIZKING:
|
||||
prefix = "SDL.Input.QuizKing.";
|
||||
for (x = 0; x < 6; x++)
|
||||
{
|
||||
sprintf (buf, "Quiz King Buzzer #%d", x + 1);
|
||||
ConfigButton (buf, &QuizKingButtons[x]);
|
||||
|
||||
g_config->setOption (prefix + QuizKingNames[x],
|
||||
QuizKingButtons[x].ButtonNum[0]);
|
||||
}
|
||||
|
||||
if (QuizKingButtons[0].ButtType[0] == BUTTC_KEYBOARD)
|
||||
{
|
||||
g_config->setOption (prefix + "DeviceType", "Keyboard");
|
||||
}
|
||||
else if (QuizKingButtons[0].ButtType[0] == BUTTC_JOYSTICK)
|
||||
{
|
||||
g_config->setOption (prefix + "DeviceType", "Joystick");
|
||||
}
|
||||
else
|
||||
{
|
||||
g_config->setOption (prefix + "DeviceType", "Unknown");
|
||||
}
|
||||
g_config->setOption (prefix + "DeviceNum",
|
||||
QuizKingButtons[0].DeviceNum[0]);
|
||||
break;
|
||||
case FCFGD_HYPERSHOT:
|
||||
prefix = "SDL.Input.HyperShot.";
|
||||
for (x = 0; x < 4; x++)
|
||||
{
|
||||
sprintf (buf, "Hyper Shot %d: %s",
|
||||
((x & 2) >> 1) + 1, (x & 1) ? "JUMP" : "RUN");
|
||||
ConfigButton (buf, &HyperShotButtons[x]);
|
||||
|
||||
g_config->setOption (prefix + HyperShotNames[x],
|
||||
HyperShotButtons[x].ButtonNum[0]);
|
||||
}
|
||||
|
||||
if (HyperShotButtons[0].ButtType[0] == BUTTC_KEYBOARD)
|
||||
{
|
||||
g_config->setOption (prefix + "DeviceType", "Keyboard");
|
||||
}
|
||||
else if (HyperShotButtons[0].ButtType[0] == BUTTC_JOYSTICK)
|
||||
{
|
||||
g_config->setOption (prefix + "DeviceType", "Joystick");
|
||||
}
|
||||
else
|
||||
{
|
||||
g_config->setOption (prefix + "DeviceType", "Unknown");
|
||||
}
|
||||
g_config->setOption (prefix + "DeviceNum",
|
||||
HyperShotButtons[0].DeviceNum[0]);
|
||||
break;
|
||||
case FCFGD_POWERPAD:
|
||||
snprintf (buf, 256, "SDL.Input.PowerPad.%d", (arg & 1));
|
||||
prefix = buf;
|
||||
for (x = 0; x < 12; x++)
|
||||
{
|
||||
sprintf (buf, "PowerPad %d: %d", (arg & 1) + 1, x + 11);
|
||||
ConfigButton (buf, &powerpadsc[arg & 1][x]);
|
||||
|
||||
g_config->setOption (prefix + PowerPadNames[x],
|
||||
powerpadsc[arg & 1][x].ButtonNum[0]);
|
||||
}
|
||||
|
||||
if (powerpadsc[arg & 1][0].ButtType[0] == BUTTC_KEYBOARD)
|
||||
{
|
||||
g_config->setOption (prefix + "DeviceType", "Keyboard");
|
||||
}
|
||||
else if (powerpadsc[arg & 1][0].ButtType[0] == BUTTC_JOYSTICK)
|
||||
{
|
||||
g_config->setOption (prefix + "DeviceType", "Joystick");
|
||||
}
|
||||
else
|
||||
{
|
||||
g_config->setOption (prefix + "DeviceType", "Unknown");
|
||||
}
|
||||
g_config->setOption (prefix + "DeviceNum",
|
||||
powerpadsc[arg & 1][0].DeviceNum[0]);
|
||||
break;
|
||||
|
||||
case FCFGD_GAMEPAD:
|
||||
snprintf (buf, 256, "SDL.Input.GamePad.%d", arg);
|
||||
prefix = buf;
|
||||
for (x = 0; x < 10; x++)
|
||||
{
|
||||
sprintf (buf, "GamePad #%d: %s", arg + 1, str[x]);
|
||||
ConfigButton (buf, &GamePadConfig[arg][x]);
|
||||
|
||||
g_config->setOption (prefix + GamePadNames[x],
|
||||
GamePadConfig[arg][x].ButtonNum[0]);
|
||||
}
|
||||
|
||||
if (GamePadConfig[arg][0].ButtType[0] == BUTTC_KEYBOARD)
|
||||
{
|
||||
g_config->setOption (prefix + "DeviceType", "Keyboard");
|
||||
}
|
||||
else if (GamePadConfig[arg][0].ButtType[0] == BUTTC_JOYSTICK)
|
||||
{
|
||||
g_config->setOption (prefix + "DeviceType", "Joystick");
|
||||
}
|
||||
else
|
||||
{
|
||||
g_config->setOption (prefix + "DeviceType", "Unknown");
|
||||
}
|
||||
g_config->setOption (prefix + "DeviceNum",
|
||||
GamePadConfig[arg][0].DeviceNum[0]);
|
||||
break;
|
||||
}
|
||||
|
||||
ButtonConfigEnd ();
|
||||
}
|
||||
//void ConfigDevice (int which, int arg)
|
||||
//{
|
||||
// char buf[256];
|
||||
// int x;
|
||||
// std::string prefix;
|
||||
// const char *str[10] =
|
||||
// { "A", "B", "SELECT", "START", "UP", "DOWN", "LEFT", "RIGHT", "Rapid A",
|
||||
// "Rapid B"
|
||||
// };
|
||||
//
|
||||
// // XXX soules - set the configuration options so that later calls
|
||||
// // don't override these. This is a temp hack until I
|
||||
// // can clean up this file.
|
||||
//
|
||||
// ButtonConfigBegin ();
|
||||
// switch (which)
|
||||
// {
|
||||
// case FCFGD_QUIZKING:
|
||||
// prefix = "SDL.Input.QuizKing.";
|
||||
// for (x = 0; x < 6; x++)
|
||||
// {
|
||||
// sprintf (buf, "Quiz King Buzzer #%d", x + 1);
|
||||
// ConfigButton (buf, &QuizKingButtons[x]);
|
||||
//
|
||||
// g_config->setOption (prefix + QuizKingNames[x],
|
||||
// QuizKingButtons[x].ButtonNum);
|
||||
// }
|
||||
//
|
||||
// if (QuizKingButtons[0].ButtType == BUTTC_KEYBOARD)
|
||||
// {
|
||||
// g_config->setOption (prefix + "DeviceType", "Keyboard");
|
||||
// }
|
||||
// else if (QuizKingButtons[0].ButtType == BUTTC_JOYSTICK)
|
||||
// {
|
||||
// g_config->setOption (prefix + "DeviceType", "Joystick");
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// g_config->setOption (prefix + "DeviceType", "Unknown");
|
||||
// }
|
||||
// g_config->setOption (prefix + "DeviceNum",
|
||||
// QuizKingButtons[0].DeviceNum);
|
||||
// break;
|
||||
// case FCFGD_HYPERSHOT:
|
||||
// prefix = "SDL.Input.HyperShot.";
|
||||
// for (x = 0; x < 4; x++)
|
||||
// {
|
||||
// sprintf (buf, "Hyper Shot %d: %s",
|
||||
// ((x & 2) >> 1) + 1, (x & 1) ? "JUMP" : "RUN");
|
||||
// ConfigButton (buf, &HyperShotButtons[x]);
|
||||
//
|
||||
// g_config->setOption (prefix + HyperShotNames[x],
|
||||
// HyperShotButtons[x].ButtonNum);
|
||||
// }
|
||||
//
|
||||
// if (HyperShotButtons[0].ButtType == BUTTC_KEYBOARD)
|
||||
// {
|
||||
// g_config->setOption (prefix + "DeviceType", "Keyboard");
|
||||
// }
|
||||
// else if (HyperShotButtons[0].ButtType == BUTTC_JOYSTICK)
|
||||
// {
|
||||
// g_config->setOption (prefix + "DeviceType", "Joystick");
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// g_config->setOption (prefix + "DeviceType", "Unknown");
|
||||
// }
|
||||
// g_config->setOption (prefix + "DeviceNum",
|
||||
// HyperShotButtons[0].DeviceNum);
|
||||
// break;
|
||||
// case FCFGD_POWERPAD:
|
||||
// snprintf (buf, 256, "SDL.Input.PowerPad.%d", (arg & 1));
|
||||
// prefix = buf;
|
||||
// for (x = 0; x < 12; x++)
|
||||
// {
|
||||
// sprintf (buf, "PowerPad %d: %d", (arg & 1) + 1, x + 11);
|
||||
// ConfigButton (buf, &powerpadsc[arg & 1][x]);
|
||||
//
|
||||
// g_config->setOption (prefix + PowerPadNames[x],
|
||||
// powerpadsc[arg & 1][x].ButtonNum);
|
||||
// }
|
||||
//
|
||||
// if (powerpadsc[arg & 1][0].ButtType == BUTTC_KEYBOARD)
|
||||
// {
|
||||
// g_config->setOption (prefix + "DeviceType", "Keyboard");
|
||||
// }
|
||||
// else if (powerpadsc[arg & 1][0].ButtType == BUTTC_JOYSTICK)
|
||||
// {
|
||||
// g_config->setOption (prefix + "DeviceType", "Joystick");
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// g_config->setOption (prefix + "DeviceType", "Unknown");
|
||||
// }
|
||||
// g_config->setOption (prefix + "DeviceNum",
|
||||
// powerpadsc[arg & 1][0].DeviceNum);
|
||||
// break;
|
||||
//
|
||||
// case FCFGD_GAMEPAD:
|
||||
// snprintf (buf, 256, "SDL.Input.GamePad.%d", arg);
|
||||
// prefix = buf;
|
||||
// for (x = 0; x < 10; x++)
|
||||
// {
|
||||
// sprintf (buf, "GamePad #%d: %s", arg + 1, str[x]);
|
||||
// ConfigButton (buf, &GamePadConfig[arg][x]);
|
||||
//
|
||||
// g_config->setOption (prefix + GamePadNames[x],
|
||||
// GamePadConfig[arg][x].ButtonNum);
|
||||
// }
|
||||
//
|
||||
// if (GamePadConfig[arg][0].ButtType == BUTTC_KEYBOARD)
|
||||
// {
|
||||
// g_config->setOption (prefix + "DeviceType", "Keyboard");
|
||||
// }
|
||||
// else if (GamePadConfig[arg][0].ButtType == BUTTC_JOYSTICK)
|
||||
// {
|
||||
// g_config->setOption (prefix + "DeviceType", "Joystick");
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// g_config->setOption (prefix + "DeviceType", "Unknown");
|
||||
// }
|
||||
// g_config->setOption (prefix + "DeviceNum",
|
||||
// GamePadConfig[arg][0].DeviceNum);
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// ButtonConfigEnd ();
|
||||
//}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -2071,10 +2066,9 @@ UpdateInput (Config * config)
|
|||
{
|
||||
config->getOption (prefix + GamePadNames[j], &button);
|
||||
|
||||
GamePadConfig[i][j].ButtType[0] = type;
|
||||
GamePadConfig[i][j].DeviceNum[0] = devnum;
|
||||
GamePadConfig[i][j].ButtonNum[0] = button;
|
||||
GamePadConfig[i][j].NumC = 1;
|
||||
GamePadConfig[i][j].ButtType = type;
|
||||
GamePadConfig[i][j].DeviceNum = devnum;
|
||||
GamePadConfig[i][j].ButtonNum = button;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2104,10 +2098,9 @@ UpdateInput (Config * config)
|
|||
{
|
||||
config->getOption (prefix + PowerPadNames[j], &button);
|
||||
|
||||
powerpadsc[i][j].ButtType[0] = type;
|
||||
powerpadsc[i][j].DeviceNum[0] = devnum;
|
||||
powerpadsc[i][j].ButtonNum[0] = button;
|
||||
powerpadsc[i][j].NumC = 1;
|
||||
powerpadsc[i][j].ButtType = type;
|
||||
powerpadsc[i][j].DeviceNum = devnum;
|
||||
powerpadsc[i][j].ButtonNum = button;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2131,10 +2124,9 @@ UpdateInput (Config * config)
|
|||
{
|
||||
config->getOption (prefix + QuizKingNames[j], &button);
|
||||
|
||||
QuizKingButtons[j].ButtType[0] = type;
|
||||
QuizKingButtons[j].DeviceNum[0] = devnum;
|
||||
QuizKingButtons[j].ButtonNum[0] = button;
|
||||
QuizKingButtons[j].NumC = 1;
|
||||
QuizKingButtons[j].ButtType = type;
|
||||
QuizKingButtons[j].DeviceNum = devnum;
|
||||
QuizKingButtons[j].ButtonNum = button;
|
||||
}
|
||||
|
||||
// HyperShot
|
||||
|
@ -2157,10 +2149,9 @@ UpdateInput (Config * config)
|
|||
{
|
||||
config->getOption (prefix + HyperShotNames[j], &button);
|
||||
|
||||
HyperShotButtons[j].ButtType[0] = type;
|
||||
HyperShotButtons[j].DeviceNum[0] = devnum;
|
||||
HyperShotButtons[j].ButtonNum[0] = button;
|
||||
HyperShotButtons[j].NumC = 1;
|
||||
HyperShotButtons[j].ButtType = type;
|
||||
HyperShotButtons[j].DeviceNum = devnum;
|
||||
HyperShotButtons[j].ButtonNum = button;
|
||||
}
|
||||
|
||||
// Mahjong
|
||||
|
@ -2183,10 +2174,9 @@ UpdateInput (Config * config)
|
|||
{
|
||||
config->getOption (prefix + MahjongNames[j], &button);
|
||||
|
||||
MahjongButtons[j].ButtType[0] = type;
|
||||
MahjongButtons[j].DeviceNum[0] = devnum;
|
||||
MahjongButtons[j].ButtonNum[0] = button;
|
||||
MahjongButtons[j].NumC = 1;
|
||||
MahjongButtons[j].ButtType = type;
|
||||
MahjongButtons[j].DeviceNum = devnum;
|
||||
MahjongButtons[j].ButtonNum = button;
|
||||
}
|
||||
|
||||
// TopRider
|
||||
|
@ -2209,10 +2199,9 @@ UpdateInput (Config * config)
|
|||
{
|
||||
config->getOption (prefix + TopRiderNames[j], &button);
|
||||
|
||||
TopRiderButtons[j].ButtType[0] = type;
|
||||
TopRiderButtons[j].DeviceNum[0] = devnum;
|
||||
TopRiderButtons[j].ButtonNum[0] = button;
|
||||
TopRiderButtons[j].NumC = 1;
|
||||
TopRiderButtons[j].ButtType = type;
|
||||
TopRiderButtons[j].DeviceNum = devnum;
|
||||
TopRiderButtons[j].ButtonNum = button;
|
||||
}
|
||||
|
||||
// FTrainer
|
||||
|
@ -2235,10 +2224,9 @@ UpdateInput (Config * config)
|
|||
{
|
||||
config->getOption (prefix + FTrainerNames[j], &button);
|
||||
|
||||
FTrainerButtons[j].ButtType[0] = type;
|
||||
FTrainerButtons[j].DeviceNum[0] = devnum;
|
||||
FTrainerButtons[j].ButtonNum[0] = button;
|
||||
FTrainerButtons[j].NumC = 1;
|
||||
FTrainerButtons[j].ButtType = type;
|
||||
FTrainerButtons[j].DeviceNum = devnum;
|
||||
FTrainerButtons[j].ButtonNum = button;
|
||||
}
|
||||
|
||||
// FamilyKeyBoard
|
||||
|
@ -2261,10 +2249,9 @@ UpdateInput (Config * config)
|
|||
{
|
||||
config->getOption (prefix + FamilyKeyBoardNames[j], &button);
|
||||
|
||||
fkbmap[j].ButtType[0] = type;
|
||||
fkbmap[j].DeviceNum[0] = devnum;
|
||||
fkbmap[j].ButtonNum[0] = button;
|
||||
fkbmap[j].NumC = 1;
|
||||
fkbmap[j].ButtType = type;
|
||||
fkbmap[j].DeviceNum = devnum;
|
||||
fkbmap[j].ButtonNum = button;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
#include "common/configSys.h"
|
||||
|
||||
#define MAXBUTTCONFIG 4
|
||||
//#define MAXBUTTCONFIG 4
|
||||
|
||||
enum {
|
||||
BUTTC_KEYBOARD = 0,
|
||||
|
@ -14,10 +14,10 @@ enum {
|
|||
};
|
||||
struct ButtConfig
|
||||
{
|
||||
int ButtType[MAXBUTTCONFIG];
|
||||
int DeviceNum[MAXBUTTCONFIG];
|
||||
int ButtonNum[MAXBUTTCONFIG];
|
||||
uint32_t NumC;
|
||||
int ButtType; //[MAXBUTTCONFIG];
|
||||
int DeviceNum; //[MAXBUTTCONFIG];
|
||||
int ButtonNum; //[MAXBUTTCONFIG];
|
||||
//uint32_t NumC;
|
||||
//uint64 DeviceID[MAXBUTTCONFIG]; /* TODO */
|
||||
};
|
||||
|
||||
|
@ -32,7 +32,7 @@ int getKeyState( int k );
|
|||
int ButtonConfigBegin();
|
||||
void ButtonConfigEnd();
|
||||
void ConfigButton(char *text, ButtConfig *bc);
|
||||
int DWaitButton(const uint8_t *text, ButtConfig *bc, int wb, int *buttonConfigStatus = NULL);
|
||||
int DWaitButton(const uint8_t *text, ButtConfig *bc, int *buttonConfigStatus = NULL);
|
||||
|
||||
|
||||
#define FCFGD_GAMEPAD 1
|
||||
|
@ -62,6 +62,6 @@ void UpdateInput(Config *config);
|
|||
void InputCfg(const std::string &);
|
||||
|
||||
std::string GetUserText(const char* title);
|
||||
const char* ButtonName(const ButtConfig* bc, int which);
|
||||
const char* ButtonName(const ButtConfig* bc);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -120,41 +120,40 @@ static int s_jinited = 0;
|
|||
int
|
||||
DTestButtonJoy(ButtConfig *bc)
|
||||
{
|
||||
int x;
|
||||
SDL_Joystick *js;
|
||||
|
||||
for(x = 0; x < bc->NumC; x++)
|
||||
if (bc->ButtonNum == -1)
|
||||
{
|
||||
if (bc->ButtonNum[x] == -1)
|
||||
{
|
||||
continue;
|
||||
return 0;
|
||||
}
|
||||
js = jsDev[bc->DeviceNum[x]].getJS();
|
||||
js = jsDev[bc->DeviceNum].getJS();
|
||||
|
||||
if (bc->ButtonNum[x] & 0x2000)
|
||||
if (bc->ButtonNum & 0x2000)
|
||||
{
|
||||
/* Hat "button" */
|
||||
if(SDL_JoystickGetHat( js,
|
||||
((bc->ButtonNum[x] >> 8) & 0x1F)) &
|
||||
(bc->ButtonNum[x]&0xFF))
|
||||
((bc->ButtonNum >> 8) & 0x1F)) &
|
||||
(bc->ButtonNum&0xFF))
|
||||
return 1;
|
||||
}
|
||||
else if (bc->ButtonNum[x] & 0x8000)
|
||||
else if (bc->ButtonNum & 0x8000)
|
||||
{
|
||||
/* Axis "button" */
|
||||
int pos;
|
||||
pos = SDL_JoystickGetAxis( js,
|
||||
bc->ButtonNum[x] & 16383);
|
||||
if ((bc->ButtonNum[x] & 0x4000) && pos <= -16383) {
|
||||
bc->ButtonNum & 16383);
|
||||
if ((bc->ButtonNum & 0x4000) && pos <= -16383) {
|
||||
return 1;
|
||||
} else if (!(bc->ButtonNum[x] & 0x4000) && pos >= 16363) {
|
||||
} else if (!(bc->ButtonNum & 0x4000) && pos >= 16363) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if(SDL_JoystickGetButton( js,
|
||||
bc->ButtonNum[x]))
|
||||
bc->ButtonNum))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue