Index: mouse.c
===================================================================
--- mouse.c	(revision 868)
+++ mouse.c	(revision 869)
@@ -9,7 +9,7 @@
 #include "index.h"
 #else
 #include "headers/mouse.h"
-#endif 
+#endif
 
 /*
 #define raydium_mouse_hide() glutSetCursor(GLUT_CURSOR_NONE);
@@ -54,7 +54,7 @@
 if(but==GLUT_LEFT_BUTTON) n=0;
 else if(but==GLUT_RIGHT_BUTTON) n=1;
 else if(but==GLUT_MIDDLE_BUTTON) n=2;
-else 
+else
     {
     special=1;
     n=but;
@@ -78,3 +78,41 @@
 {
 return raydium_mouse_button[button];
 }
+
+void raydium_mouse_grab_delta(int *x, int *y)
+{
+static int prev_state=0;
+static GLint   old_x;
+static GLint   old_y;
+GLint border;
+
+border = raydium_math_max(raydium_window_tx,raydium_window_ty) / 4;
+
+if(prev_state==0)
+{
+	*x = 0;
+	*y = 0;
+}
+else
+{
+	*x = raydium_mouse_x - old_x;
+	*y = raydium_mouse_y - old_y;
+	old_x = raydium_mouse_x;
+	old_y = raydium_mouse_y;
+}
+
+
+//putting the mouse in the middle of the screen, then read the next data of the mouse correctly
+// xf: small update, we now only move the mouse when it's needed, allow
+// a smoother handling of odd screen resolutions
+if(raydium_mouse_x < border || raydium_mouse_x > raydium_window_tx-border ||
+   raydium_mouse_y < border || raydium_mouse_y > raydium_window_ty-border ||
+   prev_state==0)
+	{
+	old_x=raydium_window_tx/2.0f;
+	old_y=raydium_window_ty/2.0f;
+	raydium_mouse_move(old_x, old_y);
+	}
+prev_state=1;
+
+}