updated PlayStation spinner code for QT Py
This commit is contained in:
parent
9caf603693
commit
24a78d63e8
1 changed files with 15 additions and 15 deletions
|
|
@ -1,40 +1,38 @@
|
|||
# SPDX-FileCopyrightText: 2023 John Park w/ Tod Kurt ps2controller library
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
# The Takara Game of Life PlayStation roulette wheel controller spinner
|
||||
# The Takara Game of Life PlayStation roulette wheel controller spinner (TAKC-00001)
|
||||
# sends two sets of held CIRCLE buttons with randomized hold time periods
|
||||
# this code turns that into mouse click spamming (the CIRCLE button also spams)
|
||||
# Tested on QT Py RP2040
|
||||
|
||||
import time
|
||||
import board
|
||||
import usb_hid
|
||||
import digitalio
|
||||
import neopixel
|
||||
from adafruit_hid.keycode import Keycode
|
||||
from adafruit_hid.keyboard import Keyboard
|
||||
from adafruit_hid.keyboard_layout_us import KeyboardLayoutUS
|
||||
from adafruit_hid.mouse import Mouse
|
||||
from ps2controller import PS2Controller
|
||||
|
||||
# turn on Pico LED
|
||||
led = digitalio.DigitalInOut(board.GP25)
|
||||
led.direction = digitalio.Direction.OUTPUT
|
||||
led.value = True
|
||||
# turn on neopixel
|
||||
led = neopixel.NeoPixel(board.NEOPIXEL, 1, brightness=0.1)
|
||||
led.fill(0x331000) # amber while we wait for controller to connect
|
||||
|
||||
mouse = Mouse(usb_hid.devices)
|
||||
|
||||
keyboard = Keyboard(usb_hid.devices)
|
||||
layout = KeyboardLayoutUS(keyboard)
|
||||
|
||||
# create controller object with Pico wiring, disable unused PS2 features
|
||||
# create controller object with QT Py wiring
|
||||
psx = PS2Controller(
|
||||
dat=board.GP2,
|
||||
cmd=board.GP3,
|
||||
att=board.GP4,
|
||||
clk=board.GP5,
|
||||
enable_sticks=False,
|
||||
enable_rumble=False,
|
||||
enable_pressure=False,
|
||||
dat=board.A0,
|
||||
cmd=board.A1,
|
||||
att=board.A2,
|
||||
clk=board.A3
|
||||
)
|
||||
led.fill(0x0010ee) # a nice PlayStation blue
|
||||
|
||||
circle_held = False
|
||||
spam_speed = 0.001
|
||||
|
|
@ -46,6 +44,8 @@ buttonmap = {
|
|||
("DOWN"): (0, Keycode.S),
|
||||
("RIGHT"): (0, Keycode.D),
|
||||
("LEFT"): (0, Keycode.A),
|
||||
("L3"): (0, Keycode.V),
|
||||
("R3"): (0, Keycode.B),
|
||||
("L2"): (0, Keycode.R),
|
||||
("R2"): (0, Keycode.T),
|
||||
("L1"): (0, Keycode.F),
|
||||
|
|
@ -61,7 +61,7 @@ print("PlayStation Roulette Wheel controller")
|
|||
while True:
|
||||
events = psx.update()
|
||||
if events:
|
||||
print("events", events)
|
||||
print(events)
|
||||
for event in events:
|
||||
if buttonmap[event.name][0] == 0: # regular button
|
||||
if event.pressed:
|
||||
|
|
|
|||
Loading…
Reference in a new issue