author | unc0rr |
Fri, 05 Jan 2018 22:32:11 +0100 | |
branch | qmlfrontend |
changeset 12885 | 590c7f324292 |
parent 11848 | 01f88c3b7b66 |
permissions | -rw-r--r-- |
10951
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff
changeset
|
1 |
unit uFLUICallback; |
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff
changeset
|
2 |
interface |
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff
changeset
|
3 |
uses uFLTypes; |
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff
changeset
|
4 |
|
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff
changeset
|
5 |
procedure registerUIMessagesCallback(p: pointer; f: TUICallback); cdecl; |
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff
changeset
|
6 |
procedure sendUI(msgType: TMessageType; msg: PChar; len: Longword); |
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff
changeset
|
7 |
|
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff
changeset
|
8 |
implementation |
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff
changeset
|
9 |
uses uFLIPC; |
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff
changeset
|
10 |
|
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff
changeset
|
11 |
var uiCallbackPointer: pointer; |
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff
changeset
|
12 |
uiCallbackFunction: TUICallback; |
11832
8c71c5a1172f
- Add state to engine callback for it to know what engine is sending
unc0rr
parents:
10951
diff
changeset
|
13 |
isGame: boolean; |
10951
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff
changeset
|
14 |
|
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff
changeset
|
15 |
procedure engineMessageCallback(p: pointer; msg: PChar; len: Longword); |
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff
changeset
|
16 |
begin |
11848 | 17 |
if (len >= 3) and (msg[1] = 'T') then |
11832
8c71c5a1172f
- Add state to engine callback for it to know what engine is sending
unc0rr
parents:
10951
diff
changeset
|
18 |
begin |
11848 | 19 |
isGame:= msg[2] = 'G'; |
11832
8c71c5a1172f
- Add state to engine callback for it to know what engine is sending
unc0rr
parents:
10951
diff
changeset
|
20 |
exit; |
8c71c5a1172f
- Add state to engine callback for it to know what engine is sending
unc0rr
parents:
10951
diff
changeset
|
21 |
end; |
8c71c5a1172f
- Add state to engine callback for it to know what engine is sending
unc0rr
parents:
10951
diff
changeset
|
22 |
|
8c71c5a1172f
- Add state to engine callback for it to know what engine is sending
unc0rr
parents:
10951
diff
changeset
|
23 |
if isGame then |
8c71c5a1172f
- Add state to engine callback for it to know what engine is sending
unc0rr
parents:
10951
diff
changeset
|
24 |
begin |
11847 | 25 |
uiCallbackFunction(uiCallbackPointer, mtToNet, msg, len) |
11832
8c71c5a1172f
- Add state to engine callback for it to know what engine is sending
unc0rr
parents:
10951
diff
changeset
|
26 |
end |
8c71c5a1172f
- Add state to engine callback for it to know what engine is sending
unc0rr
parents:
10951
diff
changeset
|
27 |
else begin |
8c71c5a1172f
- Add state to engine callback for it to know what engine is sending
unc0rr
parents:
10951
diff
changeset
|
28 |
if len = 128 * 256 then |
8c71c5a1172f
- Add state to engine callback for it to know what engine is sending
unc0rr
parents:
10951
diff
changeset
|
29 |
uiCallbackFunction(uiCallbackPointer, mtPreview, msg, len) |
8c71c5a1172f
- Add state to engine callback for it to know what engine is sending
unc0rr
parents:
10951
diff
changeset
|
30 |
else if len = 1 then |
8c71c5a1172f
- Add state to engine callback for it to know what engine is sending
unc0rr
parents:
10951
diff
changeset
|
31 |
uiCallbackFunction(uiCallbackPointer, mtPreviewHogCount, msg, len) |
8c71c5a1172f
- Add state to engine callback for it to know what engine is sending
unc0rr
parents:
10951
diff
changeset
|
32 |
end; |
10951
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff
changeset
|
33 |
end; |
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff
changeset
|
34 |
|
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff
changeset
|
35 |
procedure registerUIMessagesCallback(p: pointer; f: TUICallback); cdecl; |
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff
changeset
|
36 |
begin |
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff
changeset
|
37 |
uiCallbackPointer:= p; |
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff
changeset
|
38 |
uiCallbackFunction:= f; |
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff
changeset
|
39 |
|
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff
changeset
|
40 |
registerIPCCallback(nil, @engineMessageCallback) |
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff
changeset
|
41 |
end; |
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff
changeset
|
42 |
|
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff
changeset
|
43 |
procedure sendUI(msgType: TMessageType; msg: PChar; len: Longword); |
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff
changeset
|
44 |
begin |
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff
changeset
|
45 |
uiCallbackFunction(uiCallbackPointer, msgType, msg, len) |
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff
changeset
|
46 |
end; |
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff
changeset
|
47 |
|
89a7f617e091
- Move protocol handling events to main thread through qt's main loop
unc0rr
parents:
diff
changeset
|
48 |
end. |