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

Direct Input Gamepad Constant Input / Reading Axis Inputs as Buttons #8563

Closed
gm-bug-reporter bot opened this issue Nov 29, 2024 · 5 comments
Closed
Assignees
Labels
ide-bug Bugs with the GameMaker IDE project This issue has a sample project attached

Comments

@gm-bug-reporter
Copy link

Description

DirectInput gamepad is constantly returning true on two inputs on 5 different Direct Input gamepads. While testing, I've found that these inputs are mapped to the Dpad returning as button inputs when they should be axis inputs. On windows, joy.cpl shows these gamepads as functioning correctly, and other programs I use them in have no issue reading them correctly with no input issues.

The code being used to listen to inputs has functioned properly in GMS 1 with these same controllers, reading the correct data. Even without this code, just checking for the input returns true.

Steps To Reproduce

plug in Direct Input Controller
run code in the draw event of an object:

draw_self();
draw_set_color(c_white);
for(var _gamepad_count = gamepad_button_count(4); _gamepad_count > -1; _gamepad_count --)
{
if gamepad_button_check(4,_gamepad_count) draw_set_color(c_lime);
else draw_set_color(c_red);
if _gamepad_count < 16 draw_text(0, 0 + (9 * _gamepad_count), string(_gamepad_count));
if _gamepad_count > 15 draw_text(32, 0 + (9 * _gamepad_count - 144), string(_gamepad_count));
}
for(var _gamepad_count = gamepad_axis_count(4); _gamepad_count > -1; _gamepad_count --)
{
if gamepad_axis_value(4,_gamepad_count) > 0.5 or gamepad_axis_value(4,_gamepad_count) < -0.5 draw_set_color(c_lime);
else draw_set_color(c_red);
if _gamepad_count < 16 draw_text(64, 0 + (9 * _gamepad_count), string(_gamepad_count) + " - " + string(gamepad_axis_value(4,_gamepad_count)));
if _gamepad_count > 15 draw_text(98, 0 + (9 * _gamepad_count - 144), string(_gamepad_count));
}

Which version of GameMaker are you reporting this issue for?

IDE v2024.8.1.171 Runtime v2024.8.1.218

Which operating system(s) are you seeing the problem on?

Windows 10.0.19045.0

Attached Files

  • bug report image 2.png
  • bug report image 1.png
  • 2024-01-16 04-04-57.mp4
  • attachment information.txt

2c982ec7-629d-4957-94a0-0a744c64ee87

@gm-bug-reporter gm-bug-reporter bot added ide-bug Bugs with the GameMaker IDE project This issue has a sample project attached labels Nov 29, 2024
@stuckie stuckie moved this from Triage to Backlog in Team Workload Dec 2, 2024
@rwkay
Copy link

rwkay commented Dec 4, 2024

OK there are a few issues with your code which may impact how things are working...

you have multiple loops that are going through your gamepads but you are incorrectly starting your loops at the device_count or the axis_count or button_count - if you are doing it this way and counting down you have an off by one error and you should be starting it at device_count-1 and looping while the count is >= 0.... this may change results.

you are also using gamepad_button_check when you should use gamepad_button_value which will give you the current value of the button rather than a filtered state check.

if you are reading raw values for gamepads you would also need to check the hat values and counts - see https://manual.gamemaker.io/beta/en/GameMaker_Language/GML_Reference/Game_Input/GamePad_Input/gamepad_hat_value.htm

You should also be using the gamepad attach system events to see gamepads attached and removed rather than iterating over every gamepad device each frame. see https://gamemaker.io/en/tutorials/coffee-break-tutorials-setting-up-and-using-gamepads-gml

there is a handy library called Input https://github.com/offalynne/Input that abstracts away this whole implementation details you may want to look at that...

Within gamemaker those functions gamepad_button_count, gamepad_button_values etc are just returning the values that DirectInput is returning to us... so for the gamepads that were giving incorrect values (assuming you correct the above issues with off by one counts) then you are just seeing the raw values returned by the hardware

