As I peeked into the code of OpenMoko’s Rotate (a program that rotates the screen acording to the current tilt), I noticed it made use of system to launch the xrandr program with appropriate arguments.
Well, system costs a lot in terms of processing power, not to mention launching another program, and that means even less battery time. I didn’t like that, so I wrote a patch that alters the current rotate.c into a new rotate.c in order to use librandr and get it to rotate the screen without the costly system+xrandr duo from hell.
I also built a binary of rotate, which you can download from this link and place on your OpenMoko Neo Freerunner with 2008.8 or 2008.9 (I haven’t the foggiest idea if it works on other versions).
Hopefully, you might want to verify the sha1sums:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 afc833b7cd2c874c1c815a0cb9f7c38a65998ff5 rotate efcc6277080b2aadc3306a000a97ab202ca2bece rotate.c c1eb847d05cd36e0e9f31b5e5f6eb9337f730d0f rotate_libxrandr.patch -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFI1ES1o+C50no0+t4RAjSrAJ41N0KpD7JaY3WfiRViexn4CvQw7QCePNr3 G8Z3ejIwprpK7J7unjMaS1A= =anNm -----END PGP SIGNATURE-----
I realise the way I wrote didn’t make it very obvious, so here’s a listing of the files:
You should also pubish the code. GPL π
Sorry I didn’t see that “rotate.c” is a link.
Hi,
Some comments with regards to code:
– since you use read(2), use open(2) instead of fopen().
– just putenv() display if none is set.
– you are re-creating display every time, leaking the connection. open it at main() instead.
– do not sleep()! That’s bad, it will make your code misbehave, since if you sleep, you do not read the new values, you’ll do that just after the sleep is done, so you’re reading values 2-3 seconds older! You should, instead, remember the time of the read and if you have to really rotate, you use select/poll with a timeout and you can use the timeout as a threshold (“I just rotated ${X}ms ago, let’s wait a bit”). With that schema, you can give a change to user to rotate and “cancel”, by rotating back within the threshold.
Hi, are you hacking my computer? π
I’m just preparing a “written from scratch” release which includes many of your good points, there π
Hi Rui!
Just want to say thx, great application – has been on my wishlist! Now we have it… π
Regarding your un-present foggy ideas:
[snip]
debian-gta02:~/rotate-0.2.1$ ./test
Can’t open ‘/dev/input/event3’: Permission denied
debian-gta02:~/rotate-0.2.1$ sudo ./test
Types: a(2), b(2), c(2)
Codes: a(0), b(1), c(2)
Value: a(72), b(-828), c(90)
vertical straight
[/snip]
Here you can see 2 things:
*it runs on debian with Xglamo (happy me)!
*it does not work called as a regular user (unless one does some playing with groups&chown..)
I played around playing duke3d with rotate running and found out, that somehow killed your app. (btw…there isn’t any debug switch, is there?)
My suggestion is, rotate could listen to some signal to enter a sort of “sleep mode”, so applications that need to contol screen orientation can do that without interference. (while rotate could be started as damon)
cheers & happy birthday dinners,
radl
@radl: yes, I don’t suppose it will be able to run as a regular user unless it’s suid root, since /dev/input/event3 is unreadable to you.
As for the “sleep” mode, I’m hoping to add a turn off/turn on/sleep option somewhere, but all this instability is why version is not 1 but 0.x π