From http://www.jwz.org/xscreensaver/xscreensaver-5.35.tar.gz
[xscreensaver] / hacks / glx / crackberg.c
index 6e4b7b493691f2ea6013ac5be308d1c6b70a5724..30af9633440d6e6f27c2c4cfa885583a6db5ad26 100644 (file)
@@ -1,7 +1,7 @@
 /***************************
  ** crackberg; Matus Telgarsky [ catachresis@cmu.edu ] 2005 
  ** */
-#ifndef HAVE_COCOA
+#ifndef HAVE_JWXYZ
 # define XK_MISCELLANY
 # include <X11/keysymdef.h>
 #endif
@@ -1260,7 +1260,9 @@ ENTRYPOINT Bool crackberg_handle_event (ModeInfo *mi, XEvent *ev)
     if (ev->xany.type == KeyPress) {
         switch (keysym) {
             case XK_Left:   cberg->motion_state |= MOTION_LROT;  break;
+            case XK_Prior:  cberg->motion_state |= MOTION_LROT;  break;
             case XK_Right:  cberg->motion_state |= MOTION_RROT;  break;
+            case XK_Next:   cberg->motion_state |= MOTION_RROT;  break;
             case XK_Down:   cberg->motion_state |= MOTION_BACK;  break;
             case XK_Up:     cberg->motion_state |= MOTION_FORW;  break;
             case '1':       cberg->motion_state |= MOTION_DEC;   break; 
@@ -1288,7 +1290,9 @@ ENTRYPOINT Bool crackberg_handle_event (ModeInfo *mi, XEvent *ev)
 
         switch (keysym) {
             case XK_Left:   cberg->motion_state &= ~MOTION_LROT;  break;
+            case XK_Prior:  cberg->motion_state &= ~MOTION_LROT;  break;
             case XK_Right:  cberg->motion_state &= ~MOTION_RROT;  break;
+            case XK_Next:   cberg->motion_state &= ~MOTION_RROT;  break;
             case XK_Down:   cberg->motion_state &= ~MOTION_BACK;  break;
             case XK_Up:     cberg->motion_state &= ~MOTION_FORW;  break;
             case '1':       cberg->motion_state &= ~MOTION_DEC;   break; 
@@ -1331,6 +1335,19 @@ ENTRYPOINT Bool crackberg_handle_event (ModeInfo *mi, XEvent *ev)
       if (dy > 0 && dy > dx) dx = 0;
       if (dy < 0 && dy < dx) dx = 0;
 
+      {
+        int rot = current_device_rotation();
+        int swap;
+        while (rot <= -180) rot += 360;
+        while (rot >   180) rot -= 360;
+        if (rot > 135 || rot < -135)           /* 180 */
+            dx = -dx, dy = -dy;
+        else if (rot > 45)                     /* 90 */
+          swap = dx, dx = -dy, dy = swap;
+        else if (rot < -45)                    /* 270 */
+          swap = dx, dx = dy, dy = -swap;
+      }
+
       if      (dx > 0) cberg->motion_state |= MOTION_LEFT;
       else if (dx < 0) cberg->motion_state |= MOTION_RIGHT;
       else if (dy > 0) cberg->motion_state |= MOTION_FORW;