Skip to content

Commit

Permalink
1.1
Browse files Browse the repository at this point in the history
added configurable buttons
  • Loading branch information
R1PeR committed Jul 17, 2017
1 parent 6cf20bb commit c039837
Show file tree
Hide file tree
Showing 15 changed files with 58 additions and 94 deletions.
25 changes: 0 additions & 25 deletions MouseToVJoy/Debug/MouseToVJoy.log

This file was deleted.

Binary file removed MouseToVJoy/Debug/MouseToVJoy.obj
Binary file not shown.
Binary file removed MouseToVJoy/Debug/MouseToVJoy.tlog/CL.command.1.tlog
Binary file not shown.
Binary file removed MouseToVJoy/Debug/MouseToVJoy.tlog/CL.read.1.tlog
Binary file not shown.
Binary file removed MouseToVJoy/Debug/MouseToVJoy.tlog/CL.write.1.tlog
Binary file not shown.
2 changes: 0 additions & 2 deletions MouseToVJoy/Debug/MouseToVJoy.tlog/MouseToVJoy.lastbuildstate

This file was deleted.

Binary file not shown.
Binary file removed MouseToVJoy/Debug/MouseToVJoy.tlog/link.read.1.tlog
Binary file not shown.
Binary file removed MouseToVJoy/Debug/MouseToVJoy.tlog/link.write.1.tlog
Binary file not shown.
Binary file removed MouseToVJoy/Debug/vc141.idb
Binary file not shown.
Binary file removed MouseToVJoy/Debug/vc141.pdb
Binary file not shown.
115 changes: 50 additions & 65 deletions MouseToVJoy/MouseToVJoy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <sstream>
#include <cstdlib>
#define DEV_ID 1
DOUBLE VerApp = 1.0;
DOUBLE VerApp = 1.1;

const char g_szClassName[] = "myWindowClass";
HWND hwnd;
Expand All @@ -33,15 +33,12 @@ INT X = 0;
INT Y = 0;
INT Z = 0;
INT RX = 0;

LONG Btns = 0;
PVOID pPositionMessage;
UINT IoCode = LOAD_POSITIONS;
UINT IoSize = sizeof(JOYSTICK_POSITION);
// HID_DEVICE_ATTRIBUTES attrib;
BYTE id = 1;
UINT iInterface = 1;
DOUBLE Sensitivity, AttackTimeThrottle, ReleaseTimeThrottle, AttackTimeBreak, ReleaseTimeBreak, AttackTimeClutch, ReleaseTimeClutch;
DOUBLE Sensitivity, AttackTimeThrottle, ReleaseTimeThrottle, AttackTimeBreak, ReleaseTimeBreak, AttackTimeClutch, ReleaseTimeClutch, ThrottleKey, BreakKey, ClutchKey, MouseLockKey, UseMouse;

//Vjoy
// Step 4: the Window Procedure
Expand Down Expand Up @@ -121,9 +118,6 @@ void cInputDevices::GetData(LPARAM lParam)
// So instead of manually typing every possible
// case value, we can just start by looping through
// an expected range of keys the keycode might be.
if (keyCode == 0x11) {
pbToKey = &m_baAlphabet[26];
}

for (int iii = 0; iii < 25; ++iii)
{
Expand All @@ -143,46 +137,8 @@ void cInputDevices::GetData(LPARAM lParam)
break;
}
}


// However, if the whole for loop above did not find any matches
// to the keycode, then we can expect our boolean pointer to be the same
// value we initalized it to. Which would be NULL.

if (pbToKey != NULL)
{
// if we entered this block of code, then the boolean pointer
// is not NULL and has been assigned. The main idea is to
// call the CheckKeyPress function to update the boolean pointed to
// by the pbToKey, as well as pass in that boolean value itself.
*pbToKey = CheckKeyPress(*pbToKey, keyUp);

// Be sure to return ASAP!
return;
}

// If the boolean pointer was null, then before giving up
// we can check if the keycode falls in the arrow key range!

for (int iii = 0; iii < 4; ++iii)
{
// Notice we add 0x25 to iii,
// just like we added 0x41 to iii in the last for loop.

if (keyCode == iii + 0x25)
{
// Yay found it!
pbToKey = &m_baArrows[iii];
break;
}
}

