GLBasic forum

Main forum => GLBasic - en => Topic started by: Kitty Hello on 2016-Jul-21

Title: AndroidExtras update questions. Also Marshmellow file access
Post by: Kitty Hello on 2016-Jul-21
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
Title: Re: AndroidExtras update questions. Also Marshmellow file access
Post by: spacefractal on 2016-Jul-21
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).
Title: Re: AndroidExtras update questions. Also Marshmellow file access
Post by: spacefractal on 2016-Jul-21
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).
Title: Re: AndroidExtras update questions. Also Marshmellow file access
Post by: Schranz0r on 2016-Jul-21
 >:D Pls use the Source Forum... :whip:

:whistle:
Title: Re: AndroidExtras update questions. Also Marshmellow file access
Post by: spacefractal on 2016-Jul-21
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.
Title: Re: AndroidExtras update questions. Also Marshmellow file access
Post by: MrPlow on 2016-Jul-25
Hi

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



Title: Re: AndroidExtras update questions. Also Marshmellow file access
Post by: spacefractal on 2016-Jul-25
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.
Title: Re: AndroidExtras update questions. Also Marshmellow file access
Post by: MrPlow on 2016-Aug-04
Is there an easy to check you can write to it without crashing the app??
Title: Re: AndroidExtras update questions. Also Marshmellow file access
Post by: spacefractal on 2016-Aug-04
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.