]> git.proxmox.com Git - mirror_edk2.git/blob - EmulatorPkg/Win/Host/WinGop.h
7843b60b91a9e0ccebc2f8b246d634d5ea398d4d
[mirror_edk2.git] / EmulatorPkg / Win / Host / WinGop.h
1 /** @file
2
3 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
4 This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12 Module Name:
13
14 WinGop.h
15
16 Abstract:
17
18 Private data for the Gop driver that is bound to the WinNt Thunk protocol
19
20
21 **/
22
23 #ifndef _WIN_GOP_H_
24 #define _WIN_GOP_H_
25
26
27 #include "WinHost.h"
28
29 #include <Protocol/EmuIoThunk.h>
30 #include <Protocol/EmuGraphicsWindow.h>
31 #include <Protocol/SimpleTextIn.h>
32 #include <Protocol/SimpleTextInEx.h>
33 #include <Protocol/GraphicsOutput.h>
34 #include <Library/FrameBufferBltLib.h>
35
36 //
37 // WM_SYSKEYDOWN/WM_SYSKEYUP Notification
38 // lParam
39 // bit 24: Specifies whether the key is an extended key,
40 // such as the right-hand ALT and CTRL keys that appear on
41 // an enhanced 101- or 102-key keyboard.
42 // The value is 1 if it is an extended key; otherwise, it is 0.
43 // bit 29:Specifies the context code.
44 // The value is 1 if the ALT key is down while the key is pressed/released;
45 // it is 0 if the WM_SYSKEYDOWN message is posted to the active window
46 // because no window has the keyboard focus.
47 #define GOP_EXTENDED_KEY (0x1 << 24)
48 #define GOP_ALT_KEY_PRESSED (0x1 << 29)
49
50 #define KEYBOARD_TIMER_INTERVAL 200000 // 0.02s
51
52 #define MAX_Q 256
53
54 typedef struct {
55 UINTN Front;
56 UINTN Rear;
57 EFI_KEY_DATA Q[MAX_Q];
58 CRITICAL_SECTION Cs;
59 } GOP_QUEUE_FIXED;
60
61 #define WIN_NT_GOP_CLASS_NAME L"WinNtGopWindow"
62
63
64 typedef struct {
65 UINT64 Signature;
66 EMU_GRAPHICS_WINDOW_PROTOCOL GraphicsWindowIo;
67
68 //
69 // GOP Private Data knowing when to start hardware
70 //
71 BOOLEAN HardwareNeedsStarting;
72
73 CHAR16 *WindowName;
74 CHAR16 Buffer[160];
75
76 HANDLE ThreadInited; // Semaphore
77 HANDLE ThreadHandle; // Thread
78 DWORD ThreadId;
79
80 HWND WindowHandle;
81 WNDCLASSEX WindowsClass;
82
83 UINT32 Width;
84 UINT32 Height;
85 //
86 // This screen is used to redraw the scree when windows events happen. It's
87 // updated in the main thread and displayed in the windows thread.
88 //
89 BITMAPV4HEADER *VirtualScreenInfo;
90
91 FRAME_BUFFER_CONFIGURE *FrameBufferConfigure;
92
93 //
94 // Keyboard Queue used by Simple Text In.
95 // QueueForRead: WinProc thread adds, and main thread removes.
96 //
97 GOP_QUEUE_FIXED QueueForRead;
98
99 EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK MakeRegisterdKeyCallback;
100 EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK BreakRegisterdKeyCallback;
101 VOID *RegisterdKeyCallbackContext;
102
103 EFI_KEY_STATE KeyState;
104 BOOLEAN LeftShift;
105 BOOLEAN RightShift;
106 BOOLEAN LeftAlt;
107 BOOLEAN RightAlt;
108 BOOLEAN LeftCtrl;
109 BOOLEAN RightCtrl;
110 BOOLEAN LeftLogo;
111 BOOLEAN RightLogo;
112 BOOLEAN Menu;
113 BOOLEAN SysReq;
114 BOOLEAN NumLock;
115 BOOLEAN ScrollLock;
116 BOOLEAN CapsLock;
117 BOOLEAN IsPartialKeySupport;
118 } GRAPHICS_PRIVATE_DATA;
119 #define GRAPHICS_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('g', 'f', 'x', 'd')
120 #define GRAPHICS_PRIVATE_DATA_FROM_THIS(a) \
121 CR(a, GRAPHICS_PRIVATE_DATA, GraphicsWindowIo, GRAPHICS_PRIVATE_DATA_SIGNATURE)
122
123
124 //
125 // Gop Hardware abstraction internal worker functions
126 //
127
128 /**
129 TODO: Add function description
130
131 @param Private TODO: add argument description
132 @param Key TODO: add argument description
133
134 @return TODO: add return values
135
136 **/
137 EFI_STATUS
138 GopPrivateAddKey (
139 IN GRAPHICS_PRIVATE_DATA *Private,
140 IN EFI_INPUT_KEY Key
141 );
142
143 EFI_STATUS
144 EFIAPI
145 WinNtWndGetKey (
146 IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsIo,
147 IN EFI_KEY_DATA *KeyData
148 );
149
150 EFI_STATUS
151 EFIAPI
152 WinNtWndCheckKey (
153 IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsIo
154 );
155
156 EFI_STATUS
157 EFIAPI
158 WinNtWndKeySetState (
159 IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsIo,
160 IN EFI_KEY_TOGGLE_STATE *KeyToggleState
161 );
162
163 EFI_STATUS
164 EFIAPI
165 WinNtWndRegisterKeyNotify (
166 IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsIo,
167 IN EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK MakeCallBack,
168 IN EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK BreakCallBack,
169 IN VOID *Context
170 );
171
172 EFI_STATUS
173 EFIAPI
174 WinNtWndCheckPointer (
175 IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsIo
176 );
177
178 EFI_STATUS
179 EFIAPI
180 WinNtWndGetPointerState (
181 IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsIo,
182 IN EFI_SIMPLE_POINTER_STATE *State
183 );
184 EFI_STATUS
185 GopPrivateCreateQ (
186 IN GRAPHICS_PRIVATE_DATA *Private,
187 IN GOP_QUEUE_FIXED *Queue
188 );
189
190
191 /**
192 TODO: Add function description
193
194 @param Private TODO: add argument description
195
196 @retval EFI_SUCCESS TODO: Add description for return value
197
198 **/
199 EFI_STATUS
200 GopPrivateDestroyQ (
201 IN GRAPHICS_PRIVATE_DATA *Private,
202 IN GOP_QUEUE_FIXED *Queue
203 );
204 #endif
205