Mobile device orientation

I’m trying to port an old iOS game across to Urho3D to make it multi-platform.

One thing I need to hook into is the mobile device orientation. On iOS it’s ‘UIDeviceOrientation’ or ‘UIInterfaceOrientation’. Does Urho3D offer a way to hook in to events where these values change in a platform independent way?

Hey BananaIguana,

Welcome to the forums :slight_smile:

I’m not sure about cross-platform so it looks like it only supports iOS atm:

SetOrientations (const String &orientations)
Set allowed screen orientations as a space-separated list of "LandscapeLeft", "LandscapeRight", "Portrait" and "PortraitUpsideDown". Affects currently only iOS platform. 

Reference link: … ab796d09bb

For Android you would control the allowed orientations through the app manifest, I believe.

Getting the current orientation depends on whether SDL supports it. Haven’t looked into it myself. Typical hack way would be to detect whether current screen width is greater than height, but it doesn’t tell the difference between LandscapeLeft & LandscapeRight for instance.

Thanks for the info all.

I’ve had a good look into this now and it seems I can hack it quite easily. The downside is that I just have to specifics per-platform.

I’m loving Urho3D so far :wink:

void VideoChat::Setup()
    // Modify engine startup parameters
    engineParameters_[EP_SOUND] = true;
    engineParameters_[EP_ORIENTATIONS] = "Portrait";

it work on android