AndroidExtras update questions. Also Marshmellow file access

Previous topic - Next topic

Kitty Hello

Excellent. Can you send me the changes made to the GLBasic code? I found you have a new function: float AndroidFloatCode(int skey)
Where do you use it?

Also, I can't seem to load some resources. And I don't seem to be able to write to DOCUMENTS (Android 6.0 here).

I get:
07-20 21:53:15.807 13711 13739 I glbasic : /data/data/com.glbasic.gacknonfree/files/Media/projects/version.txt
07-20 21:53:15.807 13711 13739 I glbasic : /storage/emulated/0/Documents/GACK/version.txt

spacefractal

1. AndroidFloatCode(int skey) is used in sdl_main.cpp and in few changes to the KEY() command in glb_pc.cpp. Its used for better keyboard and gamepad support (where JOY commands cant been used, but much better been treated as a KEY, since Android gamepad is mapped very much differents). Next post is the change for KEY().

Code (glbasic) Select

in glb_pc.cpp, im added this for the KEY() function:


Code: GLBasic [Select]
// ------------------------------------------------------------- //
#if defined(ANDROID)
        extern "C" int AndroidScancode(int);
#endif

DGNat   KEY(DGNat key)
{
#if defined(ANDROID)
        return AndroidScancode(key);
#else
        #ifndef GLB_CONSOLE
                if(++gKeyStatusCounter > 128)
                {       
                        gKeyStatusCounter=0;
                        pDXin->GetKeyboardStatus();
                }
                return (DGNat)(pDXin->GetKey((unsigned char)key));
        #else
                return 0;
        #endif
#endif
}


2. FOR DOCUMET, ALLWAYS use "APPDATA", which is a more safe way to save data (have been that since Android 4.1 really). On some devices, you cannot save or use "DOCUMENT" (which might crash on some devices), which can been seen write protected. This issue was found after a system update on Ouya.

If you ask me, directory used should really been swapped bewteen "DOCUMENT" and "APPDATA". But im diddent do that due compatible, but choiced not do that. Its ok for me, not to change the default, but could been possible to swap it by a option in strings.xml or in androidmanifest.xml.

3. Also im have to say ALLOWESCAPE TRUE is WRONG for Android and should NEVER do that. You need to do a correct BACK behaiver (ingame -> menu -> quit etc) now. You can get rejected by both Google (Android TV) and on Amazon AppStore. You can no longer use glbasic ALLOWESCAPE TRUE on Android at all. So dont do that.

Im might might block this command to forced been FALSE generally on Android. Its the only way no. Back can been checked by a simple KEY(1).
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

spacefractal

also if you send me changes, then im can send your mine (its some time ago really). Im mostly thinks only glb-full.cpp and glb_pc.cpp is changed (as well the security fix, which is matter to update the cpp files).
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

Schranz0r

I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

spacefractal

Gernot did not asked about ALLOWESCAPE :-). Its my self, because its the same area and possible issue. Yes DOCUMENT issue is quite odd throught. im throught im have fixed it by used the recommored directory by Google. A issue im should look on, but currectly im dont have Android 6 installed yet.

Rest is pretty simple.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

MrPlow

Hi

So for future ref - i should
ALWAYS use "APPDATA"? and nots DOCUMENTS



Comp:
Speccy-48k, Speccy-128k, Amigas, PCs

spacefractal

yes. its a old bug, but dedicated to not change it for compatible. you can do try to use both eventuelly, etc checking you can write to it or not on startup.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

MrPlow

Is there an easy to check you can write to it without crashing the app??
Comp:
Speccy-48k, Speccy-128k, Amigas, PCs

spacefractal

Crash should not hoppens on read. You can eventuelly set a data file APPDATA, before reading for DOCUMENTS for moving on startup after a update.

I'm should swap them, but sis not do that for compatible, but I'm might do a option or directly do that on newer Andeoid versions.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/