1 #pragma once
2 
3 namespace dvl {
4 
5 typedef uint16_t SHORT;
6 typedef int32_t LONG;
7 typedef uint8_t BOOLEAN;
8 
9 typedef unsigned char UCHAR;
10 
11 typedef uint32_t DWORD;
12 typedef int BOOL;
13 typedef unsigned char BYTE;
14 typedef unsigned short WORD;
15 typedef DWORD *LPDWORD;
16 typedef void *LPVOID;
17 typedef void *PVOID;
18 
19 typedef unsigned int UINT;
20 
21 typedef int32_t WPARAM;
22 typedef int32_t LPARAM;
23 
24 //
25 // Handles
26 //
27 typedef void *HANDLE;
28 
29 typedef HANDLE HMODULE, HDC, HINSTANCE;
30 
31 typedef void (*WNDPROC)(UINT, WPARAM, LPARAM);
32 
33 typedef struct tagMSG {
34 	UINT message;
35 	WPARAM wParam;
36 	LPARAM lParam;
37 } MSG, *LPMSG;
38 
39 //
40 // Everything else
41 //
42 
43 void SetCursorPos(int X, int Y);
44 void FocusOnCharInfo();
45 
46 SHORT GetAsyncKeyState(int vKey);
47 
48 bool FetchMessage(LPMSG lpMsg);
49 
50 bool TranslateMessage(const MSG *lpMsg);
51 void PushMessage(const MSG *lpMsg);
52 bool PostMessage(UINT Msg, WPARAM wParam, LPARAM lParam);
53 
54 #ifndef TRUE
55 #define TRUE true
56 #endif
57 #ifndef FALSE
58 #define FALSE false
59 #endif
60 
61 //
62 // MSCVRT emulation
63 //
64 
65 #define DVL_FILE_BEGIN 0
66 #define DVL_FILE_CURRENT 1
67 #define DVL_FILE_END 2
68 
69 #define DVL_ERROR_HANDLE_EOF 1002
70 
71 #define DVL_WM_QUIT 0x0012
72 
73 //
74 // Events
75 //
76 #define DVL_WM_MOUSEMOVE 0x0200
77 #define DVL_WM_LBUTTONDOWN 0x0201
78 #define DVL_WM_LBUTTONUP 0x0202
79 #define DVL_WM_RBUTTONDOWN 0x0204
80 #define DVL_WM_RBUTTONUP 0x0205
81 
82 #define DVL_WM_KEYDOWN 0x0100
83 #define DVL_WM_KEYUP 0x0101
84 #define DVL_WM_SYSKEYDOWN 0x0104
85 
86 #define DVL_WM_SYSCOMMAND 0x0112
87 
88 #define DVL_WM_CHAR 0x0102
89 #define DVL_WM_CAPTURECHANGED 0x0215
90 
91 #define DVL_WM_PAINT 0x000F
92 #define DVL_WM_QUERYENDSESSION 0x0011
93 
94 #define DVL_SC_CLOSE 0xF060
95 
96 // Virtual key codes.
97 //
98 // ref: https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes
99 #define DVL_VK_BACK 0x08     // BACKSPACE key
100 #define DVL_VK_TAB 0x09      // TAB key
101 #define DVL_VK_RETURN 0x0D   // ENTER key
102 #define DVL_VK_SHIFT 0x10    // SHIFT key
103 #define DVL_VK_CONTROL 0x11  // CONTROL key
104 #define DVL_VK_MENU 0x12     // ALT key
105 #define DVL_VK_PAUSE 0x13    // PAUSE key
106 #define DVL_VK_CAPITAL 0x14  // CAPS LOCK key
107 #define DVL_VK_ESCAPE 0x1B   // ESC key
108 #define DVL_VK_SPACE 0x20    // SPACEBAR
109 #define DVL_VK_PRIOR 0x21    // PAGE UP key
110 #define DVL_VK_NEXT 0x22     // PAGE DOWN key
111 #define DVL_VK_END 0x23      // END key
112 #define DVL_VK_HOME 0x24     // HOME key
113 #define DVL_VK_LEFT 0x25     // LEFT ARROW key
114 #define DVL_VK_UP 0x26       // UP ARROW key
115 #define DVL_VK_RIGHT 0x27    // RIGHT ARROW key
116 #define DVL_VK_DOWN 0x28     // DOWN ARROW key
117 #define DVL_VK_SNAPSHOT 0x2C // PRINT SCREEN key
118 #define DVL_VK_INSERT 0x2D   // INS key
119 #define DVL_VK_DELETE 0x2E   // DEL key
120 // DVL_VK_0 through DVL_VK_9 correspond to '0' - '9'
121 // DVL_VK_A through DVL_VK_Z correspond to 'A' - 'Z'
122 #define DVL_VK_LWIN 0x5B       // Left Windows key (Natural keyboard)
123 #define DVL_VK_RWIN 0x5C       // Right Windows key (Natural keyboard)
124 #define DVL_VK_NUMPAD0 '0'     // Numeric keypad 0 key
125 #define DVL_VK_NUMPAD1 '1'     // Numeric keypad 1 key
126 #define DVL_VK_NUMPAD2 '2'     // Numeric keypad 2 key
127 #define DVL_VK_NUMPAD3 '3'     // Numeric keypad 3 key
128 #define DVL_VK_NUMPAD4 '4'     // Numeric keypad 4 key
129 #define DVL_VK_NUMPAD5 '5'     // Numeric keypad 5 key
130 #define DVL_VK_NUMPAD6 '6'     // Numeric keypad 6 key
131 #define DVL_VK_NUMPAD7 '7'     // Numeric keypad 7 key
132 #define DVL_VK_NUMPAD8 '8'     // Numeric keypad 8 key
133 #define DVL_VK_NUMPAD9 '9'     // Numeric keypad 9 key
134 #define DVL_VK_MULTIPLY 0x6A   // Multiply key
135 #define DVL_VK_ADD 0x6B        // Add key
136 #define DVL_VK_SUBTRACT 0x6D   // Subtract key
137 #define DVL_VK_DECIMAL 0x6E    // Decimal key
138 #define DVL_VK_DIVIDE 0x6F     // Divide key
139 #define DVL_VK_F1 0x70         // F1 key
140 #define DVL_VK_F2 0x71         // F2 key
141 #define DVL_VK_F3 0x72         // F3 key
142 #define DVL_VK_F4 0x73         // F4 key
143 #define DVL_VK_F5 0x74         // F5 key
144 #define DVL_VK_F6 0x75         // F6 key
145 #define DVL_VK_F7 0x76         // F7 key
146 #define DVL_VK_F8 0x77         // F8 key
147 #define DVL_VK_F9 0x78         // F9 key
148 #define DVL_VK_F10 0x79        // F10 key
149 #define DVL_VK_F11 0x7A        // F11 key
150 #define DVL_VK_F12 0x7B        // F12 key
151 #define DVL_VK_NUMLOCK 0x90    // NUM LOCK key
152 #define DVL_VK_SCROLL 0x91     // SCROLL LOCK key
153 #define DVL_VK_LSHIFT 0xA0     // Left SHIFT key
154 #define DVL_VK_RSHIFT 0xA1     // Right SHIFT key
155 #define DVL_VK_LCONTROL 0xA2   // Left CONTROL key
156 #define DVL_VK_RCONTROL 0xA3   // Right CONTROL key
157 #define DVL_VK_LMENU 0xA4      // Left MENU key
158 #define DVL_VK_RMENU 0xA5      // Right MENU key
159 #define DVL_VK_OEM_1 0xBA      // For the US standard keyboard, the ':' key
160 #define DVL_VK_OEM_PLUS 0xBB   // For any country/region, the '+' key
161 #define DVL_VK_OEM_COMMA 0xBC  // For any country/region, the ',' key
162 #define DVL_VK_OEM_MINUS 0xBD  // For any country/region, the '-' key
163 #define DVL_VK_OEM_PERIOD 0xBE // For any country/region, the '.' key
164 #define DVL_VK_OEM_2 0xBF      // For the US standard keyboard, the '/?' key
165 #define DVL_VK_OEM_3 0xC0      // For the US standard keyboard, the '`~' key
166 #define DVL_VK_OEM_4 0xDB      // For the US standard keyboard, the '[{' key
167 #define DVL_VK_OEM_5 0xDC      // For the US standard keyboard, the '\|' key
168 #define DVL_VK_OEM_6 0xDD      // For the US standard keyboard, the ']}' key
169 #define DVL_VK_OEM_7 0xDE      // For the US standard keyboard, the 'single-quote/double-quote' key
170 
171 #define DVL_MK_SHIFT 0x0004
172 #define DVL_MK_LBUTTON 0x0001
173 #define DVL_MK_RBUTTON 0x0002
174 
175 } // namespace dvl
176