-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
51 lines (49 loc) · 2.23 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using System;
using System.Threading;
using fanatec_clutch_mapper.Service;
namespace fanatec_clutch_mapper {
class Program {
static void Main(string[] args) {
ConfigService config = new ConfigService("config.xml");
if (!config.Exists()) {
config.Save();
Console.WriteLine("Created config.xml. You can edit it now.");
Console.WriteLine("Press any key to continue ...");
Console.ReadKey();
}
config.Read();
FanatecGamepadService service = new FanatecGamepadService(config.Wheel);
while (service.IsError) {
service.Load();
Console.WriteLine("No Fanatec device found. Retry to load in 5s.");
Thread.Sleep(5000);
}
Console.WriteLine("Waiting for Fanatec Wheel buttons");
while (true) {
service.ReadState();
service.GetLeftPedal();
service.GetRightPedal();
int leftPressed = service.GetLeftPressed();
int rightPressed = service.GetRightPressed();
if (leftPressed != 0) {
if (leftPressed > config.Wheel.MaxPedalValue * (config.Configuration.FullPressThreshold / 100)) {
System.Windows.Forms.SendKeys.SendWait(config.Configuration.LeftPressKey);
Console.WriteLine("LEFT PRESS");
} else {
System.Windows.Forms.SendKeys.SendWait(config.Configuration.LeftShortKey);
Console.WriteLine("LEFT SHORT PRESS");
}
}
if (rightPressed != 0) {
if (rightPressed > config.Wheel.MaxPedalValue * (config.Configuration.FullPressThreshold / 100)) {
System.Windows.Forms.SendKeys.SendWait(config.Configuration.RightPressKey);
Console.WriteLine("RIGHT PRESS");
} else {
System.Windows.Forms.SendKeys.SendWait(config.Configuration.RightShortKey);
Console.WriteLine("RIGHT SHORT PRESS");
}
}
}
}
}
}