contro icon indicating copy to clipboard operation
contro copied to clipboard

doesn't work on mobile

Open bradwbradw opened this issue 5 years ago • 1 comments

my device: OnePlus 3 Android 8.0.0 Chrome browser

gamepad: XBox controller.

here's the code. It is alerting 'a' in desktop chrome but not on mobile. I verified my gamepad is connected using https://html5gamepad.com/

const { Mouse, Keyboard, Gamepad, or, and } = Contro;

const gamepad = new Gamepad();


const controls = {
    a: gamepad.button('a').trigger,
    b: gamepad.button('b').trigger,
    left: gamepad.button('left').trigger
}

function gameLoop() {
    // Query the controls and do something
    if (controls.a.query()) {
        console.log('a');
        alert('a')
    }
    if (controls.b.query()) {
        console.log('b');
    }
    if (controls.left.query()) {
        console.log('left')
        alert('left')
    }

    requestAnimationFrame(gameLoop)
}



requestAnimationFrame(gameLoop)

bradwbradw avatar Apr 16 '19 21:04 bradwbradw

My first guess is that your phone doesn't properly report the mapping of the gamepad which Contro currently requires to be 'standard'. You can check if this is the case by opening https://html5gamepad.com/ on your phone and looking at the mapping:

If I ever have the time to update this library I will loosen the requirements for gamepad connections and add support for other kinds of gamepads. Currently, however, I'm very busy working on a different project. I hope you understand that.

shroudedcode avatar Apr 21 '19 12:04 shroudedcode