Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gamepad (SinglePad) button handling broken in 2.4.1, possible solution #1939

Closed
zatch opened this issue Jul 26, 2015 · 2 comments
Closed

Gamepad (SinglePad) button handling broken in 2.4.1, possible solution #1939

zatch opened this issue Jul 26, 2015 · 2 comments

Comments

@zatch
Copy link

zatch commented Jul 26, 2015

Hi there,

I'm running into an issue with gamepad buttons in Phaser 2.4.1 in both Firefox and Chrome (Windows 8.1 x64).

The error reported is:
Uncaught TypeError: Cannot read property 'altKey' of null

The error occurs in Phaser.DeviceButton.start. This seems to be because Phaser.SinglePad.processButtonDown passes null as the first argument of the start function, like so:

    this._buttons[buttonCode].start(null, value);

This same issue is repeated in Phaser.SinglePad.processButtonUp:

    this._buttons[buttonCode].stop(null, value);

This is my very first day working with Phaser, so I'm quite bashful to assume I know what I'm talking about, but I may be able to offer a resolution. I got my gamepad to work through a bit of guesswork; I simply passed the button reference in as the first argument of each of these function calls, and it seems to work. It looks a bit like this in my code now:

    processButtonDown: function (buttonCode, value) {

        ...

        if (this._buttons[buttonCode])
        {
            this._buttons[buttonCode].start(this._buttons[buttonCode], value);
        }

    },

    ...

    processButtonUp: function (buttonCode, value) {

        ...

        if (this._buttons[buttonCode])
        {
            this._buttons[buttonCode].stop(this._buttons[buttonCode], value);
        }

    },

So far, so good, but I'm not very familiar with the codebase yet. Regardless, I hope this helps! I'll be sure to follow up if I run into any issues with my solution.

-zatch

photonstorm added a commit that referenced this issue Jul 26, 2015
@photonstorm
Copy link
Collaborator

Thanks for the error report. This is now fixed in the dev branch :)

@zatch
Copy link
Author

zatch commented Jul 30, 2015

Works like a charm in the 2.4.2 build -- thanks!

On Sun, Jul 26, 2015 at 8:02 AM, Richard Davey notifications@github.com
wrote:

Thanks for the error report. This is now fixed in the dev branch :)


Reply to this email directly or view it on GitHub
#1939 (comment)
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants