pyglet 2.1.12__py3-none-any.whl → 3.0.dev1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pyglet/__init__.py +67 -61
- pyglet/__init__.pyi +15 -8
- pyglet/app/__init__.py +22 -13
- pyglet/app/async_app.py +212 -0
- pyglet/app/base.py +2 -1
- pyglet/app/{xlib.py → linux.py} +3 -3
- pyglet/config/__init__.py +101 -0
- pyglet/config/gl/__init__.py +30 -0
- pyglet/config/gl/egl.py +120 -0
- pyglet/config/gl/macos.py +262 -0
- pyglet/config/gl/windows.py +267 -0
- pyglet/config/gl/x11.py +142 -0
- pyglet/customtypes.py +43 -2
- pyglet/display/__init__.py +8 -6
- pyglet/display/base.py +3 -63
- pyglet/display/cocoa.py +12 -17
- pyglet/display/emscripten.py +39 -0
- pyglet/display/headless.py +23 -30
- pyglet/display/wayland.py +157 -0
- pyglet/display/win32.py +4 -17
- pyglet/display/xlib.py +19 -27
- pyglet/display/xlib_vidmoderestore.py +2 -2
- pyglet/enums.py +183 -0
- pyglet/event.py +0 -1
- pyglet/experimental/geoshader_sprite.py +15 -13
- pyglet/experimental/hidraw.py +6 -15
- pyglet/experimental/multitexture_sprite.py +31 -19
- pyglet/experimental/particles.py +13 -35
- pyglet/font/__init__.py +251 -85
- pyglet/font/base.py +116 -61
- pyglet/font/dwrite/__init__.py +349 -204
- pyglet/font/dwrite/dwrite_lib.py +27 -5
- pyglet/font/fontconfig.py +14 -6
- pyglet/font/freetype.py +138 -87
- pyglet/font/freetype_lib.py +19 -0
- pyglet/font/group.py +179 -0
- pyglet/font/harfbuzz/__init__.py +3 -3
- pyglet/font/pyodide_js.py +310 -0
- pyglet/font/quartz.py +319 -126
- pyglet/font/ttf.py +45 -3
- pyglet/font/user.py +14 -19
- pyglet/font/win32.py +45 -21
- pyglet/graphics/__init__.py +8 -787
- pyglet/graphics/allocation.py +115 -1
- pyglet/graphics/api/__init__.py +77 -0
- pyglet/graphics/api/base.py +299 -0
- pyglet/graphics/api/gl/__init__.py +58 -0
- pyglet/graphics/api/gl/base.py +24 -0
- pyglet/graphics/{vertexbuffer.py → api/gl/buffer.py} +104 -159
- pyglet/graphics/api/gl/cocoa/context.py +76 -0
- pyglet/graphics/api/gl/context.py +391 -0
- pyglet/graphics/api/gl/default_shaders.py +0 -0
- pyglet/graphics/api/gl/draw.py +627 -0
- pyglet/graphics/api/gl/egl/__init__.py +0 -0
- pyglet/graphics/api/gl/egl/context.py +92 -0
- pyglet/graphics/api/gl/enums.py +76 -0
- pyglet/graphics/api/gl/framebuffer.py +315 -0
- pyglet/graphics/api/gl/gl.py +5463 -0
- pyglet/graphics/api/gl/gl_info.py +188 -0
- pyglet/graphics/api/gl/global_opengl.py +226 -0
- pyglet/{gl → graphics/api/gl}/lib.py +34 -18
- pyglet/graphics/api/gl/shader.py +1476 -0
- pyglet/graphics/api/gl/shapes.py +55 -0
- pyglet/graphics/api/gl/sprite.py +102 -0
- pyglet/graphics/api/gl/state.py +219 -0
- pyglet/graphics/api/gl/text.py +190 -0
- pyglet/graphics/api/gl/texture.py +1526 -0
- pyglet/graphics/{vertexarray.py → api/gl/vertexarray.py} +11 -13
- pyglet/graphics/api/gl/vertexdomain.py +751 -0
- pyglet/graphics/api/gl/win32/__init__.py +0 -0
- pyglet/graphics/api/gl/win32/context.py +108 -0
- pyglet/graphics/api/gl/win32/wgl_info.py +24 -0
- pyglet/graphics/api/gl/xlib/__init__.py +0 -0
- pyglet/graphics/api/gl/xlib/context.py +174 -0
- pyglet/{gl → graphics/api/gl/xlib}/glx_info.py +26 -31
- pyglet/graphics/api/gl1/__init__.py +0 -0
- pyglet/{gl → graphics/api/gl1}/gl_compat.py +3 -2
- pyglet/graphics/api/gl2/__init__.py +0 -0
- pyglet/graphics/api/gl2/buffer.py +320 -0
- pyglet/graphics/api/gl2/draw.py +600 -0
- pyglet/graphics/api/gl2/global_opengl.py +122 -0
- pyglet/graphics/api/gl2/shader.py +200 -0
- pyglet/graphics/api/gl2/shapes.py +51 -0
- pyglet/graphics/api/gl2/sprite.py +79 -0
- pyglet/graphics/api/gl2/text.py +175 -0
- pyglet/graphics/api/gl2/vertexdomain.py +364 -0
- pyglet/graphics/api/webgl/__init__.py +233 -0
- pyglet/graphics/api/webgl/buffer.py +302 -0
- pyglet/graphics/api/webgl/context.py +234 -0
- pyglet/graphics/api/webgl/draw.py +590 -0
- pyglet/graphics/api/webgl/enums.py +76 -0
- pyglet/graphics/api/webgl/framebuffer.py +360 -0
- pyglet/graphics/api/webgl/gl.py +1537 -0
- pyglet/graphics/api/webgl/gl_info.py +130 -0
- pyglet/graphics/api/webgl/shader.py +1346 -0
- pyglet/graphics/api/webgl/shapes.py +92 -0
- pyglet/graphics/api/webgl/sprite.py +102 -0
- pyglet/graphics/api/webgl/state.py +227 -0
- pyglet/graphics/api/webgl/text.py +187 -0
- pyglet/graphics/api/webgl/texture.py +1227 -0
- pyglet/graphics/api/webgl/vertexarray.py +54 -0
- pyglet/graphics/api/webgl/vertexdomain.py +616 -0
- pyglet/graphics/api/webgl/webgl_js.pyi +307 -0
- pyglet/{image → graphics}/atlas.py +33 -32
- pyglet/graphics/base.py +10 -0
- pyglet/graphics/buffer.py +245 -0
- pyglet/graphics/draw.py +578 -0
- pyglet/graphics/framebuffer.py +26 -0
- pyglet/graphics/instance.py +178 -69
- pyglet/graphics/shader.py +267 -1553
- pyglet/graphics/state.py +83 -0
- pyglet/graphics/texture.py +703 -0
- pyglet/graphics/vertexdomain.py +695 -538
- pyglet/gui/ninepatch.py +10 -10
- pyglet/gui/widgets.py +120 -10
- pyglet/image/__init__.py +20 -1973
- pyglet/image/animation.py +12 -12
- pyglet/image/base.py +730 -0
- pyglet/image/codecs/__init__.py +9 -0
- pyglet/image/codecs/bmp.py +53 -30
- pyglet/image/codecs/dds.py +53 -31
- pyglet/image/codecs/gdiplus.py +38 -14
- pyglet/image/codecs/gdkpixbuf2.py +0 -2
- pyglet/image/codecs/js_image.py +99 -0
- pyglet/image/codecs/ktx2.py +161 -0
- pyglet/image/codecs/pil.py +1 -1
- pyglet/image/codecs/png.py +1 -1
- pyglet/image/codecs/wic.py +11 -2
- pyglet/info.py +26 -24
- pyglet/input/__init__.py +8 -0
- pyglet/input/base.py +163 -105
- pyglet/input/controller.py +13 -19
- pyglet/input/controller_db.py +39 -24
- pyglet/input/emscripten/__init__.py +18 -0
- pyglet/input/emscripten/gamepad_js.py +397 -0
- pyglet/input/linux/__init__.py +11 -5
- pyglet/input/linux/evdev.py +10 -11
- pyglet/input/linux/x11_xinput.py +2 -2
- pyglet/input/linux/x11_xinput_tablet.py +1 -1
- pyglet/input/macos/__init__.py +7 -2
- pyglet/input/macos/darwin_gc.py +559 -0
- pyglet/input/win32/__init__.py +1 -1
- pyglet/input/win32/directinput.py +34 -29
- pyglet/input/win32/xinput.py +11 -61
- pyglet/lib.py +3 -3
- pyglet/libs/__init__.py +1 -1
- pyglet/{gl → libs/darwin}/agl.py +1 -1
- pyglet/libs/darwin/cocoapy/__init__.py +2 -2
- pyglet/libs/darwin/cocoapy/cocoahelpers.py +181 -0
- pyglet/libs/darwin/cocoapy/cocoalibs.py +31 -0
- pyglet/libs/darwin/cocoapy/cocoatypes.py +27 -0
- pyglet/libs/darwin/cocoapy/runtime.py +81 -45
- pyglet/libs/darwin/coreaudio.py +4 -4
- pyglet/{gl → libs/darwin}/lib_agl.py +9 -8
- pyglet/libs/darwin/quartzkey.py +1 -3
- pyglet/libs/egl/__init__.py +2 -0
- pyglet/libs/egl/egl_lib.py +576 -0
- pyglet/libs/egl/eglext.py +51 -5
- pyglet/libs/linux/__init__.py +0 -0
- pyglet/libs/linux/egl/__init__.py +0 -0
- pyglet/libs/linux/egl/eglext.py +22 -0
- pyglet/libs/linux/glx/__init__.py +0 -0
- pyglet/{gl → libs/linux/glx}/glx.py +13 -14
- pyglet/{gl → libs/linux/glx}/glxext_arb.py +408 -192
- pyglet/{gl → libs/linux/glx}/glxext_mesa.py +1 -1
- pyglet/{gl → libs/linux/glx}/glxext_nv.py +345 -164
- pyglet/{gl → libs/linux/glx}/lib_glx.py +3 -2
- pyglet/libs/linux/wayland/__init__.py +0 -0
- pyglet/libs/linux/wayland/client.py +1068 -0
- pyglet/libs/linux/wayland/lib_wayland.py +207 -0
- pyglet/libs/linux/wayland/wayland_egl.py +38 -0
- pyglet/libs/{wayland → linux/wayland}/xkbcommon.py +26 -0
- pyglet/libs/{x11 → linux/x11}/xf86vmode.py +4 -4
- pyglet/libs/{x11 → linux/x11}/xinerama.py +2 -2
- pyglet/libs/{x11 → linux/x11}/xinput.py +10 -10
- pyglet/libs/linux/x11/xrandr.py +0 -0
- pyglet/libs/{x11 → linux/x11}/xrender.py +1 -1
- pyglet/libs/shared/__init__.py +0 -0
- pyglet/libs/shared/spirv/__init__.py +0 -0
- pyglet/libs/shared/spirv/lib_shaderc.py +85 -0
- pyglet/libs/shared/spirv/lib_spirv_cross.py +126 -0
- pyglet/libs/win32/__init__.py +27 -5
- pyglet/libs/win32/constants.py +59 -48
- pyglet/libs/win32/context_managers.py +20 -3
- pyglet/libs/win32/dinput.py +105 -88
- pyglet/{gl → libs/win32}/lib_wgl.py +52 -26
- pyglet/libs/win32/types.py +58 -23
- pyglet/{gl → libs/win32}/wgl.py +32 -25
- pyglet/{gl → libs/win32}/wglext_arb.py +364 -2
- pyglet/media/__init__.py +9 -10
- pyglet/media/codecs/__init__.py +12 -1
- pyglet/media/codecs/base.py +99 -96
- pyglet/media/codecs/ffmpeg.py +2 -2
- pyglet/media/codecs/ffmpeg_lib/libavformat.py +3 -8
- pyglet/media/codecs/webaudio_pyodide.py +111 -0
- pyglet/media/drivers/__init__.py +9 -4
- pyglet/media/drivers/base.py +4 -4
- pyglet/media/drivers/openal/__init__.py +1 -1
- pyglet/media/drivers/openal/adaptation.py +3 -3
- pyglet/media/drivers/pulse/__init__.py +1 -1
- pyglet/media/drivers/pulse/adaptation.py +3 -3
- pyglet/media/drivers/pyodide_js/__init__.py +8 -0
- pyglet/media/drivers/pyodide_js/adaptation.py +288 -0
- pyglet/media/drivers/xaudio2/adaptation.py +3 -3
- pyglet/media/player.py +276 -193
- pyglet/media/player_worker_thread.py +1 -1
- pyglet/model/__init__.py +39 -29
- pyglet/model/codecs/base.py +4 -4
- pyglet/model/codecs/gltf.py +3 -3
- pyglet/model/codecs/obj.py +71 -43
- pyglet/resource.py +129 -78
- pyglet/shapes.py +147 -177
- pyglet/sprite.py +47 -164
- pyglet/text/__init__.py +44 -54
- pyglet/text/caret.py +12 -7
- pyglet/text/document.py +19 -17
- pyglet/text/formats/html.py +2 -2
- pyglet/text/formats/structured.py +10 -40
- pyglet/text/layout/__init__.py +20 -13
- pyglet/text/layout/base.py +176 -287
- pyglet/text/layout/incremental.py +9 -10
- pyglet/text/layout/scrolling.py +7 -95
- pyglet/window/__init__.py +183 -172
- pyglet/window/cocoa/__init__.py +62 -51
- pyglet/window/cocoa/pyglet_delegate.py +2 -25
- pyglet/window/cocoa/pyglet_view.py +9 -8
- pyglet/window/dialog/__init__.py +184 -0
- pyglet/window/dialog/base.py +99 -0
- pyglet/window/dialog/darwin.py +121 -0
- pyglet/window/dialog/linux.py +72 -0
- pyglet/window/dialog/windows.py +194 -0
- pyglet/window/emscripten/__init__.py +779 -0
- pyglet/window/headless/__init__.py +44 -28
- pyglet/window/key.py +2 -0
- pyglet/window/mouse.py +2 -2
- pyglet/window/wayland/__init__.py +377 -0
- pyglet/window/win32/__init__.py +101 -46
- pyglet/window/xlib/__init__.py +104 -66
- {pyglet-2.1.12.dist-info → pyglet-3.0.dev1.dist-info}/METADATA +2 -3
- pyglet-3.0.dev1.dist-info/RECORD +322 -0
- {pyglet-2.1.12.dist-info → pyglet-3.0.dev1.dist-info}/WHEEL +1 -1
- pyglet/gl/__init__.py +0 -208
- pyglet/gl/base.py +0 -499
- pyglet/gl/cocoa.py +0 -309
- pyglet/gl/gl.py +0 -4625
- pyglet/gl/gl.pyi +0 -2320
- pyglet/gl/gl_compat.pyi +0 -3097
- pyglet/gl/gl_info.py +0 -190
- pyglet/gl/headless.py +0 -166
- pyglet/gl/wgl_info.py +0 -36
- pyglet/gl/wglext_nv.py +0 -1096
- pyglet/gl/win32.py +0 -268
- pyglet/gl/xlib.py +0 -295
- pyglet/image/buffer.py +0 -274
- pyglet/image/codecs/s3tc.py +0 -354
- pyglet/libs/x11/xrandr.py +0 -166
- pyglet-2.1.12.dist-info/RECORD +0 -234
- /pyglet/{libs/wayland → graphics/api/gl/cocoa}/__init__.py +0 -0
- /pyglet/libs/{egl → linux/egl}/egl.py +0 -0
- /pyglet/libs/{egl → linux/egl}/lib.py +0 -0
- /pyglet/libs/{ioctl.py → linux/ioctl.py} +0 -0
- /pyglet/libs/{wayland → linux/wayland}/gbm.py +0 -0
- /pyglet/libs/{x11 → linux/x11}/__init__.py +0 -0
- /pyglet/libs/{x11 → linux/x11}/cursorfont.py +0 -0
- /pyglet/libs/{x11 → linux/x11}/xlib.py +0 -0
- /pyglet/libs/{x11 → linux/x11}/xsync.py +0 -0
- {pyglet-2.1.12.dist-info/licenses → pyglet-3.0.dev1.dist-info}/LICENSE +0 -0
pyglet/libs/win32/__init__.py
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
1
2
|
import atexit
|
|
2
3
|
import struct
|
|
3
4
|
import warnings
|
|
4
5
|
from ctypes import HRESULT
|
|
5
|
-
from ctypes.wintypes import ATOM, HFONT, HGDIOBJ, HGLOBAL, HMENU, HMODULE, INT, LPVOID, PUINT
|
|
6
|
+
from ctypes.wintypes import ATOM, HFONT, HGDIOBJ, HGLOBAL, HMENU, HMODULE, INT, LPVOID, PUINT, HKEY, LPBYTE, LPCVOID
|
|
6
7
|
|
|
7
8
|
import pyglet
|
|
8
9
|
|
|
@@ -11,7 +12,7 @@ from .types import *
|
|
|
11
12
|
|
|
12
13
|
IS64 = struct.calcsize("P") == 8
|
|
13
14
|
|
|
14
|
-
_debug_win32 = pyglet.options
|
|
15
|
+
_debug_win32 = pyglet.options.debug_win32
|
|
15
16
|
|
|
16
17
|
DebugLibrary = lambda lib: ctypes.WinDLL(lib, use_last_error=True if _debug_win32 else False)
|
|
17
18
|
|
|
@@ -23,6 +24,8 @@ _shell32 = DebugLibrary('shell32')
|
|
|
23
24
|
_ole32 = DebugLibrary('ole32')
|
|
24
25
|
_oleaut32 = DebugLibrary('oleaut32')
|
|
25
26
|
_shcore = DebugLibrary('shcore')
|
|
27
|
+
_advapi32 = DebugLibrary("advapi32")
|
|
28
|
+
_comdlg32 = DebugLibrary("comdlg32")
|
|
26
29
|
|
|
27
30
|
# _gdi32
|
|
28
31
|
_gdi32.AddFontMemResourceEx.restype = HANDLE
|
|
@@ -259,8 +262,13 @@ _dwmapi.DwmFlush.restype = c_int
|
|
|
259
262
|
_dwmapi.DwmFlush.argtypes = []
|
|
260
263
|
_dwmapi.DwmGetColorizationColor.restype = HRESULT
|
|
261
264
|
_dwmapi.DwmGetColorizationColor.argtypes = [POINTER(DWORD), POINTER(BOOL)]
|
|
265
|
+
_dwmapi.DwmGetWindowAttribute.restype = HRESULT
|
|
266
|
+
_dwmapi.DwmGetWindowAttribute.argtypes = [HWND, DWORD, PVOID, DWORD]
|
|
262
267
|
_dwmapi.DwmEnableBlurBehindWindow.restype = HRESULT
|
|
263
268
|
_dwmapi.DwmEnableBlurBehindWindow.argtypes = [HWND, POINTER(DWM_BLURBEHIND)]
|
|
269
|
+
_dwmapi.DwmSetWindowAttribute.restype = HRESULT
|
|
270
|
+
_dwmapi.DwmSetWindowAttribute.argtypes = [HWND, DWORD, LPCVOID, DWORD]
|
|
271
|
+
|
|
264
272
|
|
|
265
273
|
# _shell32
|
|
266
274
|
_shell32.DragAcceptFiles.restype = c_void
|
|
@@ -300,6 +308,21 @@ if constants.WINDOWS_8_1_OR_GREATER:
|
|
|
300
308
|
_shcore.GetDpiForMonitor.argtypes = [HMONITOR, MONITOR_DPI_TYPE, POINTER(UINT), POINTER(UINT)]
|
|
301
309
|
_shcore.GetDpiForMonitor.restype = HRESULT
|
|
302
310
|
|
|
311
|
+
# _advapi32
|
|
312
|
+
_advapi32.RegCloseKey.argtypes = [HKEY]
|
|
313
|
+
_advapi32.RegCloseKey.restype = LONG
|
|
314
|
+
_advapi32.RegOpenKeyExW.argtypes = [HKEY, LPCWSTR, DWORD, REGSAM, POINTER(HKEY)]
|
|
315
|
+
_advapi32.RegOpenKeyExW.restype = LONG
|
|
316
|
+
_advapi32.RegQueryValueExW.argtypes = [HKEY,LPCWSTR,LPVOID, POINTER(DWORD), LPBYTE, POINTER(DWORD)]
|
|
317
|
+
_advapi32.RegQueryValueExW.restype = LONG
|
|
318
|
+
|
|
319
|
+
# _comdlg32
|
|
320
|
+
_comdlg32.GetOpenFileNameW.argtypes = [POINTER(OPENFILENAMEW)]
|
|
321
|
+
_comdlg32.GetOpenFileNameW.restype = BOOL
|
|
322
|
+
_comdlg32.GetSaveFileNameW.argtypes = [POINTER(OPENFILENAMEW)]
|
|
323
|
+
_comdlg32.GetSaveFileNameW.restype = BOOL
|
|
324
|
+
|
|
325
|
+
|
|
303
326
|
if _debug_win32:
|
|
304
327
|
import traceback
|
|
305
328
|
|
|
@@ -309,8 +332,7 @@ if _debug_win32:
|
|
|
309
332
|
def win32_errcheck(result, func, args):
|
|
310
333
|
last_err = ctypes.get_last_error()
|
|
311
334
|
if last_err != 0: # If the result is not success and last error is invalid.
|
|
312
|
-
|
|
313
|
-
_log_win32.write(entry)
|
|
335
|
+
_log_win32.writelines(traceback.format_list(traceback.extract_stack()[:-1]))
|
|
314
336
|
print(f"[Result {result}] Error #{last_err} - {ctypes.FormatError(last_err)}", file=_log_win32)
|
|
315
337
|
return args
|
|
316
338
|
|
|
@@ -333,7 +355,7 @@ if _debug_win32:
|
|
|
333
355
|
|
|
334
356
|
# Initialize COM. Required for: WIC (DirectWrite), WMF, and XInput
|
|
335
357
|
try:
|
|
336
|
-
if pyglet.options
|
|
358
|
+
if pyglet.options.com_mta is True:
|
|
337
359
|
_ole32.CoInitializeEx(None, constants.COINIT_MULTITHREADED)
|
|
338
360
|
else:
|
|
339
361
|
_ole32.CoInitializeEx(None, constants.COINIT_APARTMENTTHREADED)
|
pyglet/libs/win32/constants.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
1
2
|
import sys
|
|
2
3
|
|
|
3
4
|
# Most of this file is win32con.py from Python for Windows Extensions:
|
|
@@ -19,24 +20,24 @@ VK_OEM_7 = 0xde
|
|
|
19
20
|
VK_OEM_8 = 0xdf
|
|
20
21
|
VK_OEM_102 = 0xe2
|
|
21
22
|
|
|
22
|
-
# Copyright (c) 1994-2001, Mark Hammond
|
|
23
|
+
# Copyright (c) 1994-2001, Mark Hammond
|
|
23
24
|
# All rights reserved.
|
|
24
|
-
#
|
|
25
|
-
# Redistribution and use in source and binary forms, with or without
|
|
26
|
-
# modification, are permitted provided that the following conditions
|
|
25
|
+
#
|
|
26
|
+
# Redistribution and use in source and binary forms, with or without
|
|
27
|
+
# modification, are permitted provided that the following conditions
|
|
27
28
|
# are met:
|
|
28
|
-
#
|
|
29
|
-
# Redistributions of source code must retain the above copyright notice,
|
|
29
|
+
#
|
|
30
|
+
# Redistributions of source code must retain the above copyright notice,
|
|
30
31
|
# this list of conditions and the following disclaimer.
|
|
31
|
-
#
|
|
32
|
-
# Redistributions in binary form must reproduce the above copyright
|
|
33
|
-
# notice, this list of conditions and the following disclaimer in
|
|
32
|
+
#
|
|
33
|
+
# Redistributions in binary form must reproduce the above copyright
|
|
34
|
+
# notice, this list of conditions and the following disclaimer in
|
|
34
35
|
# the documentation and/or other materials provided with the distribution.
|
|
35
|
-
#
|
|
36
|
-
# Neither name of Mark Hammond nor the name of contributors may be used
|
|
37
|
-
# to endorse or promote products derived from this software without
|
|
38
|
-
# specific prior written permission.
|
|
39
|
-
#
|
|
36
|
+
#
|
|
37
|
+
# Neither name of Mark Hammond nor the name of contributors may be used
|
|
38
|
+
# to endorse or promote products derived from this software without
|
|
39
|
+
# specific prior written permission.
|
|
40
|
+
#
|
|
40
41
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
|
|
41
42
|
# IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
42
43
|
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
|
@@ -3509,7 +3510,7 @@ ELF_CULTURE_LATIN = 0
|
|
|
3509
3510
|
RASTER_FONTTYPE = 1
|
|
3510
3511
|
DEVICE_FONTTYPE = 2
|
|
3511
3512
|
TRUETYPE_FONTTYPE = 4
|
|
3512
|
-
def PALETTEINDEX(i): return (
|
|
3513
|
+
def PALETTEINDEX(i): return (16777216 | (i))
|
|
3513
3514
|
|
|
3514
3515
|
PC_RESERVED = 1
|
|
3515
3516
|
PC_EXPLICIT = 2
|
|
@@ -3564,42 +3565,42 @@ STOCK_LAST = 16
|
|
|
3564
3565
|
CLR_INVALID = -1
|
|
3565
3566
|
|
|
3566
3567
|
# Exception/Status codes from winuser.h and winnt.h
|
|
3567
|
-
STATUS_WAIT_0 = 0
|
|
3568
|
-
STATUS_ABANDONED_WAIT_0 = 128
|
|
3569
|
-
STATUS_USER_APC = 192
|
|
3570
|
-
STATUS_TIMEOUT = 258
|
|
3571
|
-
STATUS_PENDING = 259
|
|
3572
|
-
STATUS_SEGMENT_NOTIFICATION = 1073741829
|
|
3573
|
-
STATUS_GUARD_PAGE_VIOLATION = -2147483647
|
|
3574
|
-
STATUS_DATATYPE_MISALIGNMENT = -2147483646
|
|
3575
|
-
STATUS_BREAKPOINT = -2147483645
|
|
3576
|
-
STATUS_SINGLE_STEP = -2147483644
|
|
3577
|
-
STATUS_ACCESS_VIOLATION = -1073741819
|
|
3578
|
-
STATUS_IN_PAGE_ERROR = -1073741818
|
|
3579
|
-
STATUS_INVALID_HANDLE = -1073741816
|
|
3580
|
-
STATUS_NO_MEMORY = -1073741801
|
|
3581
|
-
STATUS_ILLEGAL_INSTRUCTION = -1073741795
|
|
3582
|
-
STATUS_NONCONTINUABLE_EXCEPTION = -1073741787
|
|
3583
|
-
STATUS_INVALID_DISPOSITION = -1073741786
|
|
3584
|
-
STATUS_ARRAY_BOUNDS_EXCEEDED = -1073741684
|
|
3585
|
-
STATUS_FLOAT_DENORMAL_OPERAND = -1073741683
|
|
3586
|
-
STATUS_FLOAT_DIVIDE_BY_ZERO = -1073741682
|
|
3587
|
-
STATUS_FLOAT_INEXACT_RESULT = -1073741681
|
|
3588
|
-
STATUS_FLOAT_INVALID_OPERATION = -1073741680
|
|
3589
|
-
STATUS_FLOAT_OVERFLOW = -1073741679
|
|
3590
|
-
STATUS_FLOAT_STACK_CHECK = -1073741678
|
|
3591
|
-
STATUS_FLOAT_UNDERFLOW = -1073741677
|
|
3592
|
-
STATUS_INTEGER_DIVIDE_BY_ZERO = -1073741676
|
|
3593
|
-
STATUS_INTEGER_OVERFLOW = -1073741675
|
|
3594
|
-
STATUS_PRIVILEGED_INSTRUCTION = -1073741674
|
|
3595
|
-
STATUS_STACK_OVERFLOW = -1073741571
|
|
3596
|
-
STATUS_CONTROL_C_EXIT = -1073741510
|
|
3568
|
+
STATUS_WAIT_0 = 0
|
|
3569
|
+
STATUS_ABANDONED_WAIT_0 = 128
|
|
3570
|
+
STATUS_USER_APC = 192
|
|
3571
|
+
STATUS_TIMEOUT = 258
|
|
3572
|
+
STATUS_PENDING = 259
|
|
3573
|
+
STATUS_SEGMENT_NOTIFICATION = 1073741829
|
|
3574
|
+
STATUS_GUARD_PAGE_VIOLATION = -2147483647
|
|
3575
|
+
STATUS_DATATYPE_MISALIGNMENT = -2147483646
|
|
3576
|
+
STATUS_BREAKPOINT = -2147483645
|
|
3577
|
+
STATUS_SINGLE_STEP = -2147483644
|
|
3578
|
+
STATUS_ACCESS_VIOLATION = -1073741819
|
|
3579
|
+
STATUS_IN_PAGE_ERROR = -1073741818
|
|
3580
|
+
STATUS_INVALID_HANDLE = -1073741816
|
|
3581
|
+
STATUS_NO_MEMORY = -1073741801
|
|
3582
|
+
STATUS_ILLEGAL_INSTRUCTION = -1073741795
|
|
3583
|
+
STATUS_NONCONTINUABLE_EXCEPTION = -1073741787
|
|
3584
|
+
STATUS_INVALID_DISPOSITION = -1073741786
|
|
3585
|
+
STATUS_ARRAY_BOUNDS_EXCEEDED = -1073741684
|
|
3586
|
+
STATUS_FLOAT_DENORMAL_OPERAND = -1073741683
|
|
3587
|
+
STATUS_FLOAT_DIVIDE_BY_ZERO = -1073741682
|
|
3588
|
+
STATUS_FLOAT_INEXACT_RESULT = -1073741681
|
|
3589
|
+
STATUS_FLOAT_INVALID_OPERATION = -1073741680
|
|
3590
|
+
STATUS_FLOAT_OVERFLOW = -1073741679
|
|
3591
|
+
STATUS_FLOAT_STACK_CHECK = -1073741678
|
|
3592
|
+
STATUS_FLOAT_UNDERFLOW = -1073741677
|
|
3593
|
+
STATUS_INTEGER_DIVIDE_BY_ZERO = -1073741676
|
|
3594
|
+
STATUS_INTEGER_OVERFLOW = -1073741675
|
|
3595
|
+
STATUS_PRIVILEGED_INSTRUCTION = -1073741674
|
|
3596
|
+
STATUS_STACK_OVERFLOW = -1073741571
|
|
3597
|
+
STATUS_CONTROL_C_EXIT = -1073741510
|
|
3597
3598
|
|
|
3598
3599
|
|
|
3599
3600
|
WAIT_FAILED = -1
|
|
3600
3601
|
WAIT_OBJECT_0 = STATUS_WAIT_0 + 0
|
|
3601
3602
|
|
|
3602
|
-
WAIT_ABANDONED = STATUS_ABANDONED_WAIT_0 + 0
|
|
3603
|
+
WAIT_ABANDONED = STATUS_ABANDONED_WAIT_0 + 0
|
|
3603
3604
|
WAIT_ABANDONED_0 = STATUS_ABANDONED_WAIT_0 + 0
|
|
3604
3605
|
|
|
3605
3606
|
WAIT_TIMEOUT = STATUS_TIMEOUT
|
|
@@ -4186,7 +4187,7 @@ PM_NOREMOVE = 0
|
|
|
4186
4187
|
PM_REMOVE = 1
|
|
4187
4188
|
PM_NOYIELD = 2
|
|
4188
4189
|
# Name clashes with key.MOD_ALT, key.MOD_CONTROL and key.MOD_SHIFT
|
|
4189
|
-
WIN32_MOD_ALT = 1
|
|
4190
|
+
WIN32_MOD_ALT = 1
|
|
4190
4191
|
WIN32_MOD_CONTROL = 2
|
|
4191
4192
|
WIN32_MOD_SHIFT = 4
|
|
4192
4193
|
WIN32_MOD_WIN = 8
|
|
@@ -5037,6 +5038,7 @@ WINDOWS_8_1_OR_GREATER = sys.getwindowsversion() >= (6, 3)
|
|
|
5037
5038
|
WINDOWS_10_ANNIVERSARY_UPDATE_OR_GREATER = sys.getwindowsversion() >= (10, 0, 14393) # 1607
|
|
5038
5039
|
WINDOWS_10_CREATORS_UPDATE_OR_GREATER = sys.getwindowsversion() >= (10, 0, 15063) # 1703
|
|
5039
5040
|
WINDOWS_10_1809_OR_GREATER = sys.getwindowsversion() >= (10, 0, 17763) # 1809
|
|
5041
|
+
WINDOWS_11_21H2_OR_GREATER = sys.getwindowsversion() >= (10, 0, 22000)
|
|
5040
5042
|
|
|
5041
5043
|
MSGFLT_ALLOW = 1
|
|
5042
5044
|
MSGFLT_DISALLOW = 2
|
|
@@ -5086,4 +5088,13 @@ USER_DEFAULT_SCREEN_DPI = 96
|
|
|
5086
5088
|
|
|
5087
5089
|
QDC_ONLY_ACTIVE_PATHS = 0x00000002
|
|
5088
5090
|
DISPLAYCONFIG_DEVICE_INFO_GET_SOURCE_NAME = 0x00000001
|
|
5089
|
-
DISPLAYCONFIG_DEVICE_INFO_GET_TARGET_NAME = 0x00000002
|
|
5091
|
+
DISPLAYCONFIG_DEVICE_INFO_GET_TARGET_NAME = 0x00000002
|
|
5092
|
+
|
|
5093
|
+
# Since Windows 11 21H2
|
|
5094
|
+
DWMWA_USE_IMMERSIVE_DARK_MODE = 20
|
|
5095
|
+
DWMWA_WINDOW_CORNER_PREFERENCE = 33
|
|
5096
|
+
DWMWA_BORDER_COLOR = 34
|
|
5097
|
+
DWMWA_CAPTION_COLOR = 35
|
|
5098
|
+
DWMWA_TEXT_COLOR = 36
|
|
5099
|
+
DWMWA_VISIBLE_FRAME_BORDER_THICKNESS = 37
|
|
5100
|
+
DWMWA_SYSTEMBACKDROP_TYPE = 38
|
|
@@ -27,15 +27,20 @@ After::
|
|
|
27
27
|
return result
|
|
28
28
|
|
|
29
29
|
"""
|
|
30
|
+
from __future__ import annotations
|
|
31
|
+
|
|
30
32
|
from contextlib import contextmanager
|
|
31
|
-
from typing import
|
|
32
|
-
from ctypes.wintypes import HANDLE
|
|
33
|
+
from typing import Generator, TYPE_CHECKING
|
|
33
34
|
from ctypes import WinError
|
|
34
35
|
from pyglet.libs.win32 import _user32 as user32
|
|
35
36
|
|
|
37
|
+
if TYPE_CHECKING:
|
|
38
|
+
from pyglet.libs.win32.com import COMObject
|
|
39
|
+
from ctypes.wintypes import HANDLE
|
|
40
|
+
|
|
36
41
|
|
|
37
42
|
@contextmanager
|
|
38
|
-
def device_context(window_handle:
|
|
43
|
+
def device_context(window_handle: int | None = None) -> Generator[HANDLE, None, None]:
|
|
39
44
|
"""
|
|
40
45
|
A Windows device context wrapped as a context manager.
|
|
41
46
|
|
|
@@ -55,3 +60,15 @@ def device_context(window_handle: Optional[int] = None) -> Generator[HANDLE, Non
|
|
|
55
60
|
finally:
|
|
56
61
|
if not user32.ReleaseDC(None, _dc):
|
|
57
62
|
raise WinError()
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
@contextmanager
|
|
66
|
+
def com_context(com_object: COMObject) -> Generator[COMObject, None, None]:
|
|
67
|
+
"""A simple context manager for a COM object.
|
|
68
|
+
|
|
69
|
+
This can help reduce missed release calls leading to leaks.
|
|
70
|
+
"""
|
|
71
|
+
try:
|
|
72
|
+
yield com_object
|
|
73
|
+
finally:
|
|
74
|
+
com_object.Release()
|
pyglet/libs/win32/dinput.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
import ctypes
|
|
4
|
-
from ctypes.wintypes import BOOL, DWORD, HANDLE, HWND, LPDWORD, LPVOID, UINT, WCHAR, WORD
|
|
4
|
+
from ctypes.wintypes import BOOL, DWORD, HANDLE, HWND, LONG, LPDWORD, LPVOID, UINT, WCHAR, WORD
|
|
5
5
|
|
|
6
6
|
from pyglet.libs.win32 import com
|
|
7
7
|
|
|
@@ -122,8 +122,10 @@ DIDC_ALIAS = 0x00010000
|
|
|
122
122
|
DIDC_PHANTOM = 0x00020000
|
|
123
123
|
DIDC_HIDDEN = 0x00040000
|
|
124
124
|
|
|
125
|
+
|
|
125
126
|
def DIDFT_GETINSTANCE(n):
|
|
126
|
-
return (n >> 8) &
|
|
127
|
+
return (n >> 8) & 0xFFFF
|
|
128
|
+
|
|
127
129
|
|
|
128
130
|
DIDFT_ALL = 0x00000000
|
|
129
131
|
|
|
@@ -204,8 +206,7 @@ DISCL_NOWINKEY = 0x00000010
|
|
|
204
206
|
DIPROP_BUFFERSIZE = 1
|
|
205
207
|
DIPROP_GUIDANDPATH = 12
|
|
206
208
|
|
|
207
|
-
GUID_XAxis =
|
|
208
|
-
com.GUID(0xA36D02E0,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00)
|
|
209
|
+
GUID_XAxis = com.GUID(0xA36D02E0, 0xC9F3, 0x11CF, 0xBF, 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00)
|
|
209
210
|
|
|
210
211
|
|
|
211
212
|
class DIDEVICEINSTANCE(ctypes.Structure):
|
|
@@ -220,9 +221,12 @@ class DIDEVICEINSTANCE(ctypes.Structure):
|
|
|
220
221
|
('wUsagePage', WORD),
|
|
221
222
|
('wUsage', WORD),
|
|
222
223
|
)
|
|
224
|
+
|
|
225
|
+
|
|
223
226
|
LPDIDEVICEINSTANCE = ctypes.POINTER(DIDEVICEINSTANCE)
|
|
224
227
|
LPDIENUMDEVICESCALLBACK = ctypes.WINFUNCTYPE(BOOL, LPDIDEVICEINSTANCE, LPVOID)
|
|
225
228
|
|
|
229
|
+
|
|
226
230
|
class DIDEVICEOBJECTINSTANCE(ctypes.Structure):
|
|
227
231
|
_fields_ = (
|
|
228
232
|
('dwSize', DWORD),
|
|
@@ -241,9 +245,11 @@ class DIDEVICEOBJECTINSTANCE(ctypes.Structure):
|
|
|
241
245
|
('wExponent', WORD),
|
|
242
246
|
('wReportId', WORD),
|
|
243
247
|
)
|
|
248
|
+
|
|
249
|
+
|
|
244
250
|
LPDIDEVICEOBJECTINSTANCE = ctypes.POINTER(DIDEVICEOBJECTINSTANCE)
|
|
245
|
-
LPDIENUMDEVICEOBJECTSCALLBACK =
|
|
246
|
-
|
|
251
|
+
LPDIENUMDEVICEOBJECTSCALLBACK = ctypes.WINFUNCTYPE(BOOL, LPDIDEVICEOBJECTINSTANCE, LPVOID)
|
|
252
|
+
|
|
247
253
|
|
|
248
254
|
class DIOBJECTDATAFORMAT(ctypes.Structure):
|
|
249
255
|
_fields_ = (
|
|
@@ -253,8 +259,11 @@ class DIOBJECTDATAFORMAT(ctypes.Structure):
|
|
|
253
259
|
('dwFlags', DWORD),
|
|
254
260
|
)
|
|
255
261
|
__slots__ = [n for n, t in _fields_]
|
|
262
|
+
|
|
263
|
+
|
|
256
264
|
LPDIOBJECTDATAFORMAT = ctypes.POINTER(DIOBJECTDATAFORMAT)
|
|
257
265
|
|
|
266
|
+
|
|
258
267
|
class DIDATAFORMAT(ctypes.Structure):
|
|
259
268
|
_fields_ = (
|
|
260
269
|
('dwSize', DWORD),
|
|
@@ -265,8 +274,11 @@ class DIDATAFORMAT(ctypes.Structure):
|
|
|
265
274
|
('rgodf', LPDIOBJECTDATAFORMAT),
|
|
266
275
|
)
|
|
267
276
|
__slots__ = [n for n, t in _fields_]
|
|
277
|
+
|
|
278
|
+
|
|
268
279
|
LPDIDATAFORMAT = ctypes.POINTER(DIDATAFORMAT)
|
|
269
280
|
|
|
281
|
+
|
|
270
282
|
class DIDEVICEOBJECTDATA(ctypes.Structure):
|
|
271
283
|
_fields_ = (
|
|
272
284
|
('dwOfs', DWORD),
|
|
@@ -275,8 +287,11 @@ class DIDEVICEOBJECTDATA(ctypes.Structure):
|
|
|
275
287
|
('dwSequence', DWORD),
|
|
276
288
|
('uAppData', ctypes.POINTER(UINT)),
|
|
277
289
|
)
|
|
290
|
+
|
|
291
|
+
|
|
278
292
|
LPDIDEVICEOBJECTDATA = ctypes.POINTER(DIDEVICEOBJECTDATA)
|
|
279
293
|
|
|
294
|
+
|
|
280
295
|
class DIPROPHEADER(ctypes.Structure):
|
|
281
296
|
_fields_ = (
|
|
282
297
|
('dwSize', DWORD),
|
|
@@ -284,109 +299,111 @@ class DIPROPHEADER(ctypes.Structure):
|
|
|
284
299
|
('dwObj', DWORD),
|
|
285
300
|
('dwHow', DWORD),
|
|
286
301
|
)
|
|
302
|
+
|
|
303
|
+
|
|
287
304
|
LPDIPROPHEADER = ctypes.POINTER(DIPROPHEADER)
|
|
288
305
|
|
|
306
|
+
|
|
289
307
|
class DIPROPDWORD(ctypes.Structure):
|
|
290
308
|
_fields_ = (
|
|
291
309
|
('diph', DIPROPHEADER),
|
|
292
310
|
('dwData', DWORD),
|
|
293
311
|
)
|
|
294
312
|
|
|
313
|
+
|
|
295
314
|
# All method names in the interfaces are filled in, but unused (so far)
|
|
296
315
|
# methods have no parameters.. they'll crash when we try and use them, at
|
|
297
316
|
# which point we can go in and fill them in.
|
|
298
317
|
|
|
318
|
+
|
|
319
|
+
# Define DIJOYSTATE2 based on the C++ struct
|
|
320
|
+
class DIJOYSTATE2(ctypes.Structure):
|
|
321
|
+
_fields_ = [
|
|
322
|
+
("lX", LONG), # X-axis
|
|
323
|
+
("lY", LONG), # Y-axis
|
|
324
|
+
("lZ", LONG), # Z-axis
|
|
325
|
+
("lRx", LONG), # X-axis rotation
|
|
326
|
+
("lRy", LONG), # Y-axis rotation
|
|
327
|
+
("lRz", LONG), # Z-axis rotation
|
|
328
|
+
("rglSlider", LONG * 2), # Two slider axes
|
|
329
|
+
("rgdwPOV", DWORD * 4), # Four POVs (D-pad directions)
|
|
330
|
+
("rgbButtons", ctypes.c_ubyte * 128), # 128 buttons
|
|
331
|
+
("lVX", LONG), # X-axis velocity
|
|
332
|
+
("lVY", LONG), # Y-axis velocity
|
|
333
|
+
("lVZ", LONG), # Z-axis velocity
|
|
334
|
+
("lVRx", LONG), # Angular velocity X
|
|
335
|
+
("lVRy", LONG), # Angular velocity Y
|
|
336
|
+
("lVRz", LONG), # Angular velocity Z
|
|
337
|
+
("rglVSlider", LONG * 2),
|
|
338
|
+
("lAX", LONG), # Acceleration X
|
|
339
|
+
("lAY", LONG), # Acceleration Y
|
|
340
|
+
("lAZ", LONG), # Acceleration Z
|
|
341
|
+
("lARx", LONG), # Angular acceleration X
|
|
342
|
+
("lARy", LONG), # Angular acceleration Y
|
|
343
|
+
("lARz", LONG), # Angular acceleration Z
|
|
344
|
+
("rglASlider", LONG * 2),
|
|
345
|
+
("lFX", LONG), # Force X
|
|
346
|
+
("lFY", LONG), # Force Y
|
|
347
|
+
("lFZ", LONG), # Force Z
|
|
348
|
+
("lFRx", LONG), # Force angular X
|
|
349
|
+
("lFRy", LONG), # Force angular Y
|
|
350
|
+
("lFRz", LONG), # Force angular Z
|
|
351
|
+
("rglFSlider", LONG * 2),
|
|
352
|
+
]
|
|
353
|
+
|
|
354
|
+
|
|
299
355
|
# IDirect* interfaces are all Unicode (e.g. IDirectInputDevice8W).
|
|
300
356
|
|
|
357
|
+
|
|
301
358
|
class IDirectInputDevice8(com.pIUnknown):
|
|
302
359
|
_methods_ = [
|
|
303
|
-
('GetCapabilities',
|
|
304
|
-
|
|
305
|
-
('
|
|
306
|
-
|
|
307
|
-
('
|
|
308
|
-
|
|
309
|
-
('
|
|
310
|
-
|
|
311
|
-
('
|
|
312
|
-
|
|
313
|
-
('
|
|
314
|
-
|
|
315
|
-
('
|
|
316
|
-
|
|
317
|
-
('
|
|
318
|
-
|
|
319
|
-
('
|
|
320
|
-
|
|
321
|
-
('
|
|
322
|
-
|
|
323
|
-
('
|
|
324
|
-
|
|
325
|
-
('
|
|
326
|
-
|
|
327
|
-
('
|
|
328
|
-
|
|
329
|
-
('
|
|
330
|
-
|
|
331
|
-
('
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
com.STDMETHOD()),
|
|
335
|
-
('EnumEffects',
|
|
336
|
-
com.STDMETHOD()),
|
|
337
|
-
('GetEffectInfo',
|
|
338
|
-
com.STDMETHOD()),
|
|
339
|
-
('GetForceFeedbackState',
|
|
340
|
-
com.STDMETHOD()),
|
|
341
|
-
('SendForceFeedbackCommand',
|
|
342
|
-
com.STDMETHOD()),
|
|
343
|
-
('EnumCreatedEffectObjects',
|
|
344
|
-
com.STDMETHOD()),
|
|
345
|
-
('Escape',
|
|
346
|
-
com.STDMETHOD()),
|
|
347
|
-
('Poll',
|
|
348
|
-
com.STDMETHOD()),
|
|
349
|
-
('SendDeviceData',
|
|
350
|
-
com.STDMETHOD()),
|
|
351
|
-
('EnumEffectsInFile',
|
|
352
|
-
com.STDMETHOD()),
|
|
353
|
-
('WriteEffectToFile',
|
|
354
|
-
com.STDMETHOD()),
|
|
355
|
-
('BuildActionMap',
|
|
356
|
-
com.STDMETHOD()),
|
|
357
|
-
('SetActionMap',
|
|
358
|
-
com.STDMETHOD()),
|
|
359
|
-
('GetImageInfo',
|
|
360
|
-
com.STDMETHOD()),
|
|
361
|
-
]
|
|
360
|
+
('GetCapabilities', com.STDMETHOD()),
|
|
361
|
+
('EnumObjects', com.STDMETHOD(LPDIENUMDEVICEOBJECTSCALLBACK, LPVOID, DWORD)),
|
|
362
|
+
('GetProperty', com.STDMETHOD(LPVOID, LPDIPROPHEADER)),
|
|
363
|
+
('SetProperty', com.STDMETHOD(LPVOID, LPDIPROPHEADER)),
|
|
364
|
+
('Acquire', com.STDMETHOD()),
|
|
365
|
+
('Unacquire', com.STDMETHOD()),
|
|
366
|
+
('GetDeviceState', com.STDMETHOD(DWORD, LPVOID)),
|
|
367
|
+
('GetDeviceData', com.STDMETHOD(DWORD, LPDIDEVICEOBJECTDATA, LPDWORD, DWORD)),
|
|
368
|
+
('SetDataFormat', com.STDMETHOD(LPDIDATAFORMAT)),
|
|
369
|
+
('SetEventNotification', com.STDMETHOD(HANDLE)),
|
|
370
|
+
('SetCooperativeLevel', com.STDMETHOD(HWND, DWORD)),
|
|
371
|
+
('GetObjectInfo', com.STDMETHOD()),
|
|
372
|
+
('GetDeviceInfo', com.STDMETHOD()),
|
|
373
|
+
('RunControlPanel', com.STDMETHOD()),
|
|
374
|
+
('Initialize', com.STDMETHOD()),
|
|
375
|
+
('CreateEffect', com.STDMETHOD()),
|
|
376
|
+
('EnumEffects', com.STDMETHOD()),
|
|
377
|
+
('GetEffectInfo', com.STDMETHOD()),
|
|
378
|
+
('GetForceFeedbackState', com.STDMETHOD()),
|
|
379
|
+
('SendForceFeedbackCommand', com.STDMETHOD()),
|
|
380
|
+
('EnumCreatedEffectObjects', com.STDMETHOD()),
|
|
381
|
+
('Escape', com.STDMETHOD()),
|
|
382
|
+
('Poll', com.STDMETHOD()),
|
|
383
|
+
('SendDeviceData', com.STDMETHOD()),
|
|
384
|
+
('EnumEffectsInFile', com.STDMETHOD()),
|
|
385
|
+
('WriteEffectToFile', com.STDMETHOD()),
|
|
386
|
+
('BuildActionMap', com.STDMETHOD()),
|
|
387
|
+
('SetActionMap', com.STDMETHOD()),
|
|
388
|
+
('GetImageInfo', com.STDMETHOD()),
|
|
389
|
+
]
|
|
390
|
+
|
|
362
391
|
|
|
363
392
|
class IDirectInput8(com.pIUnknown):
|
|
364
393
|
_methods_ = [
|
|
365
|
-
('CreateDevice',
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
('
|
|
370
|
-
|
|
371
|
-
('
|
|
372
|
-
|
|
373
|
-
('RunControlPanel',
|
|
374
|
-
com.STDMETHOD()),
|
|
375
|
-
('Initialize',
|
|
376
|
-
com.STDMETHOD()),
|
|
377
|
-
('FindDevice',
|
|
378
|
-
com.STDMETHOD()),
|
|
379
|
-
('EnumDevicesBySemantics',
|
|
380
|
-
com.STDMETHOD()),
|
|
381
|
-
('ConfigureDevices',
|
|
382
|
-
com.STDMETHOD()),
|
|
394
|
+
('CreateDevice', com.STDMETHOD(ctypes.POINTER(com.GUID), ctypes.POINTER(IDirectInputDevice8), ctypes.c_void_p)),
|
|
395
|
+
('EnumDevices', com.STDMETHOD(DWORD, LPDIENUMDEVICESCALLBACK, LPVOID, DWORD)),
|
|
396
|
+
('GetDeviceStatus', com.STDMETHOD()),
|
|
397
|
+
('RunControlPanel', com.STDMETHOD()),
|
|
398
|
+
('Initialize', com.STDMETHOD()),
|
|
399
|
+
('FindDevice', com.STDMETHOD()),
|
|
400
|
+
('EnumDevicesBySemantics', com.STDMETHOD()),
|
|
401
|
+
('ConfigureDevices', com.STDMETHOD()),
|
|
383
402
|
]
|
|
384
403
|
|
|
385
|
-
|
|
386
|
-
|
|
404
|
+
|
|
405
|
+
IID_IDirectInput8W = com.GUID(0xBF798031, 0x483A, 0x4DA2, 0xAA, 0x99, 0x5D, 0x64, 0xED, 0x36, 0x97, 0x00)
|
|
387
406
|
|
|
388
407
|
DIRECTINPUT_VERSION = 0x0800
|
|
389
408
|
DirectInput8Create = lib.DirectInput8Create
|
|
390
|
-
DirectInput8Create.argtypes =
|
|
391
|
-
(ctypes.c_void_p, DWORD, com.LPGUID, ctypes.c_void_p, ctypes.c_void_p)
|
|
392
|
-
|
|
409
|
+
DirectInput8Create.argtypes = (ctypes.c_void_p, DWORD, com.LPGUID, ctypes.c_void_p, ctypes.c_void_p)
|
|
@@ -5,12 +5,12 @@ from ctypes import CFUNCTYPE, POINTER, c_char_p, c_int, cast
|
|
|
5
5
|
from typing import Any, Callable, Sequence
|
|
6
6
|
|
|
7
7
|
import pyglet
|
|
8
|
-
from pyglet.gl.lib import decorate_function, missing_function
|
|
8
|
+
from pyglet.graphics.api.gl.lib import decorate_function, missing_function
|
|
9
9
|
from pyglet.util import asbytes
|
|
10
10
|
|
|
11
|
-
__all__ = ['link_GL', 'link_WGL']
|
|
11
|
+
__all__ = ['link_GL', 'link_GL_proxy', 'link_WGL', 'link_WGL_proxy']
|
|
12
12
|
|
|
13
|
-
_debug_trace = pyglet.options
|
|
13
|
+
_debug_trace = pyglet.options.debug_trace
|
|
14
14
|
|
|
15
15
|
gl_lib = ctypes.windll.opengl32
|
|
16
16
|
wgl_lib = gl_lib
|
|
@@ -22,7 +22,7 @@ if _debug_trace:
|
|
|
22
22
|
wgl_lib = _TraceLibrary(wgl_lib)
|
|
23
23
|
|
|
24
24
|
try:
|
|
25
|
-
wglGetProcAddress = wgl_lib.wglGetProcAddress
|
|
25
|
+
wglGetProcAddress = wgl_lib.wglGetProcAddress
|
|
26
26
|
wglGetProcAddress.restype = CFUNCTYPE(POINTER(c_int))
|
|
27
27
|
wglGetProcAddress.argtypes = [c_char_p]
|
|
28
28
|
_have_get_proc_address = True
|
|
@@ -53,8 +53,7 @@ class WGLFunctionProxy:
|
|
|
53
53
|
self.func = None
|
|
54
54
|
|
|
55
55
|
def __call__(self, *args: Any, **kwargs: Any) -> Callable:
|
|
56
|
-
|
|
57
|
-
if not current_context:
|
|
56
|
+
if not pyglet.graphics.api.core:
|
|
58
57
|
msg = f'Call to function "{self.name}" before GL context created'
|
|
59
58
|
raise Exception(msg)
|
|
60
59
|
address = wglGetProcAddress(asbytes(self.name))
|
|
@@ -70,8 +69,15 @@ class WGLFunctionProxy:
|
|
|
70
69
|
return self.func(*args, **kwargs)
|
|
71
70
|
|
|
72
71
|
|
|
73
|
-
def
|
|
72
|
+
def link_GL_proxy(name: str, restype: Any, argtypes: Any, requires: str | None = None, # noqa: N802
|
|
74
73
|
suggestions: Sequence[str] | None = None) -> Callable[..., Any]:
|
|
74
|
+
"""Link a GL function using a proxy address.
|
|
75
|
+
|
|
76
|
+
Most functions are not exposed in opengl32.dll, so the majority will be created via wglGetProcAddress.
|
|
77
|
+
|
|
78
|
+
If a context is not created, a proxy function will be created in its place. Through this implementation,
|
|
79
|
+
OpenGL functions can be imported globally.
|
|
80
|
+
"""
|
|
75
81
|
try:
|
|
76
82
|
func = getattr(gl_lib, name)
|
|
77
83
|
func.restype = restype
|
|
@@ -79,26 +85,46 @@ def link_GL(name: str, restype: Any, argtypes: Any, requires: str | None = None,
|
|
|
79
85
|
decorate_function(func, name)
|
|
80
86
|
return func
|
|
81
87
|
except AttributeError:
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
if
|
|
87
|
-
|
|
88
|
-
if
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
# Insert proxy until we have a context
|
|
96
|
-
return WGLFunctionProxy(name, ftype, requires, suggestions)
|
|
97
|
-
except: # noqa: E722, S110
|
|
98
|
-
# TODO: Figure out what exception this can cause instead of catching all.
|
|
99
|
-
pass
|
|
88
|
+
fargs = (restype, *tuple(argtypes))
|
|
89
|
+
ftype = ctypes.WINFUNCTYPE(*fargs)
|
|
90
|
+
if _have_get_proc_address:
|
|
91
|
+
from pyglet.graphics.api import core
|
|
92
|
+
if core and core.have_context:
|
|
93
|
+
address = wglGetProcAddress(asbytes(name))
|
|
94
|
+
if cast(address, POINTER(c_int)): # check cast because address is func
|
|
95
|
+
func = cast(address, ftype)
|
|
96
|
+
decorate_function(func, name)
|
|
97
|
+
return func
|
|
98
|
+
else:
|
|
99
|
+
# Insert proxy until we have a context
|
|
100
|
+
return WGLFunctionProxy(name, ftype, requires, suggestions)
|
|
100
101
|
|
|
101
102
|
return missing_function(name, requires, suggestions)
|
|
102
103
|
|
|
104
|
+
def link_GL(name: str, restype: Any, argtypes: Any, requires: str | None = None, # noqa: N802
|
|
105
|
+
suggestions: Sequence[str] | None = None) -> Callable[..., Any]:
|
|
106
|
+
"""Link a GL function using a proxy address.
|
|
107
|
+
|
|
108
|
+
Requires an OpenGL context to be created and current.
|
|
109
|
+
"""
|
|
110
|
+
try:
|
|
111
|
+
func = getattr(gl_lib, name)
|
|
112
|
+
func.restype = restype
|
|
113
|
+
func.argtypes = argtypes
|
|
114
|
+
decorate_function(func, name)
|
|
115
|
+
return func
|
|
116
|
+
except AttributeError:
|
|
117
|
+
# Not in opengl32.dll. Try and get a pointer from WGL.
|
|
118
|
+
fargs = (restype, *tuple(argtypes))
|
|
119
|
+
ftype = ctypes.WINFUNCTYPE(*fargs)
|
|
120
|
+
if _have_get_proc_address:
|
|
121
|
+
address = wglGetProcAddress(asbytes(name))
|
|
122
|
+
if cast(address, POINTER(c_int)): # check cast because address is func
|
|
123
|
+
func = cast(address, ftype)
|
|
124
|
+
decorate_function(func, name)
|
|
125
|
+
return func
|
|
126
|
+
|
|
127
|
+
return missing_function(name, requires, suggestions)
|
|
103
128
|
|
|
104
|
-
link_WGL = link_GL
|
|
129
|
+
link_WGL = link_GL
|
|
130
|
+
link_WGL_proxy = link_GL_proxy
|