-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_rt_trigger.py
More file actions
executable file
·149 lines (118 loc) · 4.51 KB
/
test_rt_trigger.py
File metadata and controls
executable file
·149 lines (118 loc) · 4.51 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#!/usr/bin/env python3
"""
Test RT (Right Trigger) for Turbo Speed
"""
import pygame
import sys
import time
def main():
print("🎮 Testing RT (Right Trigger) for Turbo Speed...")
# Initialize pygame
pygame.init()
pygame.joystick.init()
# Check for joysticks
joystick_count = pygame.joystick.get_count()
print(f"Found {joystick_count} joystick(s)")
if joystick_count == 0:
print("❌ No joysticks found!")
return
# Initialize the first joystick
joystick = pygame.joystick.Joystick(0)
joystick.init()
print(f"✅ Controller: {joystick.get_name()}")
print(f" Axes: {joystick.get_numaxes()}")
print(f" Buttons: {joystick.get_numbuttons()}")
print("\n🎮 RT Trigger Test - Hold RT to see turbo effect!")
print(" Press ESC or close window to exit")
print(" Watch the RT axis value and turbo multiplier")
# Create a window
screen = pygame.display.set_mode((600, 500))
pygame.display.set_caption("RT Trigger Turbo Test")
font = pygame.font.Font(None, 24)
clock = pygame.time.Clock()
# Settings
base_speed = 1200.0
boost_multiplier = 2.0
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
elif event.type == pygame.KEYDOWN:
if event.key == pygame.K_ESCAPE:
running = False
# Clear screen
screen.fill((0, 0, 0))
y = 20
line_height = 30
# Get RT trigger value
try:
rt_value = float(joystick.get_axis(5)) # RT axis
except:
rt_value = 0.0
# Calculate turbo effect
if rt_value > 0.1:
boost_factor = 1.0 + (rt_value * (boost_multiplier - 1.0))
current_speed = base_speed * boost_factor
turbo_active = True
else:
boost_factor = 1.0
current_speed = base_speed
turbo_active = False
# Display controller info
info_text = f"Controller: {joystick.get_name()}"
text = font.render(info_text, True, (255, 255, 255))
screen.blit(text, (10, y))
y += line_height
# Display RT trigger info
rt_text = f"RT Trigger Value: {rt_value:.3f}"
rt_color = (0, 255, 0) if rt_value > 0.1 else (128, 128, 128)
text = font.render(rt_text, True, rt_color)
screen.blit(text, (10, y))
y += line_height
# Display turbo status
turbo_text = f"Turbo Active: {'YES' if turbo_active else 'NO'}"
turbo_color = (255, 255, 0) if turbo_active else (128, 128, 128)
text = font.render(turbo_text, True, turbo_color)
screen.blit(text, (10, y))
y += line_height
# Display speed info
speed_text = f"Base Speed: {base_speed:.0f} px/sec"
text = font.render(speed_text, True, (200, 200, 200))
screen.blit(text, (10, y))
y += line_height
boost_text = f"Boost Factor: {boost_factor:.2f}x"
boost_color = (255, 100, 100) if turbo_active else (200, 200, 200)
text = font.render(boost_text, True, boost_color)
screen.blit(text, (10, y))
y += line_height
current_text = f"Current Speed: {current_speed:.0f} px/sec"
current_color = (255, 255, 0) if turbo_active else (200, 200, 200)
text = font.render(current_text, True, current_color)
screen.blit(text, (10, y))
y += line_height
# Visual indicator
y += 20
bar_width = 400
bar_height = 30
bar_x = 10
bar_y = y
# Background bar
pygame.draw.rect(screen, (50, 50, 50), (bar_x, bar_y, bar_width, bar_height))
# Turbo bar
if turbo_active:
turbo_width = int(bar_width * rt_value)
pygame.draw.rect(screen, (255, 100, 100), (bar_x, bar_y, turbo_width, bar_height))
# Border
pygame.draw.rect(screen, (200, 200, 200), (bar_x, bar_y, bar_width, bar_height), 2)
# Instructions
y += 60
inst_text = "Hold RT (Right Trigger) to activate turbo speed!"
text = font.render(inst_text, True, (255, 255, 255))
screen.blit(text, (10, y))
pygame.display.flip()
clock.tick(60)
pygame.quit()
print("✅ RT trigger test completed!")
if __name__ == "__main__":
main()