Skip to content

Commit

Permalink
Minor change to make sure critical section is created first and a min…
Browse files Browse the repository at this point in the history
…or bug fix where input would stay blocked in TF2 when alt-tabbing into the start of an MVM match
  • Loading branch information
VolsandJezuz committed Feb 17, 2016
1 parent c8c0760 commit d36ccf7
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
RInput Library v1.43 by Vols and Jezuz
RInput Library v1.44 by Vols and Jezuz
--------------------------------------
RInput is an alternative to in-game raw input, which some users perceive as having input lag or other shortcomings. It also allows for raw input in games which do not have a native raw input implementation. In either case, RInput will only work for x86 (32-bit) games that control aim using the Win32 API functions GetCursorPos and SetCursorPos.

Expand Down
2 changes: 1 addition & 1 deletion README.mdown
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# RInput Library v1.43 by Vols and Jezuz
# RInput Library v1.44 by Vols and Jezuz
RInput is an alternative to in-game raw input, which some users perceive as having input lag or other shortcomings. It also allows for raw input in games which do not have a native raw input implementation. In either case, RInput will only work for x86 (32-bit) games that control aim using the Win32 API functions GetCursorPos and SetCursorPos.

## Requirements
Expand Down
4 changes: 2 additions & 2 deletions RInput.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
Name="VCLinkerTool"
UseUnicodeResponseFiles="false"
AdditionalDependencies="detours.lib dxguid.lib shlwapi.lib comctl32.lib"
Version="1.43-debug"
Version="1.44-debug"
LinkIncremental="1"
AdditionalLibraryDirectories=""C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib";"C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Lib\x86""
EnableUAC="true"
Expand Down Expand Up @@ -190,7 +190,7 @@
Name="VCLinkerTool"
UseUnicodeResponseFiles="false"
AdditionalDependencies="detours.lib dxguid.lib shlwapi.lib comctl32.lib"
Version="1.43"
Version="1.44"
LinkIncremental="1"
AdditionalLibraryDirectories=""C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib";"C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Lib\x86""
GenerateManifest="true"
Expand Down
2 changes: 1 addition & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,6 @@ void unloadLibrary()
void displayError(WCHAR* pwszError)
{
MessageBoxW(NULL, pwszError, L"Raw Input error!", MB_ICONERROR | MB_OK);
CRawInput::hookLibrary(FALSE);
CRawInput::hookLibrary(false);
unloadLibrary();
}
15 changes: 12 additions & 3 deletions rawinput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ bool CRawInput::initialize(WCHAR* pwszError)
else
CRawInput::n_sourceEXE = NO_BUG_FIXES;

// Avoid collisions with accumulation of raw input packets
InitializeCriticalSection(&CRawInput::rawMouseData);

if (!CRawInput::initWindow(pwszError))
return false;

Expand Down Expand Up @@ -291,9 +294,6 @@ bool CRawInput::hookLibrary(bool bInstall)
if (!DetourFunctionWithTrampoline((PBYTE)TrmpGetCursorPos, (PBYTE)CRawInput::hGetCursorPos) || !DetourFunctionWithTrampoline((PBYTE)TrmpSetCursorPos, (PBYTE)CRawInput::hSetCursorPos))
return false;

// Avoid collisions with accumulation of raw input packets
InitializeCriticalSection(&CRawInput::rawMouseData);

// Start CS:GO and TF2 D3D9 hooking
if (CRawInput::n_sourceEXE <= 2)
CRawInput::hD3D9HookThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)CRawInput::D3D9HookThread, NULL, 0, 0);
Expand Down Expand Up @@ -424,9 +424,18 @@ DWORD WINAPI CRawInput::blockInput(LPVOID lpParameter)
{
BlockInput(TRUE);

long SleepTimer = 0;

// Unblock input after 11 SetCursorPos and/or GetCursorPos calls
while (CRawInput::signal <= 12)
{
SleepTimer += 30;

if (SleepTimer >= 2000)
break;

Sleep(30);
}

CRawInput::signal = 0;

Expand Down
4 changes: 2 additions & 2 deletions versioninfo.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef _VERSIONINFO_H_
#define _VERSIONINFO_H_

#define RINPUTVER "v1.43"
#define RINPUTFVER 1,43
#define RINPUTVER "v1.44"
#define RINPUTFVER 1,44

#endif

0 comments on commit d36ccf7

Please sign in to comment.