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