author | unc0rr |
Wed, 10 Jan 2018 23:49:47 +0100 | |
branch | qmlfrontend |
changeset 12895 | 9c259fb4d405 |
parent 12836 | 1fbc0d5a82d0 |
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; |
8346 | 7 |
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
|
8 |
|
12895
9c259fb4d405
Pass mouse movements to engine, warp cursor in frontend
unc0rr
parents:
12836
diff
changeset
|
9 |
function updateMousePosition(cx, cy, x, y: LongInt): boolean; cdecl; export; |
9c259fb4d405
Pass mouse movements to engine, warp cursor in frontend
unc0rr
parents:
12836
diff
changeset
|
10 |
|
5191
c7000a6b397b
- Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff
changeset
|
11 |
implementation |
c7000a6b397b
- Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff
changeset
|
12 |
|
12895
9c259fb4d405
Pass mouse movements to engine, warp cursor in frontend
unc0rr
parents:
12836
diff
changeset
|
13 |
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
|
14 |
|
c7000a6b397b
- Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff
changeset
|
15 |
procedure init; |
c7000a6b397b
- Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff
changeset
|
16 |
begin |
12895
9c259fb4d405
Pass mouse movements to engine, warp cursor in frontend
unc0rr
parents:
12836
diff
changeset
|
17 |
//resetPosition(); |
8225 | 18 |
end; |
19 |
||
20 |
procedure resetPosition; |
|
21 |
begin |
|
12836 | 22 |
// Move curser by 1px in case it's already centered. |
23 |
// The game camera in the Alpha for 0.9.23 screwed up if |
|
24 |
// the game started with the mouse already being centered. |
|
25 |
// This fixes it, but we might have overlooked a related |
|
26 |
// bug somewhere else. |
|
27 |
// No big deal since this function is (so far) only called once. |
|
12895
9c259fb4d405
Pass mouse movements to engine, warp cursor in frontend
unc0rr
parents:
12836
diff
changeset
|
28 |
//SDL_WarpMouse((cScreenWidth div 2) + 1, cScreenHeight div 2); |
9c259fb4d405
Pass mouse movements to engine, warp cursor in frontend
unc0rr
parents:
12836
diff
changeset
|
29 |
//SDL_WarpMouse(cScreenWidth div 2, cScreenHeight div 2); |
5191
c7000a6b397b
- Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff
changeset
|
30 |
end; |
c7000a6b397b
- Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff
changeset
|
31 |
|
12895
9c259fb4d405
Pass mouse movements to engine, warp cursor in frontend
unc0rr
parents:
12836
diff
changeset
|
32 |
function updateMousePosition(cx, cy, x, y: LongInt): boolean; cdecl; export; |
5191
c7000a6b397b
- Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff
changeset
|
33 |
begin |
12895
9c259fb4d405
Pass mouse movements to engine, warp cursor in frontend
unc0rr
parents:
12836
diff
changeset
|
34 |
if (GameState <> gsConfirm) |
9c259fb4d405
Pass mouse movements to engine, warp cursor in frontend
unc0rr
parents:
12836
diff
changeset
|
35 |
and (GameState <> gsSuspend) |
9c259fb4d405
Pass mouse movements to engine, warp cursor in frontend
unc0rr
parents:
12836
diff
changeset
|
36 |
and (GameState <> gsExit) |
9c259fb4d405
Pass mouse movements to engine, warp cursor in frontend
unc0rr
parents:
12836
diff
changeset
|
37 |
and (GameState <> gsLandgen) |
9c259fb4d405
Pass mouse movements to engine, warp cursor in frontend
unc0rr
parents:
12836
diff
changeset
|
38 |
and (GameState <> gsStart) |
9c259fb4d405
Pass mouse movements to engine, warp cursor in frontend
unc0rr
parents:
12836
diff
changeset
|
39 |
and cHasFocus |
9c259fb4d405
Pass mouse movements to engine, warp cursor in frontend
unc0rr
parents:
12836
diff
changeset
|
40 |
and (not (CurrentTeam^.ExtDriven and isCursorVisible and (not bShowAmmoMenu) and autoCameraOn)) |
9c259fb4d405
Pass mouse movements to engine, warp cursor in frontend
unc0rr
parents:
12836
diff
changeset
|
41 |
and ((x <> cx) or (y <> cy)) then |
9c259fb4d405
Pass mouse movements to engine, warp cursor in frontend
unc0rr
parents:
12836
diff
changeset
|
42 |
begin |
9c259fb4d405
Pass mouse movements to engine, warp cursor in frontend
unc0rr
parents:
12836
diff
changeset
|
43 |
handlePositionUpdate(x - cx, y - cy); |
10017 | 44 |
|
12895
9c259fb4d405
Pass mouse movements to engine, warp cursor in frontend
unc0rr
parents:
12836
diff
changeset
|
45 |
updateMousePosition:= true |
9c259fb4d405
Pass mouse movements to engine, warp cursor in frontend
unc0rr
parents:
12836
diff
changeset
|
46 |
end else |
9c259fb4d405
Pass mouse movements to engine, warp cursor in frontend
unc0rr
parents:
12836
diff
changeset
|
47 |
updateMousePosition:= false |
5191
c7000a6b397b
- Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff
changeset
|
48 |
end; |
c7000a6b397b
- Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff
changeset
|
49 |
|
8346 | 50 |
procedure handlePositionUpdate(x, y: LongInt); |
51 |
begin |
|
52 |
CursorPoint.X:= CursorPoint.X + x; |
|
53 |
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
|
54 |
end; |
c7000a6b397b
- Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff
changeset
|
55 |
|
c7000a6b397b
- Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff
changeset
|
56 |
end. |