1
0
mirror of synced 2024-11-23 22:40:57 +01:00

M2 Emu Changes

This commit is contained in:
Aaron M 2021-05-27 18:18:12 +12:00
parent 13e17b1f8f
commit 17f0685eba
8 changed files with 3955 additions and 31 deletions

View File

@ -58,6 +58,8 @@ StepFFBStrength=10
EnableFFBStrengthPersistence=0
; Set to 1 if you want FFB strength adjustments text to speech over speaker
EnableFFBStrengthTextToSpeech=0
; Set to 1 to make gui have scrollbars
AutoScrollGUI=0
; ***********************************************************************************************************************************
; ************************************************ Game overrides are specified below ***********************************************
@ -979,6 +981,57 @@ AlternativeMinForceLeftSuperGT=0
AlternativeMaxForceLeftSuperGT=-100
AlternativeMinForceRightSuperGT=0
AlternativeMaxForceRightSuperGT=100
InputDeviceWheelEnable=0
InputDeviceWheelSteeringAxis=99
InputDeviceWheelAcclAxis=99
InputDeviceWheelBrakeAxis=99
InputDeviceWheelReverseAxis=0
InputDeviceCombinedPedals=0
SteeringDeadzone=2
PedalDeadzone=2
ShowButtonNumbersForSetup=0
ShowAxisForSetup=0
DpadUp=
DpadDown=
DpadLeft=
DpadRight=
ExitButton=99
TestButton=99
ServiceButton=99
Coin1Button=99
Coin2Button=99
VR1Button=99
VR2Button=99
VR3Button=99
VR4Button=99
StartButton=99
Shift1Button=99
Shift2Button=99
Shift3Button=99
Shift4Button=99
ShiftUpButton=99
ShiftDownButton=99
Device2GUID=
DpadUpDevice2=
DpadDownDevice2=
DpadLeftDevice2=
DpadRightDevice2=
ExitButtonDevice2=99
TestButtonDevice2=99
ServiceButtonDevice2=99
Coin1ButtonDevice2=99
Coin2ButtonDevice2=99
VR1ButtonDevice2=99
VR2ButtonDevice2=99
VR3ButtonDevice2=99
VR4ButtonDevice2=99
StartButtonDevice2=99
Shift1ButtonDevice2=99
Shift2ButtonDevice2=99
Shift3ButtonDevice2=99
Shift4ButtonDevice2=99
ShiftUpButtonDevice2=99
ShiftDownButtonDevice2=99
[Supermodel 32bit Outputs]
GameId=34
@ -1120,7 +1173,6 @@ AlternativeMaxForceRightECA=100
[MAME 32bit Outputs]
GameId=22
AutoScrollGUI=0
EnableForceSpringEffect=0
ForceSpringStrength=100
Device2GUID=
@ -1618,7 +1670,6 @@ FFBDivideAceDriver=643
[MAME 64bit Outputs]
GameId=22
AutoScrollGUI=0
EnableForceSpringEffect=0
ForceSpringStrength=100
Device2GUID=

View File

@ -81,6 +81,9 @@
<ClCompile Include="Game Files\DemulInitialDInputs.cpp" />
<ClCompile Include="Game Files\InitialD0v211.cpp" />
<ClCompile Include="Game Files\KODrive.cpp" />
<ClCompile Include="Game Files\M2EmulatorDaytonaInputs.cpp" />
<ClCompile Include="Game Files\M2EmulatorIndy500Inputs.cpp" />
<ClCompile Include="Game Files\M2EmulatorSegaRallyInputs.cpp" />
<ClCompile Include="Game Files\MAMESupermodel.cpp" />
<ClCompile Include="Game Files\MarioKartGPDXUSA.cpp" />
<ClCompile Include="Game Files\OutRun2Real.cpp" />

View File

@ -138,6 +138,9 @@
<ClCompile Include="Game Files\InitialD0v131.cpp" />
<ClCompile Include="Game Files\StormRacerG.cpp" />
<ClCompile Include="Game Files\D1GP.cpp" />
<ClCompile Include="Game Files\M2EmulatorDaytonaInputs.cpp" />
<ClCompile Include="Game Files\M2EmulatorSegaRallyInputs.cpp" />
<ClCompile Include="Game Files\M2EmulatorIndy500Inputs.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="Game Files\Daytona3.h">

View File

