- Added mappings for individual joysticks in Virtual On for dual-joystick gamepads.

- Input settings are now only read from "global" to avoid confusion.
This commit is contained in:
Bart Trzynadlowski 2011-08-26 05:06:34 +00:00
parent a2ce64745f
commit b19f600fec
5 changed files with 126 additions and 86 deletions

View file

@ -65,7 +65,7 @@ const char* CInput::GetInputGroup()
case GAME_INPUT_SHIFT4: return "Racing Game Gear Shift"; case GAME_INPUT_SHIFT4: return "Racing Game Gear Shift";
case GAME_INPUT_VR: return "Racing Game VR View Buttons"; case GAME_INPUT_VR: return "Racing Game VR View Buttons";
case GAME_INPUT_RALLY: return "Sega Rally Buttons"; case GAME_INPUT_RALLY: return "Sega Rally Buttons";
case GAME_INPUT_TWIN_JOYSTICKS: return "Virtua On Controls"; case GAME_INPUT_TWIN_JOYSTICKS: return "Virtual On Controls";
case GAME_INPUT_ANALOG_JOYSTICK: return "Analog Joystick"; case GAME_INPUT_ANALOG_JOYSTICK: return "Analog Joystick";
case GAME_INPUT_GUN1: // Fall through to below case GAME_INPUT_GUN1: // Fall through to below
case GAME_INPUT_GUN2: return "Lightguns"; case GAME_INPUT_GUN2: return "Lightguns";

View file

