1 //========================================================================
2 // GLFW 3.5 - www.glfw.org
3 //------------------------------------------------------------------------
4 // Copyright (c) 2016 Google Inc.
5 // Copyright (c) 2016-2017 Camilla Löwy <elmindreda@glfw.org>
6 //
7 // This software is provided 'as-is', without any express or implied
8 // warranty. In no event will the authors be held liable for any damages
9 // arising from the use of this software.
10 //
11 // Permission is granted to anyone to use this software for any purpose,
12 // including commercial applications, and to alter it and redistribute it
13 // freely, subject to the following restrictions:
14 //
15 // 1. The origin of this software must not be misrepresented; you must not
16 // claim that you wrote the original software. If you use this software
17 // in a product, an acknowledgment in the product documentation would
18 // be appreciated but is not required.
19 //
20 // 2. Altered source versions must be plainly marked as such, and must not
21 // be misrepresented as being the original software.
22 //
23 // 3. This notice may not be removed or altered from any source
24 // distribution.
25 //
26 //========================================================================
27
28 #include "internal.h"
29
30 #include <stdlib.h>
31 #include <string.h>
32
33
34 //////////////////////////////////////////////////////////////////////////
35 ////// GLFW platform API //////
36 //////////////////////////////////////////////////////////////////////////
37
_glfwConnectNull(int platformID, _GLFWplatform* platform)38 GLFWbool _glfwConnectNull(int platformID, _GLFWplatform* platform)
39 {
40 const _GLFWplatform null =
41 {
42 .platformID = GLFW_PLATFORM_NULL,
43 .init = _glfwInitNull,
44 .terminate = _glfwTerminateNull,
45 .getCursorPos = _glfwGetCursorPosNull,
46 .setCursorPos = _glfwSetCursorPosNull,
47 .setCursorMode = _glfwSetCursorModeNull,
48 .setRawMouseMotion = _glfwSetRawMouseMotionNull,
49 .rawMouseMotionSupported = _glfwRawMouseMotionSupportedNull,
50 .createCursor = _glfwCreateCursorNull,
51 .createStandardCursor = _glfwCreateStandardCursorNull,
52 .destroyCursor = _glfwDestroyCursorNull,
53 .setCursor = _glfwSetCursorNull,
54 .getScancodeName = _glfwGetScancodeNameNull,
55 .getKeyScancode = _glfwGetKeyScancodeNull,
56 .setClipboardString = _glfwSetClipboardStringNull,
57 .getClipboardString = _glfwGetClipboardStringNull,
58 .initJoysticks = _glfwInitJoysticksNull,
59 .terminateJoysticks = _glfwTerminateJoysticksNull,
60 .pollJoystick = _glfwPollJoystickNull,
61 .getMappingName = _glfwGetMappingNameNull,
62 .updateGamepadGUID = _glfwUpdateGamepadGUIDNull,
63 .freeMonitor = _glfwFreeMonitorNull,
64 .getMonitorPos = _glfwGetMonitorPosNull,
65 .getMonitorContentScale = _glfwGetMonitorContentScaleNull,
66 .getMonitorWorkarea = _glfwGetMonitorWorkareaNull,
67 .getVideoModes = _glfwGetVideoModesNull,
68 .getVideoMode = _glfwGetVideoModeNull,
69 .getGammaRamp = _glfwGetGammaRampNull,
70 .setGammaRamp = _glfwSetGammaRampNull,
71 .createWindow = _glfwCreateWindowNull,
72 .destroyWindow = _glfwDestroyWindowNull,
73 .setWindowTitle = _glfwSetWindowTitleNull,
74 .setWindowIcon = _glfwSetWindowIconNull,
75 .getWindowPos = _glfwGetWindowPosNull,
76 .setWindowPos = _glfwSetWindowPosNull,
77 .getWindowSize = _glfwGetWindowSizeNull,
78 .setWindowSize = _glfwSetWindowSizeNull,
79 .setWindowSizeLimits = _glfwSetWindowSizeLimitsNull,
80 .setWindowAspectRatio = _glfwSetWindowAspectRatioNull,
81 .getFramebufferSize = _glfwGetFramebufferSizeNull,
82 .getWindowFrameSize = _glfwGetWindowFrameSizeNull,
83 .getWindowContentScale = _glfwGetWindowContentScaleNull,
84 .iconifyWindow = _glfwIconifyWindowNull,
85 .restoreWindow = _glfwRestoreWindowNull,
86 .maximizeWindow = _glfwMaximizeWindowNull,
87 .showWindow = _glfwShowWindowNull,
88 .hideWindow = _glfwHideWindowNull,
89 .requestWindowAttention = _glfwRequestWindowAttentionNull,
90 .focusWindow = _glfwFocusWindowNull,
91 .setWindowMonitor = _glfwSetWindowMonitorNull,
92 .windowFocused = _glfwWindowFocusedNull,
93 .windowIconified = _glfwWindowIconifiedNull,
94 .windowVisible = _glfwWindowVisibleNull,
95 .windowMaximized = _glfwWindowMaximizedNull,
96 .windowHovered = _glfwWindowHoveredNull,
97 .framebufferTransparent = _glfwFramebufferTransparentNull,
98 .getWindowOpacity = _glfwGetWindowOpacityNull,
99 .setWindowResizable = _glfwSetWindowResizableNull,
100 .setWindowDecorated = _glfwSetWindowDecoratedNull,
101 .setWindowFloating = _glfwSetWindowFloatingNull,
102 .setWindowOpacity = _glfwSetWindowOpacityNull,
103 .setWindowMousePassthrough = _glfwSetWindowMousePassthroughNull,
104 .pollEvents = _glfwPollEventsNull,
105 .waitEvents = _glfwWaitEventsNull,
106 .waitEventsTimeout = _glfwWaitEventsTimeoutNull,
107 .postEmptyEvent = _glfwPostEmptyEventNull,
108 .getEGLPlatform = _glfwGetEGLPlatformNull,
109 .getEGLNativeDisplay = _glfwGetEGLNativeDisplayNull,
110 .getEGLNativeWindow = _glfwGetEGLNativeWindowNull,
111 .getRequiredInstanceExtensions = _glfwGetRequiredInstanceExtensionsNull,
112 .getPhysicalDevicePresentationSupport = _glfwGetPhysicalDevicePresentationSupportNull,
113 .createWindowSurface = _glfwCreateWindowSurfaceNull
114 };
115
116 *platform = null;
117 return GLFW_TRUE;
118 }
119
_glfwInitNull(void)120 int _glfwInitNull(void)
121 {
122 int scancode;
123
124 memset(_glfw.null.keycodes, -1, sizeof(_glfw.null.keycodes));
125 memset(_glfw.null.scancodes, -1, sizeof(_glfw.null.scancodes));
126
127 _glfw.null.keycodes[GLFW_NULL_SC_SPACE] = GLFW_KEY_SPACE;
128 _glfw.null.keycodes[GLFW_NULL_SC_APOSTROPHE] = GLFW_KEY_APOSTROPHE;
129 _glfw.null.keycodes[GLFW_NULL_SC_COMMA] = GLFW_KEY_COMMA;
130 _glfw.null.keycodes[GLFW_NULL_SC_MINUS] = GLFW_KEY_MINUS;
131 _glfw.null.keycodes[GLFW_NULL_SC_PERIOD] = GLFW_KEY_PERIOD;
132 _glfw.null.keycodes[GLFW_NULL_SC_SLASH] = GLFW_KEY_SLASH;
133 _glfw.null.keycodes[GLFW_NULL_SC_0] = GLFW_KEY_0;
134 _glfw.null.keycodes[GLFW_NULL_SC_1] = GLFW_KEY_1;
135 _glfw.null.keycodes[GLFW_NULL_SC_2] = GLFW_KEY_2;
136 _glfw.null.keycodes[GLFW_NULL_SC_3] = GLFW_KEY_3;
137 _glfw.null.keycodes[GLFW_NULL_SC_4] = GLFW_KEY_4;
138 _glfw.null.keycodes[GLFW_NULL_SC_5] = GLFW_KEY_5;
139 _glfw.null.keycodes[GLFW_NULL_SC_6] = GLFW_KEY_6;
140 _glfw.null.keycodes[GLFW_NULL_SC_7] = GLFW_KEY_7;
141 _glfw.null.keycodes[GLFW_NULL_SC_8] = GLFW_KEY_8;
142 _glfw.null.keycodes[GLFW_NULL_SC_9] = GLFW_KEY_9;
143 _glfw.null.keycodes[GLFW_NULL_SC_SEMICOLON] = GLFW_KEY_SEMICOLON;
144 _glfw.null.keycodes[GLFW_NULL_SC_EQUAL] = GLFW_KEY_EQUAL;
145 _glfw.null.keycodes[GLFW_NULL_SC_A] = GLFW_KEY_A;
146 _glfw.null.keycodes[GLFW_NULL_SC_B] = GLFW_KEY_B;
147 _glfw.null.keycodes[GLFW_NULL_SC_C] = GLFW_KEY_C;
148 _glfw.null.keycodes[GLFW_NULL_SC_D] = GLFW_KEY_D;
149 _glfw.null.keycodes[GLFW_NULL_SC_E] = GLFW_KEY_E;
150 _glfw.null.keycodes[GLFW_NULL_SC_F] = GLFW_KEY_F;
151 _glfw.null.keycodes[GLFW_NULL_SC_G] = GLFW_KEY_G;
152 _glfw.null.keycodes[GLFW_NULL_SC_H] = GLFW_KEY_H;
153 _glfw.null.keycodes[GLFW_NULL_SC_I] = GLFW_KEY_I;
154 _glfw.null.keycodes[GLFW_NULL_SC_J] = GLFW_KEY_J;
155 _glfw.null.keycodes[GLFW_NULL_SC_K] = GLFW_KEY_K;
156 _glfw.null.keycodes[GLFW_NULL_SC_L] = GLFW_KEY_L;
157 _glfw.null.keycodes[GLFW_NULL_SC_M] = GLFW_KEY_M;
158 _glfw.null.keycodes[GLFW_NULL_SC_N] = GLFW_KEY_N;
159 _glfw.null.keycodes[GLFW_NULL_SC_O] = GLFW_KEY_O;
160 _glfw.null.keycodes[GLFW_NULL_SC_P] = GLFW_KEY_P;
161 _glfw.null.keycodes[GLFW_NULL_SC_Q] = GLFW_KEY_Q;
162 _glfw.null.keycodes[GLFW_NULL_SC_R] = GLFW_KEY_R;
163 _glfw.null.keycodes[GLFW_NULL_SC_S] = GLFW_KEY_S;
164 _glfw.null.keycodes[GLFW_NULL_SC_T] = GLFW_KEY_T;
165 _glfw.null.keycodes[GLFW_NULL_SC_U] = GLFW_KEY_U;
166 _glfw.null.keycodes[GLFW_NULL_SC_V] = GLFW_KEY_V;
167 _glfw.null.keycodes[GLFW_NULL_SC_W] = GLFW_KEY_W;
168 _glfw.null.keycodes[GLFW_NULL_SC_X] = GLFW_KEY_X;
169 _glfw.null.keycodes[GLFW_NULL_SC_Y] = GLFW_KEY_Y;
170 _glfw.null.keycodes[GLFW_NULL_SC_Z] = GLFW_KEY_Z;
171 _glfw.null.keycodes[GLFW_NULL_SC_LEFT_BRACKET] = GLFW_KEY_LEFT_BRACKET;
172 _glfw.null.keycodes[GLFW_NULL_SC_BACKSLASH] = GLFW_KEY_BACKSLASH;
173 _glfw.null.keycodes[GLFW_NULL_SC_RIGHT_BRACKET] = GLFW_KEY_RIGHT_BRACKET;
174 _glfw.null.keycodes[GLFW_NULL_SC_GRAVE_ACCENT] = GLFW_KEY_GRAVE_ACCENT;
175 _glfw.null.keycodes[GLFW_NULL_SC_WORLD_1] = GLFW_KEY_WORLD_1;
176 _glfw.null.keycodes[GLFW_NULL_SC_WORLD_2] = GLFW_KEY_WORLD_2;
177 _glfw.null.keycodes[GLFW_NULL_SC_ESCAPE] = GLFW_KEY_ESCAPE;
178 _glfw.null.keycodes[GLFW_NULL_SC_ENTER] = GLFW_KEY_ENTER;
179 _glfw.null.keycodes[GLFW_NULL_SC_TAB] = GLFW_KEY_TAB;
180 _glfw.null.keycodes[GLFW_NULL_SC_BACKSPACE] = GLFW_KEY_BACKSPACE;
181 _glfw.null.keycodes[GLFW_NULL_SC_INSERT] = GLFW_KEY_INSERT;
182 _glfw.null.keycodes[GLFW_NULL_SC_DELETE] = GLFW_KEY_DELETE;
183 _glfw.null.keycodes[GLFW_NULL_SC_RIGHT] = GLFW_KEY_RIGHT;
184 _glfw.null.keycodes[GLFW_NULL_SC_LEFT] = GLFW_KEY_LEFT;
185 _glfw.null.keycodes[GLFW_NULL_SC_DOWN] = GLFW_KEY_DOWN;
186 _glfw.null.keycodes[GLFW_NULL_SC_UP] = GLFW_KEY_UP;
187 _glfw.null.keycodes[GLFW_NULL_SC_PAGE_UP] = GLFW_KEY_PAGE_UP;
188 _glfw.null.keycodes[GLFW_NULL_SC_PAGE_DOWN] = GLFW_KEY_PAGE_DOWN;
189 _glfw.null.keycodes[GLFW_NULL_SC_HOME] = GLFW_KEY_HOME;
190 _glfw.null.keycodes[GLFW_NULL_SC_END] = GLFW_KEY_END;
191 _glfw.null.keycodes[GLFW_NULL_SC_CAPS_LOCK] = GLFW_KEY_CAPS_LOCK;
192 _glfw.null.keycodes[GLFW_NULL_SC_SCROLL_LOCK] = GLFW_KEY_SCROLL_LOCK;
193 _glfw.null.keycodes[GLFW_NULL_SC_NUM_LOCK] = GLFW_KEY_NUM_LOCK;
194 _glfw.null.keycodes[GLFW_NULL_SC_PRINT_SCREEN] = GLFW_KEY_PRINT_SCREEN;
195 _glfw.null.keycodes[GLFW_NULL_SC_PAUSE] = GLFW_KEY_PAUSE;
196 _glfw.null.keycodes[GLFW_NULL_SC_F1] = GLFW_KEY_F1;
197 _glfw.null.keycodes[GLFW_NULL_SC_F2] = GLFW_KEY_F2;
198 _glfw.null.keycodes[GLFW_NULL_SC_F3] = GLFW_KEY_F3;
199 _glfw.null.keycodes[GLFW_NULL_SC_F4] = GLFW_KEY_F4;
200 _glfw.null.keycodes[GLFW_NULL_SC_F5] = GLFW_KEY_F5;
201 _glfw.null.keycodes[GLFW_NULL_SC_F6] = GLFW_KEY_F6;
202 _glfw.null.keycodes[GLFW_NULL_SC_F7] = GLFW_KEY_F7;
203 _glfw.null.keycodes[GLFW_NULL_SC_F8] = GLFW_KEY_F8;
204 _glfw.null.keycodes[GLFW_NULL_SC_F9] = GLFW_KEY_F9;
205 _glfw.null.keycodes[GLFW_NULL_SC_F10] = GLFW_KEY_F10;
206 _glfw.null.keycodes[GLFW_NULL_SC_F11] = GLFW_KEY_F11;
207 _glfw.null.keycodes[GLFW_NULL_SC_F12] = GLFW_KEY_F12;
208 _glfw.null.keycodes[GLFW_NULL_SC_F13] = GLFW_KEY_F13;
209 _glfw.null.keycodes[GLFW_NULL_SC_F14] = GLFW_KEY_F14;
210 _glfw.null.keycodes[GLFW_NULL_SC_F15] = GLFW_KEY_F15;
211 _glfw.null.keycodes[GLFW_NULL_SC_F16] = GLFW_KEY_F16;
212 _glfw.null.keycodes[GLFW_NULL_SC_F17] = GLFW_KEY_F17;
213 _glfw.null.keycodes[GLFW_NULL_SC_F18] = GLFW_KEY_F18;
214 _glfw.null.keycodes[GLFW_NULL_SC_F19] = GLFW_KEY_F19;
215 _glfw.null.keycodes[GLFW_NULL_SC_F20] = GLFW_KEY_F20;
216 _glfw.null.keycodes[GLFW_NULL_SC_F21] = GLFW_KEY_F21;
217 _glfw.null.keycodes[GLFW_NULL_SC_F22] = GLFW_KEY_F22;
218 _glfw.null.keycodes[GLFW_NULL_SC_F23] = GLFW_KEY_F23;
219 _glfw.null.keycodes[GLFW_NULL_SC_F24] = GLFW_KEY_F24;
220 _glfw.null.keycodes[GLFW_NULL_SC_F25] = GLFW_KEY_F25;
221 _glfw.null.keycodes[GLFW_NULL_SC_KP_0] = GLFW_KEY_KP_0;
222 _glfw.null.keycodes[GLFW_NULL_SC_KP_1] = GLFW_KEY_KP_1;
223 _glfw.null.keycodes[GLFW_NULL_SC_KP_2] = GLFW_KEY_KP_2;
224 _glfw.null.keycodes[GLFW_NULL_SC_KP_3] = GLFW_KEY_KP_3;
225 _glfw.null.keycodes[GLFW_NULL_SC_KP_4] = GLFW_KEY_KP_4;
226 _glfw.null.keycodes[GLFW_NULL_SC_KP_5] = GLFW_KEY_KP_5;
227 _glfw.null.keycodes[GLFW_NULL_SC_KP_6] = GLFW_KEY_KP_6;
228 _glfw.null.keycodes[GLFW_NULL_SC_KP_7] = GLFW_KEY_KP_7;
229 _glfw.null.keycodes[GLFW_NULL_SC_KP_8] = GLFW_KEY_KP_8;
230 _glfw.null.keycodes[GLFW_NULL_SC_KP_9] = GLFW_KEY_KP_9;
231 _glfw.null.keycodes[GLFW_NULL_SC_KP_DECIMAL] = GLFW_KEY_KP_DECIMAL;
232 _glfw.null.keycodes[GLFW_NULL_SC_KP_DIVIDE] = GLFW_KEY_KP_DIVIDE;
233 _glfw.null.keycodes[GLFW_NULL_SC_KP_MULTIPLY] = GLFW_KEY_KP_MULTIPLY;
234 _glfw.null.keycodes[GLFW_NULL_SC_KP_SUBTRACT] = GLFW_KEY_KP_SUBTRACT;
235 _glfw.null.keycodes[GLFW_NULL_SC_KP_ADD] = GLFW_KEY_KP_ADD;
236 _glfw.null.keycodes[GLFW_NULL_SC_KP_ENTER] = GLFW_KEY_KP_ENTER;
237 _glfw.null.keycodes[GLFW_NULL_SC_KP_EQUAL] = GLFW_KEY_KP_EQUAL;
238 _glfw.null.keycodes[GLFW_NULL_SC_LEFT_SHIFT] = GLFW_KEY_LEFT_SHIFT;
239 _glfw.null.keycodes[GLFW_NULL_SC_LEFT_CONTROL] = GLFW_KEY_LEFT_CONTROL;
240 _glfw.null.keycodes[GLFW_NULL_SC_LEFT_ALT] = GLFW_KEY_LEFT_ALT;
241 _glfw.null.keycodes[GLFW_NULL_SC_LEFT_SUPER] = GLFW_KEY_LEFT_SUPER;
242 _glfw.null.keycodes[GLFW_NULL_SC_RIGHT_SHIFT] = GLFW_KEY_RIGHT_SHIFT;
243 _glfw.null.keycodes[GLFW_NULL_SC_RIGHT_CONTROL] = GLFW_KEY_RIGHT_CONTROL;
244 _glfw.null.keycodes[GLFW_NULL_SC_RIGHT_ALT] = GLFW_KEY_RIGHT_ALT;
245 _glfw.null.keycodes[GLFW_NULL_SC_RIGHT_SUPER] = GLFW_KEY_RIGHT_SUPER;
246 _glfw.null.keycodes[GLFW_NULL_SC_MENU] = GLFW_KEY_MENU;
247
248 for (scancode = GLFW_NULL_SC_FIRST; scancode < GLFW_NULL_SC_LAST; scancode++)
249 {
250 if (_glfw.null.keycodes[scancode] > 0)
251 _glfw.null.scancodes[_glfw.null.keycodes[scancode]] = scancode;
252 }
253
254 _glfwPollMonitorsNull();
255 return GLFW_TRUE;
256 }
257
_glfwTerminateNull(void)258 void _glfwTerminateNull(void)
259 {
260 free(_glfw.null.clipboardString);
261 _glfwTerminateOSMesa();
262 _glfwTerminateEGL();
263 }
264
265