TheGameCreators / AGK-Studio

3 stars 1 forks source link

[Bug?] VirtualJoystick does not work in Studio on a Mac #1003

Open KevinCrossDCL opened 2 years ago

KevinCrossDCL commented 2 years ago

This probably isn't a bug because according to the help files VirtualJoystick only works on mobiles, however I'm raising it as a possible bug because one user on Discord says it does work on Desktops, so I'm guessing it's Windows only.

GetVirtualJoystick(1) returns a 0 when playing in Studio on a Mac. One issue with all of this is that if you don't put GetVirtualJoystickExists(1) around all of your joystick code it will error in Studio on a Mac and won't run because it will say that joystick 1 doesn't exist.

I haven't got access to a windows machine with AGK on it to test on that platform.

This is an example where I have to put GetJoystickExists around the code so that it runs in Studio (even though the joystick doesn't)

    if (GetVirtualJoystickExists(1))
        newJoystickAngle# = ATanFull(GetVirtualJoystickX(1), GetVirtualJoystickY(1))
        if (newJoystickAngle# < lastJoystickAngle#)
            SetSpriteAngle(plane.sprite, GetSpriteAngle(plane.sprite) - 2.2)
        endif
        if (newJoystickAngle# > lastJoystickAngle#)
            SetSpriteAngle(plane.sprite, GetSpriteAngle(plane.sprite) + 2.2)
        endif
        lastJoystickAngle# = ATanFull(GetVirtualJoystickX(1), GetVirtualJoystickY(1))
    endif

It was mentioned on the Discord server that I need to set my own images for inner and outer for it to work/show on the desktop but that doesn't solve it for me on a Mac, because the joystick definitely doesn't exist according to: GetVirtualJoystickExists(1)

KevinCrossDCL commented 2 years ago

VirtualNomad helped solve this issue by suggesting I add: AddVirtualJoystick(). Adding this fixed the problem.

Could someone please update the documentation to say that it's required for desktops (and maybe remove the part that says it's virtual joystick are for mobile only), specifically this page:

https://www.appgamekit.com/documentation/examples/input/2_joysticks.htm

VirtualNomad19 commented 2 years ago

i assume you didn't broadcast to mobile but i believe the virtualjoystick wasn't added since your desktop has a keyboard.

from the help: Windows and Mac platforms will emulate the joystick functionality using the keyboard, therefore no virtual joystick will be placed on screen, instead it will be hidden from view. It is only on platforms such as iOS and Samsung Bada that the virtual joystick will be displayed.

i don't know what it would do for something like the Microsoft Surface which, as i understand it, runs on Windows and doesn't have a keyboard (or if the keyboard wasn't present on a desktop). all devices, otherwise, could have bluetooth, USB (& wifi?) joysticks/keyboards, so...