@ -89,19 +89,27 @@ CInputs::CInputs(CInputSystem *system) : m_system(system)
viewChange = AddSwitchInput("ViewChange", "View Change", GAME_INPUT_RALLY, "KEY_A,JOY1_BUTTON1"); viewChange = AddSwitchInput("ViewChange", "View Change", GAME_INPUT_RALLY, "KEY_A,JOY1_BUTTON1");
handBrake = AddSwitchInput("HandBrake", "Hand Brake", GAME_INPUT_RALLY, "KEY_S,JOY1_BUTTON2"); handBrake = AddSwitchInput("HandBrake", "Hand Brake", GAME_INPUT_RALLY, "KEY_S,JOY1_BUTTON2");
// Virtua On Controls // Virtual On Controls
twinJoyTurnLeft = AddSwitchInput("TwinJoyTurnLeft", "Turn Left", GAME_INPUT_TWIN_JOYSTICKS, "KEY_Q,JOY1_RXAXIS_NEG"); twinJoyTurnLeft = AddSwitchInput("TwinJoyTurnLeft", "Macro Turn Left", GAME_INPUT_TWIN_JOYSTICKS, "KEY_Q,JOY1_RXAXIS_NEG");
twinJoyTurnRight = AddSwitchInput("TwinJoyTurnRight", "Turn Right", GAME_INPUT_TWIN_JOYSTICKS, "KEY_W,JOY1_RXAXIS_POS"); twinJoyTurnRight = AddSwitchInput("TwinJoyTurnRight", "Macro Turn Right", GAME_INPUT_TWIN_JOYSTICKS, "KEY_W,JOY1_RXAXIS_POS");
twinJoyForward = AddSwitchInput("TwinJoyForward", "Forward", GAME_INPUT_TWIN_JOYSTICKS, "KEY_UP,JOY1_YAXIS_NEG"); twinJoyForward = AddSwitchInput("TwinJoyForward", "Macro Forward", GAME_INPUT_TWIN_JOYSTICKS, "KEY_UP,JOY1_YAXIS_NEG");
twinJoyReverse = AddSwitchInput("TwinJoyReverse", "Reverse", GAME_INPUT_TWIN_JOYSTICKS, "KEY_DOWN,JOY1_YAXIS_POS"); twinJoyReverse = AddSwitchInput("TwinJoyReverse", "Macro Reverse", GAME_INPUT_TWIN_JOYSTICKS, "KEY_DOWN,JOY1_YAXIS_POS");
twinJoyStrafeLeft = AddSwitchInput("TwinJoyStrafeLeft", "Strafe Left", GAME_INPUT_TWIN_JOYSTICKS, "KEY_LEFT,JOY1_XAXIS_NEG"); twinJoyStrafeLeft = AddSwitchInput("TwinJoyStrafeLeft", "Macro Strafe Left", GAME_INPUT_TWIN_JOYSTICKS, "KEY_LEFT,JOY1_XAXIS_NEG");
twinJoyStrafeRight = AddSwitchInput("TwinJoyStrafeRight", "Strafe Right", GAME_INPUT_TWIN_JOYSTICKS, "KEY_RIGHT,JOY1_XAXIS_POS"); twinJoyStrafeRight = AddSwitchInput("TwinJoyStrafeRight", "Macro Strafe Right", GAME_INPUT_TWIN_JOYSTICKS, "KEY_RIGHT,JOY1_XAXIS_POS");
twinJoyJump = AddSwitchInput("TwinJoyJump", "Jump", GAME_INPUT_TWIN_JOYSTICKS, "KEY_E,JOY1_BUTTON1"); twinJoyJump = AddSwitchInput("TwinJoyJump", "Macro Jump", GAME_INPUT_TWIN_JOYSTICKS, "KEY_E,JOY1_BUTTON1");
twinJoyCrouch = AddSwitchInput("TwinJoyCrouch", "Crouch", GAME_INPUT_TWIN_JOYSTICKS, "KEY_R,JOY1_BUTTON2"); twinJoyCrouch = AddSwitchInput("TwinJoyCrouch", "Macro Crouch", GAME_INPUT_TWIN_JOYSTICKS, "KEY_R,JOY1_BUTTON2");
twinJoyLeftShot = AddSwitchInput("TwinJoyLeftShot", "Left Shot Trigger", GAME_INPUT_TWIN_JOYSTICKS, "KEY_A,JOY1_BUTTON5"); twinJoyLeft1 = AddSwitchInput("TwinJoyLeft1", "Left Joystick Left", GAME_INPUT_TWIN_JOYSTICKS, "NONE");
twinJoyRightShot = AddSwitchInput("TwinJoyRightShot", "Right Shot Trigger", GAME_INPUT_TWIN_JOYSTICKS, "KEY_S,JOY1_BUTTON6"); twinJoyLeft2 = AddSwitchInput("TwinJoyLeft2", "Right Joystick Left", GAME_INPUT_TWIN_JOYSTICKS, "NONE");
twinJoyLeftTurbo = AddSwitchInput("TwinJoyLeftTurbo", "Left Turbo", GAME_INPUT_TWIN_JOYSTICKS, "KEY_Z,JOY1_BUTTON7"); twinJoyRight1 = AddSwitchInput("TwinJoyRight1", "Left Joystick Right", GAME_INPUT_TWIN_JOYSTICKS, "NONE");
twinJoyRightTurbo = AddSwitchInput("TwinJoyRightTurbo", "Right Turbo", GAME_INPUT_TWIN_JOYSTICKS, "KEY_X,JOY1_BUTTON8"); twinJoyRight2 = AddSwitchInput("TwinJoyRight2", "Right Joystick Right", GAME_INPUT_TWIN_JOYSTICKS, "NONE");
twinJoyUp1 = AddSwitchInput("TwinJoyUp1", "Left Joystick Up", GAME_INPUT_TWIN_JOYSTICKS, "NONE");
twinJoyUp2 = AddSwitchInput("TwinJoyUp2", "Right Joystick Up", GAME_INPUT_TWIN_JOYSTICKS, "NONE");
twinJoyDown1 = AddSwitchInput("TwinJoyDown1", "Left Joystick Down", GAME_INPUT_TWIN_JOYSTICKS, "NONE");
twinJoyDown2 = AddSwitchInput("TwinJoyDown2", "Right Joystick Down", GAME_INPUT_TWIN_JOYSTICKS, "NONE");
twinJoyShot1 = AddSwitchInput("TwinJoyShot1", "Left Shot Trigger", GAME_INPUT_TWIN_JOYSTICKS, "KEY_A,JOY1_BUTTON5");
twinJoyShot2 = AddSwitchInput("TwinJoyShot2", "Right Shot Trigger", GAME_INPUT_TWIN_JOYSTICKS, "KEY_S,JOY1_BUTTON6");
twinJoyTurbo1 = AddSwitchInput("TwinJoyTurbo1", "Left Turbo", GAME_INPUT_TWIN_JOYSTICKS, "KEY_Z,JOY1_BUTTON7");
twinJoyTurbo2 = AddSwitchInput("TwinJoyTurbo2", "Right Turbo", GAME_INPUT_TWIN_JOYSTICKS, "KEY_X,JOY1_BUTTON8");
// Analog Joystick // Analog Joystick
CAnalogInput *analogJoyLeft = AddAnalogInput("AnalogJoyLeft", "Analog Left", GAME_INPUT_ANALOG_JOYSTICK, "KEY_LEFT"); CAnalogInput *analogJoyLeft = AddAnalogInput("AnalogJoyLeft", "Analog Left", GAME_INPUT_ANALOG_JOYSTICK, "KEY_LEFT");