// Because the keycode may not match any in the ranges we
// so far, we check to see if the boolean
// pointer has been assigned anything other than NULL. If
// it is NULL then we do not want to call CheckKeyPress.
// The reason for that is, it would error because our pointer
// is invalid and CheckKeyPress would be fail.
if (pbToKey != NULL)
{

Expand Down Expand Up @@ -294,9 +250,7 @@ int vJoyInput::AccuireDevice() {
}

void vJoyInput::FeedDevice() {
id = (BYTE)iInterface;
iReport.bDevice = id;
iReport.bDevice = 1;
iReport.bDevice = iInterface;
iReport.wAxisX = X;
iReport.wAxisY = Y;
iReport.wAxisZ = Z;
Expand All @@ -307,30 +261,45 @@ void vJoyInput::FeedDevice() {
getchar();
AcquireVJD(iInterface);
}

}

void vJoyInput::AccelerationLogic() {
if (rInput.IsLeftMouseButtonDown() && Y < 32767) {
Y += AttackTimeThrottle;
}
if (!rInput.IsLeftMouseButtonDown() && Y > 1){
Y -= ReleaseTimeThrottle;
}
if (rInput.IsRightMouseButtonDown() && Z < 32767) {
Z += AttackTimeBreak;
if (UseMouse == 1) {
if (rInput.IsLeftMouseButtonDown() && Y < 32767) {
Y += AttackTimeThrottle;
}
if (!rInput.IsLeftMouseButtonDown() && Y > 1) {
Y -= ReleaseTimeThrottle;
}
if (rInput.IsRightMouseButtonDown() && Z < 32767) {
Z += AttackTimeBreak;
}
if (!rInput.IsRightMouseButtonDown() && Z > 1) {
Z -= ReleaseTimeBreak;
}
}
if (!rInput.IsRightMouseButtonDown() && Z > 1) {
Z -= ReleaseTimeBreak;
else {
if (rInput.IsAlphabeticKeyDown(ThrottleKey - 0x41) && Y < 32767) {
Y += AttackTimeThrottle;
}
if (!rInput.IsAlphabeticKeyDown(ThrottleKey - 0x41) && Y > 1) {
Y -= ReleaseTimeThrottle;
}
if (rInput.IsAlphabeticKeyDown(BreakKey - 0x41) && Z < 32767) {
Z += AttackTimeBreak;
}
if (!rInput.IsAlphabeticKeyDown(BreakKey - 0x41) && Z > 1) {
Z -= ReleaseTimeBreak;
}
}
if (rInput.IsAlphabeticKeyDown(VKey_C - 0x41) && RX < 32767) {
if (rInput.IsAlphabeticKeyDown(ClutchKey - 0x41) && RX < 32767) {
RX += AttackTimeClutch;
}
if (!rInput.IsAlphabeticKeyDown(VKey_C - 0x41) && RX > 1) {
if (!rInput.IsAlphabeticKeyDown(ClutchKey - 0x41) && RX > 1) {
RX -= ReleaseTimeClutch;
}
if (rInput.IsAlphabeticKeyDown(VKey_O - 0x41)) {
SleepEx(250,!(rInput.IsAlphabeticKeyDown(VKey_O - 0x41)));
if (rInput.IsAlphabeticKeyDown(MouseLockKey - 0x41)) {
SleepEx(250,!(rInput.IsAlphabeticKeyDown(MouseLockKey - 0x41)));
if (CursorLocked == false) {
CursorLocked = true;
}
Expand Down Expand Up @@ -380,9 +349,25 @@ void ReadConfigFile() {
else if (tmp == "ReleaseTimeClutch") {
ReleaseTimeClutch = value;
}
else if (tmp == "ThrottleKey") {
ThrottleKey = value;
}
else if (tmp == "BreakKey") {
BreakKey = value;
}
else if (tmp == "ClutchKey") {
ClutchKey = value;
}
else if (tmp == "MouseLockKey") {
MouseLockKey = value;
}
else if (tmp == "UseMouse") {
UseMouse = 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";
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";
std::cout << "==================================\n";
file_.close();
}
Expand Down
7 changes: 7 additions & 0 deletions MouseToVJoy/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,11 @@ AttackTimeBreak = 400
ReleaseTimeBreak = 400
AttackTimeClutch = 400
ReleaseTimeClutch = 400
ThrottleKey = 87
BreakKey = 83
ClutchKey = 67
MouseLockKey = 79
UseMouse = 1

Use keycodes from 65 to 90 (65 for A, 90 for Z)

2 changes: 0 additions & 2 deletions MouseToVJoy/input.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ enum
VKey_X,
VKey_Y,
VKey_Z,
VKey_CONTROL
};

enum
Expand All @@ -51,7 +50,6 @@ enum
VKey_RightArrow,
VKey_DownArrow
};

class cInputDevices
{
public:
Expand Down
1 change: 1 addition & 0 deletions MouseToVJoy/vJoyInput.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ class vJoyInput {
int AccuireDevice();
void FeedDevice();
void AccelerationLogic();
void GetKeyAssigned();
};
#endif

0 comments on commit c039837

Please sign in to comment.