-
Notifications
You must be signed in to change notification settings - Fork 8
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
Comments
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 |
@rwkay 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) 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? 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. |
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 |
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) an SNES style controller 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... |
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. |
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
2c982ec7-629d-4957-94a0-0a744c64ee87
The text was updated successfully, but these errors were encountered: