hedgewars/uCursor.pas
branchwebgl
changeset 8026 4a4f21070479
parent 6580 6155187bf599
child 8330 aaefa587e277
--- a/hedgewars/uCursor.pas	Sun Nov 11 16:53:16 2012 +0100
+++ b/hedgewars/uCursor.pas	Sun Nov 11 17:15:19 2012 +0100
@@ -9,6 +9,10 @@
 
 uses SDLh, uVariables;
 
+{$IFDEF WEBGL}
+var offsetx, offsety : Integer;
+{$ENDIF}
+
 procedure init;
 begin
     SDL_WarpMouse(cScreenWidth div 2, cScreenHeight div 2);
@@ -16,16 +20,33 @@
 
 procedure updatePosition;
 var x, y: LongInt;
+{$IFDEF WEBGL}
+    tx, ty : LongInt;
+{$ENDIF}
 begin
     SDL_GetMouseState(@x, @y);
 
+{$IFDEF WEBGL}
+    tx := x;
+    ty := y;
+    x := x + offsetx;
+    y := y + offsety;
+{$ENDIF}
+
     if(x <> cScreenWidth div 2) or (y <> cScreenHeight div 2) then
         begin
         CursorPoint.X:= CursorPoint.X + x - cScreenWidth div 2;
         CursorPoint.Y:= CursorPoint.Y - y + cScreenHeight div 2;
 
         if cHasFocus then
+            begin
+            {$IFNDEF WEBGL}
             SDL_WarpMouse(cScreenWidth div 2, cScreenHeight div 2);
+            {$ELSE}
+            offsetx := cScreenWidth div 2 - tx;
+            offsety := cScreenHeight div 2 - ty;
+            {$ENDIF}
+            end;
         end
 end;