Skip to content

Commit

Permalink
Do not return false when HID input report neutralization fails, just …
Browse files Browse the repository at this point in the history
…fill the result buffer with 0s
  • Loading branch information
Kaldaien committed Dec 29, 2024
1 parent e5669b2 commit 8eb17d4
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions src/input/hid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1223,7 +1223,7 @@ ReadFileEx_Detour (HANDLE hFile,
{
if (config.input.gamepad.disable_hid)
{
SK_SetLastError (ERROR_DEVICE_NOT_CONNECTED);
SetLastError (ERROR_DEVICE_NOT_CONNECTED);
return FALSE;
}

Expand Down Expand Up @@ -1316,7 +1316,7 @@ CreateFileA_Detour (LPCSTR lpFileName,

if (lpFileName == nullptr)
{
SK_SetLastError (ERROR_NO_SUCH_DEVICE);
SetLastError (ERROR_NO_SUCH_DEVICE);

return INVALID_HANDLE_VALUE;
}
Expand Down Expand Up @@ -1347,7 +1347,7 @@ CreateFileA_Detour (LPCSTR lpFileName,
{
if (config.input.gamepad.disable_hid)
{
SK_SetLastError (ERROR_NO_SUCH_DEVICE);
SetLastError (ERROR_NO_SUCH_DEVICE);

CloseHandle (hRet);

Expand Down Expand Up @@ -1429,7 +1429,7 @@ CreateFile2_Detour (

if (lpFileName == nullptr)
{
SK_SetLastError (ERROR_NO_SUCH_DEVICE);
SetLastError (ERROR_NO_SUCH_DEVICE);

return INVALID_HANDLE_VALUE;
}
Expand All @@ -1453,7 +1453,7 @@ CreateFile2_Detour (
{
if (config.input.gamepad.disable_hid)
{
SK_SetLastError (ERROR_NO_SUCH_DEVICE);
SetLastError (ERROR_NO_SUCH_DEVICE);

if (nullptr != hRet)
CloseHandle (hRet);
Expand Down Expand Up @@ -1542,7 +1542,7 @@ CreateFileW_Detour ( LPCWSTR lpFileName,

if (lpFileName == nullptr)
{
SK_SetLastError (ERROR_NO_SUCH_DEVICE);
SetLastError (ERROR_NO_SUCH_DEVICE);

return INVALID_HANDLE_VALUE;
}
Expand All @@ -1567,7 +1567,7 @@ CreateFileW_Detour ( LPCWSTR lpFileName,
{
if (config.input.gamepad.disable_hid)
{
SK_SetLastError (ERROR_NO_SUCH_DEVICE);
SetLastError (ERROR_NO_SUCH_DEVICE);

if (nullptr != hRet)
CloseHandle (hRet);
Expand Down Expand Up @@ -1658,7 +1658,7 @@ GetOverlappedResultEx_Detour (HANDLE hFile,
{
if (config.input.gamepad.disable_hid)
{
SK_SetLastError (ERROR_DEVICE_NOT_CONNECTED);
SetLastError (ERROR_DEVICE_NOT_CONNECTED);

CancelIoEx (hFile, lpOverlapped);

Expand Down Expand Up @@ -1710,8 +1710,6 @@ GetOverlappedResultEx_Detour (HANDLE hFile,
{
memset (overlapped_request.lpBuffer, 0, dwSize);
*lpNumberOfBytesTransferred = 0;
bRet = false;
SK_SetLastError (ERROR_NOT_READY);
}
}

Expand Down Expand Up @@ -1778,7 +1776,6 @@ GetOverlappedResultEx_Detour (HANDLE hFile,
{
memset (overlapped_request.lpBuffer, 0, dwSize);
dwSize = 0;
bRet = false;
}
}

Expand Down Expand Up @@ -1827,7 +1824,7 @@ GetOverlappedResult_Detour (HANDLE hFile,
{
if (config.input.gamepad.disable_hid)
{
SK_SetLastError (ERROR_DEVICE_NOT_CONNECTED);
SetLastError (ERROR_DEVICE_NOT_CONNECTED);

CancelIoEx (hFile, lpOverlapped);

Expand Down Expand Up @@ -1879,7 +1876,6 @@ GetOverlappedResult_Detour (HANDLE hFile,
{
memset (overlapped_request.lpBuffer, 0, dwSize);
*lpNumberOfBytesTransferred = 0;
bRet = false;
}
}

Expand Down Expand Up @@ -1946,8 +1942,6 @@ GetOverlappedResult_Detour (HANDLE hFile,
{
memset (overlapped_request.lpBuffer, 0, dwSize);
dwSize = 0;
bRet = false;
SK_SetLastError (ERROR_NOT_READY);
}
}

Expand Down

0 comments on commit 8eb17d4

Please sign in to comment.