forked from quimcalpe/iracing-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
65 lines (58 loc) · 1.26 KB
/
main.go
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package main
//#include<conio.h>
import "C"
import (
"fmt"
"os"
"github.com/quimcalpe/iracing-sdk"
)
func main() {
var sdk irsdk.IRSDK
sdk = irsdk.Init(nil)
defer sdk.Close()
fmt.Println("Available commands:")
fmt.Println(" c -> Open chat")
fmt.Println(" p -> Clear tire pit checkboxes")
fmt.Println(" f -> Change FFB mode")
fmt.Println("Press Esc to exit")
trueFFBState := false
for {
c := int(C.getch())
switch c {
case 27: // esc
os.Exit(0)
case 99: // c
sdk.BroadcastMsg(irsdk.Msg{
Cmd: irsdk.BroadcastChatComand,
P1: irsdk.ChatCommandBeginChat,
})
fmt.Println("* Send request to start a chat")
case 112: // p
sdk.BroadcastMsg(irsdk.Msg{
Cmd: irsdk.BroadcastPitCommand,
P1: irsdk.PitCommandClearTires,
})
fmt.Println("* Send request to clear tire checkboxes")
case 102: // f
var force float64
if trueFFBState {
force = -1.0
} else {
force = 20.9998
}
trueFFBState = !trueFFBState
sdk.BroadcastMsg(irsdk.Msg{
Cmd: irsdk.BroadcastFFBCommand,
P1: irsdk.FFBCommandMaxForce,
P2: force,
})
if force < 0 {
fmt.Println("* Set wheel to user controlled FFB")
} else {
fmt.Printf("* Set wheel to %f Nm\n", force)
}
default:
fmt.Println("Unknown command")
}
}
}