Skip to content

Commit

Permalink
consolidated header files and added #define's to make program functio…
Browse files Browse the repository at this point in the history
…n clearer
  • Loading branch information
VolsandJezuz committed Dec 20, 2015
1 parent ad2d0cc commit e7fe249
Show file tree
Hide file tree
Showing 12 changed files with 66 additions and 118 deletions.
22 changes: 5 additions & 17 deletions RInput.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -247,24 +247,12 @@
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\d3d9hook.h"
>
</File>
<File
RelativePath=".\detours.h"
>
</File>
<File
RelativePath=".\main.h"
>
</File>
<File
RelativePath=".\rawinput.h"
>
</File>
<File
RelativePath=".\versioninfo.h"
RelativePath=".\stdafx.h"
>
</File>
</Filter>
Expand All @@ -273,10 +261,6 @@
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
<File
RelativePath=".\icon.ico"
>
</File>
<File
RelativePath=".\versioninfo.rc"
>
Expand All @@ -299,6 +283,10 @@
RelativePath=".\rawinput.cpp"
>
</File>
<File
RelativePath=".\stdafx.cpp"
>
</File>
</Filter>
<File
RelativePath=".\detours.lib"
Expand Down
6 changes: 3 additions & 3 deletions d3d9hook.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "d3d9hook.h"
#include <shlobj.h>
#include "stdafx.h"
#include <d3d9.h>
#include <shlobj.h>

static LPDIRECT3DDEVICE9 pDevice;
static DWORD oD3D9EndScene = 0;
Expand Down Expand Up @@ -56,7 +56,7 @@ __declspec(naked) HRESULT __stdcall D3D9EndScene()
pushad
}

if (consec_EndScene < 6)
if (consec_EndScene < MAX_CONSEC_ENDSCENE)
++consec_EndScene;

__asm
Expand Down
11 changes: 0 additions & 11 deletions d3d9hook.h

This file was deleted.

6 changes: 2 additions & 4 deletions detours.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
// Copyright 1995-2001, Microsoft Corporation
//

#ifndef _DETOURS_H_
#define _DETOURS_H_
#pragma once

//////////////////////////////////////////////////////////////////////////////
//
Expand Down Expand Up @@ -608,6 +607,5 @@ inline PBYTE DetourGenNop(PBYTE pbCode)
#endif DETOURS_INTERAL
#endif // __cplusplus

#endif // _DETOURS_H_
//
//////////////////////////////////////////////////////////////// End of File.
//////////////////////////////////////////////////////////////// End of File.
Binary file removed icon.ico
Binary file not shown.
18 changes: 9 additions & 9 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@
along with RInput. If not, see <http://www.gnu.org/licenses/>.
*/

#include "main.h"
#include "stdafx.h"
#include <string>
#include <shlwapi.h>

HINSTANCE g_hInstance = NULL;
int n_sourceEXE = 0;
bool sourceEXE = false;
static HINSTANCE g_hInstance = NULL;

// Expose the entry point function called by RInput.exe
extern "C" __declspec(dllexport) void entryPoint();

int __stdcall DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
Expand Down Expand Up @@ -64,9 +66,7 @@ int __stdcall DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)

if ((std::string)szEXEPath == (std::string)*iSource_exes)
{
sourceEXE = true;

if (n_sourceEXE == 2)
if (n_sourceEXE == TF2)
{
// Make sure hl2.exe is TF2
PathRemoveFileSpecA(TF2path);
Expand All @@ -82,7 +82,7 @@ int __stdcall DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
// Check hl2.exe is TF2
if (testTF2[k] != tf2[k])
n_sourceEXE = 5;
n_sourceEXE = NOBUGFIXES;
}
}

Expand All @@ -91,7 +91,7 @@ int __stdcall DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
}
}
else
n_sourceEXE = 4;
n_sourceEXE = NOBUGFIXES;
}

break;
Expand Down
21 changes: 0 additions & 21 deletions main.h

This file was deleted.

29 changes: 14 additions & 15 deletions rawinput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@
along with RInput. If not, see <http://www.gnu.org/licenses/>.
*/

