-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpreventDoubleStrum.py
58 lines (49 loc) · 1.59 KB
/
preventDoubleStrum.py
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
import time
if starting:
strumHoldPeriod = 1/30.0 #seconds (default: 1/30th of a second)
vJoyId = 0
vJoy_joyId = "vJoy Device"
joyId = -1
isDetecting = True
info = "Please strum on the guitar controller you would like to use."
diagnostics.watch(info)
if vJoy[vJoyId].axisMax != -1:
vjAxisMax = vJoy[vJoyId].axisMax
vjAxisMin = -vJoy[vJoyId].axisMax
else:
vjAxisMax = 0x8000
vjAxisMin = 0
if isDetecting:
for x in range(5):
try:
if(joystick[x].pov[0] != -1):
joyId = x
except:
pass
if joyId != -1:
isDetecting = False
system.setThreadTiming(TimingTypes.HighresSystemTimer)
system.threadExecutionInterval = 1000 / 120
timepress = 0
info = "Using guitar controller of ID "+str(joyId)+". Have fun!"
diagnostics.watch(info)
else:
clock = time.clock()
if keyboard.getPressed(Key.Space) is True:
vJoy[vJoyId].setPressed(0)
for i in range(13):
if joystick[joyId].getDown(i) is True:
if not joystick[vJoy_joyId].getDown(i): vJoy[vJoyId].setButton(i, True)
else:
if joystick[vJoy_joyId].getDown(i): vJoy[vJoyId].setButton(i, False)
if joystick[joyId].pov[0] != -1:
timepress = clock
if joystick[vJoy_joyId].pov != joystick[joyId].pov:
vJoy[vJoyId].setAnalogPov(0, joystick[joyId].pov[0])
if (timepress > 0 and clock > timepress + strumHoldPeriod):
vJoy[vJoyId].setAnalogPov(0, -1)
timepress = 0
if joystick[joyId].z > 0:
vJoy[vJoyId].z = filters.mapRange(joystick[joyId].z, -1000, 1000, vjAxisMin, vjAxisMax)
elif joystick[vJoy_joyId].z != joystick[joyId].z:
vJoy[vJoyId].z = filters.mapRange(joystick[joyId].z, -1000, 1000, vjAxisMin, vjAxisMax)