Detecting device 180 degree rotation, from landscape left to landscape right

I’m trying to detect a 180 degree iOS rotation from landscape left to landscape right but the resized method is not called in this case (I guess that it’s due to the fact that width and height values aren’t changed after the rotation). Is there any way to detect such a rotation?

Desktop::getCurrentOrientation() will give the most currently known orientation.

JUCE doesn’t appear to provide the notifications for when the orientation changes though.

Audioshare functionality for iOS apps wire in Apple’s rotation handlers yourself

Thanks for the replies. At the end I have modified Juce’s ComponentPeer::handleMovedOrResized() method.

but now you have to maintain your own fork…

Indeed, but from my own experience working with JUCE, it’s usual to have to change a few things here and there in the JUCE library code . Eventually this will get addressed by JUCE developers. I have changed the JUCE method because I needed this feature for Android too (maintenance of native code for different platforms is always a pain in the long term).

That’s a solid point and should be a good motivator to make a feature request! Hopefully your change(s) are only going to be temporary. :slight_smile:

JUCE can definitely be extended to support detecting orientation changes, an action that’s not uncanny to do on mobile apps.

Juce supports orientation changes on mobile apps. The resized() method is called when there is a rotation… except in the case of a 180 degree rotation.

which is why i recommended the approach i did earlier. no forking required.

I think that’s justification enough to warrant requesting its own notification. This way you can get consistent and intuitive results.

1 Like

So did you found a solution for that problem? I have the same issue …

I don’t know if this has been fixed on JUCE library lately. I don’t remember the details but what I did was to modify Juce’s ComponentPeer::handleMovedOrResized() and implemented a couple of classes natively (one for ios and another one for android) to handle the gyroscope needed messages for this. It is not really difficult because you can find a lot of examples in native code for using the gyroscopes for those platforms. Sadly I can not share my code because it was a work for a company.

1 Like

Thanks for the quick answer.
I think I will create a general Apple (iOS) helper class, where I deal with missing things like device rotation, that are not already covered by JUCE