author | Wuzzy <Wuzzy2@mail.ru> |
Thu, 10 Oct 2019 00:40:39 +0200 | |
changeset 15463 | 19e987301674 |
parent 14814 | c2793ff4e887 |
permissions | -rw-r--r-- |
14814
c2793ff4e887
Fix camera jumping around in touchscreen mode
Wuzzy <Wuzzy2@mail.ru>
parents:
14813
diff
changeset
|
1 |
{$INCLUDE "options.inc"} |
c2793ff4e887
Fix camera jumping around in touchscreen mode
Wuzzy <Wuzzy2@mail.ru>
parents:
14813
diff
changeset
|
2 |
|
5191
c7000a6b397b
- Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff
changeset
|
3 |
unit uCursor; |
c7000a6b397b
- Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff
changeset
|
4 |
|
c7000a6b397b
- Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff
changeset
|
5 |
interface |
c7000a6b397b
- Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff
changeset
|
6 |
|
c7000a6b397b
- Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff
changeset
|
7 |
procedure init; |
8225 | 8 |
procedure resetPosition; |
14813 | 9 |
procedure resetPositionDelta(); |
10 |
procedure updatePositionDelta(xrel, yrel: LongInt); |
|
11 |
procedure updatePosition(); |
|
8346 | 12 |
procedure handlePositionUpdate(x, y: LongInt); |
5191
c7000a6b397b
- Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff
changeset
|
13 |
|
c7000a6b397b
- Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff
changeset
|
14 |
implementation |
c7000a6b397b
- Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff
changeset
|
15 |
|
13499
424944a835a7
Fix cursor teleporting to center after leaving game with video recording
Wuzzy <Wuzzy2@mail.ru>
parents:
12836
diff
changeset
|
16 |
uses SDLh, uVariables, uTypes; |
5191
c7000a6b397b
- Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff
changeset
|
17 |
|
c7000a6b397b
- Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff
changeset
|
18 |
procedure init; |
c7000a6b397b
- Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff
changeset
|
19 |
begin |
14813 | 20 |
SDL_ShowCursor(SDL_DISABLE); |
8225 | 21 |
resetPosition(); |
14814
c2793ff4e887
Fix camera jumping around in touchscreen mode
Wuzzy <Wuzzy2@mail.ru>
parents:
14813
diff
changeset
|
22 |
{$IFNDEF USE_TOUCH_INTERFACE} |
14813 | 23 |
SDL_SetRelativeMouseMode(SDL_TRUE); |
14814
c2793ff4e887
Fix camera jumping around in touchscreen mode
Wuzzy <Wuzzy2@mail.ru>
parents:
14813
diff
changeset
|
24 |
{$ENDIF} |
8225 | 25 |
end; |
26 |
||
27 |
procedure resetPosition; |
|
28 |
begin |
|
13499
424944a835a7
Fix cursor teleporting to center after leaving game with video recording
Wuzzy <Wuzzy2@mail.ru>
parents:
12836
diff
changeset
|
29 |
if GameType = gmtRecord then |
424944a835a7
Fix cursor teleporting to center after leaving game with video recording
Wuzzy <Wuzzy2@mail.ru>
parents:
12836
diff
changeset
|
30 |
exit; |
5191
c7000a6b397b
- Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff
changeset
|
31 |
SDL_WarpMouse(cScreenWidth div 2, cScreenHeight div 2); |
14813 | 32 |
resetPositionDelta(); |
33 |
end; |
|
34 |
||
35 |
procedure resetPositionDelta(); |
|
36 |
begin |
|
37 |
CursorPointDelta.X:= 0; |
|
38 |
CursorPointDelta.Y:= 0; |
|
5191
c7000a6b397b
- Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff
changeset
|
39 |
end; |
c7000a6b397b
- Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff
changeset
|
40 |
|
14813 | 41 |
procedure updatePositionDelta(xrel, yrel: LongInt); |
5191
c7000a6b397b
- Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff
changeset
|
42 |
begin |
14813 | 43 |
CursorPointDelta.X:= CursorPointDelta.X + xrel; |
44 |
CursorPointDelta.Y:= CursorPointDelta.Y + yrel; |
|
45 |
end; |
|
10017 | 46 |
|
14813 | 47 |
procedure updatePosition(); |
48 |
begin |
|
49 |
handlePositionUpdate(CursorPointDelta.X, CursorPointDelta.Y); |
|
50 |
resetPositionDelta(); |
|
5191
c7000a6b397b
- Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff
changeset
|
51 |
end; |
c7000a6b397b
- Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff
changeset
|
52 |
|
8346 | 53 |
procedure handlePositionUpdate(x, y: LongInt); |
54 |
begin |
|
55 |
CursorPoint.X:= CursorPoint.X + x; |
|
56 |
CursorPoint.Y:= CursorPoint.Y - y; |
|
5191
c7000a6b397b
- Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff
changeset
|
57 |
end; |
c7000a6b397b
- Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff
changeset
|
58 |
|
c7000a6b397b
- Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff
changeset
|
59 |
end. |