GLBasic forum

Main forum => GLBasic - en => Topic started by: ampos on 2010-Oct-22

Title: To know running idevice
Post by: ampos on 2010-Oct-22
Is there a way to know the idevice the app is running?

-Ipad
-iPhone 2G
-iPhone 3G
-iPhone 3Gs
-iPhone 4

Jut desirees, of course... so we can adjust framerates for different devices...

:D
Title: Re: To know running idevice
Post by: MrTAToad on 2010-Oct-22
Shouldn't need to adjust frame rates :)

Its possible that few objects may be needed for some devices though...
Title: Re: To know running idevice
Post by: Moebius on 2010-Oct-23
Adjusting frame rates for different devices could be necessary - Sandscapes Lite runs quite slowly on my earlier generation iTouch, and you would lose some of the effect by reducing the number of sand particles.

If it's difficult to get the device the app is running on, you could have a settings menu, but unlike PC users, iOS users would expect their apps to run without having to change graphics settings to lower quality - they would expect it to be done automatically.

Anyway, it should be possible (not necessarily easy) to detect the device (apps like Doodle jump must do it?).  Perhaps this could be an extension of PLATFORMINFO$("DEVICE"), which according to the help file currently can return "IPHONE", "IPOD TOUCH", and "IPAD".
Title: Re: To know running idevice
Post by: MrTAToad on 2010-Oct-23
QuoteSandscapes Lite runs quite slowly on my earlier generation iTouch
In that case the system used to generate a constant movement speed needs changing :)
Title: Re: To know running idevice
Post by: Millerszone on 2010-Oct-23
This is what you want, but how do you use it in GLBasic?
http://iphonedevelopertips.com/device/determine-if-iphone-is-3g-or-3gs-determine-if-ipod-is-first-or-second-generation.html (http://iphonedevelopertips.com/device/determine-if-iphone-is-3g-or-3gs-determine-if-ipod-is-first-or-second-generation.html)
Title: Re: To know running idevice
Post by: matchy on 2010-Oct-24
From that code reference, create a .... :nana:.... wrapper!!!! Something like this (not tested):


device.gbas
Code (glbasic) Select

DEBUG "Debug: "+glb_Device()+"\n"
?IFDEF IPHONE
IMPORT "C" void glb_Device()
?ELSE
FUNCTION glb_Device:
// instert code for other non-iphone sub platforms
ENDFUNCTION
?ENDIF


device.mm
Code (glbasic) Select


#import "UIDevice+machine.h"
#include <sys/types.h>
#include <sys/sysctl.h>

@implementation UIDevice(machine)

- (NSString *)machine
{
  size_t size;
  sysctlbyname("hw.machine", NULL, &size, NULL, 0);
  char *name = malloc(size);
  sysctlbyname("hw.machine", name, &size, NULL, 0);
  NSString *machine = [NSString stringWithCString:name];
  free(name);
  return machine;
}

@end

extern "C" void glb_Device() {} ///this should be string - someone please correct