The problem is that I can't know if the screen has been turned 90º, -90º or 180º.

I came unto this problem testing fullscreen mode on my portrait-oriented monitor, and finding out that all the input (mouse) is rotated. Knowing the angle is necessary thus to filter the input correctly.

From what I've seeing googling around, mobile platforms like Android have an actual .getRotation() method. How can I check this on standard Java?

You can't. Most peoples desktops don't rotate. Hardware like the accelerometer and tilt sensor are only ever going to be exposed in specialized kits like Android or J2ME, and frankly, not so much J2ME.

For Desktop you should never think that someone flips his monitor xD How should the monitor check this? You only need the code for Android and even there... just cap the view to portrait and landscape like so:

The monitor itself doesn't check it, but the display drivers do, as many Graphic cards give the option to rotate the display (not all, and not all the angles).

In my case I work with a rotated monitor, and happen to have a convertible laptop/tablet, so yeah, it might be of marginal interest, but since I'm building the screen management infrastructure for my project, I'd like to investigate possibilities now.

To the very least, having a rotation stub will help if I port the engine to Android or similar.

@CeroThose are all vertical shooters... Do you have any other examples? If not then you still have 98% of people playing games without rotating there monitors and without games that expect that. Or does... uhm... Deus Ex check if you flip you monitor and react to it?

OskuroIf you use libGDX you won't havem uch problems porting it to android anyway. And even there... I don't remember much games doing that. Most games a portrait or landscape and if I flip my device nothing happens :/Do you create are game where it is really necessary?

It's not a matter of actual application to a game, but rather curiosity, as the issue has come up while I was testing my screen manager code.

Still, this would be essential in mobile devices, I've experienced quite a few times games on tablets that do not rotate as I physically rotate the device, even though the API does offer the information (Since other games do rotate), and it's a bit obnoxious to have the user hold the device in an specific orientation, when the whole idea of a mobile device is ease of use.

But again, not concerned with what use I'd give to it. I just enjoy a lot solving programming problems

Portrait orientation on desktop (i.e. flipped monitors) is all the rave these days -- lots of people in my office have one or both of their monitors rotated. Good for programming, heavy reading, Reddit, etc.

The thing is that the API for rotation details isn't well defined. It depends heavily on the display drivers and how much information they rely to the system, if they have the rotation capability at all.

I actually had a fun time coding scripts for screen rotation in Ubuntu (It wouldn't auto-detect screen rotation on my combo laptop/tablet, so I do it manually), so this isn't exactly new... But I doubt there's an easy OS agnostic solution.

I kind of suspect that in future JDKs this might pop up. Ginourmous monitors that get rotated and graphics cards with easy rotation interfaces are increasingly common these days, hopefully these things will get standarized.

My thinking is: so what? I mean do you really want to interactively rotate your monitor? If not..put an option in your graphics configuration options screen and stick a fork in issue until someone solves the problem for you.

Ok, I don't want to be rude, but this is something I often see in programming threads when someone asks something, so let me rant for a moment....

I'm not pondering if I should do it, I'm pondering how to do it.

I appreciate the discussion about the relevance of the issue at hand, but when it has been said a couple times that I'm interested in attempting to solve this just for the sake of doing it, rather than for any practical purpose, it becomes extremely obnoxious to have people keep insisting about whether I should or shouldn't do it.

Well, I'm very unsure if screens have auto- rotate, except for the tablet devices.

However, there might be a temporary hack you can use in the meantime until a better solution can be found. The only information readily available continuously is the Java Toolkit screen size. You might be able to get away with it by comparing the Dimensions.

Client OS automatically handles everything for you. Nothing to see here. All you need to know is the width and height of the display. It is not a case of what you "should" do or "can" do, there is simply nothing to do.

Ok, I don't want to be rude, but this is something I often see in programming threads when someone asks something, so let me rant for a moment....

I'm not pondering if I should do it, I'm pondering how to do it.

I appreciate the discussion about the relevance of the issue at hand, but when it has been said a couple times that I'm interested in attempting to solve this just for the sake of doing it, rather than for any practical purpose, it becomes extremely obnoxious to have people keep insisting about whether I should or shouldn't do it.

Ok, rant over.

I qualified my statement with "My thinking is..". What I see alot in various programming forums is people insisting on wasting time on things that are pointless. The subsystem they're describing has no added value and won't provide any meaningful learning experience to the person in question. I'm not gonna beat people over the head, but I think it useful to point out that IHMO what they are attempt to do is a waste of time.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org