Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - spacefractal

Pages: [1] 2 3 ... 250
1
nice spotted and fixed (its was a renamed function using the old function name).

Im did not uses any costume and actuelly im did not need to uses it at all for that game anyway, because im used GameInput.GetNumberOfPlayers() instead (that wasent in the game from the start)...

Alternative example could been this, if you want to check whick type of controller (keyboard or touch). The GameInput does not check about that. Just a idea, if you using a touch/mouse interface as well.

Code: (glbasic) [Select]
IF GameInput.Left(i)+GameInput.LeftStick_Left(i)+GameInput.RightStick_Left(i)>0
KL=1
CONTROLLER$="KEYBOARD"
ENDIF

2
btw autofire is something that could been implemenet in same style as a fpscounter.... this is something im actuelly cannot implement in this gameinput as the api does not get a call when a button is released. but should been easy to been implemented in a game, that want to checking that.

Also auto fire wasent fun in PowerUp Elevation, lol. That bird just keep jumping low and could not jump high at all. In a shooter game, well, im would property implement a such of a cool down feature anyway. Im think even Warhawk did that for the Speccy Next port.

3
auto fire and buffede controls was not the main scope of this code, not this time. the main scope was actuelly remapping on both keyboard and gamepad. None of my games would have a advancment of a auto fire at all anyway. You are fell free to add that of course if you want.

Also if you ask me, im would not care about it in a single player game.

4
just updated, so remapping can been started from a mouse and then wait the mousebutton to been released before countine. This was done if a user should screw the remapping and cant remapping, they could been remapped by touch/clicking on the reamp and then start it again. A fail safe procudure.

5
Im have annonced with full source code:
https://www.glbasic.com/forum/index.php?topic=11566.0


Yep PS4 and xbox has some differents. also if you checking the sld list, some controllers has id all the place, which is why im chossen to have a better remap system as main focus rather than implement the database.

Except some standard configuration.

6
Just updated to beta 2. Various bug fix and the user has now possible to swap a and b buttons, which is used in some regions and controller (like Nintendo ones) and deadzone can been set. etc you want analoge output or not.

7
based from this thread:
https://www.glbasic.com/forum/index.php?topic=11565.0

Im have choosen to update and reimplement GameInput to v2.0 beta. In this version the remapping has been totally rewrote and is now supporting gamepads as well keyboards. The formatting of codes is now based on a sdl database, but also added to possible to remap keyboard as well.

to implement to your game, you can do something like this:

Code: (glbasic) [Select]
// top of the code should have those defines:
?IFDEF WIN64
?DEFINE WIN32
?ENDIF

?IFDEF WIN32
?DEFINE DESKTOP
?ENDIF


// start of the code somewhere under loading.
LOCAL SaveFile$=PLATFORMINFO$("DOCUMENTS")+"/Yourgame/Yourgame_AutoSave.ini" // should been APPDATA on other platforms.
IF STEAMDECK=1 // if you want to do that, howover users can quit remapping by mouse button now (you could get stuck).
GameInput.init(SaveController$, 1) // the first two devices should not been possible to been remapped on steamdeck.
ELSE
GameInput.init(SaveController$, -1) // if you dont want possible to remap keyboard, set it to 0.
ENDIF

// Somewhere in the game input code.
// actuelley does nothing now on Windows, but only on Android.
LOCAL profilechanged=GameInput.update()

IF GameInput.Remap_IsRemapping()=1 // the function is doing remapping, dont do any game code
LOCAL result=GameInput.Remap_ScanCode() // return a sound/visual effect.
IF result=1 THEN SoundPlay("selectlevel")
IF result=2 THEN SoundPlay("confirmlevel")
RETURN
ENDIF

// polling input from the api (incude keyboard) example. far from all games should do this.
IF ISPAUSE OR S_Status$<>"play"
GameInput.EnableKeyboard(TRUE)
ELSE
GameInput.EnableKeyboard(FALSE) // in some cases, you dont want keyboard remapped ingame.
ENDIF

// This is something like that when you want to poll a joystick. In PowerUp Elevation, wbich
// im toke this snippet from, here all sticks controls the bird (include the right one).
LOCAL K1, K2, K3, K4, KJ
LOCAL Players=GameInput.GetNumberOfPlayers()

GameInput.SetDeadZone(0, 0.6) // analoge as digital with 0.6 as deadzone.
FOR i=0 TO Players-1
//IF GameInput.GetControllerName$(i)<>""
IF Players>0 // could been 0 on Android, but allways a least 1 on Windows throught as first player is on keyboard.

KL=KL+GameInput.Left(i)+GameInput.LeftStick_Left(i)+GameInput.RightStick_Left(i); IF KL>1 THEN KL=1
KR=KR+GameInput.Right(i)+GameInput.LeftStick_Right(i)+GameInput.RightStick_Right(i); IF KR>1 THEN KR=1
KU=KU+GameInput.Up(i)+GameInput.LeftStick_Up(i)+GameInput.RightStick_Up(i); IF KU>1 THEN KU=1
KD=KD+GameInput.Down(i)+GameInput.LeftStick_Down(i)+GameInput.RightStick_Down(i); IF KD=1 THEN KD=1

