From 043378876a67b092f5d0d3d9748660121a336dd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 9 May 2024 17:18:39 +0200 Subject: [PATCH 01/36] Use CMakePushCheckState for check state management --- src/CMakeLists.txt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 463b898df..7a8726d1b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -313,30 +313,34 @@ if (GLFW_BUILD_SHARED_LIBRARY) if (MINGW) # Enable link-time exploit mitigation features enabled by default on MSVC include(CheckCCompilerFlag) + include(CMakePushCheckState) # Compatibility with data execution prevention (DEP) + cmake_push_check_state() set(CMAKE_REQUIRED_FLAGS "-Wl,--nxcompat") check_c_compiler_flag("" _GLFW_HAS_DEP) if (_GLFW_HAS_DEP) target_link_libraries(glfw PRIVATE "-Wl,--nxcompat") endif() + cmake_pop_check_state() # Compatibility with address space layout randomization (ASLR) + cmake_push_check_state() set(CMAKE_REQUIRED_FLAGS "-Wl,--dynamicbase") check_c_compiler_flag("" _GLFW_HAS_ASLR) if (_GLFW_HAS_ASLR) target_link_libraries(glfw PRIVATE "-Wl,--dynamicbase") endif() + cmake_pop_check_state() # Compatibility with 64-bit address space layout randomization (ASLR) + cmake_push_check_state() set(CMAKE_REQUIRED_FLAGS "-Wl,--high-entropy-va") check_c_compiler_flag("" _GLFW_HAS_64ASLR) if (_GLFW_HAS_64ASLR) target_link_libraries(glfw PRIVATE "-Wl,--high-entropy-va") endif() - - # Clear flags again to avoid breaking later tests - set(CMAKE_REQUIRED_FLAGS) + cmake_pop_check_state() endif() if (UNIX) From b850107a32e96ae36dc7b5f88cd337016e356404 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 10 May 2024 15:15:12 +0200 Subject: [PATCH 02/36] Update minimum CMake version to 3.16 This replaces some workarounds and manual logic with new features available with CMake 3.16, including list(FILTER), list(JOIN), foreach(IN LISTS) and enable_language(OBJC). Policy settings no longer needed with 3.16 have been removed. Related to #2541 --- CMake/GenerateMappings.cmake | 36 +++++++++++++++++++----------------- CMakeLists.txt | 31 +++---------------------------- README.md | 3 ++- docs/compile.md | 4 ++-- src/CMakeLists.txt | 16 +++------------- 5 files changed, 29 insertions(+), 61 deletions(-) diff --git a/CMake/GenerateMappings.cmake b/CMake/GenerateMappings.cmake index c8c9e23f2..9a95df6d8 100644 --- a/CMake/GenerateMappings.cmake +++ b/CMake/GenerateMappings.cmake @@ -1,6 +1,8 @@ # Usage: # cmake -P GenerateMappings.cmake +cmake_policy(VERSION 3.16) + set(source_url "https://raw.githubusercontent.com/gabomdq/SDL_GameControllerDB/master/gamecontrollerdb.txt") set(source_path "${CMAKE_CURRENT_BINARY_DIR}/gamecontrollerdb.txt") set(template_path "${CMAKE_ARGV3}") @@ -22,24 +24,24 @@ if (status_code) endif() file(STRINGS "${source_path}" lines) -foreach(line ${lines}) - if (line MATCHES "^[0-9a-fA-F]") - if (line MATCHES "platform:Windows") - if (GLFW_WIN32_MAPPINGS) - string(APPEND GLFW_WIN32_MAPPINGS "\n") - endif() - string(APPEND GLFW_WIN32_MAPPINGS "\"${line}\",") - elseif (line MATCHES "platform:Mac OS X") - if (GLFW_COCOA_MAPPINGS) - string(APPEND GLFW_COCOA_MAPPINGS "\n") - endif() - string(APPEND GLFW_COCOA_MAPPINGS "\"${line}\",") - elseif (line MATCHES "platform:Linux") - if (GLFW_LINUX_MAPPINGS) - string(APPEND GLFW_LINUX_MAPPINGS "\n") - endif() - string(APPEND GLFW_LINUX_MAPPINGS "\"${line}\",") +list(FILTER lines INCLUDE REGEX "^[0-9a-fA-F]") + +foreach(line IN LISTS lines) + if (line MATCHES "platform:Windows") + if (GLFW_WIN32_MAPPINGS) + string(APPEND GLFW_WIN32_MAPPINGS "\n") endif() + string(APPEND GLFW_WIN32_MAPPINGS "\"${line}\",") + elseif (line MATCHES "platform:Mac OS X") + if (GLFW_COCOA_MAPPINGS) + string(APPEND GLFW_COCOA_MAPPINGS "\n") + endif() + string(APPEND GLFW_COCOA_MAPPINGS "\"${line}\",") + elseif (line MATCHES "platform:Linux") + if (GLFW_LINUX_MAPPINGS) + string(APPEND GLFW_LINUX_MAPPINGS "\n") + endif() + string(APPEND GLFW_LINUX_MAPPINGS "\"${line}\",") endif() endforeach() diff --git a/CMakeLists.txt b/CMakeLists.txt index 830f8fd9a..398b36eb1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,14 +1,6 @@ -cmake_minimum_required(VERSION 3.4...3.28 FATAL_ERROR) +cmake_minimum_required(VERSION 3.16...3.28 FATAL_ERROR) -project(GLFW VERSION 3.5.0 LANGUAGES C) - -if (POLICY CMP0069) - cmake_policy(SET CMP0069 NEW) -endif() - -if (POLICY CMP0077) - cmake_policy(SET CMP0077 NEW) -endif() +project(GLFW VERSION 3.5.0 LANGUAGES C HOMEPAGE_URL "https://www.glfw.org/") set_property(GLOBAL PROPERTY USE_FOLDERS ON) @@ -80,24 +72,7 @@ endif() # This is here because it also applies to tests and examples #-------------------------------------------------------------------- if (MSVC AND NOT USE_MSVC_RUNTIME_LIBRARY_DLL) - if (CMAKE_VERSION VERSION_LESS 3.15) - foreach (flag CMAKE_C_FLAGS - CMAKE_C_FLAGS_DEBUG - CMAKE_C_FLAGS_RELEASE - CMAKE_C_FLAGS_MINSIZEREL - CMAKE_C_FLAGS_RELWITHDEBINFO) - - if (flag MATCHES "/MD") - string(REGEX REPLACE "/MD" "/MT" ${flag} "${${flag}}") - endif() - if (flag MATCHES "/MDd") - string(REGEX REPLACE "/MDd" "/MTd" ${flag} "${${flag}}") - endif() - - endforeach() - else() - set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") - endif() + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") endif() #-------------------------------------------------------------------- diff --git a/README.md b/README.md index 10044faf1..fb77b9ddf 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,7 @@ in the documentation for more information. ## Dependencies -GLFW itself needs only CMake 3.4 or later and the headers and libraries for your +GLFW itself needs only CMake 3.16 or later and the headers and libraries for your OS and window system. The examples and test programs depend on a number of tiny libraries. These are @@ -123,6 +123,7 @@ information on what to include when reporting a bug. - Added `GLFW_UNLIMITED_MOUSE_BUTTONS` input mode that allows mouse buttons beyond the limit of the mouse button tokens to be reported (#2423) + - Updated minimum CMake version to 3.16 (#2541) - [Cocoa] Added `QuartzCore` framework as link-time dependency - [Cocoa] Removed support for OS X 10.10 Yosemite and earlier (#2506) - [Wayland] Bugfix: The fractional scaling related objects were not destroyed diff --git a/docs/compile.md b/docs/compile.md index f8385fefa..6b0b71227 100644 --- a/docs/compile.md +++ b/docs/compile.md @@ -264,8 +264,8 @@ __USE_MSVC_RUNTIME_LIBRARY_DLL__ determines whether to use the DLL version or th static library version of the Visual C++ runtime library. When enabled, the DLL version of the Visual C++ library is used. This is enabled by default. -On CMake 3.15 and later you can set the standard CMake [CMAKE_MSVC_RUNTIME_LIBRARY][] -variable instead of this GLFW-specific option. +It is recommended to set the standard CMake variable [CMAKE_MSVC_RUNTIME_LIBRARY][] +instead of this GLFW-specific option. [CMAKE_MSVC_RUNTIME_LIBRARY]: https://cmake.org/cmake/help/latest/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7a8726d1b..fc4e17cf2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -30,6 +30,7 @@ add_custom_target(update_mappings set_target_properties(update_mappings PROPERTIES FOLDER "GLFW3") if (GLFW_BUILD_COCOA) + enable_language(OBJC) target_compile_definitions(glfw PRIVATE _GLFW_COCOA) target_sources(glfw PRIVATE cocoa_platform.h cocoa_joystick.h cocoa_init.m cocoa_joystick.m cocoa_monitor.m cocoa_window.m @@ -137,13 +138,6 @@ target_include_directories(glfw PRIVATE "${GLFW_BINARY_DIR}/src") target_link_libraries(glfw PRIVATE Threads::Threads) -# Workaround for CMake not knowing about .m files before version 3.16 -if (CMAKE_VERSION VERSION_LESS "3.16" AND APPLE) - set_source_files_properties(cocoa_init.m cocoa_joystick.m cocoa_monitor.m - cocoa_window.m nsgl_context.m PROPERTIES - LANGUAGE C) -endif() - if (GLFW_BUILD_WIN32) list(APPEND glfw_PKG_LIBS "-lgdi32") endif() @@ -349,12 +343,8 @@ if (GLFW_BUILD_SHARED_LIBRARY) endif() endif() -foreach(arg ${glfw_PKG_DEPS}) - string(APPEND deps " ${arg}") -endforeach() -foreach(arg ${glfw_PKG_LIBS}) - string(APPEND libs " ${arg}") -endforeach() +list(JOIN glfw_PKG_DEPS " " deps) +list(JOIN glfw_PKG_LIBS " " libs) set(GLFW_PKG_CONFIG_REQUIRES_PRIVATE "${deps}" CACHE INTERNAL "GLFW pkg-config Requires.private") From a576a56a8d6a3f17569e3d46f85365dc159c7408 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 10 May 2024 17:05:49 +0200 Subject: [PATCH 03/36] Remove unused CMake find module for OSMesa --- CMake/modules/FindOSMesa.cmake | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 CMake/modules/FindOSMesa.cmake diff --git a/CMake/modules/FindOSMesa.cmake b/CMake/modules/FindOSMesa.cmake deleted file mode 100644 index 3194bd91a..000000000 --- a/CMake/modules/FindOSMesa.cmake +++ /dev/null @@ -1,18 +0,0 @@ -# Try to find OSMesa on a Unix system -# -# This will define: -# -# OSMESA_LIBRARIES - Link these to use OSMesa -# OSMESA_INCLUDE_DIR - Include directory for OSMesa -# -# Copyright (c) 2014 Brandon Schaefer - -if (NOT WIN32) - - find_package (PkgConfig) - pkg_check_modules (PKG_OSMESA QUIET osmesa) - - set (OSMESA_INCLUDE_DIR ${PKG_OSMESA_INCLUDE_DIRS}) - set (OSMESA_LIBRARIES ${PKG_OSMESA_LIBRARIES}) - -endif () From 21fea01161e0d6b70c0c5c1f52dc8e7a7df14a50 Mon Sep 17 00:00:00 2001 From: LocalSpook Date: Sun, 10 Dec 2023 05:54:11 -0700 Subject: [PATCH 04/36] Wayland: Replace _glfwKeySym2Unicode with xkbcommon libxkbcommon already provides functions to convert keysyms to codepoints and UTF-8. The library has offered these functions since 0.5.0[1], so using them won't cause any compatibility problems. [1] https://xkbcommon.org/doc/0.5.0/group__keysyms.html Closes #2444 --- src/CMakeLists.txt | 4 ++-- src/wl_init.c | 4 ++++ src/wl_platform.h | 7 ++++++- src/wl_window.c | 28 ++++++++++++++-------------- 4 files changed, 26 insertions(+), 17 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fc4e17cf2..1a085b2b6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -53,8 +53,8 @@ endif() if (GLFW_BUILD_WAYLAND) target_compile_definitions(glfw PRIVATE _GLFW_WAYLAND) - target_sources(glfw PRIVATE wl_platform.h xkb_unicode.h wl_init.c - wl_monitor.c wl_window.c xkb_unicode.c) + target_sources(glfw PRIVATE wl_platform.h wl_init.c + wl_monitor.c wl_window.c) endif() if (GLFW_BUILD_X11 OR GLFW_BUILD_WAYLAND) diff --git a/src/wl_init.c b/src/wl_init.c index 76054bc6a..ef9e45036 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -711,6 +711,10 @@ int _glfwInitWayland(void) _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_compose_state_get_status"); _glfw.wl.xkb.compose_state_get_one_sym = (PFN_xkb_compose_state_get_one_sym) _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_compose_state_get_one_sym"); + _glfw.wl.xkb.keysym_to_utf32 = (PFN_xkb_keysym_to_utf32) + _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_keysym_to_utf32"); + _glfw.wl.xkb.keysym_to_utf8 = (PFN_xkb_keysym_to_utf8) + _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_keysym_to_utf8"); if (!_glfw.wl.xkb.context_new || !_glfw.wl.xkb.context_unref || diff --git a/src/wl_platform.h b/src/wl_platform.h index f3e8cba2d..afa6f50af 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -42,7 +42,6 @@ typedef struct VkWaylandSurfaceCreateInfoKHR typedef VkResult (APIENTRY *PFN_vkCreateWaylandSurfaceKHR)(VkInstance,const VkWaylandSurfaceCreateInfoKHR*,const VkAllocationCallbacks*,VkSurfaceKHR*); typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR)(VkPhysicalDevice,uint32_t,struct wl_display*); -#include "xkb_unicode.h" #include "posix_poll.h" typedef int (* PFN_wl_display_flush)(struct wl_display* display); @@ -178,6 +177,8 @@ typedef int (* PFN_xkb_state_key_get_syms)(struct xkb_state*, xkb_keycode_t, con typedef enum xkb_state_component (* PFN_xkb_state_update_mask)(struct xkb_state*, xkb_mod_mask_t, xkb_mod_mask_t, xkb_mod_mask_t, xkb_layout_index_t, xkb_layout_index_t, xkb_layout_index_t); typedef xkb_layout_index_t (* PFN_xkb_state_key_get_layout)(struct xkb_state*,xkb_keycode_t); typedef int (* PFN_xkb_state_mod_index_is_active)(struct xkb_state*,xkb_mod_index_t,enum xkb_state_component); +typedef uint32_t (* PFN_xkb_keysym_to_utf32)(xkb_keysym_t); +typedef int (* PFN_xkb_keysym_to_utf8)(xkb_keysym_t, char*, size_t); #define xkb_context_new _glfw.wl.xkb.context_new #define xkb_context_unref _glfw.wl.xkb.context_unref #define xkb_keymap_new_from_string _glfw.wl.xkb.keymap_new_from_string @@ -191,6 +192,8 @@ typedef int (* PFN_xkb_state_mod_index_is_active)(struct xkb_state*,xkb_mod_inde #define xkb_state_update_mask _glfw.wl.xkb.state_update_mask #define xkb_state_key_get_layout _glfw.wl.xkb.state_key_get_layout #define xkb_state_mod_index_is_active _glfw.wl.xkb.state_mod_index_is_active +#define xkb_keysym_to_utf32 _glfw.wl.xkb.keysym_to_utf32 +#define xkb_keysym_to_utf8 _glfw.wl.xkb.keysym_to_utf8 typedef struct xkb_compose_table* (* PFN_xkb_compose_table_new_from_locale)(struct xkb_context*, const char*, enum xkb_compose_compile_flags); typedef void (* PFN_xkb_compose_table_unref)(struct xkb_compose_table*); @@ -495,6 +498,8 @@ typedef struct _GLFWlibraryWayland PFN_xkb_state_update_mask state_update_mask; PFN_xkb_state_key_get_layout state_key_get_layout; PFN_xkb_state_mod_index_is_active state_mod_index_is_active; + PFN_xkb_keysym_to_utf32 keysym_to_utf32; + PFN_xkb_keysym_to_utf8 keysym_to_utf8; PFN_xkb_compose_table_new_from_locale compose_table_new_from_locale; PFN_xkb_compose_table_unref compose_table_unref; diff --git a/src/wl_window.c b/src/wl_window.c index 2e842aaaa..72c1a4026 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1192,8 +1192,8 @@ static void inputText(_GLFWwindow* window, uint32_t scancode) if (xkb_state_key_get_syms(_glfw.wl.xkb.state, keycode, &keysyms) == 1) { const xkb_keysym_t keysym = composeSymbol(keysyms[0]); - const uint32_t codepoint = _glfwKeySym2Unicode(keysym); - if (codepoint != GLFW_INVALID_CODEPOINT) + const uint32_t codepoint = xkb_keysym_to_utf32(keysym); + if (codepoint != 0) { const int mods = _glfw.wl.xkb.modifiers; const int plain = !(mods & (GLFW_MOD_CONTROL | GLFW_MOD_ALT)); @@ -2721,23 +2721,23 @@ const char* _glfwGetScancodeNameWayland(int scancode) return NULL; } - const uint32_t codepoint = _glfwKeySym2Unicode(keysyms[0]); - if (codepoint == GLFW_INVALID_CODEPOINT) + // WORKAROUND: xkb_keysym_to_utf8() requires the third parameter (size of the output buffer) + // to be at least 7 (6 bytes + a null terminator), because it was written when UTF-8 + // sequences could be up to 6 bytes long. The _glfw.wl.keynames buffers are only 5 bytes + // long, because UTF-8 sequences are now limited to 4 bytes and no codepoints were ever assigned + // that needed more than that. To work around this, we first copy to a temporary buffer. + // + // See: https://github.com/xkbcommon/libxkbcommon/issues/418 + char temp_buffer[7]; + const int bytes_written = xkb_keysym_to_utf8(keysyms[0], temp_buffer, sizeof(temp_buffer)); + if (bytes_written <= 0 || bytes_written > 5) { _glfwInputError(GLFW_PLATFORM_ERROR, - "Wayland: Failed to retrieve codepoint for key name"); + "Wayland: Failed to encode keysym as UTF-8"); return NULL; } + memcpy(_glfw.wl.keynames[key], temp_buffer, bytes_written); - const size_t count = _glfwEncodeUTF8(_glfw.wl.keynames[key], codepoint); - if (count == 0) - { - _glfwInputError(GLFW_PLATFORM_ERROR, - "Wayland: Failed to encode codepoint for key name"); - return NULL; - } - - _glfw.wl.keynames[key][count] = '\0'; return _glfw.wl.keynames[key]; } From cf4734ce8a5fbdfc3623f3842bafd2437045d8e1 Mon Sep 17 00:00:00 2001 From: er-azh <80633916+er-azh@users.noreply.github.com> Date: Thu, 25 Jul 2024 03:17:43 -0400 Subject: [PATCH 05/36] X11: Fix detectEWMH not releasing error handler If detectEWMH failed to query the EWMH helper window, it would return without restoring the previous Xlib error handler. This was bad (because other code might also be using the facility) and bad (because GLFW would assert the next time it tried to grab the error handler). This commit adds the necessary release call. Closes #2593 Fixes #2601 Closes #2631 --- src/x11_init.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/x11_init.c b/src/x11_init.c index 982c526c6..6b34c2639 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -535,6 +535,7 @@ static void detectEWMH(void) XA_WINDOW, (unsigned char**) &windowFromChild)) { + _glfwReleaseErrorHandlerX11(); XFree(windowFromRoot); return; } From e7ea71be039836da3a98cea55ae5569cb5eb885c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 12 Jan 2025 19:29:05 +0100 Subject: [PATCH 06/36] Update changelog and add credit Related to #2593 --- CONTRIBUTORS.md | 1 + README.md | 1 + 2 files changed, 2 insertions(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 1371aedbc..4fc27126d 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -67,6 +67,7 @@ video tutorials. - Robin Eklind - Jan Ekström - Siavash Eliasi + - er-azh - Ahmad Fatoum - Nikita Fediuchin - Felipe Ferreira diff --git a/README.md b/README.md index fb77b9ddf..523061885 100644 --- a/README.md +++ b/README.md @@ -129,6 +129,7 @@ information on what to include when reporting a bug. - [Wayland] Bugfix: The fractional scaling related objects were not destroyed - [Wayland] Bugfix: `glfwInit` would segfault on compositor with no seat (#2517) - [Wayland] Bugfix: A drag entering a non-GLFW surface could cause a segfault + - [X11] Bugfix: Running without a WM could trigger an assert (#2593,#2601,#2631) - [Null] Added Vulkan 'window' surface creation via `VK_EXT_headless_surface` - [Null] Added EGL context creation on Mesa via `EGL_MESA_platform_surfaceless` - [EGL] Allowed native access on Wayland with `GLFW_CONTEXT_CREATION_API` set to From d30d63313c5876f9ce8770f79cd59dd7109a768e Mon Sep 17 00:00:00 2001 From: Doug Binks Date: Sat, 5 Jul 2025 19:12:15 +0200 Subject: [PATCH 07/36] Examples: disable MSVC warning C5287 in nuklear.h Latest MSVC has a warning `operands are different enum types` which this disables until upstream nuklear fixes this --- deps/nuklear.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/deps/nuklear.h b/deps/nuklear.h index f2eb9dfa2..0f534e52a 100644 --- a/deps/nuklear.h +++ b/deps/nuklear.h @@ -423,6 +423,11 @@ NK_STATIC_ASSERT(sizeof(nk_rune) >= 4); NK_STATIC_ASSERT(sizeof(nk_size) >= sizeof(void*)); NK_STATIC_ASSERT(sizeof(nk_ptr) >= sizeof(void*)); +#if defined(_MSC_VER) +/* disable `operands are different enum types` warning on MSVC */ +#pragma warning( disable: 5287 ) +#endif + /* ============================================================================ * * API From 506c11ba43b901dbcc4d90449f46de67cf000af4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Sch=C3=BCrkamp?= Date: Sat, 5 Jul 2025 19:16:08 +0200 Subject: [PATCH 08/36] Wayland: Ignore key repeat events when no window has keyboard focus (#2732) * Wayland: Ignore key repeat events when no window has keyboard focus --- CONTRIBUTORS.md | 2 +- README.md | 1 + src/wl_window.c | 20 ++++++++++++-------- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 4fc27126d..8fa1cb724 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -229,7 +229,7 @@ video tutorials. - Brandon Schaefer - Sebastian Schuberth - Scr3amer - - Jan Schuerkamp + - Jan Schürkamp - Christian Sdunek - Matt Sealey - Steve Sexton diff --git a/README.md b/README.md index 523061885..9d78ecdad 100644 --- a/README.md +++ b/README.md @@ -129,6 +129,7 @@ information on what to include when reporting a bug. - [Wayland] Bugfix: The fractional scaling related objects were not destroyed - [Wayland] Bugfix: `glfwInit` would segfault on compositor with no seat (#2517) - [Wayland] Bugfix: A drag entering a non-GLFW surface could cause a segfault + - [Wayland] Bugfix: Ignore key repeat events when no window has keyboard focus (#2727) - [X11] Bugfix: Running without a WM could trigger an assert (#2593,#2601,#2631) - [Null] Added Vulkan 'window' surface creation via `VK_EXT_headless_surface` - [Null] Added EGL context creation on Mesa via `EGL_MESA_platform_surfaceless` diff --git a/src/wl_window.c b/src/wl_window.c index 72c1a4026..6457f31e0 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1267,17 +1267,21 @@ static void handleEvents(double* timeout) if (read(_glfw.wl.keyRepeatTimerfd, &repeats, sizeof(repeats)) == 8) { - for (uint64_t i = 0; i < repeats; i++) + if(_glfw.wl.keyboardFocus) { - _glfwInputKey(_glfw.wl.keyboardFocus, - translateKey(_glfw.wl.keyRepeatScancode), - _glfw.wl.keyRepeatScancode, - GLFW_PRESS, - _glfw.wl.xkb.modifiers); - inputText(_glfw.wl.keyboardFocus, _glfw.wl.keyRepeatScancode); + for (uint64_t i = 0; i < repeats; i++) + { + _glfwInputKey(_glfw.wl.keyboardFocus, + translateKey(_glfw.wl.keyRepeatScancode), + _glfw.wl.keyRepeatScancode, + GLFW_PRESS, + _glfw.wl.xkb.modifiers); + inputText(_glfw.wl.keyboardFocus, _glfw.wl.keyRepeatScancode); + } + + event = GLFW_TRUE; } - event = GLFW_TRUE; } } From d1b87143bcdf20eb0007965ea5d1230264780d41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 4 Apr 2024 17:00:46 +0200 Subject: [PATCH 09/36] Win32: Remove support for original MinGW The original MinGW distribution appears to no longer be maintained and should not be used. Anyone still using MinGW should consider switching to the MinGW-w64 fork or another actively maintained toolchain. MinGW-w64 supports 64-bit binaries and provides much newer compilers and Win32 headers. Fixes #2540 --- .appveyor.yml | 2 +- .editorconfig | 6 - README.md | 3 +- deps/mingw/_mingw_dxhelper.h | 117 -- deps/mingw/dinput.h | 2467 ---------------------------------- deps/mingw/xinput.h | 239 ---- docs/compile.md | 24 +- docs/intro.md | 6 +- docs/news.md | 9 + src/CMakeLists.txt | 22 - src/platform.c | 2 - src/win32_platform.h | 15 - 12 files changed, 27 insertions(+), 2885 deletions(-) delete mode 100644 deps/mingw/_mingw_dxhelper.h delete mode 100644 deps/mingw/dinput.h delete mode 100644 deps/mingw/xinput.h diff --git a/.appveyor.yml b/.appveyor.yml index c58911ccf..fe48c8268 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -29,7 +29,7 @@ for: only: - GENERATOR: MinGW Makefiles build_script: - - set PATH=%PATH:C:\Program Files\Git\usr\bin=C:\MinGW\bin% + - set PATH=C:\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin;%PATH:C:\Program Files\Git\usr\bin=% - cmake -B build -G "%GENERATOR%" -DBUILD_SHARED_LIBS=%BUILD_SHARED_LIBS% - cmake --build build - diff --git a/.editorconfig b/.editorconfig index 2b44e7b2e..bbdd90186 100644 --- a/.editorconfig +++ b/.editorconfig @@ -41,12 +41,6 @@ indent_size = 2 indent_style = tab indent_size = unset -[deps/mingw/*.h] -indent_style = space -indent_size = 4 -tab_width = 8 -trim_trailing_whitespace = false - [deps/getopt.{c,h}] indent_style = space indent_size = 2 diff --git a/README.md b/README.md index 9d78ecdad..344d61954 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ and window system. It does not need any additional headers for context creation APIs (WGL, GLX, EGL, NSGL, OSMesa) or rendering APIs (OpenGL, OpenGL ES, Vulkan) to enable support for them. -GLFW supports compilation on Windows with Visual C++ 2013 and later, MinGW and +GLFW supports compilation on Windows with Visual C++ (2013 and later) and MinGW-w64, on macOS with Clang and on Linux and other Unix-like systems with GCC and Clang. It will likely compile in other environments as well, but this is not regularly tested. @@ -124,6 +124,7 @@ information on what to include when reporting a bug. - Added `GLFW_UNLIMITED_MOUSE_BUTTONS` input mode that allows mouse buttons beyond the limit of the mouse button tokens to be reported (#2423) - Updated minimum CMake version to 3.16 (#2541) + - Removed support for building with original MinGW (#2540) - [Cocoa] Added `QuartzCore` framework as link-time dependency - [Cocoa] Removed support for OS X 10.10 Yosemite and earlier (#2506) - [Wayland] Bugfix: The fractional scaling related objects were not destroyed diff --git a/deps/mingw/_mingw_dxhelper.h b/deps/mingw/_mingw_dxhelper.h deleted file mode 100644 index 849e29146..000000000 --- a/deps/mingw/_mingw_dxhelper.h +++ /dev/null @@ -1,117 +0,0 @@ -/** - * This file has no copyright assigned and is placed in the Public Domain. - * This file is part of the mingw-w64 runtime package. - * No warranty is given; refer to the file DISCLAIMER within this package. - */ - -#if defined(_MSC_VER) && !defined(_MSC_EXTENSIONS) -#define NONAMELESSUNION 1 -#endif -#if defined(NONAMELESSSTRUCT) && \ - !defined(NONAMELESSUNION) -#define NONAMELESSUNION 1 -#endif -#if defined(NONAMELESSUNION) && \ - !defined(NONAMELESSSTRUCT) -#define NONAMELESSSTRUCT 1 -#endif -#if !defined(__GNU_EXTENSION) -#if defined(__GNUC__) || defined(__GNUG__) -#define __GNU_EXTENSION __extension__ -#else -#define __GNU_EXTENSION -#endif -#endif /* __extension__ */ - -#ifndef __ANONYMOUS_DEFINED -#define __ANONYMOUS_DEFINED -#if defined(__GNUC__) || defined(__GNUG__) -#define _ANONYMOUS_UNION __extension__ -#define _ANONYMOUS_STRUCT __extension__ -#else -#define _ANONYMOUS_UNION -#define _ANONYMOUS_STRUCT -#endif -#ifndef NONAMELESSUNION -#define _UNION_NAME(x) -#define _STRUCT_NAME(x) -#else /* NONAMELESSUNION */ -#define _UNION_NAME(x) x -#define _STRUCT_NAME(x) x -#endif -#endif /* __ANONYMOUS_DEFINED */ - -#ifndef DUMMYUNIONNAME -# ifdef NONAMELESSUNION -# define DUMMYUNIONNAME u -# define DUMMYUNIONNAME1 u1 /* Wine uses this variant */ -# define DUMMYUNIONNAME2 u2 -# define DUMMYUNIONNAME3 u3 -# define DUMMYUNIONNAME4 u4 -# define DUMMYUNIONNAME5 u5 -# define DUMMYUNIONNAME6 u6 -# define DUMMYUNIONNAME7 u7 -# define DUMMYUNIONNAME8 u8 -# define DUMMYUNIONNAME9 u9 -# else /* NONAMELESSUNION */ -# define DUMMYUNIONNAME -# define DUMMYUNIONNAME1 /* Wine uses this variant */ -# define DUMMYUNIONNAME2 -# define DUMMYUNIONNAME3 -# define DUMMYUNIONNAME4 -# define DUMMYUNIONNAME5 -# define DUMMYUNIONNAME6 -# define DUMMYUNIONNAME7 -# define DUMMYUNIONNAME8 -# define DUMMYUNIONNAME9 -# endif -#endif /* DUMMYUNIONNAME */ - -#if !defined(DUMMYUNIONNAME1) /* MinGW does not define this one */ -# ifdef NONAMELESSUNION -# define DUMMYUNIONNAME1 u1 /* Wine uses this variant */ -# else -# define DUMMYUNIONNAME1 /* Wine uses this variant */ -# endif -#endif /* DUMMYUNIONNAME1 */ - -#ifndef DUMMYSTRUCTNAME -# ifdef NONAMELESSUNION -# define DUMMYSTRUCTNAME s -# define DUMMYSTRUCTNAME1 s1 /* Wine uses this variant */ -# define DUMMYSTRUCTNAME2 s2 -# define DUMMYSTRUCTNAME3 s3 -# define DUMMYSTRUCTNAME4 s4 -# define DUMMYSTRUCTNAME5 s5 -# else -# define DUMMYSTRUCTNAME -# define DUMMYSTRUCTNAME1 /* Wine uses this variant */ -# define DUMMYSTRUCTNAME2 -# define DUMMYSTRUCTNAME3 -# define DUMMYSTRUCTNAME4 -# define DUMMYSTRUCTNAME5 -# endif -#endif /* DUMMYSTRUCTNAME */ - -/* These are for compatibility with the Wine source tree */ - -#ifndef WINELIB_NAME_AW -# ifdef __MINGW_NAME_AW -# define WINELIB_NAME_AW __MINGW_NAME_AW -# else -# ifdef UNICODE -# define WINELIB_NAME_AW(func) func##W -# else -# define WINELIB_NAME_AW(func) func##A -# endif -# endif -#endif /* WINELIB_NAME_AW */ - -#ifndef DECL_WINELIB_TYPE_AW -# ifdef __MINGW_TYPEDEF_AW -# define DECL_WINELIB_TYPE_AW __MINGW_TYPEDEF_AW -# else -# define DECL_WINELIB_TYPE_AW(type) typedef WINELIB_NAME_AW(type) type; -# endif -#endif /* DECL_WINELIB_TYPE_AW */ - diff --git a/deps/mingw/dinput.h b/deps/mingw/dinput.h deleted file mode 100644 index b5754802b..000000000 --- a/deps/mingw/dinput.h +++ /dev/null @@ -1,2467 +0,0 @@ -/* - * Copyright (C) the Wine project - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#ifndef __DINPUT_INCLUDED__ -#define __DINPUT_INCLUDED__ - -#define COM_NO_WINDOWS_H -#include -#include <_mingw_dxhelper.h> - -#ifndef DIRECTINPUT_VERSION -#define DIRECTINPUT_VERSION 0x0800 -#endif - -/* Classes */ -DEFINE_GUID(CLSID_DirectInput, 0x25E609E0,0xB259,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(CLSID_DirectInputDevice, 0x25E609E1,0xB259,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); - -DEFINE_GUID(CLSID_DirectInput8, 0x25E609E4,0xB259,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(CLSID_DirectInputDevice8, 0x25E609E5,0xB259,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); - -/* Interfaces */ -DEFINE_GUID(IID_IDirectInputA, 0x89521360,0xAA8A,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(IID_IDirectInputW, 0x89521361,0xAA8A,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(IID_IDirectInput2A, 0x5944E662,0xAA8A,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(IID_IDirectInput2W, 0x5944E663,0xAA8A,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(IID_IDirectInput7A, 0x9A4CB684,0x236D,0x11D3,0x8E,0x9D,0x00,0xC0,0x4F,0x68,0x44,0xAE); -DEFINE_GUID(IID_IDirectInput7W, 0x9A4CB685,0x236D,0x11D3,0x8E,0x9D,0x00,0xC0,0x4F,0x68,0x44,0xAE); -DEFINE_GUID(IID_IDirectInput8A, 0xBF798030,0x483A,0x4DA2,0xAA,0x99,0x5D,0x64,0xED,0x36,0x97,0x00); -DEFINE_GUID(IID_IDirectInput8W, 0xBF798031,0x483A,0x4DA2,0xAA,0x99,0x5D,0x64,0xED,0x36,0x97,0x00); -DEFINE_GUID(IID_IDirectInputDeviceA, 0x5944E680,0xC92E,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(IID_IDirectInputDeviceW, 0x5944E681,0xC92E,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(IID_IDirectInputDevice2A, 0x5944E682,0xC92E,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(IID_IDirectInputDevice2W, 0x5944E683,0xC92E,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(IID_IDirectInputDevice7A, 0x57D7C6BC,0x2356,0x11D3,0x8E,0x9D,0x00,0xC0,0x4F,0x68,0x44,0xAE); -DEFINE_GUID(IID_IDirectInputDevice7W, 0x57D7C6BD,0x2356,0x11D3,0x8E,0x9D,0x00,0xC0,0x4F,0x68,0x44,0xAE); -DEFINE_GUID(IID_IDirectInputDevice8A, 0x54D41080,0xDC15,0x4833,0xA4,0x1B,0x74,0x8F,0x73,0xA3,0x81,0x79); -DEFINE_GUID(IID_IDirectInputDevice8W, 0x54D41081,0xDC15,0x4833,0xA4,0x1B,0x74,0x8F,0x73,0xA3,0x81,0x79); -DEFINE_GUID(IID_IDirectInputEffect, 0xE7E1F7C0,0x88D2,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); - -/* Predefined object types */ -DEFINE_GUID(GUID_XAxis, 0xA36D02E0,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(GUID_YAxis, 0xA36D02E1,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(GUID_ZAxis, 0xA36D02E2,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(GUID_RxAxis,0xA36D02F4,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(GUID_RyAxis,0xA36D02F5,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(GUID_RzAxis,0xA36D02E3,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(GUID_Slider,0xA36D02E4,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(GUID_Button,0xA36D02F0,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(GUID_Key, 0x55728220,0xD33C,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(GUID_POV, 0xA36D02F2,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(GUID_Unknown,0xA36D02F3,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); - -/* Predefined product GUIDs */ -DEFINE_GUID(GUID_SysMouse, 0x6F1D2B60,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(GUID_SysKeyboard, 0x6F1D2B61,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(GUID_Joystick, 0x6F1D2B70,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(GUID_SysMouseEm, 0x6F1D2B80,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(GUID_SysMouseEm2, 0x6F1D2B81,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(GUID_SysKeyboardEm, 0x6F1D2B82,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(GUID_SysKeyboardEm2,0x6F1D2B83,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); - -/* predefined forcefeedback effects */ -DEFINE_GUID(GUID_ConstantForce, 0x13541C20,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); -DEFINE_GUID(GUID_RampForce, 0x13541C21,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); -DEFINE_GUID(GUID_Square, 0x13541C22,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); -DEFINE_GUID(GUID_Sine, 0x13541C23,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); -DEFINE_GUID(GUID_Triangle, 0x13541C24,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); -DEFINE_GUID(GUID_SawtoothUp, 0x13541C25,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); -DEFINE_GUID(GUID_SawtoothDown, 0x13541C26,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); -DEFINE_GUID(GUID_Spring, 0x13541C27,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); -DEFINE_GUID(GUID_Damper, 0x13541C28,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); -DEFINE_GUID(GUID_Inertia, 0x13541C29,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); -DEFINE_GUID(GUID_Friction, 0x13541C2A,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); -DEFINE_GUID(GUID_CustomForce, 0x13541C2B,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); - -typedef struct IDirectInputA *LPDIRECTINPUTA; -typedef struct IDirectInputW *LPDIRECTINPUTW; -typedef struct IDirectInput2A *LPDIRECTINPUT2A; -typedef struct IDirectInput2W *LPDIRECTINPUT2W; -typedef struct IDirectInput7A *LPDIRECTINPUT7A; -typedef struct IDirectInput7W *LPDIRECTINPUT7W; -#if DIRECTINPUT_VERSION >= 0x0800 -typedef struct IDirectInput8A *LPDIRECTINPUT8A; -typedef struct IDirectInput8W *LPDIRECTINPUT8W; -#endif /* DI8 */ -typedef struct IDirectInputDeviceA *LPDIRECTINPUTDEVICEA; -typedef struct IDirectInputDeviceW *LPDIRECTINPUTDEVICEW; -#if DIRECTINPUT_VERSION >= 0x0500 -typedef struct IDirectInputDevice2A *LPDIRECTINPUTDEVICE2A; -typedef struct IDirectInputDevice2W *LPDIRECTINPUTDEVICE2W; -#endif /* DI5 */ -#if DIRECTINPUT_VERSION >= 0x0700 -typedef struct IDirectInputDevice7A *LPDIRECTINPUTDEVICE7A; -typedef struct IDirectInputDevice7W *LPDIRECTINPUTDEVICE7W; -#endif /* DI7 */ -#if DIRECTINPUT_VERSION >= 0x0800 -typedef struct IDirectInputDevice8A *LPDIRECTINPUTDEVICE8A; -typedef struct IDirectInputDevice8W *LPDIRECTINPUTDEVICE8W; -#endif /* DI8 */ -#if DIRECTINPUT_VERSION >= 0x0500 -typedef struct IDirectInputEffect *LPDIRECTINPUTEFFECT; -#endif /* DI5 */ -typedef struct SysKeyboardA *LPSYSKEYBOARDA; -typedef struct SysMouseA *LPSYSMOUSEA; - -#define IID_IDirectInput WINELIB_NAME_AW(IID_IDirectInput) -#define IDirectInput WINELIB_NAME_AW(IDirectInput) -DECL_WINELIB_TYPE_AW(LPDIRECTINPUT) -#define IID_IDirectInput2 WINELIB_NAME_AW(IID_IDirectInput2) -#define IDirectInput2 WINELIB_NAME_AW(IDirectInput2) -DECL_WINELIB_TYPE_AW(LPDIRECTINPUT2) -#define IID_IDirectInput7 WINELIB_NAME_AW(IID_IDirectInput7) -#define IDirectInput7 WINELIB_NAME_AW(IDirectInput7) -DECL_WINELIB_TYPE_AW(LPDIRECTINPUT7) -#if DIRECTINPUT_VERSION >= 0x0800 -#define IID_IDirectInput8 WINELIB_NAME_AW(IID_IDirectInput8) -#define IDirectInput8 WINELIB_NAME_AW(IDirectInput8) -DECL_WINELIB_TYPE_AW(LPDIRECTINPUT8) -#endif /* DI8 */ -#define IID_IDirectInputDevice WINELIB_NAME_AW(IID_IDirectInputDevice) -#define IDirectInputDevice WINELIB_NAME_AW(IDirectInputDevice) -DECL_WINELIB_TYPE_AW(LPDIRECTINPUTDEVICE) -#if DIRECTINPUT_VERSION >= 0x0500 -#define IID_IDirectInputDevice2 WINELIB_NAME_AW(IID_IDirectInputDevice2) -#define IDirectInputDevice2 WINELIB_NAME_AW(IDirectInputDevice2) -DECL_WINELIB_TYPE_AW(LPDIRECTINPUTDEVICE2) -#endif /* DI5 */ -#if DIRECTINPUT_VERSION >= 0x0700 -#define IID_IDirectInputDevice7 WINELIB_NAME_AW(IID_IDirectInputDevice7) -#define IDirectInputDevice7 WINELIB_NAME_AW(IDirectInputDevice7) -DECL_WINELIB_TYPE_AW(LPDIRECTINPUTDEVICE7) -#endif /* DI7 */ -#if DIRECTINPUT_VERSION >= 0x0800 -#define IID_IDirectInputDevice8 WINELIB_NAME_AW(IID_IDirectInputDevice8) -#define IDirectInputDevice8 WINELIB_NAME_AW(IDirectInputDevice8) -DECL_WINELIB_TYPE_AW(LPDIRECTINPUTDEVICE8) -#endif /* DI8 */ - -#define DI_OK S_OK -#define DI_NOTATTACHED S_FALSE -#define DI_BUFFEROVERFLOW S_FALSE -#define DI_PROPNOEFFECT S_FALSE -#define DI_NOEFFECT S_FALSE -#define DI_POLLEDDEVICE ((HRESULT)0x00000002L) -#define DI_DOWNLOADSKIPPED ((HRESULT)0x00000003L) -#define DI_EFFECTRESTARTED ((HRESULT)0x00000004L) -#define DI_TRUNCATED ((HRESULT)0x00000008L) -#define DI_SETTINGSNOTSAVED ((HRESULT)0x0000000BL) -#define DI_TRUNCATEDANDRESTARTED ((HRESULT)0x0000000CL) -#define DI_WRITEPROTECT ((HRESULT)0x00000013L) - -#define DIERR_OLDDIRECTINPUTVERSION \ - MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_OLD_WIN_VERSION) -#define DIERR_BETADIRECTINPUTVERSION \ - MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_RMODE_APP) -#define DIERR_BADDRIVERVER \ - MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_BAD_DRIVER_LEVEL) -#define DIERR_DEVICENOTREG REGDB_E_CLASSNOTREG -#define DIERR_NOTFOUND \ - MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_FILE_NOT_FOUND) -#define DIERR_OBJECTNOTFOUND \ - MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_FILE_NOT_FOUND) -#define DIERR_INVALIDPARAM E_INVALIDARG -#define DIERR_NOINTERFACE E_NOINTERFACE -#define DIERR_GENERIC E_FAIL -#define DIERR_OUTOFMEMORY E_OUTOFMEMORY -#define DIERR_UNSUPPORTED E_NOTIMPL -#define DIERR_NOTINITIALIZED \ - MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_NOT_READY) -#define DIERR_ALREADYINITIALIZED \ - MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_ALREADY_INITIALIZED) -#define DIERR_NOAGGREGATION CLASS_E_NOAGGREGATION -#define DIERR_OTHERAPPHASPRIO E_ACCESSDENIED -#define DIERR_INPUTLOST \ - MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_READ_FAULT) -#define DIERR_ACQUIRED \ - MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_BUSY) -#define DIERR_NOTACQUIRED \ - MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_INVALID_ACCESS) -#define DIERR_READONLY E_ACCESSDENIED -#define DIERR_HANDLEEXISTS E_ACCESSDENIED -#ifndef E_PENDING -#define E_PENDING 0x8000000AL -#endif -#define DIERR_INSUFFICIENTPRIVS 0x80040200L -#define DIERR_DEVICEFULL 0x80040201L -#define DIERR_MOREDATA 0x80040202L -#define DIERR_NOTDOWNLOADED 0x80040203L -#define DIERR_HASEFFECTS 0x80040204L -#define DIERR_NOTEXCLUSIVEACQUIRED 0x80040205L -#define DIERR_INCOMPLETEEFFECT 0x80040206L -#define DIERR_NOTBUFFERED 0x80040207L -#define DIERR_EFFECTPLAYING 0x80040208L -#define DIERR_UNPLUGGED 0x80040209L -#define DIERR_REPORTFULL 0x8004020AL -#define DIERR_MAPFILEFAIL 0x8004020BL - -#define DIENUM_STOP 0 -#define DIENUM_CONTINUE 1 - -#define DIEDFL_ALLDEVICES 0x00000000 -#define DIEDFL_ATTACHEDONLY 0x00000001 -#define DIEDFL_FORCEFEEDBACK 0x00000100 -#define DIEDFL_INCLUDEALIASES 0x00010000 -#define DIEDFL_INCLUDEPHANTOMS 0x00020000 -#define DIEDFL_INCLUDEHIDDEN 0x00040000 - -#define DIDEVTYPE_DEVICE 1 -#define DIDEVTYPE_MOUSE 2 -#define DIDEVTYPE_KEYBOARD 3 -#define DIDEVTYPE_JOYSTICK 4 -#define DIDEVTYPE_HID 0x00010000 - -#define DI8DEVCLASS_ALL 0 -#define DI8DEVCLASS_DEVICE 1 -#define DI8DEVCLASS_POINTER 2 -#define DI8DEVCLASS_KEYBOARD 3 -#define DI8DEVCLASS_GAMECTRL 4 - -#define DI8DEVTYPE_DEVICE 0x11 -#define DI8DEVTYPE_MOUSE 0x12 -#define DI8DEVTYPE_KEYBOARD 0x13 -#define DI8DEVTYPE_JOYSTICK 0x14 -#define DI8DEVTYPE_GAMEPAD 0x15 -#define DI8DEVTYPE_DRIVING 0x16 -#define DI8DEVTYPE_FLIGHT 0x17 -#define DI8DEVTYPE_1STPERSON 0x18 -#define DI8DEVTYPE_DEVICECTRL 0x19 -#define DI8DEVTYPE_SCREENPOINTER 0x1A -#define DI8DEVTYPE_REMOTE 0x1B -#define DI8DEVTYPE_SUPPLEMENTAL 0x1C - -#define DIDEVTYPEMOUSE_UNKNOWN 1 -#define DIDEVTYPEMOUSE_TRADITIONAL 2 -#define DIDEVTYPEMOUSE_FINGERSTICK 3 -#define DIDEVTYPEMOUSE_TOUCHPAD 4 -#define DIDEVTYPEMOUSE_TRACKBALL 5 - -#define DIDEVTYPEKEYBOARD_UNKNOWN 0 -#define DIDEVTYPEKEYBOARD_PCXT 1 -#define DIDEVTYPEKEYBOARD_OLIVETTI 2 -#define DIDEVTYPEKEYBOARD_PCAT 3 -#define DIDEVTYPEKEYBOARD_PCENH 4 -#define DIDEVTYPEKEYBOARD_NOKIA1050 5 -#define DIDEVTYPEKEYBOARD_NOKIA9140 6 -#define DIDEVTYPEKEYBOARD_NEC98 7 -#define DIDEVTYPEKEYBOARD_NEC98LAPTOP 8 -#define DIDEVTYPEKEYBOARD_NEC98106 9 -#define DIDEVTYPEKEYBOARD_JAPAN106 10 -#define DIDEVTYPEKEYBOARD_JAPANAX 11 -#define DIDEVTYPEKEYBOARD_J3100 12 - -#define DIDEVTYPEJOYSTICK_UNKNOWN 1 -#define DIDEVTYPEJOYSTICK_TRADITIONAL 2 -#define DIDEVTYPEJOYSTICK_FLIGHTSTICK 3 -#define DIDEVTYPEJOYSTICK_GAMEPAD 4 -#define DIDEVTYPEJOYSTICK_RUDDER 5 -#define DIDEVTYPEJOYSTICK_WHEEL 6 -#define DIDEVTYPEJOYSTICK_HEADTRACKER 7 - -#define DI8DEVTYPEMOUSE_UNKNOWN 1 -#define DI8DEVTYPEMOUSE_TRADITIONAL 2 -#define DI8DEVTYPEMOUSE_FINGERSTICK 3 -#define DI8DEVTYPEMOUSE_TOUCHPAD 4 -#define DI8DEVTYPEMOUSE_TRACKBALL 5 -#define DI8DEVTYPEMOUSE_ABSOLUTE 6 - -#define DI8DEVTYPEKEYBOARD_UNKNOWN 0 -#define DI8DEVTYPEKEYBOARD_PCXT 1 -#define DI8DEVTYPEKEYBOARD_OLIVETTI 2 -#define DI8DEVTYPEKEYBOARD_PCAT 3 -#define DI8DEVTYPEKEYBOARD_PCENH 4 -#define DI8DEVTYPEKEYBOARD_NOKIA1050 5 -#define DI8DEVTYPEKEYBOARD_NOKIA9140 6 -#define DI8DEVTYPEKEYBOARD_NEC98 7 -#define DI8DEVTYPEKEYBOARD_NEC98LAPTOP 8 -#define DI8DEVTYPEKEYBOARD_NEC98106 9 -#define DI8DEVTYPEKEYBOARD_JAPAN106 10 -#define DI8DEVTYPEKEYBOARD_JAPANAX 11 -#define DI8DEVTYPEKEYBOARD_J3100 12 - -#define DI8DEVTYPE_LIMITEDGAMESUBTYPE 1 - -#define DI8DEVTYPEJOYSTICK_LIMITED DI8DEVTYPE_LIMITEDGAMESUBTYPE -#define DI8DEVTYPEJOYSTICK_STANDARD 2 - -#define DI8DEVTYPEGAMEPAD_LIMITED DI8DEVTYPE_LIMITEDGAMESUBTYPE -#define DI8DEVTYPEGAMEPAD_STANDARD 2 -#define DI8DEVTYPEGAMEPAD_TILT 3 - -#define DI8DEVTYPEDRIVING_LIMITED DI8DEVTYPE_LIMITEDGAMESUBTYPE -#define DI8DEVTYPEDRIVING_COMBINEDPEDALS 2 -#define DI8DEVTYPEDRIVING_DUALPEDALS 3 -#define DI8DEVTYPEDRIVING_THREEPEDALS 4 -#define DI8DEVTYPEDRIVING_HANDHELD 5 - -#define DI8DEVTYPEFLIGHT_LIMITED DI8DEVTYPE_LIMITEDGAMESUBTYPE -#define DI8DEVTYPEFLIGHT_STICK 2 -#define DI8DEVTYPEFLIGHT_YOKE 3 -#define DI8DEVTYPEFLIGHT_RC 4 - -#define DI8DEVTYPE1STPERSON_LIMITED DI8DEVTYPE_LIMITEDGAMESUBTYPE -#define DI8DEVTYPE1STPERSON_UNKNOWN 2 -#define DI8DEVTYPE1STPERSON_SIXDOF 3 -#define DI8DEVTYPE1STPERSON_SHOOTER 4 - -#define DI8DEVTYPESCREENPTR_UNKNOWN 2 -#define DI8DEVTYPESCREENPTR_LIGHTGUN 3 -#define DI8DEVTYPESCREENPTR_LIGHTPEN 4 -#define DI8DEVTYPESCREENPTR_TOUCH 5 - -#define DI8DEVTYPEREMOTE_UNKNOWN 2 - -#define DI8DEVTYPEDEVICECTRL_UNKNOWN 2 -#define DI8DEVTYPEDEVICECTRL_COMMSSELECTION 3 -#define DI8DEVTYPEDEVICECTRL_COMMSSELECTION_HARDWIRED 4 - -#define DI8DEVTYPESUPPLEMENTAL_UNKNOWN 2 -#define DI8DEVTYPESUPPLEMENTAL_2NDHANDCONTROLLER 3 -#define DI8DEVTYPESUPPLEMENTAL_HEADTRACKER 4 -#define DI8DEVTYPESUPPLEMENTAL_HANDTRACKER 5 -#define DI8DEVTYPESUPPLEMENTAL_SHIFTSTICKGATE 6 -#define DI8DEVTYPESUPPLEMENTAL_SHIFTER 7 -#define DI8DEVTYPESUPPLEMENTAL_THROTTLE 8 -#define DI8DEVTYPESUPPLEMENTAL_SPLITTHROTTLE 9 -#define DI8DEVTYPESUPPLEMENTAL_COMBINEDPEDALS 10 -#define DI8DEVTYPESUPPLEMENTAL_DUALPEDALS 11 -#define DI8DEVTYPESUPPLEMENTAL_THREEPEDALS 12 -#define DI8DEVTYPESUPPLEMENTAL_RUDDERPEDALS 13 - -#define GET_DIDEVICE_TYPE(dwDevType) LOBYTE(dwDevType) -#define GET_DIDEVICE_SUBTYPE(dwDevType) HIBYTE(dwDevType) - -typedef struct DIDEVICEOBJECTINSTANCE_DX3A { - DWORD dwSize; - GUID guidType; - DWORD dwOfs; - DWORD dwType; - DWORD dwFlags; - CHAR tszName[MAX_PATH]; -} DIDEVICEOBJECTINSTANCE_DX3A, *LPDIDEVICEOBJECTINSTANCE_DX3A; -typedef const DIDEVICEOBJECTINSTANCE_DX3A *LPCDIDEVICEOBJECTINSTANCE_DX3A; -typedef struct DIDEVICEOBJECTINSTANCE_DX3W { - DWORD dwSize; - GUID guidType; - DWORD dwOfs; - DWORD dwType; - DWORD dwFlags; - WCHAR tszName[MAX_PATH]; -} DIDEVICEOBJECTINSTANCE_DX3W, *LPDIDEVICEOBJECTINSTANCE_DX3W; -typedef const DIDEVICEOBJECTINSTANCE_DX3W *LPCDIDEVICEOBJECTINSTANCE_DX3W; - -DECL_WINELIB_TYPE_AW(DIDEVICEOBJECTINSTANCE_DX3) -DECL_WINELIB_TYPE_AW(LPDIDEVICEOBJECTINSTANCE_DX3) -DECL_WINELIB_TYPE_AW(LPCDIDEVICEOBJECTINSTANCE_DX3) - -typedef struct DIDEVICEOBJECTINSTANCEA { - DWORD dwSize; - GUID guidType; - DWORD dwOfs; - DWORD dwType; - DWORD dwFlags; - CHAR tszName[MAX_PATH]; -#if(DIRECTINPUT_VERSION >= 0x0500) - DWORD dwFFMaxForce; - DWORD dwFFForceResolution; - WORD wCollectionNumber; - WORD wDesignatorIndex; - WORD wUsagePage; - WORD wUsage; - DWORD dwDimension; - WORD wExponent; - WORD wReserved; -#endif /* DIRECTINPUT_VERSION >= 0x0500 */ -} DIDEVICEOBJECTINSTANCEA, *LPDIDEVICEOBJECTINSTANCEA; -typedef const DIDEVICEOBJECTINSTANCEA *LPCDIDEVICEOBJECTINSTANCEA; - -typedef struct DIDEVICEOBJECTINSTANCEW { - DWORD dwSize; - GUID guidType; - DWORD dwOfs; - DWORD dwType; - DWORD dwFlags; - WCHAR tszName[MAX_PATH]; -#if(DIRECTINPUT_VERSION >= 0x0500) - DWORD dwFFMaxForce; - DWORD dwFFForceResolution; - WORD wCollectionNumber; - WORD wDesignatorIndex; - WORD wUsagePage; - WORD wUsage; - DWORD dwDimension; - WORD wExponent; - WORD wReserved; -#endif /* DIRECTINPUT_VERSION >= 0x0500 */ -} DIDEVICEOBJECTINSTANCEW, *LPDIDEVICEOBJECTINSTANCEW; -typedef const DIDEVICEOBJECTINSTANCEW *LPCDIDEVICEOBJECTINSTANCEW; - -DECL_WINELIB_TYPE_AW(DIDEVICEOBJECTINSTANCE) -DECL_WINELIB_TYPE_AW(LPDIDEVICEOBJECTINSTANCE) -DECL_WINELIB_TYPE_AW(LPCDIDEVICEOBJECTINSTANCE) - -typedef struct DIDEVICEINSTANCE_DX3A { - DWORD dwSize; - GUID guidInstance; - GUID guidProduct; - DWORD dwDevType; - CHAR tszInstanceName[MAX_PATH]; - CHAR tszProductName[MAX_PATH]; -} DIDEVICEINSTANCE_DX3A, *LPDIDEVICEINSTANCE_DX3A; -typedef const DIDEVICEINSTANCE_DX3A *LPCDIDEVICEINSTANCE_DX3A; -typedef struct DIDEVICEINSTANCE_DX3W { - DWORD dwSize; - GUID guidInstance; - GUID guidProduct; - DWORD dwDevType; - WCHAR tszInstanceName[MAX_PATH]; - WCHAR tszProductName[MAX_PATH]; -} DIDEVICEINSTANCE_DX3W, *LPDIDEVICEINSTANCE_DX3W; -typedef const DIDEVICEINSTANCE_DX3W *LPCDIDEVICEINSTANCE_DX3W; - -DECL_WINELIB_TYPE_AW(DIDEVICEINSTANCE_DX3) -DECL_WINELIB_TYPE_AW(LPDIDEVICEINSTANCE_DX3) -DECL_WINELIB_TYPE_AW(LPCDIDEVICEINSTANCE_DX3) - -typedef struct DIDEVICEINSTANCEA { - DWORD dwSize; - GUID guidInstance; - GUID guidProduct; - DWORD dwDevType; - CHAR tszInstanceName[MAX_PATH]; - CHAR tszProductName[MAX_PATH]; -#if(DIRECTINPUT_VERSION >= 0x0500) - GUID guidFFDriver; - WORD wUsagePage; - WORD wUsage; -#endif /* DIRECTINPUT_VERSION >= 0x0500 */ -} DIDEVICEINSTANCEA, *LPDIDEVICEINSTANCEA; -typedef const DIDEVICEINSTANCEA *LPCDIDEVICEINSTANCEA; - -typedef struct DIDEVICEINSTANCEW { - DWORD dwSize; - GUID guidInstance; - GUID guidProduct; - DWORD dwDevType; - WCHAR tszInstanceName[MAX_PATH]; - WCHAR tszProductName[MAX_PATH]; -#if(DIRECTINPUT_VERSION >= 0x0500) - GUID guidFFDriver; - WORD wUsagePage; - WORD wUsage; -#endif /* DIRECTINPUT_VERSION >= 0x0500 */ -} DIDEVICEINSTANCEW, *LPDIDEVICEINSTANCEW; -typedef const DIDEVICEINSTANCEW *LPCDIDEVICEINSTANCEW; - -DECL_WINELIB_TYPE_AW(DIDEVICEINSTANCE) -DECL_WINELIB_TYPE_AW(LPDIDEVICEINSTANCE) -DECL_WINELIB_TYPE_AW(LPCDIDEVICEINSTANCE) - -typedef BOOL (CALLBACK *LPDIENUMDEVICESCALLBACKA)(LPCDIDEVICEINSTANCEA,LPVOID); -typedef BOOL (CALLBACK *LPDIENUMDEVICESCALLBACKW)(LPCDIDEVICEINSTANCEW,LPVOID); -DECL_WINELIB_TYPE_AW(LPDIENUMDEVICESCALLBACK) - -#define DIEDBS_MAPPEDPRI1 0x00000001 -#define DIEDBS_MAPPEDPRI2 0x00000002 -#define DIEDBS_RECENTDEVICE 0x00000010 -#define DIEDBS_NEWDEVICE 0x00000020 - -#define DIEDBSFL_ATTACHEDONLY 0x00000000 -#define DIEDBSFL_THISUSER 0x00000010 -#define DIEDBSFL_FORCEFEEDBACK DIEDFL_FORCEFEEDBACK -#define DIEDBSFL_AVAILABLEDEVICES 0x00001000 -#define DIEDBSFL_MULTIMICEKEYBOARDS 0x00002000 -#define DIEDBSFL_NONGAMINGDEVICES 0x00004000 -#define DIEDBSFL_VALID 0x00007110 - -#if DIRECTINPUT_VERSION >= 0x0800 -typedef BOOL (CALLBACK *LPDIENUMDEVICESBYSEMANTICSCBA)(LPCDIDEVICEINSTANCEA,LPDIRECTINPUTDEVICE8A,DWORD,DWORD,LPVOID); -typedef BOOL (CALLBACK *LPDIENUMDEVICESBYSEMANTICSCBW)(LPCDIDEVICEINSTANCEW,LPDIRECTINPUTDEVICE8W,DWORD,DWORD,LPVOID); -DECL_WINELIB_TYPE_AW(LPDIENUMDEVICESBYSEMANTICSCB) -#endif - -typedef BOOL (CALLBACK *LPDICONFIGUREDEVICESCALLBACK)(LPUNKNOWN,LPVOID); - -typedef BOOL (CALLBACK *LPDIENUMDEVICEOBJECTSCALLBACKA)(LPCDIDEVICEOBJECTINSTANCEA,LPVOID); -typedef BOOL (CALLBACK *LPDIENUMDEVICEOBJECTSCALLBACKW)(LPCDIDEVICEOBJECTINSTANCEW,LPVOID); -DECL_WINELIB_TYPE_AW(LPDIENUMDEVICEOBJECTSCALLBACK) - -#if DIRECTINPUT_VERSION >= 0x0500 -typedef BOOL (CALLBACK *LPDIENUMCREATEDEFFECTOBJECTSCALLBACK)(LPDIRECTINPUTEFFECT, LPVOID); -#endif - -#define DIK_ESCAPE 0x01 -#define DIK_1 0x02 -#define DIK_2 0x03 -#define DIK_3 0x04 -#define DIK_4 0x05 -#define DIK_5 0x06 -#define DIK_6 0x07 -#define DIK_7 0x08 -#define DIK_8 0x09 -#define DIK_9 0x0A -#define DIK_0 0x0B -#define DIK_MINUS 0x0C /* - on main keyboard */ -#define DIK_EQUALS 0x0D -#define DIK_BACK 0x0E /* backspace */ -#define DIK_TAB 0x0F -#define DIK_Q 0x10 -#define DIK_W 0x11 -#define DIK_E 0x12 -#define DIK_R 0x13 -#define DIK_T 0x14 -#define DIK_Y 0x15 -#define DIK_U 0x16 -#define DIK_I 0x17 -#define DIK_O 0x18 -#define DIK_P 0x19 -#define DIK_LBRACKET 0x1A -#define DIK_RBRACKET 0x1B -#define DIK_RETURN 0x1C /* Enter on main keyboard */ -#define DIK_LCONTROL 0x1D -#define DIK_A 0x1E -#define DIK_S 0x1F -#define DIK_D 0x20 -#define DIK_F 0x21 -#define DIK_G 0x22 -#define DIK_H 0x23 -#define DIK_J 0x24 -#define DIK_K 0x25 -#define DIK_L 0x26 -#define DIK_SEMICOLON 0x27 -#define DIK_APOSTROPHE 0x28 -#define DIK_GRAVE 0x29 /* accent grave */ -#define DIK_LSHIFT 0x2A -#define DIK_BACKSLASH 0x2B -#define DIK_Z 0x2C -#define DIK_X 0x2D -#define DIK_C 0x2E -#define DIK_V 0x2F -#define DIK_B 0x30 -#define DIK_N 0x31 -#define DIK_M 0x32 -#define DIK_COMMA 0x33 -#define DIK_PERIOD 0x34 /* . on main keyboard */ -#define DIK_SLASH 0x35 /* / on main keyboard */ -#define DIK_RSHIFT 0x36 -#define DIK_MULTIPLY 0x37 /* * on numeric keypad */ -#define DIK_LMENU 0x38 /* left Alt */ -#define DIK_SPACE 0x39 -#define DIK_CAPITAL 0x3A -#define DIK_F1 0x3B -#define DIK_F2 0x3C -#define DIK_F3 0x3D -#define DIK_F4 0x3E -#define DIK_F5 0x3F -#define DIK_F6 0x40 -#define DIK_F7 0x41 -#define DIK_F8 0x42 -#define DIK_F9 0x43 -#define DIK_F10 0x44 -#define DIK_NUMLOCK 0x45 -#define DIK_SCROLL 0x46 /* Scroll Lock */ -#define DIK_NUMPAD7 0x47 -#define DIK_NUMPAD8 0x48 -#define DIK_NUMPAD9 0x49 -#define DIK_SUBTRACT 0x4A /* - on numeric keypad */ -#define DIK_NUMPAD4 0x4B -#define DIK_NUMPAD5 0x4C -#define DIK_NUMPAD6 0x4D -#define DIK_ADD 0x4E /* + on numeric keypad */ -#define DIK_NUMPAD1 0x4F -#define DIK_NUMPAD2 0x50 -#define DIK_NUMPAD3 0x51 -#define DIK_NUMPAD0 0x52 -#define DIK_DECIMAL 0x53 /* . on numeric keypad */ -#define DIK_OEM_102 0x56 /* < > | on UK/Germany keyboards */ -#define DIK_F11 0x57 -#define DIK_F12 0x58 -#define DIK_F13 0x64 /* (NEC PC98) */ -#define DIK_F14 0x65 /* (NEC PC98) */ -#define DIK_F15 0x66 /* (NEC PC98) */ -#define DIK_KANA 0x70 /* (Japanese keyboard) */ -#define DIK_ABNT_C1 0x73 /* / ? on Portugese (Brazilian) keyboards */ -#define DIK_CONVERT 0x79 /* (Japanese keyboard) */ -#define DIK_NOCONVERT 0x7B /* (Japanese keyboard) */ -#define DIK_YEN 0x7D /* (Japanese keyboard) */ -#define DIK_ABNT_C2 0x7E /* Numpad . on Portugese (Brazilian) keyboards */ -#define DIK_NUMPADEQUALS 0x8D /* = on numeric keypad (NEC PC98) */ -#define DIK_CIRCUMFLEX 0x90 /* (Japanese keyboard) */ -#define DIK_AT 0x91 /* (NEC PC98) */ -#define DIK_COLON 0x92 /* (NEC PC98) */ -#define DIK_UNDERLINE 0x93 /* (NEC PC98) */ -#define DIK_KANJI 0x94 /* (Japanese keyboard) */ -#define DIK_STOP 0x95 /* (NEC PC98) */ -#define DIK_AX 0x96 /* (Japan AX) */ -#define DIK_UNLABELED 0x97 /* (J3100) */ -#define DIK_NEXTTRACK 0x99 /* Next Track */ -#define DIK_NUMPADENTER 0x9C /* Enter on numeric keypad */ -#define DIK_RCONTROL 0x9D -#define DIK_MUTE 0xA0 /* Mute */ -#define DIK_CALCULATOR 0xA1 /* Calculator */ -#define DIK_PLAYPAUSE 0xA2 /* Play / Pause */ -#define DIK_MEDIASTOP 0xA4 /* Media Stop */ -#define DIK_VOLUMEDOWN 0xAE /* Volume - */ -#define DIK_VOLUMEUP 0xB0 /* Volume + */ -#define DIK_WEBHOME 0xB2 /* Web home */ -#define DIK_NUMPADCOMMA 0xB3 /* , on numeric keypad (NEC PC98) */ -#define DIK_DIVIDE 0xB5 /* / on numeric keypad */ -#define DIK_SYSRQ 0xB7 -#define DIK_RMENU 0xB8 /* right Alt */ -#define DIK_PAUSE 0xC5 /* Pause */ -#define DIK_HOME 0xC7 /* Home on arrow keypad */ -#define DIK_UP 0xC8 /* UpArrow on arrow keypad */ -#define DIK_PRIOR 0xC9 /* PgUp on arrow keypad */ -#define DIK_LEFT 0xCB /* LeftArrow on arrow keypad */ -#define DIK_RIGHT 0xCD /* RightArrow on arrow keypad */ -#define DIK_END 0xCF /* End on arrow keypad */ -#define DIK_DOWN 0xD0 /* DownArrow on arrow keypad */ -#define DIK_NEXT 0xD1 /* PgDn on arrow keypad */ -#define DIK_INSERT 0xD2 /* Insert on arrow keypad */ -#define DIK_DELETE 0xD3 /* Delete on arrow keypad */ -#define DIK_LWIN 0xDB /* Left Windows key */ -#define DIK_RWIN 0xDC /* Right Windows key */ -#define DIK_APPS 0xDD /* AppMenu key */ -#define DIK_POWER 0xDE -#define DIK_SLEEP 0xDF -#define DIK_WAKE 0xE3 /* System Wake */ -#define DIK_WEBSEARCH 0xE5 /* Web Search */ -#define DIK_WEBFAVORITES 0xE6 /* Web Favorites */ -#define DIK_WEBREFRESH 0xE7 /* Web Refresh */ -#define DIK_WEBSTOP 0xE8 /* Web Stop */ -#define DIK_WEBFORWARD 0xE9 /* Web Forward */ -#define DIK_WEBBACK 0xEA /* Web Back */ -#define DIK_MYCOMPUTER 0xEB /* My Computer */ -#define DIK_MAIL 0xEC /* Mail */ -#define DIK_MEDIASELECT 0xED /* Media Select */ - -#define DIK_BACKSPACE DIK_BACK /* backspace */ -#define DIK_NUMPADSTAR DIK_MULTIPLY /* * on numeric keypad */ -#define DIK_LALT DIK_LMENU /* left Alt */ -#define DIK_CAPSLOCK DIK_CAPITAL /* CapsLock */ -#define DIK_NUMPADMINUS DIK_SUBTRACT /* - on numeric keypad */ -#define DIK_NUMPADPLUS DIK_ADD /* + on numeric keypad */ -#define DIK_NUMPADPERIOD DIK_DECIMAL /* . on numeric keypad */ -#define DIK_NUMPADSLASH DIK_DIVIDE /* / on numeric keypad */ -#define DIK_RALT DIK_RMENU /* right Alt */ -#define DIK_UPARROW DIK_UP /* UpArrow on arrow keypad */ -#define DIK_PGUP DIK_PRIOR /* PgUp on arrow keypad */ -#define DIK_LEFTARROW DIK_LEFT /* LeftArrow on arrow keypad */ -#define DIK_RIGHTARROW DIK_RIGHT /* RightArrow on arrow keypad */ -#define DIK_DOWNARROW DIK_DOWN /* DownArrow on arrow keypad */ -#define DIK_PGDN DIK_NEXT /* PgDn on arrow keypad */ - -#define DIDFT_ALL 0x00000000 -#define DIDFT_RELAXIS 0x00000001 -#define DIDFT_ABSAXIS 0x00000002 -#define DIDFT_AXIS 0x00000003 -#define DIDFT_PSHBUTTON 0x00000004 -#define DIDFT_TGLBUTTON 0x00000008 -#define DIDFT_BUTTON 0x0000000C -#define DIDFT_POV 0x00000010 -#define DIDFT_COLLECTION 0x00000040 -#define DIDFT_NODATA 0x00000080 -#define DIDFT_ANYINSTANCE 0x00FFFF00 -#define DIDFT_INSTANCEMASK DIDFT_ANYINSTANCE -#define DIDFT_MAKEINSTANCE(n) ((WORD)(n) << 8) -#define DIDFT_GETTYPE(n) LOBYTE(n) -#define DIDFT_GETINSTANCE(n) LOWORD((n) >> 8) -#define DIDFT_FFACTUATOR 0x01000000 -#define DIDFT_FFEFFECTTRIGGER 0x02000000 -#if DIRECTINPUT_VERSION >= 0x050a -#define DIDFT_OUTPUT 0x10000000 -#define DIDFT_VENDORDEFINED 0x04000000 -#define DIDFT_ALIAS 0x08000000 -#endif /* DI5a */ -#ifndef DIDFT_OPTIONAL -#define DIDFT_OPTIONAL 0x80000000 -#endif -#define DIDFT_ENUMCOLLECTION(n) ((WORD)(n) << 8) -#define DIDFT_NOCOLLECTION 0x00FFFF00 - -#define DIDF_ABSAXIS 0x00000001 -#define DIDF_RELAXIS 0x00000002 - -#define DIGDD_PEEK 0x00000001 - -#define DISEQUENCE_COMPARE(dwSq1,cmp,dwSq2) ((int)((dwSq1) - (dwSq2)) cmp 0) - -typedef struct DIDEVICEOBJECTDATA_DX3 { - DWORD dwOfs; - DWORD dwData; - DWORD dwTimeStamp; - DWORD dwSequence; -} DIDEVICEOBJECTDATA_DX3,*LPDIDEVICEOBJECTDATA_DX3; -typedef const DIDEVICEOBJECTDATA_DX3 *LPCDIDEVICEOBJECTDATA_DX3; - -typedef struct DIDEVICEOBJECTDATA { - DWORD dwOfs; - DWORD dwData; - DWORD dwTimeStamp; - DWORD dwSequence; -#if(DIRECTINPUT_VERSION >= 0x0800) - UINT_PTR uAppData; -#endif /* DIRECTINPUT_VERSION >= 0x0800 */ -} DIDEVICEOBJECTDATA, *LPDIDEVICEOBJECTDATA; -typedef const DIDEVICEOBJECTDATA *LPCDIDEVICEOBJECTDATA; - -typedef struct _DIOBJECTDATAFORMAT { - const GUID *pguid; - DWORD dwOfs; - DWORD dwType; - DWORD dwFlags; -} DIOBJECTDATAFORMAT, *LPDIOBJECTDATAFORMAT; -typedef const DIOBJECTDATAFORMAT *LPCDIOBJECTDATAFORMAT; - -typedef struct _DIDATAFORMAT { - DWORD dwSize; - DWORD dwObjSize; - DWORD dwFlags; - DWORD dwDataSize; - DWORD dwNumObjs; - LPDIOBJECTDATAFORMAT rgodf; -} DIDATAFORMAT, *LPDIDATAFORMAT; -typedef const DIDATAFORMAT *LPCDIDATAFORMAT; - -#if DIRECTINPUT_VERSION >= 0x0500 -#define DIDOI_FFACTUATOR 0x00000001 -#define DIDOI_FFEFFECTTRIGGER 0x00000002 -#define DIDOI_POLLED 0x00008000 -#define DIDOI_ASPECTPOSITION 0x00000100 -#define DIDOI_ASPECTVELOCITY 0x00000200 -#define DIDOI_ASPECTACCEL 0x00000300 -#define DIDOI_ASPECTFORCE 0x00000400 -#define DIDOI_ASPECTMASK 0x00000F00 -#endif /* DI5 */ -#if DIRECTINPUT_VERSION >= 0x050a -#define DIDOI_GUIDISUSAGE 0x00010000 -#endif /* DI5a */ - -typedef struct DIPROPHEADER { - DWORD dwSize; - DWORD dwHeaderSize; - DWORD dwObj; - DWORD dwHow; -} DIPROPHEADER,*LPDIPROPHEADER; -typedef const DIPROPHEADER *LPCDIPROPHEADER; - -#define DIPH_DEVICE 0 -#define DIPH_BYOFFSET 1 -#define DIPH_BYID 2 -#if DIRECTINPUT_VERSION >= 0x050a -#define DIPH_BYUSAGE 3 - -#define DIMAKEUSAGEDWORD(UsagePage, Usage) (DWORD)MAKELONG(Usage, UsagePage) -#endif /* DI5a */ - -typedef struct DIPROPDWORD { - DIPROPHEADER diph; - DWORD dwData; -} DIPROPDWORD, *LPDIPROPDWORD; -typedef const DIPROPDWORD *LPCDIPROPDWORD; - -typedef struct DIPROPRANGE { - DIPROPHEADER diph; - LONG lMin; - LONG lMax; -} DIPROPRANGE, *LPDIPROPRANGE; -typedef const DIPROPRANGE *LPCDIPROPRANGE; - -#define DIPROPRANGE_NOMIN ((LONG)0x80000000) -#define DIPROPRANGE_NOMAX ((LONG)0x7FFFFFFF) - -#if DIRECTINPUT_VERSION >= 0x050a -typedef struct DIPROPCAL { - DIPROPHEADER diph; - LONG lMin; - LONG lCenter; - LONG lMax; -} DIPROPCAL, *LPDIPROPCAL; -typedef const DIPROPCAL *LPCDIPROPCAL; - -typedef struct DIPROPCALPOV { - DIPROPHEADER diph; - LONG lMin[5]; - LONG lMax[5]; -} DIPROPCALPOV, *LPDIPROPCALPOV; -typedef const DIPROPCALPOV *LPCDIPROPCALPOV; - -typedef struct DIPROPGUIDANDPATH { - DIPROPHEADER diph; - GUID guidClass; - WCHAR wszPath[MAX_PATH]; -} DIPROPGUIDANDPATH, *LPDIPROPGUIDANDPATH; -typedef const DIPROPGUIDANDPATH *LPCDIPROPGUIDANDPATH; - -typedef struct DIPROPSTRING { - DIPROPHEADER diph; - WCHAR wsz[MAX_PATH]; -} DIPROPSTRING, *LPDIPROPSTRING; -typedef const DIPROPSTRING *LPCDIPROPSTRING; -#endif /* DI5a */ - -#if DIRECTINPUT_VERSION >= 0x0800 -typedef struct DIPROPPOINTER { - DIPROPHEADER diph; - UINT_PTR uData; -} DIPROPPOINTER, *LPDIPROPPOINTER; -typedef const DIPROPPOINTER *LPCDIPROPPOINTER; -#endif /* DI8 */ - -/* special property GUIDs */ -#ifdef __cplusplus -#define MAKEDIPROP(prop) (*(const GUID *)(prop)) -#else -#define MAKEDIPROP(prop) ((REFGUID)(prop)) -#endif -#define DIPROP_BUFFERSIZE MAKEDIPROP(1) -#define DIPROP_AXISMODE MAKEDIPROP(2) - -#define DIPROPAXISMODE_ABS 0 -#define DIPROPAXISMODE_REL 1 - -#define DIPROP_GRANULARITY MAKEDIPROP(3) -#define DIPROP_RANGE MAKEDIPROP(4) -#define DIPROP_DEADZONE MAKEDIPROP(5) -#define DIPROP_SATURATION MAKEDIPROP(6) -#define DIPROP_FFGAIN MAKEDIPROP(7) -#define DIPROP_FFLOAD MAKEDIPROP(8) -#define DIPROP_AUTOCENTER MAKEDIPROP(9) - -#define DIPROPAUTOCENTER_OFF 0 -#define DIPROPAUTOCENTER_ON 1 - -#define DIPROP_CALIBRATIONMODE MAKEDIPROP(10) - -#define DIPROPCALIBRATIONMODE_COOKED 0 -#define DIPROPCALIBRATIONMODE_RAW 1 - -#if DIRECTINPUT_VERSION >= 0x050a -#define DIPROP_CALIBRATION MAKEDIPROP(11) -#define DIPROP_GUIDANDPATH MAKEDIPROP(12) -#define DIPROP_INSTANCENAME MAKEDIPROP(13) -#define DIPROP_PRODUCTNAME MAKEDIPROP(14) -#endif - -#if DIRECTINPUT_VERSION >= 0x5B2 -#define DIPROP_JOYSTICKID MAKEDIPROP(15) -#define DIPROP_GETPORTDISPLAYNAME MAKEDIPROP(16) -#endif - -#if DIRECTINPUT_VERSION >= 0x0700 -#define DIPROP_PHYSICALRANGE MAKEDIPROP(18) -#define DIPROP_LOGICALRANGE MAKEDIPROP(19) -#endif - -#if(DIRECTINPUT_VERSION >= 0x0800) -#define DIPROP_KEYNAME MAKEDIPROP(20) -#define DIPROP_CPOINTS MAKEDIPROP(21) -#define DIPROP_APPDATA MAKEDIPROP(22) -#define DIPROP_SCANCODE MAKEDIPROP(23) -#define DIPROP_VIDPID MAKEDIPROP(24) -#define DIPROP_USERNAME MAKEDIPROP(25) -#define DIPROP_TYPENAME MAKEDIPROP(26) - -#define MAXCPOINTSNUM 8 - -typedef struct _CPOINT { - LONG lP; - DWORD dwLog; -} CPOINT, *PCPOINT; - -typedef struct DIPROPCPOINTS { - DIPROPHEADER diph; - DWORD dwCPointsNum; - CPOINT cp[MAXCPOINTSNUM]; -} DIPROPCPOINTS, *LPDIPROPCPOINTS; -typedef const DIPROPCPOINTS *LPCDIPROPCPOINTS; -#endif /* DI8 */ - - -typedef struct DIDEVCAPS_DX3 { - DWORD dwSize; - DWORD dwFlags; - DWORD dwDevType; - DWORD dwAxes; - DWORD dwButtons; - DWORD dwPOVs; -} DIDEVCAPS_DX3, *LPDIDEVCAPS_DX3; - -typedef struct DIDEVCAPS { - DWORD dwSize; - DWORD dwFlags; - DWORD dwDevType; - DWORD dwAxes; - DWORD dwButtons; - DWORD dwPOVs; -#if(DIRECTINPUT_VERSION >= 0x0500) - DWORD dwFFSamplePeriod; - DWORD dwFFMinTimeResolution; - DWORD dwFirmwareRevision; - DWORD dwHardwareRevision; - DWORD dwFFDriverVersion; -#endif /* DIRECTINPUT_VERSION >= 0x0500 */ -} DIDEVCAPS,*LPDIDEVCAPS; - -#define DIDC_ATTACHED 0x00000001 -#define DIDC_POLLEDDEVICE 0x00000002 -#define DIDC_EMULATED 0x00000004 -#define DIDC_POLLEDDATAFORMAT 0x00000008 -#define DIDC_FORCEFEEDBACK 0x00000100 -#define DIDC_FFATTACK 0x00000200 -#define DIDC_FFFADE 0x00000400 -#define DIDC_SATURATION 0x00000800 -#define DIDC_POSNEGCOEFFICIENTS 0x00001000 -#define DIDC_POSNEGSATURATION 0x00002000 -#define DIDC_DEADBAND 0x00004000 -#define DIDC_STARTDELAY 0x00008000 -#define DIDC_ALIAS 0x00010000 -#define DIDC_PHANTOM 0x00020000 -#define DIDC_HIDDEN 0x00040000 - - -/* SetCooperativeLevel dwFlags */ -#define DISCL_EXCLUSIVE 0x00000001 -#define DISCL_NONEXCLUSIVE 0x00000002 -#define DISCL_FOREGROUND 0x00000004 -#define DISCL_BACKGROUND 0x00000008 -#define DISCL_NOWINKEY 0x00000010 - -#if (DIRECTINPUT_VERSION >= 0x0500) -/* Device FF flags */ -#define DISFFC_RESET 0x00000001 -#define DISFFC_STOPALL 0x00000002 -#define DISFFC_PAUSE 0x00000004 -#define DISFFC_CONTINUE 0x00000008 -#define DISFFC_SETACTUATORSON 0x00000010 -#define DISFFC_SETACTUATORSOFF 0x00000020 - -#define DIGFFS_EMPTY 0x00000001 -#define DIGFFS_STOPPED 0x00000002 -#define DIGFFS_PAUSED 0x00000004 -#define DIGFFS_ACTUATORSON 0x00000010 -#define DIGFFS_ACTUATORSOFF 0x00000020 -#define DIGFFS_POWERON 0x00000040 -#define DIGFFS_POWEROFF 0x00000080 -#define DIGFFS_SAFETYSWITCHON 0x00000100 -#define DIGFFS_SAFETYSWITCHOFF 0x00000200 -#define DIGFFS_USERFFSWITCHON 0x00000400 -#define DIGFFS_USERFFSWITCHOFF 0x00000800 -#define DIGFFS_DEVICELOST 0x80000000 - -/* Effect flags */ -#define DIEFT_ALL 0x00000000 - -#define DIEFT_CONSTANTFORCE 0x00000001 -#define DIEFT_RAMPFORCE 0x00000002 -#define DIEFT_PERIODIC 0x00000003 -#define DIEFT_CONDITION 0x00000004 -#define DIEFT_CUSTOMFORCE 0x00000005 -#define DIEFT_HARDWARE 0x000000FF -#define DIEFT_FFATTACK 0x00000200 -#define DIEFT_FFFADE 0x00000400 -#define DIEFT_SATURATION 0x00000800 -#define DIEFT_POSNEGCOEFFICIENTS 0x00001000 -#define DIEFT_POSNEGSATURATION 0x00002000 -#define DIEFT_DEADBAND 0x00004000 -#define DIEFT_STARTDELAY 0x00008000 -#define DIEFT_GETTYPE(n) LOBYTE(n) - -#define DIEFF_OBJECTIDS 0x00000001 -#define DIEFF_OBJECTOFFSETS 0x00000002 -#define DIEFF_CARTESIAN 0x00000010 -#define DIEFF_POLAR 0x00000020 -#define DIEFF_SPHERICAL 0x00000040 - -#define DIEP_DURATION 0x00000001 -#define DIEP_SAMPLEPERIOD 0x00000002 -#define DIEP_GAIN 0x00000004 -#define DIEP_TRIGGERBUTTON 0x00000008 -#define DIEP_TRIGGERREPEATINTERVAL 0x00000010 -#define DIEP_AXES 0x00000020 -#define DIEP_DIRECTION 0x00000040 -#define DIEP_ENVELOPE 0x00000080 -#define DIEP_TYPESPECIFICPARAMS 0x00000100 -#if(DIRECTINPUT_VERSION >= 0x0600) -#define DIEP_STARTDELAY 0x00000200 -#define DIEP_ALLPARAMS_DX5 0x000001FF -#define DIEP_ALLPARAMS 0x000003FF -#else -#define DIEP_ALLPARAMS 0x000001FF -#endif /* DIRECTINPUT_VERSION >= 0x0600 */ -#define DIEP_START 0x20000000 -#define DIEP_NORESTART 0x40000000 -#define DIEP_NODOWNLOAD 0x80000000 -#define DIEB_NOTRIGGER 0xFFFFFFFF - -#define DIES_SOLO 0x00000001 -#define DIES_NODOWNLOAD 0x80000000 - -#define DIEGES_PLAYING 0x00000001 -#define DIEGES_EMULATED 0x00000002 - -#define DI_DEGREES 100 -#define DI_FFNOMINALMAX 10000 -#define DI_SECONDS 1000000 - -typedef struct DICONSTANTFORCE { - LONG lMagnitude; -} DICONSTANTFORCE, *LPDICONSTANTFORCE; -typedef const DICONSTANTFORCE *LPCDICONSTANTFORCE; - -typedef struct DIRAMPFORCE { - LONG lStart; - LONG lEnd; -} DIRAMPFORCE, *LPDIRAMPFORCE; -typedef const DIRAMPFORCE *LPCDIRAMPFORCE; - -typedef struct DIPERIODIC { - DWORD dwMagnitude; - LONG lOffset; - DWORD dwPhase; - DWORD dwPeriod; -} DIPERIODIC, *LPDIPERIODIC; -typedef const DIPERIODIC *LPCDIPERIODIC; - -typedef struct DICONDITION { - LONG lOffset; - LONG lPositiveCoefficient; - LONG lNegativeCoefficient; - DWORD dwPositiveSaturation; - DWORD dwNegativeSaturation; - LONG lDeadBand; -} DICONDITION, *LPDICONDITION; -typedef const DICONDITION *LPCDICONDITION; - -typedef struct DICUSTOMFORCE { - DWORD cChannels; - DWORD dwSamplePeriod; - DWORD cSamples; - LPLONG rglForceData; -} DICUSTOMFORCE, *LPDICUSTOMFORCE; -typedef const DICUSTOMFORCE *LPCDICUSTOMFORCE; - -typedef struct DIENVELOPE { - DWORD dwSize; - DWORD dwAttackLevel; - DWORD dwAttackTime; - DWORD dwFadeLevel; - DWORD dwFadeTime; -} DIENVELOPE, *LPDIENVELOPE; -typedef const DIENVELOPE *LPCDIENVELOPE; - -typedef struct DIEFFECT_DX5 { - DWORD dwSize; - DWORD dwFlags; - DWORD dwDuration; - DWORD dwSamplePeriod; - DWORD dwGain; - DWORD dwTriggerButton; - DWORD dwTriggerRepeatInterval; - DWORD cAxes; - LPDWORD rgdwAxes; - LPLONG rglDirection; - LPDIENVELOPE lpEnvelope; - DWORD cbTypeSpecificParams; - LPVOID lpvTypeSpecificParams; -} DIEFFECT_DX5, *LPDIEFFECT_DX5; -typedef const DIEFFECT_DX5 *LPCDIEFFECT_DX5; - -typedef struct DIEFFECT { - DWORD dwSize; - DWORD dwFlags; - DWORD dwDuration; - DWORD dwSamplePeriod; - DWORD dwGain; - DWORD dwTriggerButton; - DWORD dwTriggerRepeatInterval; - DWORD cAxes; - LPDWORD rgdwAxes; - LPLONG rglDirection; - LPDIENVELOPE lpEnvelope; - DWORD cbTypeSpecificParams; - LPVOID lpvTypeSpecificParams; -#if(DIRECTINPUT_VERSION >= 0x0600) - DWORD dwStartDelay; -#endif /* DIRECTINPUT_VERSION >= 0x0600 */ -} DIEFFECT, *LPDIEFFECT; -typedef const DIEFFECT *LPCDIEFFECT; -typedef DIEFFECT DIEFFECT_DX6; -typedef LPDIEFFECT LPDIEFFECT_DX6; - -typedef struct DIEFFECTINFOA { - DWORD dwSize; - GUID guid; - DWORD dwEffType; - DWORD dwStaticParams; - DWORD dwDynamicParams; - CHAR tszName[MAX_PATH]; -} DIEFFECTINFOA, *LPDIEFFECTINFOA; -typedef const DIEFFECTINFOA *LPCDIEFFECTINFOA; - -typedef struct DIEFFECTINFOW { - DWORD dwSize; - GUID guid; - DWORD dwEffType; - DWORD dwStaticParams; - DWORD dwDynamicParams; - WCHAR tszName[MAX_PATH]; -} DIEFFECTINFOW, *LPDIEFFECTINFOW; -typedef const DIEFFECTINFOW *LPCDIEFFECTINFOW; - -DECL_WINELIB_TYPE_AW(DIEFFECTINFO) -DECL_WINELIB_TYPE_AW(LPDIEFFECTINFO) -DECL_WINELIB_TYPE_AW(LPCDIEFFECTINFO) - -typedef BOOL (CALLBACK *LPDIENUMEFFECTSCALLBACKA)(LPCDIEFFECTINFOA, LPVOID); -typedef BOOL (CALLBACK *LPDIENUMEFFECTSCALLBACKW)(LPCDIEFFECTINFOW, LPVOID); - -typedef struct DIEFFESCAPE { - DWORD dwSize; - DWORD dwCommand; - LPVOID lpvInBuffer; - DWORD cbInBuffer; - LPVOID lpvOutBuffer; - DWORD cbOutBuffer; -} DIEFFESCAPE, *LPDIEFFESCAPE; - -typedef struct DIJOYSTATE { - LONG lX; - LONG lY; - LONG lZ; - LONG lRx; - LONG lRy; - LONG lRz; - LONG rglSlider[2]; - DWORD rgdwPOV[4]; - BYTE rgbButtons[32]; -} DIJOYSTATE, *LPDIJOYSTATE; - -typedef struct DIJOYSTATE2 { - LONG lX; - LONG lY; - LONG lZ; - LONG lRx; - LONG lRy; - LONG lRz; - LONG rglSlider[2]; - DWORD rgdwPOV[4]; - BYTE rgbButtons[128]; - LONG lVX; /* 'v' as in velocity */ - LONG lVY; - LONG lVZ; - LONG lVRx; - LONG lVRy; - LONG lVRz; - LONG rglVSlider[2]; - LONG lAX; /* 'a' as in acceleration */ - LONG lAY; - LONG lAZ; - LONG lARx; - LONG lARy; - LONG lARz; - LONG rglASlider[2]; - LONG lFX; /* 'f' as in force */ - LONG lFY; - LONG lFZ; - LONG lFRx; /* 'fr' as in rotational force aka torque */ - LONG lFRy; - LONG lFRz; - LONG rglFSlider[2]; -} DIJOYSTATE2, *LPDIJOYSTATE2; - -#define DIJOFS_X FIELD_OFFSET(DIJOYSTATE, lX) -#define DIJOFS_Y FIELD_OFFSET(DIJOYSTATE, lY) -#define DIJOFS_Z FIELD_OFFSET(DIJOYSTATE, lZ) -#define DIJOFS_RX FIELD_OFFSET(DIJOYSTATE, lRx) -#define DIJOFS_RY FIELD_OFFSET(DIJOYSTATE, lRy) -#define DIJOFS_RZ FIELD_OFFSET(DIJOYSTATE, lRz) -#define DIJOFS_SLIDER(n) (FIELD_OFFSET(DIJOYSTATE, rglSlider) + \ - (n) * sizeof(LONG)) -#define DIJOFS_POV(n) (FIELD_OFFSET(DIJOYSTATE, rgdwPOV) + \ - (n) * sizeof(DWORD)) -#define DIJOFS_BUTTON(n) (FIELD_OFFSET(DIJOYSTATE, rgbButtons) + (n)) -#define DIJOFS_BUTTON0 DIJOFS_BUTTON(0) -#define DIJOFS_BUTTON1 DIJOFS_BUTTON(1) -#define DIJOFS_BUTTON2 DIJOFS_BUTTON(2) -#define DIJOFS_BUTTON3 DIJOFS_BUTTON(3) -#define DIJOFS_BUTTON4 DIJOFS_BUTTON(4) -#define DIJOFS_BUTTON5 DIJOFS_BUTTON(5) -#define DIJOFS_BUTTON6 DIJOFS_BUTTON(6) -#define DIJOFS_BUTTON7 DIJOFS_BUTTON(7) -#define DIJOFS_BUTTON8 DIJOFS_BUTTON(8) -#define DIJOFS_BUTTON9 DIJOFS_BUTTON(9) -#define DIJOFS_BUTTON10 DIJOFS_BUTTON(10) -#define DIJOFS_BUTTON11 DIJOFS_BUTTON(11) -#define DIJOFS_BUTTON12 DIJOFS_BUTTON(12) -#define DIJOFS_BUTTON13 DIJOFS_BUTTON(13) -#define DIJOFS_BUTTON14 DIJOFS_BUTTON(14) -#define DIJOFS_BUTTON15 DIJOFS_BUTTON(15) -#define DIJOFS_BUTTON16 DIJOFS_BUTTON(16) -#define DIJOFS_BUTTON17 DIJOFS_BUTTON(17) -#define DIJOFS_BUTTON18 DIJOFS_BUTTON(18) -#define DIJOFS_BUTTON19 DIJOFS_BUTTON(19) -#define DIJOFS_BUTTON20 DIJOFS_BUTTON(20) -#define DIJOFS_BUTTON21 DIJOFS_BUTTON(21) -#define DIJOFS_BUTTON22 DIJOFS_BUTTON(22) -#define DIJOFS_BUTTON23 DIJOFS_BUTTON(23) -#define DIJOFS_BUTTON24 DIJOFS_BUTTON(24) -#define DIJOFS_BUTTON25 DIJOFS_BUTTON(25) -#define DIJOFS_BUTTON26 DIJOFS_BUTTON(26) -#define DIJOFS_BUTTON27 DIJOFS_BUTTON(27) -#define DIJOFS_BUTTON28 DIJOFS_BUTTON(28) -#define DIJOFS_BUTTON29 DIJOFS_BUTTON(29) -#define DIJOFS_BUTTON30 DIJOFS_BUTTON(30) -#define DIJOFS_BUTTON31 DIJOFS_BUTTON(31) -#endif /* DIRECTINPUT_VERSION >= 0x0500 */ - -/* DInput 7 structures, types */ -#if(DIRECTINPUT_VERSION >= 0x0700) -typedef struct DIFILEEFFECT { - DWORD dwSize; - GUID GuidEffect; - LPCDIEFFECT lpDiEffect; - CHAR szFriendlyName[MAX_PATH]; -} DIFILEEFFECT, *LPDIFILEEFFECT; - -typedef const DIFILEEFFECT *LPCDIFILEEFFECT; -typedef BOOL (CALLBACK *LPDIENUMEFFECTSINFILECALLBACK)(LPCDIFILEEFFECT , LPVOID); -#endif /* DIRECTINPUT_VERSION >= 0x0700 */ - -/* DInput 8 structures and types */ -#if DIRECTINPUT_VERSION >= 0x0800 -typedef struct _DIACTIONA { - UINT_PTR uAppData; - DWORD dwSemantic; - DWORD dwFlags; - __GNU_EXTENSION union { - LPCSTR lptszActionName; - UINT uResIdString; - } DUMMYUNIONNAME; - GUID guidInstance; - DWORD dwObjID; - DWORD dwHow; -} DIACTIONA, *LPDIACTIONA; -typedef const DIACTIONA *LPCDIACTIONA; - -typedef struct _DIACTIONW { - UINT_PTR uAppData; - DWORD dwSemantic; - DWORD dwFlags; - __GNU_EXTENSION union { - LPCWSTR lptszActionName; - UINT uResIdString; - } DUMMYUNIONNAME; - GUID guidInstance; - DWORD dwObjID; - DWORD dwHow; -} DIACTIONW, *LPDIACTIONW; -typedef const DIACTIONW *LPCDIACTIONW; - -DECL_WINELIB_TYPE_AW(DIACTION) -DECL_WINELIB_TYPE_AW(LPDIACTION) -DECL_WINELIB_TYPE_AW(LPCDIACTION) - -#define DIA_FORCEFEEDBACK 0x00000001 -#define DIA_APPMAPPED 0x00000002 -#define DIA_APPNOMAP 0x00000004 -#define DIA_NORANGE 0x00000008 -#define DIA_APPFIXED 0x00000010 - -#define DIAH_UNMAPPED 0x00000000 -#define DIAH_USERCONFIG 0x00000001 -#define DIAH_APPREQUESTED 0x00000002 -#define DIAH_HWAPP 0x00000004 -#define DIAH_HWDEFAULT 0x00000008 -#define DIAH_DEFAULT 0x00000020 -#define DIAH_ERROR 0x80000000 - -typedef struct _DIACTIONFORMATA { - DWORD dwSize; - DWORD dwActionSize; - DWORD dwDataSize; - DWORD dwNumActions; - LPDIACTIONA rgoAction; - GUID guidActionMap; - DWORD dwGenre; - DWORD dwBufferSize; - LONG lAxisMin; - LONG lAxisMax; - HINSTANCE hInstString; - FILETIME ftTimeStamp; - DWORD dwCRC; - CHAR tszActionMap[MAX_PATH]; -} DIACTIONFORMATA, *LPDIACTIONFORMATA; -typedef const DIACTIONFORMATA *LPCDIACTIONFORMATA; - -typedef struct _DIACTIONFORMATW { - DWORD dwSize; - DWORD dwActionSize; - DWORD dwDataSize; - DWORD dwNumActions; - LPDIACTIONW rgoAction; - GUID guidActionMap; - DWORD dwGenre; - DWORD dwBufferSize; - LONG lAxisMin; - LONG lAxisMax; - HINSTANCE hInstString; - FILETIME ftTimeStamp; - DWORD dwCRC; - WCHAR tszActionMap[MAX_PATH]; -} DIACTIONFORMATW, *LPDIACTIONFORMATW; -typedef const DIACTIONFORMATW *LPCDIACTIONFORMATW; - -DECL_WINELIB_TYPE_AW(DIACTIONFORMAT) -DECL_WINELIB_TYPE_AW(LPDIACTIONFORMAT) -DECL_WINELIB_TYPE_AW(LPCDIACTIONFORMAT) - -#define DIAFTS_NEWDEVICELOW 0xFFFFFFFF -#define DIAFTS_NEWDEVICEHIGH 0xFFFFFFFF -#define DIAFTS_UNUSEDDEVICELOW 0x00000000 -#define DIAFTS_UNUSEDDEVICEHIGH 0x00000000 - -#define DIDBAM_DEFAULT 0x00000000 -#define DIDBAM_PRESERVE 0x00000001 -#define DIDBAM_INITIALIZE 0x00000002 -#define DIDBAM_HWDEFAULTS 0x00000004 - -#define DIDSAM_DEFAULT 0x00000000 -#define DIDSAM_NOUSER 0x00000001 -#define DIDSAM_FORCESAVE 0x00000002 - -#define DICD_DEFAULT 0x00000000 -#define DICD_EDIT 0x00000001 - -#ifndef D3DCOLOR_DEFINED -typedef DWORD D3DCOLOR; -#define D3DCOLOR_DEFINED -#endif - -typedef struct _DICOLORSET { - DWORD dwSize; - D3DCOLOR cTextFore; - D3DCOLOR cTextHighlight; - D3DCOLOR cCalloutLine; - D3DCOLOR cCalloutHighlight; - D3DCOLOR cBorder; - D3DCOLOR cControlFill; - D3DCOLOR cHighlightFill; - D3DCOLOR cAreaFill; -} DICOLORSET, *LPDICOLORSET; -typedef const DICOLORSET *LPCDICOLORSET; - -typedef struct _DICONFIGUREDEVICESPARAMSA { - DWORD dwSize; - DWORD dwcUsers; - LPSTR lptszUserNames; - DWORD dwcFormats; - LPDIACTIONFORMATA lprgFormats; - HWND hwnd; - DICOLORSET dics; - LPUNKNOWN lpUnkDDSTarget; -} DICONFIGUREDEVICESPARAMSA, *LPDICONFIGUREDEVICESPARAMSA; -typedef const DICONFIGUREDEVICESPARAMSA *LPCDICONFIGUREDEVICESPARAMSA; - -typedef struct _DICONFIGUREDEVICESPARAMSW { - DWORD dwSize; - DWORD dwcUsers; - LPWSTR lptszUserNames; - DWORD dwcFormats; - LPDIACTIONFORMATW lprgFormats; - HWND hwnd; - DICOLORSET dics; - LPUNKNOWN lpUnkDDSTarget; -} DICONFIGUREDEVICESPARAMSW, *LPDICONFIGUREDEVICESPARAMSW; -typedef const DICONFIGUREDEVICESPARAMSW *LPCDICONFIGUREDEVICESPARAMSW; - -DECL_WINELIB_TYPE_AW(DICONFIGUREDEVICESPARAMS) -DECL_WINELIB_TYPE_AW(LPDICONFIGUREDEVICESPARAMS) -DECL_WINELIB_TYPE_AW(LPCDICONFIGUREDEVICESPARAMS) - -#define DIDIFT_CONFIGURATION 0x00000001 -#define DIDIFT_OVERLAY 0x00000002 - -#define DIDAL_CENTERED 0x00000000 -#define DIDAL_LEFTALIGNED 0x00000001 -#define DIDAL_RIGHTALIGNED 0x00000002 -#define DIDAL_MIDDLE 0x00000000 -#define DIDAL_TOPALIGNED 0x00000004 -#define DIDAL_BOTTOMALIGNED 0x00000008 - -typedef struct _DIDEVICEIMAGEINFOA { - CHAR tszImagePath[MAX_PATH]; - DWORD dwFlags; - DWORD dwViewID; - RECT rcOverlay; - DWORD dwObjID; - DWORD dwcValidPts; - POINT rgptCalloutLine[5]; - RECT rcCalloutRect; - DWORD dwTextAlign; -} DIDEVICEIMAGEINFOA, *LPDIDEVICEIMAGEINFOA; -typedef const DIDEVICEIMAGEINFOA *LPCDIDEVICEIMAGEINFOA; - -typedef struct _DIDEVICEIMAGEINFOW { - WCHAR tszImagePath[MAX_PATH]; - DWORD dwFlags; - DWORD dwViewID; - RECT rcOverlay; - DWORD dwObjID; - DWORD dwcValidPts; - POINT rgptCalloutLine[5]; - RECT rcCalloutRect; - DWORD dwTextAlign; -} DIDEVICEIMAGEINFOW, *LPDIDEVICEIMAGEINFOW; -typedef const DIDEVICEIMAGEINFOW *LPCDIDEVICEIMAGEINFOW; - -DECL_WINELIB_TYPE_AW(DIDEVICEIMAGEINFO) -DECL_WINELIB_TYPE_AW(LPDIDEVICEIMAGEINFO) -DECL_WINELIB_TYPE_AW(LPCDIDEVICEIMAGEINFO) - -typedef struct _DIDEVICEIMAGEINFOHEADERA { - DWORD dwSize; - DWORD dwSizeImageInfo; - DWORD dwcViews; - DWORD dwcButtons; - DWORD dwcAxes; - DWORD dwcPOVs; - DWORD dwBufferSize; - DWORD dwBufferUsed; - LPDIDEVICEIMAGEINFOA lprgImageInfoArray; -} DIDEVICEIMAGEINFOHEADERA, *LPDIDEVICEIMAGEINFOHEADERA; -typedef const DIDEVICEIMAGEINFOHEADERA *LPCDIDEVICEIMAGEINFOHEADERA; - -typedef struct _DIDEVICEIMAGEINFOHEADERW { - DWORD dwSize; - DWORD dwSizeImageInfo; - DWORD dwcViews; - DWORD dwcButtons; - DWORD dwcAxes; - DWORD dwcPOVs; - DWORD dwBufferSize; - DWORD dwBufferUsed; - LPDIDEVICEIMAGEINFOW lprgImageInfoArray; -} DIDEVICEIMAGEINFOHEADERW, *LPDIDEVICEIMAGEINFOHEADERW; -typedef const DIDEVICEIMAGEINFOHEADERW *LPCDIDEVICEIMAGEINFOHEADERW; - -DECL_WINELIB_TYPE_AW(DIDEVICEIMAGEINFOHEADER) -DECL_WINELIB_TYPE_AW(LPDIDEVICEIMAGEINFOHEADER) -DECL_WINELIB_TYPE_AW(LPCDIDEVICEIMAGEINFOHEADER) - -#endif /* DI8 */ - - -/***************************************************************************** - * IDirectInputEffect interface - */ -#if (DIRECTINPUT_VERSION >= 0x0500) -#undef INTERFACE -#define INTERFACE IDirectInputEffect -DECLARE_INTERFACE_(IDirectInputEffect,IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - /*** IDirectInputEffect methods ***/ - STDMETHOD(Initialize)(THIS_ HINSTANCE, DWORD, REFGUID) PURE; - STDMETHOD(GetEffectGuid)(THIS_ LPGUID) PURE; - STDMETHOD(GetParameters)(THIS_ LPDIEFFECT, DWORD) PURE; - STDMETHOD(SetParameters)(THIS_ LPCDIEFFECT, DWORD) PURE; - STDMETHOD(Start)(THIS_ DWORD, DWORD) PURE; - STDMETHOD(Stop)(THIS) PURE; - STDMETHOD(GetEffectStatus)(THIS_ LPDWORD) PURE; - STDMETHOD(Download)(THIS) PURE; - STDMETHOD(Unload)(THIS) PURE; - STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE) PURE; -}; - -#if !defined(__cplusplus) || defined(CINTERFACE) -/*** IUnknown methods ***/ -#define IDirectInputEffect_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectInputEffect_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectInputEffect_Release(p) (p)->lpVtbl->Release(p) -/*** IDirectInputEffect methods ***/ -#define IDirectInputEffect_Initialize(p,a,b,c) (p)->lpVtbl->Initialize(p,a,b,c) -#define IDirectInputEffect_GetEffectGuid(p,a) (p)->lpVtbl->GetEffectGuid(p,a) -#define IDirectInputEffect_GetParameters(p,a,b) (p)->lpVtbl->GetParameters(p,a,b) -#define IDirectInputEffect_SetParameters(p,a,b) (p)->lpVtbl->SetParameters(p,a,b) -#define IDirectInputEffect_Start(p,a,b) (p)->lpVtbl->Start(p,a,b) -#define IDirectInputEffect_Stop(p) (p)->lpVtbl->Stop(p) -#define IDirectInputEffect_GetEffectStatus(p,a) (p)->lpVtbl->GetEffectStatus(p,a) -#define IDirectInputEffect_Download(p) (p)->lpVtbl->Download(p) -#define IDirectInputEffect_Unload(p) (p)->lpVtbl->Unload(p) -#define IDirectInputEffect_Escape(p,a) (p)->lpVtbl->Escape(p,a) -#else -/*** IUnknown methods ***/ -#define IDirectInputEffect_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectInputEffect_AddRef(p) (p)->AddRef() -#define IDirectInputEffect_Release(p) (p)->Release() -/*** IDirectInputEffect methods ***/ -#define IDirectInputEffect_Initialize(p,a,b,c) (p)->Initialize(a,b,c) -#define IDirectInputEffect_GetEffectGuid(p,a) (p)->GetEffectGuid(a) -#define IDirectInputEffect_GetParameters(p,a,b) (p)->GetParameters(a,b) -#define IDirectInputEffect_SetParameters(p,a,b) (p)->SetParameters(a,b) -#define IDirectInputEffect_Start(p,a,b) (p)->Start(a,b) -#define IDirectInputEffect_Stop(p) (p)->Stop() -#define IDirectInputEffect_GetEffectStatus(p,a) (p)->GetEffectStatus(a) -#define IDirectInputEffect_Download(p) (p)->Download() -#define IDirectInputEffect_Unload(p) (p)->Unload() -#define IDirectInputEffect_Escape(p,a) (p)->Escape(a) -#endif - -#endif /* DI5 */ - - -/***************************************************************************** - * IDirectInputDeviceA interface - */ -#undef INTERFACE -#define INTERFACE IDirectInputDeviceA -DECLARE_INTERFACE_(IDirectInputDeviceA,IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - /*** IDirectInputDeviceA methods ***/ - STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS lpDIDevCaps) PURE; - STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKA lpCallback, LPVOID pvRef, DWORD dwFlags) PURE; - STDMETHOD(GetProperty)(THIS_ REFGUID rguidProp, LPDIPROPHEADER pdiph) PURE; - STDMETHOD(SetProperty)(THIS_ REFGUID rguidProp, LPCDIPROPHEADER pdiph) PURE; - STDMETHOD(Acquire)(THIS) PURE; - STDMETHOD(Unacquire)(THIS) PURE; - STDMETHOD(GetDeviceState)(THIS_ DWORD cbData, LPVOID lpvData) PURE; - STDMETHOD(GetDeviceData)(THIS_ DWORD cbObjectData, LPDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD dwFlags) PURE; - STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT lpdf) PURE; - STDMETHOD(SetEventNotification)(THIS_ HANDLE hEvent) PURE; - STDMETHOD(SetCooperativeLevel)(THIS_ HWND hwnd, DWORD dwFlags) PURE; - STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEA pdidoi, DWORD dwObj, DWORD dwHow) PURE; - STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEA pdidi) PURE; - STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE; - STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion, REFGUID rguid) PURE; -}; - -/***************************************************************************** - * IDirectInputDeviceW interface - */ -#undef INTERFACE -#define INTERFACE IDirectInputDeviceW -DECLARE_INTERFACE_(IDirectInputDeviceW,IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - /*** IDirectInputDeviceW methods ***/ - STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS lpDIDevCaps) PURE; - STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKW lpCallback, LPVOID pvRef, DWORD dwFlags) PURE; - STDMETHOD(GetProperty)(THIS_ REFGUID rguidProp, LPDIPROPHEADER pdiph) PURE; - STDMETHOD(SetProperty)(THIS_ REFGUID rguidProp, LPCDIPROPHEADER pdiph) PURE; - STDMETHOD(Acquire)(THIS) PURE; - STDMETHOD(Unacquire)(THIS) PURE; - STDMETHOD(GetDeviceState)(THIS_ DWORD cbData, LPVOID lpvData) PURE; - STDMETHOD(GetDeviceData)(THIS_ DWORD cbObjectData, LPDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD dwFlags) PURE; - STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT lpdf) PURE; - STDMETHOD(SetEventNotification)(THIS_ HANDLE hEvent) PURE; - STDMETHOD(SetCooperativeLevel)(THIS_ HWND hwnd, DWORD dwFlags) PURE; - STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEW pdidoi, DWORD dwObj, DWORD dwHow) PURE; - STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEW pdidi) PURE; - STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE; - STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion, REFGUID rguid) PURE; -}; - -#if !defined(__cplusplus) || defined(CINTERFACE) -/*** IUnknown methods ***/ -#define IDirectInputDevice_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectInputDevice_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectInputDevice_Release(p) (p)->lpVtbl->Release(p) -/*** IDirectInputDevice methods ***/ -#define IDirectInputDevice_GetCapabilities(p,a) (p)->lpVtbl->GetCapabilities(p,a) -#define IDirectInputDevice_EnumObjects(p,a,b,c) (p)->lpVtbl->EnumObjects(p,a,b,c) -#define IDirectInputDevice_GetProperty(p,a,b) (p)->lpVtbl->GetProperty(p,a,b) -#define IDirectInputDevice_SetProperty(p,a,b) (p)->lpVtbl->SetProperty(p,a,b) -#define IDirectInputDevice_Acquire(p) (p)->lpVtbl->Acquire(p) -#define IDirectInputDevice_Unacquire(p) (p)->lpVtbl->Unacquire(p) -#define IDirectInputDevice_GetDeviceState(p,a,b) (p)->lpVtbl->GetDeviceState(p,a,b) -#define IDirectInputDevice_GetDeviceData(p,a,b,c,d) (p)->lpVtbl->GetDeviceData(p,a,b,c,d) -#define IDirectInputDevice_SetDataFormat(p,a) (p)->lpVtbl->SetDataFormat(p,a) -#define IDirectInputDevice_SetEventNotification(p,a) (p)->lpVtbl->SetEventNotification(p,a) -#define IDirectInputDevice_SetCooperativeLevel(p,a,b) (p)->lpVtbl->SetCooperativeLevel(p,a,b) -#define IDirectInputDevice_GetObjectInfo(p,a,b,c) (p)->lpVtbl->GetObjectInfo(p,a,b,c) -#define IDirectInputDevice_GetDeviceInfo(p,a) (p)->lpVtbl->GetDeviceInfo(p,a) -#define IDirectInputDevice_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b) -#define IDirectInputDevice_Initialize(p,a,b,c) (p)->lpVtbl->Initialize(p,a,b,c) -#else -/*** IUnknown methods ***/ -#define IDirectInputDevice_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectInputDevice_AddRef(p) (p)->AddRef() -#define IDirectInputDevice_Release(p) (p)->Release() -/*** IDirectInputDevice methods ***/ -#define IDirectInputDevice_GetCapabilities(p,a) (p)->GetCapabilities(a) -#define IDirectInputDevice_EnumObjects(p,a,b,c) (p)->EnumObjects(a,b,c) -#define IDirectInputDevice_GetProperty(p,a,b) (p)->GetProperty(a,b) -#define IDirectInputDevice_SetProperty(p,a,b) (p)->SetProperty(a,b) -#define IDirectInputDevice_Acquire(p) (p)->Acquire() -#define IDirectInputDevice_Unacquire(p) (p)->Unacquire() -#define IDirectInputDevice_GetDeviceState(p,a,b) (p)->GetDeviceState(a,b) -#define IDirectInputDevice_GetDeviceData(p,a,b,c,d) (p)->GetDeviceData(a,b,c,d) -#define IDirectInputDevice_SetDataFormat(p,a) (p)->SetDataFormat(a) -#define IDirectInputDevice_SetEventNotification(p,a) (p)->SetEventNotification(a) -#define IDirectInputDevice_SetCooperativeLevel(p,a,b) (p)->SetCooperativeLevel(a,b) -#define IDirectInputDevice_GetObjectInfo(p,a,b,c) (p)->GetObjectInfo(a,b,c) -#define IDirectInputDevice_GetDeviceInfo(p,a) (p)->GetDeviceInfo(a) -#define IDirectInputDevice_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b) -#define IDirectInputDevice_Initialize(p,a,b,c) (p)->Initialize(a,b,c) -#endif - - -#if (DIRECTINPUT_VERSION >= 0x0500) -/***************************************************************************** - * IDirectInputDevice2A interface - */ -#undef INTERFACE -#define INTERFACE IDirectInputDevice2A -DECLARE_INTERFACE_(IDirectInputDevice2A,IDirectInputDeviceA) -{ - /*** IUnknown methods ***/ - STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - /*** IDirectInputDeviceA methods ***/ - STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS lpDIDevCaps) PURE; - STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKA lpCallback, LPVOID pvRef, DWORD dwFlags) PURE; - STDMETHOD(GetProperty)(THIS_ REFGUID rguidProp, LPDIPROPHEADER pdiph) PURE; - STDMETHOD(SetProperty)(THIS_ REFGUID rguidProp, LPCDIPROPHEADER pdiph) PURE; - STDMETHOD(Acquire)(THIS) PURE; - STDMETHOD(Unacquire)(THIS) PURE; - STDMETHOD(GetDeviceState)(THIS_ DWORD cbData, LPVOID lpvData) PURE; - STDMETHOD(GetDeviceData)(THIS_ DWORD cbObjectData, LPDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD dwFlags) PURE; - STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT lpdf) PURE; - STDMETHOD(SetEventNotification)(THIS_ HANDLE hEvent) PURE; - STDMETHOD(SetCooperativeLevel)(THIS_ HWND hwnd, DWORD dwFlags) PURE; - STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEA pdidoi, DWORD dwObj, DWORD dwHow) PURE; - STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEA pdidi) PURE; - STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE; - STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion, REFGUID rguid) PURE; - /*** IDirectInputDevice2A methods ***/ - STDMETHOD(CreateEffect)(THIS_ REFGUID rguid, LPCDIEFFECT lpeff, LPDIRECTINPUTEFFECT *ppdeff, LPUNKNOWN punkOuter) PURE; - STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKA lpCallback, LPVOID pvRef, DWORD dwEffType) PURE; - STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOA pdei, REFGUID rguid) PURE; - STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD pdwOut) PURE; - STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD dwFlags) PURE; - STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback, LPVOID pvRef, DWORD fl) PURE; - STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE pesc) PURE; - STDMETHOD(Poll)(THIS) PURE; - STDMETHOD(SendDeviceData)(THIS_ DWORD cbObjectData, LPCDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD fl) PURE; -}; - -/***************************************************************************** - * IDirectInputDevice2W interface - */ -#undef INTERFACE -#define INTERFACE IDirectInputDevice2W -DECLARE_INTERFACE_(IDirectInputDevice2W,IDirectInputDeviceW) -{ - /*** IUnknown methods ***/ - STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - /*** IDirectInputDeviceW methods ***/ - STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS lpDIDevCaps) PURE; - STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKW lpCallback, LPVOID pvRef, DWORD dwFlags) PURE; - STDMETHOD(GetProperty)(THIS_ REFGUID rguidProp, LPDIPROPHEADER pdiph) PURE; - STDMETHOD(SetProperty)(THIS_ REFGUID rguidProp, LPCDIPROPHEADER pdiph) PURE; - STDMETHOD(Acquire)(THIS) PURE; - STDMETHOD(Unacquire)(THIS) PURE; - STDMETHOD(GetDeviceState)(THIS_ DWORD cbData, LPVOID lpvData) PURE; - STDMETHOD(GetDeviceData)(THIS_ DWORD cbObjectData, LPDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD dwFlags) PURE; - STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT lpdf) PURE; - STDMETHOD(SetEventNotification)(THIS_ HANDLE hEvent) PURE; - STDMETHOD(SetCooperativeLevel)(THIS_ HWND hwnd, DWORD dwFlags) PURE; - STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEW pdidoi, DWORD dwObj, DWORD dwHow) PURE; - STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEW pdidi) PURE; - STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE; - STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion, REFGUID rguid) PURE; - /*** IDirectInputDevice2W methods ***/ - STDMETHOD(CreateEffect)(THIS_ REFGUID rguid, LPCDIEFFECT lpeff, LPDIRECTINPUTEFFECT *ppdeff, LPUNKNOWN punkOuter) PURE; - STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKW lpCallback, LPVOID pvRef, DWORD dwEffType) PURE; - STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOW pdei, REFGUID rguid) PURE; - STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD pdwOut) PURE; - STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD dwFlags) PURE; - STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback, LPVOID pvRef, DWORD fl) PURE; - STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE pesc) PURE; - STDMETHOD(Poll)(THIS) PURE; - STDMETHOD(SendDeviceData)(THIS_ DWORD cbObjectData, LPCDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD fl) PURE; -}; - -#if !defined(__cplusplus) || defined(CINTERFACE) -/*** IUnknown methods ***/ -#define IDirectInputDevice2_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectInputDevice2_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectInputDevice2_Release(p) (p)->lpVtbl->Release(p) -/*** IDirectInputDevice methods ***/ -#define IDirectInputDevice2_GetCapabilities(p,a) (p)->lpVtbl->GetCapabilities(p,a) -#define IDirectInputDevice2_EnumObjects(p,a,b,c) (p)->lpVtbl->EnumObjects(p,a,b,c) -#define IDirectInputDevice2_GetProperty(p,a,b) (p)->lpVtbl->GetProperty(p,a,b) -#define IDirectInputDevice2_SetProperty(p,a,b) (p)->lpVtbl->SetProperty(p,a,b) -#define IDirectInputDevice2_Acquire(p) (p)->lpVtbl->Acquire(p) -#define IDirectInputDevice2_Unacquire(p) (p)->lpVtbl->Unacquire(p) -#define IDirectInputDevice2_GetDeviceState(p,a,b) (p)->lpVtbl->GetDeviceState(p,a,b) -#define IDirectInputDevice2_GetDeviceData(p,a,b,c,d) (p)->lpVtbl->GetDeviceData(p,a,b,c,d) -#define IDirectInputDevice2_SetDataFormat(p,a) (p)->lpVtbl->SetDataFormat(p,a) -#define IDirectInputDevice2_SetEventNotification(p,a) (p)->lpVtbl->SetEventNotification(p,a) -#define IDirectInputDevice2_SetCooperativeLevel(p,a,b) (p)->lpVtbl->SetCooperativeLevel(p,a,b) -#define IDirectInputDevice2_GetObjectInfo(p,a,b,c) (p)->lpVtbl->GetObjectInfo(p,a,b,c) -#define IDirectInputDevice2_GetDeviceInfo(p,a) (p)->lpVtbl->GetDeviceInfo(p,a) -#define IDirectInputDevice2_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b) -#define IDirectInputDevice2_Initialize(p,a,b,c) (p)->lpVtbl->Initialize(p,a,b,c) -/*** IDirectInputDevice2 methods ***/ -#define IDirectInputDevice2_CreateEffect(p,a,b,c,d) (p)->lpVtbl->CreateEffect(p,a,b,c,d) -#define IDirectInputDevice2_EnumEffects(p,a,b,c) (p)->lpVtbl->EnumEffects(p,a,b,c) -#define IDirectInputDevice2_GetEffectInfo(p,a,b) (p)->lpVtbl->GetEffectInfo(p,a,b) -#define IDirectInputDevice2_GetForceFeedbackState(p,a) (p)->lpVtbl->GetForceFeedbackState(p,a) -#define IDirectInputDevice2_SendForceFeedbackCommand(p,a) (p)->lpVtbl->SendForceFeedbackCommand(p,a) -#define IDirectInputDevice2_EnumCreatedEffectObjects(p,a,b,c) (p)->lpVtbl->EnumCreatedEffectObjects(p,a,b,c) -#define IDirectInputDevice2_Escape(p,a) (p)->lpVtbl->Escape(p,a) -#define IDirectInputDevice2_Poll(p) (p)->lpVtbl->Poll(p) -#define IDirectInputDevice2_SendDeviceData(p,a,b,c,d) (p)->lpVtbl->SendDeviceData(p,a,b,c,d) -#else -/*** IUnknown methods ***/ -#define IDirectInputDevice2_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectInputDevice2_AddRef(p) (p)->AddRef() -#define IDirectInputDevice2_Release(p) (p)->Release() -/*** IDirectInputDevice methods ***/ -#define IDirectInputDevice2_GetCapabilities(p,a) (p)->GetCapabilities(a) -#define IDirectInputDevice2_EnumObjects(p,a,b,c) (p)->EnumObjects(a,b,c) -#define IDirectInputDevice2_GetProperty(p,a,b) (p)->GetProperty(a,b) -#define IDirectInputDevice2_SetProperty(p,a,b) (p)->SetProperty(a,b) -#define IDirectInputDevice2_Acquire(p) (p)->Acquire() -#define IDirectInputDevice2_Unacquire(p) (p)->Unacquire() -#define IDirectInputDevice2_GetDeviceState(p,a,b) (p)->GetDeviceState(a,b) -#define IDirectInputDevice2_GetDeviceData(p,a,b,c,d) (p)->GetDeviceData(a,b,c,d) -#define IDirectInputDevice2_SetDataFormat(p,a) (p)->SetDataFormat(a) -#define IDirectInputDevice2_SetEventNotification(p,a) (p)->SetEventNotification(a) -#define IDirectInputDevice2_SetCooperativeLevel(p,a,b) (p)->SetCooperativeLevel(a,b) -#define IDirectInputDevice2_GetObjectInfo(p,a,b,c) (p)->GetObjectInfo(a,b,c) -#define IDirectInputDevice2_GetDeviceInfo(p,a) (p)->GetDeviceInfo(a) -#define IDirectInputDevice2_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b) -#define IDirectInputDevice2_Initialize(p,a,b,c) (p)->Initialize(a,b,c) -/*** IDirectInputDevice2 methods ***/ -#define IDirectInputDevice2_CreateEffect(p,a,b,c,d) (p)->CreateEffect(a,b,c,d) -#define IDirectInputDevice2_EnumEffects(p,a,b,c) (p)->EnumEffects(a,b,c) -#define IDirectInputDevice2_GetEffectInfo(p,a,b) (p)->GetEffectInfo(a,b) -#define IDirectInputDevice2_GetForceFeedbackState(p,a) (p)->GetForceFeedbackState(a) -#define IDirectInputDevice2_SendForceFeedbackCommand(p,a) (p)->SendForceFeedbackCommand(a) -#define IDirectInputDevice2_EnumCreatedEffectObjects(p,a,b,c) (p)->EnumCreatedEffectObjects(a,b,c) -#define IDirectInputDevice2_Escape(p,a) (p)->Escape(a) -#define IDirectInputDevice2_Poll(p) (p)->Poll() -#define IDirectInputDevice2_SendDeviceData(p,a,b,c,d) (p)->SendDeviceData(a,b,c,d) -#endif -#endif /* DI5 */ - -#if DIRECTINPUT_VERSION >= 0x0700 -/***************************************************************************** - * IDirectInputDevice7A interface - */ -#undef INTERFACE -#define INTERFACE IDirectInputDevice7A -DECLARE_INTERFACE_(IDirectInputDevice7A,IDirectInputDevice2A) -{ - /*** IUnknown methods ***/ - STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - /*** IDirectInputDeviceA methods ***/ - STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS lpDIDevCaps) PURE; - STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKA lpCallback, LPVOID pvRef, DWORD dwFlags) PURE; - STDMETHOD(GetProperty)(THIS_ REFGUID rguidProp, LPDIPROPHEADER pdiph) PURE; - STDMETHOD(SetProperty)(THIS_ REFGUID rguidProp, LPCDIPROPHEADER pdiph) PURE; - STDMETHOD(Acquire)(THIS) PURE; - STDMETHOD(Unacquire)(THIS) PURE; - STDMETHOD(GetDeviceState)(THIS_ DWORD cbData, LPVOID lpvData) PURE; - STDMETHOD(GetDeviceData)(THIS_ DWORD cbObjectData, LPDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD dwFlags) PURE; - STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT lpdf) PURE; - STDMETHOD(SetEventNotification)(THIS_ HANDLE hEvent) PURE; - STDMETHOD(SetCooperativeLevel)(THIS_ HWND hwnd, DWORD dwFlags) PURE; - STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEA pdidoi, DWORD dwObj, DWORD dwHow) PURE; - STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEA pdidi) PURE; - STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE; - STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion, REFGUID rguid) PURE; - /*** IDirectInputDevice2A methods ***/ - STDMETHOD(CreateEffect)(THIS_ REFGUID rguid, LPCDIEFFECT lpeff, LPDIRECTINPUTEFFECT *ppdeff, LPUNKNOWN punkOuter) PURE; - STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKA lpCallback, LPVOID pvRef, DWORD dwEffType) PURE; - STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOA pdei, REFGUID rguid) PURE; - STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD pdwOut) PURE; - STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD dwFlags) PURE; - STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback, LPVOID pvRef, DWORD fl) PURE; - STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE pesc) PURE; - STDMETHOD(Poll)(THIS) PURE; - STDMETHOD(SendDeviceData)(THIS_ DWORD cbObjectData, LPCDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD fl) PURE; - /*** IDirectInputDevice7A methods ***/ - STDMETHOD(EnumEffectsInFile)(THIS_ LPCSTR lpszFileName,LPDIENUMEFFECTSINFILECALLBACK pec,LPVOID pvRef,DWORD dwFlags) PURE; - STDMETHOD(WriteEffectToFile)(THIS_ LPCSTR lpszFileName,DWORD dwEntries,LPDIFILEEFFECT rgDiFileEft,DWORD dwFlags) PURE; -}; - -/***************************************************************************** - * IDirectInputDevice7W interface - */ -#undef INTERFACE -#define INTERFACE IDirectInputDevice7W -DECLARE_INTERFACE_(IDirectInputDevice7W,IDirectInputDevice2W) -{ - /*** IUnknown methods ***/ - STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - /*** IDirectInputDeviceW methods ***/ - STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS lpDIDevCaps) PURE; - STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKW lpCallback, LPVOID pvRef, DWORD dwFlags) PURE; - STDMETHOD(GetProperty)(THIS_ REFGUID rguidProp, LPDIPROPHEADER pdiph) PURE; - STDMETHOD(SetProperty)(THIS_ REFGUID rguidProp, LPCDIPROPHEADER pdiph) PURE; - STDMETHOD(Acquire)(THIS) PURE; - STDMETHOD(Unacquire)(THIS) PURE; - STDMETHOD(GetDeviceState)(THIS_ DWORD cbData, LPVOID lpvData) PURE; - STDMETHOD(GetDeviceData)(THIS_ DWORD cbObjectData, LPDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD dwFlags) PURE; - STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT lpdf) PURE; - STDMETHOD(SetEventNotification)(THIS_ HANDLE hEvent) PURE; - STDMETHOD(SetCooperativeLevel)(THIS_ HWND hwnd, DWORD dwFlags) PURE; - STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEW pdidoi, DWORD dwObj, DWORD dwHow) PURE; - STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEW pdidi) PURE; - STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE; - STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion, REFGUID rguid) PURE; - /*** IDirectInputDevice2W methods ***/ - STDMETHOD(CreateEffect)(THIS_ REFGUID rguid, LPCDIEFFECT lpeff, LPDIRECTINPUTEFFECT *ppdeff, LPUNKNOWN punkOuter) PURE; - STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKW lpCallback, LPVOID pvRef, DWORD dwEffType) PURE; - STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOW pdei, REFGUID rguid) PURE; - STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD pdwOut) PURE; - STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD dwFlags) PURE; - STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback, LPVOID pvRef, DWORD fl) PURE; - STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE pesc) PURE; - STDMETHOD(Poll)(THIS) PURE; - STDMETHOD(SendDeviceData)(THIS_ DWORD cbObjectData, LPCDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD fl) PURE; - /*** IDirectInputDevice7W methods ***/ - STDMETHOD(EnumEffectsInFile)(THIS_ LPCWSTR lpszFileName,LPDIENUMEFFECTSINFILECALLBACK pec,LPVOID pvRef,DWORD dwFlags) PURE; - STDMETHOD(WriteEffectToFile)(THIS_ LPCWSTR lpszFileName,DWORD dwEntries,LPDIFILEEFFECT rgDiFileEft,DWORD dwFlags) PURE; -}; - -#if !defined(__cplusplus) || defined(CINTERFACE) -/*** IUnknown methods ***/ -#define IDirectInputDevice7_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectInputDevice7_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectInputDevice7_Release(p) (p)->lpVtbl->Release(p) -/*** IDirectInputDevice methods ***/ -#define IDirectInputDevice7_GetCapabilities(p,a) (p)->lpVtbl->GetCapabilities(p,a) -#define IDirectInputDevice7_EnumObjects(p,a,b,c) (p)->lpVtbl->EnumObjects(p,a,b,c) -#define IDirectInputDevice7_GetProperty(p,a,b) (p)->lpVtbl->GetProperty(p,a,b) -#define IDirectInputDevice7_SetProperty(p,a,b) (p)->lpVtbl->SetProperty(p,a,b) -#define IDirectInputDevice7_Acquire(p) (p)->lpVtbl->Acquire(p) -#define IDirectInputDevice7_Unacquire(p) (p)->lpVtbl->Unacquire(p) -#define IDirectInputDevice7_GetDeviceState(p,a,b) (p)->lpVtbl->GetDeviceState(p,a,b) -#define IDirectInputDevice7_GetDeviceData(p,a,b,c,d) (p)->lpVtbl->GetDeviceData(p,a,b,c,d) -#define IDirectInputDevice7_SetDataFormat(p,a) (p)->lpVtbl->SetDataFormat(p,a) -#define IDirectInputDevice7_SetEventNotification(p,a) (p)->lpVtbl->SetEventNotification(p,a) -#define IDirectInputDevice7_SetCooperativeLevel(p,a,b) (p)->lpVtbl->SetCooperativeLevel(p,a,b) -#define IDirectInputDevice7_GetObjectInfo(p,a,b,c) (p)->lpVtbl->GetObjectInfo(p,a,b,c) -#define IDirectInputDevice7_GetDeviceInfo(p,a) (p)->lpVtbl->GetDeviceInfo(p,a) -#define IDirectInputDevice7_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b) -#define IDirectInputDevice7_Initialize(p,a,b,c) (p)->lpVtbl->Initialize(p,a,b,c) -/*** IDirectInputDevice2 methods ***/ -#define IDirectInputDevice7_CreateEffect(p,a,b,c,d) (p)->lpVtbl->CreateEffect(p,a,b,c,d) -#define IDirectInputDevice7_EnumEffects(p,a,b,c) (p)->lpVtbl->EnumEffects(p,a,b,c) -#define IDirectInputDevice7_GetEffectInfo(p,a,b) (p)->lpVtbl->GetEffectInfo(p,a,b) -#define IDirectInputDevice7_GetForceFeedbackState(p,a) (p)->lpVtbl->GetForceFeedbackState(p,a) -#define IDirectInputDevice7_SendForceFeedbackCommand(p,a) (p)->lpVtbl->SendForceFeedbackCommand(p,a) -#define IDirectInputDevice7_EnumCreatedEffectObjects(p,a,b,c) (p)->lpVtbl->EnumCreatedEffectObjects(p,a,b,c) -#define IDirectInputDevice7_Escape(p,a) (p)->lpVtbl->Escape(p,a) -#define IDirectInputDevice7_Poll(p) (p)->lpVtbl->Poll(p) -#define IDirectInputDevice7_SendDeviceData(p,a,b,c,d) (p)->lpVtbl->SendDeviceData(p,a,b,c,d) -/*** IDirectInputDevice7 methods ***/ -#define IDirectInputDevice7_EnumEffectsInFile(p,a,b,c,d) (p)->lpVtbl->EnumEffectsInFile(p,a,b,c,d) -#define IDirectInputDevice7_WriteEffectToFile(p,a,b,c,d) (p)->lpVtbl->WriteEffectToFile(p,a,b,c,d) -#else -/*** IUnknown methods ***/ -#define IDirectInputDevice7_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectInputDevice7_AddRef(p) (p)->AddRef() -#define IDirectInputDevice7_Release(p) (p)->Release() -/*** IDirectInputDevice methods ***/ -#define IDirectInputDevice7_GetCapabilities(p,a) (p)->GetCapabilities(a) -#define IDirectInputDevice7_EnumObjects(p,a,b,c) (p)->EnumObjects(a,b,c) -#define IDirectInputDevice7_GetProperty(p,a,b) (p)->GetProperty(a,b) -#define IDirectInputDevice7_SetProperty(p,a,b) (p)->SetProperty(a,b) -#define IDirectInputDevice7_Acquire(p) (p)->Acquire() -#define IDirectInputDevice7_Unacquire(p) (p)->Unacquire() -#define IDirectInputDevice7_GetDeviceState(p,a,b) (p)->GetDeviceState(a,b) -#define IDirectInputDevice7_GetDeviceData(p,a,b,c,d) (p)->GetDeviceData(a,b,c,d) -#define IDirectInputDevice7_SetDataFormat(p,a) (p)->SetDataFormat(a) -#define IDirectInputDevice7_SetEventNotification(p,a) (p)->SetEventNotification(a) -#define IDirectInputDevice7_SetCooperativeLevel(p,a,b) (p)->SetCooperativeLevel(a,b) -#define IDirectInputDevice7_GetObjectInfo(p,a,b,c) (p)->GetObjectInfo(a,b,c) -#define IDirectInputDevice7_GetDeviceInfo(p,a) (p)->GetDeviceInfo(a) -#define IDirectInputDevice7_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b) -#define IDirectInputDevice7_Initialize(p,a,b,c) (p)->Initialize(a,b,c) -/*** IDirectInputDevice2 methods ***/ -#define IDirectInputDevice7_CreateEffect(p,a,b,c,d) (p)->CreateEffect(a,b,c,d) -#define IDirectInputDevice7_EnumEffects(p,a,b,c) (p)->EnumEffects(a,b,c) -#define IDirectInputDevice7_GetEffectInfo(p,a,b) (p)->GetEffectInfo(a,b) -#define IDirectInputDevice7_GetForceFeedbackState(p,a) (p)->GetForceFeedbackState(a) -#define IDirectInputDevice7_SendForceFeedbackCommand(p,a) (p)->SendForceFeedbackCommand(a) -#define IDirectInputDevice7_EnumCreatedEffectObjects(p,a,b,c) (p)->EnumCreatedEffectObjects(a,b,c) -#define IDirectInputDevice7_Escape(p,a) (p)->Escape(a) -#define IDirectInputDevice7_Poll(p) (p)->Poll() -#define IDirectInputDevice7_SendDeviceData(p,a,b,c,d) (p)->SendDeviceData(a,b,c,d) -/*** IDirectInputDevice7 methods ***/ -#define IDirectInputDevice7_EnumEffectsInFile(p,a,b,c,d) (p)->EnumEffectsInFile(a,b,c,d) -#define IDirectInputDevice7_WriteEffectToFile(p,a,b,c,d) (p)->WriteEffectToFile(a,b,c,d) -#endif - -#endif /* DI7 */ - -#if DIRECTINPUT_VERSION >= 0x0800 -/***************************************************************************** - * IDirectInputDevice8A interface - */ -#undef INTERFACE -#define INTERFACE IDirectInputDevice8A -DECLARE_INTERFACE_(IDirectInputDevice8A,IDirectInputDevice7A) -{ - /*** IUnknown methods ***/ - STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - /*** IDirectInputDeviceA methods ***/ - STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS lpDIDevCaps) PURE; - STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKA lpCallback, LPVOID pvRef, DWORD dwFlags) PURE; - STDMETHOD(GetProperty)(THIS_ REFGUID rguidProp, LPDIPROPHEADER pdiph) PURE; - STDMETHOD(SetProperty)(THIS_ REFGUID rguidProp, LPCDIPROPHEADER pdiph) PURE; - STDMETHOD(Acquire)(THIS) PURE; - STDMETHOD(Unacquire)(THIS) PURE; - STDMETHOD(GetDeviceState)(THIS_ DWORD cbData, LPVOID lpvData) PURE; - STDMETHOD(GetDeviceData)(THIS_ DWORD cbObjectData, LPDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD dwFlags) PURE; - STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT lpdf) PURE; - STDMETHOD(SetEventNotification)(THIS_ HANDLE hEvent) PURE; - STDMETHOD(SetCooperativeLevel)(THIS_ HWND hwnd, DWORD dwFlags) PURE; - STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEA pdidoi, DWORD dwObj, DWORD dwHow) PURE; - STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEA pdidi) PURE; - STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE; - STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion, REFGUID rguid) PURE; - /*** IDirectInputDevice2A methods ***/ - STDMETHOD(CreateEffect)(THIS_ REFGUID rguid, LPCDIEFFECT lpeff, LPDIRECTINPUTEFFECT *ppdeff, LPUNKNOWN punkOuter) PURE; - STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKA lpCallback, LPVOID pvRef, DWORD dwEffType) PURE; - STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOA pdei, REFGUID rguid) PURE; - STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD pdwOut) PURE; - STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD dwFlags) PURE; - STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback, LPVOID pvRef, DWORD fl) PURE; - STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE pesc) PURE; - STDMETHOD(Poll)(THIS) PURE; - STDMETHOD(SendDeviceData)(THIS_ DWORD cbObjectData, LPCDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD fl) PURE; - /*** IDirectInputDevice7A methods ***/ - STDMETHOD(EnumEffectsInFile)(THIS_ LPCSTR lpszFileName,LPDIENUMEFFECTSINFILECALLBACK pec,LPVOID pvRef,DWORD dwFlags) PURE; - STDMETHOD(WriteEffectToFile)(THIS_ LPCSTR lpszFileName,DWORD dwEntries,LPDIFILEEFFECT rgDiFileEft,DWORD dwFlags) PURE; - /*** IDirectInputDevice8A methods ***/ - STDMETHOD(BuildActionMap)(THIS_ LPDIACTIONFORMATA lpdiaf, LPCSTR lpszUserName, DWORD dwFlags) PURE; - STDMETHOD(SetActionMap)(THIS_ LPDIACTIONFORMATA lpdiaf, LPCSTR lpszUserName, DWORD dwFlags) PURE; - STDMETHOD(GetImageInfo)(THIS_ LPDIDEVICEIMAGEINFOHEADERA lpdiDevImageInfoHeader) PURE; -}; - -/***************************************************************************** - * IDirectInputDevice8W interface - */ -#undef INTERFACE -#define INTERFACE IDirectInputDevice8W -DECLARE_INTERFACE_(IDirectInputDevice8W,IDirectInputDevice7W) -{ - /*** IUnknown methods ***/ - STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - /*** IDirectInputDeviceW methods ***/ - STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS lpDIDevCaps) PURE; - STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKW lpCallback, LPVOID pvRef, DWORD dwFlags) PURE; - STDMETHOD(GetProperty)(THIS_ REFGUID rguidProp, LPDIPROPHEADER pdiph) PURE; - STDMETHOD(SetProperty)(THIS_ REFGUID rguidProp, LPCDIPROPHEADER pdiph) PURE; - STDMETHOD(Acquire)(THIS) PURE; - STDMETHOD(Unacquire)(THIS) PURE; - STDMETHOD(GetDeviceState)(THIS_ DWORD cbData, LPVOID lpvData) PURE; - STDMETHOD(GetDeviceData)(THIS_ DWORD cbObjectData, LPDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD dwFlags) PURE; - STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT lpdf) PURE; - STDMETHOD(SetEventNotification)(THIS_ HANDLE hEvent) PURE; - STDMETHOD(SetCooperativeLevel)(THIS_ HWND hwnd, DWORD dwFlags) PURE; - STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEW pdidoi, DWORD dwObj, DWORD dwHow) PURE; - STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEW pdidi) PURE; - STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE; - STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion, REFGUID rguid) PURE; - /*** IDirectInputDevice2W methods ***/ - STDMETHOD(CreateEffect)(THIS_ REFGUID rguid, LPCDIEFFECT lpeff, LPDIRECTINPUTEFFECT *ppdeff, LPUNKNOWN punkOuter) PURE; - STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKW lpCallback, LPVOID pvRef, DWORD dwEffType) PURE; - STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOW pdei, REFGUID rguid) PURE; - STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD pdwOut) PURE; - STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD dwFlags) PURE; - STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback, LPVOID pvRef, DWORD fl) PURE; - STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE pesc) PURE; - STDMETHOD(Poll)(THIS) PURE; - STDMETHOD(SendDeviceData)(THIS_ DWORD cbObjectData, LPCDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD fl) PURE; - /*** IDirectInputDevice7W methods ***/ - STDMETHOD(EnumEffectsInFile)(THIS_ LPCWSTR lpszFileName,LPDIENUMEFFECTSINFILECALLBACK pec,LPVOID pvRef,DWORD dwFlags) PURE; - STDMETHOD(WriteEffectToFile)(THIS_ LPCWSTR lpszFileName,DWORD dwEntries,LPDIFILEEFFECT rgDiFileEft,DWORD dwFlags) PURE; - /*** IDirectInputDevice8W methods ***/ - STDMETHOD(BuildActionMap)(THIS_ LPDIACTIONFORMATW lpdiaf, LPCWSTR lpszUserName, DWORD dwFlags) PURE; - STDMETHOD(SetActionMap)(THIS_ LPDIACTIONFORMATW lpdiaf, LPCWSTR lpszUserName, DWORD dwFlags) PURE; - STDMETHOD(GetImageInfo)(THIS_ LPDIDEVICEIMAGEINFOHEADERW lpdiDevImageInfoHeader) PURE; -}; - -#if !defined(__cplusplus) || defined(CINTERFACE) -/*** IUnknown methods ***/ -#define IDirectInputDevice8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectInputDevice8_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectInputDevice8_Release(p) (p)->lpVtbl->Release(p) -/*** IDirectInputDevice methods ***/ -#define IDirectInputDevice8_GetCapabilities(p,a) (p)->lpVtbl->GetCapabilities(p,a) -#define IDirectInputDevice8_EnumObjects(p,a,b,c) (p)->lpVtbl->EnumObjects(p,a,b,c) -#define IDirectInputDevice8_GetProperty(p,a,b) (p)->lpVtbl->GetProperty(p,a,b) -#define IDirectInputDevice8_SetProperty(p,a,b) (p)->lpVtbl->SetProperty(p,a,b) -#define IDirectInputDevice8_Acquire(p) (p)->lpVtbl->Acquire(p) -#define IDirectInputDevice8_Unacquire(p) (p)->lpVtbl->Unacquire(p) -#define IDirectInputDevice8_GetDeviceState(p,a,b) (p)->lpVtbl->GetDeviceState(p,a,b) -#define IDirectInputDevice8_GetDeviceData(p,a,b,c,d) (p)->lpVtbl->GetDeviceData(p,a,b,c,d) -#define IDirectInputDevice8_SetDataFormat(p,a) (p)->lpVtbl->SetDataFormat(p,a) -#define IDirectInputDevice8_SetEventNotification(p,a) (p)->lpVtbl->SetEventNotification(p,a) -#define IDirectInputDevice8_SetCooperativeLevel(p,a,b) (p)->lpVtbl->SetCooperativeLevel(p,a,b) -#define IDirectInputDevice8_GetObjectInfo(p,a,b,c) (p)->lpVtbl->GetObjectInfo(p,a,b,c) -#define IDirectInputDevice8_GetDeviceInfo(p,a) (p)->lpVtbl->GetDeviceInfo(p,a) -#define IDirectInputDevice8_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b) -#define IDirectInputDevice8_Initialize(p,a,b,c) (p)->lpVtbl->Initialize(p,a,b,c) -/*** IDirectInputDevice2 methods ***/ -#define IDirectInputDevice8_CreateEffect(p,a,b,c,d) (p)->lpVtbl->CreateEffect(p,a,b,c,d) -#define IDirectInputDevice8_EnumEffects(p,a,b,c) (p)->lpVtbl->EnumEffects(p,a,b,c) -#define IDirectInputDevice8_GetEffectInfo(p,a,b) (p)->lpVtbl->GetEffectInfo(p,a,b) -#define IDirectInputDevice8_GetForceFeedbackState(p,a) (p)->lpVtbl->GetForceFeedbackState(p,a) -#define IDirectInputDevice8_SendForceFeedbackCommand(p,a) (p)->lpVtbl->SendForceFeedbackCommand(p,a) -#define IDirectInputDevice8_EnumCreatedEffectObjects(p,a,b,c) (p)->lpVtbl->EnumCreatedEffectObjects(p,a,b,c) -#define IDirectInputDevice8_Escape(p,a) (p)->lpVtbl->Escape(p,a) -#define IDirectInputDevice8_Poll(p) (p)->lpVtbl->Poll(p) -#define IDirectInputDevice8_SendDeviceData(p,a,b,c,d) (p)->lpVtbl->SendDeviceData(p,a,b,c,d) -/*** IDirectInputDevice7 methods ***/ -#define IDirectInputDevice8_EnumEffectsInFile(p,a,b,c,d) (p)->lpVtbl->EnumEffectsInFile(p,a,b,c,d) -#define IDirectInputDevice8_WriteEffectToFile(p,a,b,c,d) (p)->lpVtbl->WriteEffectToFile(p,a,b,c,d) -/*** IDirectInputDevice8 methods ***/ -#define IDirectInputDevice8_BuildActionMap(p,a,b,c) (p)->lpVtbl->BuildActionMap(p,a,b,c) -#define IDirectInputDevice8_SetActionMap(p,a,b,c) (p)->lpVtbl->SetActionMap(p,a,b,c) -#define IDirectInputDevice8_GetImageInfo(p,a) (p)->lpVtbl->GetImageInfo(p,a) -#else -/*** IUnknown methods ***/ -#define IDirectInputDevice8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectInputDevice8_AddRef(p) (p)->AddRef() -#define IDirectInputDevice8_Release(p) (p)->Release() -/*** IDirectInputDevice methods ***/ -#define IDirectInputDevice8_GetCapabilities(p,a) (p)->GetCapabilities(a) -#define IDirectInputDevice8_EnumObjects(p,a,b,c) (p)->EnumObjects(a,b,c) -#define IDirectInputDevice8_GetProperty(p,a,b) (p)->GetProperty(a,b) -#define IDirectInputDevice8_SetProperty(p,a,b) (p)->SetProperty(a,b) -#define IDirectInputDevice8_Acquire(p) (p)->Acquire() -#define IDirectInputDevice8_Unacquire(p) (p)->Unacquire() -#define IDirectInputDevice8_GetDeviceState(p,a,b) (p)->GetDeviceState(a,b) -#define IDirectInputDevice8_GetDeviceData(p,a,b,c,d) (p)->GetDeviceData(a,b,c,d) -#define IDirectInputDevice8_SetDataFormat(p,a) (p)->SetDataFormat(a) -#define IDirectInputDevice8_SetEventNotification(p,a) (p)->SetEventNotification(a) -#define IDirectInputDevice8_SetCooperativeLevel(p,a,b) (p)->SetCooperativeLevel(a,b) -#define IDirectInputDevice8_GetObjectInfo(p,a,b,c) (p)->GetObjectInfo(a,b,c) -#define IDirectInputDevice8_GetDeviceInfo(p,a) (p)->GetDeviceInfo(a) -#define IDirectInputDevice8_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b) -#define IDirectInputDevice8_Initialize(p,a,b,c) (p)->Initialize(a,b,c) -/*** IDirectInputDevice2 methods ***/ -#define IDirectInputDevice8_CreateEffect(p,a,b,c,d) (p)->CreateEffect(a,b,c,d) -#define IDirectInputDevice8_EnumEffects(p,a,b,c) (p)->EnumEffects(a,b,c) -#define IDirectInputDevice8_GetEffectInfo(p,a,b) (p)->GetEffectInfo(a,b) -#define IDirectInputDevice8_GetForceFeedbackState(p,a) (p)->GetForceFeedbackState(a) -#define IDirectInputDevice8_SendForceFeedbackCommand(p,a) (p)->SendForceFeedbackCommand(a) -#define IDirectInputDevice8_EnumCreatedEffectObjects(p,a,b,c) (p)->EnumCreatedEffectObjects(a,b,c) -#define IDirectInputDevice8_Escape(p,a) (p)->Escape(a) -#define IDirectInputDevice8_Poll(p) (p)->Poll() -#define IDirectInputDevice8_SendDeviceData(p,a,b,c,d) (p)->SendDeviceData(a,b,c,d) -/*** IDirectInputDevice7 methods ***/ -#define IDirectInputDevice8_EnumEffectsInFile(p,a,b,c,d) (p)->EnumEffectsInFile(a,b,c,d) -#define IDirectInputDevice8_WriteEffectToFile(p,a,b,c,d) (p)->WriteEffectToFile(a,b,c,d) -/*** IDirectInputDevice8 methods ***/ -#define IDirectInputDevice8_BuildActionMap(p,a,b,c) (p)->BuildActionMap(a,b,c) -#define IDirectInputDevice8_SetActionMap(p,a,b,c) (p)->SetActionMap(a,b,c) -#define IDirectInputDevice8_GetImageInfo(p,a) (p)->GetImageInfo(a) -#endif - -#endif /* DI8 */ - -/* "Standard" Mouse report... */ -typedef struct DIMOUSESTATE { - LONG lX; - LONG lY; - LONG lZ; - BYTE rgbButtons[4]; -} DIMOUSESTATE; - -#if DIRECTINPUT_VERSION >= 0x0700 -/* "Standard" Mouse report for DInput 7... */ -typedef struct DIMOUSESTATE2 { - LONG lX; - LONG lY; - LONG lZ; - BYTE rgbButtons[8]; -} DIMOUSESTATE2; -#endif /* DI7 */ - -#define DIMOFS_X FIELD_OFFSET(DIMOUSESTATE, lX) -#define DIMOFS_Y FIELD_OFFSET(DIMOUSESTATE, lY) -#define DIMOFS_Z FIELD_OFFSET(DIMOUSESTATE, lZ) -#define DIMOFS_BUTTON0 (FIELD_OFFSET(DIMOUSESTATE, rgbButtons) + 0) -#define DIMOFS_BUTTON1 (FIELD_OFFSET(DIMOUSESTATE, rgbButtons) + 1) -#define DIMOFS_BUTTON2 (FIELD_OFFSET(DIMOUSESTATE, rgbButtons) + 2) -#define DIMOFS_BUTTON3 (FIELD_OFFSET(DIMOUSESTATE, rgbButtons) + 3) -#if DIRECTINPUT_VERSION >= 0x0700 -#define DIMOFS_BUTTON4 (FIELD_OFFSET(DIMOUSESTATE2, rgbButtons) + 4) -#define DIMOFS_BUTTON5 (FIELD_OFFSET(DIMOUSESTATE2, rgbButtons) + 5) -#define DIMOFS_BUTTON6 (FIELD_OFFSET(DIMOUSESTATE2, rgbButtons) + 6) -#define DIMOFS_BUTTON7 (FIELD_OFFSET(DIMOUSESTATE2, rgbButtons) + 7) -#endif /* DI7 */ - -#ifdef __cplusplus -extern "C" { -#endif -extern const DIDATAFORMAT c_dfDIMouse; -#if DIRECTINPUT_VERSION >= 0x0700 -extern const DIDATAFORMAT c_dfDIMouse2; /* DX 7 */ -#endif /* DI7 */ -extern const DIDATAFORMAT c_dfDIKeyboard; -#if DIRECTINPUT_VERSION >= 0x0500 -extern const DIDATAFORMAT c_dfDIJoystick; -extern const DIDATAFORMAT c_dfDIJoystick2; -#endif /* DI5 */ -#ifdef __cplusplus -}; -#endif - -/***************************************************************************** - * IDirectInputA interface - */ -#undef INTERFACE -#define INTERFACE IDirectInputA -DECLARE_INTERFACE_(IDirectInputA,IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - /*** IDirectInputA methods ***/ - STDMETHOD(CreateDevice)(THIS_ REFGUID rguid, LPDIRECTINPUTDEVICEA *lplpDirectInputDevice, LPUNKNOWN pUnkOuter) PURE; - STDMETHOD(EnumDevices)(THIS_ DWORD dwDevType, LPDIENUMDEVICESCALLBACKA lpCallback, LPVOID pvRef, DWORD dwFlags) PURE; - STDMETHOD(GetDeviceStatus)(THIS_ REFGUID rguidInstance) PURE; - STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE; - STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion) PURE; -}; - -/***************************************************************************** - * IDirectInputW interface - */ -#undef INTERFACE -#define INTERFACE IDirectInputW -DECLARE_INTERFACE_(IDirectInputW,IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - /*** IDirectInputW methods ***/ - STDMETHOD(CreateDevice)(THIS_ REFGUID rguid, LPDIRECTINPUTDEVICEW *lplpDirectInputDevice, LPUNKNOWN pUnkOuter) PURE; - STDMETHOD(EnumDevices)(THIS_ DWORD dwDevType, LPDIENUMDEVICESCALLBACKW lpCallback, LPVOID pvRef, DWORD dwFlags) PURE; - STDMETHOD(GetDeviceStatus)(THIS_ REFGUID rguidInstance) PURE; - STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE; - STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion) PURE; -}; - -#if !defined(__cplusplus) || defined(CINTERFACE) -/*** IUnknown methods ***/ -#define IDirectInput_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectInput_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectInput_Release(p) (p)->lpVtbl->Release(p) -/*** IDirectInput methods ***/ -#define IDirectInput_CreateDevice(p,a,b,c) (p)->lpVtbl->CreateDevice(p,a,b,c) -#define IDirectInput_EnumDevices(p,a,b,c,d) (p)->lpVtbl->EnumDevices(p,a,b,c,d) -#define IDirectInput_GetDeviceStatus(p,a) (p)->lpVtbl->GetDeviceStatus(p,a) -#define IDirectInput_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b) -#define IDirectInput_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) -#else -/*** IUnknown methods ***/ -#define IDirectInput_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectInput_AddRef(p) (p)->AddRef() -#define IDirectInput_Release(p) (p)->Release() -/*** IDirectInput methods ***/ -#define IDirectInput_CreateDevice(p,a,b,c) (p)->CreateDevice(a,b,c) -#define IDirectInput_EnumDevices(p,a,b,c,d) (p)->EnumDevices(a,b,c,d) -#define IDirectInput_GetDeviceStatus(p,a) (p)->GetDeviceStatus(a) -#define IDirectInput_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b) -#define IDirectInput_Initialize(p,a,b) (p)->Initialize(a,b) -#endif - -/***************************************************************************** - * IDirectInput2A interface - */ -#undef INTERFACE -#define INTERFACE IDirectInput2A -DECLARE_INTERFACE_(IDirectInput2A,IDirectInputA) -{ - /*** IUnknown methods ***/ - STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - /*** IDirectInputA methods ***/ - STDMETHOD(CreateDevice)(THIS_ REFGUID rguid, LPDIRECTINPUTDEVICEA *lplpDirectInputDevice, LPUNKNOWN pUnkOuter) PURE; - STDMETHOD(EnumDevices)(THIS_ DWORD dwDevType, LPDIENUMDEVICESCALLBACKA lpCallback, LPVOID pvRef, DWORD dwFlags) PURE; - STDMETHOD(GetDeviceStatus)(THIS_ REFGUID rguidInstance) PURE; - STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE; - STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion) PURE; - /*** IDirectInput2A methods ***/ - STDMETHOD(FindDevice)(THIS_ REFGUID rguid, LPCSTR pszName, LPGUID pguidInstance) PURE; -}; - -/***************************************************************************** - * IDirectInput2W interface - */ -#undef INTERFACE -#define INTERFACE IDirectInput2W -DECLARE_INTERFACE_(IDirectInput2W,IDirectInputW) -{ - /*** IUnknown methods ***/ - STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - /*** IDirectInputW methods ***/ - STDMETHOD(CreateDevice)(THIS_ REFGUID rguid, LPDIRECTINPUTDEVICEW *lplpDirectInputDevice, LPUNKNOWN pUnkOuter) PURE; - STDMETHOD(EnumDevices)(THIS_ DWORD dwDevType, LPDIENUMDEVICESCALLBACKW lpCallback, LPVOID pvRef, DWORD dwFlags) PURE; - STDMETHOD(GetDeviceStatus)(THIS_ REFGUID rguidInstance) PURE; - STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE; - STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion) PURE; - /*** IDirectInput2W methods ***/ - STDMETHOD(FindDevice)(THIS_ REFGUID rguid, LPCWSTR pszName, LPGUID pguidInstance) PURE; -}; - -#if !defined(__cplusplus) || defined(CINTERFACE) -/*** IUnknown methods ***/ -#define IDirectInput2_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectInput2_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectInput2_Release(p) (p)->lpVtbl->Release(p) -/*** IDirectInput methods ***/ -#define IDirectInput2_CreateDevice(p,a,b,c) (p)->lpVtbl->CreateDevice(p,a,b,c) -#define IDirectInput2_EnumDevices(p,a,b,c,d) (p)->lpVtbl->EnumDevices(p,a,b,c,d) -#define IDirectInput2_GetDeviceStatus(p,a) (p)->lpVtbl->GetDeviceStatus(p,a) -#define IDirectInput2_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b) -#define IDirectInput2_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) -/*** IDirectInput2 methods ***/ -#define IDirectInput2_FindDevice(p,a,b,c) (p)->lpVtbl->FindDevice(p,a,b,c) -#else -/*** IUnknown methods ***/ -#define IDirectInput2_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectInput2_AddRef(p) (p)->AddRef() -#define IDirectInput2_Release(p) (p)->Release() -/*** IDirectInput methods ***/ -#define IDirectInput2_CreateDevice(p,a,b,c) (p)->CreateDevice(a,b,c) -#define IDirectInput2_EnumDevices(p,a,b,c,d) (p)->EnumDevices(a,b,c,d) -#define IDirectInput2_GetDeviceStatus(p,a) (p)->GetDeviceStatus(a) -#define IDirectInput2_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b) -#define IDirectInput2_Initialize(p,a,b) (p)->Initialize(a,b) -/*** IDirectInput2 methods ***/ -#define IDirectInput2_FindDevice(p,a,b,c) (p)->FindDevice(a,b,c) -#endif - -/***************************************************************************** - * IDirectInput7A interface - */ -#undef INTERFACE -#define INTERFACE IDirectInput7A -DECLARE_INTERFACE_(IDirectInput7A,IDirectInput2A) -{ - /*** IUnknown methods ***/ - STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - /*** IDirectInputA methods ***/ - STDMETHOD(CreateDevice)(THIS_ REFGUID rguid, LPDIRECTINPUTDEVICEA *lplpDirectInputDevice, LPUNKNOWN pUnkOuter) PURE; - STDMETHOD(EnumDevices)(THIS_ DWORD dwDevType, LPDIENUMDEVICESCALLBACKA lpCallback, LPVOID pvRef, DWORD dwFlags) PURE; - STDMETHOD(GetDeviceStatus)(THIS_ REFGUID rguidInstance) PURE; - STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE; - STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion) PURE; - /*** IDirectInput2A methods ***/ - STDMETHOD(FindDevice)(THIS_ REFGUID rguid, LPCSTR pszName, LPGUID pguidInstance) PURE; - /*** IDirectInput7A methods ***/ - STDMETHOD(CreateDeviceEx)(THIS_ REFGUID rguid, REFIID riid, LPVOID *pvOut, LPUNKNOWN lpUnknownOuter) PURE; -}; - -/***************************************************************************** - * IDirectInput7W interface - */ -#undef INTERFACE -#define INTERFACE IDirectInput7W -DECLARE_INTERFACE_(IDirectInput7W,IDirectInput2W) -{ - /*** IUnknown methods ***/ - STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - /*** IDirectInputW methods ***/ - STDMETHOD(CreateDevice)(THIS_ REFGUID rguid, LPDIRECTINPUTDEVICEW *lplpDirectInputDevice, LPUNKNOWN pUnkOuter) PURE; - STDMETHOD(EnumDevices)(THIS_ DWORD dwDevType, LPDIENUMDEVICESCALLBACKW lpCallback, LPVOID pvRef, DWORD dwFlags) PURE; - STDMETHOD(GetDeviceStatus)(THIS_ REFGUID rguidInstance) PURE; - STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE; - STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion) PURE; - /*** IDirectInput2W methods ***/ - STDMETHOD(FindDevice)(THIS_ REFGUID rguid, LPCWSTR pszName, LPGUID pguidInstance) PURE; - /*** IDirectInput7W methods ***/ - STDMETHOD(CreateDeviceEx)(THIS_ REFGUID rguid, REFIID riid, LPVOID *pvOut, LPUNKNOWN lpUnknownOuter) PURE; -}; - -#if !defined(__cplusplus) || defined(CINTERFACE) -/*** IUnknown methods ***/ -#define IDirectInput7_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectInput7_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectInput7_Release(p) (p)->lpVtbl->Release(p) -/*** IDirectInput methods ***/ -#define IDirectInput7_CreateDevice(p,a,b,c) (p)->lpVtbl->CreateDevice(p,a,b,c) -#define IDirectInput7_EnumDevices(p,a,b,c,d) (p)->lpVtbl->EnumDevices(p,a,b,c,d) -#define IDirectInput7_GetDeviceStatus(p,a) (p)->lpVtbl->GetDeviceStatus(p,a) -#define IDirectInput7_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b) -#define IDirectInput7_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) -/*** IDirectInput2 methods ***/ -#define IDirectInput7_FindDevice(p,a,b,c) (p)->lpVtbl->FindDevice(p,a,b,c) -/*** IDirectInput7 methods ***/ -#define IDirectInput7_CreateDeviceEx(p,a,b,c,d) (p)->lpVtbl->CreateDeviceEx(p,a,b,c,d) -#else -/*** IUnknown methods ***/ -#define IDirectInput7_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectInput7_AddRef(p) (p)->AddRef() -#define IDirectInput7_Release(p) (p)->Release() -/*** IDirectInput methods ***/ -#define IDirectInput7_CreateDevice(p,a,b,c) (p)->CreateDevice(a,b,c) -#define IDirectInput7_EnumDevices(p,a,b,c,d) (p)->EnumDevices(a,b,c,d) -#define IDirectInput7_GetDeviceStatus(p,a) (p)->GetDeviceStatus(a) -#define IDirectInput7_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b) -#define IDirectInput7_Initialize(p,a,b) (p)->Initialize(a,b) -/*** IDirectInput2 methods ***/ -#define IDirectInput7_FindDevice(p,a,b,c) (p)->FindDevice(a,b,c) -/*** IDirectInput7 methods ***/ -#define IDirectInput7_CreateDeviceEx(p,a,b,c,d) (p)->CreateDeviceEx(a,b,c,d) -#endif - - -#if DIRECTINPUT_VERSION >= 0x0800 -/***************************************************************************** - * IDirectInput8A interface - */ -#undef INTERFACE -#define INTERFACE IDirectInput8A -DECLARE_INTERFACE_(IDirectInput8A,IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - /*** IDirectInput8A methods ***/ - STDMETHOD(CreateDevice)(THIS_ REFGUID rguid, LPDIRECTINPUTDEVICE8A *lplpDirectInputDevice, LPUNKNOWN pUnkOuter) PURE; - STDMETHOD(EnumDevices)(THIS_ DWORD dwDevType, LPDIENUMDEVICESCALLBACKA lpCallback, LPVOID pvRef, DWORD dwFlags) PURE; - STDMETHOD(GetDeviceStatus)(THIS_ REFGUID rguidInstance) PURE; - STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE; - STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion) PURE; - STDMETHOD(FindDevice)(THIS_ REFGUID rguid, LPCSTR pszName, LPGUID pguidInstance) PURE; - STDMETHOD(EnumDevicesBySemantics)(THIS_ LPCSTR ptszUserName, LPDIACTIONFORMATA lpdiActionFormat, LPDIENUMDEVICESBYSEMANTICSCBA lpCallback, LPVOID pvRef, DWORD dwFlags) PURE; - STDMETHOD(ConfigureDevices)(THIS_ LPDICONFIGUREDEVICESCALLBACK lpdiCallback, LPDICONFIGUREDEVICESPARAMSA lpdiCDParams, DWORD dwFlags, LPVOID pvRefData) PURE; -}; - -/***************************************************************************** - * IDirectInput8W interface - */ -#undef INTERFACE -#define INTERFACE IDirectInput8W -DECLARE_INTERFACE_(IDirectInput8W,IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - /*** IDirectInput8W methods ***/ - STDMETHOD(CreateDevice)(THIS_ REFGUID rguid, LPDIRECTINPUTDEVICE8W *lplpDirectInputDevice, LPUNKNOWN pUnkOuter) PURE; - STDMETHOD(EnumDevices)(THIS_ DWORD dwDevType, LPDIENUMDEVICESCALLBACKW lpCallback, LPVOID pvRef, DWORD dwFlags) PURE; - STDMETHOD(GetDeviceStatus)(THIS_ REFGUID rguidInstance) PURE; - STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE; - STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion) PURE; - STDMETHOD(FindDevice)(THIS_ REFGUID rguid, LPCWSTR pszName, LPGUID pguidInstance) PURE; - STDMETHOD(EnumDevicesBySemantics)(THIS_ LPCWSTR ptszUserName, LPDIACTIONFORMATW lpdiActionFormat, LPDIENUMDEVICESBYSEMANTICSCBW lpCallback, LPVOID pvRef, DWORD dwFlags) PURE; - STDMETHOD(ConfigureDevices)(THIS_ LPDICONFIGUREDEVICESCALLBACK lpdiCallback, LPDICONFIGUREDEVICESPARAMSW lpdiCDParams, DWORD dwFlags, LPVOID pvRefData) PURE; -}; -#undef INTERFACE - -#if !defined(__cplusplus) || defined(CINTERFACE) -/*** IUnknown methods ***/ -#define IDirectInput8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectInput8_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectInput8_Release(p) (p)->lpVtbl->Release(p) -/*** IDirectInput8 methods ***/ -#define IDirectInput8_CreateDevice(p,a,b,c) (p)->lpVtbl->CreateDevice(p,a,b,c) -#define IDirectInput8_EnumDevices(p,a,b,c,d) (p)->lpVtbl->EnumDevices(p,a,b,c,d) -#define IDirectInput8_GetDeviceStatus(p,a) (p)->lpVtbl->GetDeviceStatus(p,a) -#define IDirectInput8_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b) -#define IDirectInput8_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) -#define IDirectInput8_FindDevice(p,a,b,c) (p)->lpVtbl->FindDevice(p,a,b,c) -#define IDirectInput8_EnumDevicesBySemantics(p,a,b,c,d,e) (p)->lpVtbl->EnumDevicesBySemantics(p,a,b,c,d,e) -#define IDirectInput8_ConfigureDevices(p,a,b,c,d) (p)->lpVtbl->ConfigureDevices(p,a,b,c,d) -#else -/*** IUnknown methods ***/ -#define IDirectInput8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectInput8_AddRef(p) (p)->AddRef() -#define IDirectInput8_Release(p) (p)->Release() -/*** IDirectInput8 methods ***/ -#define IDirectInput8_CreateDevice(p,a,b,c) (p)->CreateDevice(a,b,c) -#define IDirectInput8_EnumDevices(p,a,b,c,d) (p)->EnumDevices(a,b,c,d) -#define IDirectInput8_GetDeviceStatus(p,a) (p)->GetDeviceStatus(a) -#define IDirectInput8_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b) -#define IDirectInput8_Initialize(p,a,b) (p)->Initialize(a,b) -#define IDirectInput8_FindDevice(p,a,b,c) (p)->FindDevice(a,b,c) -#define IDirectInput8_EnumDevicesBySemantics(p,a,b,c,d,e) (p)->EnumDevicesBySemantics(a,b,c,d,e) -#define IDirectInput8_ConfigureDevices(p,a,b,c,d) (p)->ConfigureDevices(a,b,c,d) -#endif - -#endif /* DI8 */ - -/* Export functions */ - -#ifdef __cplusplus -extern "C" { -#endif - -#if DIRECTINPUT_VERSION >= 0x0800 -HRESULT WINAPI DirectInput8Create(HINSTANCE,DWORD,REFIID,LPVOID *,LPUNKNOWN); -#else /* DI < 8 */ -HRESULT WINAPI DirectInputCreateA(HINSTANCE,DWORD,LPDIRECTINPUTA *,LPUNKNOWN); -HRESULT WINAPI DirectInputCreateW(HINSTANCE,DWORD,LPDIRECTINPUTW *,LPUNKNOWN); -#define DirectInputCreate WINELIB_NAME_AW(DirectInputCreate) - -HRESULT WINAPI DirectInputCreateEx(HINSTANCE,DWORD,REFIID,LPVOID *,LPUNKNOWN); -#endif /* DI8 */ - -#ifdef __cplusplus -}; -#endif - -#endif /* __DINPUT_INCLUDED__ */ diff --git a/deps/mingw/xinput.h b/deps/mingw/xinput.h deleted file mode 100644 index d3ca726ce..000000000 --- a/deps/mingw/xinput.h +++ /dev/null @@ -1,239 +0,0 @@ -/* - * The Wine project - Xinput Joystick Library - * Copyright 2008 Andrew Fenn - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#ifndef __WINE_XINPUT_H -#define __WINE_XINPUT_H - -#include - -/* - * Bitmasks for the joysticks buttons, determines what has - * been pressed on the joystick, these need to be mapped - * to whatever device you're using instead of an xbox 360 - * joystick - */ - -#define XINPUT_GAMEPAD_DPAD_UP 0x0001 -#define XINPUT_GAMEPAD_DPAD_DOWN 0x0002 -#define XINPUT_GAMEPAD_DPAD_LEFT 0x0004 -#define XINPUT_GAMEPAD_DPAD_RIGHT 0x0008 -#define XINPUT_GAMEPAD_START 0x0010 -#define XINPUT_GAMEPAD_BACK 0x0020 -#define XINPUT_GAMEPAD_LEFT_THUMB 0x0040 -#define XINPUT_GAMEPAD_RIGHT_THUMB 0x0080 -#define XINPUT_GAMEPAD_LEFT_SHOULDER 0x0100 -#define XINPUT_GAMEPAD_RIGHT_SHOULDER 0x0200 -#define XINPUT_GAMEPAD_A 0x1000 -#define XINPUT_GAMEPAD_B 0x2000 -#define XINPUT_GAMEPAD_X 0x4000 -#define XINPUT_GAMEPAD_Y 0x8000 - -/* - * Defines the flags used to determine if the user is pushing - * down on a button, not holding a button, etc - */ - -#define XINPUT_KEYSTROKE_KEYDOWN 0x0001 -#define XINPUT_KEYSTROKE_KEYUP 0x0002 -#define XINPUT_KEYSTROKE_REPEAT 0x0004 - -/* - * Defines the codes which are returned by XInputGetKeystroke - */ - -#define VK_PAD_A 0x5800 -#define VK_PAD_B 0x5801 -#define VK_PAD_X 0x5802 -#define VK_PAD_Y 0x5803 -#define VK_PAD_RSHOULDER 0x5804 -#define VK_PAD_LSHOULDER 0x5805 -#define VK_PAD_LTRIGGER 0x5806 -#define VK_PAD_RTRIGGER 0x5807 -#define VK_PAD_DPAD_UP 0x5810 -#define VK_PAD_DPAD_DOWN 0x5811 -#define VK_PAD_DPAD_LEFT 0x5812 -#define VK_PAD_DPAD_RIGHT 0x5813 -#define VK_PAD_START 0x5814 -#define VK_PAD_BACK 0x5815 -#define VK_PAD_LTHUMB_PRESS 0x5816 -#define VK_PAD_RTHUMB_PRESS 0x5817 -#define VK_PAD_LTHUMB_UP 0x5820 -#define VK_PAD_LTHUMB_DOWN 0x5821 -#define VK_PAD_LTHUMB_RIGHT 0x5822 -#define VK_PAD_LTHUMB_LEFT 0x5823 -#define VK_PAD_LTHUMB_UPLEFT 0x5824 -#define VK_PAD_LTHUMB_UPRIGHT 0x5825 -#define VK_PAD_LTHUMB_DOWNRIGHT 0x5826 -#define VK_PAD_LTHUMB_DOWNLEFT 0x5827 -#define VK_PAD_RTHUMB_UP 0x5830 -#define VK_PAD_RTHUMB_DOWN 0x5831 -#define VK_PAD_RTHUMB_RIGHT 0x5832 -#define VK_PAD_RTHUMB_LEFT 0x5833 -#define VK_PAD_RTHUMB_UPLEFT 0x5834 -#define VK_PAD_RTHUMB_UPRIGHT 0x5835 -#define VK_PAD_RTHUMB_DOWNRIGHT 0x5836 -#define VK_PAD_RTHUMB_DOWNLEFT 0x5837 - -/* - * Deadzones are for analogue joystick controls on the joypad - * which determine when input should be assumed to be in the - * middle of the pad. This is a threshold to stop a joypad - * controlling the game when the player isn't touching the - * controls. - */ - -#define XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE 7849 -#define XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE 8689 -#define XINPUT_GAMEPAD_TRIGGER_THRESHOLD 30 - - -/* - * Defines what type of abilities the type of joystick has - * DEVTYPE_GAMEPAD is available for all joysticks, however - * there may be more specific identifiers for other joysticks - * which are being used. - */ - -#define XINPUT_DEVTYPE_GAMEPAD 0x01 -#define XINPUT_DEVSUBTYPE_GAMEPAD 0x01 -#define XINPUT_DEVSUBTYPE_WHEEL 0x02 -#define XINPUT_DEVSUBTYPE_ARCADE_STICK 0x03 -#define XINPUT_DEVSUBTYPE_FLIGHT_SICK 0x04 -#define XINPUT_DEVSUBTYPE_DANCE_PAD 0x05 -#define XINPUT_DEVSUBTYPE_GUITAR 0x06 -#define XINPUT_DEVSUBTYPE_DRUM_KIT 0x08 - -/* - * These are used with the XInputGetCapabilities function to - * determine the abilities to the joystick which has been - * plugged in. - */ - -#define XINPUT_CAPS_VOICE_SUPPORTED 0x0004 -#define XINPUT_FLAG_GAMEPAD 0x00000001 - -/* - * Defines the status of the battery if one is used in the - * attached joystick. The first two define if the joystick - * supports a battery. Disconnected means that the joystick - * isn't connected. Wired shows that the joystick is a wired - * joystick. - */ - -#define BATTERY_DEVTYPE_GAMEPAD 0x00 -#define BATTERY_DEVTYPE_HEADSET 0x01 -#define BATTERY_TYPE_DISCONNECTED 0x00 -#define BATTERY_TYPE_WIRED 0x01 -#define BATTERY_TYPE_ALKALINE 0x02 -#define BATTERY_TYPE_NIMH 0x03 -#define BATTERY_TYPE_UNKNOWN 0xFF -#define BATTERY_LEVEL_EMPTY 0x00 -#define BATTERY_LEVEL_LOW 0x01 -#define BATTERY_LEVEL_MEDIUM 0x02 -#define BATTERY_LEVEL_FULL 0x03 - -/* - * How many joysticks can be used with this library. Games that - * use the xinput library will not go over this number. - */ - -#define XUSER_MAX_COUNT 4 -#define XUSER_INDEX_ANY 0x000000FF - -/* - * Defines the structure of an xbox 360 joystick. - */ - -typedef struct _XINPUT_GAMEPAD { - WORD wButtons; - BYTE bLeftTrigger; - BYTE bRightTrigger; - SHORT sThumbLX; - SHORT sThumbLY; - SHORT sThumbRX; - SHORT sThumbRY; -} XINPUT_GAMEPAD, *PXINPUT_GAMEPAD; - -typedef struct _XINPUT_STATE { - DWORD dwPacketNumber; - XINPUT_GAMEPAD Gamepad; -} XINPUT_STATE, *PXINPUT_STATE; - -/* - * Defines the structure of how much vibration is set on both the - * right and left motors in a joystick. If you're not using a 360 - * joystick you will have to map these to your device. - */ - -typedef struct _XINPUT_VIBRATION { - WORD wLeftMotorSpeed; - WORD wRightMotorSpeed; -} XINPUT_VIBRATION, *PXINPUT_VIBRATION; - -/* - * Defines the structure for what kind of abilities the joystick has - * such abilities are things such as if the joystick has the ability - * to send and receive audio, if the joystick is in fact a driving - * wheel or perhaps if the joystick is some kind of dance pad or - * guitar. - */ - -typedef struct _XINPUT_CAPABILITIES { - BYTE Type; - BYTE SubType; - WORD Flags; - XINPUT_GAMEPAD Gamepad; - XINPUT_VIBRATION Vibration; -} XINPUT_CAPABILITIES, *PXINPUT_CAPABILITIES; - -/* - * Defines the structure for a joystick input event which is - * retrieved using the function XInputGetKeystroke - */ -typedef struct _XINPUT_KEYSTROKE { - WORD VirtualKey; - WCHAR Unicode; - WORD Flags; - BYTE UserIndex; - BYTE HidCode; -} XINPUT_KEYSTROKE, *PXINPUT_KEYSTROKE; - -typedef struct _XINPUT_BATTERY_INFORMATION -{ - BYTE BatteryType; - BYTE BatteryLevel; -} XINPUT_BATTERY_INFORMATION, *PXINPUT_BATTERY_INFORMATION; - -#ifdef __cplusplus -extern "C" { -#endif - -void WINAPI XInputEnable(WINBOOL); -DWORD WINAPI XInputSetState(DWORD, XINPUT_VIBRATION*); -DWORD WINAPI XInputGetState(DWORD, XINPUT_STATE*); -DWORD WINAPI XInputGetKeystroke(DWORD, DWORD, PXINPUT_KEYSTROKE); -DWORD WINAPI XInputGetCapabilities(DWORD, DWORD, XINPUT_CAPABILITIES*); -DWORD WINAPI XInputGetDSoundAudioDeviceGuids(DWORD, GUID*, GUID*); -DWORD WINAPI XInputGetBatteryInformation(DWORD, BYTE, XINPUT_BATTERY_INFORMATION*); - -#ifdef __cplusplus -} -#endif - -#endif /* __WINE_XINPUT_H */ diff --git a/docs/compile.md b/docs/compile.md index 6b0b71227..3b10ea575 100644 --- a/docs/compile.md +++ b/docs/compile.md @@ -36,9 +36,9 @@ specific to GLFW. It may be a useful companion to this one. ### Installing dependencies {#compile_deps} -The C/C++ development environments in Visual Studio, Xcode and MinGW come with -all necessary dependencies for compiling GLFW, but on Unix-like systems like -Linux and FreeBSD you will need a few extra packages. +The C/C++ development environments in Visual Studio, Xcode and MinGW-w64 come +with all necessary dependencies for compiling GLFW, but on Unix-like systems +like Linux and FreeBSD you will need a few extra packages. #### Dependencies for Wayland and X11 {#compile_deps_wayland} @@ -180,7 +180,7 @@ cd path/to/build make ``` -With MinGW, it is `mingw32-make`. +With MinGW-w64, it is `mingw32-make`. ```sh cd path/to/build @@ -299,12 +299,12 @@ library. This option is only available when compiling for Linux and other Unix- systems other than macOS. This is enabled by default. -## Cross-compilation with CMake and MinGW {#compile_mingw_cross} +## Cross-compilation with CMake and MinGW-w64 {#compile_mingw_cross} -Both Cygwin and many Linux distributions have MinGW or MinGW-w64 packages. For -example, Cygwin has the `mingw64-i686-gcc` and `mingw64-x86_64-gcc` packages -for 32- and 64-bit version of MinGW-w64, while Debian GNU/Linux and derivatives -like Ubuntu have the `mingw-w64` package for both. +Both Cygwin and many Linux distributions have MinGW-w64 packages. For example, +Cygwin has the `mingw64-i686-gcc` and `mingw64-x86_64-gcc` packages for 32- and +64-bit version of MinGW-w64, while Debian GNU/Linux and derivatives like Ubuntu +have the `mingw-w64` package for both. GLFW has CMake toolchain files in the `CMake` subdirectory that set up cross-compilation of Windows binaries. To use these files you set the @@ -315,9 +315,9 @@ configuring and generating the build files. cmake -S path/to/glfw -B path/to/build -D CMAKE_TOOLCHAIN_FILE=path/to/file ``` -The exact toolchain file to use depends on the prefix used by the MinGW or -MinGW-w64 binaries on your system. You can usually see this in the /usr -directory. For example, both the Ubuntu and Cygwin MinGW-w64 packages have +The exact toolchain file to use depends on the prefix used by the MinGW-w64 +binaries on your system. You can usually see this in the /usr directory. For +example, both the Ubuntu and Cygwin MinGW-w64 packages have `/usr/x86_64-w64-mingw32` for the 64-bit compilers, so the correct invocation would be: diff --git a/docs/intro.md b/docs/intro.md index 7aa75e31e..f2060c330 100644 --- a/docs/intro.md +++ b/docs/intro.md @@ -621,11 +621,11 @@ The format of the string is as follows: - The names of the always supported context creation APIs EGL and OSMesa - Any additional compile-time options, APIs and (on Windows) what compiler was used -For example, compiling GLFW 3.5 with MinGW as a DLL for Windows, may result in a version string -like this: +For example, compiling GLFW 3.5 with MinGW-64 as a DLL for Windows, may result +in a version string like this: ```c -3.5.0 Win32 WGL Null EGL OSMesa MinGW DLL +3.5.0 Win32 WGL Null EGL OSMesa MinGW-w64 DLL ``` Compiling GLFW as a static library for Linux, with both Wayland and X11 enabled, may diff --git a/docs/news.md b/docs/news.md index 148d08712..e98e2a770 100644 --- a/docs/news.md +++ b/docs/news.md @@ -20,6 +20,15 @@ this. ## Removals {#removals} +### Original MinGW support has been removed {#original_mingw} + +Support for the now unmaintained original MinGW distribution has been removed. + +This does not apply to the much more capable [MinGW-w64](https://www.mingw-w64.org/), +which remains fully supported. MinGW-w64 can build both 32- and 64-bit binaries, is +actively maintained and available on many platforms. + + ## New symbols {#new_symbols} ### New functions {#new_functions} diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1a085b2b6..2cbe8a733 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -255,24 +255,6 @@ if (GLFW_BUILD_WIN32) target_compile_definitions(glfw PRIVATE UNICODE _UNICODE) endif() -# HACK: When building on MinGW, WINVER and UNICODE need to be defined before -# the inclusion of stddef.h (by glfw3.h), which is itself included before -# win32_platform.h. We define them here until a saner solution can be found -# NOTE: MinGW-w64 and Visual C++ do /not/ need this hack. -if (MINGW) - target_compile_definitions(glfw PRIVATE WINVER=0x0501) -endif() - -# Workaround for legacy MinGW not providing XInput and DirectInput -if (MINGW) - include(CheckIncludeFile) - check_include_file(dinput.h DINPUT_H_FOUND) - check_include_file(xinput.h XINPUT_H_FOUND) - if (NOT DINPUT_H_FOUND OR NOT XINPUT_H_FOUND) - target_include_directories(glfw PRIVATE "${GLFW_SOURCE_DIR}/deps/mingw") - endif() -endif() - # Workaround for the MS CRT deprecating parts of the standard library if (MSVC OR CMAKE_C_SIMULATE_ID STREQUAL "MSVC") target_compile_definitions(glfw PRIVATE _CRT_SECURE_NO_WARNINGS) @@ -286,10 +268,6 @@ endif() if (GLFW_BUILD_SHARED_LIBRARY) if (WIN32) if (MINGW) - # Remove the dependency on the shared version of libgcc - # NOTE: MinGW-w64 has the correct default but MinGW needs this - target_link_libraries(glfw PRIVATE "-static-libgcc") - # Remove the lib prefix on the DLL (but not the import library) set_target_properties(glfw PROPERTIES PREFIX "") diff --git a/src/platform.c b/src/platform.c index 9ca64963e..95b8d0b58 100644 --- a/src/platform.c +++ b/src/platform.c @@ -187,8 +187,6 @@ GLFWAPI const char* glfwGetVersionString(void) " OSMesa" #if defined(__MINGW64_VERSION_MAJOR) " MinGW-w64" -#elif defined(__MINGW32__) - " MinGW" #elif defined(_MSC_VER) " VisualC" #endif diff --git a/src/win32_platform.h b/src/win32_platform.h index a2f868527..bcbc604b4 100644 --- a/src/win32_platform.h +++ b/src/win32_platform.h @@ -83,24 +83,12 @@ #ifndef WM_COPYGLOBALDATA #define WM_COPYGLOBALDATA 0x0049 #endif -#ifndef WM_UNICHAR - #define WM_UNICHAR 0x0109 -#endif -#ifndef UNICODE_NOCHAR - #define UNICODE_NOCHAR 0xFFFF -#endif #ifndef WM_DPICHANGED #define WM_DPICHANGED 0x02E0 #endif -#ifndef GET_XBUTTON_WPARAM - #define GET_XBUTTON_WPARAM(w) (HIWORD(w)) -#endif #ifndef EDS_ROTATEDMODE #define EDS_ROTATEDMODE 0x00000004 #endif -#ifndef DISPLAY_DEVICE_ACTIVE - #define DISPLAY_DEVICE_ACTIVE 0x00000001 -#endif #ifndef _WIN32_WINNT_WINBLUE #define _WIN32_WINNT_WINBLUE 0x0603 #endif @@ -113,9 +101,6 @@ #ifndef USER_DEFAULT_SCREEN_DPI #define USER_DEFAULT_SCREEN_DPI 96 #endif -#ifndef OCR_HAND - #define OCR_HAND 32649 -#endif #if WINVER < 0x0601 typedef struct From d11cb3779b828116af6391dfc07c147fa5e0a1c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 4 Apr 2024 16:40:27 +0200 Subject: [PATCH 10/36] Win32: Remove support for Windows XP and Vista It's increasingly difficult to maintain a safe testing environment for Windows XP, and so increasingly a burden on contributors to maintain support for it. Windows XP has been out of of support since 2014 and should not be used as a desktop OS. Fixes #2505 --- README.md | 3 ++- docs/news.md | 6 +++++ src/wgl_context.c | 10 ++++---- src/win32_init.c | 6 +---- src/win32_platform.h | 57 +++++--------------------------------------- src/win32_window.c | 19 +++------------ 6 files changed, 23 insertions(+), 78 deletions(-) diff --git a/README.md b/README.md index 344d61954..718449f5e 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,7 @@ more information. ## System requirements -GLFW supports Windows XP and later and macOS 10.11 and later. Linux and other +GLFW supports Windows 7 and later and macOS 10.11 and later. Linux and other Unix-like systems running the X Window System are supported even without a desktop environment or modern extensions, although some features require a running window or clipboard manager. The OSMesa backend requires Mesa 6.3. @@ -125,6 +125,7 @@ information on what to include when reporting a bug. the limit of the mouse button tokens to be reported (#2423) - Updated minimum CMake version to 3.16 (#2541) - Removed support for building with original MinGW (#2540) + - [Win32] Removed support for Windows XP and Vista (#2505) - [Cocoa] Added `QuartzCore` framework as link-time dependency - [Cocoa] Removed support for OS X 10.10 Yosemite and earlier (#2506) - [Wayland] Bugfix: The fractional scaling related objects were not destroyed diff --git a/docs/news.md b/docs/news.md index e98e2a770..640ae7a57 100644 --- a/docs/news.md +++ b/docs/news.md @@ -20,6 +20,12 @@ this. ## Removals {#removals} +### Windows XP and Vista support has been removed {#winxp_vista} + +Support for Windows XP and Vista has been removed. Windows XP has been out of extended +support since 2014. + + ### Original MinGW support has been removed {#original_mingw} Support for the now unmaintained original MinGW distribution has been removed. diff --git a/src/wgl_context.c b/src/wgl_context.c index 1c9189fab..3c7d71c23 100644 --- a/src/wgl_context.c +++ b/src/wgl_context.c @@ -327,8 +327,8 @@ static void swapBuffersWGL(_GLFWwindow* window) { if (!window->monitor) { - // HACK: Use DwmFlush when desktop composition is enabled on Windows Vista and 7 - if (!IsWindows8OrGreater() && IsWindowsVistaOrGreater()) + // HACK: Use DwmFlush when desktop composition is enabled on Windows 7 + if (!IsWindows8OrGreater()) { BOOL enabled = FALSE; @@ -353,9 +353,9 @@ static void swapIntervalWGL(int interval) if (!window->monitor) { - // HACK: Disable WGL swap interval when desktop composition is enabled on Windows - // Vista and 7 to avoid interfering with DWM vsync - if (!IsWindows8OrGreater() && IsWindowsVistaOrGreater()) + // HACK: Disable WGL swap interval when desktop composition is enabled on + // Windows 7 to avoid interfering with DWM vsync + if (!IsWindows8OrGreater()) { BOOL enabled = FALSE; diff --git a/src/win32_init.c b/src/win32_init.c index 77ab56bab..6b6e9d08e 100644 --- a/src/win32_init.c +++ b/src/win32_init.c @@ -89,10 +89,6 @@ static GLFWbool loadLibraries(void) return GLFW_FALSE; } - _glfw.win32.user32.SetProcessDPIAware_ = (PFN_SetProcessDPIAware) - _glfwPlatformGetModuleSymbol(_glfw.win32.user32.instance, "SetProcessDPIAware"); - _glfw.win32.user32.ChangeWindowMessageFilterEx_ = (PFN_ChangeWindowMessageFilterEx) - _glfwPlatformGetModuleSymbol(_glfw.win32.user32.instance, "ChangeWindowMessageFilterEx"); _glfw.win32.user32.EnableNonClientDpiScaling_ = (PFN_EnableNonClientDpiScaling) _glfwPlatformGetModuleSymbol(_glfw.win32.user32.instance, "EnableNonClientDpiScaling"); _glfw.win32.user32.SetProcessDpiAwarenessContext_ = (PFN_SetProcessDpiAwarenessContext) @@ -692,7 +688,7 @@ int _glfwInitWin32(void) SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2); else if (IsWindows8Point1OrGreater()) SetProcessDpiAwareness(PROCESS_PER_MONITOR_DPI_AWARE); - else if (IsWindowsVistaOrGreater()) + else SetProcessDPIAware(); if (!createHelperWindow()) diff --git a/src/win32_platform.h b/src/win32_platform.h index bcbc604b4..49cceba6d 100644 --- a/src/win32_platform.h +++ b/src/win32_platform.h @@ -48,14 +48,14 @@ #define UNICODE #endif -// GLFW requires Windows XP or later -#if WINVER < 0x0501 +// GLFW requires Windows 7 or later +#if WINVER < 0x0601 #undef WINVER - #define WINVER 0x0501 + #define WINVER 0x0601 #endif -#if _WIN32_WINNT < 0x0501 +#if _WIN32_WINNT < 0x0601 #undef _WIN32_WINNT - #define _WIN32_WINNT 0x0501 + #define _WIN32_WINNT 0x0601 #endif // GLFW uses DirectInput8 interfaces @@ -66,20 +66,12 @@ #include #include +#include #include #include #include // HACK: Define macros that some windows.h variants don't -#ifndef WM_MOUSEHWHEEL - #define WM_MOUSEHWHEEL 0x020E -#endif -#ifndef WM_DWMCOMPOSITIONCHANGED - #define WM_DWMCOMPOSITIONCHANGED 0x031E -#endif -#ifndef WM_DWMCOLORIZATIONCOLORCHANGED - #define WM_DWMCOLORIZATIONCOLORCHANGED 0x0320 -#endif #ifndef WM_COPYGLOBALDATA #define WM_COPYGLOBALDATA 0x0049 #endif @@ -102,31 +94,6 @@ #define USER_DEFAULT_SCREEN_DPI 96 #endif -#if WINVER < 0x0601 -typedef struct -{ - DWORD cbSize; - DWORD ExtStatus; -} CHANGEFILTERSTRUCT; -#ifndef MSGFLT_ALLOW - #define MSGFLT_ALLOW 1 -#endif -#endif /*Windows 7*/ - -#if WINVER < 0x0600 -#define DWM_BB_ENABLE 0x00000001 -#define DWM_BB_BLURREGION 0x00000002 -typedef struct -{ - DWORD dwFlags; - BOOL fEnable; - HRGN hRgnBlur; - BOOL fTransitionOnMaximized; -} DWM_BLURBEHIND; -#else - #include -#endif /*Windows Vista*/ - #ifndef DPI_ENUMS_DECLARED typedef enum { @@ -150,12 +117,6 @@ typedef enum // Replacement for versionhelpers.h macros, as we cannot rely on the // application having a correct embedded manifest // -#define IsWindowsVistaOrGreater() \ - _glfwIsWindowsVersionOrGreaterWin32(HIBYTE(_WIN32_WINNT_VISTA), \ - LOBYTE(_WIN32_WINNT_VISTA), 0) -#define IsWindows7OrGreater() \ - _glfwIsWindowsVersionOrGreaterWin32(HIBYTE(_WIN32_WINNT_WIN7), \ - LOBYTE(_WIN32_WINNT_WIN7), 0) #define IsWindows8OrGreater() \ _glfwIsWindowsVersionOrGreaterWin32(HIBYTE(_WIN32_WINNT_WIN8), \ LOBYTE(_WIN32_WINNT_WIN8), 0) @@ -266,15 +227,11 @@ typedef HRESULT (WINAPI * PFN_DirectInput8Create)(HINSTANCE,DWORD,REFIID,LPVOID* #define DirectInput8Create _glfw.win32.dinput8.Create // user32.dll function pointer typedefs -typedef BOOL (WINAPI * PFN_SetProcessDPIAware)(void); -typedef BOOL (WINAPI * PFN_ChangeWindowMessageFilterEx)(HWND,UINT,DWORD,CHANGEFILTERSTRUCT*); typedef BOOL (WINAPI * PFN_EnableNonClientDpiScaling)(HWND); typedef BOOL (WINAPI * PFN_SetProcessDpiAwarenessContext)(HANDLE); typedef UINT (WINAPI * PFN_GetDpiForWindow)(HWND); typedef BOOL (WINAPI * PFN_AdjustWindowRectExForDpi)(LPRECT,DWORD,BOOL,DWORD,UINT); typedef int (WINAPI * PFN_GetSystemMetricsForDpi)(int,UINT); -#define SetProcessDPIAware _glfw.win32.user32.SetProcessDPIAware_ -#define ChangeWindowMessageFilterEx _glfw.win32.user32.ChangeWindowMessageFilterEx_ #define EnableNonClientDpiScaling _glfw.win32.user32.EnableNonClientDpiScaling_ #define SetProcessDpiAwarenessContext _glfw.win32.user32.SetProcessDpiAwarenessContext_ #define GetDpiForWindow _glfw.win32.user32.GetDpiForWindow_ @@ -460,8 +417,6 @@ typedef struct _GLFWlibraryWin32 struct { HINSTANCE instance; - PFN_SetProcessDPIAware SetProcessDPIAware_; - PFN_ChangeWindowMessageFilterEx ChangeWindowMessageFilterEx_; PFN_EnableNonClientDpiScaling EnableNonClientDpiScaling_; PFN_SetProcessDpiAwarenessContext SetProcessDpiAwarenessContext_; PFN_GetDpiForWindow GetDpiForWindow_; diff --git a/src/win32_window.c b/src/win32_window.c index d014944b8..26f9684b7 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -374,9 +374,6 @@ static void updateFramebufferTransparency(const _GLFWwindow* window) BOOL composition, opaque; DWORD color; - if (!IsWindowsVistaOrGreater()) - return; - if (FAILED(DwmIsCompositionEnabled(&composition)) || !composition) return; @@ -983,7 +980,6 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l case WM_MOUSEHWHEEL: { - // This message is only sent on Windows Vista and later // NOTE: The X-axis is inverted for consistency with macOS and X11 _glfwInputScroll(window, -((SHORT) HIWORD(wParam) / (double) WHEEL_DELTA), 0.0); return 0; @@ -1407,15 +1403,9 @@ static int createNativeWindow(_GLFWwindow* window, SetPropW(window->win32.handle, L"GLFW", window); - if (IsWindows7OrGreater()) - { - ChangeWindowMessageFilterEx(window->win32.handle, - WM_DROPFILES, MSGFLT_ALLOW, NULL); - ChangeWindowMessageFilterEx(window->win32.handle, - WM_COPYDATA, MSGFLT_ALLOW, NULL); - ChangeWindowMessageFilterEx(window->win32.handle, - WM_COPYGLOBALDATA, MSGFLT_ALLOW, NULL); - } + ChangeWindowMessageFilterEx(window->win32.handle, WM_DROPFILES, MSGFLT_ALLOW, NULL); + ChangeWindowMessageFilterEx(window->win32.handle, WM_COPYDATA, MSGFLT_ALLOW, NULL); + ChangeWindowMessageFilterEx(window->win32.handle, WM_COPYGLOBALDATA, MSGFLT_ALLOW, NULL); window->win32.scaleToMonitor = wndconfig->scaleToMonitor; window->win32.keymenu = wndconfig->win32.keymenu; @@ -1981,9 +1971,6 @@ GLFWbool _glfwFramebufferTransparentWin32(_GLFWwindow* window) if (!window->win32.transparent) return GLFW_FALSE; - if (!IsWindowsVistaOrGreater()) - return GLFW_FALSE; - if (FAILED(DwmIsCompositionEnabled(&composition)) || !composition) return GLFW_FALSE; From feb2a6b7283cbea73d92410dbddf3cc83dcc957f Mon Sep 17 00:00:00 2001 From: Doug Binks Date: Wed, 16 Jul 2025 14:19:19 +0200 Subject: [PATCH 11/36] Wayland: Reset key repeat timer on window destruction Windows with keyboard focus may have an active key repeat timer. This should be reset when the window is closed, or key repeat events could be sent to a NULL window were it not for the quickfix in PR #2732. Fixes #2741 Probably the source of #2727 --- README.md | 1 + src/wl_window.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/README.md b/README.md index 718449f5e..e7ad5a0cd 100644 --- a/README.md +++ b/README.md @@ -132,6 +132,7 @@ information on what to include when reporting a bug. - [Wayland] Bugfix: `glfwInit` would segfault on compositor with no seat (#2517) - [Wayland] Bugfix: A drag entering a non-GLFW surface could cause a segfault - [Wayland] Bugfix: Ignore key repeat events when no window has keyboard focus (#2727) + - [Wayland] Bugfix: Reset key repeat timer when window destroyed (#2741,#2727) - [X11] Bugfix: Running without a WM could trigger an assert (#2593,#2601,#2631) - [Null] Added Vulkan 'window' surface creation via `VK_EXT_headless_surface` - [Null] Added EGL context creation on Mesa via `EGL_MESA_platform_surfaceless` diff --git a/src/wl_window.c b/src/wl_window.c index 6457f31e0..01650182c 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -2187,7 +2187,12 @@ void _glfwDestroyWindowWayland(_GLFWwindow* window) _glfw.wl.pointerFocus = NULL; if (window == _glfw.wl.keyboardFocus) + { + struct itimerspec timer = {0}; + timerfd_settime(_glfw.wl.keyRepeatTimerfd, 0, &timer, NULL); + _glfw.wl.keyboardFocus = NULL; + } if (window->wl.fractionalScale) wp_fractional_scale_v1_destroy(window->wl.fractionalScale); From ac10768495837eb98da27d01fe706073d6d251c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 17 Jul 2025 13:07:52 +0200 Subject: [PATCH 12/36] Wayland: Fix memory leaks in data offer reading The buffer storing the contents of the data offer being read could leak if buffer reallocation or reading from the pipe failed. --- README.md | 1 + src/wl_window.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/README.md b/README.md index e7ad5a0cd..c453739d0 100644 --- a/README.md +++ b/README.md @@ -133,6 +133,7 @@ information on what to include when reporting a bug. - [Wayland] Bugfix: A drag entering a non-GLFW surface could cause a segfault - [Wayland] Bugfix: Ignore key repeat events when no window has keyboard focus (#2727) - [Wayland] Bugfix: Reset key repeat timer when window destroyed (#2741,#2727) + - [Wayland] Bugfix: Memory would leak if reading a data offer failed midway - [X11] Bugfix: Running without a WM could trigger an assert (#2593,#2601,#2631) - [Null] Added Vulkan 'window' surface creation via `VK_EXT_headless_surface` - [Null] Added EGL context creation on Mesa via `EGL_MESA_platform_surfaceless` diff --git a/src/wl_window.c b/src/wl_window.c index 01650182c..def3b8704 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1333,6 +1333,7 @@ static char* readDataOfferAsString(struct wl_data_offer* offer, const char* mime if (!longer) { _glfwInputError(GLFW_OUT_OF_MEMORY, NULL); + _glfw_free(string); close(fds[0]); return NULL; } @@ -1352,6 +1353,7 @@ static char* readDataOfferAsString(struct wl_data_offer* offer, const char* mime _glfwInputError(GLFW_PLATFORM_ERROR, "Wayland: Failed to read from data offer pipe: %s", strerror(errno)); + _glfw_free(string); close(fds[0]); return NULL; } From 7b51a8eb315ba8221ee0cd37d6b8641e75cddadb Mon Sep 17 00:00:00 2001 From: Doug Binks Date: Sun, 10 Aug 2025 18:27:44 +0200 Subject: [PATCH 13/36] Wayland: Keyboard leave event handler now processes key repeats - Fixes #2736 --- README.md | 1 + src/wl_window.c | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/README.md b/README.md index c453739d0..456c75333 100644 --- a/README.md +++ b/README.md @@ -134,6 +134,7 @@ information on what to include when reporting a bug. - [Wayland] Bugfix: Ignore key repeat events when no window has keyboard focus (#2727) - [Wayland] Bugfix: Reset key repeat timer when window destroyed (#2741,#2727) - [Wayland] Bugfix: Memory would leak if reading a data offer failed midway + - [Wayland] Bugfix: Keyboard leave event handler now processes key repeats (#2736) - [X11] Bugfix: Running without a WM could trigger an assert (#2593,#2601,#2631) - [Null] Added Vulkan 'window' surface creation via `VK_EXT_headless_surface` - [Null] Added EGL context creation on Mesa via `EGL_MESA_platform_surfaceless` diff --git a/src/wl_window.c b/src/wl_window.c index def3b8704..7e15a3d01 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1760,6 +1760,24 @@ static void keyboardHandleLeave(void* userData, if (!window) return; + // Handle any key repeats up to this point. We don't poll as this should be infrequent. + uint64_t repeats; + if (read(_glfw.wl.keyRepeatTimerfd, &repeats, sizeof(repeats)) == 8) + { + if(_glfw.wl.keyboardFocus) + { + for (uint64_t i = 0; i < repeats; i++) + { + _glfwInputKey(_glfw.wl.keyboardFocus, + translateKey(_glfw.wl.keyRepeatScancode), + _glfw.wl.keyRepeatScancode, + GLFW_PRESS, + _glfw.wl.xkb.modifiers); + inputText(_glfw.wl.keyboardFocus, _glfw.wl.keyRepeatScancode); + } + } + } + struct itimerspec timer = {0}; timerfd_settime(_glfw.wl.keyRepeatTimerfd, 0, &timer, NULL); From 5245180c56120f05b75ecd2ba4933bd04890ebba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 21 Jul 2025 18:41:06 +0200 Subject: [PATCH 14/36] Formatting --- src/wl_platform.h | 80 +++++++++++++++++++++++------------------------ src/wl_window.c | 8 ++--- 2 files changed, 44 insertions(+), 44 deletions(-) diff --git a/src/wl_platform.h b/src/wl_platform.h index afa6f50af..eb68f7e8f 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -217,62 +217,62 @@ struct libdecor_configuration; enum libdecor_error { - LIBDECOR_ERROR_COMPOSITOR_INCOMPATIBLE, - LIBDECOR_ERROR_INVALID_FRAME_CONFIGURATION, + LIBDECOR_ERROR_COMPOSITOR_INCOMPATIBLE, + LIBDECOR_ERROR_INVALID_FRAME_CONFIGURATION, }; enum libdecor_window_state { - LIBDECOR_WINDOW_STATE_NONE = 0, - LIBDECOR_WINDOW_STATE_ACTIVE = 1, - LIBDECOR_WINDOW_STATE_MAXIMIZED = 2, - LIBDECOR_WINDOW_STATE_FULLSCREEN = 4, - LIBDECOR_WINDOW_STATE_TILED_LEFT = 8, - LIBDECOR_WINDOW_STATE_TILED_RIGHT = 16, - LIBDECOR_WINDOW_STATE_TILED_TOP = 32, - LIBDECOR_WINDOW_STATE_TILED_BOTTOM = 64 + LIBDECOR_WINDOW_STATE_NONE = 0, + LIBDECOR_WINDOW_STATE_ACTIVE = 1, + LIBDECOR_WINDOW_STATE_MAXIMIZED = 2, + LIBDECOR_WINDOW_STATE_FULLSCREEN = 4, + LIBDECOR_WINDOW_STATE_TILED_LEFT = 8, + LIBDECOR_WINDOW_STATE_TILED_RIGHT = 16, + LIBDECOR_WINDOW_STATE_TILED_TOP = 32, + LIBDECOR_WINDOW_STATE_TILED_BOTTOM = 64 }; enum libdecor_capabilities { - LIBDECOR_ACTION_MOVE = 1, - LIBDECOR_ACTION_RESIZE = 2, - LIBDECOR_ACTION_MINIMIZE = 4, - LIBDECOR_ACTION_FULLSCREEN = 8, - LIBDECOR_ACTION_CLOSE = 16 + LIBDECOR_ACTION_MOVE = 1, + LIBDECOR_ACTION_RESIZE = 2, + LIBDECOR_ACTION_MINIMIZE = 4, + LIBDECOR_ACTION_FULLSCREEN = 8, + LIBDECOR_ACTION_CLOSE = 16 }; struct libdecor_interface { - void (* error)(struct libdecor*,enum libdecor_error,const char*); - void (* reserved0)(void); - void (* reserved1)(void); - void (* reserved2)(void); - void (* reserved3)(void); - void (* reserved4)(void); - void (* reserved5)(void); - void (* reserved6)(void); - void (* reserved7)(void); - void (* reserved8)(void); - void (* reserved9)(void); + void (* error)(struct libdecor*,enum libdecor_error,const char*); + void (* reserved0)(void); + void (* reserved1)(void); + void (* reserved2)(void); + void (* reserved3)(void); + void (* reserved4)(void); + void (* reserved5)(void); + void (* reserved6)(void); + void (* reserved7)(void); + void (* reserved8)(void); + void (* reserved9)(void); }; struct libdecor_frame_interface { - void (* configure)(struct libdecor_frame*,struct libdecor_configuration*,void*); - void (* close)(struct libdecor_frame*,void*); - void (* commit)(struct libdecor_frame*,void*); - void (* dismiss_popup)(struct libdecor_frame*,const char*,void*); - void (* reserved0)(void); - void (* reserved1)(void); - void (* reserved2)(void); - void (* reserved3)(void); - void (* reserved4)(void); - void (* reserved5)(void); - void (* reserved6)(void); - void (* reserved7)(void); - void (* reserved8)(void); - void (* reserved9)(void); + void (* configure)(struct libdecor_frame*,struct libdecor_configuration*,void*); + void (* close)(struct libdecor_frame*,void*); + void (* commit)(struct libdecor_frame*,void*); + void (* dismiss_popup)(struct libdecor_frame*,const char*,void*); + void (* reserved0)(void); + void (* reserved1)(void); + void (* reserved2)(void); + void (* reserved3)(void); + void (* reserved4)(void); + void (* reserved5)(void); + void (* reserved6)(void); + void (* reserved7)(void); + void (* reserved8)(void); + void (* reserved9)(void); }; typedef struct libdecor* (* PFN_libdecor_new)(struct wl_display*,const struct libdecor_interface*); diff --git a/src/wl_window.c b/src/wl_window.c index 7e15a3d01..50f770e61 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -2207,12 +2207,12 @@ void _glfwDestroyWindowWayland(_GLFWwindow* window) _glfw.wl.pointerFocus = NULL; if (window == _glfw.wl.keyboardFocus) - { - struct itimerspec timer = {0}; - timerfd_settime(_glfw.wl.keyRepeatTimerfd, 0, &timer, NULL); + { + struct itimerspec timer = {0}; + timerfd_settime(_glfw.wl.keyRepeatTimerfd, 0, &timer, NULL); _glfw.wl.keyboardFocus = NULL; - } + } if (window->wl.fractionalScale) wp_fractional_scale_v1_destroy(window->wl.fractionalScale); From ddbb8e0f2ccf20ada8e91f28b0b2c1f60c6699f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 18 Jul 2025 15:28:36 +0200 Subject: [PATCH 15/36] Wayland: Fix fallback decoration cursor position If fallback decorations were in use, pointer motion over a decoration surface would cause glfwGetCursorPos to provide incorrect cursor positions. The cursor position is now only updated when the pointer is over the content area of the window, similar to libdecor and XDG decorations. --- README.md | 2 ++ src/wl_platform.h | 1 + src/wl_window.c | 20 +++++++++++++------- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 456c75333..a3fd32b28 100644 --- a/README.md +++ b/README.md @@ -135,6 +135,8 @@ information on what to include when reporting a bug. - [Wayland] Bugfix: Reset key repeat timer when window destroyed (#2741,#2727) - [Wayland] Bugfix: Memory would leak if reading a data offer failed midway - [Wayland] Bugfix: Keyboard leave event handler now processes key repeats (#2736) + - [Wayland] Bugfix: Retrieved cursor position would be incorrect when hovering over + fallback decorations - [X11] Bugfix: Running without a WM could trigger an assert (#2593,#2601,#2631) - [Null] Added Vulkan 'window' surface creation via `VK_EXT_headless_surface` - [Null] Added EGL context creation on Mesa via `EGL_MESA_platform_surfaceless` diff --git a/src/wl_platform.h b/src/wl_platform.h index eb68f7e8f..a85a7c2ae 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -413,6 +413,7 @@ typedef struct _GLFWwindowWayland struct wl_buffer* buffer; _GLFWfallbackEdgeWayland top, left, right, bottom; struct wl_surface* focus; + wl_fixed_t pointerX, pointerY; } fallback; } _GLFWwindowWayland; diff --git a/src/wl_window.c b/src/wl_window.c index 50f770e61..677efd79b 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1446,11 +1446,11 @@ static void pointerHandleMotion(void* userData, const double xpos = wl_fixed_to_double(sx); const double ypos = wl_fixed_to_double(sy); - window->wl.cursorPosX = xpos; - window->wl.cursorPosY = ypos; if (window->wl.hovered) { + window->wl.cursorPosX = xpos; + window->wl.cursorPosY = ypos; _glfw.wl.cursorPreviousName = NULL; _glfwInputCursorPos(window, xpos, ypos); return; @@ -1458,6 +1458,9 @@ static void pointerHandleMotion(void* userData, if (window->wl.fallback.decorations) { + window->wl.fallback.pointerX = sx; + window->wl.fallback.pointerY = sy; + const char* cursorName = "left_ptr"; if (window->resizable) @@ -1557,36 +1560,39 @@ static void pointerHandleButton(void* userData, if (window->wl.fallback.decorations) { + const double xpos = wl_fixed_to_double(window->wl.fallback.pointerX); + const double ypos = wl_fixed_to_double(window->wl.fallback.pointerY); + if (button == BTN_LEFT) { uint32_t edges = XDG_TOPLEVEL_RESIZE_EDGE_NONE; if (window->wl.fallback.focus == window->wl.fallback.top.surface) { - if (window->wl.cursorPosY < GLFW_BORDER_SIZE) + if (ypos < GLFW_BORDER_SIZE) edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP; else xdg_toplevel_move(window->wl.xdg.toplevel, _glfw.wl.seat, serial); } else if (window->wl.fallback.focus == window->wl.fallback.left.surface) { - if (window->wl.cursorPosY < GLFW_BORDER_SIZE) + if (ypos < GLFW_BORDER_SIZE) edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP_LEFT; else edges = XDG_TOPLEVEL_RESIZE_EDGE_LEFT; } else if (window->wl.fallback.focus == window->wl.fallback.right.surface) { - if (window->wl.cursorPosY < GLFW_BORDER_SIZE) + if (ypos < GLFW_BORDER_SIZE) edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP_RIGHT; else edges = XDG_TOPLEVEL_RESIZE_EDGE_RIGHT; } else if (window->wl.fallback.focus == window->wl.fallback.bottom.surface) { - if (window->wl.cursorPosX < GLFW_BORDER_SIZE) + if (xpos < GLFW_BORDER_SIZE) edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_LEFT; - else if (window->wl.cursorPosX > window->wl.width + GLFW_BORDER_SIZE) + else if (xpos > window->wl.width + GLFW_BORDER_SIZE) edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_RIGHT; else edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM; From 5190a30d8a96d76de172cb6595e4fd658ca8ada1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 18 Jul 2025 15:43:32 +0200 Subject: [PATCH 16/36] Wayland: Move fallback decoration struct member The cursorPreviousName member was only used for the fallback decorations but was not grouped with other related members. --- src/wl_platform.h | 2 +- src/wl_window.c | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/wl_platform.h b/src/wl_platform.h index a85a7c2ae..c3e456931 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -414,6 +414,7 @@ typedef struct _GLFWwindowWayland _GLFWfallbackEdgeWayland top, left, right, bottom; struct wl_surface* focus; wl_fixed_t pointerX, pointerY; + const char* cursorName; } fallback; } _GLFWwindowWayland; @@ -455,7 +456,6 @@ typedef struct _GLFWlibraryWayland struct wl_cursor_theme* cursorTheme; struct wl_cursor_theme* cursorThemeHiDPI; struct wl_surface* cursorSurface; - const char* cursorPreviousName; int cursorTimerfd; uint32_t serial; uint32_t pointerEnterSerial; diff --git a/src/wl_window.c b/src/wl_window.c index 677efd79b..b8a3e716f 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1417,7 +1417,6 @@ static void pointerHandleLeave(void* userData, _glfw.wl.serial = serial; _glfw.wl.pointerFocus = NULL; - _glfw.wl.cursorPreviousName = NULL; if (window->wl.hovered) { @@ -1427,7 +1426,10 @@ static void pointerHandleLeave(void* userData, else { if (window->wl.fallback.decorations) + { window->wl.fallback.focus = NULL; + window->wl.fallback.cursorName = NULL; + } } } @@ -1451,7 +1453,6 @@ static void pointerHandleMotion(void* userData, { window->wl.cursorPosX = xpos; window->wl.cursorPosY = ypos; - _glfw.wl.cursorPreviousName = NULL; _glfwInputCursorPos(window, xpos, ypos); return; } @@ -1495,7 +1496,7 @@ static void pointerHandleMotion(void* userData, } } - if (_glfw.wl.cursorPreviousName != cursorName) + if (window->wl.fallback.cursorName != cursorName) { struct wl_surface* surface = _glfw.wl.cursorSurface; struct wl_cursor_theme* theme = _glfw.wl.cursorTheme; @@ -1531,7 +1532,7 @@ static void pointerHandleMotion(void* userData, wl_surface_damage(surface, 0, 0, image->width, image->height); wl_surface_commit(surface); - _glfw.wl.cursorPreviousName = cursorName; + window->wl.fallback.cursorName = cursorName; } } } From 7523b0e6bdd84baa68d4de731a978581293aae0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 18 Jul 2025 16:00:25 +0200 Subject: [PATCH 17/36] Wayland: Move fallback decoration pointer logic Decluttered the wl_pointer handlers by moving the bulk of fallback decoration related logic to separate functions. --- src/wl_window.c | 293 +++++++++++++++++++++++++----------------------- 1 file changed, 152 insertions(+), 141 deletions(-) diff --git a/src/wl_window.c b/src/wl_window.c index b8a3e716f..99a8a0e28 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -275,6 +275,149 @@ static void destroyFallbackDecorations(_GLFWwindow* window) destroyFallbackEdge(&window->wl.fallback.bottom); } +static void updateFallbackDecorationCursor(_GLFWwindow* window, + wl_fixed_t sx, + wl_fixed_t sy) +{ + window->wl.fallback.pointerX = sx; + window->wl.fallback.pointerY = sy; + + const double xpos = wl_fixed_to_double(sx); + const double ypos = wl_fixed_to_double(sy); + const char* cursorName = "left_ptr"; + + if (window->resizable) + { + if (window->wl.fallback.focus == window->wl.fallback.top.surface) + { + if (ypos < GLFW_BORDER_SIZE) + cursorName = "n-resize"; + } + else if (window->wl.fallback.focus == window->wl.fallback.left.surface) + { + if (ypos < GLFW_BORDER_SIZE) + cursorName = "nw-resize"; + else + cursorName = "w-resize"; + } + else if (window->wl.fallback.focus == window->wl.fallback.right.surface) + { + if (ypos < GLFW_BORDER_SIZE) + cursorName = "ne-resize"; + else + cursorName = "e-resize"; + } + else if (window->wl.fallback.focus == window->wl.fallback.bottom.surface) + { + if (xpos < GLFW_BORDER_SIZE) + cursorName = "sw-resize"; + else if (xpos > window->wl.width + GLFW_BORDER_SIZE) + cursorName = "se-resize"; + else + cursorName = "s-resize"; + } + } + + if (window->wl.fallback.cursorName != cursorName) + { + struct wl_surface* surface = _glfw.wl.cursorSurface; + struct wl_cursor_theme* theme = _glfw.wl.cursorTheme; + int scale = 1; + + if (window->wl.bufferScale > 1 && _glfw.wl.cursorThemeHiDPI) + { + // We only support up to scale=2 for now, since libwayland-cursor + // requires us to load a different theme for each size. + scale = 2; + theme = _glfw.wl.cursorThemeHiDPI; + } + + struct wl_cursor* cursor = wl_cursor_theme_get_cursor(theme, cursorName); + if (!cursor) + return; + + // TODO: handle animated cursors too. + struct wl_cursor_image* image = cursor->images[0]; + if (!image) + return; + + struct wl_buffer* buffer = wl_cursor_image_get_buffer(image); + if (!buffer) + return; + + wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.pointerEnterSerial, + surface, + image->hotspot_x / scale, + image->hotspot_y / scale); + wl_surface_set_buffer_scale(surface, scale); + wl_surface_attach(surface, buffer, 0, 0); + wl_surface_damage(surface, 0, 0, image->width, image->height); + wl_surface_commit(surface); + + window->wl.fallback.cursorName = cursorName; + } +} + +static void handleFallbackDecorationButton(_GLFWwindow* window, + uint32_t serial, + uint32_t button) +{ + const double xpos = wl_fixed_to_double(window->wl.fallback.pointerX); + const double ypos = wl_fixed_to_double(window->wl.fallback.pointerY); + + if (button == BTN_LEFT) + { + uint32_t edges = XDG_TOPLEVEL_RESIZE_EDGE_NONE; + + if (window->wl.fallback.focus == window->wl.fallback.top.surface) + { + if (ypos < GLFW_BORDER_SIZE) + edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP; + else + xdg_toplevel_move(window->wl.xdg.toplevel, _glfw.wl.seat, serial); + } + else if (window->wl.fallback.focus == window->wl.fallback.left.surface) + { + if (ypos < GLFW_BORDER_SIZE) + edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP_LEFT; + else + edges = XDG_TOPLEVEL_RESIZE_EDGE_LEFT; + } + else if (window->wl.fallback.focus == window->wl.fallback.right.surface) + { + if (ypos < GLFW_BORDER_SIZE) + edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP_RIGHT; + else + edges = XDG_TOPLEVEL_RESIZE_EDGE_RIGHT; + } + else if (window->wl.fallback.focus == window->wl.fallback.bottom.surface) + { + if (xpos < GLFW_BORDER_SIZE) + edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_LEFT; + else if (xpos > window->wl.width + GLFW_BORDER_SIZE) + edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_RIGHT; + else + edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM; + } + + if (edges != XDG_TOPLEVEL_RESIZE_EDGE_NONE) + { + xdg_toplevel_resize(window->wl.xdg.toplevel, _glfw.wl.seat, + serial, edges); + } + } + else if (button == BTN_RIGHT) + { + if (window->wl.xdg.toplevel) + { + xdg_toplevel_show_window_menu(window->wl.xdg.toplevel, + _glfw.wl.seat, serial, + window->wl.cursorPosX, + window->wl.cursorPosY); + } + } +} + static void xdgDecorationHandleConfigure(void* userData, struct zxdg_toplevel_decoration_v1* decoration, uint32_t mode) @@ -1446,94 +1589,16 @@ static void pointerHandleMotion(void* userData, if (window->cursorMode == GLFW_CURSOR_DISABLED) return; - const double xpos = wl_fixed_to_double(sx); - const double ypos = wl_fixed_to_double(sy); - if (window->wl.hovered) { - window->wl.cursorPosX = xpos; - window->wl.cursorPosY = ypos; - _glfwInputCursorPos(window, xpos, ypos); - return; + window->wl.cursorPosX = wl_fixed_to_double(sx); + window->wl.cursorPosY = wl_fixed_to_double(sy); + _glfwInputCursorPos(window, window->wl.cursorPosX, window->wl.cursorPosY); } - - if (window->wl.fallback.decorations) + else { - window->wl.fallback.pointerX = sx; - window->wl.fallback.pointerY = sy; - - const char* cursorName = "left_ptr"; - - if (window->resizable) - { - if (window->wl.fallback.focus == window->wl.fallback.top.surface) - { - if (ypos < GLFW_BORDER_SIZE) - cursorName = "n-resize"; - } - else if (window->wl.fallback.focus == window->wl.fallback.left.surface) - { - if (ypos < GLFW_BORDER_SIZE) - cursorName = "nw-resize"; - else - cursorName = "w-resize"; - } - else if (window->wl.fallback.focus == window->wl.fallback.right.surface) - { - if (ypos < GLFW_BORDER_SIZE) - cursorName = "ne-resize"; - else - cursorName = "e-resize"; - } - else if (window->wl.fallback.focus == window->wl.fallback.bottom.surface) - { - if (xpos < GLFW_BORDER_SIZE) - cursorName = "sw-resize"; - else if (xpos > window->wl.width + GLFW_BORDER_SIZE) - cursorName = "se-resize"; - else - cursorName = "s-resize"; - } - } - - if (window->wl.fallback.cursorName != cursorName) - { - struct wl_surface* surface = _glfw.wl.cursorSurface; - struct wl_cursor_theme* theme = _glfw.wl.cursorTheme; - int scale = 1; - - if (window->wl.bufferScale > 1 && _glfw.wl.cursorThemeHiDPI) - { - // We only support up to scale=2 for now, since libwayland-cursor - // requires us to load a different theme for each size. - scale = 2; - theme = _glfw.wl.cursorThemeHiDPI; - } - - struct wl_cursor* cursor = wl_cursor_theme_get_cursor(theme, cursorName); - if (!cursor) - return; - - // TODO: handle animated cursors too. - struct wl_cursor_image* image = cursor->images[0]; - if (!image) - return; - - struct wl_buffer* buffer = wl_cursor_image_get_buffer(image); - if (!buffer) - return; - - wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.pointerEnterSerial, - surface, - image->hotspot_x / scale, - image->hotspot_y / scale); - wl_surface_set_buffer_scale(surface, scale); - wl_surface_attach(surface, buffer, 0, 0); - wl_surface_damage(surface, 0, 0, image->width, image->height); - wl_surface_commit(surface); - - window->wl.fallback.cursorName = cursorName; - } + if (window->wl.fallback.decorations) + updateFallbackDecorationCursor(window, sx, sy); } } @@ -1556,65 +1621,11 @@ static void pointerHandleButton(void* userData, button - BTN_LEFT, state == WL_POINTER_BUTTON_STATE_PRESSED, _glfw.wl.xkb.modifiers); - return; } - - if (window->wl.fallback.decorations) + else { - const double xpos = wl_fixed_to_double(window->wl.fallback.pointerX); - const double ypos = wl_fixed_to_double(window->wl.fallback.pointerY); - - if (button == BTN_LEFT) - { - uint32_t edges = XDG_TOPLEVEL_RESIZE_EDGE_NONE; - - if (window->wl.fallback.focus == window->wl.fallback.top.surface) - { - if (ypos < GLFW_BORDER_SIZE) - edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP; - else - xdg_toplevel_move(window->wl.xdg.toplevel, _glfw.wl.seat, serial); - } - else if (window->wl.fallback.focus == window->wl.fallback.left.surface) - { - if (ypos < GLFW_BORDER_SIZE) - edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP_LEFT; - else - edges = XDG_TOPLEVEL_RESIZE_EDGE_LEFT; - } - else if (window->wl.fallback.focus == window->wl.fallback.right.surface) - { - if (ypos < GLFW_BORDER_SIZE) - edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP_RIGHT; - else - edges = XDG_TOPLEVEL_RESIZE_EDGE_RIGHT; - } - else if (window->wl.fallback.focus == window->wl.fallback.bottom.surface) - { - if (xpos < GLFW_BORDER_SIZE) - edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_LEFT; - else if (xpos > window->wl.width + GLFW_BORDER_SIZE) - edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_RIGHT; - else - edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM; - } - - if (edges != XDG_TOPLEVEL_RESIZE_EDGE_NONE) - { - xdg_toplevel_resize(window->wl.xdg.toplevel, _glfw.wl.seat, - serial, edges); - } - } - else if (button == BTN_RIGHT) - { - if (window->wl.xdg.toplevel) - { - xdg_toplevel_show_window_menu(window->wl.xdg.toplevel, - _glfw.wl.seat, serial, - window->wl.cursorPosX, - window->wl.cursorPosY); - } - } + if (window->wl.fallback.decorations) + handleFallbackDecorationButton(window, serial, button); } } From 645a35a38ed2cefd5a236db3eebc51f63065a4e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 18 Jul 2025 16:04:40 +0200 Subject: [PATCH 18/36] Wayland: Cleanup --- src/wl_window.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/wl_window.c b/src/wl_window.c index 99a8a0e28..134ef6d1a 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -401,10 +401,7 @@ static void handleFallbackDecorationButton(_GLFWwindow* window, } if (edges != XDG_TOPLEVEL_RESIZE_EDGE_NONE) - { - xdg_toplevel_resize(window->wl.xdg.toplevel, _glfw.wl.seat, - serial, edges); - } + xdg_toplevel_resize(window->wl.xdg.toplevel, _glfw.wl.seat, serial, edges); } else if (button == BTN_RIGHT) { From 161fb1b6f6adaf92a88a922bb2d974fb62e911d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 18 Jul 2025 16:35:57 +0200 Subject: [PATCH 19/36] Wayland: Fix fallback decoration scroll events The fallback decorations would emit scroll events as if scrolling had occurred over the content area of the window. --- README.md | 1 + src/wl_window.c | 13 ++++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index a3fd32b28..d1be31411 100644 --- a/README.md +++ b/README.md @@ -137,6 +137,7 @@ information on what to include when reporting a bug. - [Wayland] Bugfix: Keyboard leave event handler now processes key repeats (#2736) - [Wayland] Bugfix: Retrieved cursor position would be incorrect when hovering over fallback decorations + - [Wayland] Bugfix: Fallback decorations would report scroll events - [X11] Bugfix: Running without a WM could trigger an assert (#2593,#2601,#2631) - [Null] Added Vulkan 'window' surface creation via `VK_EXT_headless_surface` - [Null] Added EGL context creation on Mesa via `EGL_MESA_platform_surfaceless` diff --git a/src/wl_window.c b/src/wl_window.c index 134ef6d1a..0a6a8543e 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1636,11 +1636,14 @@ static void pointerHandleAxis(void* userData, if (!window) return; - // NOTE: 10 units of motion per mouse wheel step seems to be a common ratio - if (axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL) - _glfwInputScroll(window, -wl_fixed_to_double(value) / 10.0, 0.0); - else if (axis == WL_POINTER_AXIS_VERTICAL_SCROLL) - _glfwInputScroll(window, 0.0, -wl_fixed_to_double(value) / 10.0); + if (window->wl.hovered) + { + // NOTE: 10 units of motion per mouse wheel step seems to be a common ratio + if (axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL) + _glfwInputScroll(window, -wl_fixed_to_double(value) / 10.0, 0.0); + else if (axis == WL_POINTER_AXIS_VERTICAL_SCROLL) + _glfwInputScroll(window, 0.0, -wl_fixed_to_double(value) / 10.0); + } } static const struct wl_pointer_listener pointerListener = From 768e81a0eb3ae411d108168fdff7cd3335f2a34a Mon Sep 17 00:00:00 2001 From: Jan Hendrik Farr Date: Fri, 31 May 2024 01:42:53 +0200 Subject: [PATCH 20/36] Wayland: Fix key repeat halting Key repeat shoud only be halted when the repeating key is released, not when another key is released. --- CONTRIBUTORS.md | 1 + README.md | 1 + src/wl_window.c | 5 +++-- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 8fa1cb724..295a4c477 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -68,6 +68,7 @@ video tutorials. - Jan Ekström - Siavash Eliasi - er-azh + - Jan Hendrik Farr - Ahmad Fatoum - Nikita Fediuchin - Felipe Ferreira diff --git a/README.md b/README.md index d1be31411..cebdf0896 100644 --- a/README.md +++ b/README.md @@ -138,6 +138,7 @@ information on what to include when reporting a bug. - [Wayland] Bugfix: Retrieved cursor position would be incorrect when hovering over fallback decorations - [Wayland] Bugfix: Fallback decorations would report scroll events + - [Wayland] Bugfix: Keyboard repeat events halted when any key is released (#2568) - [X11] Bugfix: Running without a WM could trigger an assert (#2593,#2601,#2631) - [Null] Added Vulkan 'window' surface creation via `VK_EXT_headless_surface` - [Null] Added EGL context creation on Mesa via `EGL_MESA_platform_surfaceless` diff --git a/src/wl_window.c b/src/wl_window.c index 0a6a8543e..b33a2262f 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1838,11 +1838,12 @@ static void keyboardHandleKey(void* userData, timer.it_value.tv_sec = _glfw.wl.keyRepeatDelay / 1000; timer.it_value.tv_nsec = (_glfw.wl.keyRepeatDelay % 1000) * 1000000; + timerfd_settime(_glfw.wl.keyRepeatTimerfd, 0, &timer, NULL); } + } else if (scancode == _glfw.wl.keyRepeatScancode) { + timerfd_settime(_glfw.wl.keyRepeatTimerfd, 0, &timer, NULL); } - timerfd_settime(_glfw.wl.keyRepeatTimerfd, 0, &timer, NULL); - _glfwInputKey(window, key, scancode, action, _glfw.wl.xkb.modifiers); if (action == GLFW_PRESS) From 0d2d85d19c16ae936fb6b076a1a9ccdd732e65c0 Mon Sep 17 00:00:00 2001 From: Doug Binks Date: Fri, 15 Aug 2025 11:27:59 +0200 Subject: [PATCH 21/36] Revert "Wayland: Keyboard leave event handler now processes key repeats" --- src/wl_window.c | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/src/wl_window.c b/src/wl_window.c index b33a2262f..2b172c9c2 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1778,24 +1778,6 @@ static void keyboardHandleLeave(void* userData, if (!window) return; - // Handle any key repeats up to this point. We don't poll as this should be infrequent. - uint64_t repeats; - if (read(_glfw.wl.keyRepeatTimerfd, &repeats, sizeof(repeats)) == 8) - { - if(_glfw.wl.keyboardFocus) - { - for (uint64_t i = 0; i < repeats; i++) - { - _glfwInputKey(_glfw.wl.keyboardFocus, - translateKey(_glfw.wl.keyRepeatScancode), - _glfw.wl.keyRepeatScancode, - GLFW_PRESS, - _glfw.wl.xkb.modifiers); - inputText(_glfw.wl.keyboardFocus, _glfw.wl.keyRepeatScancode); - } - } - } - struct itimerspec timer = {0}; timerfd_settime(_glfw.wl.keyRepeatTimerfd, 0, &timer, NULL); From bfa1c424e56093bc4a08184ec68543e45b468374 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 14 Aug 2025 21:19:13 +0200 Subject: [PATCH 22/36] Wayland: Fix fallback decoration menu placement The fallback decorations would place the menu at the wrong position, by not translating the last decoration surface position into toplevel surface coordinates. This also limits the menu to the caption area of the top decoration surface, similar to how other toolkits work. --- README.md | 1 + src/wl_window.c | 20 +++++++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index cebdf0896..6efa1ae70 100644 --- a/README.md +++ b/README.md @@ -139,6 +139,7 @@ information on what to include when reporting a bug. fallback decorations - [Wayland] Bugfix: Fallback decorations would report scroll events - [Wayland] Bugfix: Keyboard repeat events halted when any key is released (#2568) + - [Wayland] Bugfix: Fallback decorations would show menu at wrong position - [X11] Bugfix: Running without a WM could trigger an assert (#2593,#2601,#2631) - [Null] Added Vulkan 'window' surface creation via `VK_EXT_headless_surface` - [Null] Added EGL context creation on Mesa via `EGL_MESA_platform_surfaceless` diff --git a/src/wl_window.c b/src/wl_window.c index 2b172c9c2..b9aa405d1 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -405,13 +405,19 @@ static void handleFallbackDecorationButton(_GLFWwindow* window, } else if (button == BTN_RIGHT) { - if (window->wl.xdg.toplevel) - { - xdg_toplevel_show_window_menu(window->wl.xdg.toplevel, - _glfw.wl.seat, serial, - window->wl.cursorPosX, - window->wl.cursorPosY); - } + if (!window->wl.xdg.toplevel) + return; + + if (window->wl.fallback.focus != window->wl.fallback.top.surface) + return; + + if (ypos < GLFW_BORDER_SIZE) + return; + + xdg_toplevel_show_window_menu(window->wl.xdg.toplevel, + _glfw.wl.seat, serial, + xpos, + ypos - GLFW_CAPTION_HEIGHT - GLFW_BORDER_SIZE); } } From 3cf9f6726d1062c219d861755768ec5a2a238ae4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 18 Aug 2025 16:17:55 +0200 Subject: [PATCH 23/36] Wayland: Fix fallback decoration cursor updating When a click through to the fallback decorations caused the end of a modal like the window menu, the cursor shape would not be updated until the next time the cursor moved. This commit adds an update of the cursor for the pointer enter event for fallback decoration surfaces, in addition to the updates at pointer motion events. --- README.md | 2 ++ src/wl_window.c | 3 +++ 2 files changed, 5 insertions(+) diff --git a/README.md b/README.md index 6efa1ae70..f7c3b07d3 100644 --- a/README.md +++ b/README.md @@ -140,6 +140,8 @@ information on what to include when reporting a bug. - [Wayland] Bugfix: Fallback decorations would report scroll events - [Wayland] Bugfix: Keyboard repeat events halted when any key is released (#2568) - [Wayland] Bugfix: Fallback decorations would show menu at wrong position + - [Wayland] Bugfix: The cursor was not updated when clicking through from + a modal to a fallback decoration - [X11] Bugfix: Running without a WM could trigger an assert (#2593,#2601,#2631) - [Null] Added Vulkan 'window' surface creation via `VK_EXT_headless_surface` - [Null] Added EGL context creation on Mesa via `EGL_MESA_platform_surfaceless` diff --git a/src/wl_window.c b/src/wl_window.c index b9aa405d1..ed767055d 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1542,7 +1542,10 @@ static void pointerHandleEnter(void* userData, else { if (window->wl.fallback.decorations) + { window->wl.fallback.focus = surface; + updateFallbackDecorationCursor(window, sx, sy); + } } } From 7ef6efeb662e0833645e4b03b910e054fc7d8a85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 14 Aug 2025 21:38:37 +0200 Subject: [PATCH 24/36] Wayland: Fix cursor position after a modal If a modal surface like the window menu was active, clicking on the GLFW window content area to close it would correctly emit the cursor enter event but would not propagate the cursor position from the event. --- README.md | 2 ++ src/wl_window.c | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/README.md b/README.md index f7c3b07d3..c0a473d41 100644 --- a/README.md +++ b/README.md @@ -142,6 +142,8 @@ information on what to include when reporting a bug. - [Wayland] Bugfix: Fallback decorations would show menu at wrong position - [Wayland] Bugfix: The cursor was not updated when clicking through from a modal to a fallback decoration + - [Wayland] Bugfix: The cursor position was not updated when clicking through + from a modal to the content area - [X11] Bugfix: Running without a WM could trigger an assert (#2593,#2601,#2631) - [Null] Added Vulkan 'window' surface creation via `VK_EXT_headless_surface` - [Null] Added EGL context creation on Mesa via `EGL_MESA_platform_surfaceless` diff --git a/src/wl_window.c b/src/wl_window.c index ed767055d..4220d17e0 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1538,6 +1538,13 @@ static void pointerHandleEnter(void* userData, window->wl.hovered = GLFW_TRUE; _glfwSetCursorWayland(window, window->wl.currentCursor); _glfwInputCursorEnter(window, GLFW_TRUE); + + if (window->cursorMode != GLFW_CURSOR_DISABLED) + { + window->wl.cursorPosX = wl_fixed_to_double(sx); + window->wl.cursorPosY = wl_fixed_to_double(sy); + _glfwInputCursorPos(window, window->wl.cursorPosX, window->wl.cursorPosY); + } } else { From acb92944d4e97e6efa36057927c9fcf114710226 Mon Sep 17 00:00:00 2001 From: Doug Binks Date: Tue, 19 Aug 2025 11:30:52 +0200 Subject: [PATCH 25/36] Revert readme for "Wayland: Keyboard leave event handler now processes key repeats" --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index c0a473d41..6eb6b9bd1 100644 --- a/README.md +++ b/README.md @@ -134,7 +134,6 @@ information on what to include when reporting a bug. - [Wayland] Bugfix: Ignore key repeat events when no window has keyboard focus (#2727) - [Wayland] Bugfix: Reset key repeat timer when window destroyed (#2741,#2727) - [Wayland] Bugfix: Memory would leak if reading a data offer failed midway - - [Wayland] Bugfix: Keyboard leave event handler now processes key repeats (#2736) - [Wayland] Bugfix: Retrieved cursor position would be incorrect when hovering over fallback decorations - [Wayland] Bugfix: Fallback decorations would report scroll events From 63a7e8b7f82497b0459acba5c1ce7f39aa2bc0e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 18 Aug 2025 21:06:50 +0200 Subject: [PATCH 26/36] Add and update Wayland-specific notes in docs Fixes #2746 --- CONTRIBUTORS.md | 1 + docs/monitor.md | 4 ++++ docs/window.md | 12 ++++++++++++ include/GLFW/glfw3.h | 45 ++++++++++++++++++++++++-------------------- 4 files changed, 42 insertions(+), 20 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 295a4c477..d8eb7aee0 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -55,6 +55,7 @@ video tutorials. - Jason Daly - danhambleton - Jarrod Davis + - decce - Olivier Delannoy - Paul R. Deppe - Michael Dickens diff --git a/docs/monitor.md b/docs/monitor.md index 12d98541a..df5fda9ae 100644 --- a/docs/monitor.md +++ b/docs/monitor.md @@ -255,3 +255,7 @@ hardware gamma correction, which today is typically an approximation of sRGB gamma. This means that setting a perfectly linear ramp, or gamma 1.0, will produce the default (usually sRGB-like) behavior. +@note @wayland An application cannot read or modify the monitor gamma ramp. The +@ref glfwGetGammaRamp, @ref glfwSetGammaRamp and @ref glfwSetGamma functions +emit @ref GLFW_FEATURE_UNAVAILABLE. + diff --git a/docs/window.md b/docs/window.md index 371baa562..dd6d8a2aa 100644 --- a/docs/window.md +++ b/docs/window.md @@ -893,6 +893,12 @@ int xpos, ypos; glfwGetWindowPos(window, &xpos, &ypos); ``` +@note @wayland An applications cannot know the positions of its windows or +whether one has been moved. The @ref GLFW_POSITION_X and @ref GLFW_POSITION_Y +window hints are ignored. The @ref glfwGetWindowPos and @ref glfwSetWindowPos +functions emit @ref GLFW_FEATURE_UNAVAILABLE. The window position callback will +not be called. + ### Window title {#window_title} @@ -1038,6 +1044,12 @@ You can also get the current iconification state with @ref glfwGetWindowAttrib. int iconified = glfwGetWindowAttrib(window, GLFW_ICONIFIED); ``` +@note @wayland An application cannot know if any of its windows have been +iconified or restore one from iconification. The @ref glfwRestoreWindow +function can only restore windows from maximization and the iconify callback +will not be called. The [GLFW_ICONIFIED](@ref GLFW_ICONIFIED_attrib) attribute +will be false. The @ref glfwIconifyWindow function works normally. + ### Window maximization {#window_maximize} diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 79b062884..b0ce7f660 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -2915,8 +2915,8 @@ GLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* monitor); * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref GLFW_INVALID_VALUE, * @ref GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks). * - * @remark @wayland Gamma handling is a privileged protocol, this function - * will thus never be implemented and emits @ref GLFW_FEATURE_UNAVAILABLE. + * @remark @wayland Monitor gamma is a privileged protocol, so this function + * cannot be implemented and emits @ref GLFW_FEATURE_UNAVAILABLE. * * @thread_safety This function must only be called from the main thread. * @@ -2939,8 +2939,8 @@ GLFWAPI void glfwSetGamma(GLFWmonitor* monitor, float gamma); * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref GLFW_PLATFORM_ERROR * and @ref GLFW_FEATURE_UNAVAILABLE (see remarks). * - * @remark @wayland Gamma handling is a privileged protocol, this function - * will thus never be implemented and emits @ref GLFW_FEATURE_UNAVAILABLE while + * @remark @wayland Monitor gamma is a privileged protocol, so this function + * cannot be implemented and emits @ref GLFW_FEATURE_UNAVAILABLE while * returning `NULL`. * * @pointer_lifetime The returned structure and its arrays are allocated and @@ -2983,8 +2983,8 @@ GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* monitor); * * @remark @win32 The gamma ramp size must be 256. * - * @remark @wayland Gamma handling is a privileged protocol, this function - * will thus never be implemented and emits @ref GLFW_FEATURE_UNAVAILABLE. + * @remark @wayland Monitor gamma is a privileged protocol, so this function + * cannot be implemented and emits @ref GLFW_FEATURE_UNAVAILABLE. * * @pointer_lifetime The specified gamma ramp is copied before this function * returns. @@ -3430,8 +3430,8 @@ GLFWAPI void glfwSetWindowIcon(GLFWwindow* window, int count, const GLFWimage* i * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref * GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks). * - * @remark @wayland There is no way for an application to retrieve the global - * position of its windows. This function will emit @ref + * @remark @wayland Window positions are not currently part of any common + * Wayland protocol, so this function cannot be implemented and will emit @ref * GLFW_FEATURE_UNAVAILABLE. * * @thread_safety This function must only be called from the main thread. @@ -3464,8 +3464,8 @@ GLFWAPI void glfwGetWindowPos(GLFWwindow* window, int* xpos, int* ypos); * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref * GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks). * - * @remark @wayland There is no way for an application to set the global - * position of its windows. This function will emit @ref + * @remark @wayland Window positions are not currently part of any common + * Wayland protocol, so this function cannot be implemented and will emit @ref * GLFW_FEATURE_UNAVAILABLE. * * @thread_safety This function must only be called from the main thread. @@ -3807,10 +3807,6 @@ GLFWAPI void glfwSetWindowOpacity(GLFWwindow* window, float opacity); * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref * GLFW_PLATFORM_ERROR. * - * @remark @wayland Once a window is iconified, @ref glfwRestoreWindow won’t - * be able to restore it. This is a design decision of the xdg-shell - * protocol. - * * @thread_safety This function must only be called from the main thread. * * @sa @ref window_iconify @@ -3838,6 +3834,10 @@ GLFWAPI void glfwIconifyWindow(GLFWwindow* window); * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref * GLFW_PLATFORM_ERROR. * + * @remark @wayland Restoring a window from maximization is not currently part + * of any common Wayland protocol, so this function can only restore windows + * from maximization. + * * @thread_safety This function must only be called from the main thread. * * @sa @ref window_iconify @@ -4058,8 +4058,8 @@ GLFWAPI GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* window); * affected by any resizing or mode switching, although you may need to update * your viewport if the framebuffer size has changed. * - * @remark @wayland The desired window position is ignored, as there is no way - * for an application to set this property. + * @remark @wayland Window positions are not currently part of any common + * Wayland protocol. The window position arguments are ignored. * * @thread_safety This function must only be called from the main thread. * @@ -4096,8 +4096,9 @@ GLFWAPI void glfwSetWindowMonitor(GLFWwindow* window, GLFWmonitor* monitor, int * errors. However, this function should not fail as long as it is passed * valid arguments and the library has been [initialized](@ref intro_init). * - * @remark @wayland The Wayland protocol provides no way to check whether a - * window is iconfied, so @ref GLFW_ICONIFIED always returns `GLFW_FALSE`. + * @remark @wayland Checking whether a window is iconified is not currently + * part of any common Wayland protocol, so the @ref GLFW_ICONIFIED attribute + * cannot be implemented and is always `GLFW_FALSE`. * * @thread_safety This function must only be called from the main thread. * @@ -4219,8 +4220,8 @@ GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow* window); * * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. * - * @remark @wayland This callback will never be called, as there is no way for - * an application to know its global position. + * @remark @wayland This callback will not be called. The Wayland protocol + * provides no way to be notified of when a window is moved. * * @thread_safety This function must only be called from the main thread. * @@ -4395,6 +4396,10 @@ GLFWAPI GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* window, GLFWwi * * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. * + * @remark @wayland This callback will not be called. The Wayland protocol + * provides no way to be notified of when a window is iconified, and no way to + * check whether a window is currently iconified. + * * @thread_safety This function must only be called from the main thread. * * @sa @ref window_iconify From 5c87937e444bef5b796f6f877bd9bcf549e3ef9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 21 Aug 2025 19:07:33 +0200 Subject: [PATCH 27/36] Update README --- README.md | 129 +++++++++++++++++++++++++++--------------------------- 1 file changed, 64 insertions(+), 65 deletions(-) diff --git a/README.md b/README.md index 6eb6b9bd1..5148467a7 100644 --- a/README.md +++ b/README.md @@ -9,34 +9,28 @@ GLFW is an Open Source, multi-platform library for OpenGL, OpenGL ES and Vulkan application development. It provides a simple, platform-independent API for creating windows, contexts and surfaces, reading input, handling events, etc. -GLFW natively supports Windows, macOS and Linux and other Unix-like systems. On -Linux both Wayland and X11 are supported. +GLFW is written primarily in C99, with parts of macOS support being written in +Objective-C. + +GLFW supports Windows, macOS and Linux, and also works on many other Unix-like +systems. On Linux both Wayland and X11 are supported. GLFW is licensed under the [zlib/libpng license](https://www.glfw.org/license.html). You can [download](https://www.glfw.org/download.html) the latest stable release -as source or Windows binaries. Each release starting with 3.0 also has -a corresponding [annotated tag](https://github.com/glfw/glfw/releases) with -source and binary archives. +as source or Windows and macOS binaries. There are [release +tags](https://github.com/glfw/glfw/releases) with source and binary archives +attached for every version since 3.0. The [documentation](https://www.glfw.org/docs/latest/) is available online and is -included in all source and binary archives. See the [release -notes](https://www.glfw.org/docs/latest/news.html) for new features, caveats and -deprecations in the latest release. For more details see the [version -history](https://www.glfw.org/changelog.html). - -The `master` branch is the stable integration branch and _should_ always compile -and run on all supported platforms, although details of newly added features may -change until they have been included in a release. New features and many bug -fixes live in [other branches](https://github.com/glfw/glfw/branches/all) until -they are stable enough to merge. - -If you are new to GLFW, you may find the -[tutorial](https://www.glfw.org/docs/latest/quick.html) for GLFW 3 useful. If -you have used GLFW 2 in the past, there is a [transition -guide](https://www.glfw.org/docs/latest/moving.html) for moving to the GLFW -3 API. +also included in source and binary archives, except those generated +automatically by Github. The documentation contains guides, a tutorial and the +API reference. The [release +notes](https://www.glfw.org/docs/latest/news.html) list the new features, +caveats and deprecations in the latest release. The [version +history](https://www.glfw.org/changelog.html) lists every user-visible change +for every release. GLFW exists because of the contributions of [many people](CONTRIBUTORS.md) around the world, whether by reporting bugs, providing community support, adding @@ -44,57 +38,37 @@ features, reviewing or testing code, debugging, proofreading docs, suggesting features or fixing bugs. -## Compiling GLFW - -GLFW is written primarily in C99, with parts of macOS support being written in -Objective-C. GLFW itself requires only the headers and libraries for your OS -and window system. It does not need any additional headers for context creation -APIs (WGL, GLX, EGL, NSGL, OSMesa) or rendering APIs (OpenGL, OpenGL ES, Vulkan) -to enable support for them. - -GLFW supports compilation on Windows with Visual C++ (2013 and later) and -MinGW-w64, on macOS with Clang and on Linux and other Unix-like systems with GCC -and Clang. It will likely compile in other environments as well, but this is -not regularly tested. - -There are [pre-compiled binaries](https://www.glfw.org/download.html) available -for all supported compilers on Windows and macOS. - -See the [compilation guide](https://www.glfw.org/docs/latest/compile.html) for -more information about how to compile GLFW yourself. - - -## Using GLFW - -See the [documentation](https://www.glfw.org/docs/latest/) for tutorials, guides -and the API reference. - - -## Contributing to GLFW - -See the [contribution -guide](https://github.com/glfw/glfw/blob/master/docs/CONTRIBUTING.md) for -more information. - - ## System requirements -GLFW supports Windows 7 and later and macOS 10.11 and later. Linux and other -Unix-like systems running the X Window System are supported even without -a desktop environment or modern extensions, although some features require -a running window or clipboard manager. The OSMesa backend requires Mesa 6.3. +GLFW supports Windows 7 and later and macOS 10.11 and later. On GNOME Wayland, +window decorations will be very basic unless the +[libdecor](https://gitlab.freedesktop.org/libdecor/libdecor) package is +installed. Linux and other Unix-like systems running X11 are supported even +without a desktop environment or modern extensions, although some features +require a clipboard manager or a modern window manager. See the [compatibility guide](https://www.glfw.org/docs/latest/compat.html) -in the documentation for more information. +for more detailed information. -## Dependencies +## Compiling GLFW -GLFW itself needs only CMake 3.16 or later and the headers and libraries for your -OS and window system. +GLFW supports compilation with Visual C++ (2013 and later), GCC and Clang. Both +Clang-CL and MinGW-w64 are supported. Other C99 compilers will likely also +work, but this is not regularly tested. + +There are [pre-compiled binaries](https://www.glfw.org/download.html) +available for Windows and macOS. + +GLFW itself needs only CMake and the headers and libraries for your operating +system and window system. No other SDKs are required. + +See the [compilation guide](https://www.glfw.org/docs/latest/compile.html) for +more information about compiling GLFW and the exact dependencies required for +each window system. The examples and test programs depend on a number of tiny libraries. These are -located in the `deps/` directory. +bundled in the `deps/` directory. The repository has no submodules. - [getopt\_port](https://github.com/kimgr/getopt_port/) for examples with command-line options @@ -107,8 +81,33 @@ located in the `deps/` directory. - [Nuklear](https://github.com/Immediate-Mode-UI/Nuklear) for test and example UI - [stb\_image\_write](https://github.com/nothings/stb) for writing images to disk -The documentation is generated with [Doxygen](https://doxygen.org/) if CMake can -find that tool. +The documentation is generated with [Doxygen](https://doxygen.org/) when the +library is built, provided CMake could find a sufficiently new version of it +during configuration. + + +## Using GLFW + +See the [HTML documentation](https://www.glfw.org/docs/latest/) for a tutorial, +guides and the API reference. + + +## Contributing to GLFW + +See the [contribution +guide](https://github.com/glfw/glfw/blob/master/docs/CONTRIBUTING.md) for +more information. + +The `master` branch is the stable integration branch and _should_ always compile +and run on all supported platforms. Details of a newly added feature, +including the public API, may change until it has been included in a release. + +The `latest` branch is equivalent to the [highest numbered](https://semver.org/) +release, although it may not always point to the same commit as the tag for that +release. + +The `ci` branch is used to trigger continuous integration jobs for code under +testing and should never be relied on for any purpose. ## Reporting bugs From 04a67c826718c7099c532bd90aa9d2ac97958d08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 28 Aug 2025 18:56:48 +0200 Subject: [PATCH 28/36] Fix X11 clipboard compatibility description --- docs/compat.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/compat.md b/docs/compat.md index 5072d5c11..a97192b3f 100644 --- a/docs/compat.md +++ b/docs/compat.md @@ -50,10 +50,11 @@ compositing window manager to un-redirect full screen GLFW windows. If the running window manager uses compositing but does not support this property then additional copying may be performed for each buffer swap of full screen windows. -GLFW uses the [clipboard manager protocol][ClipboardManager] to push a clipboard -string (i.e. selection) owned by a GLFW window about to be destroyed to the -clipboard manager. If there is no running clipboard manager, the clipboard -string will be unavailable once the window has been destroyed. +GLFW uses the [clipboard manager protocol][ClipboardManager] to keep the +clipboard string availble for the user after the libary has been terminated. If +there is no running clipboard manager and the clipboard contents has been set +with @ref glfwSetClipboardString, the clipboard will be emptied when the library +is terminated. [clipboardManager]: https://www.freedesktop.org/wiki/ClipboardManager/ From c9b129753aa3a002de90c8458e4c8121a2fe6d8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 21 Aug 2025 21:36:19 +0200 Subject: [PATCH 29/36] Update Doxygen version handling --- docs/CMakeLists.txt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index 50522173a..4cf863653 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -1,4 +1,8 @@ +# Because of bugs and limitations in its Markdown support, only fairly recent +# versions of Doxygen can produce acceptable output +set(MINIMUM_DOXYGEN_VERSION 1.9.8) + # NOTE: The order of this list determines the order of items in the Guides # (i.e. Pages) list in the generated documentation set(source_files @@ -32,10 +36,10 @@ foreach(file IN LISTS source_files) endforeach() set(DOXYGEN_SKIP_DOT TRUE) -find_package(Doxygen) +find_package(Doxygen ${MINIMUM_DOXYGEN_VERSION} QUIET) -if (NOT DOXYGEN_FOUND OR DOXYGEN_VERSION VERSION_LESS "1.9.8") - message(STATUS "Documentation generation requires Doxygen 1.9.8 or later") +if (NOT DOXYGEN_FOUND) + message(STATUS "Documentation generation requires Doxygen ${MINIMUM_DOXYGEN_VERSION} or later") else() configure_file(Doxyfile.in Doxyfile @ONLY) add_custom_command(OUTPUT "html/index.html" From 1fdd39cf3e5badfd61d051d686b21c1963bbb045 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 21 Aug 2025 21:36:59 +0200 Subject: [PATCH 30/36] Fix documentation target dependency Related to #2704 --- CONTRIBUTORS.md | 1 + docs/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index d8eb7aee0..22ef76d0a 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -23,6 +23,7 @@ video tutorials. - Denis Bernard - BiBi - Doug Binks + - bitb4ker - blanco - Waris Boonyasiriwat - Kyle Brenneman diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index 4cf863653..629c16441 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -50,7 +50,7 @@ else() COMMENT "Generating HTML documentation" VERBATIM) - add_custom_target(docs ALL SOURCES "html/index.html") + add_custom_target(docs ALL DEPENDS "html/index.html") set_target_properties(docs PROPERTIES FOLDER "GLFW3") if (GLFW_INSTALL) From f8582d26d0c88c67ddee5606dcf688107e875d52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 21 Aug 2025 23:51:45 +0200 Subject: [PATCH 31/36] Add Markdown files as sources to IDE docs target --- docs/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index 629c16441..ffa7768ea 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -50,7 +50,7 @@ else() COMMENT "Generating HTML documentation" VERBATIM) - add_custom_target(docs ALL DEPENDS "html/index.html") + add_custom_target(docs ALL SOURCES ${source_files} DEPENDS "html/index.html") set_target_properties(docs PROPERTIES FOLDER "GLFW3") if (GLFW_INSTALL) From bfcb98fb6cfcee008207f9252bd5c76a98e76e7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 12 Mar 2024 19:59:04 +0100 Subject: [PATCH 32/36] Replace some Doxygen aliases with Markdown --- docs/Doxyfile.in | 8 +-- docs/intro.md | 2 +- docs/monitor.md | 4 +- docs/vulkan.md | 6 +- docs/window.md | 10 +-- include/GLFW/glfw3.h | 162 +++++++++++++++++++++---------------------- 6 files changed, 93 insertions(+), 99 deletions(-) diff --git a/docs/Doxyfile.in b/docs/Doxyfile.in index 067619c7d..27c4b3f67 100644 --- a/docs/Doxyfile.in +++ b/docs/Doxyfile.in @@ -278,13 +278,7 @@ ALIASES = "thread_safety=@par Thread safety^^" \ "analysis=@par Analysis^^" \ "reentrancy=@par Reentrancy^^" \ "errors=@par Errors^^" \ - "callback_signature=@par Callback signature^^" \ - "glfw3=__GLFW 3:__" \ - "x11=__X11:__" \ - "wayland=__Wayland:__" \ - "win32=__Windows:__" \ - "macos=__macOS:__" \ - "linux=__Linux:__" + "callback_signature=@par Callback signature^^" # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources # only. Doxygen will then generate output that is more tailored for C. For diff --git a/docs/intro.md b/docs/intro.md index f2060c330..e09989e03 100644 --- a/docs/intro.md +++ b/docs/intro.md @@ -63,7 +63,7 @@ before the application exits. Modern systems are very good at freeing resources allocated by programs that exit, but GLFW sometimes has to change global system settings and these might not be restored without termination. -@macos When the library is initialized the main menu and dock icon are created. +__macOS:__ When the library is initialized the main menu and dock icon are created. These are not desirable for a command-line only program. The creation of the main menu and dock icon can be disabled with the @ref GLFW_COCOA_MENUBAR init hint. diff --git a/docs/monitor.md b/docs/monitor.md index df5fda9ae..8e01a8f25 100644 --- a/docs/monitor.md +++ b/docs/monitor.md @@ -255,7 +255,7 @@ hardware gamma correction, which today is typically an approximation of sRGB gamma. This means that setting a perfectly linear ramp, or gamma 1.0, will produce the default (usually sRGB-like) behavior. -@note @wayland An application cannot read or modify the monitor gamma ramp. The -@ref glfwGetGammaRamp, @ref glfwSetGammaRamp and @ref glfwSetGamma functions +@note __Wayland:__ An application cannot read or modify the monitor gamma ramp. +The @ref glfwGetGammaRamp, @ref glfwSetGammaRamp and @ref glfwSetGamma functions emit @ref GLFW_FEATURE_UNAVAILABLE. diff --git a/docs/vulkan.md b/docs/vulkan.md index cb67302fb..48fa79fd1 100644 --- a/docs/vulkan.md +++ b/docs/vulkan.md @@ -35,7 +35,7 @@ By default, GLFW will load the Vulkan loader dynamically at runtime via its stan `vulkan-1.dll` on Windows, `libvulkan.so.1` on Linux and other Unix-like systems and `libvulkan.1.dylib` on macOS. -@macos GLFW will also look up and search the `Frameworks` subdirectory of your +__macOS:__ GLFW will also look up and search the `Frameworks` subdirectory of your application bundle. If your code is using a Vulkan loader with a different name or in a non-standard location @@ -47,7 +47,7 @@ entry point retrieval. This prevents GLFW from dynamically loading the Vulkan l glfwInitVulkanLoader(vkGetInstanceProcAddr); ``` -@macos To make your application be redistributable you will need to set up the application +__macOS:__ To make your application be redistributable you will need to set up the application bundle according to the LunarG SDK documentation. This is explained in more detail in the [SDK documentation for macOS](https://vulkan.lunarg.com/doc/sdk/latest/mac/getting_started.html). @@ -186,7 +186,7 @@ check whether any extensions you wish to enable are already in the returned array, as it is an error to specify an extension more than once in the `VkInstanceCreateInfo` struct. -@macos MoltenVK is (as of July 2022) not yet a fully conformant implementation +__macOS:__ MoltenVK is (as of July 2022) not yet a fully conformant implementation of Vulkan. As of Vulkan SDK 1.3.216.0, this means you must also enable the `VK_KHR_portability_enumeration` instance extension and set the `VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR` bit in the instance creation diff --git a/docs/window.md b/docs/window.md index dd6d8a2aa..2140f0975 100644 --- a/docs/window.md +++ b/docs/window.md @@ -363,10 +363,10 @@ which API was used to create the current context may fail if you change this hint. This can be resolved by having it load functions via @ref glfwGetProcAddress. -@note @wayland The EGL API _is_ the native context creation API, so this hint +@note __Wayland:__ The EGL API _is_ the native context creation API, so this hint will have no effect. -@note @x11 On some Linux systems, creating contexts via both the native and EGL +@note __X11:__ On some Linux systems, creating contexts via both the native and EGL APIs in a single process will cause the application to segfault. Stick to one API or the other on Linux for now. @@ -400,7 +400,7 @@ requested. Additionally, OpenGL ES 1.x cannot be returned if 2.0 or later was requested, and vice versa. This is because OpenGL ES 3.x is backward compatible with 2.0, but OpenGL ES 2.0 is not backward compatible with 1.x. -@note @macos The OS only supports core profile contexts for OpenGL versions 3.2 +@note __macOS:__ The OS only supports core profile contexts for OpenGL versions 3.2 and later. Before creating an OpenGL context of version 3.2 or later you must set the [GLFW_OPENGL_PROFILE](@ref GLFW_OPENGL_PROFILE_hint) hint accordingly. OpenGL 3.0 and 3.1 contexts are not supported at all on macOS. @@ -893,7 +893,7 @@ int xpos, ypos; glfwGetWindowPos(window, &xpos, &ypos); ``` -@note @wayland An applications cannot know the positions of its windows or +@note __Wayland:__ An applications cannot know the positions of its windows or whether one has been moved. The @ref GLFW_POSITION_X and @ref GLFW_POSITION_Y window hints are ignored. The @ref glfwGetWindowPos and @ref glfwSetWindowPos functions emit @ref GLFW_FEATURE_UNAVAILABLE. The window position callback will @@ -1044,7 +1044,7 @@ You can also get the current iconification state with @ref glfwGetWindowAttrib. int iconified = glfwGetWindowAttrib(window, GLFW_ICONIFIED); ``` -@note @wayland An application cannot know if any of its windows have been +@note __Wayland:__ An application cannot know if any of its windows have been iconified or restore one from iconification. The @ref glfwRestoreWindow function can only restore windows from maximization and the iconify callback will not be called. The [GLFW_ICONIFIED](@ref GLFW_ICONIFIED_attrib) attribute diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index b0ce7f660..3ce1c0191 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -1228,13 +1228,13 @@ extern "C" { * The top-left to bottom-right diagonal resize/move shape. This is usually * a diagonal double-headed arrow. * - * @note @macos This shape is provided by a private system API and may fail + * @note __macOS:__ This shape is provided by a private system API and may fail * with @ref GLFW_CURSOR_UNAVAILABLE in the future. * - * @note @wayland This shape is provided by a newer standard not supported by + * @note __Wayland:__ This shape is provided by a newer standard not supported by * all cursor themes. * - * @note @x11 This shape is provided by a newer standard not supported by all + * @note __X11:__ This shape is provided by a newer standard not supported by all * cursor themes. */ #define GLFW_RESIZE_NWSE_CURSOR 0x00036007 @@ -1243,13 +1243,13 @@ extern "C" { * The top-right to bottom-left diagonal resize/move shape. This is usually * a diagonal double-headed arrow. * - * @note @macos This shape is provided by a private system API and may fail + * @note __macOS:__ This shape is provided by a private system API and may fail * with @ref GLFW_CURSOR_UNAVAILABLE in the future. * - * @note @wayland This shape is provided by a newer standard not supported by + * @note __Wayland:__ This shape is provided by a newer standard not supported by * all cursor themes. * - * @note @x11 This shape is provided by a newer standard not supported by all + * @note __X11:__ This shape is provided by a newer standard not supported by all * cursor themes. */ #define GLFW_RESIZE_NESW_CURSOR 0x00036008 @@ -1264,10 +1264,10 @@ extern "C" { * The operation-not-allowed shape. This is usually a circle with a diagonal * line through it. * - * @note @wayland This shape is provided by a newer standard not supported by + * @note __Wayland:__ This shape is provided by a newer standard not supported by * all cursor themes. * - * @note @x11 This shape is provided by a newer standard not supported by all + * @note __X11:__ This shape is provided by a newer standard not supported by all * cursor themes. */ #define GLFW_NOT_ALLOWED_CURSOR 0x0003600A @@ -1629,7 +1629,7 @@ typedef void (* GLFWwindowposfun)(GLFWwindow* window, int xpos, int ypos); * @sa @ref glfwSetWindowSizeCallback * * @since Added in version 1.0. - * @glfw3 Added window handle parameter. + * __GLFW 3:__ Added window handle parameter. * * @ingroup window */ @@ -1649,7 +1649,7 @@ typedef void (* GLFWwindowsizefun)(GLFWwindow* window, int width, int height); * @sa @ref glfwSetWindowCloseCallback * * @since Added in version 2.5. - * @glfw3 Added window handle parameter. + * __GLFW 3:__ Added window handle parameter. * * @ingroup window */ @@ -1669,7 +1669,7 @@ typedef void (* GLFWwindowclosefun)(GLFWwindow* window); * @sa @ref glfwSetWindowRefreshCallback * * @since Added in version 2.5. - * @glfw3 Added window handle parameter. + * __GLFW 3:__ Added window handle parameter. * * @ingroup window */ @@ -1800,7 +1800,7 @@ typedef void (* GLFWwindowcontentscalefun)(GLFWwindow* window, float xscale, flo * @sa @ref glfwSetMouseButtonCallback * * @since Added in version 1.0. - * @glfw3 Added window handle and modifier mask parameters. + * __GLFW 3:__ Added window handle and modifier mask parameters. * * @ingroup input */ @@ -1891,7 +1891,7 @@ typedef void (* GLFWscrollfun)(GLFWwindow* window, double xoffset, double yoffse * @sa @ref glfwSetKeyCallback * * @since Added in version 1.0. - * @glfw3 Added window handle, scancode and modifier mask parameters. + * __GLFW 3:__ Added window handle, scancode and modifier mask parameters. * * @ingroup input */ @@ -1912,7 +1912,7 @@ typedef void (* GLFWkeyfun)(GLFWwindow* window, int key, int scancode, int actio * @sa @ref glfwSetCharCallback * * @since Added in version 2.4. - * @glfw3 Added window handle parameter. + * __GLFW 3:__ Added window handle parameter. * * @ingroup input */ @@ -2020,7 +2020,7 @@ typedef void (* GLFWjoystickfun)(int jid, int event); * @sa @ref glfwGetVideoModes * * @since Added in version 1.0. - * @glfw3 Added refresh rate member. + * __GLFW 3:__ Added refresh rate member. * * @ingroup monitor */ @@ -2083,7 +2083,7 @@ typedef struct GLFWgammaramp * @sa @ref window_icon * * @since Added in version 2.1. - * @glfw3 Removed format and bytes-per-pixel members. + * __GLFW 3:__ Removed format and bytes-per-pixel members. * * @ingroup window */ @@ -2183,12 +2183,12 @@ typedef struct GLFWallocator * @errors Possible errors include @ref GLFW_PLATFORM_UNAVAILABLE and @ref * GLFW_PLATFORM_ERROR. * - * @remark @macos This function will change the current directory of the + * @remark __macOS:__ This function will change the current directory of the * application to the `Contents/Resources` subdirectory of the application's * bundle, if present. This can be disabled with the @ref * GLFW_COCOA_CHDIR_RESOURCES init hint. * - * @remark @macos This function will create the main menu and dock icon for the + * @remark __macOS:__ This function will create the main menu and dock icon for the * application. If GLFW finds a `MainMenu.nib` it is loaded and assumed to * contain a menu bar. Otherwise a minimal menu bar is created manually with * common commands like Hide, Quit and About. The About entry opens a minimal @@ -2203,7 +2203,7 @@ typedef struct GLFWallocator * to something other than `wayland` or `x11`, the regular detection mechanism * will be used instead. * - * @remark @x11 This function will set the `LC_CTYPE` category of the + * @remark __X11:__ This function will set the `LC_CTYPE` category of the * application locale according to the current environment if that category is * still "C". This is because the "C" locale breaks Unicode text input. * @@ -2679,7 +2679,7 @@ GLFWAPI void glfwGetMonitorWorkarea(GLFWmonitor* monitor, int* xpos, int* ypos, * * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. * - * @remark @win32 On Windows 8 and earlier the physical size is calculated from + * @remark __Win32:__ On Windows 8 and earlier the physical size is calculated from * the current resolution and system DPI instead of querying the monitor EDID data. * * @thread_safety This function must only be called from the main thread. @@ -2713,7 +2713,7 @@ GLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor* monitor, int* widthMM, int* * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref * GLFW_PLATFORM_ERROR. * - * @remark @wayland Fractional scaling information is not yet available for + * @remark __Wayland:__ Fractional scaling information is not yet available for * monitors, so this function only returns integer content scales. * * @thread_safety This function must only be called from the main thread. @@ -2861,7 +2861,7 @@ GLFWAPI GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun callback); * @sa @ref glfwGetVideoMode * * @since Added in version 1.0. - * @glfw3 Changed to return an array of modes for a specific monitor. + * __GLFW 3:__ Changed to return an array of modes for a specific monitor. * * @ingroup monitor */ @@ -2915,7 +2915,7 @@ GLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* monitor); * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref GLFW_INVALID_VALUE, * @ref GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks). * - * @remark @wayland Monitor gamma is a privileged protocol, so this function + * @remark __Wayland:__ Monitor gamma is a privileged protocol, so this function * cannot be implemented and emits @ref GLFW_FEATURE_UNAVAILABLE. * * @thread_safety This function must only be called from the main thread. @@ -2939,7 +2939,7 @@ GLFWAPI void glfwSetGamma(GLFWmonitor* monitor, float gamma); * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref GLFW_PLATFORM_ERROR * and @ref GLFW_FEATURE_UNAVAILABLE (see remarks). * - * @remark @wayland Monitor gamma is a privileged protocol, so this function + * @remark __Wayland:__ Monitor gamma is a privileged protocol, so this function * cannot be implemented and emits @ref GLFW_FEATURE_UNAVAILABLE while * returning `NULL`. * @@ -2981,9 +2981,9 @@ GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* monitor); * @remark The size of the specified gamma ramp should match the size of the * current ramp for that monitor. * - * @remark @win32 The gamma ramp size must be 256. + * @remark __Win32:__ The gamma ramp size must be 256. * - * @remark @wayland Monitor gamma is a privileged protocol, so this function + * @remark __Wayland:__ Monitor gamma is a privileged protocol, so this function * cannot be implemented and emits @ref GLFW_FEATURE_UNAVAILABLE. * * @pointer_lifetime The specified gamma ramp is copied before this function @@ -3159,32 +3159,32 @@ GLFWAPI void glfwWindowHintString(int hint, const char* value); * GLFW_VERSION_UNAVAILABLE, @ref GLFW_FORMAT_UNAVAILABLE, @ref * GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_ERROR. * - * @remark @win32 Window creation will fail if the Microsoft GDI software + * @remark __Win32:__ Window creation will fail if the Microsoft GDI software * OpenGL implementation is the only one available. * - * @remark @win32 If the executable has an icon resource named `GLFW_ICON,` it + * @remark __Win32:__ If the executable has an icon resource named `GLFW_ICON,` it * will be set as the initial icon for the window. If no such icon is present, * the `IDI_APPLICATION` icon will be used instead. To set a different icon, * see @ref glfwSetWindowIcon. * - * @remark @win32 The context to share resources with must not be current on + * @remark __Win32:__ The context to share resources with must not be current on * any other thread. * - * @remark @macos The OS only supports core profile contexts for OpenGL + * @remark __macOS:__ The OS only supports core profile contexts for OpenGL * versions 3.2 and later. Before creating an OpenGL context of version 3.2 or * later you must set the [GLFW_OPENGL_PROFILE](@ref GLFW_OPENGL_PROFILE_hint) * hint accordingly. OpenGL 3.0 and 3.1 contexts are not supported at all * on macOS. * - * @remark @macos The GLFW window has no icon, as it is not a document + * @remark __macOS:__ The GLFW window has no icon, as it is not a document * window, but the dock icon will be the same as the application bundle's icon. * For more information on bundles, see the * [Bundle Programming Guide][bundle-guide] in the Mac Developer Library. * * [bundle-guide]: https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/ * - * @remark @macos The window frame will not be rendered at full resolution on - * Retina displays unless the + * @remark __macOS:__ The window frame will not be rendered at full resolution + * on Retina displays unless the * [GLFW_SCALE_FRAMEBUFFER](@ref GLFW_SCALE_FRAMEBUFFER_hint) * hint is `GLFW_TRUE` and the `NSHighResolutionCapable` key is enabled in the * application bundle's `Info.plist`. For more information, see @@ -3195,11 +3195,11 @@ GLFWAPI void glfwWindowHintString(int hint, const char* value); * * [hidpi-guide]: https://developer.apple.com/library/mac/documentation/GraphicsAnimation/Conceptual/HighResolutionOSX/Explained/Explained.html * - * @remark @macos When activating frame autosaving with + * @remark __macOS:__ When activating frame autosaving with * [GLFW_COCOA_FRAME_NAME](@ref GLFW_COCOA_FRAME_NAME_hint), the specified * window size and position may be overridden by previously saved values. * - * @remark @wayland GLFW uses [libdecor][] where available to create its window + * @remark __Wayland:__ GLFW uses [libdecor][] where available to create its window * decorations. This in turn uses server-side XDG decorations where available * and provides high quality client-side decorations on compositors like GNOME. * If both XDG decorations and libdecor are unavailable, GLFW falls back to @@ -3208,15 +3208,15 @@ GLFWAPI void glfwWindowHintString(int hint, const char* value); * * [libdecor]: https://gitlab.freedesktop.org/libdecor/libdecor * - * @remark @x11 Some window managers will not respect the placement of + * @remark __X11:__ Some window managers will not respect the placement of * initially hidden windows. * - * @remark @x11 Due to the asynchronous nature of X11, it may take a moment for + * @remark __X11:__ Due to the asynchronous nature of X11, it may take a moment for * a window to reach its requested state. This means you may not be able to * query the final size, position or other attributes directly after window * creation. * - * @remark @x11 The class part of the `WM_CLASS` window property will by + * @remark __X11:__ The class part of the `WM_CLASS` window property will by * default be set to the window title passed to this function. The instance * part will use the contents of the `RESOURCE_NAME` environment variable, if * present and not empty, or fall back to the window title. Set the @@ -3349,7 +3349,7 @@ GLFWAPI const char* glfwGetWindowTitle(GLFWwindow* window); * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref * GLFW_PLATFORM_ERROR. * - * @remark @macos The window title will not be updated until the next time you + * @remark __macOS:__ The window title will not be updated until the next time you * process events. * * @thread_safety This function must only be called from the main thread. @@ -3358,7 +3358,7 @@ GLFWAPI const char* glfwGetWindowTitle(GLFWwindow* window); * @sa @ref glfwGetWindowTitle * * @since Added in version 1.0. - * @glfw3 Added window handle parameter. + * __GLFW 3:__ Added window handle parameter. * * @ingroup window */ @@ -3392,14 +3392,14 @@ GLFWAPI void glfwSetWindowTitle(GLFWwindow* window, const char* title); * @pointer_lifetime The specified image data is copied before this function * returns. * - * @remark @macos Regular windows do not have icons on macOS. This function + * @remark __macOS:__ Regular windows do not have icons on macOS. This function * will emit @ref GLFW_FEATURE_UNAVAILABLE. The dock icon will be the same as * the application bundle's icon. For more information on bundles, see the * [Bundle Programming Guide][bundle-guide] in the Mac Developer Library. * * [bundle-guide]: https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/ * - * @remark @wayland There is no existing protocol to change an icon, the + * @remark __Wayland:__ There is no existing protocol to change an icon, the * window will thus inherit the one defined in the application's desktop file. * This function will emit @ref GLFW_FEATURE_UNAVAILABLE. * @@ -3430,7 +3430,7 @@ GLFWAPI void glfwSetWindowIcon(GLFWwindow* window, int count, const GLFWimage* i * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref * GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks). * - * @remark @wayland Window positions are not currently part of any common + * @remark __Wayland:__ Window positions are not currently part of any common * Wayland protocol, so this function cannot be implemented and will emit @ref * GLFW_FEATURE_UNAVAILABLE. * @@ -3464,7 +3464,7 @@ GLFWAPI void glfwGetWindowPos(GLFWwindow* window, int* xpos, int* ypos); * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref * GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks). * - * @remark @wayland Window positions are not currently part of any common + * @remark __Wayland:__ Window positions are not currently part of any common * Wayland protocol, so this function cannot be implemented and will emit @ref * GLFW_FEATURE_UNAVAILABLE. * @@ -3474,7 +3474,7 @@ GLFWAPI void glfwGetWindowPos(GLFWwindow* window, int* xpos, int* ypos); * @sa @ref glfwGetWindowPos * * @since Added in version 1.0. - * @glfw3 Added window handle parameter. + * __GLFW 3:__ Added window handle parameter. * * @ingroup window */ @@ -3504,7 +3504,7 @@ GLFWAPI void glfwSetWindowPos(GLFWwindow* window, int xpos, int ypos); * @sa @ref glfwSetWindowSize * * @since Added in version 1.0. - * @glfw3 Added window handle parameter. + * __GLFW 3:__ Added window handle parameter. * * @ingroup window */ @@ -3539,7 +3539,7 @@ GLFWAPI void glfwGetWindowSize(GLFWwindow* window, int* width, int* height); * @remark If you set size limits and an aspect ratio that conflict, the * results are undefined. * - * @remark @wayland The size limits will not be applied until the window is + * @remark __Wayland:__ The size limits will not be applied until the window is * actually resized, either by the user or by the compositor. * * @thread_safety This function must only be called from the main thread. @@ -3582,7 +3582,7 @@ GLFWAPI void glfwSetWindowSizeLimits(GLFWwindow* window, int minwidth, int minhe * @remark If you set size limits and an aspect ratio that conflict, the * results are undefined. * - * @remark @wayland The aspect ratio will not be applied until the window is + * @remark __Wayland:__ The aspect ratio will not be applied until the window is * actually resized, either by the user or by the compositor. * * @thread_safety This function must only be called from the main thread. @@ -3628,7 +3628,7 @@ GLFWAPI void glfwSetWindowAspectRatio(GLFWwindow* window, int numer, int denom); * @sa @ref glfwSetWindowMonitor * * @since Added in version 1.0. - * @glfw3 Added window handle parameter. + * __GLFW 3:__ Added window handle parameter. * * @ingroup window */ @@ -3778,7 +3778,7 @@ GLFWAPI float glfwGetWindowOpacity(GLFWwindow* window); * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref * GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks). * - * @remark @wayland There is no way to set an opacity factor for a window. + * @remark __Wayland:__ There is no way to set an opacity factor for a window. * This function will emit @ref GLFW_FEATURE_UNAVAILABLE. * * @thread_safety This function must only be called from the main thread. @@ -3814,7 +3814,7 @@ GLFWAPI void glfwSetWindowOpacity(GLFWwindow* window, float opacity); * @sa @ref glfwMaximizeWindow * * @since Added in version 2.1. - * @glfw3 Added window handle parameter. + * __GLFW 3:__ Added window handle parameter. * * @ingroup window */ @@ -3834,9 +3834,9 @@ GLFWAPI void glfwIconifyWindow(GLFWwindow* window); * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref * GLFW_PLATFORM_ERROR. * - * @remark @wayland Restoring a window from maximization is not currently part - * of any common Wayland protocol, so this function can only restore windows - * from maximization. + * @remark __Wayland:__ Restoring a window from maximization is not currently + * part of any common Wayland protocol, so this function can only restore + * windows from maximization. * * @thread_safety This function must only be called from the main thread. * @@ -3845,7 +3845,7 @@ GLFWAPI void glfwIconifyWindow(GLFWwindow* window); * @sa @ref glfwMaximizeWindow * * @since Added in version 2.1. - * @glfw3 Added window handle parameter. + * __GLFW 3:__ Added window handle parameter. * * @ingroup window */ @@ -3892,7 +3892,7 @@ GLFWAPI void glfwMaximizeWindow(GLFWwindow* window); * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref * GLFW_PLATFORM_ERROR. * - * @remark @wayland Because Wayland wants every frame of the desktop to be + * @remark __Wayland:__ Because Wayland wants every frame of the desktop to be * complete, this function does not immediately make the window visible. * Instead it will become visible the next time the window framebuffer is * updated after this call. @@ -3955,7 +3955,7 @@ GLFWAPI void glfwHideWindow(GLFWwindow* window); * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref * GLFW_PLATFORM_ERROR. * - * @remark @wayland The compositor will likely ignore focus requests unless + * @remark __Wayland:__ The compositor will likely ignore focus requests unless * another window created by the same application already has input focus. * * @thread_safety This function must only be called from the main thread. @@ -3983,7 +3983,7 @@ GLFWAPI void glfwFocusWindow(GLFWwindow* window); * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref * GLFW_PLATFORM_ERROR. * - * @remark @macos Attention is requested to the application as a whole, not the + * @remark __macOS:__ Attention is requested to the application as a whole, not the * specific window. * * @thread_safety This function must only be called from the main thread. @@ -4058,7 +4058,7 @@ GLFWAPI GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* window); * affected by any resizing or mode switching, although you may need to update * your viewport if the framebuffer size has changed. * - * @remark @wayland Window positions are not currently part of any common + * @remark __Wayland:__ Window positions are not currently part of any common * Wayland protocol. The window position arguments are ignored. * * @thread_safety This function must only be called from the main thread. @@ -4096,7 +4096,7 @@ GLFWAPI void glfwSetWindowMonitor(GLFWwindow* window, GLFWmonitor* monitor, int * errors. However, this function should not fail as long as it is passed * valid arguments and the library has been [initialized](@ref intro_init). * - * @remark @wayland Checking whether a window is iconified is not currently + * @remark __Wayland:__ Checking whether a window is iconified is not currently * part of any common Wayland protocol, so the @ref GLFW_ICONIFIED attribute * cannot be implemented and is always `GLFW_FALSE`. * @@ -4140,7 +4140,7 @@ GLFWAPI int glfwGetWindowAttrib(GLFWwindow* window, int attrib); * @remark Calling @ref glfwGetWindowAttrib will always return the latest * value, even if that value is ignored by the current mode of the window. * - * @remark @wayland The [GLFW_FLOATING](@ref GLFW_FLOATING_attrib) window attribute is + * @remark __Wayland:__ The [GLFW_FLOATING](@ref GLFW_FLOATING_attrib) window attribute is * not supported. Setting this will emit @ref GLFW_FEATURE_UNAVAILABLE. * * @thread_safety This function must only be called from the main thread. @@ -4220,7 +4220,7 @@ GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow* window); * * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. * - * @remark @wayland This callback will not be called. The Wayland protocol + * @remark __Wayland:__ This callback will not be called. The Wayland protocol * provides no way to be notified of when a window is moved. * * @thread_safety This function must only be called from the main thread. @@ -4259,7 +4259,7 @@ GLFWAPI GLFWwindowposfun glfwSetWindowPosCallback(GLFWwindow* window, GLFWwindow * @sa @ref window_size * * @since Added in version 1.0. - * @glfw3 Added window handle parameter and return value. + * __GLFW 3:__ Added window handle parameter and return value. * * @ingroup window */ @@ -4291,7 +4291,7 @@ GLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* window, GLFWwind * * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. * - * @remark @macos Selecting Quit from the application menu will trigger the + * @remark __macOS:__ Selecting Quit from the application menu will trigger the * close callback for all windows. * * @thread_safety This function must only be called from the main thread. @@ -4299,7 +4299,7 @@ GLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* window, GLFWwind * @sa @ref window_close * * @since Added in version 2.5. - * @glfw3 Added window handle parameter and return value. + * __GLFW 3:__ Added window handle parameter and return value. * * @ingroup window */ @@ -4335,7 +4335,7 @@ GLFWAPI GLFWwindowclosefun glfwSetWindowCloseCallback(GLFWwindow* window, GLFWwi * @sa @ref window_refresh * * @since Added in version 2.5. - * @glfw3 Added window handle parameter and return value. + * __GLFW 3:__ Added window handle parameter and return value. * * @ingroup window */ @@ -4396,7 +4396,7 @@ GLFWAPI GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* window, GLFWwi * * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. * - * @remark @wayland This callback will not be called. The Wayland protocol + * @remark __Wayland:__ This callback will not be called. The Wayland protocol * provides no way to be notified of when a window is iconified, and no way to * check whether a window is currently iconified. * @@ -4905,7 +4905,7 @@ GLFWAPI int glfwGetKeyScancode(int key); * @sa @ref input_key * * @since Added in version 1.0. - * @glfw3 Added window handle parameter. + * __GLFW 3:__ Added window handle parameter. * * @ingroup input */ @@ -4937,7 +4937,7 @@ GLFWAPI int glfwGetKey(GLFWwindow* window, int key); * @sa @ref input_mouse_button * * @since Added in version 1.0. - * @glfw3 Added window handle parameter. + * __GLFW 3:__ Added window handle parameter. * * @ingroup input */ @@ -5007,7 +5007,7 @@ GLFWAPI void glfwGetCursorPos(GLFWwindow* window, double* xpos, double* ypos); * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref * GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks). * - * @remark @wayland This function will only work when the cursor mode is + * @remark __Wayland:__ This function will only work when the cursor mode is * `GLFW_CURSOR_DISABLED`, otherwise it will emit @ref GLFW_FEATURE_UNAVAILABLE. * * @thread_safety This function must only be called from the main thread. @@ -5205,7 +5205,7 @@ GLFWAPI void glfwSetCursor(GLFWwindow* window, GLFWcursor* cursor); * @sa @ref input_key * * @since Added in version 1.0. - * @glfw3 Added window handle parameter and return value. + * __GLFW 3:__ Added window handle parameter and return value. * * @ingroup input */ @@ -5248,7 +5248,7 @@ GLFWAPI GLFWkeyfun glfwSetKeyCallback(GLFWwindow* window, GLFWkeyfun callback); * @sa @ref input_char * * @since Added in version 2.4. - * @glfw3 Added window handle parameter and return value. + * __GLFW 3:__ Added window handle parameter and return value. * * @ingroup input */ @@ -5332,7 +5332,7 @@ GLFWAPI GLFWcharmodsfun glfwSetCharModsCallback(GLFWwindow* window, GLFWcharmods * @sa @ref input_mouse_button * * @since Added in version 1.0. - * @glfw3 Added window handle parameter and return value. + * __GLFW 3:__ Added window handle parameter and return value. * * @ingroup input */ @@ -5562,7 +5562,7 @@ GLFWAPI const float* glfwGetJoystickAxes(int jid, int* count); * @sa @ref joystick_button * * @since Added in version 2.2. - * @glfw3 Changed to return a dynamic array. + * __GLFW 3:__ Changed to return a dynamic array. * * @ingroup input */ @@ -5926,7 +5926,7 @@ GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate* state); * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref * GLFW_PLATFORM_ERROR. * - * @remark @win32 The clipboard on Windows has a single global lock for reading and + * @remark __Win32:__ The clipboard on Windows has a single global lock for reading and * writing. GLFW tries to acquire it a few times, which is almost always enough. If it * cannot acquire the lock then this function emits @ref GLFW_PLATFORM_ERROR and returns. * It is safe to try this multiple times. @@ -5959,7 +5959,7 @@ GLFWAPI void glfwSetClipboardString(GLFWwindow* window, const char* string); * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref * GLFW_FORMAT_UNAVAILABLE and @ref GLFW_PLATFORM_ERROR. * - * @remark @win32 The clipboard on Windows has a single global lock for reading and + * @remark __Win32:__ The clipboard on Windows has a single global lock for reading and * writing. GLFW tries to acquire it a few times, which is almost always enough. If it * cannot acquire the lock then this function emits @ref GLFW_PLATFORM_ERROR and returns. * It is safe to try this multiple times. @@ -6176,7 +6176,7 @@ GLFWAPI GLFWwindow* glfwGetCurrentContext(void); * @sa @ref glfwSwapInterval * * @since Added in version 1.0. - * @glfw3 Added window handle parameter. + * __GLFW 3:__ Added window handle parameter. * * @ingroup window */ @@ -6443,7 +6443,7 @@ GLFWAPI GLFWvkproc glfwGetInstanceProcAddress(VkInstance instance, const char* p * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref * GLFW_API_UNAVAILABLE and @ref GLFW_PLATFORM_ERROR. * - * @remark @macos This function currently always returns `GLFW_TRUE`, as the + * @remark __macOS:__ This function currently always returns `GLFW_TRUE`, as the * `VK_MVK_macos_surface` and `VK_EXT_metal_surface` extensions do not provide * a `vkGetPhysicalDevice*PresentationSupport` type function. * @@ -6501,15 +6501,15 @@ GLFWAPI int glfwGetPhysicalDevicePresentationSupport(VkInstance instance, VkPhys * @ref glfwVulkanSupported and @ref glfwGetRequiredInstanceExtensions should * eliminate almost all occurrences of these errors. * - * @remark @macos GLFW prefers the `VK_EXT_metal_surface` extension, with the + * @remark __macOS:__ GLFW prefers the `VK_EXT_metal_surface` extension, with the * `VK_MVK_macos_surface` extension as a fallback. The name of the selected * extension, if any, is included in the array returned by @ref * glfwGetRequiredInstanceExtensions. * - * @remark @macos This function creates and sets a `CAMetalLayer` instance for + * @remark __macOS:__ This function creates and sets a `CAMetalLayer` instance for * the window content view, which is required for MoltenVK to function. * - * @remark @x11 By default GLFW prefers the `VK_KHR_xcb_surface` extension, + * @remark __X11:__ By default GLFW prefers the `VK_KHR_xcb_surface` extension, * with the `VK_KHR_xlib_surface` extension as a fallback. You can make * `VK_KHR_xlib_surface` the preferred extension by setting the * [GLFW_X11_XCB_VULKAN_SURFACE](@ref GLFW_X11_XCB_VULKAN_SURFACE_hint) init From 4c64184455f393b85ca55408ece3e8c596af7050 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 13 Mar 2024 00:19:11 +0100 Subject: [PATCH 33/36] Remove title member from window config The window title is already available in the window struct. --- src/cocoa_window.m | 2 +- src/internal.h | 1 - src/win32_window.c | 2 +- src/window.c | 1 - src/x11_window.c | 10 +++++----- 5 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/cocoa_window.m b/src/cocoa_window.m index e69b5fe0c..2bff22a6b 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -884,7 +884,7 @@ static GLFWbool createNativeWindow(_GLFWwindow* window, [window->ns.object setContentView:window->ns.view]; [window->ns.object makeFirstResponder:window->ns.view]; - [window->ns.object setTitle:@(wndconfig->title)]; + [window->ns.object setTitle:@(window->title)]; [window->ns.object setDelegate:window->ns.delegate]; [window->ns.object setAcceptsMouseMovedEvents:YES]; [window->ns.object setRestorable:NO]; diff --git a/src/internal.h b/src/internal.h index 4f097aa82..de703740f 100644 --- a/src/internal.h +++ b/src/internal.h @@ -402,7 +402,6 @@ struct _GLFWwndconfig int ypos; int width; int height; - const char* title; GLFWbool resizable; GLFWbool visible; GLFWbool decorated; diff --git a/src/win32_window.c b/src/win32_window.c index 26f9684b7..6427a673e 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -1377,7 +1377,7 @@ static int createNativeWindow(_GLFWwindow* window, frameHeight = rect.bottom - rect.top; } - wideTitle = _glfwCreateWideStringFromUTF8Win32(wndconfig->title); + wideTitle = _glfwCreateWideStringFromUTF8Win32(window->title); if (!wideTitle) return GLFW_FALSE; diff --git a/src/window.c b/src/window.c index e03121a46..3a3b66dfe 100644 --- a/src/window.c +++ b/src/window.c @@ -208,7 +208,6 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height, wndconfig.width = width; wndconfig.height = height; - wndconfig.title = title; ctxconfig.share = (_GLFWwindow*) share; if (!_glfwIsValidContextConfig(&ctxconfig)) diff --git a/src/x11_window.c b/src/x11_window.c index 322349f08..986bfb93b 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -754,13 +754,13 @@ static GLFWbool createNativeWindow(_GLFWwindow* window, const char* resourceName = getenv("RESOURCE_NAME"); if (resourceName && strlen(resourceName)) hint->res_name = (char*) resourceName; - else if (strlen(wndconfig->title)) - hint->res_name = (char*) wndconfig->title; + else if (strlen(window->title)) + hint->res_name = (char*) window->title; else hint->res_name = (char*) "glfw-application"; - if (strlen(wndconfig->title)) - hint->res_class = (char*) wndconfig->title; + if (strlen(window->title)) + hint->res_class = (char*) window->title; else hint->res_class = (char*) "GLFW-Application"; } @@ -780,7 +780,7 @@ static GLFWbool createNativeWindow(_GLFWwindow* window, if (_glfw.x11.im) _glfwCreateInputContextX11(window); - _glfwSetWindowTitleX11(window, wndconfig->title); + _glfwSetWindowTitleX11(window, window->title); _glfwGetWindowPosX11(window, &window->x11.xpos, &window->x11.ypos); _glfwGetWindowSizeX11(window, &window->x11.width, &window->x11.height); From 1a0b7827d45238e23df05f13dee47dda331bde05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 29 Aug 2025 17:08:36 +0200 Subject: [PATCH 34/36] EGL: Fix error return value for glfwGetEGLSurface This is a semantic fix only. The behavior is unchanged. --- src/egl_context.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/egl_context.c b/src/egl_context.c index 517c64cb2..272e7a4d2 100644 --- a/src/egl_context.c +++ b/src/egl_context.c @@ -939,7 +939,7 @@ GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* handle) window->context.source != GLFW_NATIVE_CONTEXT_API) { _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); - return EGL_NO_CONTEXT; + return EGL_NO_SURFACE; } } From 621e99d53ec3a49033f59e2656436d607812f5ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 29 Aug 2025 15:44:34 +0200 Subject: [PATCH 35/36] Add glfwGetEGLConfig native access function This adds the glfwGetEGLConfig function for querying the EGLConfig of the EGLSurface of a window. This is a re-implementation of the PR #2045 by knokko, slightly redesigned to handle EGLConfig being an opaque type in core EGL. Closes #2045 --- CONTRIBUTORS.md | 1 + README.md | 1 + docs/news.md | 10 ++++++++++ include/GLFW/glfw3native.h | 23 +++++++++++++++++++++++ src/egl_context.c | 22 ++++++++++++++++++++++ 5 files changed, 57 insertions(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 22ef76d0a..cfb4f42ca 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -124,6 +124,7 @@ video tutorials. - Josh Kilmer - Byunghoon Kim - Cameron King + - knokko - Peter Knut - Christoph Kubisch - Yuri Kunde Schlesner diff --git a/README.md b/README.md index 5148467a7..cfb748f9f 100644 --- a/README.md +++ b/README.md @@ -122,6 +122,7 @@ information on what to include when reporting a bug. - Added `GLFW_UNLIMITED_MOUSE_BUTTONS` input mode that allows mouse buttons beyond the limit of the mouse button tokens to be reported (#2423) + - Added `glfwGetEGLConfig` function to query the `EGLConfig` of a window (#2045) - Updated minimum CMake version to 3.16 (#2541) - Removed support for building with original MinGW (#2540) - [Win32] Removed support for Windows XP and Vista (#2505) diff --git a/docs/news.md b/docs/news.md index 640ae7a57..0e0cb029b 100644 --- a/docs/news.md +++ b/docs/news.md @@ -14,6 +14,13 @@ values over 8. For compatibility with older versions, the @ref GLFW_UNLIMITED_MOUSE_BUTTONS input mode needs to be set to make use of this. + +### EGLConfig native access function {#eglconfig} + +GLFW now provides the @ref glfwGetEGLConfig native access function for querying +the `EGLConfig` of a window that has a `EGLSurface`. + + ## Caveats {#caveats} ## Deprecations {#deprecations} @@ -39,6 +46,9 @@ actively maintained and available on many platforms. ### New functions {#new_functions} + - @ref glfwGetEGLConfig + + ### New types {#new_types} ### New constants {#new_constants} diff --git a/include/GLFW/glfw3native.h b/include/GLFW/glfw3native.h index 011b239c8..0071d12bf 100644 --- a/include/GLFW/glfw3native.h +++ b/include/GLFW/glfw3native.h @@ -586,6 +586,29 @@ GLFWAPI EGLContext glfwGetEGLContext(GLFWwindow* window); * @ingroup native */ GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* window); + +/*! @brief Retrieves the `EGLConfig` of the specified window's `EGLSurface`. + * + * @param[in] window The window whose `EGLSurface` to query. + * @param[out] config The `EGLConfig` of the window `EGLSurface`, if available. + * @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an + * [error](@ref error_handling) occurred. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_NO_WINDOW_CONTEXT. + * + * @remark `EGLConfig` is an opaque type. Unlike other GLFW functions, the @p + * config out parameter is not cleared on error, as core EGL does not define + * any invalid value. + * + * @thread_safety This function may be called from any thread. Access is not + * synchronized. + * + * @since Added in version 3.5. + * + * @ingroup native + */ +GLFWAPI int glfwGetEGLConfig(GLFWwindow* window, EGLConfig* config); #endif #if defined(GLFW_EXPOSE_NATIVE_OSMESA) diff --git a/src/egl_context.c b/src/egl_context.c index 272e7a4d2..0ef7f7295 100644 --- a/src/egl_context.c +++ b/src/egl_context.c @@ -946,3 +946,25 @@ GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* handle) return window->context.egl.surface; } +GLFWAPI int glfwGetEGLConfig(GLFWwindow* handle, EGLConfig* config) +{ + _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE); + + _GLFWwindow* window = (_GLFWwindow*) handle; + assert(window != NULL); + assert(config != NULL); + + if (window->context.source != GLFW_EGL_CONTEXT_API) + { + if (_glfw.platform.platformID != GLFW_PLATFORM_WAYLAND || + window->context.source != GLFW_NATIVE_CONTEXT_API) + { + _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); + return GLFW_FALSE; + } + } + + *config = window->context.egl.config; + return GLFW_TRUE; +} + From 8e15281d34a8b9ee9271ccce38177a3d812456f8 Mon Sep 17 00:00:00 2001 From: knokko Date: Sun, 27 Jun 2021 17:36:01 +0200 Subject: [PATCH 36/36] Add glfwGetGLXFBConfig native access function This adds the glfwGetGLXFBConfig function for querying the GLXFBConfig the GLXWindow of a window. This commit is a squashed and modified version of PR #1925 by knokko. The following changes were made by elmindreda: The function signature was changed to handle GLXFBConfig being an opaque value in core GLX. The function error checks were fixed and updated. The struct member name was changed. The struct member clearing on context destruction was removed. All documentation snippets were updated. Closes #1925 --- README.md | 1 + docs/news.md | 7 +++++++ include/GLFW/glfw3native.h | 23 +++++++++++++++++++++++ src/glx_context.c | 26 ++++++++++++++++++++++++++ src/x11_platform.h | 1 + 5 files changed, 58 insertions(+) diff --git a/README.md b/README.md index cfb748f9f..1c7ced36e 100644 --- a/README.md +++ b/README.md @@ -123,6 +123,7 @@ information on what to include when reporting a bug. - Added `GLFW_UNLIMITED_MOUSE_BUTTONS` input mode that allows mouse buttons beyond the limit of the mouse button tokens to be reported (#2423) - Added `glfwGetEGLConfig` function to query the `EGLConfig` of a window (#2045) + - Added `glfwGetGLXFBConfig` function to query the `GLXFBConfig` of a window (#1925) - Updated minimum CMake version to 3.16 (#2541) - Removed support for building with original MinGW (#2540) - [Win32] Removed support for Windows XP and Vista (#2505) diff --git a/docs/news.md b/docs/news.md index 0e0cb029b..f752ce427 100644 --- a/docs/news.md +++ b/docs/news.md @@ -21,6 +21,12 @@ GLFW now provides the @ref glfwGetEGLConfig native access function for querying the `EGLConfig` of a window that has a `EGLSurface`. +### GLXFBConfig native access function {#glxfbconfig} + +GLFW now provides the @ref glfwGetGLXFBConfig native access function for +querying the `GLXFBConfig` of a window that has a `GLXWindow`. + + ## Caveats {#caveats} ## Deprecations {#deprecations} @@ -47,6 +53,7 @@ actively maintained and available on many platforms. ### New functions {#new_functions} - @ref glfwGetEGLConfig + - @ref glfwGetGLXFBConfig ### New types {#new_types} diff --git a/include/GLFW/glfw3native.h b/include/GLFW/glfw3native.h index 0071d12bf..8db2cfa3b 100644 --- a/include/GLFW/glfw3native.h +++ b/include/GLFW/glfw3native.h @@ -478,6 +478,29 @@ GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* window); * @ingroup native */ GLFWAPI GLXWindow glfwGetGLXWindow(GLFWwindow* window); + +/*! @brief Retrieves the `GLXFBConfig` of the specified window's `GLXWindow`. + * + * @param[in] window The window whose `GLXWindow` to query. + * @param[out] config The `GLXFBConfig` of the window `GLXWindow`, if available. + * @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an + * [error](@ref error_handling) occurred. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref + * GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_UNAVAILABLE. + * + * @remark `GLXFBConfig` is an opaque type. Unlike other GLFW functions, the + * @p config out parameter is not cleared on error, as core GLX does not define + * any invalid value. + * + * @thread_safety This function may be called from any thread. Access is not + * synchronized. + * + * @since Added in version 3.5 + * + * @ingroup native + */ +GLFWAPI int glfwGetGLXFBConfig(GLFWwindow* window, GLXFBConfig* config); #endif #if defined(GLFW_EXPOSE_NATIVE_WAYLAND) diff --git a/src/glx_context.c b/src/glx_context.c index a2464a9d6..098c4bade 100644 --- a/src/glx_context.c +++ b/src/glx_context.c @@ -626,6 +626,8 @@ GLFWbool _glfwCreateContextGLX(_GLFWwindow* window, return GLFW_FALSE; } + window->context.glx.fbconfig = native; + window->context.makeCurrent = makeContextCurrentGLX; window->context.swapBuffers = swapBuffersGLX; window->context.swapInterval = swapIntervalGLX; @@ -719,5 +721,29 @@ GLFWAPI GLXWindow glfwGetGLXWindow(GLFWwindow* handle) return window->context.glx.window; } +GLFWAPI int glfwGetGLXFBConfig(GLFWwindow* handle, GLXFBConfig* config) +{ + _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE); + + if (_glfw.platform.platformID != GLFW_PLATFORM_X11) + { + _glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "GLX: Platform not initialized"); + return GLFW_FALSE; + } + + _GLFWwindow* window = (_GLFWwindow*) handle; + assert(window != NULL); + assert(config != NULL); + + if (window->context.source != GLFW_NATIVE_CONTEXT_API) + { + _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); + return GLFW_FALSE; + } + + *config = window->context.glx.fbconfig; + return GLFW_TRUE; +} + #endif // _GLFW_X11 diff --git a/src/x11_platform.h b/src/x11_platform.h index 30326c5be..1bfeaab49 100644 --- a/src/x11_platform.h +++ b/src/x11_platform.h @@ -470,6 +470,7 @@ typedef struct _GLFWcontextGLX { GLXContext handle; GLXWindow window; + GLXFBConfig fbconfig; } _GLFWcontextGLX; // GLX-specific global data