npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

psg1-sim

v0.1.0

Published

Development simulator for the PlaySolana PSG1 handheld console

Readme

psg1-sim

PSG1 Simulator

Web-first PSG1 simulator library for React and React Native Web.

It provides one unified gamepad API for:

  • real controllers via browser navigator.getGamepads()
  • native Android gamepad key events
  • simulated on-screen PSG1 controls
  • keyboard fallback controls

Install

npm install psg1-sim

Peer dependencies: react >= 18, react-dom >= 18

PSG1 Button Model

PSG1 controls are exposed with PSG1 labels:

  • A, B, X, Y
  • DPadUp, DPadDown, DPadLeft, DPadRight
  • L1, R1, Start, Select, L3, R3

Internally these map to PS-style naming for compatibility:

  • A -> Cross, B -> Circle, X -> Square, Y -> Triangle
  • Start -> Options, Select -> Share

Wrap Your App

import { Psg1Simulator } from 'psg1-sim';

export function App() {
  return (
    <Psg1Simulator enabledRealGamepad showDebugHud={false}>
      <MyGame />
    </Psg1Simulator>
  );
}

Read Input in Game Code

import { Psg1Button, usePsg1Gamepad } from 'psg1-sim';

function MyGame() {
  const { pressed, lastEvent, isDown } = usePsg1Gamepad();

  return (
    <div>
      {isDown(Psg1Button.A) && <p>Jump</p>}
      {pressed.has(Psg1Button.DPadLeft) && <p>Move Left</p>}
      {lastEvent && <p>Last: {lastEvent.type} {lastEvent.button} ({lastEvent.source})</p>}
    </div>
  );
}

Real Controller Testing (Web)

Psg1Simulator can auto-enable the web backend with enabledRealGamepad.

You can also manage it manually:

import { enableWebGamepadBackend, disableWebGamepadBackend } from 'psg1-sim';

const stop = enableWebGamepadBackend();
// ...later
stop();
// or disableWebGamepadBackend();

Custom gamepad index mapping:

enableWebGamepadBackend({
  buttonMap: {
    [Psg1Button.A]: 1,
    [Psg1Button.B]: 2,
  },
});

Default mapping used by the backend:

  • 0 -> A, 1 -> B, 2 -> X, 3 -> Y
  • 4 -> L1, 5 -> R1
  • 8 -> Select, 9 -> Start
  • 10 -> L3, 11 -> R3
  • 12 -> DPadUp, 13 -> DPadDown, 14 -> DPadLeft, 15 -> DPadRight

Android APK Controller Support

Android controller input is supported through a native backend that maps Android KeyEvent codes into PSG1 buttons.

  • Psg1InputProvider / Psg1Simulator auto-enables the Android backend.
  • Default keycode mapping:
    • 96 -> A, 97 -> B, 99 -> X, 100 -> Y
    • 102 -> L1, 103 -> R1
    • 108 -> Start, 109 -> Select
    • 106 -> L3, 107 -> R3
    • 19/20/21/22 -> DPadUp/Down/Left/Right

If your runtime emits custom native events, bridge them with:

import { emitAndroidGamepadEvent } from 'psg1-sim';

emitAndroidGamepadEvent({
  action: 'down',
  keyCode: 96, // A
});

Keyboard Fallback Defaults

  • Arrow keys -> D-pad
  • J -> A
  • K -> B
  • U -> X
  • I -> Y
  • Q -> L1
  • E -> R1
  • Enter -> Start
  • Shift -> Select
  • Z -> L3
  • C -> R3

API

usePsg1Gamepad()

Returns:

{
  pressed: ReadonlySet<Psg1Button>;
  lastEvent?: GamepadEvent;
  isDown(btn: Psg1Button): boolean;
}

<Psg1Simulator />

Props:

  • enabledRealGamepad?: boolean (default true)
  • showDebugHud?: boolean (default false)
  • realGamepadOptions?: WebGamepadBackendOptions
  • keyMap?: Record<string, Psg1Button>
  • store?: InputStore

Compatibility

usePsg1Input() is still exported as a deprecated compatibility hook. Deprecated enum aliases are kept for migration:

  • A -> Cross, B -> Circle, X -> Square, Y -> Triangle
  • Start -> Options, Select -> Share

License

MIT