From http://www.jwz.org/xscreensaver/xscreensaver-5.16.tar.gz
[xscreensaver] / hacks / glx / crackberg.c
index 1c11d97fa90783c740b5b807b12cb9ff62ed0411..c4e925c73670fdcc389bce8954db781cad9f0004 100644 (file)
@@ -1,8 +1,10 @@
 /***************************
  ** crackberg; Matus Telgarsky [ catachresis@cmu.edu ] 2005 
  ** */
-#define XK_MISCELLANY
-#include <X11/keysymdef.h>
+#ifndef HAVE_COCOA
+# define XK_MISCELLANY
+# include <X11/keysymdef.h>
+#endif
 
 #define DEFAULTS    "*delay:        20000       \n" \
                     "*showFPS:      False       \n" \
@@ -20,7 +22,7 @@
 #define DEF_CRACK      "True"
 #define DEF_WATER      "True"
 #define DEF_FLAT       "True"
-#define DEF_COLOR      "plain"
+#define DEF_COLOR      "random"
 #define DEF_LIT        "True"
 #define DEF_VISIBILITY "0.6"
 #define DEF_LETTERBOX  "False"
@@ -1244,11 +1246,17 @@ ENTRYPOINT void reshape_crackberg (ModeInfo *mi, int w, int h)
 ENTRYPOINT Bool crackberg_handle_event (ModeInfo *mi, XEvent *ev)
 {
     cberg_state *cberg = &cbergs[MI_SCREEN(mi)];
+    KeySym keysym = 0;
+    char c = 0;
+    if (ev->xany.type == KeyPress || ev->xany.type == KeyRelease)
+      XLookupString (&ev->xkey, &c, 1, &keysym, 0);
 
     if (ev->xany.type == KeyPress) {
-        switch (XKeycodeToKeysym(mi->dpy, ev->xkey.keycode, 0)) {
+        switch (keysym) {
             case XK_Left:   cberg->motion_state |= MOTION_LROT;  break;
             case XK_Right:  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; 
             case '2':       cberg->motion_state |= MOTION_INC;   break;
             case 'a':       cberg->motion_state |= MOTION_LEFT;  break;
@@ -1272,9 +1280,11 @@ ENTRYPOINT Bool crackberg_handle_event (ModeInfo *mi, XEvent *ev)
         }
 #endif
 
-        switch (XKeycodeToKeysym(mi->dpy, ev->xkey.keycode, 0)) {
+        switch (keysym) {
             case XK_Left:   cberg->motion_state &= ~MOTION_LROT;  break;
             case XK_Right:  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; 
             case '2':       cberg->motion_state &= ~MOTION_INC;   break;
             case 'a':       cberg->motion_state &= ~MOTION_LEFT;  break;
@@ -1367,6 +1377,7 @@ ENTRYPOINT void draw_crackberg (ModeInfo *mi)
         
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
     glLoadIdentity();
+    glRotatef(current_device_rotation(), 0, 0, 1);
     gluLookAt(0,0,0, 1,0,0, 0,0,1);
     glLightfv(GL_LIGHT0, GL_POSITION, lpos);
     /*glRotated(cberg->roll, 1,0,0); / * XXX blah broken and unused for now..* /