What System is in Use?

Hi all,
Could anyone out there tell me how I can interrogate the OS to find out what system is in use - is it a phone, iPod, iTouch or iPad. Also which version. I’d like to get a general routine up so that I can improve compatibility of any code across the user base - good example is the screen width and height ( I know you can find these from WIDTH and HEIGHT) - which may impose limitations on the package I produce. OS would also be useful as it could dictate what facilities are available.
Ta
Bri_G

We can probably expose a hardware device string that you can use to determine hardware version (e.g. “iPhone,3,1”).

Apple generally recommends against checking for specific devices when creating apps, and I’d have to make the same suggestion with Codea projects. You can cope with differing speeds by using DeltaTime to modulate your motion – the physics engine is already independent of device speed.

I don’t see any harm in making device information available. Could you add it as a feature request to the issue tracker? http://bitbucket.org/TwoLivesLeft/codea/issues

Hi Simeon,
Added to issues as requested, I don’t see why apple should be concerned about this issue - it gives us the ability to detect and tailor software applications to the hardware and OS involved. Smacks of not letting anyone dig up our treasures!!!
Ta
Bri_G

Apple is concerned because exposing device ID (rather than things like resolution and such) leads directly to lazy programmers saying “Rather than fix my performance issues, I’ll just check to make sure it’s an iPad2 and die if it’s not”. You won’t do that, of course, and I won’t - but others will.

Other than width/height and speed differences that you can figure out with DeltaTime - what else would you need the device ID for? (Camera use isn’t supported yet, and the compass isn’t exposed…)

Hi Bortels,
Don’t need the device ID, just need the type. Especially iPad vs iPad2. For some program aspects I’d like to determine options in an initialisation routine before running the main program.
Bri_G

There was some code someone made that tested the iPad by its speed, I’ll find it later.

@Bri_G yeah device ID is not a problem. I just meant what @Bortels said: it’s better to rely on indirect device characteristics (such as checking the framerate or whether a function is available) rather than directly querying the device.

Hi Guys,

Thanks for the input folks. I’ll keep an eye on this thread - any routines that help here would be appreciated, or links to them.
Thanks.
Bri_G

Here it is. Here is the link.

Hi Zoyt,

Thanks for the link - scanned through the code, may be able to use that so I’m going to play with it. Just thought of a problem - I don’t have an iPad 1 to compare it to !!!
Also will this vary with the different versions of the iPad - with or without 3G? (enabled or not). Same with blue tooth - how does the iPad configuration affect the perceived speed of the system?
Thanks
Bri_G

I’ve added a deviceMetrics() function that will be available in the next version. It returns a table of device characteristics.

Edit: I’d also recommend not using it, but that will be up to you :slight_smile:

Hi Simeon,

That’s what I call service - looking forward to the next release, but still plenty to play with and learn in the present version.
Thanks
Bri_G

To expand a bit - if you check device and adjust, the code will work on the ipad and ipad2.

If you measure timing, your code will work on the ipad, ipad2, ipad3, and presumably all other compatible devices, without you having to modify things.

That’s what’s meant by “you’re better off not checking the device type”.

True Story: I was pleasantly surprised when, during beta, I found that the portrait-mode sidebar still had all the graphics centered the way I like it - then I realized it didn’t, I was just doing my math off of WIDTH/HEIGHT and it just worked. If I had checked the device type and made assumptions based on that, my code would have broken.

Hi Bortels,

There goes the serendipity again - I usually find that when I program badly (most of the time that is !!!).

Bri_G