Removed unused button config arrays in preparation for implementing SDL2 game controller setup.

This commit is contained in:
Matthew Budd 2020-07-23 18:43:45 -04:00
parent 10b84fa47c
commit e018b4b945
4 changed files with 261 additions and 277 deletions

View File

@ -24,7 +24,6 @@ GamePadConfDialog_t::GamePadConfDialog_t(QWidget *parent)
InitJoysticks(); InitJoysticks();
portNum = 0; portNum = 0;
configNo = 0;
buttonConfigStatus = 1; buttonConfigStatus = 1;
setWindowTitle( tr("GamePad Config") ); setWindowTitle( tr("GamePad Config") );
@ -157,14 +156,14 @@ void GamePadConfDialog_t::updateCntrlrDpy(void)
for (int i=0; i<GAMEPAD_NUM_BUTTONS; i++) 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", snprintf( keyNameStr, sizeof (keyNameStr), "%s",
SDL_GetKeyName (GamePadConfig[portNum][i].ButtonNum[configNo])); SDL_GetKeyName (GamePadConfig[portNum][i].ButtonNum));
} }
else else
{ {
strcpy( keyNameStr, ButtonName( &GamePadConfig[portNum][i], configNo ) ); strcpy( keyNameStr, ButtonName( &GamePadConfig[portNum][i] ) );
} }
keyName[i]->setText( tr(keyNameStr) ); 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); snprintf (buf, sizeof(buf)-1, "SDL.Input.GamePad.%d.", padNo);
prefix = buf; prefix = buf;
DWaitButton (NULL, &GamePadConfig[padNo][x], configNo, &buttonConfigStatus ); DWaitButton (NULL, &GamePadConfig[padNo][x], &buttonConfigStatus );
g_config->setOption (prefix + GamePadNames[x], 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"); 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"); 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 + "DeviceType", "Unknown");
} }
g_config->setOption (prefix + "DeviceNum", 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 ); keyName[x]->setText( keyNameStr );
button[x]->setText("Change"); button[x]->setText("Change");
@ -245,7 +244,7 @@ void GamePadConfDialog_t::clearButton( int padNo, int x )
char buf[256]; char buf[256];
std::string prefix; std::string prefix;
GamePadConfig[padNo][x].ButtonNum[configNo] = -1; GamePadConfig[padNo][x].ButtonNum = -1;
keyName[x]->setText(""); keyName[x]->setText("");
@ -253,7 +252,7 @@ void GamePadConfDialog_t::clearButton( int padNo, int x )
prefix = buf; prefix = buf;
g_config->setOption (prefix + GamePadNames[x], 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++) for (int x=0; x<GAMEPAD_NUM_BUTTONS; x++)
{ {
GamePadConfig[portNum][x].ButtType[configNo] = BUTTC_KEYBOARD; GamePadConfig[portNum][x].ButtType = BUTTC_KEYBOARD;
GamePadConfig[portNum][x].DeviceNum[configNo] = 0; GamePadConfig[portNum][x].DeviceNum = 0;
GamePadConfig[portNum][x].ButtonNum[configNo] = DefaultGamePad[portNum][x]; GamePadConfig[portNum][x].ButtonNum = DefaultGamePad[portNum][x];
GamePadConfig[portNum][x].NumC = 1;
g_config->setOption (prefix + GamePadNames[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"); 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"); 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 + "DeviceType", "Unknown");
} }
g_config->setOption (prefix + "DeviceNum", g_config->setOption (prefix + "DeviceNum",
GamePadConfig[portNum][x].DeviceNum[configNo]); GamePadConfig[portNum][x].DeviceNum);
} }
updateCntrlrDpy(); updateCntrlrDpy();
} }

View File

