Changes output reading and spring
This commit is contained in:
parent
bd4c03e140
commit
08d7a56a2a
10
DllMain.cpp
10
DllMain.cpp
@ -1675,8 +1675,8 @@ void TriggerSpringEffectWithDefaultOption(double strength, bool isDefault)
|
|||||||
|
|
||||||
tempEffect.condition.left_coeff[0] = (short)(coeff);
|
tempEffect.condition.left_coeff[0] = (short)(coeff);
|
||||||
tempEffect.condition.right_coeff[0] = (short)(coeff);
|
tempEffect.condition.right_coeff[0] = (short)(coeff);
|
||||||
tempEffect.condition.left_sat[0] = (short)(coeff); //Needed for Logitech G920 wheel
|
tempEffect.condition.left_sat[0] = (short)(coeff * 2.0); //Needed for Logitech G920 wheel
|
||||||
tempEffect.condition.right_sat[0] = (short)(coeff); //Needed for Logitech G920 wheel
|
tempEffect.condition.right_sat[0] = (short)(coeff * 2.0); //Needed for Logitech G920 wheel
|
||||||
tempEffect.condition.center[0] = 0;
|
tempEffect.condition.center[0] = 0;
|
||||||
|
|
||||||
SDL_HapticUpdateEffect(haptic, effects.effect_spring_id, &tempEffect);
|
SDL_HapticUpdateEffect(haptic, effects.effect_spring_id, &tempEffect);
|
||||||
@ -1707,8 +1707,8 @@ void TriggerSpringEffectInfinite(double strength)
|
|||||||
|
|
||||||
tempEffect.condition.left_coeff[0] = (short)(coeff);
|
tempEffect.condition.left_coeff[0] = (short)(coeff);
|
||||||
tempEffect.condition.right_coeff[0] = (short)(coeff);
|
tempEffect.condition.right_coeff[0] = (short)(coeff);
|
||||||
tempEffect.condition.left_sat[0] = (short)(coeff) * 10; //Needed for Logitech G920 wheel
|
tempEffect.condition.left_sat[0] = (short)(coeff * 2.0); //Needed for Logitech G920 wheel
|
||||||
tempEffect.condition.right_sat[0] = (short)(coeff) * 10; //Needed for Logitech G920 wheel
|
tempEffect.condition.right_sat[0] = (short)(coeff * 2.0); //Needed for Logitech G920 wheel
|
||||||
tempEffect.condition.center[0] = 0;
|
tempEffect.condition.center[0] = 0;
|
||||||
|
|
||||||
SDL_HapticUpdateEffect(haptic, effects.effect_spring_id, &tempEffect);
|
SDL_HapticUpdateEffect(haptic, effects.effect_spring_id, &tempEffect);
|
||||||
@ -2911,6 +2911,8 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ulReasonForCall, LPVOID lpReserved)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);
|
||||||
|
|
||||||
hlp.log("creating ffb loop thread...");
|
hlp.log("creating ffb loop thread...");
|
||||||
CreateFFBLoopThread();
|
CreateFFBLoopThread();
|
||||||
if (BeepWhenHook == 1)
|
if (BeepWhenHook == 1)
|
||||||
|
@ -785,41 +785,6 @@ int __stdcall mame_output(const char* name, int value)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool __stdcall ExitHook(UINT uExitCode)
|
|
||||||
{
|
|
||||||
TerminateProcess(GetCurrentProcess(), 0);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool Hook(void* toHook, void* ourFunct, int len) {
|
|
||||||
|
|
||||||
if (len < 5) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
DWORD curProtection;
|
|
||||||
VirtualProtect(toHook, len, PAGE_EXECUTE_READWRITE, &curProtection);
|
|
||||||
|
|
||||||
memset(toHook, 0x90, len);
|
|
||||||
|
|
||||||
#ifdef _WIN64
|
|
||||||
DWORD64 relativeAddress = ((DWORD64)ourFunct - (DWORD64)toHook) - 5;
|
|
||||||
|
|
||||||
*(DWORD64*)toHook = 0xE9;
|
|
||||||
*(DWORD64*)((DWORD64)toHook + 1) = relativeAddress;
|
|
||||||
#else
|
|
||||||
DWORD relativeAddress = ((DWORD)ourFunct - (DWORD)toHook) - 5;
|
|
||||||
|
|
||||||
*(DWORD*)toHook = 0xE9;
|
|
||||||
*(DWORD*)((DWORD)toHook + 1) = relativeAddress;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
DWORD temp;
|
|
||||||
VirtualProtect(toHook, len, curProtection, &temp);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static BOOL CALLBACK FindWindowBySubstr(HWND hwnd, LPARAM substring)
|
static BOOL CALLBACK FindWindowBySubstr(HWND hwnd, LPARAM substring)
|
||||||
{
|
{
|
||||||
const DWORD TITLE_SIZE = 1024;
|
const DWORD TITLE_SIZE = 1024;
|
||||||
@ -1077,26 +1042,11 @@ std::string MAME("MAME");
|
|||||||
std::string Supermodel("Supermodel");
|
std::string Supermodel("Supermodel");
|
||||||
|
|
||||||
void OutputReading::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTriggers* triggers) {
|
void OutputReading::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTriggers* triggers) {
|
||||||
|
|
||||||
if (!init)
|
if (!init)
|
||||||
{
|
{
|
||||||
CreateThread(NULL, 0, ThreadForOutputs, NULL, 0, NULL);
|
CreateThread(NULL, 0, ThreadForOutputs, NULL, 0, NULL);
|
||||||
|
|
||||||
HMODULE hMod = GetModuleHandleA("KERNEL32.dll");
|
|
||||||
if (hMod)
|
|
||||||
{
|
|
||||||
int hookLength = 6;
|
|
||||||
#ifdef _WIN64
|
|
||||||
DWORD64 hookAddress = (DWORD64)GetProcAddress(GetModuleHandle(L"KERNEL32.dll"), "ExitProcess");
|
|
||||||
#else
|
|
||||||
DWORD hookAddress = (DWORD)GetProcAddress(GetModuleHandle(L"KERNEL32.dll"), "ExitProcess");
|
|
||||||
#endif
|
|
||||||
if (hookAddress)
|
|
||||||
{
|
|
||||||
Hook((void*)hookAddress, ExitHook, hookLength);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
wchar_t* deviceGUIDString2 = new wchar_t[256];
|
wchar_t* deviceGUIDString2 = new wchar_t[256];
|
||||||
int Device2GUID = GetPrivateProfileString(TEXT("Settings"), TEXT("Device2GUID"), NULL, deviceGUIDString2, 256, settingsFilename);
|
int Device2GUID = GetPrivateProfileString(TEXT("Settings"), TEXT("Device2GUID"), NULL, deviceGUIDString2, 256, settingsFilename);
|
||||||
char joystick_guid[256];
|
char joystick_guid[256];
|
||||||
@ -1888,7 +1838,6 @@ void OutputReading::FFBLoop(EffectConstants* constants, Helpers* helpers, Effect
|
|||||||
|
|
||||||
if (name == RawDrive)
|
if (name == RawDrive)
|
||||||
{
|
{
|
||||||
|
|
||||||
helpers->log("got value: ");
|
helpers->log("got value: ");
|
||||||
std::string ffs = std::to_string(newstateFFB);
|
std::string ffs = std::to_string(newstateFFB);
|
||||||
helpers->log((char*)ffs.c_str());
|
helpers->log((char*)ffs.c_str());
|
||||||
@ -2160,28 +2109,21 @@ void OutputReading::FFBLoop(EffectConstants* constants, Helpers* helpers, Effect
|
|||||||
stateFFB = newstateFFB;
|
stateFFB = newstateFFB;
|
||||||
}
|
}
|
||||||
|
|
||||||
UINT8 static oldff = 0;
|
if ((stateFFB > 0x80) && (stateFFB < 0x100))
|
||||||
UINT8 newff = stateFFB;
|
|
||||||
|
|
||||||
if (oldff != newff)
|
|
||||||
{
|
{
|
||||||
if ((stateFFB > 0x80) && (stateFFB < 0x100))
|
double percentForce = (256 - stateFFB) / 127.0;
|
||||||
{
|
double percentLength = 100;
|
||||||
double percentForce = (256 - stateFFB) / 127.0;
|
triggers->Rumble(0, percentForce, percentLength);
|
||||||
double percentLength = 100;
|
triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce);
|
||||||
triggers->Rumble(0, percentForce, percentLength);
|
|
||||||
triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce);
|
|
||||||
}
|
|
||||||
else if ((stateFFB > 0x00) && (stateFFB < 0x80))
|
|
||||||
{
|
|
||||||
double percentForce = (stateFFB) / 127.0;
|
|
||||||
double percentLength = 100;
|
|
||||||
triggers->Rumble(percentForce, 0, percentLength);
|
|
||||||
triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
oldff = newff;
|
else if ((stateFFB > 0x00) && (stateFFB < 0x80))
|
||||||
}
|
{
|
||||||
|
double percentForce = (stateFFB) / 127.0;
|
||||||
|
double percentLength = 100;
|
||||||
|
triggers->Rumble(percentForce, 0, percentLength);
|
||||||
|
triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RunningFFB == RacingFullValueActive2) //Mame games using all values (reverse direction to above)
|
if (RunningFFB == RacingFullValueActive2) //Mame games using all values (reverse direction to above)
|
||||||
@ -2197,28 +2139,21 @@ void OutputReading::FFBLoop(EffectConstants* constants, Helpers* helpers, Effect
|
|||||||
stateFFB = newstateFFB;
|
stateFFB = newstateFFB;
|
||||||
}
|
}
|
||||||
|
|
||||||
UINT8 static oldff = 0;
|
if ((stateFFB > 0x80) && (stateFFB < 0x100))
|
||||||
UINT8 newff = stateFFB;
|
|
||||||
|
|
||||||
if (oldff != newff)
|
|
||||||
{
|
{
|
||||||
if ((stateFFB > 0x80) && (stateFFB < 0x100))
|
double percentForce = (256 - stateFFB) / 127.0;
|
||||||
{
|
double percentLength = 100;
|
||||||
double percentForce = (256 - stateFFB) / 127.0;
|
triggers->Rumble(0, percentForce, percentLength);
|
||||||
double percentLength = 100;
|
triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce);
|
||||||
triggers->Rumble(0, percentForce, percentLength);
|
|
||||||
triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce);
|
|
||||||
}
|
|
||||||
else if ((stateFFB > 0x00) && (stateFFB < 0x80))
|
|
||||||
{
|
|
||||||
double percentForce = (stateFFB) / 127.0;
|
|
||||||
double percentLength = 100;
|
|
||||||
triggers->Rumble(percentForce, 0, percentLength);
|
|
||||||
triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
oldff = newff;
|
else if ((stateFFB > 0x00) && (stateFFB < 0x80))
|
||||||
}
|
{
|
||||||
|
double percentForce = (stateFFB) / 127.0;
|
||||||
|
double percentLength = 100;
|
||||||
|
triggers->Rumble(percentForce, 0, percentLength);
|
||||||
|
triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RunningFFB == LightGunActive) //LightGun Games
|
if (RunningFFB == LightGunActive) //LightGun Games
|
||||||
|
Loading…
Reference in New Issue
Block a user