Found the post-- sounds great!
Happy to take a look at some of those games and see if can get some working on mobile , thanks!
Virtual gamepad
Re: Virtual gamepad
Thanks SugarRayLua, that's great. I will try to implement any solution based on the feedback received. Hopefully the list will improve over time.SugarRayLua wrote: ↑Wed Feb 14, 2024 2:36 pm Found the post-- sounds great!
Happy to take a look at some of those games and see if can get some working on mobile , thanks!
Re: Virtual gamepad
I added a third layout which is a virtual keyboard. The first game to implement this layout is Gravitonik which you can now play on your mobile:
https://codeberg.org/glitchapp/gravitonik
https://codeberg.org/glitchapp/virtual-gamepad
https://codeberg.org/glitchapp/gravitonik
https://codeberg.org/glitchapp/virtual-gamepad
Re: Virtual gamepad
I've recently started a function to provide network functionality to the touch library. The main function in charge of that feature is here: https://codeberg.org/glitchapp/virtual- ... ckAxes.lua
Basically the data should be transmitted over UDP to another instance and retrieve through the variables:
This will open the possibility of easily making games multiplayer and even over the internet (although for latency sensible games it may not work).
Beware that the function "releaseJoystickButtons" in charge of receiving the release data from a real controller interfere with the touch controls and needs to be commented if you don't plan to use a real gamepad so that the touch buttons react
Feel free to test it and let me know what you think, and of course feel free to contribute if you have ideas on how to improve this feature.
Basically the data should be transmitted over UDP to another instance and retrieve through the variables:
Code: Select all
receivedLeftXAxis = 0
receivedLeftYAxis = 0
receivedRightXAxis = 0
receivedRightYAxis = 0
Beware that the function "releaseJoystickButtons" in charge of receiving the release data from a real controller interfere with the touch controls and needs to be commented if you don't plan to use a real gamepad so that the touch buttons react
Code: Select all
if joystick then
assignRealGamepadAxisToVirtualAxis() -- assign real Gamepad values to virtual gamepad
releaseJoystickButtons(joystick, button) -- Release joystick buttons
end
- Attachments
-
- TouchControls-0.1-5.love
- (1.07 MiB) Downloaded 278 times
-
- Citizen
- Posts: 55
- Joined: Sat Dec 03, 2022 7:52 pm
Re: Virtual gamepad
Coming along nicely, @glitchapp!
Only thing I notice is that as move virtual joystick from one extreme to the other (e.g. from far left of center to far right of center) the joystick moves as if it were moving through a gearshift box (i.e. as I drag the joystick it seems to "jump" from farthest left to a position not quite as far left to center to a position mid to right of center to extreme right as opposed to rendering a smooth transition from one extreme position to the other). If I rotate the virtual joystick in a circular position, the app rotates the circular movement smoothly. Not sure if that "gearshift" life side to side and up to down movement of the joystick is what you were intending; other virtual joysticks instead render side to side and up to down movement as a smooth continuous movement.
Fyi
Only thing I notice is that as move virtual joystick from one extreme to the other (e.g. from far left of center to far right of center) the joystick moves as if it were moving through a gearshift box (i.e. as I drag the joystick it seems to "jump" from farthest left to a position not quite as far left to center to a position mid to right of center to extreme right as opposed to rendering a smooth transition from one extreme position to the other). If I rotate the virtual joystick in a circular position, the app rotates the circular movement smoothly. Not sure if that "gearshift" life side to side and up to down movement of the joystick is what you were intending; other virtual joysticks instead render side to side and up to down movement as a smooth continuous movement.
Fyi
Re: Virtual gamepad
Thanks for the feedback SugarRayLua,SugarRayLua wrote: ↑Fri Mar 01, 2024 3:42 am Coming along nicely, @glitchapp!
Only thing I notice is that as move virtual joystick from one extreme to the other (e.g. from far left of center to far right of center) the joystick moves as if it were moving through a gearshift box (i.e. as I drag the joystick it seems to "jump" from farthest left to a position not quite as far left to center to a position mid to right of center to extreme right as opposed to rendering a smooth transition from one extreme position to the other). If I rotate the virtual joystick in a circular position, the app rotates the circular movement smoothly. Not sure if that "gearshift" life side to side and up to down movement of the joystick is what you were intending; other virtual joysticks instead render side to side and up to down movement as a smooth continuous movement.
Fyi
No it is not intended, it's the first time I try to make a virtual thumbstick and I'm using some ideas I used for a radial menu... I think what you are telling me is caused by the threshold.
Code: Select all
-- Update the existing updateThumbstickAxes function to update left thumbstick axes
function touchControls:updateLeftThumbstickAxes(x, y)
local relativeX = x - self.leftThumbstickX
local relativeY = y - self.leftThumbstickY
local length = math.sqrt(relativeX^2 + relativeY^2)
if length <= self.leftThumbstickRadius then
self.leftxaxis = relativeX / self.leftThumbstickRadius
self.leftyaxis = relativeY / self.leftThumbstickRadius
else
local scaleFactor = self.leftThumbstickRadius / length
self.leftxaxis = relativeX * scaleFactor
self.leftyaxis = relativeY * scaleFactor
end
I need to keep tweaking all of those parameters and also the size of the thumstick and buttons to find out how to make it more smooth and comfortable.
I don't make releases as oft as updates so if anyone is interested on testing the last tweaks I do to this library feel free to fork the repository and do git pull. I will try to find out the right parameters with your feedback and some experimentation, I hope I manage to get it right!
Last edited by glitchapp on Fri Mar 01, 2024 6:31 am, edited 1 time in total.
Re: Virtual gamepad
I think I solved that problem, feel free to test it and let me know if it is right now.
I still need to adjust other parameters but I think it starts to feel right and react like a real thumbstick does.
I still need to adjust other parameters but I think it starts to feel right and react like a real thumbstick does.
- Attachments
-
- TouchControls-0.1-6.love
- (1.07 MiB) Downloaded 324 times
-
- Citizen
- Posts: 55
- Joined: Sat Dec 03, 2022 7:52 pm
Re: Virtual gamepad
Yes, @glitchapp, much better-- pretty smooth now!
Re: Virtual gamepad
I've recently released a new version of the touch controls which introduces remote network capabilities.
The extra circles on top of the gamepad represents the thumbstick of the remote instance (and reacts to the receiving movement from that instance)
To test it all that is needed is to set up the Ip address of the receiving and sending instance on src/Network/sendAxes.lua and to open two instances of the controls and press "2" on one of them.
You can even test that functionality on the same computer, just make sure you set up the same ip for both the receiving and sending instance.
I'm sharing here because there is still a big problem: the lag make it almost useless for arcade or any game that requires fast response, this happens even through local network. I'm not sure how to solve that so just in case anyone knows and want to test it here is the preliminary demo.
* I forgot to mention that this new version can also be used with a real gamepad (without using the touch controls)
* Problem with lag is solved: I called send axes twice by mistake causing the lag, at least on local network now it is perfectly usable even for arcade games
The extra circles on top of the gamepad represents the thumbstick of the remote instance (and reacts to the receiving movement from that instance)
To test it all that is needed is to set up the Ip address of the receiving and sending instance on src/Network/sendAxes.lua and to open two instances of the controls and press "2" on one of them.
You can even test that functionality on the same computer, just make sure you set up the same ip for both the receiving and sending instance.
* I forgot to mention that this new version can also be used with a real gamepad (without using the touch controls)
* Problem with lag is solved: I called send axes twice by mistake causing the lag, at least on local network now it is perfectly usable even for arcade games
- Attachments
-
- TouchControls-0.1-7.love
- (1.22 MiB) Downloaded 272 times
Who is online
Users browsing this forum: Bing [Bot] and 4 guests