Index: mania2.c
===================================================================
--- mania2.c	(revision 151)
+++ mania2.c	(revision 152)
@@ -226,6 +226,9 @@
 	raydium_vertex_texture_u[raydium_vertex_index]=raydium_vertex_texture_u[j];
 	raydium_vertex_texture_v[raydium_vertex_index]=raydium_vertex_texture_v[j];
 	raydium_vertex_texture[raydium_vertex_index]=raydium_vertex_texture[j];
+	raydium_vertex_texture_multi[raydium_vertex_index]=raydium_vertex_texture_multi[j];
+	raydium_vertex_texture_multi_u[raydium_vertex_index]=raydium_vertex_texture_multi_u[j];
+	raydium_vertex_texture_multi_v[raydium_vertex_index]=raydium_vertex_texture_multi_v[j];
 	raydium_vertex_index++;
 	}
     rotatez(-grid[i].rot,grid[i].obj);
texture_filter_change(RAYDIUM_TEXTURE_FILTER_TRILINEAR);
 raydium_projection_near=0.01;
 raydium_projection_far=1000;	
5,10 @@
 
       case KeyRelease      :
         updown = GLUT_UP ;
-
-        XQueryKeymap ( currDisplay, keyflags ) ;
-
-        repeating = ( ( keyflags [ event.xkey.keycode >> 3 ] &
-                          ( 1 << ( event.xkey.keycode & 7 ) ) ) != 0 ) ;
-
         // FALLTHROUGH 
 
       case KeyPress        :
-        
-        //  Only generate a key up callback if the key is actually up
-        //  and not repeating.
 
-//        if ( ! autoRepeat && repeating )
-    //      break ;
-
-
         len = XLookupString( &event.xkey, asciiCode, sizeof(asciiCode),
                                  &keySym, &composeStatus ) ;
         result = -1 ;
@@ -627,12 +603,27 @@
 
 	if(result!=-1)
 	    {
+	    // check autorepeat with current KeyRelease and next event
+	    if (special && XEventsQueued(currDisplay, QueuedAfterReading))
+	    {
+	    XEvent ahead;
+	    XPeekEvent(currDisplay, &ahead);
+	    if (ahead.type == KeyPress && event.type == KeyRelease
+	        && ahead.xkey.window == event.xkey.window
+	        && ahead.xkey.keycode == event.xkey.keycode
+	        && ahead.xkey.time == event.xkey.time) 
+		{
+		// repeating key. Discard event.
+		break;
+		}
+	    }
+
 	    // special down
-	    if(special && updown==GLUT_DOWN && glutSpecialFuncCB && !repeating)
+	    if(special && updown==GLUT_DOWN && glutSpecialFuncCB && !raydium_key[result])
 		glutSpecialFuncCB(result,event.xkey.x, event.xkey.y);
 
 	    // special up
-	    if(special && updown==GLUT_UP && glutSpecialUpFuncCB && !repeating)
+	    if(special && updown==GLUT_UP && glutSpecialUpFuncCB && raydium_key[result])
 		glutSpecialUpFuncCB(result,event.xkey.x, event.xkey.y);
 
 	    // normal