@rwkay rwkay closed this as not planned Won't fix, can't repro, duplicate, stale Dec 4, 2024
@github-project-automation github-project-automation bot moved this from Backlog to Done in Team Workload Dec 4, 2024
@looloopaa
Copy link

@rwkay
Hello, made an account so I can respond.
I'm not going to argue that my project's code is correct, but that shouldn't really factor in here since the sample code I sent is only checking controller port 4 to listen for button and axis inputs, right? I even opened up my old project file in Game Maker Studio 1 again and ran this same draw code to make sure that the 5 different controllers didn't suddenly break. It works perfectly fine in that older project. I totally get that a lot has changed between then and now, but this is unexpected behavior returning different values from both that older version of itself and other programs.

In Game Maker Studio 1, this controller's D Pad is read as an axis and not a button. (it can't check for hat in that one obviously)
On Windows, this controller's D Pad is read as an axis, and not a hat input or a button.
In other programs, this controller's D Pad is read as an axis and not a hat input or a button.
But for current Game Maker Studio, it doesn't read any axis on this controller or hat input, but as a button.

Attached is a video showing both the old project, the new project, and the windows controller properties. The code has been changed slightly to show the button values instead of JUST whether or not the button check is true. Like, you can see there's something weird going on here, right?
https://github.com/user-attachments/assets/18ee4382-00cf-455b-bf17-9669dcec9b73

I really appreciate you pointing me in the direction of those resources and will absolutely check them out, but I'm pretty sure my poor programming knowledge and ignorance isn't the root of this, since even those superior methods of controller integration will return these same values in any case.

@rwkay
Copy link

rwkay commented Dec 4, 2024

Without knowing what the controllers are I could not really tell you what should happen - the values that get passed to the code are exactly what DirectInput is telling us.

Usually D-pad on modern controllers (I have no idea what controllers you are using) come in as HAT values on DirectInput but this is not always true - I have no idea what the joy control panel is showing (probably some older API that windows has had for years)

So without knowing the actual controllers I cannot advise any further.

here is a project that I have used to show all the values that come from the sub-systems it would be useful to see what comes from your gamepads with this project

GamepadRemap_v4 (2).yyz.zip

@looloopaa
Copy link

Oh yeah, I have no doubt that it's happening for good reason. These are cheap retro style usb controllers I got off amazon years ago. If I weren't running into this problem ONLY with this aspect of Game Maker, I wouldn't be causing trouble, but because they clearly used to work as axis before I upgraded and now they read as buttons instead and don't work, I don't get it. XInput controllers still work perfectly fine, everything is where it should be, even with the off-brand ones I have.

It should also be noted, these controllers work fine in games made by Game Maker! The SNES controller specifically works perfectly in ondydev's game Tresbashers made in GMS2, for example, even when inputting custom controls. Super weird!

the NES style controller used in previous videos (despite it saying snes in the program, haha)
https://github.com/user-attachments/assets/26d3923b-48a7-4f03-a474-1c34dfbd2774

an SNES style controller
https://github.com/user-attachments/assets/707d9601-0e0f-4480-b195-2aadf0beb4f3

Okay, but here's something interesting. They have the same problem behavior in this project, BUT, if I go and hit the "remap" button, the inputs that are "stuck" light up for a second and then turn off. The Dpad inputs are showing as axis inputs there, and as the correct values at that, and going back has the resting values at 0.50. How absolutely bizarre...
https://github.com/user-attachments/assets/73892364-c802-4104-872a-089d2c84be11

@rwkay
Copy link

rwkay commented Dec 5, 2024

Please try using the Input library that I linked above with these controllers - this may be situations that alynne has already encountered and implemented a solution for.

the raw functions that you (and my project) are using - simply pass through the underlying values from DirectInput - I know alynne has done a lot of work across different devices to better interpret what is coming through from that layer.

@gurpreetsinghmatharoo gurpreetsinghmatharoo moved this from Done to Not Planned in Team Workload Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ide-bug Bugs with the GameMaker IDE project This issue has a sample project attached
Projects
Status: Not Planned
Development

No branches or pull requests

2 participants