diff --git a/.vs/MouseToVJoy/v15/.suo b/.vs/MouseToVJoy/v15/.suo index d836e84..ce1148c 100644 Binary files a/.vs/MouseToVJoy/v15/.suo and b/.vs/MouseToVJoy/v15/.suo differ diff --git a/.vs/MouseToVJoy/v15/Browse.VC.db b/.vs/MouseToVJoy/v15/Browse.VC.db index 6b3495b..63a7f7b 100644 Binary files a/.vs/MouseToVJoy/v15/Browse.VC.db and b/.vs/MouseToVJoy/v15/Browse.VC.db differ diff --git a/.vs/MouseToVJoy/v15/ipch/AutoPCH/8e210337ae4e5a86/VJOY.ipch b/.vs/MouseToVJoy/v15/ipch/AutoPCH/8e210337ae4e5a86/VJOY.ipch index c0620a1..ca40204 100644 Binary files a/.vs/MouseToVJoy/v15/ipch/AutoPCH/8e210337ae4e5a86/VJOY.ipch and b/.vs/MouseToVJoy/v15/ipch/AutoPCH/8e210337ae4e5a86/VJOY.ipch differ diff --git a/.vs/MouseToVJoy/v15/ipch/AutoPCH/9686cc012bc482c4/MOUSETOVJOY.ipch b/.vs/MouseToVJoy/v15/ipch/AutoPCH/9686cc012bc482c4/MOUSETOVJOY.ipch index 086ad22..17d99e4 100644 Binary files a/.vs/MouseToVJoy/v15/ipch/AutoPCH/9686cc012bc482c4/MOUSETOVJOY.ipch and b/.vs/MouseToVJoy/v15/ipch/AutoPCH/9686cc012bc482c4/MOUSETOVJOY.ipch differ diff --git a/.vs/MouseToVJoy/v15/ipch/AutoPCH/f2642cdcdf689397/MAIN.ipch b/.vs/MouseToVJoy/v15/ipch/AutoPCH/f2642cdcdf689397/MAIN.ipch index 6ffba73..0d612c7 100644 Binary files a/.vs/MouseToVJoy/v15/ipch/AutoPCH/f2642cdcdf689397/MAIN.ipch and b/.vs/MouseToVJoy/v15/ipch/AutoPCH/f2642cdcdf689397/MAIN.ipch differ diff --git a/Debug/MouseToVJoy.exe b/Debug/MouseToVJoy.exe index 3bb1711..ab6b9f0 100644 Binary files a/Debug/MouseToVJoy.exe and b/Debug/MouseToVJoy.exe differ diff --git a/Debug/MouseToVJoy.ilk b/Debug/MouseToVJoy.ilk index 0e007ae..f43d3a1 100644 Binary files a/Debug/MouseToVJoy.ilk and b/Debug/MouseToVJoy.ilk differ diff --git a/Debug/MouseToVJoy.pdb b/Debug/MouseToVJoy.pdb index 976f377..223992a 100644 Binary files a/Debug/MouseToVJoy.pdb and b/Debug/MouseToVJoy.pdb differ diff --git a/MouseToVJoy/Debug/MouseToVJoy.Build.CppClean.log b/MouseToVJoy/Debug/MouseToVJoy.Build.CppClean.log deleted file mode 100644 index 9176417..0000000 --- a/MouseToVJoy/Debug/MouseToVJoy.Build.CppClean.log +++ /dev/null @@ -1,16 +0,0 @@ -c:\users\lenovo\documents\github\mousetovjoy\mousetovjoy\debug\vc141.pdb -c:\users\lenovo\documents\github\mousetovjoy\mousetovjoy\debug\vc141.idb -c:\users\lenovo\documents\github\mousetovjoy\mousetovjoy\debug\cinputdevices.obj -c:\users\lenovo\documents\github\mousetovjoy\mousetovjoy\debug\fileread.obj -c:\users\lenovo\documents\github\mousetovjoy\mousetovjoy\debug\mousetovjoy.obj -c:\users\lenovo\documents\github\mousetovjoy\mousetovjoy\debug\main.obj -c:\users\lenovo\documents\github\mousetovjoy\mousetovjoy\debug\vjoy.obj -c:\users\lenovo\documents\github\mousetovjoy\debug\mousetovjoy.ilk -c:\users\lenovo\documents\github\mousetovjoy\debug\mousetovjoy.exe -c:\users\lenovo\documents\github\mousetovjoy\debug\mousetovjoy.pdb -c:\users\lenovo\documents\github\mousetovjoy\mousetovjoy\debug\mousetovjoy.tlog\cl.command.1.tlog -c:\users\lenovo\documents\github\mousetovjoy\mousetovjoy\debug\mousetovjoy.tlog\cl.read.1.tlog -c:\users\lenovo\documents\github\mousetovjoy\mousetovjoy\debug\mousetovjoy.tlog\cl.write.1.tlog -c:\users\lenovo\documents\github\mousetovjoy\mousetovjoy\debug\mousetovjoy.tlog\link.command.1.tlog -c:\users\lenovo\documents\github\mousetovjoy\mousetovjoy\debug\mousetovjoy.tlog\link.read.1.tlog -c:\users\lenovo\documents\github\mousetovjoy\mousetovjoy\debug\mousetovjoy.tlog\link.write.1.tlog diff --git a/MouseToVJoy/Debug/MouseToVJoy.log b/MouseToVJoy/Debug/MouseToVJoy.log deleted file mode 100644 index 290ae95..0000000 --- a/MouseToVJoy/Debug/MouseToVJoy.log +++ /dev/null @@ -1 +0,0 @@ - MouseToVJoy.vcxproj -> C:\Users\Lenovo\Documents\GitHub\mousetovjoy\Debug\MouseToVJoy.exe diff --git a/MouseToVJoy/Debug/MouseToVJoy.tlog/CL.command.1.tlog b/MouseToVJoy/Debug/MouseToVJoy.tlog/CL.command.1.tlog deleted file mode 100644 index 64c500f..0000000 Binary files a/MouseToVJoy/Debug/MouseToVJoy.tlog/CL.command.1.tlog and /dev/null differ diff --git a/MouseToVJoy/Debug/MouseToVJoy.tlog/CL.read.1.tlog b/MouseToVJoy/Debug/MouseToVJoy.tlog/CL.read.1.tlog deleted file mode 100644 index 986fe98..0000000 Binary files a/MouseToVJoy/Debug/MouseToVJoy.tlog/CL.read.1.tlog and /dev/null differ diff --git a/MouseToVJoy/Debug/MouseToVJoy.tlog/CL.write.1.tlog b/MouseToVJoy/Debug/MouseToVJoy.tlog/CL.write.1.tlog deleted file mode 100644 index 82f86c1..0000000 Binary files a/MouseToVJoy/Debug/MouseToVJoy.tlog/CL.write.1.tlog and /dev/null differ diff --git a/MouseToVJoy/Debug/MouseToVJoy.tlog/MouseToVJoy.lastbuildstate b/MouseToVJoy/Debug/MouseToVJoy.tlog/MouseToVJoy.lastbuildstate deleted file mode 100644 index 37a2b81..0000000 --- a/MouseToVJoy/Debug/MouseToVJoy.tlog/MouseToVJoy.lastbuildstate +++ /dev/null @@ -1,2 +0,0 @@ -#TargetFrameworkVersion=v4.0:PlatformToolSet=v141:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=10.0.15063.0 -Debug|Win32|C:\Users\Lenovo\Documents\GitHub\mousetovjoy\| diff --git a/MouseToVJoy/Debug/MouseToVJoy.tlog/link.command.1.tlog b/MouseToVJoy/Debug/MouseToVJoy.tlog/link.command.1.tlog deleted file mode 100644 index 05c940b..0000000 Binary files a/MouseToVJoy/Debug/MouseToVJoy.tlog/link.command.1.tlog and /dev/null differ diff --git a/MouseToVJoy/Debug/MouseToVJoy.tlog/link.read.1.tlog b/MouseToVJoy/Debug/MouseToVJoy.tlog/link.read.1.tlog deleted file mode 100644 index d2f1542..0000000 Binary files a/MouseToVJoy/Debug/MouseToVJoy.tlog/link.read.1.tlog and /dev/null differ diff --git a/MouseToVJoy/Debug/MouseToVJoy.tlog/link.write.1.tlog b/MouseToVJoy/Debug/MouseToVJoy.tlog/link.write.1.tlog deleted file mode 100644 index f2e1aa7..0000000 Binary files a/MouseToVJoy/Debug/MouseToVJoy.tlog/link.write.1.tlog and /dev/null differ diff --git a/MouseToVJoy/Debug/cInputDevices.obj b/MouseToVJoy/Debug/cInputDevices.obj deleted file mode 100644 index 9d7b342..0000000 Binary files a/MouseToVJoy/Debug/cInputDevices.obj and /dev/null differ diff --git a/MouseToVJoy/Debug/fileRead.obj b/MouseToVJoy/Debug/fileRead.obj deleted file mode 100644 index 626ba6b..0000000 Binary files a/MouseToVJoy/Debug/fileRead.obj and /dev/null differ diff --git a/MouseToVJoy/Debug/main.obj b/MouseToVJoy/Debug/main.obj deleted file mode 100644 index d6729fc..0000000 Binary files a/MouseToVJoy/Debug/main.obj and /dev/null differ diff --git a/MouseToVJoy/Debug/mouseToVjoy.obj b/MouseToVJoy/Debug/mouseToVjoy.obj deleted file mode 100644 index 3d06ed8..0000000 Binary files a/MouseToVJoy/Debug/mouseToVjoy.obj and /dev/null differ diff --git a/MouseToVJoy/Debug/vJoy.obj b/MouseToVJoy/Debug/vJoy.obj deleted file mode 100644 index 84963ac..0000000 Binary files a/MouseToVJoy/Debug/vJoy.obj and /dev/null differ diff --git a/MouseToVJoy/Debug/vc141.idb b/MouseToVJoy/Debug/vc141.idb deleted file mode 100644 index cdb70fb..0000000 Binary files a/MouseToVJoy/Debug/vc141.idb and /dev/null differ diff --git a/MouseToVJoy/Debug/vc141.pdb b/MouseToVJoy/Debug/vc141.pdb deleted file mode 100644 index 65cabdf..0000000 Binary files a/MouseToVJoy/Debug/vc141.pdb and /dev/null differ diff --git a/MouseToVJoy/MouseToVJoy.cpp b/MouseToVJoy/MouseToVJoy.cpp index 7da4e3d..b8b0144 100644 --- a/MouseToVJoy/MouseToVJoy.cpp +++ b/MouseToVJoy/MouseToVJoy.cpp @@ -1,13 +1,12 @@ #include "mousetovjoy.h" #include #include +#define SteeringMax 16384 +#define SteeringMin -16384 //define center multiplier to be able to modify it during function. DOUBLE CenterMultiplier; -//define maximal value of vjoy axis. -DOUBLE SteeringMax = 16384, SteeringMin = -16384; - -void mouseToVjoy::inputLogic(cInputDevices Input, INT &X, INT &Y, INT &Z, INT &RX, BOOL &BUTTON1, BOOL &BUTTON2, BOOL &BUTTON3, DOUBLE AttackTimeThrottle, DOUBLE ReleaseTimeThrottle, DOUBLE AttackTimeBreak, DOUBLE ReleaseTimeBreak, DOUBLE AttackTimeClutch, DOUBLE ReleaseTimeClutch, DOUBLE ThrottleKey, DOUBLE BreakKey, DOUBLE ClutchKey, DOUBLE GearShiftUpKey, DOUBLE GearShiftDownKey, DOUBLE HandBrakeKey, DOUBLE MouseLockKey, DOUBLE MouseCenterKey, DOUBLE UseMouse, DOUBLE AccelerationThrottle, DOUBLE AccelerationBreak, DOUBLE AccelerationClutch) { +void mouseToVjoy::inputLogic(cInputDevices Input, INT &X, INT &Y, INT &Z, INT &RX, BOOL &BUTTON1, BOOL &BUTTON2, BOOL &BUTTON3, DOUBLE AttackTimeThrottle, DOUBLE ReleaseTimeThrottle, DOUBLE AttackTimeBreak, DOUBLE ReleaseTimeBreak, DOUBLE AttackTimeClutch, DOUBLE ReleaseTimeClutch, INT ThrottleKey, INT BreakKey, INT ClutchKey, INT GearShiftUpKey, INT GearShiftDownKey, INT HandBrakeKey, INT MouseLockKey, INT MouseCenterKey, INT UseMouse, DOUBLE AccelerationThrottle, DOUBLE AccelerationBreak, DOUBLE AccelerationClutch) { if (UseMouse == 1) { if (Input.IsLeftMouseButtonDown() && Y < 32767) { Y = (Y + AttackTimeThrottle ) * AccelerationThrottle; @@ -70,9 +69,10 @@ void mouseToVjoy::inputLogic(cInputDevices Input, INT &X, INT &Y, INT &Z, INT &R if (CursorLocked == true) { SetCursorPos(0, 0); } + } -void mouseToVjoy::mouseLogic(cInputDevices Input, INT &X, DOUBLE Sensitivity, DOUBLE SensitivityCenterReduction, INT UseCenterReduction) { +void mouseToVjoy::mouseLogic(cInputDevices Input, INT &X, DOUBLE Sensitivity, DOUBLE SensitivityCenterReduction, INT UseCenterReduction){ //vjoy max value is 0-32767 to make it easier to scale linear reduction/acceleration I subtract half of it so 16384 to make it -16384 to 16384. X = X - 16384; if (X > 0) { @@ -87,11 +87,12 @@ void mouseToVjoy::mouseLogic(cInputDevices Input, INT &X, DOUBLE Sensitivity, DO else { X = X + (Input.GetMouseChangeX() * Sensitivity); } + if (X > 16384) { X = 16384; } else if (X < -16384) { X = -16384; } - X = X + 16384; + X += 16384; }; \ No newline at end of file diff --git a/MouseToVJoy/Release/MouseToVJoy.log b/MouseToVJoy/Release/MouseToVJoy.log deleted file mode 100644 index 24e6664..0000000 --- a/MouseToVJoy/Release/MouseToVJoy.log +++ /dev/null @@ -1,85 +0,0 @@ - cInputDevices.cpp - fileRead.cpp - forceFeedBack.cpp -c:\users\lenovo\documents\github\mousetovjoy\mousetovjoy\vjoyinterface.h(91): error C3646: "position": nieznany specyfikator przesłonięcia -c:\users\lenovo\documents\github\mousetovjoy\mousetovjoy\vjoyinterface.h(91): error C4430: brak specyfikatora typu - założono, że int. Uwaga: C++ nie obsługuje domyślnie typu int -c:\users\lenovo\documents\github\mousetovjoy\mousetovjoy\vjoyinterface.h(133): error C2065: "HID_ID_EFFREP": niezadeklarowany identyfikator -c:\users\lenovo\documents\github\mousetovjoy\mousetovjoy\vjoyinterface.h(134): error C2065: "HID_ID_ENVREP": niezadeklarowany identyfikator -c:\users\lenovo\documents\github\mousetovjoy\mousetovjoy\vjoyinterface.h(135): error C2065: "HID_ID_CONDREP": niezadeklarowany identyfikator -c:\users\lenovo\documents\github\mousetovjoy\mousetovjoy\vjoyinterface.h(136): error C2065: "HID_ID_PRIDREP": niezadeklarowany identyfikator -c:\users\lenovo\documents\github\mousetovjoy\mousetovjoy\vjoyinterface.h(137): error C2065: "HID_ID_CONSTREP": niezadeklarowany identyfikator -c:\users\lenovo\documents\github\mousetovjoy\mousetovjoy\vjoyinterface.h(138): error C2065: "HID_ID_RAMPREP": niezadeklarowany identyfikator -c:\users\lenovo\documents\github\mousetovjoy\mousetovjoy\vjoyinterface.h(139): error C2065: "HID_ID_CSTMREP": niezadeklarowany identyfikator -c:\users\lenovo\documents\github\mousetovjoy\mousetovjoy\vjoyinterface.h(140): error C2065: "HID_ID_SMPLREP": niezadeklarowany identyfikator -c:\users\lenovo\documents\github\mousetovjoy\mousetovjoy\vjoyinterface.h(141): error C2065: "HID_ID_EFOPREP": niezadeklarowany identyfikator -c:\users\lenovo\documents\github\mousetovjoy\mousetovjoy\vjoyinterface.h(142): error C2065: "HID_ID_BLKFRREP": niezadeklarowany identyfikator -c:\users\lenovo\documents\github\mousetovjoy\mousetovjoy\vjoyinterface.h(143): error C2065: "HID_ID_CTRLREP": niezadeklarowany identyfikator -c:\users\lenovo\documents\github\mousetovjoy\mousetovjoy\vjoyinterface.h(144): error C2065: "HID_ID_GAINREP": niezadeklarowany identyfikator -c:\users\lenovo\documents\github\mousetovjoy\mousetovjoy\vjoyinterface.h(145): error C2065: "HID_ID_SETCREP": niezadeklarowany identyfikator -c:\users\lenovo\documents\github\mousetovjoy\mousetovjoy\vjoyinterface.h(148): error C2065: "HID_ID_NEWEFREP": niezadeklarowany identyfikator -c:\users\lenovo\documents\github\mousetovjoy\mousetovjoy\vjoyinterface.h(148): error C2056: niedozwolone wyrażenie -c:\users\lenovo\documents\github\mousetovjoy\mousetovjoy\vjoyinterface.h(149): error C2065: "HID_ID_BLKLDREP": niezadeklarowany identyfikator -c:\users\lenovo\documents\github\mousetovjoy\mousetovjoy\vjoyinterface.h(149): error C2056: niedozwolone wyrażenie -c:\users\lenovo\documents\github\mousetovjoy\mousetovjoy\vjoyinterface.h(150): error C2065: "HID_ID_POOLREP": niezadeklarowany identyfikator -c:\users\lenovo\documents\github\mousetovjoy\mousetovjoy\vjoyinterface.h(150): error C2056: niedozwolone wyrażenie -forceFeedBack.cpp(15): error C2196: wartość case "0" już użyta -forceFeedBack.cpp(18): error C2196: wartość case "0" już użyta -forceFeedBack.cpp(21): error C2196: wartość case "0" już użyta -forceFeedBack.cpp(24): error C2196: wartość case "0" już użyta -forceFeedBack.cpp(27): error C2196: wartość case "0" już użyta -forceFeedBack.cpp(30): error C2196: wartość case "0" już użyta -forceFeedBack.cpp(33): error C2196: wartość case "0" już użyta -forceFeedBack.cpp(36): error C2196: wartość case "0" już użyta -forceFeedBack.cpp(39): error C2196: wartość case "0" już użyta -forceFeedBack.cpp(42): error C2196: wartość case "0" już użyta -forceFeedBack.cpp(45): error C2196: wartość case "0" już użyta -forceFeedBack.cpp(48): error C2196: wartość case "0" już użyta -forceFeedBack.cpp(51): error C2196: wartość case "0" już użyta -forceFeedBack.cpp(54): error C2196: wartość case "0" już użyta -forceFeedBack.cpp(57): error C2196: wartość case "0" już użyta -forceFeedBack.cpp(338): warning C4244: "argument": konwersja z "LONG" do "BYTE", możliwa utrata danych -forceFeedBack.cpp(339): warning C4244: "argument": konwersja z "LONG" do "BYTE", możliwa utrata danych -forceFeedBack.cpp(340): warning C4244: "argument": konwersja z "LONG" do "BYTE", możliwa utrata danych -forceFeedBack.cpp(362): warning C4244: "argument": konwersja z "LONG" do "BYTE", możliwa utrata danych -forceFeedBack.cpp(384): warning C4244: "argument": konwersja z "LONG" do "BYTE", możliwa utrata danych -forceFeedBack.cpp(385): warning C4244: "argument": konwersja z "LONG" do "BYTE", możliwa utrata danych -forceFeedBack.cpp(265): warning C4996: 'Ffb_h_Eff_Report': ** Ffb_h_Eff_Const function was deprecated - Use function Ffb_h_Eff_Report ** - c:\users\lenovo\documents\github\mousetovjoy\mousetovjoy\vjoyinterface.h(345): note: zobacz deklarację „Ffb_h_Eff_Report” -forceFeedBack.cpp(398): warning C4996: 'FfbStart': ** FfbStart function was deprecated - you can remove it from your code ** - c:\users\lenovo\documents\github\mousetovjoy\mousetovjoy\vjoyinterface.h(332): note: zobacz deklarację „FfbStart” - main.cpp -main.cpp(92): warning C4244: "argument": konwersja z "double" do "INT", możliwa utrata danych -main.cpp(117): warning C4996: 'freopen': This function or variable may be unsafe. Consider using freopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. - C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\ucrt\stdio.h(242): note: zobacz deklarację „freopen” -main.cpp(118): warning C4996: 'freopen': This function or variable may be unsafe. Consider using freopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. - C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\ucrt\stdio.h(242): note: zobacz deklarację „freopen” - mouseToVjoy.cpp -mouseToVjoy.cpp(13): warning C4244: "=": konwersja z "DOUBLE" do "INT", możliwa utrata danych -mouseToVjoy.cpp(16): warning C4244: "=": konwersja z "DOUBLE" do "INT", możliwa utrata danych -mouseToVjoy.cpp(19): warning C4244: "=": konwersja z "DOUBLE" do "INT", możliwa utrata danych -mouseToVjoy.cpp(22): warning C4244: "=": konwersja z "DOUBLE" do "INT", możliwa utrata danych -mouseToVjoy.cpp(26): warning C4244: "argument": konwersja z "DOUBLE" do "int", możliwa utrata danych -mouseToVjoy.cpp(27): warning C4244: "=": konwersja z "DOUBLE" do "INT", możliwa utrata danych -mouseToVjoy.cpp(29): warning C4244: "argument": konwersja z "DOUBLE" do "int", możliwa utrata danych -mouseToVjoy.cpp(30): warning C4244: "=": konwersja z "DOUBLE" do "INT", możliwa utrata danych -mouseToVjoy.cpp(32): warning C4244: "argument": konwersja z "DOUBLE" do "int", możliwa utrata danych -mouseToVjoy.cpp(33): warning C4244: "=": konwersja z "DOUBLE" do "INT", możliwa utrata danych -mouseToVjoy.cpp(35): warning C4244: "argument": konwersja z "DOUBLE" do "int", możliwa utrata danych -mouseToVjoy.cpp(36): warning C4244: "=": konwersja z "DOUBLE" do "INT", możliwa utrata danych -mouseToVjoy.cpp(39): warning C4244: "argument": konwersja z "DOUBLE" do "int", możliwa utrata danych -mouseToVjoy.cpp(40): warning C4244: "=": konwersja z "DOUBLE" do "INT", możliwa utrata danych -mouseToVjoy.cpp(42): warning C4244: "argument": konwersja z "DOUBLE" do "int", możliwa utrata danych -mouseToVjoy.cpp(43): warning C4244: "=": konwersja z "DOUBLE" do "INT", możliwa utrata danych -mouseToVjoy.cpp(45): warning C4244: "argument": konwersja z "DOUBLE" do "int", możliwa utrata danych -mouseToVjoy.cpp(46): warning C4244: "argument": konwersja z "DOUBLE" do "int", możliwa utrata danych -mouseToVjoy.cpp(54): warning C4244: "argument": konwersja z "DOUBLE" do "int", możliwa utrata danych -mouseToVjoy.cpp(55): warning C4244: "argument": konwersja z "DOUBLE" do "int", możliwa utrata danych -mouseToVjoy.cpp(58): warning C4244: "argument": konwersja z "DOUBLE" do "int", możliwa utrata danych -mouseToVjoy.cpp(62): warning C4244: "argument": konwersja z "DOUBLE" do "int", możliwa utrata danych -mouseToVjoy.cpp(66): warning C4244: "argument": konwersja z "DOUBLE" do "int", możliwa utrata danych -mouseToVjoy.cpp(85): warning C4244: "=": konwersja z "DOUBLE" do "INT", możliwa utrata danych -mouseToVjoy.cpp(88): warning C4244: "=": konwersja z "DOUBLE" do "INT", możliwa utrata danych - vJoy.cpp -vJoy.cpp(17): warning C4477: „printf”: ciąg formatu „%S” wymaga argumentu typu „wchar_t *”, ale argument 1 ze zmienną liczbą argumentów ma typ „PVOID” -vJoy.cpp(27): warning C4474: „printf”: przekazano za dużo argumentów dla ciągu formatowania - vJoy.cpp(27): note: symbole zastępcze i ich parametry oczekują 0 argumentów ze zmienną liczbą argumentów, ale podano następującą liczbę zmiennych argumentów: 1 diff --git a/MouseToVJoy/Release/MouseToVJoy.tlog/CL.command.1.tlog b/MouseToVJoy/Release/MouseToVJoy.tlog/CL.command.1.tlog deleted file mode 100644 index b97890e..0000000 Binary files a/MouseToVJoy/Release/MouseToVJoy.tlog/CL.command.1.tlog and /dev/null differ diff --git a/MouseToVJoy/Release/MouseToVJoy.tlog/CL.read.1.tlog b/MouseToVJoy/Release/MouseToVJoy.tlog/CL.read.1.tlog deleted file mode 100644 index 78b678a..0000000 Binary files a/MouseToVJoy/Release/MouseToVJoy.tlog/CL.read.1.tlog and /dev/null differ diff --git a/MouseToVJoy/Release/MouseToVJoy.tlog/CL.write.1.tlog b/MouseToVJoy/Release/MouseToVJoy.tlog/CL.write.1.tlog deleted file mode 100644 index 22a551b..0000000 Binary files a/MouseToVJoy/Release/MouseToVJoy.tlog/CL.write.1.tlog and /dev/null differ diff --git a/MouseToVJoy/Release/MouseToVJoy.tlog/MouseToVJoy.lastbuildstate b/MouseToVJoy/Release/MouseToVJoy.tlog/MouseToVJoy.lastbuildstate deleted file mode 100644 index 7068ca7..0000000 --- a/MouseToVJoy/Release/MouseToVJoy.tlog/MouseToVJoy.lastbuildstate +++ /dev/null @@ -1,2 +0,0 @@ -#TargetFrameworkVersion=v4.0:PlatformToolSet=v141:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=10.0.15063.0 -Release|Win32|C:\Users\Lenovo\Documents\GitHub\mousetovjoy\| diff --git a/MouseToVJoy/Release/MouseToVJoy.tlog/unsuccessfulbuild b/MouseToVJoy/Release/MouseToVJoy.tlog/unsuccessfulbuild deleted file mode 100644 index e69de29..0000000 diff --git a/MouseToVJoy/Release/cInputDevices.obj b/MouseToVJoy/Release/cInputDevices.obj deleted file mode 100644 index d0c8608..0000000 Binary files a/MouseToVJoy/Release/cInputDevices.obj and /dev/null differ diff --git a/MouseToVJoy/Release/fileRead.obj b/MouseToVJoy/Release/fileRead.obj deleted file mode 100644 index d0a94c5..0000000 Binary files a/MouseToVJoy/Release/fileRead.obj and /dev/null differ diff --git a/MouseToVJoy/Release/main.obj b/MouseToVJoy/Release/main.obj deleted file mode 100644 index d52bbcb..0000000 Binary files a/MouseToVJoy/Release/main.obj and /dev/null differ diff --git a/MouseToVJoy/Release/mouseToVjoy.obj b/MouseToVJoy/Release/mouseToVjoy.obj deleted file mode 100644 index 1729776..0000000 Binary files a/MouseToVJoy/Release/mouseToVjoy.obj and /dev/null differ diff --git a/MouseToVJoy/Release/vJoy.obj b/MouseToVJoy/Release/vJoy.obj deleted file mode 100644 index bd18b24..0000000 Binary files a/MouseToVJoy/Release/vJoy.obj and /dev/null differ diff --git a/MouseToVJoy/Release/vc141.pdb b/MouseToVJoy/Release/vc141.pdb deleted file mode 100644 index 215b6fa..0000000 Binary files a/MouseToVJoy/Release/vc141.pdb and /dev/null differ diff --git a/MouseToVJoy/config.txt b/MouseToVJoy/config.txt index 5e7d185..8d67a17 100644 --- a/MouseToVJoy/config.txt +++ b/MouseToVJoy/config.txt @@ -15,6 +15,7 @@ MouseLockKey = 0 MouseCenterKey = 0 UseMouse = 1 UseCenterReduction = 1 +UseForceFeedback = 1 AccelerationThrottle = 1.01 AccelerationBreak = 1.01 AccelerationClutch = 1.01 diff --git a/MouseToVJoy/main.cpp b/MouseToVJoy/main.cpp index b6f7649..3d7515a 100644 --- a/MouseToVJoy/main.cpp +++ b/MouseToVJoy/main.cpp @@ -7,7 +7,6 @@ #include "public.h" #include "vjoyinterface.h" #include "input.h" -//#include "forceFeedBack.h" const char g_szClassName[] = "myWindowClass"; HWND hwnd; @@ -17,39 +16,22 @@ vJoy vJ; mouseToVjoy mTV; cInputDevices rInput; fileRead fR; -//forceFeedBack fFB; INT X, Y, Z, RX; BOOL BUTTON1, BUTTON2, BUTTON3; string keyCodeName; INT ffbSize = 0; +INT force = 0; +INT direction = 0; using namespace std; void InitializationCode() { //Code that is run only once, tests vjoy device, reads config file and prints basic out accuired vars. - - BOOL PacketType2Str(FFBPType Type, LPTSTR OutStr); - - BOOL EffectType2Str(FFBEType Type, LPTSTR OutStr); - - BOOL DevCtrl2Str(FFB_CTRL Ctrl, LPTSTR OutStr); - - BOOL EffectOpStr(FFBOP Op, LPTSTR OutStr); - int Polar2Deg(BYTE Polar); - int Byte2Percent(BYTE InByte); - - int TwosCompByte2Int(BYTE in); - - - void CALLBACK FfbFunction(PVOID data); - - void CALLBACK FfbFunction1(PVOID data, PVOID userdata); - void CALLBACK FfbToVjoy(PVOID data, PVOID userdata); UINT DevID = 1; - + vJ.testDriver(); vJ.testVirtualDevices(DevID); vJ.accuireDevice(DevID); @@ -57,10 +39,10 @@ void InitializationCode() { FfbRegisterGenCB(FfbToVjoy, &DevID); string fileName = "config.txt"; - string checkArray[21] = {"Sensitivity", "AttackTimeThrottle", "ReleaseTimeThrottle", "AttackTimeBreak", "ReleaseTimeBreak", "AttackTimeClutch", "ReleaseTimeClutch", "ThrottleKey", "BreakKey", "ClutchKey", "GearShiftUpKey", "GearShiftDownKey", "HandBrakeKey", "MouseLockKey", "MouseCenterKey", "UseMouse","UseCenterReduction" , "AccelerationThrottle", "AccelerationBreak", "AccelerationClutch", "CenterMultiplier"}; + string checkArray[22] = { "Sensitivity", "AttackTimeThrottle", "ReleaseTimeThrottle", "AttackTimeBreak", "ReleaseTimeBreak", "AttackTimeClutch", "ReleaseTimeClutch", "ThrottleKey", "BreakKey", "ClutchKey", "GearShiftUpKey", "GearShiftDownKey", "HandBrakeKey", "MouseLockKey", "MouseCenterKey", "UseMouse","UseCenterReduction" , "AccelerationThrottle", "AccelerationBreak", "AccelerationClutch", "CenterMultiplier", "UseForceFeedback" }; fR.newFile(fileName, checkArray); printf("==================================\n"); - printf("Sensitivity = %.2f \n",fR.result(0)); + printf("Sensitivity = %.2f \n", fR.result(0)); printf("Throttle Attack Time = %.0f \n", fR.result(1)); printf("Throttle Release Time = %.0f \n", fR.result(2)); printf("Break Attack Time = %.0f \n", fR.result(3)); @@ -77,6 +59,7 @@ void InitializationCode() { printf("Mouse Center key = %d \n", (int)fR.result(14)); printf("Use Mouse = %d \n", (int)fR.result(15)); printf("Use Center Reduction = %d \n", (int)fR.result(16)); + printf("Use Force Feedback = %d \n", (int)fR.result(21)); printf("Acceleration Throttle = %.2f \n", fR.result(17)); printf("Acceleration Break = %.2f \n", fR.result(18)); printf("Acceleration Clutch = %.2f \n", fR.result(19)); @@ -86,9 +69,11 @@ void InitializationCode() { void UpdateCode() { //Code that is run every time program gets an message from enviroment(mouse movement, mouse click etc.), manages input logic and feeding device. - mTV.inputLogic(rInput, X, Y, Z, RX, BUTTON1, BUTTON2, BUTTON3, fR.result(1), fR.result(2), fR.result(3), fR.result(4), fR.result(5), fR.result(6), fR.result(7), fR.result(8), fR.result(9), fR.result(10), fR.result(11), fR.result(12), fR.result(13), fR.result(14),fR.result(16), fR.result(17), fR.result(18), fR.result(19)); - X = X + ffbSize; - vJ.feedDevice(1, X, Y, Z, RX, BUTTON1, BUTTON2, BUTTON3, &ffbSize); + if (fR.result(21) == 1) { + X = X + ffbSize; + } + mTV.inputLogic(rInput, X, Y, Z, RX, BUTTON1, BUTTON2, BUTTON3, fR.result(1), fR.result(2), fR.result(3), fR.result(4), fR.result(5), fR.result(6), fR.result(7), fR.result(8), fR.result(9), fR.result(10), fR.result(11), fR.result(12), fR.result(13), fR.result(14), fR.result(16), fR.result(17), fR.result(18), fR.result(19)); + vJ.feedDevice(1, X, Y, Z, RX, BUTTON1, BUTTON2, BUTTON3, &ffbSize, fR.result(21)); } LRESULT CALLBACK WndProc(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam) @@ -128,7 +113,6 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam) int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { - //invisible window initialization to be able to recive raw input even if the window is not focused. static const char* class_name = "DUMMY_CLASS"; wc.cbSize = sizeof(WNDCLASSEX); @@ -159,8 +143,6 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine //To optimalize cpu usade wait 2 milisecond before running update code. Sleep(2); UpdateCode(); - // if (BUTTON1) printf("btn1\n"); DEBUG - // if (BUTTON2) printf("btn2\n"); DEBUG //If Message is equal to quit or destroy, break loop and end program. if (Msg.message == WM_QUIT || Msg.message == WM_DESTROY) { @@ -170,398 +152,12 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine } } -// Convert Packet type to String -BOOL PacketType2Str(FFBPType Type, LPTSTR OutStr) -{ - BOOL stat = TRUE; - LPTSTR Str = ""; - - switch (Type) - { - case PT_EFFREP: - Str = "Effect Report"; - break; - case PT_ENVREP: - Str = "Envelope Report"; - break; - case PT_CONDREP: - Str = "Condition Report"; - break; - case PT_PRIDREP: - Str = "Periodic Report"; - break; - case PT_CONSTREP: - Str = "Constant Force Report"; - break; - case PT_RAMPREP: - Str = "Ramp Force Report"; - break; - case PT_CSTMREP: - Str = "Custom Force Data Report"; - break; - case PT_SMPLREP: - Str = "Download Force Sample"; - break; - case PT_EFOPREP: - Str = "Effect Operation Report"; - break; - case PT_BLKFRREP: - Str = "PID Block Free Report"; - break; - case PT_CTRLREP: - Str = "PID Device Contro"; - break; - case PT_GAINREP: - Str = "Device Gain Report"; - break; - case PT_SETCREP: - Str = "Set Custom Force Report"; - break; - case PT_NEWEFREP: - Str = "Create New Effect Report"; - break; - case PT_BLKLDREP: - Str = "Block Load Report"; - break; - case PT_POOLREP: - Str = "PID Pool Report"; - break; - default: - stat = FALSE; - break; - } - - if (stat) - _tcscpy_s(OutStr, 100, Str); - - return stat; -} - -// Convert Effect type to String -BOOL EffectType2Str(FFBEType Type, LPTSTR OutStr) -{ - BOOL stat = TRUE; - LPTSTR Str = ""; - - switch (Type) - { - case ET_NONE: - stat = FALSE; - break; - case ET_CONST: - Str = "Constant Force"; - break; - case ET_RAMP: - Str = "Ramp"; - break; - case ET_SQR: - Str = "Square"; - break; - case ET_SINE: - Str = "Sine"; - break; - case ET_TRNGL: - Str = "Triangle"; - break; - case ET_STUP: - Str = "Sawtooth Up"; - break; - case ET_STDN: - Str = "Sawtooth Down"; - break; - case ET_SPRNG: - Str = "Spring"; - break; - case ET_DMPR: - Str = "Damper"; - break; - case ET_INRT: - Str = "Inertia"; - break; - case ET_FRCTN: - Str = "Friction"; - break; - case ET_CSTM: - Str = "Custom Force"; - break; - default: - stat = FALSE; - break; - }; - - if (stat) - _tcscpy_s(OutStr, 100, Str); - - return stat; -} - -// Convert PID Device Control to String -BOOL DevCtrl2Str(FFB_CTRL Ctrl, LPTSTR OutStr) -{ - BOOL stat = TRUE; - LPTSTR Str = ""; - - switch (Ctrl) - { - case CTRL_ENACT: - Str = "Enable Actuators"; - break; - case CTRL_DISACT: - Str = "Disable Actuators"; - break; - case CTRL_STOPALL: - Str = "Stop All Effects"; - break; - case CTRL_DEVRST: - Str = "Device Reset"; - break; - case CTRL_DEVPAUSE: - Str = "Device Pause"; - break; - case CTRL_DEVCONT: - Str = "Device Continue"; - break; - default: - stat = FALSE; - break; - } - if (stat) - _tcscpy_s(OutStr, 100, Str); - - return stat; -} - -// Convert Effect operation to string -BOOL EffectOpStr(FFBOP Op, LPTSTR OutStr) -{ - BOOL stat = TRUE; - LPTSTR Str = ""; - - switch (Op) - { - case EFF_START: - Str = "Effect Start"; - break; - case EFF_SOLO: - Str = "Effect Solo Start"; - break; - case EFF_STOP: - Str = "Effect Stop"; - break; - default: - stat = FALSE; - break; - } - - if (stat) - _tcscpy_s(OutStr, 100, Str); - - return stat; -} - // Polar values (0x00-0xFF) to Degrees (0-360) int Polar2Deg(BYTE Polar) { return ((UINT)Polar * 360) / 255; } -// Convert range 0x00-0xFF to 0%-100% -int Byte2Percent(BYTE InByte) -{ - return ((UINT)InByte * 100) / 255; -} - -// Convert One-Byte 2's complement input to integer -int TwosCompByte2Int(BYTE in) -{ - int tmp; - BYTE inv = ~in; - BOOL isNeg = in >> 7; - if (isNeg) - { - tmp = (int)(inv); - tmp = -1 * tmp; - return tmp; - } - else - return (int)in; -} - -void CALLBACK FfbFunction(PVOID data) -{ - FFB_DATA * FfbData = (FFB_DATA *)data; - int size = FfbData->size; - printf("\nFFB Size %d\n", size); - - printf("Cmd:%08.8X ", FfbData->cmd); - printf("ID:%02.2X ", FfbData->data[0]); - printf("Size:%02.2d ", static_cast(FfbData->size - 8)); - printf(" - "); - for (UINT i = 0; i < FfbData->size - 8; i++) - printf(" %02.2X", (UINT)FfbData->data); - printf("\n"); -} - -void CALLBACK FfbFunction1(PVOID data, PVOID userdata) -{ - // Packet Header - printf("\n ============= FFB Packet size Size %d =============\n", static_cast(((FFB_DATA *)data)->size)); - - /////// Packet Device ID, and Type Block Index (if exists) -#pragma region Packet Device ID, and Type Block Index - int DeviceID, BlockIndex; - FFBPType Type; - TCHAR TypeStr[100]; - - if (ERROR_SUCCESS == Ffb_h_DeviceID((FFB_DATA *)data, &DeviceID)) - printf("\n > Device ID: %d", DeviceID); - if (ERROR_SUCCESS == Ffb_h_Type((FFB_DATA *)data, &Type)) - { - if (!PacketType2Str(Type, TypeStr)) - printf("\n > Packet Type: %d", Type); - else - printf("\n > Packet Type: %s", TypeStr); - - } - if (ERROR_SUCCESS == Ffb_h_EBI((FFB_DATA *)data, &BlockIndex)) - printf("\n > Effect Block Index: %d", BlockIndex); -#pragma endregion - - - /////// Effect Report -#pragma region Effect Report - FFB_EFF_CONST Effect; - if (ERROR_SUCCESS == Ffb_h_Eff_Report((FFB_DATA *)data, &Effect)) - { - if (!EffectType2Str(Effect.EffectType, TypeStr)) - printf("\n >> Effect Report: %02x", Effect.EffectType); - else - printf("\n >> Effect Report: %s", TypeStr); - - if (Effect.Polar) - { - printf("\n >> Direction: %d deg (%02x)", Polar2Deg(Effect.Direction), Effect.Direction); - - - } - else - { - printf("\n >> X Direction: %02x", Effect.DirX); - printf("\n >> Y Direction: %02x", Effect.DirY); - }; - - if (Effect.Duration == 0xFFFF) - printf("\n >> Duration: Infinit"); - else - printf("\n >> Duration: %d MilliSec", static_cast(Effect.Duration)); - - if (Effect.TrigerRpt == 0xFFFF) - printf("\n >> Trigger Repeat: Infinit"); - else - printf("\n >> Trigger Repeat: %d", static_cast(Effect.TrigerRpt)); - - if (Effect.SamplePrd == 0xFFFF) - printf("\n >> Sample Period: Infinit"); - else - printf("\n >> Sample Period: %d", static_cast(Effect.SamplePrd)); - - - printf("\n >> Gain: %d%%", Byte2Percent(Effect.Gain)); - - }; -#pragma endregion -#pragma region PID Device Control - FFB_CTRL Control; - TCHAR CtrlStr[100]; - if (ERROR_SUCCESS == Ffb_h_DevCtrl((FFB_DATA *)data, &Control) && DevCtrl2Str(Control, CtrlStr)) - printf("\n >> PID Device Control: %s", CtrlStr); - -#pragma endregion -#pragma region Effect Operation - FFB_EFF_OP Operation; - TCHAR EffOpStr[100]; - if (ERROR_SUCCESS == Ffb_h_EffOp((FFB_DATA *)data, &Operation) && EffectOpStr(Operation.EffectOp, EffOpStr)) - { - _tprintf("\n >> Effect Operation: %s", EffOpStr); - if (Operation.LoopCount == 0xFF) - printf("\n >> Loop until stopped"); - else - printf("\n >> Loop %d times", static_cast(Operation.LoopCount)); - - }; -#pragma endregion -#pragma region Global Device Gain - BYTE Gain; - if (ERROR_SUCCESS == Ffb_h_DevGain((FFB_DATA *)data, &Gain)) - printf("\n >> Global Device Gain: %d", Byte2Percent(Gain)); - -#pragma endregion -#pragma region Condition - FFB_EFF_COND Condition; - if (ERROR_SUCCESS == Ffb_h_Eff_Cond((FFB_DATA *)data, &Condition)) - { - if (Condition.isY) - _tprintf("\n >> Y Axis"); - else - _tprintf("\n >> X Axis"); - _tprintf("\n >> Center Point Offset: %d", TwosCompByte2Int(Condition.CenterPointOffset) * 10000 / 127); - _tprintf("\n >> Positive Coefficient: %d", TwosCompByte2Int(Condition.PosCoeff) * 10000 / 127); - _tprintf("\n >> Negative Coefficient: %d", TwosCompByte2Int(Condition.NegCoeff) * 10000 / 127); - _tprintf("\n >> Positive Saturation: %d", Condition.PosSatur * 10000 / 255); - _tprintf("\n >> Negative Saturation: %d", Condition.NegSatur * 10000 / 255); - _tprintf("\n >> Dead Band: %d", Condition.DeadBand * 10000 / 255); - } -#pragma endregion -#pragma region Envelope - FFB_EFF_ENVLP Envelope; - if (ERROR_SUCCESS == Ffb_h_Eff_Envlp((FFB_DATA *)data, &Envelope)) - { - _tprintf("\n >> Attack Level: %d", Envelope.AttackLevel * 10000 / 255); - _tprintf("\n >> Fade Level: %d", Envelope.FadeLevel * 10000 / 255); - _tprintf("\n >> Attack Time: %d", static_cast(Envelope.AttackTime)); - _tprintf("\n >> Fade Time: %d", static_cast(Envelope.FadeTime)); - }; - -#pragma endregion -#pragma region Periodic - FFB_EFF_PERIOD EffPrd; - if (ERROR_SUCCESS == Ffb_h_Eff_Period((FFB_DATA *)data, &EffPrd)) - { - _tprintf("\n >> Magnitude: %d", EffPrd.Magnitude * 10000 / 255); - _tprintf("\n >> Offset: %d", TwosCompByte2Int(EffPrd.Offset) * 10000 / 127); - _tprintf("\n >> Phase: %d", EffPrd.Phase * 3600 / 255); - _tprintf("\n >> Period: %d", static_cast(EffPrd.Period)); - }; -#pragma endregion - -#pragma region Effect Type - FFBEType EffectType; - if (ERROR_SUCCESS == Ffb_h_EffNew((FFB_DATA *)data, &EffectType)) - { - if (EffectType2Str(EffectType, TypeStr)) - _tprintf("\n >> Effect Type: %s", TypeStr); - else - _tprintf("\n >> Effect Type: Unknown"); - } - -#pragma endregion - -#pragma region Ramp Effect - FFB_EFF_RAMP RampEffect; - if (ERROR_SUCCESS == Ffb_h_Eff_Ramp((FFB_DATA *)data, &RampEffect)) - { - _tprintf("\n >> Ramp Start: %d", TwosCompByte2Int(RampEffect.Start) * 10000 / 127); - _tprintf("\n >> Ramp End: %d", TwosCompByte2Int(RampEffect.End) * 10000 / 127); - }; - -#pragma endregion - - printf("\n"); - FfbFunction(data); - printf("\n ====================================================\n"); - -} - void CALLBACK FfbToVjoy(PVOID data, PVOID userdata) { // Packet Header //printf("\n ============= FFB Packet size Size %d =============\n", static_cast(((FFB_DATA *)data)->size)); @@ -574,18 +170,19 @@ void CALLBACK FfbToVjoy(PVOID data, PVOID userdata) { #pragma region Effect Report FFB_EFF_CONST Effect; - if (ERROR_SUCCESS == Ffb_h_Eff_Report((FFB_DATA *)data, &Effect)) - { - printf("\n"); - //FfbFunction(data); - //printf("\n ====================================================\n"); - - if (Polar2Deg(Effect.Direction) > 100) { - ffbSize = 0; - } - else { - ffbSize = 0; - } - printf("ForceFeedBack is equal to: %ld and degrees to: %d", NULL, Polar2Deg(Effect.Direction)); + FFB_EFF_CONSTANT ConstantEffect; + if (ERROR_SUCCESS == Ffb_h_Eff_Constant((FFB_DATA *)data, &ConstantEffect)) { + force = ConstantEffect.Magnitude/1000; + printf("Force to : %d\n", force); + } + if (ERROR_SUCCESS == Ffb_h_Eff_Report((FFB_DATA *)data, &Effect)) { + direction = Polar2Deg(Effect.Direction); + //printf("Degrees to: %d\n", Polar2Deg(Effect.Direction)); + } + if (direction > 100) { + ffbSize = force; + } + else { + ffbSize = -force; } } diff --git a/MouseToVJoy/mousetovjoy.h b/MouseToVJoy/mousetovjoy.h index 64feecc..694215a 100644 --- a/MouseToVJoy/mousetovjoy.h +++ b/MouseToVJoy/mousetovjoy.h @@ -8,9 +8,9 @@ class mouseToVjoy { public: //Function responsible for getting and modifying vars for throttle, break, clutch. - void inputLogic(cInputDevices Input, INT &X, INT &Y, INT &Z, INT &RX, BOOL &BUTTON1, BOOL &BUTTON2, BOOL &BUTTON3, DOUBLE AttackTimeThrottle, DOUBLE ReleaseTimeThrottle, DOUBLE AttackTimeBreak, DOUBLE ReleaseTimeBreak, DOUBLE AttackTimeClutch, DOUBLE ReleaseTimeClutch, DOUBLE ThrottleKey, DOUBLE BreakKey, DOUBLE ClutchKey, DOUBLE GearShiftUpKey, DOUBLE GearShiftDownKey, DOUBLE HandBrakeKey, DOUBLE MouseLockKey, DOUBLE MouseCenterKey, DOUBLE UseMouse, DOUBLE AccelerationThrottle, DOUBLE AccelerationBreak, DOUBLE AccelerationClutch); + void mouseToVjoy::inputLogic(cInputDevices Input, INT &X, INT &Y, INT &Z, INT &RX, BOOL &BUTTON1, BOOL &BUTTON2, BOOL &BUTTON3, DOUBLE AttackTimeThrottle, DOUBLE ReleaseTimeThrottle, DOUBLE AttackTimeBreak, DOUBLE ReleaseTimeBreak, DOUBLE AttackTimeClutch, DOUBLE ReleaseTimeClutch, INT ThrottleKey, INT BreakKey, INT ClutchKey, INT GearShiftUpKey, INT GearShiftDownKey, INT HandBrakeKey, INT MouseLockKey, INT MouseCenterKey, INT UseMouse, DOUBLE AccelerationThrottle, DOUBLE AccelerationBreak, DOUBLE AccelerationClutch); //Function responsible for getting and modifying vars for steering wheel. - void mouseLogic(cInputDevices Input, INT &X, DOUBLE Sensitivity, DOUBLE CenterMultiplier, INT UseCenterReduction); + void mouseToVjoy::mouseLogic(cInputDevices Input, INT &X, DOUBLE Sensitivity, DOUBLE SensitivityCenterReduction, INT UseCenterReduction); //Gets if the Cursor is locked then, sets cursor in cords 0,0 every input. bool CursorLocked; //Gets if the Center Reduction is used, when used function mouselogic() uses linear algorithm to calculate sensitivity, the more the joystick is centered the sloweer the sensitivity(max 1.0 of the sensitivity.), the further the faster the sensitivity(max = CenterReduction value * Sensitivity ) diff --git a/MouseToVJoy/template.cpp b/MouseToVJoy/template.cpp deleted file mode 100644 index e442ce7..0000000 --- a/MouseToVJoy/template.cpp +++ /dev/null @@ -1,568 +0,0 @@ -// Monitor Force Feedback (FFB) vJoy device -//#include "stdafx.h" -//#include "Devioctl.h" -#include "public.h" -#include -#include -#include -#include "vjoyinterface.h" -#include "Math.h" -#include "vjoy.h" -using namespace std; -// Default device ID (Used when ID not specified) -#define DEV_ID 1 - -// Prototypes -void CALLBACK FfbFunction(PVOID data); -void CALLBACK FfbFunction1(PVOID cb, PVOID data); - -BOOL PacketType2Str(FFBPType Type, LPTSTR Str); -BOOL EffectType2Str(FFBEType Ctrl, LPTSTR Str); -BOOL DevCtrl2Str(FFB_CTRL Type, LPTSTR Str); -BOOL EffectOpStr(FFBOP Op, LPTSTR Str); -int Polar2Deg(BYTE Polar); -int Byte2Percent(BYTE InByte); -int TwosCompByte2Int(BYTE in); - - -int ffb_direction = 0; -int ffb_strenght = 0; -int serial_result = 0; - - -JOYSTICK_POSITION_V2 iReport; // The structure that holds the full position data - -int -__cdecl -_tmain(int argc, _TCHAR* argv[]) -{ - int stat = 0; - UINT DevID = DEV_ID; - USHORT X = 0; - USHORT Y = 0; - USHORT Z = 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; - - // Define the effect names - static FFBEType FfbEffect = (FFBEType)-1; - LPCTSTR FfbEffectName[] = - { "NONE", "Constant Force", "Ramp", "Square", "Sine", "Triangle", "Sawtooth Up",\ - "Sawtooth Down", "Spring", "Damper", "Inertia", "Friction", "Custom Force" }; - - // Set the target Joystick - get it from the command-line - if (argc>1) - DevID = _tstoi(argv[1]); - - // Get the driver attributes (Vendor ID, Product ID, Version Number) - if (!vJoyEnabled()) - { - _tprintf("Function vJoyEnabled Failed - make sure that vJoy is installed and enabled\n"); - int dummy = getchar(); - stat = -2; - goto Exit; - } - else - { - wprintf(L"Vendor: %s\nProduct :%s\nVersion Number:%s\n", static_cast (GetvJoyManufacturerString()), static_cast(GetvJoyProductString()), static_cast(GetvJoySerialNumberString())); - }; - - // Get the status of the vJoy device before trying to acquire it - VjdStat status = GetVJDStatus(DevID); - - switch (status) - { - case VJD_STAT_OWN: - _tprintf("vJoy device %d is already owned by this feeder\n", DevID); - break; - case VJD_STAT_FREE: - _tprintf("vJoy device %d is free\n", DevID); - break; - case VJD_STAT_BUSY: - _tprintf("vJoy device %d is already owned by another feeder\nCannot continue\n", DevID); - return -3; - case VJD_STAT_MISS: - _tprintf("vJoy device %d is not installed or disabled\nCannot continue\n", DevID); - return -4; - default: - _tprintf("vJoy device %d general error\nCannot continue\n", DevID); - return -1; - }; - - // Acquire the vJoy device - if (!AcquireVJD(DevID)) - { - _tprintf("Failed to acquire vJoy device number %d.\n", DevID); - int dummy = getchar(); - stat = -1; - goto Exit; - } - else - _tprintf("Acquired device number %d - OK\n", DevID); - - - - // Start FFB -#if 1 - BOOL Ffbstarted = FfbStart(DevID); - if (!Ffbstarted) - { - _tprintf("Failed to start FFB on vJoy device number %d.\n", DevID); - int dummy = getchar(); - stat = -3; - goto Exit; - } - else - _tprintf("Started FFB on vJoy device number %d - OK\n", DevID); - -#endif // 1 - - // Register Generic callback function - // At this point you instruct the Receptor which callback function to call with every FFB packet it receives - // It is the role of the designer to register the right FFB callback function - FfbRegisterGenCB(FfbFunction1, NULL); - - - - - // Start endless loop - // The loop injects position data to the vJoy device - // If it fails it let's the user try again - // - // FFB Note: - // All FFB activity is performed in a separate thread created when registered the callback function - while (1) - { - - // Set destenition vJoy device - id = (BYTE)DevID; - iReport.bDevice = id; - - // Set position data of 3 first axes - if (Z>35000) Z = 0; - Z += 200; - iReport.wAxisZ = Z; - iReport.wAxisX = 32000 - Z; - iReport.wAxisY = Z / 2 + 7000; - - // Set position data of first 8 buttons - Btns = 1 << (Z / 4000); - iReport.lButtons = Btns; - - // Send position data to vJoy device - pPositionMessage = (PVOID)(&iReport); - if (!UpdateVJD(DevID, pPositionMessage)) - { - printf("Feeding vJoy device number %d failed - try to enable device then press enter\n", DevID); - getchar(); - AcquireVJD(DevID); - } - Sleep(2); - } - -Exit: - RelinquishVJD(DevID); - return 0; -} - - -// Generic callback function -void CALLBACK FfbFunction(PVOID data) -{ - FFB_DATA * FfbData = (FFB_DATA *)data; - int size = FfbData->size; - _tprintf("\nFFB Size %d\n", size); - - _tprintf("Cmd:%08.8X ", FfbData->cmd); - _tprintf("ID:%02.2X ", FfbData->data[0]); - _tprintf("Size:%02.2d ", static_cast(FfbData->size - 8)); - _tprintf(" - "); - for (UINT i = 0; i < FfbData->size - 8; i++) - _tprintf(" %02.2X", (UINT)FfbData->data); - _tprintf("\n"); -} - -void CALLBACK FfbFunction1(PVOID data, PVOID userdata) -{ - // Packet Header - _tprintf("\n ============= FFB Packet size Size %d =============\n", static_cast(((FFB_DATA *)data)->size)); - - /////// Packet Device ID, and Type Block Index (if exists) -#pragma region Packet Device ID, and Type Block Index - int DeviceID, BlockIndex; - FFBPType Type; - TCHAR TypeStr[100]; - - if (ERROR_SUCCESS == Ffb_h_DeviceID((FFB_DATA *)data, &DeviceID)) - _tprintf("\n > Device ID: %d", DeviceID); - if (ERROR_SUCCESS == Ffb_h_Type((FFB_DATA *)data, &Type)) - { - if (!PacketType2Str(Type, TypeStr)) - _tprintf("\n > Packet Type: %d", Type); - else - _tprintf("\n > Packet Type: %s", TypeStr); - - } - if (ERROR_SUCCESS == Ffb_h_EBI((FFB_DATA *)data, &BlockIndex)) - _tprintf("\n > Effect Block Index: %d", BlockIndex); -#pragma endregion - - - /////// Effect Report -#pragma region Effect Report - FFB_EFF_CONST Effect; - if (ERROR_SUCCESS == Ffb_h_Eff_Report((FFB_DATA *)data, &Effect)) - { - if (!EffectType2Str(Effect.EffectType, TypeStr)) - _tprintf("\n >> Effect Report: %02x", Effect.EffectType); - else - _tprintf("\n >> Effect Report: %s", TypeStr); - - if (Effect.Polar) - { - _tprintf("\n >> Direction: %d deg (%02x)", Polar2Deg(Effect.Direction), Effect.Direction); - - - } - else - { - _tprintf("\n >> X Direction: %02x", Effect.DirX); - _tprintf("\n >> Y Direction: %02x", Effect.DirY); - }; - - if (Effect.Duration == 0xFFFF) - _tprintf("\n >> Duration: Infinit"); - else - _tprintf("\n >> Duration: %d MilliSec", static_cast(Effect.Duration)); - - if (Effect.TrigerRpt == 0xFFFF) - _tprintf("\n >> Trigger Repeat: Infinit"); - else - _tprintf("\n >> Trigger Repeat: %d", static_cast(Effect.TrigerRpt)); - - if (Effect.SamplePrd == 0xFFFF) - _tprintf("\n >> Sample Period: Infinit"); - else - _tprintf("\n >> Sample Period: %d", static_cast(Effect.SamplePrd)); - - - _tprintf("\n >> Gain: %d%%", Byte2Percent(Effect.Gain)); - - }; -#pragma endregion -#pragma region PID Device Control - FFB_CTRL Control; - TCHAR CtrlStr[100]; - if (ERROR_SUCCESS == Ffb_h_DevCtrl((FFB_DATA *)data, &Control) && DevCtrl2Str(Control, CtrlStr)) - _tprintf("\n >> PID Device Control: %s", CtrlStr); - -#pragma endregion -#pragma region Effect Operation - FFB_EFF_OP Operation; - TCHAR EffOpStr[100]; - if (ERROR_SUCCESS == Ffb_h_EffOp((FFB_DATA *)data, &Operation) && EffectOpStr(Operation.EffectOp, EffOpStr)) - { - _tprintf("\n >> Effect Operation: %s", EffOpStr); - if (Operation.LoopCount == 0xFF) - _tprintf("\n >> Loop until stopped"); - else - _tprintf("\n >> Loop %d times", static_cast(Operation.LoopCount)); - - }; -#pragma endregion -#pragma region Global Device Gain - BYTE Gain; - if (ERROR_SUCCESS == Ffb_h_DevGain((FFB_DATA *)data, &Gain)) - _tprintf("\n >> Global Device Gain: %d", Byte2Percent(Gain)); - -#pragma endregion -#pragma region Condition - FFB_EFF_COND Condition; - if (ERROR_SUCCESS == Ffb_h_Eff_Cond((FFB_DATA *)data, &Condition)) - { - if (Condition.isY) - _tprintf("\n >> Y Axis"); - else - _tprintf("\n >> X Axis"); - _tprintf("\n >> Center Point Offset: %d", TwosCompByte2Int(Condition.CenterPointOffset) * 10000 / 127); - _tprintf("\n >> Positive Coefficient: %d", TwosCompByte2Int(Condition.PosCoeff) * 10000 / 127); - _tprintf("\n >> Negative Coefficient: %d", TwosCompByte2Int(Condition.NegCoeff) * 10000 / 127); - _tprintf("\n >> Positive Saturation: %d", Condition.PosSatur * 10000 / 255); - _tprintf("\n >> Negative Saturation: %d", Condition.NegSatur * 10000 / 255); - _tprintf("\n >> Dead Band: %d", Condition.DeadBand * 10000 / 255); - } -#pragma endregion -#pragma region Envelope - FFB_EFF_ENVLP Envelope; - if (ERROR_SUCCESS == Ffb_h_Eff_Envlp((FFB_DATA *)data, &Envelope)) - { - _tprintf("\n >> Attack Level: %d", Envelope.AttackLevel * 10000 / 255); - _tprintf("\n >> Fade Level: %d", Envelope.FadeLevel * 10000 / 255); - _tprintf("\n >> Attack Time: %d", static_cast(Envelope.AttackTime)); - _tprintf("\n >> Fade Time: %d", static_cast(Envelope.FadeTime)); - }; - -#pragma endregion -#pragma region Periodic - FFB_EFF_PERIOD EffPrd; - if (ERROR_SUCCESS == Ffb_h_Eff_Period((FFB_DATA *)data, &EffPrd)) - { - _tprintf("\n >> Magnitude: %d", EffPrd.Magnitude * 10000 / 255); - _tprintf("\n >> Offset: %d", TwosCompByte2Int(EffPrd.Offset) * 10000 / 127); - _tprintf("\n >> Phase: %d", EffPrd.Phase * 3600 / 255); - _tprintf("\n >> Period: %d", static_cast(EffPrd.Period)); - }; -#pragma endregion - -#pragma region Effect Type - FFBEType EffectType; - if (ERROR_SUCCESS == Ffb_h_EffNew((FFB_DATA *)data, &EffectType)) - { - if (EffectType2Str(EffectType, TypeStr)) - _tprintf("\n >> Effect Type: %s", TypeStr); - else - _tprintf("\n >> Effect Type: Unknown"); - } - -#pragma endregion - -#pragma region Ramp Effect - FFB_EFF_RAMP RampEffect; - if (ERROR_SUCCESS == Ffb_h_Eff_Ramp((FFB_DATA *)data, &RampEffect)) - { - _tprintf("\n >> Ramp Start: %d", TwosCompByte2Int(RampEffect.Start) * 10000 / 127); - _tprintf("\n >> Ramp End: %d", TwosCompByte2Int(RampEffect.End) * 10000 / 127); - }; - -#pragma endregion - - _tprintf("\n"); - FfbFunction(data); - _tprintf("\n ====================================================\n"); - -} - - -// Convert Packet type to String -BOOL PacketType2Str(FFBPType Type, LPTSTR OutStr) -{ - BOOL stat = TRUE; - LPTSTR Str = ""; - - switch (Type) - { - case PT_EFFREP: - Str = "Effect Report"; - break; - case PT_ENVREP: - Str = "Envelope Report"; - break; - case PT_CONDREP: - Str = "Condition Report"; - break; - case PT_PRIDREP: - Str = "Periodic Report"; - break; - case PT_CONSTREP: - Str = "Constant Force Report"; - break; - case PT_RAMPREP: - Str = "Ramp Force Report"; - break; - case PT_CSTMREP: - Str = "Custom Force Data Report"; - break; - case PT_SMPLREP: - Str = "Download Force Sample"; - break; - case PT_EFOPREP: - Str = "Effect Operation Report"; - break; - case PT_BLKFRREP: - Str = "PID Block Free Report"; - break; - case PT_CTRLREP: - Str = "PID Device Contro"; - break; - case PT_GAINREP: - Str = "Device Gain Report"; - break; - case PT_SETCREP: - Str = "Set Custom Force Report"; - break; - case PT_NEWEFREP: - Str = "Create New Effect Report"; - break; - case PT_BLKLDREP: - Str = "Block Load Report"; - break; - case PT_POOLREP: - Str = "PID Pool Report"; - break; - default: - stat = FALSE; - break; - } - - if (stat) - _tcscpy_s(OutStr, 100, Str); - - return stat; -} - -// Convert Effect type to String -BOOL EffectType2Str(FFBEType Type, LPTSTR OutStr) -{ - BOOL stat = TRUE; - LPTSTR Str = ""; - - switch (Type) - { - case ET_NONE: - stat = FALSE; - break; - case ET_CONST: - Str = "Constant Force"; - break; - case ET_RAMP: - Str = "Ramp"; - break; - case ET_SQR: - Str = "Square"; - break; - case ET_SINE: - Str = "Sine"; - break; - case ET_TRNGL: - Str = "Triangle"; - break; - case ET_STUP: - Str = "Sawtooth Up"; - break; - case ET_STDN: - Str = "Sawtooth Down"; - break; - case ET_SPRNG: - Str = "Spring"; - break; - case ET_DMPR: - Str = "Damper"; - break; - case ET_INRT: - Str = "Inertia"; - break; - case ET_FRCTN: - Str = "Friction"; - break; - case ET_CSTM: - Str = "Custom Force"; - break; - default: - stat = FALSE; - break; - }; - - if (stat) - _tcscpy_s(OutStr, 100, Str); - - return stat; -} - -// Convert PID Device Control to String -BOOL DevCtrl2Str(FFB_CTRL Ctrl, LPTSTR OutStr) -{ - BOOL stat = TRUE; - LPTSTR Str = ""; - - switch (Ctrl) - { - case CTRL_ENACT: - Str = "Enable Actuators"; - break; - case CTRL_DISACT: - Str = "Disable Actuators"; - break; - case CTRL_STOPALL: - Str = "Stop All Effects"; - break; - case CTRL_DEVRST: - Str = "Device Reset"; - break; - case CTRL_DEVPAUSE: - Str = "Device Pause"; - break; - case CTRL_DEVCONT: - Str = "Device Continue"; - break; - default: - stat = FALSE; - break; - } - if (stat) - _tcscpy_s(OutStr, 100, Str); - - return stat; -} - -// Convert Effect operation to string -BOOL EffectOpStr(FFBOP Op, LPTSTR OutStr) -{ - BOOL stat = TRUE; - LPTSTR Str = ""; - - switch (Op) - { - case EFF_START: - Str = "Effect Start"; - break; - case EFF_SOLO: - Str = "Effect Solo Start"; - break; - case EFF_STOP: - Str = "Effect Stop"; - break; - default: - stat = FALSE; - break; - } - - if (stat) - _tcscpy_s(OutStr, 100, Str); - - return stat; -} - -// Polar values (0x00-0xFF) to Degrees (0-360) -int Polar2Deg(BYTE Polar) -{ - return ((UINT)Polar * 360) / 255; -} - -// Convert range 0x00-0xFF to 0%-100% -int Byte2Percent(BYTE InByte) -{ - return ((UINT)InByte * 100) / 255; -} - -// Convert One-Byte 2's complement input to integer -int TwosCompByte2Int(BYTE in) -{ - int tmp; - BYTE inv = ~in; - BOOL isNeg = in >> 7; - if (isNeg) - { - tmp = (int)(inv); - tmp = -1 * tmp; - return tmp; - } - else - return (int)in; -} \ No newline at end of file diff --git a/MouseToVJoy/vJoy.cpp b/MouseToVJoy/vJoy.cpp index 5b9ea48..2bce037 100644 --- a/MouseToVJoy/vJoy.cpp +++ b/MouseToVJoy/vJoy.cpp @@ -6,7 +6,7 @@ int vJoy::testDriver() { printf("Mouse to vJoy Feeder\n"); printf("==================================\n"); printf("Author: R1per\n"); - printf("Version: 1.6 BETA\n"); + printf("Version: 1.6\n"); // Get the driver attributes (Vendor ID, Product ID, Version Number) if (!vJoyEnabled()) { @@ -80,7 +80,7 @@ int vJoy::enableFFB(UINT iInterface) { return 0; } -void vJoy::feedDevice(UINT iInterface, INT X, INT Y, INT Z, INT RX, BOOL BUTTON1, BOOL BUTTON2, BOOL BUTTON3, INT *FFBSIZE) { +void vJoy::feedDevice(UINT iInterface, INT X, INT Y, INT Z, INT RX, BOOL BUTTON1, BOOL BUTTON2, BOOL BUTTON3, INT *FFBSIZE, DOUBLE UseForceFeedback) { iReport.bDevice = iInterface; iReport.wAxisX = X; iReport.wAxisY = Y; diff --git a/MouseToVJoy/vjoy.h b/MouseToVJoy/vjoy.h index 1e8a675..5ce0f42 100644 --- a/MouseToVJoy/vjoy.h +++ b/MouseToVJoy/vjoy.h @@ -22,7 +22,7 @@ class vJoy { //If UINT iInterface exist, enable FFB to device. int enableFFB(UINT iInterface); //When UINT iInterface is accuired, feeds vars X Y Z RX to Axises X Y Z RX. - void feedDevice(UINT iInterface, INT X, INT Y, INT Z, INT RX, BOOL BUTTON1, BOOL BUTTON2, BOOL BUTTON3, INT *FFBSIZE); + void feedDevice(UINT iInterface, INT X, INT Y, INT Z, INT RX, BOOL BUTTON1, BOOL BUTTON2, BOOL BUTTON3, INT *FFBSIZE, DOUBLE UseForceFeedback); private: //Gets status from vjoy device using vjoyinterface.dll.