deluxx-fluxx-controls
v1.0.20
Published
standarize controls across games and set up a control bridge between the app and the games.
Downloads
8
Readme
controls.player1.onJoystick(function (axes) { console.log('I heard a joystick event', axes); }); controls.player1.onUp(function (pressed) { console.log('I heard a p1 UP event', pressed); }); controls.player1.onDown(function (pressed) { console.log('I heard a p1 DOWN event', pressed); }); controls.player1.onLeft(function (pressed) { console.log('I heard a p1 LEFT event', pressed); }); controls.player1.onRight(function (pressed) { console.log('I heard a p1 RIGHT event', pressed); }); controls.player1.onB1(function (pressed, heldDuration) { console.log('I heard a p1 BUTTON 1 event', pressed, heldDuration); }); controls.player1.onB2(function (pressed, heldDuration) { console.log('I heard a p1 BUTTON 2 event', pressed, heldDuration); });
controls.player2.onJoystick(function (axes) { console.log('I heard a p2 joystick event', axes); }); controls.player2.onUp(function (pressed) { console.log('I heard a p2 UP event', pressed); }); controls.player2.onDown(function (pressed) { console.log('I heard a p2 DOWN event', pressed); }); controls.player2.onLeft(function (pressed) { console.log('I heard a p2 LEFT event', pressed); }); controls.player2.onRight(function (pressed) { console.log('I heard a p2 RIGHT event', pressed); }); controls.player2.onB1(function (pressed, heldDuration) { console.log('I heard a p2 BUTTON 1 event', pressed, heldDuration); }); controls.player2.onB2(function (pressed, heldDuration) { console.log('I heard a p2 BUTTON 2 event', pressed, heldDuration); });
setInterval(function () { if (controls.player1.b1Pressed) console.log(controls.player1.joystickAxes); }, 1000 / 30);
// CONTROLS AND FRAMEWORK CODE START --->
function getQueryString(field) {
const reg = new RegExp([?&]${field}=([^&#]*)
, 'i');
const string = reg.exec(window.location.href);
return string ? string[1] : null;
}
const { controlsBridge, controlsHook } = deluxxFluxxControls;
if (!getQueryString('framework')) { } controlsBridge.bind(controlsHook);
window.DFFrameWorkAPI = { ping() { return true; }, getControlsHook() { return controlsHook; }, }; // <---- CONTROLS AND FRAMEWORK CODE END