IF GameInput.ActionButton("A", i) OR GameInput.ActionButton("B", i) THEN KJ=1
IF GameInput.ActionButton("X", i) OR GameInput.ActionButton("Y", i) THEN KJ=1
IF GameInput.LeftTrigger(i) OR GameInput.ActionButton("RB", i) THEN KJ=1
IF GameInput.RightTrigger(i)=1 OR GameInput.ActionButton("LB", i) THEN TURNED=1

LOCAL SE=GameInput.ActionButton("select", i); // AB cab been swapped on some controllers
LOCAL PA=GameInput.ActionButton("parent", i); // AB cab been swapped on some controllers
ENDIF
NEXT

// somewhere in the menu to start the remap
// First argument, is if you want keyboard remapped or not.
IF OPTIONSELECTNAME$="remap"
// this is a full remap for a game controller, but only required buttons for keyboard.
// if a game controller dont have all buttons, the user will escape.
// if you dont want a full remap for a controller, you can remove those you dont uses.
GameInput.Remap_Start(0,"back:back/pause|*,start:start|*,leftx:Left Stick|Movement,a:Face Bottom|Jump,b:Face Right|Turn,x:Face Left|*,y:Face Up|*,leftshoulder:Back Left Top|*,rightshoulder:Back Right Top|*,LeftTrigger:Back Left Bottom|*,RightTrigger:Back Right Bottom|*,dpdown:Dpad Down|*,dpright:Dpad Right|*,dpup:DPad Up|*,dpleft:DPad Left|*,rightx:Right Stick|*,leftstick:Left Stick|*,rightstick:Right Stick|*")
ENDIF

// somewhere to print, when under remapping (allways max 3 lines)
// also escape or back button will allways quit remapping with no save.
IF GameInput.Remap_IsRemapping()=1
LOCAL line$=GameInput.Remap_GetText$(1)
BMFont.DrawText(line$, 0, PY+PH+SCALING*70, SIN(FADING*90)*1, SIN(FADING*90)*0.5*2, 0, -1, -2)

line$=GameInput.Remap_GetText$(2)
IF line$<>"" THEN BMFont.DrawText(line$, 0, PY+PH+SCALING*75, SIN(FADING*90)*1, SIN(FADING*90)*0.5*2, 0, -1, -2)

line$=GameInput.Remap_GetText$(3)
IF line$<>"" THEN BMFont.DrawText(line$, 0, PY+PH+SCALING*80, SIN(FADING*90)*1, SIN(FADING*90)*0.5*2, 0, -1, -2)

RETURN
ENDIF

this code is only tested on Windows, while the code for Android is there, im have nowhere tested it at all. Its might or might not work, or not compile at all. No idea. Im have still yet to update Android Studio, if im want to do that.

PS. PowerUp Elevation has been updated on steam, which uses this api (that game became test game).

8
Android threat gamepads as keyboard and is even worse than the Windows does. You newer know which keys a button send. This was the main thing why im changed KEY() to use float rather than integer as its was needed for Android as im remember.

Im also reouted the sticks to been KEY(241) to 256 as well, and does also support multiple players (keys 0-255, 256-511 and so on).

9
and this one should been much easier to integrate than the old GameInput remapping system, which was qutie costumesome and actuelly limited.

In the old system, you was more or less needed to integrate that by you self, which is not need now, only require to call a init, and checking a string and checks when its finished.... that it.

Something like this:
Code: (glbasic) [Select]
LOCAL result=GameInput.Remap_ScanCode(0, "back:back/pause|*,start:start|*,leftx:Left Stick|Movement,a:Face Bottom|Jump,b:Face Right|Turn,x:Face Left|*,y:Face Up|*,leftshoulder:Back Left Top|*,rightshoulder:Back Right Top|*,LeftTrigger:Back Left Bottom|*,RightTrigger:Back Right Bottom|*,dpdown:Dpad Down|*,rightx:Right Stick|Cursor,dpright:Dpad Right|*,dpup:DPad Up|*,dpleft:DPad Left|*,leftstick:Left Stick|*,rightstick:Right Stick|*")
IF result=TRUE
DEPRINT(GameInput.Remapping$) // only for testing
DEPRINT("FINISH")
ELSE
DEPRINT(GameInput.RemapStatus$) // the output.
ENDIF

Still missing a way to init it (its start right way as its does now, not intended).

10
now im is forced to break the sdl style database, so im could extends it a bit, when you doing remapping. etc example combination of keyboard and arcade controller. The way we using on Android is also a little bit different as we need to scan the controller using KEY() anyway. No idea how its worked with android sdl throught.

The only one that is fixed by now on keyboard, that is the ESCAPE button. That is allways on Back. Im is still missing to do a example, get a interface to start/finish it, get the save done. But the main thing, the main thing seens working, a least on Windows.