View file

@ -116,7 +116,21 @@ public:
CSwitchInput *viewChange; CSwitchInput *viewChange;
CSwitchInput *handBrake; CSwitchInput *handBrake;
// Twin joysticks // Twin joysticks (individually mapped version; 1 = left stick, 2 = right stick)
CSwitchInput *twinJoyLeft1;
CSwitchInput *twinJoyLeft2;
CSwitchInput *twinJoyRight1;
CSwitchInput *twinJoyRight2;
CSwitchInput *twinJoyUp1;
CSwitchInput *twinJoyUp2;
CSwitchInput *twinJoyDown1;
CSwitchInput *twinJoyDown2;
CSwitchInput *twinJoyShot1;
CSwitchInput *twinJoyShot2;
CSwitchInput *twinJoyTurbo1;
CSwitchInput *twinJoyTurbo2;
// Twin joysticks (macro mapping, for users w/out dual joysticks)
CSwitchInput *twinJoyTurnLeft; CSwitchInput *twinJoyTurnLeft;
CSwitchInput *twinJoyTurnRight; CSwitchInput *twinJoyTurnRight;
CSwitchInput *twinJoyStrafeLeft; CSwitchInput *twinJoyStrafeLeft;
@ -125,10 +139,7 @@ public:
CSwitchInput *twinJoyReverse; CSwitchInput *twinJoyReverse;
CSwitchInput *twinJoyJump; CSwitchInput *twinJoyJump;
CSwitchInput *twinJoyCrouch; CSwitchInput *twinJoyCrouch;
CSwitchInput *twinJoyLeftShot;
CSwitchInput *twinJoyRightShot;
CSwitchInput *twinJoyLeftTurbo;
CSwitchInput *twinJoyRightTurbo;
// Analog joystick // Analog joystick
CAxisInput *analogJoyX; CAxisInput *analogJoyX;

View file