#include "rawinput.h"
#include <commctrl.h>
#include "stdafx.h"
#include "detours.h"
#include <commctrl.h>

#pragma intrinsic(memset)

// Initialize static variables
HWND CRawInput::hwndClient = NULL;
bool CRawInput::TF2unblock = false;
long CRawInput::hold_x = 0;
Expand All @@ -48,13 +49,11 @@ CRITICAL_SECTION CRawInput::rawMouseData;
long CRawInput::x = 0;
long CRawInput::y = 0;
int CRawInput::signal = 0;
int consec_EndScene = 0;
int CRawInput::consecG = 2;
bool CRawInput::alttab = false;
int CRawInput::SCP = 0;
bool CRawInput::bSubclass = false;
HANDLE CRawInput::hCreateThread = NULL;
HANDLE hD3D9HookThread = NULL;

// Define functions that are to be hooked and detoured
extern "C" DETOUR_TRAMPOLINE(int __stdcall TrmpGetCursorPos(LPPOINT lpPoint), GetCursorPos);
Expand Down Expand Up @@ -85,7 +84,7 @@ bool CRawInput::initWindow(WCHAR* pwszError)
if (CRawInput::hwndClient)
{
// TF2 Window must be active for backpack fixes to work
if (n_sourceEXE == 2 && GetForegroundWindow() != CRawInput::hwndClient)
if (n_sourceEXE == TF2 && GetForegroundWindow() != CRawInput::hwndClient)
{
CRawInput::TF2unblock = true;
BlockInput(TRUE);
Expand Down Expand Up @@ -149,7 +148,7 @@ bool CRawInput::initInput(WCHAR* pwszError)
memset(&rMouse, 0, sizeof(RAWINPUTDEVICE));

// Flag allows accumulation to continue for TF2 while alt-tabbed
if (n_sourceEXE == 2)
if (n_sourceEXE == TF2)
rMouse.dwFlags = RIDEV_INPUTSINK;
else
rMouse.dwFlags = 0;
Expand Down Expand Up @@ -267,15 +266,15 @@ int __stdcall CRawInput::hSetCursorPos(int x, int y)
CRawInput::set_x = (long)x;
CRawInput::set_y = (long)y;

if (sourceEXE)
if (n_sourceEXE != NOBUGFIXES)
{
if (n_sourceEXE == 2)
if (n_sourceEXE == TF2)
{
if (CRawInput::signal >= 1)
++CRawInput::signal;

// Bug fix for Steam overlay in TF2 backpack
if (consec_EndScene == 6 && CRawInput::consecG == 3 && !CRawInput::alttab)
if (consec_EndScene == MAX_CONSEC_ENDSCENE && CRawInput::consecG == MAX_CONSECG && !CRawInput::alttab)
{
if (CRawInput::SCP == 0)
CRawInput::SCP = -1;
Expand All @@ -301,7 +300,7 @@ int __stdcall CRawInput::hSetCursorPos(int x, int y)
}
else if (CRawInput::SCP == 2)
{
if (n_sourceEXE != 2)
if (n_sourceEXE != TF2)
CRawInput::SCP = 0;

consec_EndScene = 0;
Expand Down Expand Up @@ -329,7 +328,7 @@ int __stdcall CRawInput::hGetCursorPos(LPPOINT lpPoint)

LeaveCriticalSection(&CRawInput::rawMouseData);

if (n_sourceEXE == 2)
if (n_sourceEXE == TF2)
{
if (CRawInput::signal >= 1)
++CRawInput::signal;
Expand All @@ -340,11 +339,11 @@ int __stdcall CRawInput::hGetCursorPos(LPPOINT lpPoint)
CRawInput::bSubclass = false;
}

if (CRawInput::consecG < 3)
if (CRawInput::consecG < MAX_CONSECG)
++CRawInput::consecG;

// Bug fix for cursor hitting side of screen in TF2 backpack
if (CRawInput::consecG == 3)
if (CRawInput::consecG == MAX_CONSECG)
{
if (CRawInput::set_x >= CRawInput::hold_x * 2)
CRawInput::set_x = CRawInput::hold_x * 2 - 1;
Expand Down Expand Up @@ -374,10 +373,10 @@ int __stdcall CRawInput::hGetCursorPos(LPPOINT lpPoint)

if (!CRawInput::alttab)
{
if (consec_EndScene == 6)
if (consec_EndScene == MAX_CONSEC_ENDSCENE)
{
// Needed to not break backpack in TF2
if (!(CRawInput::SCP != 1 && CRawInput::consecG == 3))
if (!(CRawInput::SCP != 1 && CRawInput::consecG == MAX_CONSECG))
{
if (!CRawInput::hwndClient)
CRawInput::hwndClient = CRawInput::clientWindow(GetCurrentProcessId());
Expand Down
5 changes: 5 additions & 0 deletions stdafx.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "stdafx.h"

int consec_EndScene = 0;
HANDLE hD3D9HookThread = NULL;
int n_sourceEXE = 0;
33 changes: 19 additions & 14 deletions rawinput.h → stdafx.h
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
#ifndef RAWINPUT_H_
#define RAWINPUT_H_
#pragma once

#define STRICT
#define WINVER 0x0501
#define _WIN32_WINDOWS 0x0501
#define _WIN32_WINNT 0x0501
#define WIN32_LEAN_AND_MEAN
#define KERNEL_LIB L"kernel32.dll"
#define RINPUTVER "v1.42"
#define RINPUTFVER 1,42
#define TF2 2
#define NOBUGFIXES 4
#define MAX_CONSEC_ENDSCENE 6
#define MAX_CONSECG 3

#include <windows.h>

extern bool sourceEXE;
extern int consec_EndScene;
extern HANDLE hD3D9HookThread;
extern int n_sourceEXE;
extern DWORD WINAPI D3D9HookThread(LPVOID lpParameter);

/**
* Note from original author (abort):
* ----------------------------------
* Sadly everything has been made static, as Win32 API does not support object oriented callbacks, as it has been written in C.
* To keep the performance as high as possible, I decided not to work with storing the class instance through Win32 API.
* Feel free to rewrite this to something more clean in coding terms :).
*/
DWORD WINAPI D3D9HookThread(LPVOID lpParameter);

class CRawInput
{
public:
Expand Down Expand Up @@ -60,6 +67,4 @@ class CRawInput
static int SCP;
static bool bSubclass;
static HANDLE hCreateThread;
};

#endif
};
11 changes: 0 additions & 11 deletions versioninfo.h

This file was deleted.

22 changes: 9 additions & 13 deletions versioninfo.rc
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "versioninfo.h"
#define VS_VERSION_INFO 1
#include "stdafx.h"

VS_VERSION_INFO VERSIONINFO
1 VERSIONINFO
FILEVERSION RINPUTFVER
PRODUCTVERSION RINPUTFVER
FILEFLAGSMASK 0x17L
Expand All @@ -10,20 +9,19 @@ VS_VERSION_INFO VERSIONINFO
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x0L
FILEOS 0x40000L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", "Digitalise.NET"
VALUE "FileDescription", "Utilize Raw Input in any game/application using Get- and SetCursorPos."
VALUE "FileDescription", "Raw input in any game using Get/SetCursorPos."
VALUE "FileVersion", RINPUTVER
VALUE "InternalName", RINPUTINT
VALUE "LegalCopyright", "Copyright (C) 2008"
VALUE "OriginalFilename", RINPUTDLL
VALUE "InternalName", "RInput"
VALUE "LegalCopyright", "Copyright (C) 2015"
VALUE "OriginalFilename", "RInput.dll"
VALUE "ProductName", "RInput Dynamic Link Library"
VALUE "ProductVersion", RINPUTVER
END
Expand All @@ -32,6 +30,4 @@ BEGIN
BEGIN
VALUE "Translation", 0x409, 1200
END
END

IDI_ICON ICON "icon.ico"
END

0 comments on commit e7fe249

Please sign in to comment.