Its would look like this when doing on a keyboard:
Code: (glbasic) [Select]
Remap Your [Keyboard]|Press [Movement Down] key
Remap Your [Keyboard]|Dont touch any keys on your keyboard
Remap Your [Keyboard]|Press [Movement Right] key|wait 10 to finish
Glbasic ImageLoad: Graphics/preview2.png
Remap Your [Keyboard]|Press [Movement Right] key|wait 10 to finish
Remap Your [Keyboard]|Dont touch any keys on your keyboard
Remap Your [Keyboard]|Press [Movement Left] key|wait 10 to finish
Remap Your [Keyboard]|Press [Movement Left] key|wait 10 to finish
Remap Your [Keyboard]|Dont touch any keys on your keyboard
Remap Your [Keyboard]|Press [Movement Up] key|wait 10 to finish
Remap Your [Keyboard]|Press [Movement Up] key|wait 10 to finish
Remap Your [Keyboard]|Dont touch any keys on your keyboard
Remap Your [Keyboard]|Press The [Jump] key|wait 10 to finish
Remap Your [Keyboard]|Press The [Jump] key|wait 9 to finish
Remap Your [Keyboard]|Press The [Jump] key|wait 8 to finish
Remap Your [Keyboard]|Dont touch any keys on your keyboard
Remap Your [Keyboard]|Press The [Turn] key|wait 10 to finish
Remap Your [Keyboard]|Dont touch any keys on your keyboard
Remap Your [Keyboard]|Press [Cursor Down] key|wait 10 to finish
Remap Your [Keyboard]|Press [Cursor Down] key|wait 9 to finish
Remap Your [Keyboard]|Dont touch any keys on your keyboard
Remap Your [Keyboard]|Press [Cursor Right] key|wait 10 to finish
Remap Your [Keyboard]|Press [Cursor Right] key|wait 10 to finish
Remap Your [Keyboard]|Dont touch any keys on your keyboard
Remap Your [Keyboard]|Press [Cursor Left] key|wait 10 to finish
Remap Your [Keyboard]|Press [Cursor Left] key|wait 10 to finish
Remap Your [Keyboard]|Dont touch any keys on your keyboard
Remap Your [Keyboard]|Press [Cursor Up] key|wait 10 to finish
Remap Your [Keyboard]|Dont touch any keys on your keyboard

The cursor keys was actuelly just a test, not need in that game, lol. hihi.

11
Im should here possible to return which key that is used for a partical button, then up to the game to uses it.

Anyway, far from all glbasic games uses a fulll game controller. Most games only uses few input, so you dont need to remap a full controller, if its not needed by the game.

etc example a stick/dpad and 2 buttons.

Same with keyboard. Games that uses all buttons, would property been a keyboard/mouse game. Mouse is not used by the gameinput.

Powerup Elevation is example a case im dont uses gameinput for the keyboard (can been checked), if a player is a keyboard or not. This is due nature of the game.

12
Code: (glbasic) [Select]
Remap on a [ps4 fun controller]|Hold [Down] with your primary [Left Stick/Pad]
Remap Controller: [ps4 fun controller]|Dont touch any Sticks/buttons
Remap on a [ps4 fun controller]|Hold [Face Bottom] Button|wait [5] to end mapping
Remap on a [ps4 fun controller]|Hold [Face Bottom] Button|wait [4] to end mapping
Remap Controller: [ps4 fun controller]|Dont touch any Sticks/buttons
Remap on a [ps4 fun controller]|Hold [Face Right] Button|wait [5] to end mapping
Remap Controller: [ps4 fun controller]|Dont touch any Sticks/buttons
Remap on a [ps4 fun controller]|Hold [Face Left] Button|wait [5] to end mapping
Remap Controller: [ps4 fun controller]|Dont touch any Sticks/buttons
Remap on a [ps4 fun controller]|Hold [Face Up] Button|wait [5] to end mapping
Remap Controller: [ps4 fun controller]|Dont touch any Sticks/buttons
Remap on a [ps4 fun controller]|Hold [Back Left Top] Button|wait [5] to end mapping
Remap Controller: [ps4 fun controller]|Dont touch any Sticks/buttons
Remap on a [ps4 fun controller]|Hold [Back Right Top] Button|wait [5] to end mapping
Remap Controller: [ps4 fun controller]|Dont touch any Sticks/buttons
Remap on a [ps4 fun controller]|Hold [Back Left Bottom] Button|wait [5] to end mapping
Remap Controller: [ps4 fun controller]|Dont touch any Sticks/buttons
Remap on a [ps4 fun controller]|Hold [Back Right Bottom] Button|wait [5] to end mapping
Remap Controller: [ps4 fun controller]|Dont touch any Sticks/buttons
Remap on a [ps4 fun controller]|Hold [Dpad Down] Button|wait [5] to end mapping
Remap on a [ps4 fun controller]|Hold [Dpad Down] Button|wait [4] to end mapping
Remap Controller: [ps4 fun controller]|Dont touch any Sticks/buttons
FINISH

Also if dpad was used as a stick, the stick will been skipped (only uses as a hat), as im asume the controller dont have such of one.

Would works like this. Currectly working from logcat. Still working on it. Should show Key rather than button when on keyboard. hihi.

13
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.

14
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.

15
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).

Pages: [1] 2 3 ... 250