@ -291,6 +291,25 @@ UINT8 CModel3::ReadInputs(unsigned reg)
if ((Game->inputFlags&GAME_INPUT_TWIN_JOYSTICKS)) // First twin joystick if ((Game->inputFlags&GAME_INPUT_TWIN_JOYSTICKS)) // First twin joystick
{ {
/*
* Process left joystick inputs first
*/
// Shot trigger and Turbo
data &= ~(Inputs->twinJoyShot1->value<<0);
data &= ~(Inputs->twinJoyTurbo1->value<<1);
// Stick
data &= ~(Inputs->twinJoyLeft1->value<<7);
data &= ~(Inputs->twinJoyRight1->value<<6);
data &= ~(Inputs->twinJoyUp1->value<<5);
data &= ~(Inputs->twinJoyDown1->value<<4);
/*
* Next, process twin joystick macro inputs (higher level inputs
* that map to actions on both joysticks simultaneously).
*/
/* /*
* Forward/reverse/turn are mutually exclusive. * Forward/reverse/turn are mutually exclusive.
* *
@ -324,10 +343,6 @@ UINT8 CModel3::ReadInputs(unsigned reg)
data &= ~0x80; data &= ~0x80;
else if (Inputs->twinJoyCrouch->value) else if (Inputs->twinJoyCrouch->value)
data &= ~0x40; data &= ~0x40;
// Shot trigger and Turbo
data &= ~(Inputs->twinJoyLeftShot->value<<0);
data &= ~(Inputs->twinJoyLeftTurbo->value<<1);
} }
return data; return data;
@ -360,6 +375,15 @@ UINT8 CModel3::ReadInputs(unsigned reg)
if ((Game->inputFlags&GAME_INPUT_TWIN_JOYSTICKS)) // Second twin joystick (see register 0x08 for comments) if ((Game->inputFlags&GAME_INPUT_TWIN_JOYSTICKS)) // Second twin joystick (see register 0x08 for comments)
{ {
data &= ~(Inputs->twinJoyShot2->value<<0);
data &= ~(Inputs->twinJoyTurbo2->value<<1);
data &= ~(Inputs->twinJoyLeft2->value<<7);
data &= ~(Inputs->twinJoyRight2->value<<6);
data &= ~(Inputs->twinJoyUp2->value<<5);
data &= ~(Inputs->twinJoyDown2->value<<4);
if (Inputs->twinJoyTurnLeft->value) if (Inputs->twinJoyTurnLeft->value)
data &= ~0x20; data &= ~0x20;
else if (Inputs->twinJoyTurnRight->value) else if (Inputs->twinJoyTurnRight->value)
@ -377,9 +401,6 @@ UINT8 CModel3::ReadInputs(unsigned reg)
data &= ~0x40; data &= ~0x40;
else if (Inputs->twinJoyCrouch->value) else if (Inputs->twinJoyCrouch->value)
data &= ~0x80; data &= ~0x80;
data &= ~(Inputs->twinJoyRightShot->value<<0);
data &= ~(Inputs->twinJoyRightTurbo->value<<1);
} }
if ((Game->inputFlags&GAME_INPUT_GUN2)) if ((Game->inputFlags&GAME_INPUT_GUN2))

View file

@ -348,8 +348,8 @@ static bool ConfigureInputs(CInputs *Inputs, bool configure)
return OKAY; return OKAY;
} }
// Apply configuration settings from configuration file // Apply configuration settings from configuration file (does NOT read input settings; see ConfigureInputs())
static void ApplySettings(CInputs *Inputs, CINIFile *INI, const char *section) static void ApplySettings(CINIFile *INI, const char *section)
{ {
unsigned x; unsigned x;
string String; string String;
@ -383,21 +383,17 @@ static void ApplySettings(CInputs *Inputs, CINIFile *INI, const char *section)
g_Config.throttle = x ? true : false; g_Config.throttle = x ? true : false;
if (OKAY == INI->Get(section, "ShowFrameRate", x)) if (OKAY == INI->Get(section, "ShowFrameRate", x))
g_Config.showFPS = x ? true : false; g_Config.showFPS = x ? true : false;
// Inputs
if (Inputs != NULL)
Inputs->ReadFromINIFile(INI, section);
} }
// Read settings (from a specific section) from the config file // Read settings (from a specific section) from the config file
static void ReadConfigFile(CInputs *Inputs, const char *section) static void ReadConfigFile(const char *section)
{ {
CINIFile INI; CINIFile INI;
INI.Open(CONFIG_FILE_PATH); INI.Open(CONFIG_FILE_PATH);
INI.SetDefaultSectionName("Global"); // required to read settings not associated with a specific section INI.SetDefaultSectionName("Global"); // required to read settings not associated with a specific section
INI.Parse(); INI.Parse();
ApplySettings(Inputs, &INI, section); ApplySettings(&INI, section);
INI.Close(); INI.Close();
} }
@ -576,9 +572,7 @@ static void LoadNVRAM(CModel3 *Model3)
/****************************************************************************** /******************************************************************************
Main Program Driver Main Program Loop
All configuration management is done prior to calling Supermodel().
******************************************************************************/ ******************************************************************************/
#ifdef SUPERMODEL_DEBUGGER #ifdef SUPERMODEL_DEBUGGER
@ -606,8 +600,8 @@ int Supermodel(const char *zipFile, CInputs *Inputs, CINIFile *CmdLine)
return 1; return 1;
// Apply game-specific settings and then, lastly, command line settings // Apply game-specific settings and then, lastly, command line settings
ReadConfigFile(Inputs, Model3->GetGameInfo()->id); ReadConfigFile(Model3->GetGameInfo()->id);
ApplySettings(Inputs, CmdLine, "Global"); ApplySettings(CmdLine, "Global");
// Load NVRAM // Load NVRAM
LoadNVRAM(Model3); LoadNVRAM(Model3);
@ -1036,7 +1030,7 @@ int main(int argc, char **argv)
InfoLog(""); InfoLog("");
// Read global settings from INI file // Read global settings from INI file
ReadConfigFile(NULL, "Global"); ReadConfigFile("Global");
/* /*
* Parse command line. * Parse command line.
@ -1284,5 +1278,11 @@ Exit:
if (InputSystem != NULL) if (InputSystem != NULL)
delete InputSystem; delete InputSystem;
SDL_Quit(); SDL_Quit();
if (exitCode)
InfoLog("Program terminated due to an error.");
else
InfoLog("Program terminated normally.");
return exitCode; return exitCode;
} }