Skip to content

Commit

Permalink
1.3
Browse files Browse the repository at this point in the history
Added ability to center steering axis using mouse center key.
  • Loading branch information
R1PeR committed Aug 2, 2017
1 parent affdd29 commit e73b046
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 15 deletions.
18 changes: 13 additions & 5 deletions MouseToVJoy/MouseToVJoy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include <cstdlib>
#include <iomanip>
#define DEV_ID 1
DOUBLE VerApp = 1.2;
DOUBLE VerApp = 1.3;

const char g_szClassName[] = "myWindowClass";
HWND hwnd;
Expand All @@ -39,7 +39,7 @@ UINT IoCode = LOAD_POSITIONS;
UINT IoSize = sizeof(JOYSTICK_POSITION);
// HID_DEVICE_ATTRIBUTES attrib;
UINT iInterface = 1;
DOUBLE Sensitivity, AttackTimeThrottle, ReleaseTimeThrottle, AttackTimeBreak, ReleaseTimeBreak, AttackTimeClutch, ReleaseTimeClutch, ThrottleKey, BreakKey, ClutchKey, MouseLockKey, UseMouse, AccelerationThrottle, AccelerationBreak, AccelerationClutch;
DOUBLE Sensitivity, AttackTimeThrottle, ReleaseTimeThrottle, AttackTimeBreak, ReleaseTimeBreak, AttackTimeClutch, ReleaseTimeClutch, ThrottleKey, BreakKey, ClutchKey, MouseLockKey, UseMouse, AccelerationThrottle, AccelerationBreak, AccelerationClutch, MouseCenterKey;

//Vjoy
// Step 4: the Window Procedure
Expand Down Expand Up @@ -264,7 +264,7 @@ void vJoyInput::FeedDevice() {
}
}

void vJoyInput::AccelerationLogic() {
void vJoyInput::InputLogic() {

if (UseMouse == 1) {
if (rInput.IsLeftMouseButtonDown() && Y < 32767) {
Expand Down Expand Up @@ -309,9 +309,14 @@ void vJoyInput::AccelerationLogic() {
CursorLocked = false;
}
}
if (rInput.IsAlphabeticKeyDown(MouseCenterKey - 0x41)) {
SleepEx(250, !(rInput.IsAlphabeticKeyDown(MouseCenterKey - 0x41)));
X = (32766/2);
}
if (CursorLocked == true) {
SetCursorPos(0, 0);
}

}

void ReadConfigFile() {
Expand Down Expand Up @@ -372,9 +377,12 @@ void ReadConfigFile() {
else if (tmp == "AccelerationClutch") {
AccelerationClutch = value;
}
else if (tmp == "MouseCenterKey") {
MouseCenterKey = value;
}
}
std::cout << "==================================\n";
std::cout << "Sensitivity = " << Sensitivity << "\n" << "Throttle Attack Time = " << AttackTimeThrottle << "\n" << "Throttle Release Time = " << ReleaseTimeThrottle << "\n" << "Break Attack Time = " << AttackTimeBreak << "\n" << "Break Release Time = " << ReleaseTimeBreak << "\n" << "Clutch Attack Time = " << AttackTimeClutch << "\n" << "Clutch Release Time = " << ReleaseTimeClutch << "\n" << "Throttle key = " << ThrottleKey << "\n" << "Break key = " << BreakKey << "\n" << "Clutch key = " << ClutchKey << "\n" << "Mouse Lock key = " << MouseLockKey << "\n" << "Use Mouse = " << UseMouse << "\n" << "Acceleration Throttle = " << AccelerationThrottle << "\n" << "Acceleration Break = " << AccelerationBreak << "\n" << "Acceleration Clutch = " << AccelerationClutch << "\n";
std::cout << "Sensitivity = " << Sensitivity << "\n" << "Throttle Attack Time = " << AttackTimeThrottle << "\n" << "Throttle Release Time = " << ReleaseTimeThrottle << "\n" << "Break Attack Time = " << AttackTimeBreak << "\n" << "Break Release Time = " << ReleaseTimeBreak << "\n" << "Clutch Attack Time = " << AttackTimeClutch << "\n" << "Clutch Release Time = " << ReleaseTimeClutch << "\n" << "Throttle key = " << ThrottleKey << "\n" << "Break key = " << BreakKey << "\n" << "Clutch key = " << ClutchKey << "\n" << "Mouse Lock key = " << MouseLockKey << "\n" << "Mouse Center key = " << MouseCenterKey << "\n" << "Use Mouse = " << UseMouse << "\n" << "Acceleration Throttle = " << AccelerationThrottle << "\n" << "Acceleration Break = " << AccelerationBreak << "\n" << "Acceleration Clutch = " << AccelerationClutch << "\n";
std::cout << "==================================\n";
file_.close();
}
Expand Down Expand Up @@ -470,7 +478,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
//vjoylogic here
Sleep(2);

vJ.AccelerationLogic();
vJ.InputLogic();
vJ.FeedDevice();

if (Msg.message == WM_QUIT || Msg.message == WM_DESTROY)
Expand Down
18 changes: 10 additions & 8 deletions MouseToVJoy/config.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
Sensitivity = 5
AttackTimeThrottle = 1
ReleaseTimeThrottle = 1
AttackTimeBreak = 1
ReleaseTimeBreak = 1
AttackTimeClutch = 1
ReleaseTimeClutch = 1
Sensitivity = 2
AttackTimeThrottle = 100
ReleaseTimeThrottle = 100
AttackTimeBreak = 100
ReleaseTimeBreak = 100
AttackTimeClutch = 100
ReleaseTimeClutch = 100
ThrottleKey = 87
BreakKey = 83
BreakKey = 69
ClutchKey = 67
MouseLockKey = 79
MouseCenterKey = 80
UseMouse = 1
AccelerationThrottle = 1.01
AccelerationBreak = 1.01
Expand All @@ -17,5 +18,6 @@ AccelerationClutch = 1.01

Acceleration works like this: X = (X + AttackTime) * Acceleration, X = (X - ReleaseTime) / Acceleration
If you want raw acceleration use 1 for time variables and scale acceleration
If you dont want acceleration set it to 1 and use linear time values
Use keycodes from 65 to 90 (65 for A, 90 for Z)

3 changes: 1 addition & 2 deletions MouseToVJoy/vJoyInput.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class vJoyInput {
int TestVirtualDevices();
int AccuireDevice();
void FeedDevice();
void AccelerationLogic();
void GetKeyAssigned();
void InputLogic();
};
#endif

0 comments on commit e73b046

Please sign in to comment.