New games every week!
JSE - Controller Day Two Blog
2nd May 2021
I spent a lot of yesterday fiddling with controller code some more.

-=-=-

// GamePad Test // by Jayenkai // Created 2021/4/30 Graphics 640,640,1 Repeat CLS ang=360/7 port=0-1 Repeat desc="" dx=320+(Sin((port+1)*ang)*200) dy=320-(Cos((port+1)*ang)*200) If port==(0-1) then desc="Everything Combined" If port==4 then desc="Keyboard" If port==5 then desc="Onscreen Controls" Text dx,dy-48,"Port "+port,1 Text dx,dy-36,desc,1 // Combined DPad and Left Thumbstick SetCol 255,255,128;Oval dx+((GamePad(ButtonRight,port)-GamePad(ButtonLeft,port))*16),dy+((GamePad(ButtonDown,port)-GamePad(ButtonUp,port))*16),20,20,8 // Just the DPad SetCol 255,255,255;Oval dx+((GamePad(DPadRight,port)-GamePad(DpadLeft,port))*50),dy+((GamePad(DPadDown,port)-GamePad(DPadUp,port))*50),16,16,3 // Left Thumbstick SetCol 255,128,255;Oval dx+(GamePad(StickLX,port)*16)-64,dy+(GamePad(StickLY,port)*16)+24,18,18,8 // Right Thumbstick SetCol 128,255,255;Oval dx+(GamePad(StickRX,port)*16)+64,dy+(GamePad(StickRY,port)*16)+24,16,16,8 // Face Buttons s=4+(GamePad(ButtonA,port)*8);SetCol 0,255,0;Oval dx-18,dy+16,s,s,8 s=4+(GamePad(ButtonB,port)*8);SetCol 255,0,0;Oval dx-6,dy+16,s,s,8 s=4+(GamePad(ButtonY,port)*8);SetCol 64,64,255;Oval dx+6,dy+16,s,s,8 s=4+(GamePad(ButtonX,port)*8);SetCol 255,255,0;Oval dx+18,dy+16,s,s,8 // Triggers s=4+(GamePad(ButtonL1,port)*8);SetCol 255,255,255;Oval dx-18,dy-16,s,s,8 s=4+(GamePad(ButtonR1,port)*8);SetCol 255,255,255;Oval dx+18,dy-16,s,s,8 s=4+(GamePad(ButtonL2,port)*8);SetCol 255,255,255;Oval dx-24,dy-24,s,s,8 s=4+(GamePad(ButtonR2,port)*8);SetCol 255,255,255;Oval dx+24,dy-24,s,s,8 // Start and Select/Back s=4+(GamePad(ButtonStart,port)*8);SetCol 255,255,255;Oval dx+32,dy,s,s,8 s=4+(GamePad(ButtonSelect,port)*8);SetCol 255,255,255;Oval dx-32,dy,s,s,8 port=port+1 Until port>5 Flip Forever
You can Play with JSE here.

It's fairly complicated looking code, but all of the input can be gained from the single GamePad() command.
There's the four face buttons, four shoulder buttons, Start and Select, DPad, Two thumbsticks.
There's also onscreen controls that appear if you toggle the new button on the top-right of the JSE GUI. (I'll try to make this toggle be automagical, in future, but that may not be ideal in all situations..!)



I've spotted a few syntax issues, though. Like how you have to write "0-1" instead of just "-1"..
The language currently sees that as..
000000 = n1
000001 = m-
It reaches the "m"aths symbol, and tries to take "The previous number" (1) away from the 0'th number (1), leaving a resulting value of 0..
Hmmm..

I need to account for "numbers that are negative numbers", without breaking any instances of actual subtraction..

A line like, "7+-1" is currently baffling to the script engine, and if I'm completely honest, it's quite baffling to me, too!

Anyway, the controller code is getting better. I need to fix the "combined" values, as they're not working as nicely as they oughta.
I also need to dig out my old windows laptop and stress test the controller support.
It "works" on the Mac, but I only appear to have one single controller that works with it! My PS4 Dualshock seems to work perfectly fine, but all my older wired controllers don't seem to be doing a thing.
Grrrr.
(Maybe I should buy a PS5, just so I have another controller in the house....??)

I left the Windows Laptop charging overnight, so I guess at some point I'll be sitting on the couch with two laptops, and half a dozen wired controllers strewn around me, like some kind of crazy videogame developer!!

Something to look forward to..!
Views 71, Upvotes 7  
Daily Blog , Jse
New games every week!
Site credits : All of the above : Jayenkai
(c) Jayenkai 2023 and onwards, RSS feed

Blog - JSE - Controller Day Two - AGameAWeek