50 lines
No EOL
1.3 KiB
Python
50 lines
No EOL
1.3 KiB
Python
import time
|
|
import traceback
|
|
import sys
|
|
|
|
print("Starting game control test...")
|
|
|
|
try:
|
|
from src.game.input.gamepad import VirtualController
|
|
print("Controller support module imported successfully")
|
|
|
|
controller = VirtualController()
|
|
print(f"Controller available: {controller.is_available()}")
|
|
|
|
if controller.is_available():
|
|
print("Testing basic controller actions...")
|
|
|
|
# Test some basic controller actions
|
|
print("Pressing A button")
|
|
controller.press_a()
|
|
time.sleep(0.5)
|
|
|
|
print("Pressing B button")
|
|
controller.press_b()
|
|
time.sleep(0.5)
|
|
|
|
print("Moving left stick up")
|
|
controller.move_left_stick_up()
|
|
time.sleep(0.5)
|
|
|
|
print("Moving right stick right")
|
|
controller.move_right_stick_right()
|
|
time.sleep(0.5)
|
|
|
|
print("Pressing left trigger")
|
|
controller.press_left_trigger()
|
|
time.sleep(0.5)
|
|
|
|
print("Pressing D-pad up")
|
|
controller.press_dpad_up()
|
|
time.sleep(0.5)
|
|
|
|
# Reset controller at the end
|
|
controller.reset()
|
|
print("Controller reset")
|
|
|
|
print("Test completed successfully!")
|
|
except Exception as e:
|
|
print(f"Error during testing: {e}")
|
|
traceback.print_exc()
|
|
sys.exit(1) |