@ -1002,32 +1002,28 @@ ButtonConfigEnd ()
static int static int
DTestButton (ButtConfig * bc) 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)])
{ {
if (g_keyState[SDL_GetScancodeFromKey (bc->ButtonNum[x])]) return 1;
{
return 1;
}
} }
else if (bc->ButtType[x] == BUTTC_JOYSTICK) }
else if (bc->ButtType == BUTTC_JOYSTICK)
{
if (DTestButtonJoy (bc))
{ {
if (DTestButtonJoy (bc)) return 1;
{
return 1;
}
} }
} }
return 0; return 0;
} }
#define MK(x) {{BUTTC_KEYBOARD},{0},{MKK(x)},1} #define MK(x) {BUTTC_KEYBOARD,0,MKK(x)}
#define MK2(x1,x2) {{BUTTC_KEYBOARD},{0},{MKK(x1),MKK(x2)},2} //#define MK2(x1,x2) {BUTTC_KEYBOARD,0,MKK(x1)}
#define MKZ() {{0},{0},{-1},0} #define MKZ() {0,0,-1}
#define GPZ() {MKZ(), MKZ(), MKZ(), MKZ()} #define GPZ() {MKZ(), MKZ(), MKZ(), MKZ()}
ButtConfig GamePadConfig[ GAMEPAD_NUM_DEVICES ][ GAMEPAD_NUM_BUTTONS ] = ButtConfig GamePadConfig[ GAMEPAD_NUM_DEVICES ][ GAMEPAD_NUM_BUTTONS ] =
@ -1549,42 +1545,42 @@ UpdateFTrainer ()
* @param bc the NES gamepad's button config * @param bc the NES gamepad's button config
* @param which the index of the button * @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]; static char name[256];
name[0] = 0; name[0] = 0;
if (bc->ButtonNum[which] == -1) if (bc->ButtonNum == -1)
{ {
return name; return name;
} }
switch (bc->ButtType[which]) switch (bc->ButtType)
{ {
case BUTTC_KEYBOARD: case BUTTC_KEYBOARD:
return SDL_GetKeyName (bc->ButtonNum[which]); return SDL_GetKeyName (bc->ButtonNum);
break; break;
case BUTTC_JOYSTICK: case BUTTC_JOYSTICK:
{ {
int joyNum, inputNum; int joyNum, inputNum;
const char *inputType, *inputDirection; const char *inputType, *inputDirection;
joyNum = bc->DeviceNum[which]; joyNum = bc->DeviceNum;
if (bc->ButtonNum[which] & 0x8000) if (bc->ButtonNum & 0x8000)
{ {
inputType = "Axis"; inputType = "Axis";
inputNum = bc->ButtonNum[which] & 0x3FFF; inputNum = bc->ButtonNum & 0x3FFF;
inputDirection = bc->ButtonNum[which] & 0x4000 ? "-" : "+"; inputDirection = bc->ButtonNum & 0x4000 ? "-" : "+";
} }
else if (bc->ButtonNum[which] & 0x2000) else if (bc->ButtonNum & 0x2000)
{ {
int inputValue; int inputValue;
char direction[128] = ""; char direction[128] = "";
inputType = "Hat"; inputType = "Hat";
inputNum = (bc->ButtonNum[which] >> 8) & 0x1F; inputNum = (bc->ButtonNum >> 8) & 0x1F;
inputValue = bc->ButtonNum[which] & 0xF; inputValue = bc->ButtonNum & 0xF;
if (inputValue & SDL_HAT_UP) if (inputValue & SDL_HAT_UP)
strncat (direction, "Up ", sizeof (direction)-1); strncat (direction, "Up ", sizeof (direction)-1);
@ -1603,7 +1599,7 @@ const char * ButtonName (const ButtConfig * bc, int which)
else else
{ {
inputType = "Button"; inputType = "Button";
inputNum = bc->ButtonNum[which]; inputNum = bc->ButtonNum;
inputDirection = ""; inputDirection = "";
} }
sprintf( name, "js%i:%s%i%s", joyNum, inputType, inputNum, 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 * Waits for a button input and returns the information as to which
* button was pressed. Used in button configuration. * 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; SDL_Event event;
static int32 LastAx[64][64]; static int32 LastAx[64][64];
@ -1670,23 +1666,23 @@ int DWaitButton (const uint8_t * text, ButtConfig * bc, int wb, int *buttonConfi
{ {
case SDL_KEYDOWN: case SDL_KEYDOWN:
//printf("SDL KeyDown:%i \n", event.key.keysym.sym ); //printf("SDL KeyDown:%i \n", event.key.keysym.sym );
bc->ButtType[wb] = BUTTC_KEYBOARD; bc->ButtType = BUTTC_KEYBOARD;
bc->DeviceNum[wb] = 0; bc->DeviceNum = 0;
bc->ButtonNum[wb] = event.key.keysym.sym; bc->ButtonNum = event.key.keysym.sym;
return (1); return (1);
case SDL_JOYBUTTONDOWN: case SDL_JOYBUTTONDOWN:
bc->ButtType[wb] = BUTTC_JOYSTICK; bc->ButtType = BUTTC_JOYSTICK;
bc->DeviceNum[wb] = event.jbutton.which; bc->DeviceNum = event.jbutton.which;
bc->ButtonNum[wb] = event.jbutton.button; bc->ButtonNum = event.jbutton.button;
return (1); return (1);
case SDL_JOYHATMOTION: case SDL_JOYHATMOTION:
if (event.jhat.value == SDL_HAT_CENTERED) if (event.jhat.value == SDL_HAT_CENTERED)
done--; done--;
else else
{ {
bc->ButtType[wb] = BUTTC_JOYSTICK; bc->ButtType = BUTTC_JOYSTICK;
bc->DeviceNum[wb] = event.jhat.which; bc->DeviceNum = event.jhat.which;
bc->ButtonNum[wb] = bc->ButtonNum =
(0x2000 | ((event.jhat.hat & 0x1F) << 8) | event. (0x2000 | ((event.jhat.hat & 0x1F) << 8) | event.
jhat.value); jhat.value);
return (1); 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] - (LastAx[event.jaxis.which][event.jaxis.axis] -
event.jaxis.value) >= 8192) event.jaxis.value) >= 8192)
{ {
bc->ButtType[wb] = BUTTC_JOYSTICK; bc->ButtType = BUTTC_JOYSTICK;
bc->DeviceNum[wb] = event.jaxis.which; bc->DeviceNum = event.jaxis.which;
bc->ButtonNum[wb] = (0x8000 | event.jaxis.axis | bc->ButtonNum = (0x8000 | event.jaxis.axis |
((event.jaxis.value < 0) ((event.jaxis.value < 0)
? 0x4000 : 0)); ? 0x4000 : 0));
return (1); 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 * used as input for the specified button, thus allowing up to four
* possible settings for each input button. * possible settings for each input button.
*/ */
void // void
ConfigButton (char *text, ButtConfig * bc) //ConfigButton (char *text, ButtConfig * bc)
{ //{
uint8 buf[256]; // uint8 buf[256];
int wc; // int wc;
//
for (wc = 0; wc < MAXBUTTCONFIG; wc++) // for (wc = 0; wc < MAXBUTTCONFIG; wc++)
{ // {
sprintf ((char *) buf, "%s (%d)", text, wc + 1); // sprintf ((char *) buf, "%s (%d)", text, wc + 1);
DWaitButton (buf, bc, wc, NULL); // DWaitButton (buf, bc, wc, NULL);
//
if (wc && // if (wc &&
bc->ButtType[wc] == bc->ButtType[wc - 1] && // bc->ButtType[wc] == bc->ButtType[wc - 1] &&
bc->DeviceNum[wc] == bc->DeviceNum[wc - 1] && // bc->DeviceNum[wc] == bc->DeviceNum[wc - 1] &&
bc->ButtonNum[wc] == bc->ButtonNum[wc - 1]) // bc->ButtonNum[wc] == bc->ButtonNum[wc - 1])
{ // {
break; // break;
} // }
} // }
bc->NumC = wc; //}
}
/** /**
* Update the button configuration for a specified device. * Update the button configuration for a specified device.
*/ */
extern Config *g_config; extern Config *g_config;
void ConfigDevice (int which, int arg) //void ConfigDevice (int which, int arg)
{ //{
char buf[256]; // char buf[256];
int x; // int x;
std::string prefix; // std::string prefix;
const char *str[10] = // const char *str[10] =
{ "A", "B", "SELECT", "START", "UP", "DOWN", "LEFT", "RIGHT", "Rapid A", // { "A", "B", "SELECT", "START", "UP", "DOWN", "LEFT", "RIGHT", "Rapid A",
"Rapid B" // "Rapid B"
}; // };
//
// XXX soules - set the configuration options so that later calls // // XXX soules - set the configuration options so that later calls
// don't override these. This is a temp hack until I // // don't override these. This is a temp hack until I
// can clean up this file. // // can clean up this file.
//
ButtonConfigBegin (); // ButtonConfigBegin ();
switch (which) // switch (which)
{ // {
case FCFGD_QUIZKING: // case FCFGD_QUIZKING:
prefix = "SDL.Input.QuizKing."; // prefix = "SDL.Input.QuizKing.";
for (x = 0; x < 6; x++) // for (x = 0; x < 6; x++)
{ // {
sprintf (buf, "Quiz King Buzzer #%d", x + 1); // sprintf (buf, "Quiz King Buzzer #%d", x + 1);
ConfigButton (buf, &QuizKingButtons[x]); // ConfigButton (buf, &QuizKingButtons[x]);
//
g_config->setOption (prefix + QuizKingNames[x], // g_config->setOption (prefix + QuizKingNames[x],
QuizKingButtons[x].ButtonNum[0]); // QuizKingButtons[x].ButtonNum);
} // }
//
if (QuizKingButtons[0].ButtType[0] == BUTTC_KEYBOARD) // if (QuizKingButtons[0].ButtType == BUTTC_KEYBOARD)
{ // {
g_config->setOption (prefix + "DeviceType", "Keyboard"); // g_config->setOption (prefix + "DeviceType", "Keyboard");
} // }
else if (QuizKingButtons[0].ButtType[0] == BUTTC_JOYSTICK) // else if (QuizKingButtons[0].ButtType == BUTTC_JOYSTICK)
{ // {
g_config->setOption (prefix + "DeviceType", "Joystick"); // g_config->setOption (prefix + "DeviceType", "Joystick");
} // }
else // else
{ // {
g_config->setOption (prefix + "DeviceType", "Unknown"); // g_config->setOption (prefix + "DeviceType", "Unknown");
} // }
g_config->setOption (prefix + "DeviceNum", // g_config->setOption (prefix + "DeviceNum",
QuizKingButtons[0].DeviceNum[0]); // QuizKingButtons[0].DeviceNum);
break; // break;
case FCFGD_HYPERSHOT: // case FCFGD_HYPERSHOT:
prefix = "SDL.Input.HyperShot."; // prefix = "SDL.Input.HyperShot.";
for (x = 0; x < 4; x++) // for (x = 0; x < 4; x++)
{ // {
sprintf (buf, "Hyper Shot %d: %s", // sprintf (buf, "Hyper Shot %d: %s",
((x & 2) >> 1) + 1, (x & 1) ? "JUMP" : "RUN"); // ((x & 2) >> 1) + 1, (x & 1) ? "JUMP" : "RUN");
ConfigButton (buf, &HyperShotButtons[x]); // ConfigButton (buf, &HyperShotButtons[x]);
//
g_config->setOption (prefix + HyperShotNames[x], // g_config->setOption (prefix + HyperShotNames[x],
HyperShotButtons[x].ButtonNum[0]); // HyperShotButtons[x].ButtonNum);
} // }
//
if (HyperShotButtons[0].ButtType[0] == BUTTC_KEYBOARD) // if (HyperShotButtons[0].ButtType == BUTTC_KEYBOARD)
{ // {
g_config->setOption (prefix + "DeviceType", "Keyboard"); // g_config->setOption (prefix + "DeviceType", "Keyboard");
} // }
else if (HyperShotButtons[0].ButtType[0] == BUTTC_JOYSTICK) // else if (HyperShotButtons[0].ButtType == BUTTC_JOYSTICK)
{ // {
g_config->setOption (prefix + "DeviceType", "Joystick"); // g_config->setOption (prefix + "DeviceType", "Joystick");
} // }
else // else
{ // {
g_config->setOption (prefix + "DeviceType", "Unknown"); // g_config->setOption (prefix + "DeviceType", "Unknown");
} // }
g_config->setOption (prefix + "DeviceNum", // g_config->setOption (prefix + "DeviceNum",
HyperShotButtons[0].DeviceNum[0]); // HyperShotButtons[0].DeviceNum);
break; // break;
case FCFGD_POWERPAD: // case FCFGD_POWERPAD:
snprintf (buf, 256, "SDL.Input.PowerPad.%d", (arg & 1)); // snprintf (buf, 256, "SDL.Input.PowerPad.%d", (arg & 1));
prefix = buf; // prefix = buf;
for (x = 0; x < 12; x++) // for (x = 0; x < 12; x++)
{ // {
sprintf (buf, "PowerPad %d: %d", (arg & 1) + 1, x + 11); // sprintf (buf, "PowerPad %d: %d", (arg & 1) + 1, x + 11);
ConfigButton (buf, &powerpadsc[arg & 1][x]); // ConfigButton (buf, &powerpadsc[arg & 1][x]);
//
g_config->setOption (prefix + PowerPadNames[x], // g_config->setOption (prefix + PowerPadNames[x],
powerpadsc[arg & 1][x].ButtonNum[0]); // powerpadsc[arg & 1][x].ButtonNum);
} // }
//
if (powerpadsc[arg & 1][0].ButtType[0] == BUTTC_KEYBOARD) // if (powerpadsc[arg & 1][0].ButtType == BUTTC_KEYBOARD)
{ // {
g_config->setOption (prefix + "DeviceType", "Keyboard"); // g_config->setOption (prefix + "DeviceType", "Keyboard");
} // }
else if (powerpadsc[arg & 1][0].ButtType[0] == BUTTC_JOYSTICK) // else if (powerpadsc[arg & 1][0].ButtType == BUTTC_JOYSTICK)
{ // {
g_config->setOption (prefix + "DeviceType", "Joystick"); // g_config->setOption (prefix + "DeviceType", "Joystick");
} // }
else // else
{ // {
g_config->setOption (prefix + "DeviceType", "Unknown"); // g_config->setOption (prefix + "DeviceType", "Unknown");
} // }
g_config->setOption (prefix + "DeviceNum", // g_config->setOption (prefix + "DeviceNum",
powerpadsc[arg & 1][0].DeviceNum[0]); // powerpadsc[arg & 1][0].DeviceNum);
break; // break;
//
case FCFGD_GAMEPAD: // case FCFGD_GAMEPAD:
snprintf (buf, 256, "SDL.Input.GamePad.%d", arg); // snprintf (buf, 256, "SDL.Input.GamePad.%d", arg);
prefix = buf; // prefix = buf;
for (x = 0; x < 10; x++) // for (x = 0; x < 10; x++)
{ // {
sprintf (buf, "GamePad #%d: %s", arg + 1, str[x]); // sprintf (buf, "GamePad #%d: %s", arg + 1, str[x]);
ConfigButton (buf, &GamePadConfig[arg][x]); // ConfigButton (buf, &GamePadConfig[arg][x]);
//
g_config->setOption (prefix + GamePadNames[x], // g_config->setOption (prefix + GamePadNames[x],
GamePadConfig[arg][x].ButtonNum[0]); // GamePadConfig[arg][x].ButtonNum);
} // }
//
if (GamePadConfig[arg][0].ButtType[0] == BUTTC_KEYBOARD) // if (GamePadConfig[arg][0].ButtType == BUTTC_KEYBOARD)
{ // {
g_config->setOption (prefix + "DeviceType", "Keyboard"); // g_config->setOption (prefix + "DeviceType", "Keyboard");
} // }
else if (GamePadConfig[arg][0].ButtType[0] == BUTTC_JOYSTICK) // else if (GamePadConfig[arg][0].ButtType == BUTTC_JOYSTICK)
{ // {
g_config->setOption (prefix + "DeviceType", "Joystick"); // g_config->setOption (prefix + "DeviceType", "Joystick");
} // }
else // else
{ // {
g_config->setOption (prefix + "DeviceType", "Unknown"); // g_config->setOption (prefix + "DeviceType", "Unknown");
} // }
g_config->setOption (prefix + "DeviceNum", // g_config->setOption (prefix + "DeviceNum",
GamePadConfig[arg][0].DeviceNum[0]); // GamePadConfig[arg][0].DeviceNum);
break; // break;
} // }
//
ButtonConfigEnd (); // ButtonConfigEnd ();
} //}
/** /**
@ -2071,10 +2066,9 @@ UpdateInput (Config * config)
{ {
config->getOption (prefix + GamePadNames[j], &button); config->getOption (prefix + GamePadNames[j], &button);
GamePadConfig[i][j].ButtType[0] = type; GamePadConfig[i][j].ButtType = type;
GamePadConfig[i][j].DeviceNum[0] = devnum; GamePadConfig[i][j].DeviceNum = devnum;
GamePadConfig[i][j].ButtonNum[0] = button; GamePadConfig[i][j].ButtonNum = button;
GamePadConfig[i][j].NumC = 1;
} }
} }
@ -2104,10 +2098,9 @@ UpdateInput (Config * config)
{ {
config->getOption (prefix + PowerPadNames[j], &button); config->getOption (prefix + PowerPadNames[j], &button);
powerpadsc[i][j].ButtType[0] = type; powerpadsc[i][j].ButtType = type;
powerpadsc[i][j].DeviceNum[0] = devnum; powerpadsc[i][j].DeviceNum = devnum;
powerpadsc[i][j].ButtonNum[0] = button; powerpadsc[i][j].ButtonNum = button;
powerpadsc[i][j].NumC = 1;
} }
} }
@ -2131,10 +2124,9 @@ UpdateInput (Config * config)
{ {
config->getOption (prefix + QuizKingNames[j], &button); config->getOption (prefix + QuizKingNames[j], &button);
QuizKingButtons[j].ButtType[0] = type; QuizKingButtons[j].ButtType = type;
QuizKingButtons[j].DeviceNum[0] = devnum; QuizKingButtons[j].DeviceNum = devnum;
QuizKingButtons[j].ButtonNum[0] = button; QuizKingButtons[j].ButtonNum = button;
QuizKingButtons[j].NumC = 1;
} }
// HyperShot // HyperShot
@ -2157,10 +2149,9 @@ UpdateInput (Config * config)
{ {
config->getOption (prefix + HyperShotNames[j], &button); config->getOption (prefix + HyperShotNames[j], &button);
HyperShotButtons[j].ButtType[0] = type; HyperShotButtons[j].ButtType = type;
HyperShotButtons[j].DeviceNum[0] = devnum; HyperShotButtons[j].DeviceNum = devnum;
HyperShotButtons[j].ButtonNum[0] = button; HyperShotButtons[j].ButtonNum = button;
HyperShotButtons[j].NumC = 1;
} }
// Mahjong // Mahjong
@ -2183,10 +2174,9 @@ UpdateInput (Config * config)
{ {
config->getOption (prefix + MahjongNames[j], &button); config->getOption (prefix + MahjongNames[j], &button);
MahjongButtons[j].ButtType[0] = type; MahjongButtons[j].ButtType = type;
MahjongButtons[j].DeviceNum[0] = devnum; MahjongButtons[j].DeviceNum = devnum;
MahjongButtons[j].ButtonNum[0] = button; MahjongButtons[j].ButtonNum = button;
MahjongButtons[j].NumC = 1;
} }
// TopRider // TopRider
@ -2209,10 +2199,9 @@ UpdateInput (Config * config)
{ {
config->getOption (prefix + TopRiderNames[j], &button); config->getOption (prefix + TopRiderNames[j], &button);
TopRiderButtons[j].ButtType[0] = type; TopRiderButtons[j].ButtType = type;
TopRiderButtons[j].DeviceNum[0] = devnum; TopRiderButtons[j].DeviceNum = devnum;
TopRiderButtons[j].ButtonNum[0] = button; TopRiderButtons[j].ButtonNum = button;
TopRiderButtons[j].NumC = 1;
} }
// FTrainer // FTrainer
@ -2235,10 +2224,9 @@ UpdateInput (Config * config)
{ {
config->getOption (prefix + FTrainerNames[j], &button); config->getOption (prefix + FTrainerNames[j], &button);
FTrainerButtons[j].ButtType[0] = type; FTrainerButtons[j].ButtType = type;
FTrainerButtons[j].DeviceNum[0] = devnum; FTrainerButtons[j].DeviceNum = devnum;
FTrainerButtons[j].ButtonNum[0] = button; FTrainerButtons[j].ButtonNum = button;
FTrainerButtons[j].NumC = 1;
} }
// FamilyKeyBoard // FamilyKeyBoard
@ -2261,10 +2249,9 @@ UpdateInput (Config * config)
{ {
config->getOption (prefix + FamilyKeyBoardNames[j], &button); config->getOption (prefix + FamilyKeyBoardNames[j], &button);
fkbmap[j].ButtType[0] = type; fkbmap[j].ButtType = type;
fkbmap[j].DeviceNum[0] = devnum; fkbmap[j].DeviceNum = devnum;
fkbmap[j].ButtonNum[0] = button; fkbmap[j].ButtonNum = button;
fkbmap[j].NumC = 1;
} }
} }

View File

@ -5,7 +5,7 @@
#include "common/configSys.h" #include "common/configSys.h"
#define MAXBUTTCONFIG 4 //#define MAXBUTTCONFIG 4
enum { enum {
BUTTC_KEYBOARD = 0, BUTTC_KEYBOARD = 0,
@ -14,10 +14,10 @@ enum {
}; };
struct ButtConfig struct ButtConfig
{ {
int ButtType[MAXBUTTCONFIG]; int ButtType; //[MAXBUTTCONFIG];
int DeviceNum[MAXBUTTCONFIG]; int DeviceNum; //[MAXBUTTCONFIG];
int ButtonNum[MAXBUTTCONFIG]; int ButtonNum; //[MAXBUTTCONFIG];
uint32_t NumC; //uint32_t NumC;
//uint64 DeviceID[MAXBUTTCONFIG]; /* TODO */ //uint64 DeviceID[MAXBUTTCONFIG]; /* TODO */
}; };
@ -32,7 +32,7 @@ int getKeyState( int k );
int ButtonConfigBegin(); int ButtonConfigBegin();
void ButtonConfigEnd(); void ButtonConfigEnd();
void ConfigButton(char *text, ButtConfig *bc); 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 #define FCFGD_GAMEPAD 1
@ -62,6 +62,6 @@ void UpdateInput(Config *config);
void InputCfg(const std::string &); void InputCfg(const std::string &);
std::string GetUserText(const char* title); std::string GetUserText(const char* title);
const char* ButtonName(const ButtConfig* bc, int which); const char* ButtonName(const ButtConfig* bc);
#endif #endif

View File

@ -120,41 +120,40 @@ static int s_jinited = 0;
int int
DTestButtonJoy(ButtConfig *bc) DTestButtonJoy(ButtConfig *bc)
{ {
int x;
SDL_Joystick *js; SDL_Joystick *js;
for(x = 0; x < bc->NumC; x++) if (bc->ButtonNum == -1)
{ {
if (bc->ButtonNum[x] == -1) return 0;
{ }
continue; js = jsDev[bc->DeviceNum].getJS();
}
js = jsDev[bc->DeviceNum[x]].getJS();
if (bc->ButtonNum[x] & 0x2000) if (bc->ButtonNum & 0x2000)
{ {
/* Hat "button" */ /* Hat "button" */
if(SDL_JoystickGetHat( js, if(SDL_JoystickGetHat( js,
((bc->ButtonNum[x] >> 8) & 0x1F)) & ((bc->ButtonNum >> 8) & 0x1F)) &
(bc->ButtonNum[x]&0xFF)) (bc->ButtonNum&0xFF))
return 1; return 1;
}
else if (bc->ButtonNum & 0x8000)
{
/* Axis "button" */
int pos;
pos = SDL_JoystickGetAxis( js,
bc->ButtonNum & 16383);
if ((bc->ButtonNum & 0x4000) && pos <= -16383) {
return 1;
} else if (!(bc->ButtonNum & 0x4000) && pos >= 16363) {
return 1;
} }
else if (bc->ButtonNum[x] & 0x8000) }
{ else if(SDL_JoystickGetButton( js,
/* Axis "button" */ bc->ButtonNum))
int pos; {
pos = SDL_JoystickGetAxis( js,
bc->ButtonNum[x] & 16383);
if ((bc->ButtonNum[x] & 0x4000) && pos <= -16383) {
return 1;
} else if (!(bc->ButtonNum[x] & 0x4000) && pos >= 16363) {
return 1;
}
}
else if(SDL_JoystickGetButton( js,
bc->ButtonNum[x]))
return 1; return 1;
} }
return 0; return 0;
} }