项目作者: touchgadget

项目描述 :
Touchscreen arcade controller for Nintendo Switch
高级语言: Python
项目地址: git://github.com/touchgadget/toucharcade.git
创建时间: 2020-09-13T22:54:51Z
项目社区:https://github.com/touchgadget/toucharcade

开源协议:MIT License

下载


Touchscreen Monitor Arcade Controller

Use a touchscreen monitor as an arcade controller for a Nintendo Switch or
PlayStation 4.

System Block Diagram

The following shows the touch areas on the monitor. The top half has the
32 region touch slider. The bottom half has four large buttons.

The latest version for the PlayStation 4 and Nintendo Switch includes gamepad
buttons such as direcitonal pad L1, R1, L2, R2, etc. on the top row.

Touch regions on monitor for PlayStation 4

Touch regions on monitor for Nintendo Switch

One option is to plug the Switch HDMI out into the touchscreen monitor.
This creates a Switch MegaMix Tap Play mode but on an external monitor.
The system block diagram shows this option.

The other option is to plug the Switch HDMI out into a different monitor (no
touchscreen needed). Plug the touchscreen monitor into the Raspberry Pi HDMI
out so the touch areas are displayed. This is closer to the arcade experience.

In both cases, the touch USB out from the monitor goes to the Pi.

Hardware

  • Nintendo Switch in dock. Or PlayStation 4. No hacks or mods.
  • Virzen Portable Monitor with 10-point touchscreen 13.3 inch.
  • Raspberry Pi 4. Older Pi’s including the Pi Zero may also work but have not
    been tested.
  • Trinket M0 running NSGadget (Switch compatible gamepad software) or
    Trinket M0 running DS4Gadget (PS4 Dual Shock 4 compatible gamepad software)
  • Optional breadboard, 2x20 breakout adapter, etc.
  • Various HDMI and USB cables.
  • MayFlash Magic-S Pro Controller Adapter (only for PS4)

USB NSGadget

[This section is adapted from the NSGadget_Pi README.md]

NSGadget is an Adafruit Trinket M0 emulating an NS compatible gamepad. The UART
connection between the Pi and NSGadget runs at 2 Mbits/sec. The UART device
name is /dev/ttyAMA0.

Trinket M0 Raspberry Pi
BAT 5V0
Gnd Gnd
RX(3) D15(TXD)

The firmware/ directory has the NSGadget firmware.

Compiled programs can be burned into the Trinket M0 just by dragging and
dropping a UF2 file on to the Trinket M0 USB drive. There is no need to install
the Arduino IDE, source code, or USB serial device driver.

  • Download the UF2 file of your choice.
  • Plug in the Trinket M0 to the computer.
  • Double tap the Trinket M0 reset button.
  • When the TRINKETBOOT USB drive appears, drop the UF2 file on to the drive.
  • Wait a few seconds until the Trinket M0 reboots.

USB DS4Gadget

The hook up is the same as for the NSGadget but the firmware file name is
firmware/DS4Gadget.ino.bin.uf2.

WARNING: DS4Gadget does not support controller authentication so it
will stop working after about 8 minutes. The MayFlash Magic-S Pro controller
adapter solves this problem. I do not plan to add controller authentication.

  1. PS4 -- MayFlash adapter -- Trinket M0/DS4Gadget -- Raspberry Pi

Prepare the Pi

[This section and its two subsections are adapted from the NSGadget_Pi README.md]

Install Raspberry Pi OS (formerly known as Raspbian) Buster Desktop. Update to
the latest version.

  1. sudo apt update
  2. sudo apt full-upgrade
  3. sudo reboot

Prepare /dev/ttyAMA0

If the Pi has built-in Bluetooth (Pi 3, Pi 3+, Pi 4, Pi zero W) disable
Bluetooth to free up the PL011 UART.

The following is from /boot/overlays/README.

  1. Name: disable-bt
  2. Info: Disable onboard Bluetooth on Pi 3B, 3B+, 3A+, 4B and Zero W, restoring
  3. UART0/ttyAMA0 over GPIOs 14 & 15.
  4. N.B. To disable the systemd service that initialises the modem so it
  5. doesn't use the UART, use 'sudo systemctl disable hciuart'.
  6. Load: dtoverlay=disable-bt
  1. sudo systemctl disable hciuart
  2. sudo nano /boot/config.txt

Add dtoverlay=disable-bt as the last line of config.txt. Save and exit.

Turn off the login shell on /dev/ttyAMA0. This is necessary even if the Pi does
not have Bluetooth.

  1. sudo raspi-config
  • Select Interfacing Options.
  • Select P6 Serial.
  • Disable the login shell.
  • Enable the serial interface.
  • Exit raspi-config
  1. sudo reboot

Installing pygame 2.0.0-dev6

pygame 1.9 does not support the FINGERUP, FINGERDOWN, and FINGERMOTION events
so this is required.

  1. sudo apt install python3 python3-pip python3-serial libsdl2-ttf-2.0-0
  2. python3 -m pip install -U pygame==2.0.0.dev6 --user
  3. git clone https://github.com/touchgadget/toucharcade
  4. cd toucharcade
  5. python3 pdtouch.py

Project Diva Touchscreen

pdtouch.py displays a Project Diva controller, reads touches, and writes
gamepad button presses to the game console. It currently supports
PlayStation 4 and Nintendo Switch.

The --slider==normal option sends joystick movements for slides. Use
“—slider=dedicated” when using a dedicated arcade controller. Note the English
version of PS4 Future Tone does not support dedicated mode. The Japanese
version supports dedicated mode. The Nintendo Switch supports both modes but
the dedicated controller mode defaults off.

Nintendo Switch

  1. python3 pdtouch.py --console=switch --slider=normal
  2. python3 pdtouch.py --console=switch --slider=dedicated

PlayStation 4

  1. python3 pdtouch.py --console=ps4 --slider=normal
  2. python3 pdtouch.py --console=ps4 --slider=dedicated

See https://github.com/gdsports/NSGadget_Pi for other ways to use a Pi with a
Switch.

To emulate Switch controllers over Bluetooth, see https://github.com/mart1nro/joycontrol.
It would be nice to use this to eliminate the Trinket M0 and all soldering.

For another Python project that emulates a wireless Nintendo Pro Controller,
see https://github.com/Brikwerk/nxbt.

Helpful Resources