Log In  
Follow
VyrCossont
Pinput: Extended gamepad support for PICO-8
by
[ :: Read More :: ]

Cart #geometry_wars-1 | 2022-11-04 | Code ▽ | Embed ▽ | No License
5

Demake in progress of Geometry Wars: Retro Evolved, one of my favorite games of all time.

This uses twin-stick shooter input conventions, and I strongly recommend playing it with a dual-analog gamepad using Pinput, either with the native desktop PICO-8 player and a native Pinput build, or using the Firefox or Chrome extensions for Pinput to play it here on the BBS website.

However, you can now also play with two alternate schemes other than Pinput's analog gamepad support. The game will ask you at startup and save your input preferences, but you can always change it from the pause menu.

  • Pinput: same as the original Geometry Wars. Left stick moves, right stick aims, either trigger bombs.
  • Devkit: uses mouse and full keyboard. WASD or arrow keys move, mouse aims, spacebar bombs.
  • P1+P2: uses inputs from both player 1 and player 2. Player 2's D-pad moves (yes, 2), player 1's D-pad aims, press either player's O or X buttons to bomb. This is intended for keyboards.

This demake isn't suitable for mobile devices without gamepads, because the PICO-8 BBS mobile player only provides virtual gamepad overlays for one player.

P#103050 2021-12-18 08:46 ( Edited 2022-11-04 18:18)

[ :: Read More :: ]

Cart #pinput_gamepad_tester-0 | 2021-12-08 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
4

Pinput gamepad tester cartridge. This won't do anything useful without Pinput, either if you download and run it locally, or if you install the Firefox or Chrome extensions for Pinput to play it here on the BBS website.

P#102019 2021-12-08 03:39 ( Edited 2021-12-18 08:28)

[ :: Read More :: ]

Ever wish PICO-8 had dual analog stick support? Me too, so I wrote Pinput. Pinput is a Lua library and suite of external helper apps to provide XInput-like gamepad support to PICO-8, without requiring binary patching. The library and helpers use the GPIO area of cartridge RAM to communicate, making Pinput a sort of virtual peripheral plugged into an imaginary expansion port. (The P8T Twitter client uses GPIO the same way.)

You can try it now if you have a gamepad that works with your browser. (You may want to test it first with this gamepad test page.)

Demo video:

Pinput working in web browser with Logitech F310 gamepad

What do you get?

  • Up to 8 players
  • Per player:
  • 2 analog thumbsticks
  • 2 analog triggers
  • 4-way digital D-pad
  • 4 digital action buttons (ABXY)
  • 2 digital bumper/shoulder buttons
  • 2 digital thumbstick buttons
  • 2 or 3 digital menu buttons (Start and Back, plus Guide/Xbox/PS button on macOS and web)

Pinput currently works on:

  • macOS: with up to 8 gamepads supported by Apple's Game Controller API (newer Xbox One, DualShock 4, DualSense, MFi)
  • Windows: with up to 4 gamepads supported by XInput (360, Xbox One)
  • Web: depends on your OS and browser's support for the web gamepad API, but expect USB/BT HID gamepads to work, and on Windows, probably XInput too

Coming soon:

  • rumble/vibration support
  • battery level/charging status for wireless controllers (macOS and Windows only)
  • Linux

How does it work?

When you initialize the Pinput library in a cartridge, it writes a magic UUID to the first 16 bytes of the GPIO area. The external helpers look for this magic UUID in PICO-8's memory to identify the GPIO area. On macOS, the helper uses Mach virtual memory APIs to map GPIO into the helper's address space. On Windows, the helper uses ReadProcessMemory/WriteProcessMemory from the Windows memory API. Cartridges exported in web format expose GPIO as an array of integers in JavaScript, so the web version just needs a little extra JavaScript. Once the helper knows where GPIO is, it can read and write gamepad data there for the cartridge to use.

All platforms have the same interface between a cartridge and the helper, so you can run the same Pinput-enabled cartridge on macOS, Windows, or your browser.

Why?

I wanted to do a Geometry Wars demake but still have twinstick support. 😁

Claw ship firing shots at all angles

P#98548 2021-10-12 18:25 ( Edited 2021-10-12 19:09)