Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including snex with all npm packages installed. Try it out:

var snex = require("snex")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

snex v0.5.0

Library for listening to input from SNEX gamepads.

SNEX Virtual Gamepad API SDK

Library for using SNEX.io virtual gamepads providing SVG surface interaction, peering, and message sending.

What is it?

SNEX provides on-screen virtual gamepads that can connect to any web application using WebRTC. Just create a session, share the session token, and start receiving signals right away.

Usage

Node environment

  1. Install
npm install snex
  1. Implement
const snex = require('snex');

snex.createSession()
.then(session => {

    session.on('connection', conn => {
        console.log('Player joined!');

        conn.on('data', data => {
            if (data.state && data.key === 'A') {
                console.log('User pressed "A"');
            }
        });
    });

    return session.createURL('nes');
})
.then(desc => {
    console.log('Go to url to play', desc.url);
});

Browser

  1. Add the following snippet to your site.
<script src="https://cdn.snex.io/snex.latest.min.js"></script>
  1. Implement.
window.snex.createSession()
.then(session => {

    session.on('connection', conn => {
        console.log('Player joined!');

        conn.on('data', data => {
            if (data.state && data.key === 'A') {
                console.log('Player pressed "A"');
            }
        });
    });

    return session.createURL('nes');
})
.then(desc => {
    console.log('Go to url to play', desc.url);
});

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free