From http://www.jwz.org/xscreensaver/xscreensaver-5.35.tar.gz
[xscreensaver] / hacks / glx / crackberg.c
index 2d8acbd47db7afad3a7e1281ec90d37d380d8949..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
@@ -1211,7 +1211,9 @@ ENTRYPOINT void init_crackberg (ModeInfo *mi)
     glEnable(GL_BLEND);
     glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
     glShadeModel((flat) ? GL_FLAT : GL_SMOOTH);
+# ifndef HAVE_JWZGLES /* #### glPolygonMode other than GL_FILL unimplemented */
     glPolygonMode(GL_FRONT_AND_BACK, (MI_IS_WIREFRAME(mi)) ? GL_LINE : GL_FILL);
+# endif
 
     if (lit) {
         glEnable(GL_LIGHTING);
@@ -1258,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; 
@@ -1286,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; 
@@ -1329,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;