• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Gamepad input partially detected

R

RylanStylin

Guest
aight so i hate to do this but i have no idea how to fix this and ive been looking over documentation all day trying to find this out.

I am making a game on the desktop edition for windows and I want to add controller support. To learn to do it, I made a throwaway game and created an object. This is the code in the object:

///////////////
line 1: if(gamepad_button_check_pressed(4,gp_padr)) game_end();
line 2: if(gamepad_button_check_pressed(4,gp_face1)) game_end();
line 3:
line 4: if(gamepad_is_connected(4)) game_end();
////////////////

note: line x not actually written just there for visual aid
Upon starting the game, the game ends, because the gamepad is in slot 4.

if I remove the 4th line, the game does not close upon starting. Now, if I press D-pad right, nothing happens. If I press "A" on the controller, which is gp_face1, the game ends. I dont understand why gp_padr doesnt work, and why my controller is mapped to slot 4.

PLEASE SEND HELP.
 
Last edited by a moderator:

kburkhart84

Firehammer Games
The documentation is not very good on the input system. The constants in use there only apply for XInput devices. XInput devices show up as 0 thru 3. DirectInput devices show up as devices 4 thru 12. For those, you still use the same function gamepad_button_check() and gamepad_axis_value(), and even gamepad_hat_value() as DInput devices have actual POV hats in some cases.

So instead of using the gp_constants, you will just need to use numbers. My input system technically checks for all the supported inputs for these things, so I check for 10 axes(0 - 9), 32 buttons, and 8 directions on 4 POV hats. I use raw numbers instead of the constants and it works just fine for me.
 
R

RylanStylin

Guest
hmmm interesting
 
Last edited by a moderator:
R

RylanStylin

Guest
The documentation is not very good on the input system. The constants in use there only apply for XInput devices. XInput devices show up as 0 thru 3. DirectInput devices show up as devices 4 thru 12. For those, you still use the same function gamepad_button_check() and gamepad_axis_value(), and even gamepad_hat_value() as DInput devices have actual POV hats in some cases.

So instead of using the gp_constants, you will just need to use numbers. My input system technically checks for all the supported inputs for these things, so I check for 10 axes(0 - 9), 32 buttons, and 8 directions on 4 POV hats. I use raw numbers instead of the constants and it works just fine for me.
OK. I've tried playing around with setting values for the buttons instead of built in constants. I can get all the keys to work except A and Dup, Ddown, Dleft, and Dright. Is there a way to "get" key mapping? How exactly do you find the input keys? and incorperate this?
 

kburkhart84

Firehammer Games
I'm betting that your Dup, etc... are actually working as POV hat directions. Some controllers, including a Saitek Dual-Stick pad I have, are just like that. As far as the A, I really don't know why you aren't picking it up, you may simply not be checking every single possible option out there. The way I handle it in my input system is to not worry about it. I just let the player press the keys, and I search through literally every single possible one while in that searching mode. Then, since it picks it up, I just store it as assigned to that action. So the player presses whatever button they want to use to "jump" for example. Then in the game, it knows which one it is because it picked it up in the searching.
 
Top