Android Preprocessor ?

Previous topic - Next topic

mrplant

I am having problems detecting Android platform.

It would be great, looking at documentation as it stands, if there was a defined pre-processor for android platforms.

Why is there no defined name for the Anroid platform?

I am running into complicated problems looking at Target$ isntead and trying to create a ?DEFINE myself but the code is being run even on say WIN32. argh...

anyone?


Defined names
The following symbols are defined by the editor:
GLB_DEBUG Debug mode is active
GLB_VERSION The version number of the compiler
GLB_CONSOLE Program is a console program

Platforms:
WIN32 Current platform is: Win32
OSXUNI Apple Mac OS-X
LINUX Linux x86
IPHONEiPhone, iPod Touch
WINCEWindows Mobile, Windows Phone, PocketPC
GP2XWIZGamepark Holding GP2X-Wiz
WIN32DLLWin32, DLL
GP2XGamepark holding GP2X (F100, F200)
XBOXLINUXLinux x86, software renderer
CAANOOGPH Caanoo device

Example:


?IF GLB_VERSION < 7.0
   ?ERROR Precprocessor not enabled ;)
?ENDIF

?IF WIN32
  ?DEFINE FASTGFX
?ENDIF

?IF FASTGFX
   STARTPOLY -1
     POLYVECTOR  0, 0, 0,0, 0xffffff
     POLYVECTOR  0,99, 0,0, 0xffffff
     POLYVECTOR 99,99, 0,0, 0xffffff
   ENDPOLY
?ELSE // slow graphics ->
   DRRAWRECT 0,0,99,99, 0xffffff
?ENDIF

mrplant

MY game works on iOS, Osx, Win32, Android platforms and I coded this routine to detect and report back on platform info.

I set a preprocessor variable called ANDROID , if the android target is detected as there does not appear to be  a predefined one I could find documentation on.

Later on i test for IF defined (Android) ... do this code... etc.

My major problem is that the code below as it stands.. when I compile for windows - my game thinks it is running on Android and behaves accordingly.

In other words - the ANROID preprocessor variable is ALWAYS being defined..

How can I rewrite or work around this - I ideally want the game deciding on the platform rather than commenting or uncommenting a ?DEFINE ANDROID statement at the top of my code


Thanks.

//////////////////////////////////////
//   Get Device Info
///////////////////////////////////////


// This function gets more detailed device info.
// At the end of this function, Global Target$ will contain the text "PC", "IPHONE", "IPOD", "IPAD", "MAC" or "ANDROID", depending on device detected below. On Android, the ANDROID Preprocessor variable will also be created.

FUNCTION GetDeviceInfo:
   iPhoneVer = 0 // Reset iPhone specific version flag.
   Target$ = PLATFORMINFO$("") // Get the current Platform Info
   SELECT Target$
      CASE "WIN32"
         Target$ = "PC"
      CASE "IPHONE" // What type of iOS Device? Will return "iPhone", "iPod Touch", "iPad".
         Target$=UCASE$(PLATFORMINFO$("DEVICE")) // Get the Target Device Info. Make sure everything is in capitals for the ZX81 font!
         IF Target$="IPOD TOUCH"
            Target$="IPOD" // Device name too long so shorten it.
         ENDIF
         IF Target$<>"IPAD"
            iPhoneVer = 1 // Set flag for iPhone or iPod touch models. This allows for onscreen buttons to be moved later etc.
         ENDIF
      CASE "MACOSX"
         Target$="MAC"
      CASE "ANDROID"
         ?DEFINE ANDROID // Define the ANDROID Preprocessor variable.
   ENDSELECT
   
   
ENDFUNCTION

MrTAToad

I use ?IF DEFINED(ANDROID) as it's a bit clearer.  However, currently stacked ?IF commands do have a slight problem in that all of them are checked even if the ?IF value is true.

It is fixed in the old/current/last beta though