Updating GameInput API (previous wanted to check Switch)

Previous topic - Next topic

spacefractal

Those who have Swicth Pro controller. Can you checking which buttons that does that.

Etc im need the name of it, and how and which axis the right controller and the both analoge triggers does.

Im purchased such of one you can see, but that controller did not have the analoge trigger, but a digital trigger instead (not a issue in such a game that is not racing really). Im wasent aware of that of course, but im implementated this feature of course.

Im do believe they follow the ps layout button wise, not xbox. Then im will update my GameInput thing for Windows.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

bigsofty

I have some 8Bitdo Pro 2 Wired USB Controllers for Switch, these results any use?
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

spacefractal

Just give me the screen like the above one.

Anyway im think found a method im can detect, its using a xbox or a ps4/switch laylout....

Code (glbasic) Select

self.code$[i]="standard"
IF RIGHT$(self.NAMES$[i],1)="s" OR INSTR(self.NAMES$[i],"switch")>-1 OR INSTR(self.NAMES$[i],"pro controller")>-1
self.code$[i]="switch"
self.digi[i]=-1
ENDIF

IF INSTR(self.NAMES$[i],"ps4")>-1 OR INSTR(self.NAMES$[i],"ps3")>-1
self.code$[i]="ps4"
ENDIF

IF INSTR(self.NAMES$[i],"xbox")>-1 OR INSTR(self.NAMES$[i],"360")>-1
self.code$[i]="xbox"
ENDIF

IF self.code$[i]="standard"
LOCAL result=GETJOYBUTTON(i-1, 6)+(GETJOYRX(i-1)+1)/2
IF result<0.4 OR result>0.6 THEN self.code$[i]="ps4/switch"
ENDIF


GETJOYBUTTON(i-1, 6)+(GETJOYRX(i-1)+1)/2 gave 0.5 on a xbox controller and 0.0 on a ps4 controller or if its dont have such a left trigger.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

bigsofty

Out of house till tomorrow night but maybe this database of controller mappings may help?

https://github.com/gabomdq/SDL_GameControllerDB
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

spacefractal

This is a good database. The only issue is im in this case need to find out how to get the GUID code of that controller. When its possible, im could actuelly implement that one in the GameInput API instead that one im using (only contains official xbox, ps4 and switch controllers).
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

spacefractal

except not getting the GUID code, its acuelly easy to implement the style of the data used in the database and also a better way to remap later (binding).

Also its looked like the HORIPAD S switch controller as im is not in the database.... damn :-).
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

spacefractal

Im consider im should a little seperate remapping utilty you can uses for the game, rather than doing it from ingame. In that way GameInput could automatic tacle that rather than the game needs to do the same.

Howover can somebody draw a nice controller image that resemple a controller that could been used from a big compony, which should should like a generic controller.

Something like this in the same resolution, but without colors and antialasing:
https://opengameart.org/content/generic-gamepad-template

Then im will give it a try. Im also could do same kind of utility for key binding as well.

By now the utilty would been Windows only (but im will include the source code of course).
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

bigsofty

This guys got quite a few vector art based ones...

https://zacksly.itch.io/

There CC By 3.00 license, so you can share if credit is given.

Oh and here is the 8bitdo Pro 2...
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

spacefractal

Looks different than me. This cause its very important to also possible to remap on controllers, so you can support them all, regaardless thier configuration.

etc im will improve GameInput and clean its vastly up and also would been possible to remap keyboard too with the utility in same method with a String. etc a was seen as axis, while b was a button, then im uses k for a keyboard button....

Etc im will uses a screen like it.

PS. IM guess its could been looks much better.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

bigsofty

Looks good.   :good:

Yeah, my 8bit do pro 2 wired is not in the controller database either(even though Valve uses this DB for Steam) but my Xbox One controller is.

Better to cycle through a diagram of a generic joypad, highlighting buttons and asking the user to press(or skip) the equivalent button on their controller, to make custom templates. Maybe setup some of the more popular ones by name by default. Xbox, Ps4 for example.
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

spacefractal

its would been something like that, but of course with only the input a game would need.

Also that string based system did caused the code to been vastly shorted with fewer lines, since only the init and a function take care most of it really.

Also im will also see how im can save the code for a controller, so people a least could tweak it, even there is no remapping feature in a Windows game.

Today im implemented keyboard keys as well. On Android, its would been keyboard only of course as this would been easier its should, that way im impleneted using KEY(), while its why a outout is from 0-128 rather than 0-1.

But all in all, its totally impossible to support every gampad, but 99% of times, remapping should do the job. That is the main goal here. This time the utility should do this for you as well. even for each player.

btw, for standard, its of course ps4, switch and xbox. the main layout would been  after ps4, not xbox. The main thing here, its depend how the trigger is used (on Ps4, 3 axis returns -1 on 3 axis, while a xbox does do that).
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

bigsofty

Interesting, sounds good. I have been using my basic controller library for a while now. Unfortunately this thread has highlighted some shortcomings in my own approach...  :'( Seriously though, it will be interesting to see what you finally come up with Spacefractal.
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

spacefractal

getting more code today. Etc im choosen to uses the digital button and not the analoge trigger on a switch/ps4 for to get more combatible as possible. Those controllers sends 2 inputs, the analoge and a digital one. Im just choosen to take advance of that in this case. Most of time, we dont using the analoge trigger anyway, except its a racing game.....

Also im did a another SCANCODE, like INKEY$, which can been used per player here today (this include both keyboard and controllers). Its seens the button one on the analoge trigger might invoke before the analoge one. This is just to been aware when doing a remapping lol.

Also..... some controllers has AB and XY swapped. Im should do code for that as well as a user selectable. But the game can both disable and enable it. Like using it in menus, but not ingame.

Sooner or later im will also release the code as well. Property later next week.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

bigsofty

One small suggestion, as my old lib does it this way, is for each button to buffer each button scan. This would be a list of the button states, discarding the very earliest states in the list, I save the last 2 seconds, of button scans.

This would allow more history of key presses. Examining the list for certain action.

Easy to see if the user is holding down a button, say for in my case a secondary fire mode with a large single shot.
Check for combos, double presses, or even triple presses. Up and down, in quick succession.
Check if he is cheating with an auto fire 🤪

You can obviously do it in the game code but this way abstracts the usual fluff of having to set flags outside the lib.

Good luck with the lib, I've decided to rewrite mine because of some of the points raised here, which is a good thing!  :good:


Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

spacefractal

im is not intersered for any button combos as this is not what a controller api, like that one im doing is. This is what a game that using the api should do. All im want to do is make sure the remapping is easy as possible and let api do the job when remapped.

etc im started on the remapping, and do something like this when a user call it:
Code (glbasic) Select

LOCAL result=GameInput.Remap_ScanCode(1, "a:Face Bottom,b:Face Right:,x:Face Left,y:Face Up")
LOCAL status$=GameInput.RemapStatus$


the result would simply just return TRUE when finished or the user quit. Api does the rest. That include keyboard and joypad. (number 1 is a player).

btw need to deal with the stick. Some controllers might not have a stick, but only a dpad. Those that only have a dpad might have reduced number of buttons. So you can quit/end it anytime. So first you should do is move the stick..... im havent implemented it yet.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/