SNEX Virtual Gamepad 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
- Install
npm install snex
- 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
- Add the following snippet to your site.
<script src="https://snex-cdn.pomle.com/snex.latest.min.js"></script>
- 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);
});