Marmalade SDK Bitesize Tutorial – How to Determine Device Operating System

Just though that I would sneak this quick bite sized tutorial in whilst taking a breather from documenting IwGame. Tell you something, I never realised just what a big beast IwGame has become.

Ok, I’m going to quickly cover how to determine which device operating system we are running on using the Marmalade SDK.

The Marmalade SDK has two neat little functions called s3eDeviceGetInt(s3eDeviceProperty property) and s3eDeviceGetString(s3eDeviceProperty property) which allow us to query details about the device that we are running our apps on. As the names suggest, one returns an integer value, whilst the other returns a human readable string value.

Using the property parameter you can query all sorts of things such as:

  • Device operating system (S3E_DEVICE_OS)
  • Device phone number (S3E_DEVICE_PHONE_NUMBER)
  • Device language (S3E_DEVICE_LANGUAGE)
  • Battery level (S3E_DEVICE_BATTERY_LEVEL)
  • Operating system version (S3E_DEVICE_OS_VERSION)
  • Floating point unit support (S3E_DEVICE_FPU)
  • Language- country code pair, e.g. en-us (S3E_DEVICE_LOCALE)

And all sorts of other useful info. Check 3seDevice.h for a comprehensive list of all properties that you can retrieve.

To find out which operating system you are running on you call:

int os = s3eDeviceGetInt(S3E_DEVICE_OS);

You can then test for which OS is running using a simple switch statement like this:

switch (os) { case S3E_OS_ID_SYMBIAN: break; case S3E_OS_ID_WINMOBILE: break; case S3E_OS_ID_WINCE: break; case S3E_OS_ID_QNX: break; case S3E_OS_ID_BADA: break; case S3E_OS_ID_ANDROID: break; case S3E_OS_ID_IPHONE: break; case S3E_OS_ID_WEBOS: break; case S3E_OS_ID_WINDOWS: break; case S3E_OS_ID_LINUX: break; case S3E_OS_ID_OSX: break; }

Leave a Reply