author | alfadur |
Wed, 21 Sep 2022 06:36:05 +0300 | |
branch | 1.0.0 |
changeset 15895 | f8a3f204242d |
parent 14830 | c2793ff4e887 |
child 15908 | 014f4edd0421 |
permissions | -rw-r--r-- |
14830
c2793ff4e887
Fix camera jumping around in touchscreen mode
Wuzzy <Wuzzy2@mail.ru>
parents:
14829
diff
changeset
|
1 |
{$INCLUDE "options.inc"} |
c2793ff4e887
Fix camera jumping around in touchscreen mode
Wuzzy <Wuzzy2@mail.ru>
parents:
14829
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; |
14829 | 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 |
|
13498
424944a835a7
Fix cursor teleporting to center after leaving game with video recording
Wuzzy <Wuzzy2@mail.ru>
parents:
12831
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 |
14829 | 20 |
SDL_ShowCursor(SDL_DISABLE); |
8225 | 21 |
resetPosition(); |
14830
c2793ff4e887
Fix camera jumping around in touchscreen mode
Wuzzy <Wuzzy2@mail.ru>
parents:
14829
diff
changeset
|
22 |
{$IFNDEF USE_TOUCH_INTERFACE} |
14829 | 23 |
SDL_SetRelativeMouseMode(SDL_TRUE); |
14830
c2793ff4e887
Fix camera jumping around in touchscreen mode
Wuzzy <Wuzzy2@mail.ru>
parents:
14829
diff
changeset
|
24 |
{$ENDIF} |
8225 | 25 |
end; |
26 |
||
27 |
procedure resetPosition; |
|
28 |
begin |
|
13498
424944a835a7
Fix cursor teleporting to center after leaving game with video recording
Wuzzy <Wuzzy2@mail.ru>
parents:
12831
diff
changeset
|
29 |
if GameType = gmtRecord then |
424944a835a7
Fix cursor teleporting to center after leaving game with video recording
Wuzzy <Wuzzy2@mail.ru>
parents:
12831
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); |
14829 | 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 |
|
14829 | 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 |
14829 | 43 |
CursorPointDelta.X:= CursorPointDelta.X + xrel; |
44 |
CursorPointDelta.Y:= CursorPointDelta.Y + yrel; |
|
45 |
end; |
|
10017 | 46 |
|
14829 | 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. |