Author Topic: Auto rotate desktop when monitor is rotated  (Read 5078 times)

Grezzo

  • Newbie
  • *
  • Posts: 4
Auto rotate desktop when monitor is rotated
« on: December 13, 2015, 02:41:37 am »
This is my first digispark project. I love how small this thing is, and that I can be a USB keyboard!

I can't find where to buy one in the UK (everywhere is out of stock), so I had to get a clone from eBay. I would rather support the people who designed it by buying an authentic version, but that didn't seem to be possible.

Anyway...

I put a tilt switch on my digispark and plug it into my monitor (it has a USB hub built-in). Now when I rotate my monitor, the digispark sends the hotkeys (I have Windows with Intel graphics, but I also made it work on my MacBook) to rotate the desktop so that the picture is always the right way around.

Code and simple explanation is here: https://gist.github.com/Grezzo/148d25de66fe82916d90

Any ideas for improvements are welcome.

smartynov

  • Newbie
  • *
  • Posts: 7
Re: Auto rotate desktop when monitor is rotated
« Reply #1 on: December 20, 2015, 05:18:27 pm »
Great idea! What key codes do you use to rotate a screen on mac? Maybe you can #define a constant and use #ifdef to make the code useful for both windows and mac.