Skip to content

Commit

Permalink
TF2 backpack now 100% fixed; numerous other small changes
Browse files Browse the repository at this point in the history
  • Loading branch information
VolsandJezuz committed Nov 5, 2015
1 parent 3221619 commit 4c48a9a
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 20 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.36 by Vols and Jezuz
RInput Library v1.37 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 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.36 by Vols and Jezuz
# RInput Library v1.37 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 games that control aim using the Win32 API functions GetCursorPos and SetCursorPos.

## Requirements
Expand Down
5 changes: 3 additions & 2 deletions RInput.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="3"
CallingConvention="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
Expand All @@ -77,7 +78,7 @@
Name="VCLinkerTool"
UseUnicodeResponseFiles="false"
AdditionalDependencies="shlwapi.lib"
Version="1.36-debug"
Version="1.37-debug"
LinkIncremental="1"
AdditionalLibraryDirectories="&quot;C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib&quot;"
EnableUAC="true"
Expand Down Expand Up @@ -185,7 +186,7 @@
Name="VCLinkerTool"
UseUnicodeResponseFiles="false"
AdditionalDependencies="shlwapi.lib"
Version="1.36"
Version="1.37"
LinkIncremental="1"
AdditionalLibraryDirectories="&quot;C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib&quot;"
GenerateManifest="true"
Expand Down
2 changes: 1 addition & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ extern "C" __declspec(dllexport) void entryPoint()
#endif
}

// Validate that we are working with Windows XP or higher (required for raw input)
// Validate that we are working with at least Windows XP
inline bool validateVersion()
{
DWORD dwVersion = GetVersion();
Expand Down
12 changes: 6 additions & 6 deletions main.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@
#define STRICT
#define WIN32_LEAN_AND_MEAN

#define WINVER 0x0501 // XP atleast
#define _WIN32_WINDOWS 0x0501 // XP atleast
#define _WIN32_WINNT 0x0501 // XP atleast
#define WINVER 0x0501 // Need at least Windows XP
#define _WIN32_WINDOWS 0x0501 // Need at least Windows XP
#define _WIN32_WINNT 0x0501 // Need at least Windows XP

#define ERROR_BUFFER_SIZE 256 // amount of bytes to store an error string
#define ERROR_BUFFER_SIZE 256 // Amount of bytes to store an error string

#define EVENTNAME "RInputEvent32"
#define KERNEL_LIB L"kernel32.dll"

#include <windows.h>
#include "rawinput.h" // raw input class
#include "rawinput.h" // Raw input class

HINSTANCE g_hInstance = NULL;

// only handle the hooking / dll functions here
// Only handle the hooking and dll functions here
extern "C" __declspec(dllexport) void entryPoint();
inline bool validateVersion();
void unloadLibrary();
Expand Down
25 changes: 22 additions & 3 deletions rawinput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ long CRawInput::hold_y = 0;
int CRawInput::SCP = 0;
bool CRawInput::GCP = false;
bool CRawInput::sourceEXE = false;
int CRawInput::consecG = 0;

bool CRawInput::initialize(WCHAR* pwszError)
{
Expand Down Expand Up @@ -95,8 +96,9 @@ bool CRawInput::initWindow(WCHAR* pwszError)

bool CRawInput::initInput(WCHAR* pwszError)
{
// Set default coordinates
CRawInput::x = CRawInput::y = CRawInput::set_x = CRawInput::set_y = 0;
// Set screen center until SetCursorPos is called
CRawInput::hold_x = GetSystemMetrics(SM_CXSCREEN) >> 1;
CRawInput::hold_y = GetSystemMetrics(SM_CYSCREEN) >> 1;

// Get process and enable bug fixes for source games
char szEXEPath[MAX_PATH];
Expand Down Expand Up @@ -181,13 +183,15 @@ LRESULT __stdcall CRawInput::wpInput(HWND hWnd, UINT message, WPARAM wParam, LPA

int __stdcall CRawInput::hSetCursorPos(int x, int y)
{
if (!TrmpSetCursorPos(x, y)) return 1;
// Skips unnecessary second SetCursorPos call for source games
if (!CRawInput::SCP && !TrmpSetCursorPos(x, y)) return 1;

CRawInput::set_x = (long)x;
CRawInput::set_y = (long)y;

if (CRawInput::sourceEXE)
{
CRawInput::consecG = 0;
// Alt-tab bug fix
if ((CRawInput::set_x == 0) && (CRawInput::set_y == 0))
CRawInput::GCP = true;
Expand Down Expand Up @@ -221,6 +225,21 @@ int __stdcall CRawInput::hGetCursorPos(LPPOINT lpPoint)
CRawInput::set_y += CRawInput::y;

CRawInput::SCP = 0;
// Bug fix for cursor hitting side of screen in TF2 backpack
if (CRawInput::consecG < 2)
++CRawInput::consecG;
if (CRawInput::sourceEXE && (CRawInput::consecG == 2))
{
if (CRawInput::set_x >= CRawInput::hold_x << 1)
CRawInput::set_x = (CRawInput::hold_x << 1) - 1;
else if (CRawInput::set_x < 0)
CRawInput::set_x = 0;
if (CRawInput::set_y >= CRawInput::hold_y << 1)
CRawInput::set_y = (CRawInput::hold_y << 1) - 1;
else if (CRawInput::set_y < 0)
CRawInput::set_y = 0;
}

// Alt-tab bug fix
if (!CRawInput::GCP)
{
Expand Down
9 changes: 5 additions & 4 deletions rawinput.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,24 @@ class CRawInput {
// Initialize raw input
static bool initialize(WCHAR* pwszError);

// Enable/Disable the hooking
// Enables or disables the hooking
static bool hookLibrary(bool bInstall);

// Hooked functions handling
static int __stdcall hGetCursorPos(LPPOINT lpPoint);
static int __stdcall hSetCursorPos(int x, int y);

// Poll Input
// Poll input
static unsigned int pollInput();

// Input Window Proc
// Input window proc
static LRESULT __stdcall wpInput(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);

// Initialization
static bool initWindow(WCHAR* pwszError);
static bool initInput(WCHAR* pwszError);

// Unload Raw Input
// Unload raw input
static void unload();

private:
Expand All @@ -55,6 +55,7 @@ class CRawInput {
static int SCP;
static bool GCP;
static bool sourceEXE;
static int consecG;

static HWND hwndInput;
static bool bRegistered;
Expand Down
4 changes: 2 additions & 2 deletions versioninfo.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#ifndef _VERSIONINFO_H_
#define _VERSIONINFO_H_

#define RINPUTVER "v1.36"
#define RINPUTFVER 1,36
#define RINPUTVER "v1.37"
#define RINPUTFVER 1,37
#define IDI_ICON 101

#define RINPUTINT "RInput"
Expand Down

0 comments on commit 4c48a9a

Please sign in to comment.