commit
b8a8058225
1
.gitignore
vendored
1
.gitignore
vendored
@ -18,3 +18,4 @@ TeknoParrot/TeknoParrot\.vcxproj\.user
|
|||||||
ParrotLoader/ParrotLoader\.vcxproj\.user
|
ParrotLoader/ParrotLoader\.vcxproj\.user
|
||||||
|
|
||||||
*.user
|
*.user
|
||||||
|
*.aps
|
@ -7,7 +7,7 @@ project "OpenParrot"
|
|||||||
{
|
{
|
||||||
"src/**.cpp", "src/**.h",
|
"src/**.cpp", "src/**.h",
|
||||||
"deps/cpp/**.cpp", "deps/inc/**.h",
|
"deps/cpp/**.cpp", "deps/inc/**.h",
|
||||||
"src/OpenParrot.aps", "src/OpenParrot.rc"
|
"src/OpenParrot.rc"
|
||||||
}
|
}
|
||||||
|
|
||||||
includedirs { "src", "deps/inc/" }
|
includedirs { "src", "deps/inc/" }
|
||||||
|
@ -40,16 +40,13 @@ DWORD WINAPI QuitGameThread(__in LPVOID lpParameter)
|
|||||||
{
|
{
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
if ((GameDetect::currentGame == GameID::Daytona3) && (GetAsyncKeyState(VK_ESCAPE)))
|
if (GetAsyncKeyState(VK_ESCAPE))
|
||||||
{
|
|
||||||
#ifndef _DEBUG
|
|
||||||
system("taskkill /f /im InpWrapper.exe");
|
|
||||||
TerminateProcess(GetCurrentProcess(), 0);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else if (GetAsyncKeyState(VK_ESCAPE))
|
|
||||||
{
|
{
|
||||||
#ifndef _DEBUG
|
#ifndef _DEBUG
|
||||||
|
if (GameDetect::currentGame == GameID::Daytona3)
|
||||||
|
{
|
||||||
|
system("taskkill /f /im InpWrapper.exe");
|
||||||
|
}
|
||||||
TerminateProcess(GetCurrentProcess(), 0);
|
TerminateProcess(GetCurrentProcess(), 0);
|
||||||
#endif
|
#endif
|
||||||
//ExitProcess(0);
|
//ExitProcess(0);
|
||||||
|
@ -53,7 +53,7 @@ int __cdecl iDmacDrvRegisterRead(int DeviceId, DWORD CommandCode, LPVOID OutBuff
|
|||||||
result = 0x00FF00FF;
|
result = 0x00FF00FF;
|
||||||
break;
|
break;
|
||||||
case 0x4004:
|
case 0x4004:
|
||||||
if(GameDetect::currentGame == GameID::DariusBurst)
|
if (GameDetect::currentGame == GameID::DariusBurst)
|
||||||
{
|
{
|
||||||
// I/O error without this switch
|
// I/O error without this switch
|
||||||
result = 0x00FF00FF;
|
result = 0x00FF00FF;
|
||||||
|
@ -481,11 +481,7 @@ void NesysEmu::Initialize(bool isDarius)
|
|||||||
{
|
{
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
HANDLE pipe;
|
HANDLE pipe = CreateNamedPipeW(isDarius ? L"\\\\.\\pipe\\nesystest" : L"\\\\.\\pipe\\nesys_games", PIPE_ACCESS_DUPLEX, PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT, PIPE_UNLIMITED_INSTANCES, 8192, 8192, 0, nullptr);
|
||||||
if(!isDarius)
|
|
||||||
pipe = CreateNamedPipeW(L"\\\\.\\pipe\\nesys_games", PIPE_ACCESS_DUPLEX, PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT, PIPE_UNLIMITED_INSTANCES, 8192, 8192, 0, nullptr);
|
|
||||||
else
|
|
||||||
pipe = CreateNamedPipeW(L"\\\\.\\pipe\\nesystest", PIPE_ACCESS_DUPLEX, PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT, PIPE_UNLIMITED_INSTANCES, 8192, 8192, 0, nullptr);
|
|
||||||
|
|
||||||
if (pipe == INVALID_HANDLE_VALUE)
|
if (pipe == INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
|
@ -144,10 +144,10 @@ public:
|
|||||||
for (DWORD i = sizeaddr; i<xpos; i++)
|
for (DWORD i = sizeaddr; i<xpos; i++)
|
||||||
if (buffer[i] != 0xD0)
|
if (buffer[i] != 0xD0)
|
||||||
++sizeK;
|
++sizeK;
|
||||||
// codifica o tamanho da stream
|
// encode the size of the stream
|
||||||
buffer[sizeaddr] = sizeK;
|
buffer[sizeaddr] = sizeK;
|
||||||
|
|
||||||
// calcula o checksum
|
// calculate the checksum
|
||||||
DWORD sum = 0;
|
DWORD sum = 0;
|
||||||
for (DWORD i = sumaddr, inc = 0; i<xpos; i++) {
|
for (DWORD i = sumaddr, inc = 0; i<xpos; i++) {
|
||||||
if (buffer[i] == 0xD0) {
|
if (buffer[i] == 0xD0) {
|
||||||
|
@ -1,367 +1,361 @@
|
|||||||
#pragma optimize("", off)
|
#pragma optimize("", off)
|
||||||
#include "StdInc.h"
|
#include "StdInc.h"
|
||||||
#include "Utility/GameDetect.h"
|
#include "Utility/GameDetect.h"
|
||||||
#include "Utility/InitFunction.h"
|
#include "Utility/InitFunction.h"
|
||||||
#include "PokkenXInputEmu.h"
|
#include "XInputEmu.h"
|
||||||
|
|
||||||
struct XboxOneControllerHandler
|
struct XboxOneControllerHandler
|
||||||
{
|
{
|
||||||
struct usb_dev_handle *handle;
|
struct usb_dev_handle *handle;
|
||||||
bool isConnected;
|
bool isConnected;
|
||||||
XBOXONE_STATE controllerState;
|
XBOXONE_STATE controllerState;
|
||||||
|
|
||||||
uint8_t lastState[64];
|
uint8_t lastState[64];
|
||||||
unsigned int tickCount;
|
unsigned int tickCount;
|
||||||
|
|
||||||
XINPUT_GAMEPAD lastGamepadState;
|
XINPUT_GAMEPAD lastGamepadState;
|
||||||
};
|
};
|
||||||
|
|
||||||
XboxOneControllerHandler *controllerHandler[4] = { NULL, NULL, NULL, NULL };
|
XboxOneControllerHandler *controllerHandler[4] = { NULL, NULL, NULL, NULL };
|
||||||
HANDLE XboxOneControllerThread[4] = { 0 };
|
HANDLE XboxOneControllerThread[4] = { 0 };
|
||||||
HANDLE XboxOneControllerMutex[4] = { 0 };
|
HANDLE XboxOneControllerMutex[4] = { 0 };
|
||||||
|
|
||||||
static unsigned short idVendor = 0x045E;
|
static unsigned short idVendor = 0x045E;
|
||||||
static unsigned short idProduct = 0x02D1;
|
static unsigned short idProduct = 0x02D1;
|
||||||
|
|
||||||
int configuration = 1;
|
int configuration = 1;
|
||||||
int interface = 0;
|
int interface = 0;
|
||||||
int endpointIn = 0x81;
|
int endpointIn = 0x81;
|
||||||
int endpointOut = 0x01;
|
int endpointOut = 0x01;
|
||||||
int timeout = 2000; // milliseconds
|
int timeout = 2000; // milliseconds
|
||||||
bool controllerInit = false;
|
bool controllerInit = false;
|
||||||
bool runThread = true;
|
bool runThread = true;
|
||||||
|
|
||||||
// Structure we receive from the controller
|
// Structure we receive from the controller
|
||||||
struct XboxOneControllerState
|
struct XboxOneControllerState
|
||||||
{
|
{
|
||||||
char eventCount;
|
char eventCount;
|
||||||
char unknown;
|
char unknown;
|
||||||
char buttons1;
|
char buttons1;
|
||||||
char buttons2;
|
char buttons2;
|
||||||
short leftTrigger; // Triggers are 0 - 1023
|
short leftTrigger; // Triggers are 0 - 1023
|
||||||
short rightTrigger;
|
short rightTrigger;
|
||||||
short thumbLX; // Axes are -32767 - 32767
|
short thumbLX; // Axes are -32767 - 32767
|
||||||
short thumbLY;
|
short thumbLY;
|
||||||
short thumbRX;
|
short thumbRX;
|
||||||
short thumbRY;
|
short thumbRY;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool connectController(bool enable)
|
bool connectController(bool enable)
|
||||||
{
|
{
|
||||||
controllerInit = enable;
|
controllerInit = enable;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int iround(double num) {
|
int iround(double num) {
|
||||||
return (num > 0.0) ? (int)floor(num + 0.5) : (int)ceil(num - 0.5);
|
return (num > 0.0) ? (int)floor(num + 0.5) : (int)ceil(num - 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int* ffbOffset;
|
extern int* ffbOffset;
|
||||||
extern int* ffbOffset2;
|
extern int* ffbOffset2;
|
||||||
|
|
||||||
DWORD WINAPI XInputGetState
|
DWORD WINAPI XInputGetState
|
||||||
(
|
(
|
||||||
__in DWORD dwUserIndex, // Index of the gamer associated with the device
|
__in DWORD dwUserIndex, // Index of the gamer associated with the device
|
||||||
__out XINPUT_STATE* pState // Receives the current state
|
__out XINPUT_STATE* pState // Receives the current state
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (!controllerInit)
|
if (!controllerInit)
|
||||||
{
|
{
|
||||||
connectController(true);
|
connectController(true);
|
||||||
}
|
}
|
||||||
if (controllerInit && dwUserIndex == 0)
|
if (controllerInit && dwUserIndex == 0)
|
||||||
{
|
{
|
||||||
XINPUT_GAMEPAD gamepadState = { 0 };
|
XINPUT_GAMEPAD gamepadState = { 0 };
|
||||||
|
|
||||||
if (GameDetect::currentGame == GameID::Daytona3 || GameDetect::currentGame == GameID::PokkenTournament)
|
if (GameDetect::currentGame == GameID::Daytona3 || GameDetect::currentGame == GameID::PokkenTournament)
|
||||||
gamepadState.wButtons |= *ffbOffset;
|
gamepadState.wButtons |= *ffbOffset;
|
||||||
else
|
else
|
||||||
gamepadState.wButtons |= 0;
|
gamepadState.wButtons |= 0;
|
||||||
#ifdef _M_IX86
|
#ifdef _M_IX86
|
||||||
if (GameDetect::currentGame == GameID::Daytona3)
|
if (GameDetect::currentGame == GameID::Daytona3)
|
||||||
{
|
{
|
||||||
gamepadState.bRightTrigger = daytonaPressStart ? 0xFF : 0x00;
|
gamepadState.bRightTrigger = daytonaPressStart ? 0xFF : 0x00;
|
||||||
}
|
gamepadState.sThumbLX |= (-(33024 - *ffbOffset2) * 255);
|
||||||
if (GameDetect::currentGame == GameID::Daytona3)
|
}
|
||||||
{
|
#endif
|
||||||
gamepadState.sThumbLX |= (-(33024 - *ffbOffset2) * 255);
|
if (pState->dwPacketNumber == UINT_MAX)
|
||||||
}
|
pState->dwPacketNumber = 0;
|
||||||
#endif
|
else
|
||||||
if (pState->dwPacketNumber == UINT_MAX)
|
pState->dwPacketNumber++;
|
||||||
pState->dwPacketNumber = 0;
|
|
||||||
else
|
pState->Gamepad = gamepadState;
|
||||||
pState->dwPacketNumber++;
|
return ERROR_SUCCESS;
|
||||||
|
}
|
||||||
pState->Gamepad = gamepadState;
|
else
|
||||||
return ERROR_SUCCESS;
|
{
|
||||||
}
|
return ERROR_DEVICE_NOT_CONNECTED;
|
||||||
else
|
}
|
||||||
{
|
}
|
||||||
return ERROR_DEVICE_NOT_CONNECTED;
|
|
||||||
}
|
DWORD WINAPI XInputSetState
|
||||||
}
|
(
|
||||||
|
__in DWORD dwUserIndex, // Index of the gamer associated with the device
|
||||||
DWORD WINAPI XInputSetState
|
__in XINPUT_VIBRATION* pVibration // The vibration information to send to the controller
|
||||||
(
|
)
|
||||||
__in DWORD dwUserIndex, // Index of the gamer associated with the device
|
{
|
||||||
__in XINPUT_VIBRATION* pVibration // The vibration information to send to the controller
|
if (!controllerInit)
|
||||||
)
|
{
|
||||||
{
|
connectController(true);
|
||||||
if (!controllerInit)
|
}
|
||||||
{
|
|
||||||
connectController(true);
|
if (controllerInit && dwUserIndex == 0)
|
||||||
}
|
{
|
||||||
|
// We're receiving as XInput [0 ~ 65535], need to be [0 ~ 255] !!
|
||||||
if (controllerInit && dwUserIndex == 0)
|
int leftVal = iround(((float)pVibration->wLeftMotorSpeed / 65535) * 255);
|
||||||
{
|
int rightVal = iround(((float)pVibration->wRightMotorSpeed / 65535) * 255);
|
||||||
// We're receiving as XInput [0 ~ 65535], need to be [0 ~ 255] !!
|
return ERROR_SUCCESS;
|
||||||
int leftVal = iround(((float)pVibration->wLeftMotorSpeed / 65535) * 255);
|
}
|
||||||
int rightVal = iround(((float)pVibration->wRightMotorSpeed / 65535) * 255);
|
else
|
||||||
return ERROR_SUCCESS;
|
{
|
||||||
}
|
return ERROR_DEVICE_NOT_CONNECTED;
|
||||||
else
|
}
|
||||||
{
|
}
|
||||||
return ERROR_DEVICE_NOT_CONNECTED;
|
|
||||||
}
|
DWORD WINAPI XInputGetCapabilities
|
||||||
}
|
(
|
||||||
|
__in DWORD dwUserIndex, // Index of the gamer associated with the device
|
||||||
DWORD WINAPI XInputGetCapabilities
|
__in DWORD dwFlags, // Input flags that identify the device type
|
||||||
(
|
__out XINPUT_CAPABILITIES* pCapabilities // Receives the capabilities
|
||||||
__in DWORD dwUserIndex, // Index of the gamer associated with the device
|
)
|
||||||
__in DWORD dwFlags, // Input flags that identify the device type
|
{
|
||||||
__out XINPUT_CAPABILITIES* pCapabilities // Receives the capabilities
|
if (!controllerInit)
|
||||||
)
|
{
|
||||||
{
|
connectController(true);
|
||||||
if (!controllerInit)
|
}
|
||||||
{
|
|
||||||
connectController(true);
|
if (dwFlags > XINPUT_FLAG_GAMEPAD)
|
||||||
}
|
{
|
||||||
|
return ERROR_BAD_ARGUMENTS;
|
||||||
if (dwFlags > XINPUT_FLAG_GAMEPAD)
|
}
|
||||||
{
|
|
||||||
return ERROR_BAD_ARGUMENTS;
|
if (controllerInit && dwUserIndex == 0)
|
||||||
}
|
{
|
||||||
|
pCapabilities->Flags = XINPUT_CAPS_VOICE_SUPPORTED;
|
||||||
if (controllerInit && dwUserIndex == 0)
|
pCapabilities->Type = XINPUT_DEVTYPE_GAMEPAD;
|
||||||
{
|
pCapabilities->SubType = XINPUT_DEVSUBTYPE_GAMEPAD;
|
||||||
pCapabilities->Flags = XINPUT_CAPS_VOICE_SUPPORTED;
|
|
||||||
pCapabilities->Type = XINPUT_DEVTYPE_GAMEPAD;
|
pCapabilities->Gamepad.wButtons = 0xF3FF;
|
||||||
pCapabilities->SubType = XINPUT_DEVSUBTYPE_GAMEPAD;
|
|
||||||
|
pCapabilities->Gamepad.bLeftTrigger = 0xFF;
|
||||||
pCapabilities->Gamepad.wButtons = 0xF3FF;
|
pCapabilities->Gamepad.bRightTrigger = 0xFF;
|
||||||
|
|
||||||
pCapabilities->Gamepad.bLeftTrigger = 0xFF;
|
pCapabilities->Gamepad.sThumbLX = (SHORT)0xFFC0;
|
||||||
pCapabilities->Gamepad.bRightTrigger = 0xFF;
|
pCapabilities->Gamepad.sThumbLY = (SHORT)0xFFC0;
|
||||||
|
pCapabilities->Gamepad.sThumbRX = (SHORT)0xFFC0;
|
||||||
pCapabilities->Gamepad.sThumbLX = (SHORT)0xFFC0;
|
pCapabilities->Gamepad.sThumbRY = (SHORT)0xFFC0;
|
||||||
pCapabilities->Gamepad.sThumbLY = (SHORT)0xFFC0;
|
|
||||||
pCapabilities->Gamepad.sThumbRX = (SHORT)0xFFC0;
|
pCapabilities->Vibration.wLeftMotorSpeed = 0xFF;
|
||||||
pCapabilities->Gamepad.sThumbRY = (SHORT)0xFFC0;
|
pCapabilities->Vibration.wRightMotorSpeed = 0xFF;
|
||||||
|
|
||||||
pCapabilities->Vibration.wLeftMotorSpeed = 0xFF;
|
return ERROR_SUCCESS;
|
||||||
pCapabilities->Vibration.wRightMotorSpeed = 0xFF;
|
}
|
||||||
|
else
|
||||||
return ERROR_SUCCESS;
|
{
|
||||||
}
|
return ERROR_DEVICE_NOT_CONNECTED;
|
||||||
else
|
}
|
||||||
{
|
}
|
||||||
return ERROR_DEVICE_NOT_CONNECTED;
|
|
||||||
}
|
void WINAPI XInputEnable
|
||||||
}
|
(
|
||||||
|
__in bool enable // [in] Indicates whether xinput is enabled or disabled.
|
||||||
void WINAPI XInputEnable
|
)
|
||||||
(
|
{
|
||||||
__in bool enable // [in] Indicates whether xinput is enabled or disabled.
|
if (!controllerInit)
|
||||||
)
|
{
|
||||||
{
|
connectController(true);
|
||||||
if (!controllerInit)
|
}
|
||||||
{
|
|
||||||
connectController(true);
|
if (controllerInit && !enable)
|
||||||
}
|
{
|
||||||
|
XINPUT_VIBRATION Vibration = { 0, 0 };
|
||||||
if (controllerInit && !enable)
|
int xboxControllerCounter = 0;
|
||||||
{
|
|
||||||
XINPUT_VIBRATION Vibration = { 0, 0 };
|
while (xboxControllerCounter < 4)
|
||||||
int xboxControllerCounter = 0;
|
{
|
||||||
|
if (controllerHandler[xboxControllerCounter])
|
||||||
while (xboxControllerCounter < 4)
|
{
|
||||||
{
|
XInputSetState(xboxControllerCounter, &Vibration);
|
||||||
if (controllerHandler[xboxControllerCounter])
|
}
|
||||||
{
|
xboxControllerCounter++;
|
||||||
XInputSetState(xboxControllerCounter, &Vibration);
|
}
|
||||||
}
|
}
|
||||||
xboxControllerCounter++;
|
}
|
||||||
}
|
|
||||||
}
|
DWORD WINAPI XInputGetDSoundAudioDeviceGuids
|
||||||
}
|
(
|
||||||
|
__in DWORD dwUserIndex, // Index of the gamer associated with the device
|
||||||
DWORD WINAPI XInputGetDSoundAudioDeviceGuids
|
__out GUID* pDSoundRenderGuid, // DSound device ID for render
|
||||||
(
|
__out GUID* pDSoundCaptureGuid // DSound device ID for capture
|
||||||
__in DWORD dwUserIndex, // Index of the gamer associated with the device
|
)
|
||||||
__out GUID* pDSoundRenderGuid, // DSound device ID for render
|
{
|
||||||
__out GUID* pDSoundCaptureGuid // DSound device ID for capture
|
if (!controllerInit)
|
||||||
)
|
{
|
||||||
{
|
connectController(true);
|
||||||
if (!controllerInit)
|
}
|
||||||
{
|
|
||||||
connectController(true);
|
if (controllerInit && dwUserIndex == 0)
|
||||||
}
|
{
|
||||||
|
pDSoundRenderGuid = NULL;
|
||||||
if (controllerInit && dwUserIndex == 0)
|
pDSoundCaptureGuid = NULL;
|
||||||
{
|
|
||||||
pDSoundRenderGuid = NULL;
|
return ERROR_SUCCESS;
|
||||||
pDSoundCaptureGuid = NULL;
|
}
|
||||||
|
else
|
||||||
return ERROR_SUCCESS;
|
{
|
||||||
}
|
return ERROR_DEVICE_NOT_CONNECTED;
|
||||||
else
|
}
|
||||||
{
|
}
|
||||||
return ERROR_DEVICE_NOT_CONNECTED;
|
|
||||||
}
|
DWORD XInputGetBatteryInformation
|
||||||
}
|
(
|
||||||
|
__in DWORD dwUserIndex, // Index of the gamer associated with the device
|
||||||
DWORD XInputGetBatteryInformation
|
__in BYTE devType, // Which device on this user index
|
||||||
(
|
__out XINPUT_BATTERY_INFORMATION* pBatteryInformation // Contains the level and types of batteries
|
||||||
__in DWORD dwUserIndex, // Index of the gamer associated with the device
|
)
|
||||||
__in BYTE devType, // Which device on this user index
|
{
|
||||||
__out XINPUT_BATTERY_INFORMATION* pBatteryInformation // Contains the level and types of batteries
|
if (!controllerInit)
|
||||||
)
|
{
|
||||||
{
|
connectController(true);
|
||||||
if (!controllerInit)
|
}
|
||||||
{
|
|
||||||
connectController(true);
|
if (controllerInit && dwUserIndex == 0)
|
||||||
}
|
{
|
||||||
|
pBatteryInformation->BatteryType = BATTERY_TYPE_WIRED;
|
||||||
if (controllerInit && dwUserIndex == 0)
|
pBatteryInformation->BatteryLevel = BATTERY_LEVEL_FULL;
|
||||||
{
|
return ERROR_SUCCESS;
|
||||||
pBatteryInformation->BatteryType = BATTERY_TYPE_WIRED;
|
}
|
||||||
pBatteryInformation->BatteryLevel = BATTERY_LEVEL_FULL;
|
else
|
||||||
return ERROR_SUCCESS;
|
{
|
||||||
}
|
return ERROR_DEVICE_NOT_CONNECTED;
|
||||||
else
|
}
|
||||||
{
|
}
|
||||||
return ERROR_DEVICE_NOT_CONNECTED;
|
|
||||||
}
|
DWORD WINAPI XInputGetKeystroke
|
||||||
}
|
(
|
||||||
|
__in DWORD dwUserIndex, // Index of the gamer associated with the device
|
||||||
DWORD WINAPI XInputGetKeystroke
|
__reserved DWORD dwReserved, // Reserved for future use
|
||||||
(
|
__out PXINPUT_KEYSTROKE pKeystroke // Pointer to an XINPUT_KEYSTROKE structure that receives an input event.
|
||||||
__in DWORD dwUserIndex, // Index of the gamer associated with the device
|
)
|
||||||
__reserved DWORD dwReserved, // Reserved for future use
|
{
|
||||||
__out PXINPUT_KEYSTROKE pKeystroke // Pointer to an XINPUT_KEYSTROKE structure that receives an input event.
|
if (!controllerInit)
|
||||||
)
|
{
|
||||||
{
|
connectController(true);
|
||||||
if (!controllerInit)
|
}
|
||||||
{
|
|
||||||
connectController(true);
|
if (controllerInit && dwUserIndex == 0)
|
||||||
}
|
{
|
||||||
|
return ERROR_EMPTY; // or ERROR_SUCCESS
|
||||||
if (controllerInit && dwUserIndex == 0)
|
}
|
||||||
{
|
else
|
||||||
return ERROR_EMPTY; // or ERROR_SUCCESS
|
{
|
||||||
}
|
return ERROR_DEVICE_NOT_CONNECTED;
|
||||||
else
|
}
|
||||||
{
|
}
|
||||||
return ERROR_DEVICE_NOT_CONNECTED;
|
|
||||||
}
|
DWORD WINAPI XInputGetStateEx
|
||||||
}
|
(
|
||||||
|
__in DWORD dwUserIndex, // Index of the gamer associated with the device
|
||||||
DWORD WINAPI XInputGetStateEx
|
__out XINPUT_STATE* pState // Receives the current state
|
||||||
(
|
)
|
||||||
__in DWORD dwUserIndex, // Index of the gamer associated with the device
|
{
|
||||||
__out XINPUT_STATE* pState // Receives the current state
|
if (!controllerInit)
|
||||||
)
|
{
|
||||||
{
|
connectController(true);
|
||||||
if (!controllerInit)
|
}
|
||||||
{
|
if (controllerInit && dwUserIndex == 0)
|
||||||
connectController(true);
|
{
|
||||||
}
|
XINPUT_GAMEPAD gamepadState = { 0 };
|
||||||
if (controllerInit && dwUserIndex == 0)
|
|
||||||
{
|
if (GameDetect::currentGame == GameID::Daytona3 || GameDetect::currentGame == GameID::PokkenTournament)
|
||||||
XINPUT_GAMEPAD gamepadState = { 0 };
|
gamepadState.wButtons = *ffbOffset;
|
||||||
|
else
|
||||||
if (GameDetect::currentGame == GameID::Daytona3 || GameDetect::currentGame == GameID::PokkenTournament)
|
gamepadState.wButtons = 0;
|
||||||
gamepadState.wButtons = *ffbOffset;
|
|
||||||
else
|
#ifdef _M_IX86
|
||||||
gamepadState.wButtons = 0;
|
if (GameDetect::currentGame == GameID::Daytona3)
|
||||||
|
{
|
||||||
#ifdef _M_IX86
|
gamepadState.bRightTrigger = daytonaPressStart ? 0xFF : 0x00;
|
||||||
if (GameDetect::currentGame == GameID::Daytona3)
|
gamepadState.sThumbLX |= (-(33024 - *ffbOffset2) * 255);
|
||||||
{
|
}
|
||||||
gamepadState.bRightTrigger = daytonaPressStart ? 0xFF : 0x00;
|
#endif
|
||||||
}
|
if (pState->dwPacketNumber == UINT_MAX)
|
||||||
if (GameDetect::currentGame == GameID::Daytona3)
|
pState->dwPacketNumber = 0;
|
||||||
{
|
else
|
||||||
gamepadState.sThumbLX |= (-(33024 - *ffbOffset2) * 255);
|
pState->dwPacketNumber++;
|
||||||
}
|
pState->Gamepad = gamepadState;
|
||||||
#endif
|
return ERROR_SUCCESS;
|
||||||
if (pState->dwPacketNumber == UINT_MAX)
|
}
|
||||||
pState->dwPacketNumber = 0;
|
else
|
||||||
else
|
{
|
||||||
pState->dwPacketNumber++;
|
return ERROR_DEVICE_NOT_CONNECTED;
|
||||||
pState->Gamepad = gamepadState;
|
}
|
||||||
return ERROR_SUCCESS;
|
}
|
||||||
}
|
|
||||||
else
|
DWORD WINAPI XInputSetStateEx
|
||||||
{
|
(
|
||||||
return ERROR_DEVICE_NOT_CONNECTED;
|
__in DWORD dwUserIndex, // Index of the gamer associated with the device
|
||||||
}
|
__in XINPUT_VIBRATION_EX* pVibration // The vibration information to send to the controller
|
||||||
}
|
)
|
||||||
|
{
|
||||||
DWORD WINAPI XInputSetStateEx
|
if (!controllerInit)
|
||||||
(
|
{
|
||||||
__in DWORD dwUserIndex, // Index of the gamer associated with the device
|
connectController(true);
|
||||||
__in XINPUT_VIBRATION_EX* pVibration // The vibration information to send to the controller
|
}
|
||||||
)
|
|
||||||
{
|
if (controllerInit && dwUserIndex == 0)
|
||||||
if (!controllerInit)
|
{
|
||||||
{
|
int leftTriggerVal = iround(((float)pVibration->wLeftTriggerMotorSpeed / 65535) * 255);
|
||||||
connectController(true);
|
int rightTriggerVal = iround(((float)pVibration->wRightTriggerMotorSpeed / 65535) * 255);
|
||||||
}
|
int leftVal = iround(((float)pVibration->wLeftMotorSpeed / 65535) * 255);
|
||||||
|
int rightVal = iround(((float)pVibration->wRightMotorSpeed / 65535) * 255);
|
||||||
if (controllerInit && dwUserIndex == 0)
|
|
||||||
{
|
return ERROR_SUCCESS;
|
||||||
int leftTriggerVal = iround(((float)pVibration->wLeftTriggerMotorSpeed / 65535) * 255);
|
}
|
||||||
int rightTriggerVal = iround(((float)pVibration->wRightTriggerMotorSpeed / 65535) * 255);
|
else
|
||||||
int leftVal = iround(((float)pVibration->wLeftMotorSpeed / 65535) * 255);
|
{
|
||||||
int rightVal = iround(((float)pVibration->wRightMotorSpeed / 65535) * 255);
|
return ERROR_DEVICE_NOT_CONNECTED;
|
||||||
|
}
|
||||||
return ERROR_SUCCESS;
|
}
|
||||||
}
|
|
||||||
else
|
LPCWSTR libName = L"xinput1_3.dll";
|
||||||
{
|
LPCWSTR daytonalibName = L"xinput9_1_0.dll";
|
||||||
return ERROR_DEVICE_NOT_CONNECTED;
|
LPCWSTR ptrToUse;
|
||||||
}
|
|
||||||
}
|
static InitFunction XInputHook([]()
|
||||||
|
{
|
||||||
LPCWSTR libName = L"xinput1_3.dll";
|
if (GameDetect::currentGame == GameID::PokkenTournament || GameDetect::currentGame == GameID::SchoolOfRagnarok || GameDetect::currentGame == GameID::Daytona3)
|
||||||
LPCWSTR daytonalibName = L"xinput9_1_0.dll";
|
{
|
||||||
LPCWSTR ptrToUse;
|
controllerInit = true;
|
||||||
|
|
||||||
static InitFunction XInputHook([]()
|
MH_Initialize();
|
||||||
{
|
|
||||||
if (GameDetect::currentGame == GameID::PokkenTournament || GameDetect::currentGame == GameID::SchoolOfRagnarok || GameDetect::currentGame == GameID::Daytona3)
|
if (GameDetect::currentGame == GameID::Daytona3)
|
||||||
{
|
ptrToUse = daytonalibName;
|
||||||
controllerInit = true;
|
else
|
||||||
|
ptrToUse = libName;
|
||||||
MH_Initialize();
|
|
||||||
|
MH_CreateHookApi(ptrToUse, "XInputGetState", &XInputGetState, NULL);
|
||||||
if (GameDetect::currentGame == GameID::Daytona3)
|
MH_CreateHookApi(ptrToUse, "XInputSetState", &XInputSetState, NULL);
|
||||||
ptrToUse = daytonalibName;
|
MH_CreateHookApi(ptrToUse, "XInputGetCapabilities", &XInputGetCapabilities, NULL);
|
||||||
else
|
MH_CreateHookApi(ptrToUse, "XInputEnable", &XInputEnable, NULL);
|
||||||
ptrToUse = libName;
|
MH_CreateHookApi(ptrToUse, "XInputGetDSoundAudioDeviceGuids", &XInputGetDSoundAudioDeviceGuids, NULL);
|
||||||
|
MH_CreateHookApi(ptrToUse, "XInputGetBatteryInformation", &XInputGetBatteryInformation, NULL);
|
||||||
MH_CreateHookApi(ptrToUse, "XInputGetState", &XInputGetState, NULL);
|
MH_CreateHookApi(ptrToUse, "XInputGetKeystroke", &XInputGetKeystroke, NULL);
|
||||||
MH_CreateHookApi(ptrToUse, "XInputSetState", &XInputSetState, NULL);
|
MH_CreateHookApi(ptrToUse, "XInputGetStateEx", &XInputGetStateEx, NULL);
|
||||||
MH_CreateHookApi(ptrToUse, "XInputGetCapabilities", &XInputGetCapabilities, NULL);
|
MH_CreateHookApi(ptrToUse, "XInputSetStateEx", &XInputSetStateEx, NULL);
|
||||||
MH_CreateHookApi(ptrToUse, "XInputEnable", &XInputEnable, NULL);
|
|
||||||
MH_CreateHookApi(ptrToUse, "XInputGetDSoundAudioDeviceGuids", &XInputGetDSoundAudioDeviceGuids, NULL);
|
MH_EnableHook(MH_ALL_HOOKS);
|
||||||
MH_CreateHookApi(ptrToUse, "XInputGetBatteryInformation", &XInputGetBatteryInformation, NULL);
|
}
|
||||||
MH_CreateHookApi(ptrToUse, "XInputGetKeystroke", &XInputGetKeystroke, NULL);
|
});
|
||||||
MH_CreateHookApi(ptrToUse, "XInputGetStateEx", &XInputGetStateEx, NULL);
|
#pragma optimize("", on)´
|
||||||
MH_CreateHookApi(ptrToUse, "XInputSetStateEx", &XInputSetStateEx, NULL);
|
|
||||||
|
|
||||||
MH_EnableHook(MH_ALL_HOOKS);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
#pragma optimize("", on)´
|
|
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user