hedgewars/uCursor.pas
branchwebgl
changeset 8026 4a4f21070479
parent 6580 6155187bf599
child 8330 aaefa587e277
equal deleted inserted replaced
8023:7de85783b823 8026:4a4f21070479
     7 
     7 
     8 implementation
     8 implementation
     9 
     9 
    10 uses SDLh, uVariables;
    10 uses SDLh, uVariables;
    11 
    11 
       
    12 {$IFDEF WEBGL}
       
    13 var offsetx, offsety : Integer;
       
    14 {$ENDIF}
       
    15 
    12 procedure init;
    16 procedure init;
    13 begin
    17 begin
    14     SDL_WarpMouse(cScreenWidth div 2, cScreenHeight div 2);
    18     SDL_WarpMouse(cScreenWidth div 2, cScreenHeight div 2);
    15 end;
    19 end;
    16 
    20 
    17 procedure updatePosition;
    21 procedure updatePosition;
    18 var x, y: LongInt;
    22 var x, y: LongInt;
       
    23 {$IFDEF WEBGL}
       
    24     tx, ty : LongInt;
       
    25 {$ENDIF}
    19 begin
    26 begin
    20     SDL_GetMouseState(@x, @y);
    27     SDL_GetMouseState(@x, @y);
       
    28 
       
    29 {$IFDEF WEBGL}
       
    30     tx := x;
       
    31     ty := y;
       
    32     x := x + offsetx;
       
    33     y := y + offsety;
       
    34 {$ENDIF}
    21 
    35 
    22     if(x <> cScreenWidth div 2) or (y <> cScreenHeight div 2) then
    36     if(x <> cScreenWidth div 2) or (y <> cScreenHeight div 2) then
    23         begin
    37         begin
    24         CursorPoint.X:= CursorPoint.X + x - cScreenWidth div 2;
    38         CursorPoint.X:= CursorPoint.X + x - cScreenWidth div 2;
    25         CursorPoint.Y:= CursorPoint.Y - y + cScreenHeight div 2;
    39         CursorPoint.Y:= CursorPoint.Y - y + cScreenHeight div 2;
    26 
    40 
    27         if cHasFocus then
    41         if cHasFocus then
       
    42             begin
       
    43             {$IFNDEF WEBGL}
    28             SDL_WarpMouse(cScreenWidth div 2, cScreenHeight div 2);
    44             SDL_WarpMouse(cScreenWidth div 2, cScreenHeight div 2);
       
    45             {$ELSE}
       
    46             offsetx := cScreenWidth div 2 - tx;
       
    47             offsety := cScreenHeight div 2 - ty;
       
    48             {$ENDIF}
       
    49             end;
    29         end
    50         end
    30 end;
    51 end;
    31 
    52 
    32 end.
    53 end.