snex

Library for listening to input from SNEX gamepads.

Usage no npm install needed!

<script type="module">
  import snex from 'https://cdn.skypack.dev/snex';
</script>

README

SNEX

Library for using SNEX.io gamepads built on Peer.js.

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);
});