A quick gamepad tester I wrote for picotron to test the gamepad api. The tester also supports changing the player number to use multiple gamepads.
I labeled the buttons according to their corresponding keyboard inputs, and layed out the buttons according to how they mapped on my xbox controller.
The two buttons in the middle are buttons 6 and 7, which the readme lists as reserved, but I think represent start and select buttons.
Button 6 seems to map to the start and home buttons, as well as the enter key.
Button 7 doesn't seem to map to anything yet.
As of writing there seems to be a bug in picotron where higher player numbers don't work correctly.
player 0 works properly, but odd numbered players, such as player 1, will have their inputs split across two controllers.
I've also confirmed that as of writing picotron only fully supports up to 4 controllers. If you connect a 5th controller, half of their inputs will register on player 7, and player numbers higher than 7 aren't supported so only half the controller will work.
Update:
Now highlights the player tab when that player's controller has active inputs, making it easier to find what player your controller is mapped to.
Update 2:
Now reports analogue values for the sticks
It wouldn't let me export on windows so I tried on my steamdeck, which runs linux
I started writing the same thing to make a dual-stick shmup, and discovered there are some bugs in Picotron's input. Arrow keys, d-pad and joysticks aren't mapped to the 0,1,2,3 directions properly, at least in Windows 10.
Nice work!
There is a problem pointing straight x/y axis with sticks. I think v2 of this app must show the stick direction as a vector :)
Joystick axis are being reported as diagonals too often, I think the circle is not evenly divided by either Picotron or Gamepad_tester. https://youtube.com/shorts/e5BfUavQVcQ?feature=share
I wrote my own gamepad tester app and I can confirm this input issue is in Picotron itself. https://twitter.com/conorokane/status/1768608063886651458
I've tested it with 5 different gamepads so far and strangely I've found the diagonals issue only happens with some of them! It seems with some controllers picotron reports any nonzero axis value as being true for that direction?
In particular my generic xbox and switch controllers have worked properly with picotron whereas all of my playstation controllers have the diagonals issue others have described. (both my generic and official ps4 controller, as well as my victrix controller when set to pc mode has the issue)
I'm pretty sure the axis thing is not a real issue in the tester.
Even more! And if your gamepad gives you easy x/y axis -- it is a one with bad sticks that tend to stick to axis.
In real world the real "only X" or "only Y" have to be triggered ONLY when sticks are moved STRICTLY vertical or horizontal, that is pretty difficult to do with this analog stuff (and the more precise stick is, the harder the job is).
That is why I asked for the vector version of the tester. But it is possible ONLY if picotron has an API to get stick angles and not a binary values
I don't think picotron currently has a way to get analogue values for the sticks, the value returned by the btn function is just true or false.
@Cutievirus & @maleficmax Actually, one of the first tests I did was to print
the values of the btn
function, which showed that the value returned by btn
is actually a number! Here's a basic test program to show the printed values:
function _draw() cls() for i=0,15 do ?tostr(btn(i)),0,i*10,btn(i) and 27 or 22 end end |
Oh I didn't know that! I got errors when trying to treat them as numbers because they're false when at rest, so I assumed it was just a limitation.
It's a bit strange to switch between boolean and numbers like that but I guess that's how it has to be considering zero is truthy in lua.
I updated the tester to report analogue values now!
@Cutievirus Wow! Great news! It works awesome now, exactly as intended!
Thank you!
@Cutievirus - great to see the analog sticks in action! I'm quite excited for making dual-stick shmups in Picotron now.
Also, I noticed at line 59 you're normalizing the vector if both axes have input. Isn't that only required for keyboard input? The circular gate on the joystick means you don't need to do this for analog joystick inputs.
@Conor
I checked the outputs and when you do a diagonal input both values sit at about 181, which even seems to be true for keyboard input.
So you're right that I don't need to normalize them, it seems like picotron normalizes them for us which is pretty convenient.
[Please log in to post a comment]