npm.io
2.0.0 • Published yesterday

shower-gamepad

Licence
MIT
Version
2.0.0
Deps
0
Size
20 kB
Vulns
0
Weekly
0

shower-gamepad

node version npm version downloads count size license

Support Gamepad API in shower.js (presentation architecture).

Setup

Installation:

npm install shower-gamepad gamepad-api @shower/core

gamepad-api (2.x) and @shower/core (3.x) are peer dependencies, so install them next to the plugin.

With <script> tags

Load the scripts in this order, all with defer (Shower 3 loads its core with defer too). The plugin connects window.shower with window.GamepadAPI by itself:

<script src="node_modules/@shower/core/dist/index.js" defer></script>
<script src="node_modules/gamepad-api/dist/gamepad-api.js" defer></script>
<script src="node_modules/shower-gamepad/dist/shower.gamepad.js" defer></script>

The paths are relative to your presentation's index.html. A missing library ends with a readable error in the console.

With a bundler
import GamepadAPI from 'gamepad-api';
import { attachGamepad } from 'shower-gamepad'; // or: require('shower-gamepad')

const plugin = attachGamepad(window.shower, GamepadAPI);

// later, to stop listening to the pad:
plugin.detach();

The optional third argument changes the buttons, e.g. attachGamepad(window.shower, GamepadAPI, { bindings: { next: ['shape:cross'] } }). Actions: next, prev, toggleFullMode; event names come from gamepad-api.

Controls

Buttons follow the W3C standard mapping (Xbox, PlayStation and most other pads).

Action Buttons
Next slide D-pad right or down, circle (B), R1, stick to the right
Previous slide D-pad left or up, square (X), L1, stick to the left
Toggle the full mode Start

One press moves one slide, a held button does not repeat.

The legacy shower-core 2.x still works (window.shower from shower-core/shower.min.js), there Start toggles the slide mode.

Demo

demo/index.html uses the packages from node_modules: run npm install, npm run build and open the file in a browser with a pad connected.

License

The MIT License @ 2026

Keywords