|
1 | 1 | # SPDX-FileCopyrightText: 2023 John Park w/ Tod Kurt ps2controller library
|
2 | 2 | #
|
3 | 3 | # SPDX-License-Identifier: MIT
|
4 |
| -# The Takara Game of Life PlayStation roulette wheel controller spinner |
| 4 | +# The Takara Game of Life PlayStation roulette wheel controller spinner (TAKC-00001) |
5 | 5 | # sends two sets of held CIRCLE buttons with randomized hold time periods
|
6 | 6 | # this code turns that into mouse click spamming (the CIRCLE button also spams)
|
| 7 | +# Tested on QT Py RP2040 |
7 | 8 |
|
8 | 9 | import time
|
9 | 10 | import board
|
10 | 11 | import usb_hid
|
11 |
| -import digitalio |
| 12 | +import neopixel |
12 | 13 | from adafruit_hid.keycode import Keycode
|
13 | 14 | from adafruit_hid.keyboard import Keyboard
|
14 | 15 | from adafruit_hid.keyboard_layout_us import KeyboardLayoutUS
|
15 | 16 | from adafruit_hid.mouse import Mouse
|
16 | 17 | from ps2controller import PS2Controller
|
17 | 18 |
|
18 |
| -# turn on Pico LED |
19 |
| -led = digitalio.DigitalInOut(board.GP25) |
20 |
| -led.direction = digitalio.Direction.OUTPUT |
21 |
| -led.value = True |
| 19 | +# turn on neopixel |
| 20 | +led = neopixel.NeoPixel(board.NEOPIXEL, 1, brightness=0.1) |
| 21 | +led.fill(0x331000) # amber while we wait for controller to connect |
22 | 22 |
|
23 | 23 | mouse = Mouse(usb_hid.devices)
|
24 | 24 |
|
25 | 25 | keyboard = Keyboard(usb_hid.devices)
|
26 | 26 | layout = KeyboardLayoutUS(keyboard)
|
27 | 27 |
|
28 |
| -# create controller object with Pico wiring, disable unused PS2 features |
| 28 | +# create controller object with QT Py wiring |
29 | 29 | psx = PS2Controller(
|
30 |
| - dat=board.GP2, |
31 |
| - cmd=board.GP3, |
32 |
| - att=board.GP4, |
33 |
| - clk=board.GP5, |
34 |
| - enable_sticks=False, |
35 |
| - enable_rumble=False, |
36 |
| - enable_pressure=False, |
| 30 | + dat=board.A0, |
| 31 | + cmd=board.A1, |
| 32 | + att=board.A2, |
| 33 | + clk=board.A3 |
37 | 34 | )
|
| 35 | +led.fill(0x0010ee) # a nice PlayStation blue |
38 | 36 |
|
39 | 37 | circle_held = False
|
40 | 38 | spam_speed = 0.001
|
|
46 | 44 | ("DOWN"): (0, Keycode.S),
|
47 | 45 | ("RIGHT"): (0, Keycode.D),
|
48 | 46 | ("LEFT"): (0, Keycode.A),
|
| 47 | + ("L3"): (0, Keycode.V), |
| 48 | + ("R3"): (0, Keycode.B), |
49 | 49 | ("L2"): (0, Keycode.R),
|
50 | 50 | ("R2"): (0, Keycode.T),
|
51 | 51 | ("L1"): (0, Keycode.F),
|
|
61 | 61 | while True:
|
62 | 62 | events = psx.update()
|
63 | 63 | if events:
|
64 |
| - print("events", events) |
| 64 | + print(events) |
65 | 65 | for event in events:
|
66 | 66 | if buttonmap[event.name][0] == 0: # regular button
|
67 | 67 | if event.pressed:
|
|
0 commit comments