Gamepad LastButton returns values when axes are moved

0 favourites
  • 5 posts
From the Asset Store
Total customisation of the input! You can combine inputs from all peripherals. Make your game accessible for everyone!
  • Problem Description

    The "LastButton" on a gamepad returns a button press after an axis has been moved in the positive direction, when using both "Every Tick" and "On Any Button Pressed" or when using only "On Any Button Pressed", but not when using "Every Tick" only.

    Attach a Capx

    Description of Capx

    It prints out the method(s) it is using to detect button presses, the last button pressed, its value and its raw value.

    Steps to Reproduce Bug

    • Add Gamepad object
    • Add Text object
    • Add "On gamepad any button pressed" event
    • Set text object's text "Gamepad.LastButton"
    • Run the project
    • Test with a few buttons
    • Push any analogue stick right or down
    • Test with a few buttons again

    Observed Result

    When moving an analogue stick down or right (along an axis in the positive direction), it returns a value from 16 (when moving along axis 0) to 19 (when moving along axis 3) iff using "On any button pressed". The button's value is always 0.

    Expected Result

    Not changing the returned value, as it is supposed to report only button presses, not axis movements.

    Suspected cause

    Construct 2's use of a gamepad API, or a bug in the API itself.

    Affected Browsers

    • Chrome: YES
    • FireFox: YES
    • Internet Explorer: NOT SUPPORTED

    Operating System and Service Pack

    Windows 7 Home Premium SP1

    Used hardware

    Xbox 360 Controller (XInput STANDARD INPUT)

    (literal ID)

    Construct 2 Version ID

    r178 64-bit free edition

    (first noticed in r173, I did not own a gamepad before that)

  • Closing as won't fix. What's the point of using 'LastButton' outside of a trigger? What are you hoping it will do? Why should it do anything in particular? It's useless outside of a trigger, because if you are holding two buttons, it cannot report both of them - it's only intended to be used in the triggers.

  • I think you understood the exact opposite. It works outside the trigger, but not inside.

    EDIT: Just to clarify, it works in both cases, but outputs values when it shouldn't if inside the trigger.

  • Oh, so the problem is not actually to do with LastButton at all. It's firing 'On any button pressed' when moving the analog sticks. That is the real difference here, right? Since that's the only reason it's retrieving LastButton at all.

    It's still difficult to fix, because not all gamepads have a clear distinction between an axis and a button. For example the Xbox 360 controller has triggers at the back which are buttons, but return a continuous value from 0-100, like an axis. To support 'On trigger pressed' Construct 2 treats axes as buttons which are pressed by moving the axis past 50. Some browsers/platforms report them as buttons, and others as axes, so it's hard to tell exactly what physical control is being used. The analogs get the same treatment since it's hard to distinguish them from triggers in the code, so moving them down or right past 50 will fire 'On any button pressed' with the LastButton set to the index of the analog stick. I'm not sure we can fix this without breaking the triggers or other gamepad models, so I think this will be left as is.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thank you for clearing that up for me and anyone who will be visiting this thread! I know that native Windows applications treat the triggers as an axis, left being the negative part, right being the positive. Only axes can be analogue there, and buttons can be only digital. I think that would be counter-intuitive for most users. In my opinion, Construct 2 is not such an advanced tool to support that kind of stuff. It is more of a tool for those who want to begin game development, or is a prototyping tool. Still, you can do a lot of amazing things, but it has its limitations. I love it because it is so easy to use.

    PS: The axes being buttons could have a use if the button would return anything except 0. But after all, a missing feature is better than 5 broken ones. I've already found a way to avoid the problem.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)