@ -517,41 +517,41 @@ void ATVTrackInputsEnabled(Helpers* helpers)
}
else if (e.jhat.which == joystick_index2)
{
if (dpdup.compare(exit2) == 0)
if (dpdup2.compare(exit2) == 0)
{
system("taskkill /f /im demul.exe");
}
if (dpdup.compare(test2) == 0)
if (dpdup2.compare(test2) == 0)
{
helpers->WriteByte(ServiceTestAddress, servicetestread -= 0x08, false);
testbuttonA = true;
}
if (dpdup.compare(service2) == 0)
if (dpdup2.compare(service2) == 0)
{
helpers->WriteByte(ServiceTestAddress, servicetestread -= 0x02, false);
servicebuttonA = true;
}
if (dpdup.compare(coin2) == 0)
if (dpdup2.compare(coin2) == 0)
{
helpers->WriteByte(ServiceTestAddress, servicetestread -= 0x20, false);
coinA = true;
}
if (dpdup.compare(emergency2) == 0)
if (dpdup2.compare(emergency2) == 0)
{
helpers->WriteByte(BrakeAddress, brakeread += 0x40, false);
emergencystopA = true;
}
if (dpdup.compare(start2) == 0)
if (dpdup2.compare(start2) == 0)
{
helpers->WriteByte(BrakeAddress, brakeread -= 0x80, false);
startbuttonA = true;
}
if (dpdup.compare(volup2) == 0)
if (dpdup2.compare(volup2) == 0)
{
helpers->WriteByte(ServiceTestAddress, servicetestread -= 0x01, false);
volumeupA = true;
}
if (dpdup.compare(voldown2) == 0)
if (dpdup2.compare(voldown2) == 0)
{
helpers->WriteByte(ServiceTestAddress, servicetestread -= 0x04, false);
volumedownA = true;

View File

@ -17,6 +17,10 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>.
#include "math.h"
#include "SDL.h"
extern void M2EmulatorDaytonaUSAInputsEnabled(Helpers* helpers);
extern void M2EmulatorSegaRallyInputsEnabled(Helpers* helpers);
extern void M2EmulatorIndy500InputsEnabled(Helpers* helpers);
//M2 Emulator Games
std::string SegaRallyChampionship("Sega Rally Championship");
std::string SegaRallyChampionshipRevB("Sega Rally Championship (Rev B)");
@ -58,7 +62,11 @@ extern int EnableForceSpringEffect;
extern int ForceSpringStrength;
extern int EnableDamper;
extern int DamperStrength;
static DWORD hookAddressM2A;
static DWORD hookAddressM2B;
static DWORD hookAddressM2C;
static int InputDeviceWheelEnable = GetPrivateProfileInt(TEXT("Settings"), TEXT("InputDeviceWheelEnable"), 0, settingsFilename);
static int DaytonaAIMultiplayerHack = GetPrivateProfileInt(TEXT("Settings"), TEXT("DaytonaAIMultiplayerHack"), 0, settingsFilename);
static int DaytonaForcePanoramicAttract = GetPrivateProfileInt(TEXT("Settings"), TEXT("DaytonaForcePanoramicAttract"), 0, settingsFilename);
static int EnableOutputs = GetPrivateProfileInt(TEXT("Settings"), TEXT("EnableOutputs"), 0, settingsFilename);
@ -141,12 +149,37 @@ static int ForceSpringStrengthSuperGT = GetPrivateProfileInt(TEXT("Settings"), T
static int EnableDamperSuperGT = GetPrivateProfileInt(TEXT("Settings"), TEXT("EnableDamperSuperGT"), 0, settingsFilename);
static int DamperStrengthSuperGT = GetPrivateProfileInt(TEXT("Settings"), TEXT("DamperStrengthSuperGT"), 100, settingsFilename);
static HWND hWnd1;
static HWND hWnd2;
static HWND hWnd3;
static HWND hWnd4;
static HWND hWnd5;
static HWND hWnd6;
static HWND hWnd7;
static HWND hWnd8;
static HWND hWnd9;
static HWND hWnd10;
static HWND hWnd11;
static HWND hWnd12;
static HWND hWnd13;
static HWND hWnd14;
static HWND hWnd15;
static HWND hWnd16;
static HWND hWnd17;
static HWND hWnd18;
static HWND hWnd19;
static HWND hWnd20;
HWND hWndM2;
static bool init = false;
static bool inputinit = false;
static bool CustomStrengthInit = false;
static bool outputinit = false;
static UINT8 ff;
static void OldInputs(){}
static bool __stdcall ExitHook(UINT uExitCode)
{
ExitProcess(0);
@ -178,110 +211,193 @@ static DWORD jmpBackAddy;
char* romnameM2;
static int ThreadLoop()
{
if (hWnd1 > NULL || hWnd14 > NULL || hWnd15 > NULL)
{
if (InputDeviceWheelEnable)
M2EmulatorSegaRallyInputsEnabled(0);
}
if (hWnd2 > NULL || hWnd7 > NULL || hWnd8 > NULL || hWnd9 > NULL || hWnd10 > NULL || hWnd11 > NULL || hWnd12 > NULL || hWnd13 > NULL)
{
if (InputDeviceWheelEnable)
M2EmulatorDaytonaUSAInputsEnabled(0);
}
if (hWnd3 > NULL || hWnd4 > NULL || hWnd5 > NULL || hWnd6 > NULL || hWnd16 > NULL || hWnd17 > NULL || hWnd18 > NULL || hWnd19 > NULL || hWnd20 > NULL)
{
if (InputDeviceWheelEnable)
M2EmulatorIndy500InputsEnabled(0);
}
return 0;
}
static DWORD WINAPI InputLoop(LPVOID lpParam)
{
while (true)
{
ThreadLoop();
Sleep(16);
}
}
void M2Emulator::FFBLoop(EffectConstants * constants, Helpers * helpers, EffectTriggers * triggers) {
HWND hWnd1 = FindWindowA(0, ("Sega Rally Championship"));
HWND hWnd2 = FindWindowA(0, ("Daytona USA"));
HWND hWnd3 = FindWindowA(0, ("Indianapolis 500 (Rev A, Deluxe)"));
HWND hWnd4 = FindWindowA(0, ("Sega Touring Car Championship (Rev A)"));
HWND hWnd5 = FindWindowA(0, ("Over Rev"));
HWND hWnd6 = FindWindowA(0, ("Super GT 24h"));
HWND hWnd7 = FindWindowA(0, ("Daytona USA '93 Edition"));
HWND hWnd8 = FindWindowA(0, ("Daytona USA (Saturn Ads)"));
HWND hWnd9 = FindWindowA(0, ("Daytona USA Special Edition"));
HWND hWnd10 = FindWindowA(0, ("Daytona USA Turbo"));
HWND hWnd11 = FindWindowA(0, ("Daytona USA Turbo (Rev A)"));
HWND hWnd12 = FindWindowA(0, ("Daytona USA: GTX 2004"));
HWND hWnd13 = FindWindowA(0, ("Daytona USA: To The Maxx"));
HWND hWnd14 = FindWindowA(0, ("Sega Rally Championship (Rev B)"));
HWND hWnd15 = FindWindowA(0, ("Sega Rally Pro Drivin'"));
HWND hWnd16 = FindWindowA(0, ("Indianapolis 500 (Rev A, Twin, Newer rev)"));
HWND hWnd17 = FindWindowA(0, ("Indianapolis 500 (Rev A, Twin, Older rev)"));
HWND hWnd18 = FindWindowA(0, ("Sega Touring Car Championship"));
HWND hWnd19 = FindWindowA(0, ("Sega Touring Car Championship (Rev B)"));
HWND hWnd20 = FindWindowA(0, ("Over Rev (Model 2B)"));
hWnd1 = FindWindowA(0, ("Sega Rally Championship"));
hWnd2 = FindWindowA(0, ("Daytona USA"));
hWnd3 = FindWindowA(0, ("Indianapolis 500 (Rev A, Deluxe)"));
hWnd4 = FindWindowA(0, ("Sega Touring Car Championship (Rev A)"));
hWnd5 = FindWindowA(0, ("Over Rev"));
hWnd6 = FindWindowA(0, ("Super GT 24h"));
hWnd7 = FindWindowA(0, ("Daytona USA '93 Edition"));
hWnd8 = FindWindowA(0, ("Daytona USA (Saturn Ads)"));
hWnd9 = FindWindowA(0, ("Daytona USA Special Edition"));
hWnd10 = FindWindowA(0, ("Daytona USA Turbo"));
hWnd11 = FindWindowA(0, ("Daytona USA Turbo (Rev A)"));
hWnd12 = FindWindowA(0, ("Daytona USA: GTX 2004"));
hWnd13 = FindWindowA(0, ("Daytona USA: To The Maxx"));
hWnd14 = FindWindowA(0, ("Sega Rally Championship (Rev B)"));
hWnd15 = FindWindowA(0, ("Sega Rally Pro Drivin'"));
hWnd16 = FindWindowA(0, ("Indianapolis 500 (Rev A, Twin, Newer rev)"));
hWnd17 = FindWindowA(0, ("Indianapolis 500 (Rev A, Twin, Older rev)"));
hWnd18 = FindWindowA(0, ("Sega Touring Car Championship"));
hWnd19 = FindWindowA(0, ("Sega Touring Car Championship (Rev B)"));
hWnd20 = FindWindowA(0, ("Over Rev (Model 2B)"));
romnameM2 = new char[256];
if (hWnd1 > NULL || hWnd2 > NULL || hWnd3 > NULL || hWnd4 > NULL || hWnd5 > NULL || hWnd6 > NULL || hWnd7 > NULL || hWnd8 > NULL || hWnd9 > NULL || hWnd10 > NULL ||
hWnd11 > NULL || hWnd12 > NULL || hWnd13 > NULL || hWnd14 > NULL || hWnd15 > NULL || hWnd16 > NULL || hWnd17 > NULL || hWnd18 > NULL || hWnd19 > NULL || hWnd20 > NULL)
{
if (InputDeviceWheelEnable)
{
hookAddressM2A = 0x4CA450;
hookAddressM2B = 0x4CB870;
hookAddressM2C = 0x4C9080;
helpers->WriteNop(0xCCA6B, 6, true);
int hookLength = 6;
if (hookAddressM2A)
{
jmpBackAddy = hookAddressM2A + hookLength;
Hook((void*)hookAddressM2A, OldInputs, hookLength);
}
if (hookAddressM2B)
{
jmpBackAddy = hookAddressM2B + hookLength;
Hook((void*)hookAddressM2B, OldInputs, hookLength);
}
if (hookAddressM2C)
{
jmpBackAddy = hookAddressM2C + hookLength;
Hook((void*)hookAddressM2C, OldInputs, hookLength);
}
}
}
if (hWnd1 > NULL)
{
sprintf(romnameM2, "%s", "Sega Rally Championship");
hWndM2 = hWnd1;
}
else if(hWnd2 > NULL)
{
sprintf(romnameM2, "%s", "Daytona USA");
hWndM2 = hWnd2;
}
else if (hWnd3 > NULL)
{
sprintf(romnameM2, "%s", "Indianapolis 500 (Rev A, Deluxe)");
hWndM2 = hWnd3;
}
else if (hWnd4 > NULL)
{
sprintf(romnameM2, "%s", "Sega Touring Car Championship (Rev A)");
hWndM2 = hWnd4;
}
else if (hWnd5 > NULL)
{
sprintf(romnameM2, "%s", "Over Rev");
hWndM2 = hWnd5;
}
else if (hWnd6 > NULL)
{
sprintf(romnameM2, "%s", "Super GT 24h");
hWndM2 = hWnd6;
}
else if (hWnd7 > NULL)
{
sprintf(romnameM2, "%s", "Daytona USA '93 Edition");
hWndM2 = hWnd7;
}
else if (hWnd8 > NULL)
{
sprintf(romnameM2, "%s", "Daytona USA (Saturn Ads)");
hWndM2 = hWnd8;
}
else if (hWnd9 > NULL)
{
sprintf(romnameM2, "%s", "Daytona USA Special Edition");
hWndM2 = hWnd9;
}
else if (hWnd10 > NULL)
{
sprintf(romnameM2, "%s", "Daytona USA Turbo");
hWndM2 = hWnd10;
}
else if (hWnd11 > NULL)
{
sprintf(romnameM2, "%s", "Daytona USA Turbo (Rev A)");
hWndM2 = hWnd11;
}
else if (hWnd12 > NULL)
{
sprintf(romnameM2, "%s", "Daytona USA: GTX 2004");
hWndM2 = hWnd12;
}
else if (hWnd13 > NULL)
{
sprintf(romnameM2, "%s", "Daytona USA: To The Maxx");
hWndM2 = hWnd13;
}
else if (hWnd14 > NULL)
{
sprintf(romnameM2, "%s", "Sega Rally Championship (Rev B)");
hWndM2 = hWnd14;
}
else if (hWnd15 > NULL)
{
sprintf(romnameM2, "%s", "Sega Rally Pro Drivin'");
hWndM2 = hWnd15;
}
else if (hWnd16 > NULL)
{
sprintf(romnameM2, "%s", "Indianapolis 500 (Rev A, Twin, Newer rev)");
hWndM2 = hWnd16;
}
else if (hWnd17 > NULL)
{
sprintf(romnameM2, "%s", "Indianapolis 500 (Rev A, Twin, Older rev)");
hWndM2 = hWnd17;
}
else if (hWnd18 > NULL)
{
sprintf(romnameM2, "%s", "Sega Touring Car Championship");
hWndM2 = hWnd18;
}
else if (hWnd19 > NULL)
{
sprintf(romnameM2, "%s", "Sega Touring Car Championship (Rev B)");
hWndM2 = hWnd19;
}
else if (hWnd20 > NULL)
{
sprintf(romnameM2, "%s", "Over Rev (Model 2B)");
hWndM2 = hWnd20;
}
if (EnableForceSpringEffect == 1)
@ -296,13 +412,20 @@ void M2Emulator::FFBLoop(EffectConstants * constants, Helpers * helpers, EffectT
if (!outputinit)
{
if (EnableOutputs == 1)
if (EnableOutputs)
{
HMODULE lib = LoadLibraryA("OutputBlaster.dll");
outputinit = true;
}
}
if (!inputinit)
{
if (InputDeviceWheelEnable)
CreateThread(NULL, 0, InputLoop, NULL, 0, NULL);
inputinit = true;
}
HMODULE hMod = GetModuleHandleA("KERNEL32.dll");
if (hMod)
{

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,997 @@
#include "../Common Files/Game.h"
#include <string>
#include <windows.h>
#include "SDL.h"
static DWORD imageBase;
extern int joystick_index1;
extern int joystick_index2;
extern SDL_Joystick* GameController2;
static bool testA;
static bool serviceA;
static bool startA;
static bool vr1A;
static bool vr2A;
static bool shiftupA;
static bool shiftdwnA;
static bool coin1A;
static bool coin2A;
static bool Inputsinit = false;
extern SDL_Event e;
extern HWND hWndM2;
static INT_PTR SteeringAddress;
static INT_PTR AcclAddress;
static INT_PTR BrakeAddress;
static INT_PTR Button1Address;
static INT_PTR Button2Address;
static int SteeringValue;
static int AcclValue;
static int BrakeValue;
extern wchar_t* settingsFilename;
static int InputDeviceWheelEnable = GetPrivateProfileInt(TEXT("Settings"), TEXT("InputDeviceWheelEnable"), 0, settingsFilename);
static int InputDeviceWheelSteeringAxis = GetPrivateProfileInt(TEXT("Settings"), TEXT("InputDeviceWheelSteeringAxis"), 0, settingsFilename);
static int InputDeviceWheelAcclAxis = GetPrivateProfileInt(TEXT("Settings"), TEXT("InputDeviceWheelAcclAxis"), 0, settingsFilename);
static int InputDeviceWheelBrakeAxis = GetPrivateProfileInt(TEXT("Settings"), TEXT("InputDeviceWheelBrakeAxis"), 0, settingsFilename);
static int InputDeviceWheelReverseAxis = GetPrivateProfileInt(TEXT("Settings"), TEXT("InputDeviceWheelReverseAxis"), 0, settingsFilename);
static int InputDeviceCombinedPedals = GetPrivateProfileInt(TEXT("Settings"), TEXT("InputDeviceCombinedPedals"), 0, settingsFilename);
static int SteeringDeadzone = GetPrivateProfileInt(TEXT("Settings"), TEXT("SteeringDeadzone"), 0, settingsFilename);
static int PedalDeadzone = GetPrivateProfileInt(TEXT("Settings"), TEXT("PedalDeadzone"), 0, settingsFilename);
static int ShowButtonNumbersForSetup = GetPrivateProfileInt(TEXT("Settings"), TEXT("ShowButtonNumbersForSetup"), 0, settingsFilename);
static int ShowAxisForSetup = GetPrivateProfileInt(TEXT("Settings"), TEXT("ShowAxisForSetup"), 0, settingsFilename);
static int ExitButton = GetPrivateProfileInt(TEXT("Settings"), TEXT("ExitButton"), 0, settingsFilename);
static int TestButton = GetPrivateProfileInt(TEXT("Settings"), TEXT("TestButton"), 0, settingsFilename);
static int ServiceButton = GetPrivateProfileInt(TEXT("Settings"), TEXT("ServiceButton"), 0, settingsFilename);
static int Coin1Button = GetPrivateProfileInt(TEXT("Settings"), TEXT("Coin1Button"), 0, settingsFilename);
static int Coin2Button = GetPrivateProfileInt(TEXT("Settings"), TEXT("Coin2Button"), 0, settingsFilename);
static int VR1Button = GetPrivateProfileInt(TEXT("Settings"), TEXT("VR1Button"), 0, settingsFilename);
static int VR2Button = GetPrivateProfileInt(TEXT("Settings"), TEXT("VR2Button"), 0, settingsFilename);
static int StartButton = GetPrivateProfileInt(TEXT("Settings"), TEXT("StartButton"), 0, settingsFilename);
static int ShiftUpButton = GetPrivateProfileInt(TEXT("Settings"), TEXT("ShiftUpButton"), 0, settingsFilename);
static int ShiftDownButton = GetPrivateProfileInt(TEXT("Settings"), TEXT("ShiftDownButton"), 0, settingsFilename);
static int ExitButtonDevice2 = GetPrivateProfileInt(TEXT("Settings"), TEXT("ExitButtonDevice2"), 0, settingsFilename);
static int TestButtonDevice2 = GetPrivateProfileInt(TEXT("Settings"), TEXT("TestButtonDevice2"), 0, settingsFilename);
static int ServiceButtonDevice2 = GetPrivateProfileInt(TEXT("Settings"), TEXT("ServiceButtonDevice2"), 0, settingsFilename);
static int Coin1ButtonDevice2 = GetPrivateProfileInt(TEXT("Settings"), TEXT("Coin1ButtonDevice2"), 0, settingsFilename);
static int Coin2ButtonDevice2 = GetPrivateProfileInt(TEXT("Settings"), TEXT("Coin2ButtonDevice2"), 0, settingsFilename);
static int VR1ButtonDevice2 = GetPrivateProfileInt(TEXT("Settings"), TEXT("VR1ButtonDevice2"), 0, settingsFilename);
static int VR2ButtonDevice2 = GetPrivateProfileInt(TEXT("Settings"), TEXT("VR2ButtonDevice2"), 0, settingsFilename);
static int StartButtonDevice2 = GetPrivateProfileInt(TEXT("Settings"), TEXT("StartButtonDevice2"), 0, settingsFilename);
static int ShiftUpButtonDevice2 = GetPrivateProfileInt(TEXT("Settings"), TEXT("ShiftUpButtonDevice2"), 0, settingsFilename);
static int ShiftDownButtonDevice2 = GetPrivateProfileInt(TEXT("Settings"), TEXT("ShiftDownButtonDevice2"), 0, settingsFilename);
void M2EmulatorIndy500InputsEnabled(Helpers* helpers)
{
if (!Inputsinit)
{
//Added 2nd device stuff from here
wchar_t* deviceGUIDString2 = new wchar_t[256];
int Device2GUID = GetPrivateProfileString(TEXT("Settings"), TEXT("Device2GUID"), NULL, deviceGUIDString2, 256, settingsFilename);
char joystick_guid[256];
sprintf(joystick_guid, "%S", deviceGUIDString2);
SDL_JoystickGUID guid, dev_guid;
int numJoysticks = SDL_NumJoysticks();
std::string njs = std::to_string(numJoysticks);
((char)njs.c_str());
for (int i = 0; i < SDL_NumJoysticks(); i++)
{
SDL_Joystick* js2 = SDL_JoystickOpen(i);
SDL_JoystickGUID guid = SDL_JoystickGetGUID(js2);
char guid_str[1024];
SDL_JoystickGetGUIDString(guid, guid_str, sizeof(guid_str));
const char* name = SDL_JoystickName(js2);
char text[256];
sprintf(text, "Joystick: %d / Name: %s / GUID: %s\n", i, name, guid_str);
guid = SDL_JoystickGetGUIDFromString(joystick_guid);
dev_guid = SDL_JoystickGetGUID(js2);
SDL_JoystickClose(js2);
if (!memcmp(&guid, &dev_guid, sizeof(SDL_JoystickGUID)))
{
GameController2 = SDL_JoystickOpen(i);
joystick_index2 = SDL_JoystickInstanceID(GameController2);
break;
}
}
imageBase = (DWORD)GetModuleHandleA(0);
SteeringAddress = imageBase + 0x1AA70C;
AcclAddress = imageBase + 0x1AA70D;
BrakeAddress = imageBase + 0x1AA70E;
Button1Address = imageBase + 0x1AA875;
Button2Address = imageBase + 0x1AA874;
helpers->WriteByte(Button1Address, 0xFF, false);
helpers->WriteByte(Button2Address, 0xFF, false);
helpers->WriteByte(SteeringAddress, 0x80, false);
helpers->WriteByte(AcclAddress, 0x00, false);
helpers->WriteByte(BrakeAddress, 0x00, false);
Inputsinit = true;
}
// Dpad stuff here to set as any button
char DpadUpChar[256];
char DpadDownChar[256];
char DpadLeftChar[256];
char DpadRightChar[256];
char DpadUpCharDevice2[256];
char DpadDownCharDevice2[256];
char DpadLeftCharDevice2[256];
char DpadRightCharDevice2[256];
GetPrivateProfileStringA("Settings", "DpadUp", "", DpadUpChar, 256, ".\\FFBplugin.ini");
GetPrivateProfileStringA("Settings", "DpadDown", "", DpadDownChar, 256, ".\\FFBplugin.ini");
GetPrivateProfileStringA("Settings", "DpadLeft", "", DpadLeftChar, 256, ".\\FFBplugin.ini");
GetPrivateProfileStringA("Settings", "DpadRight", "", DpadRightChar, 256, ".\\FFBplugin.ini");
GetPrivateProfileStringA("Settings", "DpadUpDevice2", "", DpadUpCharDevice2, 256, ".\\FFBplugin.ini");
GetPrivateProfileStringA("Settings", "DpadDownDevice2", "", DpadDownCharDevice2, 256, ".\\FFBplugin.ini");
GetPrivateProfileStringA("Settings", "DpadLeftDevice2", "", DpadLeftCharDevice2, 256, ".\\FFBplugin.ini");
GetPrivateProfileStringA("Settings", "DpadRightDevice2", "", DpadRightCharDevice2, 256, ".\\FFBplugin.ini");
std::string exit("ExitButton");
std::string test("TestButton");
std::string service("ServiceButton");
std::string coin1("Coin1Button");
std::string coin2("Coin2Button");
std::string vr1("VR1Button");
std::string vr2("VR2Button");
std::string start("StartButton");
std::string shiftup("ShiftUpButton");
std::string shiftdwn("ShiftDownButton");
std::string exit2("ExitButtonDevice2");
std::string test2("TestButtonDevice2");
std::string service2("ServiceButtonDevice2");
std::string coin12("Coin1ButtonDevice2");
std::string coin22("Coin2ButtonDevice2");
std::string vr12("VR1ButtonDevice2");
std::string vr22("VR2ButtonDevice2");
std::string start2("StartButtonDevice2");
std::string shiftup2("ShiftUpButtonDevice2");
std::string shiftdwn2("ShiftDownButtonDevice2");
std::string dpdup(DpadUpChar);
std::string dpddown(DpadDownChar);
std::string dpdleft(DpadLeftChar);
std::string dpdright(DpadRightChar);
std::string dpdup2(DpadUpCharDevice2);
std::string dpddown2(DpadDownCharDevice2);
std::string dpdleft2(DpadLeftCharDevice2);
std::string dpdright2(DpadRightCharDevice2);
const int WHEEL_DEAD_ZONE = (SteeringDeadzone * 100.0);
const int ACCL_DEAD_ZONE = (1 + PedalDeadzone * 100.0);
const int BRAKE_DEAD_ZONE = (1 + PedalDeadzone * 100.0);
const int SETUP_DEAD_ZONE = 20000;
while (SDL_WaitEvent(&e) != 0)
{
UINT8 button1read = helpers->ReadByte(Button1Address, false);
UINT8 button2read = helpers->ReadByte(Button2Address, false);
if ((e.type == SDL_JOYAXISMOTION) & (ShowAxisForSetup == 0))
{
if (e.jaxis.which == joystick_index1)
{
if (e.jaxis.axis == InputDeviceWheelSteeringAxis)
{
if (e.jaxis.value < -WHEEL_DEAD_ZONE)
{
e.jaxis.value = e.jaxis.value - WHEEL_DEAD_ZONE;
SteeringValue = 128 + (e.jaxis.value + WHEEL_DEAD_ZONE) / 255;
}
else if (e.jaxis.value > WHEEL_DEAD_ZONE)
{
e.jaxis.value = e.jaxis.value + WHEEL_DEAD_ZONE;
SteeringValue = 127 + (e.jaxis.value - WHEEL_DEAD_ZONE) / 255;
}
else
{
SteeringValue = 0x80;
}
}
if (InputDeviceWheelReverseAxis == 1)
{
if (InputDeviceCombinedPedals == 1)
{
if (e.jaxis.axis == InputDeviceWheelAcclAxis)
{
if (e.jaxis.value < -ACCL_DEAD_ZONE)
{
e.jaxis.value = e.jaxis.value + ACCL_DEAD_ZONE;
AcclValue = (-e.jaxis.value + ACCL_DEAD_ZONE) / 128.5;
}
else if (e.jaxis.value > ACCL_DEAD_ZONE)
{
e.jaxis.value = e.jaxis.value - ACCL_DEAD_ZONE;
BrakeValue = (e.jaxis.value + ACCL_DEAD_ZONE) / 128;
}
else
{
AcclValue = 0x00;
BrakeValue = 0x00;
}
}
}
else
{
if (e.jaxis.axis == InputDeviceWheelAcclAxis)
{
if (e.jaxis.value < -ACCL_DEAD_ZONE)
{
e.jaxis.value = (e.jaxis.value / 255);
AcclValue = 127 - e.jaxis.value;
}
else if (e.jaxis.value > ACCL_DEAD_ZONE)
{
e.jaxis.value = (e.jaxis.value / 255);
AcclValue = 128 - e.jaxis.value;
}
}
else if (e.jaxis.axis == InputDeviceWheelBrakeAxis)
{
if (e.jaxis.value < -BRAKE_DEAD_ZONE)
{
e.jaxis.value = (e.jaxis.value / 255);
BrakeValue = 127 - e.jaxis.value;
}
else if (e.jaxis.value > BRAKE_DEAD_ZONE)
{
e.jaxis.value = (e.jaxis.value / 255);
BrakeValue = 128 - e.jaxis.value;
}
}
}
}
else
{
if (InputDeviceCombinedPedals == 1)
{
if (e.jaxis.axis == InputDeviceWheelAcclAxis)
{
if (e.jaxis.value < -ACCL_DEAD_ZONE)
{
e.jaxis.value = e.jaxis.value - ACCL_DEAD_ZONE;
AcclValue = (e.jaxis.value + ACCL_DEAD_ZONE) / 128;
}
else if (e.jaxis.value > ACCL_DEAD_ZONE)
{
e.jaxis.value = e.jaxis.value + ACCL_DEAD_ZONE;
BrakeValue = (-e.jaxis.value + ACCL_DEAD_ZONE) / 128;
}
else if ((e.jaxis.value < ACCL_DEAD_ZONE) & (e.jaxis.value > -ACCL_DEAD_ZONE))
{
AcclValue = 0xFF;
BrakeValue = 0xFF;
}
}
}
else
{
if (e.jaxis.axis == InputDeviceWheelAcclAxis)
{
if (e.jaxis.value < -ACCL_DEAD_ZONE)
{
e.jaxis.value = (e.jaxis.value / 255);
AcclValue = 128 + e.jaxis.value;
}
else if (e.jaxis.value > ACCL_DEAD_ZONE)
{
e.jaxis.value = (e.jaxis.value / 255);
AcclValue = 127 + e.jaxis.value;
}
}
if (e.jaxis.axis == InputDeviceWheelBrakeAxis)
{
if (e.jaxis.value < -BRAKE_DEAD_ZONE)
{
e.jaxis.value = (e.jaxis.value / 255);
BrakeValue = 128 + e.jaxis.value;
}
else if (e.jaxis.value > BRAKE_DEAD_ZONE)
{
e.jaxis.value = (e.jaxis.value / 255);
BrakeValue = 127 + e.jaxis.value;
}
}
}
}
helpers->WriteByte(SteeringAddress, SteeringValue, false);
helpers->WriteByte(AcclAddress, AcclValue, false);
helpers->WriteByte(BrakeAddress, BrakeValue, false);
}
}
if (ShowAxisForSetup == 1)
{
if (e.type == SDL_JOYAXISMOTION)
{
if (e.jaxis.which == joystick_index1)
{
if (e.jaxis.axis >= 0)
{
if (e.jaxis.value < -SETUP_DEAD_ZONE)
{
e.jaxis.value = e.jaxis.value - SETUP_DEAD_ZONE;
char buff[100];
sprintf_s(buff, "Axis %d Moved", e.jaxis.axis);
MessageBoxA(NULL, buff, "", NULL);
}
else if (e.jaxis.value > SETUP_DEAD_ZONE)
{
char buff[100];
sprintf_s(buff, "Axis %d Moved", e.jaxis.axis);
MessageBoxA(NULL, buff, "", NULL);
}
}
}
}
}
if (ShowButtonNumbersForSetup == 1)
{
if (e.type == SDL_JOYBUTTONDOWN)
{
if (e.jaxis.which == joystick_index1 || e.jaxis.which == joystick_index2)
{
if (e.jbutton.button >= 0)
{
char buff[100];
sprintf_s(buff, "Button %d Pressed", e.jbutton.button);
MessageBoxA(NULL, buff, "", NULL);
}
}
}
}
if (e.jhat.type == SDL_JOYHATMOTION)
{
if (e.jhat.value == SDL_HAT_CENTERED)
{
if (e.jhat.which == joystick_index1 || e.jhat.which == joystick_index2)
{
if (testA)
{
helpers->WriteByte(Button2Address, button2read += 0x04, false);
testA = false;
}
if (serviceA)
{
helpers->WriteByte(Button2Address, button2read += 0x08, false);
serviceA = false;
}
if (startA)
{
helpers->WriteByte(Button2Address, button2read += 0x40, false);
startA = false;
}
if (vr1A)
{
helpers->WriteByte(Button1Address, button1read += 0x01, false);
vr1A = false;
}
if (vr2A)
{
helpers->WriteByte(Button1Address, button1read += 0x02, false);
vr2A = false;
}
if (coin1A)
{
helpers->WriteByte(Button2Address, button2read += 0x01, false);
coin1A = false;
}
if (coin2A)
{
helpers->WriteByte(Button2Address, button2read += 0x02, false);
coin2A = false;
}
if (shiftupA)
{
helpers->WriteByte(Button1Address, button1read += 0x10, false);
shiftupA = false;
}
if (shiftdwnA)
{
helpers->WriteByte(Button1Address, button1read += 0x20, false);
shiftdwnA = false;
}
}
}
if (e.jhat.value == SDL_HAT_UP)
{
if (e.jhat.which == joystick_index1)
{
if (dpdup.compare(exit) == 0)
{
SendMessage(hWndM2, WM_CLOSE, NULL, NULL);
}
if (dpdup.compare(test) == 0)
{
helpers->WriteByte(Button2Address, button2read -= 0x04, false);
testA = true;
}
if (dpdup.compare(service) == 0)
{
helpers->WriteByte(Button2Address, button2read -= 0x08, false);
serviceA = true;
}
if (dpdup.compare(coin1) == 0)
{
helpers->WriteByte(Button2Address, button2read -= 0x01, false);
coin1A = true;
}
if (dpdup.compare(coin2) == 0)
{
helpers->WriteByte(Button2Address, button2read -= 0x02, false);
coin2A = true;
}
if (dpdup.compare(start) == 0)
{
helpers->WriteByte(Button2Address, button2read -= 0x40, false);
startA = true;
}
if (dpdup.compare(vr1) == 0)
{
helpers->WriteByte(Button1Address, button1read -= 0x01, false);
vr1A = true;
}
if (dpdup.compare(vr2) == 0)
{
helpers->WriteByte(Button1Address, button1read -= 0x02, false);
vr2A = true;
}
if (dpdup.compare(shiftup) == 0)
{
helpers->WriteByte(Button1Address, button1read -= 0x10, false);
shiftupA = true;
}
if (dpdup.compare(shiftdwn) == 0)
{
helpers->WriteByte(Button1Address, button1read -= 0x20, false);
shiftdwnA = true;
}
}
else if (e.jhat.which == joystick_index2)
{
if (dpdup2.compare(exit2) == 0)
{
SendMessage(hWndM2, WM_CLOSE, NULL, NULL);
}
if (dpdup2.compare(test2) == 0)
{
helpers->WriteByte(Button2Address, button2read -= 0x04, false);
testA = true;
}
if (dpdup2.compare(service2) == 0)
{
helpers->WriteByte(Button2Address, button2read -= 0x08, false);
serviceA = true;
}
if (dpdup2.compare(coin12) == 0)
{
helpers->WriteByte(Button2Address, button2read -= 0x01, false);
coin1A = true;
}
if (dpdup2.compare(coin22) == 0)
{
helpers->WriteByte(Button2Address, button2read -= 0x02, false);
coin2A = true;
}
if (dpdup2.compare(start2) == 0)
{
helpers->WriteByte(Button2Address, button2read -= 0x40, false);
startA = true;
}
if (dpdup2.compare(vr12) == 0)
{
helpers->WriteByte(Button1Address, button1read -= 0x01, false);
vr1A = true;
}
if (dpdup2.compare(vr22) == 0)
{
helpers->WriteByte(Button1Address, button1read -= 0x02, false);
vr2A = true;
}
if (dpdup2.compare(shiftup2) == 0)
{
helpers->WriteByte(Button1Address, button1read -= 0x10, false);
shiftupA = true;
}
if (dpdup2.compare(shiftdwn2) == 0)
{
helpers->WriteByte(Button1Address, button1read -= 0x20, false);
shiftdwnA = true;
}
}
}
if (e.jhat.value == SDL_HAT_DOWN)
{
if (e.jhat.which == joystick_index1)
{
if (dpddown.compare(exit) == 0)
{
SendMessage(hWndM2, WM_CLOSE, NULL, NULL);
}
if (dpddown.compare(test) == 0)
{
helpers->WriteByte(Button2Address, button2read -= 0x04, false);
testA = true;
}
if (dpddown.compare(service) == 0)
{
helpers->WriteByte(Button2Address, button2read -= 0x08, false);
serviceA = true;
}
if (dpddown.compare(coin1) == 0)
{
helpers->WriteByte(Button2Address, button2read -= 0x01, false);
coin1A = true;
}
if (dpddown.compare(coin2) == 0)
{
helpers->WriteByte(Button2Address, button2read -= 0x02, false);
coin2A = true;
}
if (dpddown.compare(start) == 0)
{
helpers->WriteByte(Button2Address, button2read -= 0x40, false);
startA = true;
}
if (dpddown.compare(vr1) == 0)
{
helpers->WriteByte(Button1Address, button1read -= 0x01, false);
vr1A = true;
}
if (dpddown.compare(vr2) == 0)
{
helpers->WriteByte(Button1Address, button1read -= 0x02, false);
vr2A = true;
}
if (dpddown.compare(shiftup) == 0)
{
helpers->WriteByte(Button1Address, button1read -= 0x10, false);
shiftupA = true;
}
if (dpddown.compare(shiftdwn) == 0)
{
helpers->WriteByte(Button1Address, button1read -= 0x20, false);
shiftdwnA = true;
}
}
else if (e.jhat.which == joystick_index2)
{
if (dpddown2.compare(exit2) == 0)
{
SendMessage(hWndM2, WM_CLOSE, NULL, NULL);
}
if (dpddown2.compare(test2) == 0)
{
helpers->WriteByte(Button2Address, button2read -= 0x04, false);
testA = true;
}
if (dpddown2.compare(service2) == 0)
{
helpers->WriteByte(Button2Address, button2read -= 0x08, false);
serviceA = true;
}
if (dpddown2.compare(coin12) == 0)
{
helpers->WriteByte(Button2Address, button2read -= 0x01, false);
coin1A = true;
}
if (dpddown2.compare(coin22) == 0)
{
helpers->WriteByte(Button2Address, button2read -= 0x02, false);
coin2A = true;
}
if (dpddown2.compare(start2) == 0)
{
helpers->WriteByte(Button2Address, button2read -= 0x40, false);
startA = true;
}
if (dpddown2.compare(vr12) == 0)
{
helpers->WriteByte(Button1Address, button1read -= 0x01, false);
vr1A = true;
}
if (dpddown2.compare(vr22) == 0)
{
helpers->WriteByte(Button1Address, button1read -= 0x02, false);
vr2A = true;
}
if (dpddown2.compare(shiftup2) == 0)
{
helpers->WriteByte(Button1Address, button1read -= 0x10, false);
shiftupA = true;
}
if (dpddown2.compare(shiftdwn2) == 0)
{
helpers->WriteByte(Button1Address, button1read -= 0x20, false);
shiftdwnA = true;
}
}
}
if (e.jhat.value == SDL_HAT_LEFT)
{
if (e.jhat.which == joystick_index1)
{
if (dpdleft.compare(exit) == 0)
{
SendMessage(hWndM2, WM_CLOSE, NULL, NULL);
}
if (dpdleft.compare(test) == 0)
{
helpers->WriteByte(Button2Address, button2read -= 0x04, false);
testA = true;
}
if (dpdleft.compare(service) == 0)
{
helpers->WriteByte(Button2Address, button2read -= 0x08, false);
serviceA = true;
}
if (dpdleft.compare(coin1) == 0)
{
helpers->WriteByte(Button2Address, button2read -= 0x01, false);
coin1A = true;
}
if (dpdleft.compare(coin2) == 0)
{
helpers->WriteByte(Button2Address, button2read -= 0x02, false);
coin2A = true;
}
if (dpdleft.compare(start) == 0)
{
helpers->WriteByte(Button2Address, button2read -= 0x40, false);
startA = true;
}
if (dpdleft.compare(vr1) == 0)
{
helpers->WriteByte(Button1Address, button1read -= 0x01, false);
vr1A = true;
}
if (dpdleft.compare(vr2) == 0)
{
helpers->WriteByte(Button1Address, button1read -= 0x02, false);
vr2A = true;
}
if (dpdleft.compare(shiftup) == 0)
{
helpers->WriteByte(Button1Address, button1read -= 0x10, false);
shiftupA = true;
}
if (dpdleft.compare(shiftdwn) == 0)
{
helpers->WriteByte(Button1Address, button1read -= 0x20, false);
shiftdwnA = true;
}
}
else if (e.jhat.which == joystick_index2)
{
if (dpdleft2.compare(exit2) == 0)
{
SendMessage(hWndM2, WM_CLOSE, NULL, NULL);
}
if (dpdleft2.compare(test2) == 0)
{
helpers->WriteByte(Button2Address, button2read -= 0x04, false);
testA = true;
}
if (dpdleft2.compare(service2) == 0)
{
helpers->WriteByte(Button2Address, button2read -= 0x08, false);
serviceA = true;
}
if (dpdleft2.compare(coin12) == 0)
{
helpers->WriteByte(Button2Address, button2read -= 0x01, false);
coin1A = true;
}
if (dpdleft2.compare(coin22) == 0)
{
helpers->WriteByte(Button2Address, button2read -= 0x02, false);
coin2A = true;
}
if (dpdleft2.compare(start2) == 0)
{
helpers->WriteByte(Button2Address, button2read -= 0x40, false);
startA = true;
}
if (dpdleft2.compare(vr12) == 0)
{
helpers->WriteByte(Button1Address, button1read -= 0x01, false);
vr1A = true;
}
if (dpdleft2.compare(vr22) == 0)
{
helpers->WriteByte(Button1Address, button1read -= 0x02, false);
vr2A = true;
}
if (dpdleft2.compare(shiftup2) == 0)
{
helpers->WriteByte(Button1Address, button1read -= 0x10, false);
shiftupA = true;
}
if (dpdleft2.compare(shiftdwn2) == 0)
{
helpers->WriteByte(Button1Address, button1read -= 0x20, false);
shiftdwnA = true;
}
}
}
if (e.jhat.value == SDL_HAT_RIGHT)
{
if (e.jhat.which == joystick_index1)
{
if (dpdright.compare(exit) == 0)
{
SendMessage(hWndM2, WM_CLOSE, NULL, NULL);
}
if (dpdright.compare(test) == 0)
{
helpers->WriteByte(Button2Address, button2read -= 0x04, false);
testA = true;
}
if (dpdright.compare(service) == 0)
{
helpers->WriteByte(Button2Address, button2read -= 0x08, false);
serviceA = true;
}
if (dpdright.compare(coin1) == 0)
{
helpers->WriteByte(Button2Address, button2read -= 0x01, false);
coin1A = true;
}
if (dpdright.compare(coin2) == 0)
{
helpers->WriteByte(Button2Address, button2read -= 0x02, false);
coin2A = true;
}
if (dpdright.compare(start) == 0)
{
helpers->WriteByte(Button2Address, button2read -= 0x40, false);
startA = true;
}
if (dpdright.compare(vr1) == 0)
{
helpers->WriteByte(Button1Address, button1read -= 0x01, false);
vr1A = true;
}
if (dpdright.compare(vr2) == 0)
{
helpers->WriteByte(Button1Address, button1read -= 0x02, false);
vr2A = true;
}
if (dpdright.compare(shiftup) == 0)
{
helpers->WriteByte(Button1Address, button1read -= 0x10, false);
shiftupA = true;
}
if (dpdright.compare(shiftdwn) == 0)
{
helpers->WriteByte(Button1Address, button1read -= 0x20, false);
shiftdwnA = true;
}
}
else if (e.jhat.which == joystick_index2)
{
if (dpdright2.compare(exit2) == 0)
{
SendMessage(hWndM2, WM_CLOSE, NULL, NULL);
}
if (dpdright2.compare(test2) == 0)
{
helpers->WriteByte(Button2Address, button2read -= 0x04, false);
testA = true;
}
if (dpdright2.compare(service2) == 0)
{
helpers->WriteByte(Button2Address, button2read -= 0x08, false);
serviceA = true;
}
if (dpdright2.compare(coin12) == 0)
{
helpers->WriteByte(Button2Address, button2read -= 0x01, false);
coin1A = true;
}
if (dpdright2.compare(coin22) == 0)
{
helpers->WriteByte(Button2Address, button2read -= 0x02, false);
coin2A = true;
}
if (dpdright2.compare(start2) == 0)
{
helpers->WriteByte(Button2Address, button2read -= 0x40, false);
startA = true;
}
if (dpdright2.compare(vr12) == 0)
{
helpers->WriteByte(Button1Address, button1read -= 0x01, false);
vr1A = true;
}
if (dpdright2.compare(vr22) == 0)
{
helpers->WriteByte(Button1Address, button1read -= 0x02, false);
vr2A = true;
}
if (dpdright2.compare(shiftup2) == 0)
{
helpers->WriteByte(Button1Address, button1read -= 0x10, false);
shiftupA = true;
}
if (dpdright2.compare(shiftdwn2) == 0)
{
helpers->WriteByte(Button1Address, button1read -= 0x20, false);
shiftdwnA = true;
}
}
}
}
if (e.type == SDL_JOYBUTTONDOWN)
{
if (e.jbutton.which == joystick_index1)
{
if (e.jbutton.button == TestButton)
{
helpers->WriteByte(Button2Address, button2read -= 0x04, false);
}
if (e.jbutton.button == ExitButton)
{
SendMessage(hWndM2, WM_CLOSE, NULL, NULL);
}
if (e.jbutton.button == ServiceButton)
{
helpers->WriteByte(Button2Address, button2read -= 0x08, false);
}
if (e.jbutton.button == Coin1Button)
{
helpers->WriteByte(Button2Address, button2read -= 0x01, false);
}
if (e.jbutton.button == Coin2Button)
{
helpers->WriteByte(Button2Address, button2read -= 0x02, false);
}
if (e.jbutton.button == VR1Button)
{
helpers->WriteByte(Button1Address, button1read -= 0x01, false);
}
if (e.jbutton.button == VR2Button)
{
helpers->WriteByte(Button1Address, button1read -= 0x02, false);
}
if (e.jbutton.button == ShiftUpButton)
{
helpers->WriteByte(Button1Address, button1read -= 0x10, false);
}
if (e.jbutton.button == ShiftDownButton)
{
helpers->WriteByte(Button1Address, button1read -= 0x20, false);
}
if (e.jbutton.button == StartButton)
{
helpers->WriteByte(Button2Address, button2read -= 0x40, false);
}
}
else if (e.jbutton.which == joystick_index2)
{
if (e.jbutton.button == TestButtonDevice2)
{
helpers->WriteByte(Button2Address, button2read -= 0x04, false);
}
if (e.jbutton.button == ExitButtonDevice2)
{
SendMessage(hWndM2, WM_CLOSE, NULL, NULL);
}
if (e.jbutton.button == ServiceButtonDevice2)
{
helpers->WriteByte(Button2Address, button2read -= 0x08, false);
}
if (e.jbutton.button == Coin1ButtonDevice2)
{
helpers->WriteByte(Button2Address, button2read -= 0x01, false);
}
if (e.jbutton.button == Coin2ButtonDevice2)
{
helpers->WriteByte(Button2Address, button2read -= 0x02, false);
}
if (e.jbutton.button == VR1ButtonDevice2)
{
helpers->WriteByte(Button1Address, button1read -= 0x01, false);
}
if (e.jbutton.button == VR2ButtonDevice2)
{
helpers->WriteByte(Button1Address, button1read -= 0x02, false);
}
if (e.jbutton.button == ShiftUpButtonDevice2)
{
helpers->WriteByte(Button1Address, button1read -= 0x10, false);
}
if (e.jbutton.button == ShiftDownButtonDevice2)
{
helpers->WriteByte(Button1Address, button1read -= 0x20, false);
}
if (e.jbutton.button == StartButtonDevice2)
{
helpers->WriteByte(Button2Address, button2read -= 0x40, false);
}
}
}
if (e.type == SDL_JOYBUTTONUP)
{
if (e.jbutton.which == joystick_index1)
{
if (e.jbutton.button == TestButton)
{
helpers->WriteByte(Button2Address, button2read += 0x04, false);
}
if (e.jbutton.button == ServiceButton)
{
helpers->WriteByte(Button2Address, button2read += 0x08, false);
}
if (e.jbutton.button == Coin1Button)
{
helpers->WriteByte(Button2Address, button2read += 0x01, false);
}
if (e.jbutton.button == Coin2Button)
{
helpers->WriteByte(Button2Address, button2read += 0x02, false);
}
if (e.jbutton.button == VR1Button)
{
helpers->WriteByte(Button1Address, button1read += 0x01, false);
}
if (e.jbutton.button == VR2Button)
{
helpers->WriteByte(Button1Address, button1read += 0x02, false);
}
if (e.jbutton.button == ShiftUpButton)
{
helpers->WriteByte(Button1Address, button1read += 0x10, false);
}
if (e.jbutton.button == ShiftDownButton)
{
helpers->WriteByte(Button1Address, button1read += 0x20, false);
}
if (e.jbutton.button == StartButton)
{
helpers->WriteByte(Button2Address, button2read += 0x40, false);
}
}
else if (e.jbutton.which == joystick_index2)
{
if (e.jbutton.button == TestButtonDevice2)
{
helpers->WriteByte(Button2Address, button2read += 0x04, false);
}
if (e.jbutton.button == ServiceButtonDevice2)
{
helpers->WriteByte(Button2Address, button2read += 0x08, false);
}
if (e.jbutton.button == Coin1ButtonDevice2)
{
helpers->WriteByte(Button2Address, button2read += 0x01, false);
}
if (e.jbutton.button == Coin2ButtonDevice2)
{
helpers->WriteByte(Button2Address, button2read += 0x02, false);
}
if (e.jbutton.button == VR1ButtonDevice2)
{
helpers->WriteByte(Button1Address, button1read += 0x01, false);
}
if (e.jbutton.button == VR2ButtonDevice2)
{
helpers->WriteByte(Button1Address, button1read += 0x02, false);
}
if (e.jbutton.button == ShiftUpButtonDevice2)
{
helpers->WriteByte(Button1Address, button1read += 0x10, false);
}
if (e.jbutton.button == ShiftDownButtonDevice2)
{
helpers->WriteByte(Button1Address, button1read += 0x20, false);
}
if (e.jbutton.button == StartButtonDevice2)
{
helpers->WriteByte(Button2Address, button2read += 0x40, false);
}
}
}
}
}

File diff suppressed because it is too large Load Diff