From d61f7225d128c08d938b45897cb7614ab8a36a8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 22 Jun 2021 00:25:42 +0200 Subject: [PATCH 01/16] Wayland: Fix missing constant on FreeBSD On FreeBSD O_CLOEXEC is only available when _POSIX_C_SOURCE >= 200809. O_CLOEXEC is in turn required by the epollshim header. Issue reported on IRC. (cherry picked from commit a89fcd20d8d03fef795211939bc19b87cb59bb87) --- src/wl_init.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/wl_init.c b/src/wl_init.c index 49e7cc52..3d48702b 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -26,6 +26,8 @@ // It is fine to use C99 in this file because it will not be built with VS //======================================================================== +#define _POSIX_C_SOURCE 200809L + #include "internal.h" #include From bd346b64d60f40ab4fb3ed33ae97a0f61f2ef2a8 Mon Sep 17 00:00:00 2001 From: "A. Tombs" Date: Wed, 23 Jun 2021 08:16:53 +0100 Subject: [PATCH 02/16] Consistent subsections in compile guide In the compile guide, the "Dependencies for Linux and OSMesa" section looks to be one level too high in the hierarchy. I've moved it to be in line with the similarly-named sub-sub-sections. Closes #1923. (cherry picked from commit 52d8347d34b51229cb6029a351ef19cfe60835ca) --- docs/compile.dox | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/compile.dox b/docs/compile.dox index aa6f0f08..4f47c59e 100644 --- a/docs/compile.dox +++ b/docs/compile.dox @@ -110,7 +110,7 @@ Once you have installed the necessary packages, move on to @ref compile_generate. -@subsection compile_deps_osmesa Dependencies for Linux and OSMesa +@subsubsection compile_deps_osmesa Dependencies for Linux and OSMesa To compile GLFW for OSMesa, you need to install the OSMesa library and header packages. For example, on Ubuntu and other distributions based on Debian From 8f0198e82efc1cec31b0474d723a77c333024bf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 25 Jun 2021 19:49:38 +0200 Subject: [PATCH 03/16] Remove errors for gamepad element mismatch Because there are controllers in the wild using the same hardware ID despite having different numbers of buttons and axes, an error message was triggered that was only expected for a corrupted mapping database. This removes the error for now, in preparation for better error handling for gamepad mappings overall. Fixes #1763. (cherry picked from commit 6876cf8d7e0e70dc3e4d7b0224d08312c9f78099) --- README.md | 2 ++ src/input.c | 12 ------------ 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 3c8dbccf..3ee222ab 100644 --- a/README.md +++ b/README.md @@ -119,6 +119,8 @@ information on what to include when reporting a bug. ## Changelog - Bugfix: Buffers were swapped at creation on single-buffered windows (#1873) + - Bugfix: Gamepad mapping updates could spam `GLFW_INVALID_VALUE` due to + incompatible controllers sharing hardware ID (#1763) - [Win32] Bugfix: `USE_MSVC_RUNTIME_LIBRARY_DLL` had no effect on CMake 3.15 or later (#1783,#1796) - [Win32] Bugfix: Compilation with LLVM for Windows failed (#1807,#1824,#1874) diff --git a/src/input.c b/src/input.c index 56277ca4..20b7c412 100644 --- a/src/input.c +++ b/src/input.c @@ -85,25 +85,13 @@ static _GLFWmapping* findValidMapping(const _GLFWjoystick* js) for (i = 0; i <= GLFW_GAMEPAD_BUTTON_LAST; i++) { if (!isValidElementForJoystick(mapping->buttons + i, js)) - { - _glfwInputError(GLFW_INVALID_VALUE, - "Invalid button in gamepad mapping %s (%s)", - mapping->guid, - mapping->name); return NULL; - } } for (i = 0; i <= GLFW_GAMEPAD_AXIS_LAST; i++) { if (!isValidElementForJoystick(mapping->axes + i, js)) - { - _glfwInputError(GLFW_INVALID_VALUE, - "Invalid axis in gamepad mapping %s (%s)", - mapping->guid, - mapping->name); return NULL; - } } } From 014ce9c74f263ac2e4110766803df29f1ab15782 Mon Sep 17 00:00:00 2001 From: "David V. McKay" Date: Wed, 7 Jul 2021 23:25:35 -0400 Subject: [PATCH 04/16] Clarify "as you would" for beginners. fixes #1088 (cherry picked from commit f010d8b77dda7fa62a16e6afaf7156222be468b5) --- docs/compile.dox | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/compile.dox b/docs/compile.dox index 4f47c59e..80c632c3 100644 --- a/docs/compile.dox +++ b/docs/compile.dox @@ -178,7 +178,12 @@ development environment, move on to @ref compile_compile. You should now have all required dependencies and the project files or makefiles necessary to compile GLFW. Go ahead and compile the actual GLFW library with -these files, as you would with any other project. +these files, as you would with any other project: + +@code{.sh} +cd +make install +@endcode Once the GLFW library is compiled, you are ready to build your applications, linking it to the GLFW library. See @ref build_guide for more information. From 3bf580ad1d244e1bc4eeee98ca28fa4ff724f32d Mon Sep 17 00:00:00 2001 From: "David V. McKay" Date: Wed, 7 Jul 2021 23:44:22 -0400 Subject: [PATCH 05/16] realizing "as you would" is platform dependent specified "for linux or unix" and added a bit about using Visual Studio on Windows. (cherry picked from commit 1a5e07fd4b0a5b6a70e99bbc52470962824d6979) --- docs/compile.dox | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/compile.dox b/docs/compile.dox index 80c632c3..1410137e 100644 --- a/docs/compile.dox +++ b/docs/compile.dox @@ -180,10 +180,12 @@ You should now have all required dependencies and the project files or makefiles necessary to compile GLFW. Go ahead and compile the actual GLFW library with these files, as you would with any other project: +e.g. on linux or unix, @code{.sh} cd make install @endcode +or on Windows, open the .sln file in Visual Studio and build via the file menu. Once the GLFW library is compiled, you are ready to build your applications, linking it to the GLFW library. See @ref build_guide for more information. From a18f4e50b0efc64e88cd5a1bc5484fe8ef7d0342 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 14 Jul 2021 17:56:05 +0200 Subject: [PATCH 06/16] Add credit Related to #1931. (cherry picked from commit b6f7ead3c50fd33efcd4b1dd2244d3a6f03aaddb) --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 3ee222ab..f1600a04 100644 --- a/README.md +++ b/README.md @@ -251,6 +251,7 @@ skills. - Adam Marcus - Célestin Marot - Kyle McDonald + - David V. McKay - David Medlock - Bryce Mehring - Jonathan Mercier From 9a5511b311aeef81079916e6ae1ecc3414c36173 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 8 Jul 2021 21:56:00 +0200 Subject: [PATCH 07/16] Improve library compilation guide somewhat Related to #1931. (cherry picked from commit 3b9597048259a198f8f27db7d5eb0eab7de0d3b3) --- docs/compile.dox | 327 +++++++++++++++++++++++++++-------------------- 1 file changed, 188 insertions(+), 139 deletions(-) diff --git a/docs/compile.dox b/docs/compile.dox index 1410137e..2fe50e50 100644 --- a/docs/compile.dox +++ b/docs/compile.dox @@ -10,165 +10,156 @@ build applications that use GLFW, see @ref build_guide. @section compile_cmake Using CMake +@note GLFW behaves like most other libraries that use CMake so this guide mostly +describes the basic configure/generate/compile sequence. If you are already +familiar with this from other projects, you may want to focus on the @ref +compile_deps and @ref compile_options sections for GLFW-specific information. + GLFW uses [CMake](https://cmake.org/) to generate project files or makefiles -for a particular development environment. If you are on a Unix-like system such -as Linux or FreeBSD or have a package system like Fink, MacPorts, Cygwin or -Homebrew, you can install its CMake package. If not, you can download -installers for Windows and macOS from the -[CMake website](https://cmake.org/). +for your chosen development environment. To compile GLFW, first generate these +files with CMake and then use them to compile the GLFW library. -@note CMake only generates project files or makefiles. It does not compile the -actual GLFW library. To compile GLFW, first generate these files for your -chosen development environment and then use them to compile the actual GLFW -library. +If you are on Windows and macOS you can +[download CMake](https://cmake.org/download/) from their site. + +If you are on a Unix-like system such as Linux, FreeBSD or Cygwin or have +a package system like Fink, MacPorts or Homebrew, you can install its CMake +package. + +CMake is a complex tool and this guide will only show a few of the possible ways +to set up and compile GLFW. The CMake project has their own much more detailed +[CMake user guide](https://cmake.org/cmake/help/latest/guide/user-interaction/) +that includes everything in this guide not specific to GLFW. It may be a useful +companion to this one. -@subsection compile_deps Dependencies +@subsection compile_deps Installing dependencies -Once you have installed CMake, make sure that all other dependencies are -available. On some platforms, GLFW needs a few additional packages to be -installed. See the section for your chosen platform and development environment -below. +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. -@subsubsection compile_deps_msvc Dependencies for Visual C++ on Windows +@subsubsection compile_deps_x11 Dependencies for X11 on Unix-like systems -The Windows SDK bundled with Visual C++ already contains all the necessary -headers, link libraries and tools except for CMake. Move on to @ref -compile_generate. +To compile GLFW for X11, you need to have the X11 development packages +installed. They are not needed to build or run programs that use GLFW. - -@subsubsection compile_deps_mingw Dependencies for MinGW or MinGW-w64 on Windows - -Both the MinGW and the MinGW-w64 packages already contain all the necessary -headers, link libraries and tools except for CMake. Move on to @ref -compile_generate. - - -@subsubsection compile_deps_mingw_cross Dependencies for MinGW or MinGW-w64 cross-compilation - -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. - -GLFW has CMake toolchain files in the `CMake/` directory that set up -cross-compilation of Windows binaries. To use these files you add an option -when running `cmake` to generate the project files or makefiles: +On Debian and derivates like Ubuntu the `xorg-dev` meta-package pulls in the +development packages for all of X11. @code{.sh} -cmake -DCMAKE_TOOLCHAIN_FILE= . +sudo apt install xorg-dev @endcode -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 Debian/Ubuntu and Cygwin MinGW-w64 packages -have `/usr/x86_64-w64-mingw32` for the 64-bit compilers, so the correct -invocation would be: +On FreeBSD the X11 headers are installed along the end-user X11 packages, so if +you have an X server running you should have the headers as well. If not, +install the `xorgproto` package. @code{.sh} -cmake -DCMAKE_TOOLCHAIN_FILE=CMake/x86_64-w64-mingw32.cmake . +pkg install xorgproto @endcode -For more details see the article -[CMake Cross Compiling](https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/CrossCompiling) on -the CMake wiki. +On Cygwin the `xorgproto` package in the Devel section of the GUI installer will +install the headers and other development related files for all of X11. -Once you have this set up, move on to @ref compile_generate. +Once you have the required depdendencies, move on to @ref compile_generate. -@subsubsection compile_deps_xcode Dependencies for Xcode on macOS +@subsubsection compile_deps_wayland Dependencies for Wayland on Unix-like systems -Xcode comes with all necessary tools except for CMake. The required headers -and libraries are included in the core macOS frameworks. Xcode can be -downloaded from the Mac App Store or from the ADC Member Center. +To compile GLFW for Wayland, you need to have the Wayland and xkbcommon +development packages installed. They are not needed to build or run programs +that use GLFW. -Once you have Xcode installed, move on to @ref compile_generate. +On Debian and derivates like Ubuntu you will need the `libwayland-dev`, +`libxkbcommon-dev`, `wayland-protocols` and `extra-cmake-modules` packages. +@code{.sh} +sudo apt install libwayland-dev libxkbcommon-dev wayland-protocols extra-cmake-modules +@endcode -@subsubsection compile_deps_x11 Dependencies for Linux and X11 +On FreeBSD you will need the `wayland`, `libxkbcommon`, `wayland-protocols` and +`kf5-extra-cmake-modules` packages. -To compile GLFW for X11, you need to have the X11 packages installed, as well as -the basic development tools like GCC and make. For example, on Ubuntu and other -distributions based on Debian GNU/Linux, you need to install the `xorg-dev` -package, which pulls in all X.org header packages. +@code{.sh} +pkg install wayland libxkbcommon wayland-protocols kf5-extra-cmake-modules +@endcode -Once you have installed the necessary packages, move on to @ref -compile_generate. - - -@subsubsection compile_deps_wayland Dependencies for Linux and Wayland - -To compile GLFW for Wayland, you need to have the Wayland packages installed, -as well as the basic development tools like GCC and make. For example, on -Ubuntu and other distributions based on Debian GNU/Linux, you need to install -the `libwayland-dev` package, which contains all Wayland headers and pulls in -wayland-scanner, as well as the `wayland-protocols` and `extra-cmake-modules` -packages. - -Once you have installed the necessary packages, move on to @ref -compile_generate. - - -@subsubsection compile_deps_osmesa Dependencies for Linux and OSMesa - -To compile GLFW for OSMesa, you need to install the OSMesa library and header -packages. For example, on Ubuntu and other distributions based on Debian -GNU/Linux, you need to install the `libosmesa6-dev` package. The OSMesa library -is required at runtime for context creation and is loaded on demand. - -Once you have installed the necessary packages, move on to @ref -compile_generate. +Once you have the required depdendencies, move on to @ref compile_generate. @subsection compile_generate Generating build files with CMake Once you have all necessary dependencies it is time to generate the project -files or makefiles for your development environment. CMake needs to know two -paths for this: the path to the _root_ directory of the GLFW source tree (i.e. -_not_ the `src` subdirectory) and the target path for the generated files and -compiled binaries. If these are the same, it is called an in-tree build, -otherwise it is called an out-of-tree build. +files or makefiles for your development environment. CMake needs two paths for +this: -One of several advantages of out-of-tree builds is that you can generate files -and compile for different development environments using a single source tree. + - the path to the root directory of the GLFW source tree (not its `src` + subdirectory) + - the path to the directory where the generated build files and compiled + binaries will be placed -@note This section is about generating the project files or makefiles necessary -to compile the GLFW library, not about compiling the actual library. +If these are the same, it is called an in-tree build, otherwise it is called an +out-of-tree build. + +Out-of-tree builds are recommended as they avoid cluttering up the source tree. +They also allow you to have several build directories for different +configurations all using the same source tree. + +A common pattern when building a single configuration is to have a build +directory named `build` in the root of the source tree. -@subsubsection compile_generate_cli Generating files with the CMake command-line tool +@subsubsection compile_generate_gui Generating files with the CMake GUI -To make an in-tree build, enter the _root_ directory of the GLFW source tree -(i.e. _not_ the `src` subdirectory) and run CMake. The current directory is -used as target path, while the path provided as an argument is used to find the -source tree. +Start the CMake GUI and set the paths to the source and build directories +described above. Then press _Configure_ and _Generate_. -@code{.sh} -cd -cmake . -@endcode +If you wish change any CMake variables in the list, press _Configure_ and then +_Generate_ to have the new values take effect. The variable list will be +populated after the first configure step. -To make an out-of-tree build, make a directory outside of the source tree, enter -it and run CMake with the (relative or absolute) path to the root of the source -tree as an argument. - -@code{.sh} -mkdir glfw-build -cd glfw-build -cmake -@endcode +By default GLFW will use X11 on Linux and other Unix-like systems other +than macOS. To use Wayland instead, set the `GLFW_USE_WAYLAND` option in the +GLFW section of the variable list, then apply the new value as described above. Once you have generated the project files or makefiles for your chosen development environment, move on to @ref compile_compile. -@subsubsection compile_generate_gui Generating files with the CMake GUI +@subsubsection compile_generate_cli Generating files with the CMake command-line tool -If you are using the GUI version, choose the root of the GLFW source tree as -source location and the same directory or another, empty directory as the -destination for binaries. Choose _Configure_, change any options you wish to, -_Configure_ again to let the changes take effect and then _Generate_. +To make a build directory, pass the source and build directories to the `cmake` +command. These can be relative or absolute paths. The build directory is +created if it doesn't already exist. + +@code{.sh} +cmake -S path/to/glfw -B path/to/build +@endcode + +It is common to name the build directory `build` and place it in the root of the +source tree when only planning to build a single configuration. + +@code{.sh} +cd path/to/glfw +cmake -S . -B build +@endcode + +Without other flags these will generate Visual Studio project files on Windows +and makefiles on other platforms. You can choose other targets using the `-G` +flag. + +@code{.sh} +cmake -S path/to/glfw -B path/to/build -G Xcode +@endcode + +By default GLFW will use X11 on Linux and other Unix-like systems other +than macOS. To use Wayland instead, set the `GLFW_USE_WAYLAND` CMake option. + +@code{.sh} +cmake -S path/to/glfw -B path/to/build -D GLFW_USE_WAYLAND=1 +@endcode Once you have generated the project files or makefiles for your chosen development environment, move on to @ref compile_compile. @@ -178,20 +169,39 @@ development environment, move on to @ref compile_compile. You should now have all required dependencies and the project files or makefiles necessary to compile GLFW. Go ahead and compile the actual GLFW library with -these files, as you would with any other project: +these files as you would with any other project. + +With Visual Studio open `GLFW.sln` and use the Build menu. With Xcode open +`GLFW.xcodeproj` and use the Project menu. + +With Linux, macOS and other forms of Unix, run `make`. -e.g. on linux or unix, @code{.sh} -cd -make install +cd path/to/build +make @endcode -or on Windows, open the .sln file in Visual Studio and build via the file menu. -Once the GLFW library is compiled, you are ready to build your applications, +With MinGW, it is `mingw32-make`. + +@code{.sh} +cd path/to/build +mingw32-make +@endcode + +Any CMake build directory can also be built with the `cmake` command and the +`--build` flag. + +@code{.sh} +cmake --build path/to/build +@endcode + +This will run the platform specific build tool the directory was generated for. + +Once the GLFW library is compiled you are ready to build your application, linking it to the GLFW library. See @ref build_guide for more information. -@subsection compile_options CMake options +@section compile_options CMake options The CMake files for GLFW provide a number of options, although not all are available on all supported platforms. Some of these are de facto standards @@ -207,15 +217,16 @@ Finally, if you don't want to use any GUI, you can set options from the `cmake` command-line with the `-D` flag. @code{.sh} -cmake -DBUILD_SHARED_LIBS=ON . +cmake -S path/to/glfw -B path/to/build -D BUILD_SHARED_LIBS=ON @endcode -@subsubsection compile_options_shared Shared CMake options +@subsection compile_options_shared Shared CMake options @anchor BUILD_SHARED_LIBS __BUILD_SHARED_LIBS__ determines whether GLFW is built as a static -library or as a DLL / shared library / dynamic library. +library or as a DLL / shared library / dynamic library. This is disabled by +default, producing a static GLFW library. @anchor GLFW_BUILD_EXAMPLES __GLFW_BUILD_EXAMPLES__ determines whether the GLFW examples are built @@ -227,37 +238,80 @@ built along with the library. @anchor GLFW_BUILD_DOCS __GLFW_BUILD_DOCS__ determines whether the GLFW documentation is built along -with the library. +with the library. This is enabled by default if +[Doxygen](https://www.doxygen.nl/) is found by CMake during configuration. @anchor GLFW_VULKAN_STATIC __GLFW_VULKAN_STATIC__ determines whether to use the Vulkan loader linked -directly with the application. +directly with the application. This is disabled by default. -@subsubsection compile_options_win32 Windows specific CMake options +@subsection compile_options_win32 Windows specific CMake options @anchor USE_MSVC_RUNTIME_LIBRARY_DLL __USE_MSVC_RUNTIME_LIBRARY_DLL__ determines whether to use the DLL version or the -static library version of the Visual C++ runtime library. If set to `ON`, the -DLL version of the Visual C++ library is used. +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. -@note On CMake 3.15 and later you can set the +On CMake 3.15 and later you can set the standard CMake [CMAKE_MSVC_RUNTIME_LIBRARY](https://cmake.org/cmake/help/latest/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html) -variable instead of this option. +variable instead of this GLFW-specific option. @anchor GLFW_USE_HYBRID_HPG __GLFW_USE_HYBRID_HPG__ determines whether to export the `NvOptimusEnablement` and `AmdPowerXpressRequestHighPerformance` symbols, which force the use of the high-performance GPU on Nvidia Optimus and AMD PowerXpress systems. These symbols need to be exported by the EXE to be detected by the driver, so the override -will not work if GLFW is built as a DLL. +will not work if GLFW is built as a DLL. This is disabled by default, letting +the operating system and driver decide. + + +@subsection compile_options_wayland Wayland specific CMake options + +@anchor GLFW_USE_WAYLAND +__GLFW_USE_WAYLAND__ determines whether to compile the library for Wayland. +This option is only available on Linux and other Unix-like systems other than +macOS. This is disabled by default. + + +@section compile_mingw_cross Cross-compilation with CMake and MinGW + +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. + +GLFW has CMake toolchain files in the `CMake` subdirectory that set up +cross-compilation of Windows binaries. To use these files you set the +`CMAKE_TOOLCHAIN_FILE` CMake variable with the `-D` flag add an option when +configuring and generating the build files. + +@code{.sh} +cmake -S path/to/glfw -B path/to/build -D CMAKE_TOOLCHAIN_FILE=path/to/file +@endcode + +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 +`/usr/x86_64-w64-mingw32` for the 64-bit compilers, so the correct invocation +would be: + +@code{.sh} +cmake -S path/to/glfw -B path/to/build -D CMAKE_TOOLCHAIN_FILE=CMake/x86_64-w64-mingw32.cmake +@endcode + +The path to the toolchain file is relative to the path to the GLFW source tree +passed to the `-S` flag, not to the current directory. + +For more details see the +[CMake toolchain guide](https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html). @section compile_manual Compiling GLFW manually If you wish to compile GLFW without its CMake build environment then you will have to do at least some of the platform detection yourself. GLFW needs -a configuration macro to be defined in order to know what window system it's +a configuration macro to be defined in order to know what window system it is being compiled for and also has optional, platform-specific ones for various features. @@ -289,11 +343,6 @@ of @b _GLFW_VULKAN_LIBRARY, @b _GLFW_EGL_LIBRARY, @b _GLFW_GLX_LIBRARY, @b _GLFW_OSMESA_LIBRARY, @b _GLFW_OPENGL_LIBRARY, @b _GLFW_GLESV1_LIBRARY and @b _GLFW_GLESV2_LIBRARY. Otherwise, GLFW will use the built-in default names. -For the EGL context creation API, the following options are available: - - - @b _GLFW_USE_EGLPLATFORM_H to use an existing `EGL/eglplatform.h` header file - for native handle types (fallback) - @note None of the @ref build_macros may be defined during the compilation of GLFW. If you define any of these in your build files, make sure they are not applied to the GLFW sources. From a7202e23413f457c41bc02301eb088a0bad75880 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 5 Jul 2021 20:26:38 +0200 Subject: [PATCH 08/16] Cocoa: Remove calls to -update on nil These calls have no effect unless the context was created with NSGL. (cherry picked from commit 836e709503f600436f582318a06efb8a8b33f2ad) --- src/cocoa_window.m | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 9fa72a6b..32a55512 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -243,7 +243,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 }; - (void)windowDidResize:(NSNotification *)notification { - if (window->context.client != GLFW_NO_API) + if (window->context.source == GLFW_NATIVE_CONTEXT_API) [window->context.nsgl.object update]; if (_glfw.ns.disabledCursorWindow == window) @@ -278,7 +278,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 }; - (void)windowDidMove:(NSNotification *)notification { - if (window->context.client != GLFW_NO_API) + if (window->context.source == GLFW_NATIVE_CONTEXT_API) [window->context.nsgl.object update]; if (_glfw.ns.disabledCursorWindow == window) @@ -397,7 +397,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 }; - (void)updateLayer { - if (window->context.client != GLFW_NO_API) + if (window->context.source == GLFW_NATIVE_CONTEXT_API) [window->context.nsgl.object update]; _glfwInputWindowDamage(window); From 545b6c79703127e1a7490c7077592f8f65fd2b36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 16 Jul 2021 20:04:56 +0200 Subject: [PATCH 09/16] Cocoa: Fix MoltenVK layer scale out of sync The contents scale of the hosted CAMetalLayer created for MoltenVK was updated only after the GLFW content scale and framebuffer size events were emitted, causing the layer to get out of sync with the monitor the window was on. (cherry picked from commit 076bfd55be45e7ba5c887d4b32aa03d26881a1fb) --- README.md | 2 ++ src/cocoa_window.m | 25 ++++++++++++------------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index f1600a04..77897441 100644 --- a/README.md +++ b/README.md @@ -124,6 +124,8 @@ information on what to include when reporting a bug. - [Win32] Bugfix: `USE_MSVC_RUNTIME_LIBRARY_DLL` had no effect on CMake 3.15 or later (#1783,#1796) - [Win32] Bugfix: Compilation with LLVM for Windows failed (#1807,#1824,#1874) + - [Cocoa] Bugfix: The MoltenVK layer contents scale was updated only after + related events were emitted - [EGL] Bugfix: The `GLFW_DOUBLEBUFFER` context attribute was ignored (#1843) diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 32a55512..6f442134 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -520,6 +520,18 @@ static const NSRange kEmptyRange = { NSNotFound, 0 }; { const NSRect contentRect = [window->ns.view frame]; const NSRect fbRect = [window->ns.view convertRectToBacking:contentRect]; + const float xscale = fbRect.size.width / contentRect.size.width; + const float yscale = fbRect.size.height / contentRect.size.height; + + if (xscale != window->ns.xscale || yscale != window->ns.yscale) + { + if (window->ns.retina && window->ns.layer) + [window->ns.layer setContentsScale:[window->ns.object backingScaleFactor]]; + + window->ns.xscale = xscale; + window->ns.yscale = yscale; + _glfwInputWindowContentScale(window, xscale, yscale); + } if (fbRect.size.width != window->ns.fbWidth || fbRect.size.height != window->ns.fbHeight) @@ -528,19 +540,6 @@ static const NSRange kEmptyRange = { NSNotFound, 0 }; window->ns.fbHeight = fbRect.size.height; _glfwInputFramebufferSize(window, fbRect.size.width, fbRect.size.height); } - - const float xscale = fbRect.size.width / contentRect.size.width; - const float yscale = fbRect.size.height / contentRect.size.height; - - if (xscale != window->ns.xscale || yscale != window->ns.yscale) - { - window->ns.xscale = xscale; - window->ns.yscale = yscale; - _glfwInputWindowContentScale(window, xscale, yscale); - - if (window->ns.retina && window->ns.layer) - [window->ns.layer setContentsScale:[window->ns.object backingScaleFactor]]; - } } - (void)drawRect:(NSRect)rect From 1e98fc325dafc6dd464f5c1482e4ba99e5f3b553 Mon Sep 17 00:00:00 2001 From: Stephen Gowen Date: Tue, 19 Jan 2021 11:31:15 -0600 Subject: [PATCH 10/16] Cocoa: Fix macro redefinition warning This avoids generating a macro redefinition warning when the GL_SILENCE_DEPRECATION macro has been defined for the whole of a larger project. Closes #1840. (cherry picked from commit 1d88a2e3d6d501112a741626d91abd025bd75d16) --- src/cocoa_platform.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cocoa_platform.h b/src/cocoa_platform.h index 05c23b70..405abf9f 100644 --- a/src/cocoa_platform.h +++ b/src/cocoa_platform.h @@ -31,7 +31,9 @@ // NOTE: All of NSGL was deprecated in the 10.14 SDK // This disables the pointless warnings for every symbol we use +#ifndef GL_SILENCE_DEPRECATION #define GL_SILENCE_DEPRECATION +#endif #if defined(__OBJC__) #import From 65c36563f689d158fd009d22b0ccb6833aa77006 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 29 Jul 2021 21:27:02 +0200 Subject: [PATCH 11/16] Update changelog Related to #1840. (cherry picked from commit ab34cc51c6deef504efc44a6380060a649983ce0) --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 77897441..8a7841f7 100644 --- a/README.md +++ b/README.md @@ -126,6 +126,8 @@ information on what to include when reporting a bug. - [Win32] Bugfix: Compilation with LLVM for Windows failed (#1807,#1824,#1874) - [Cocoa] Bugfix: The MoltenVK layer contents scale was updated only after related events were emitted + - [NSGL] Bugfix: Defining `GL_SILENCE_DEPRECATION` externally caused + a duplicate definition warning (#1840) - [EGL] Bugfix: The `GLFW_DOUBLEBUFFER` context attribute was ignored (#1843) From 1b0eac9c5871b2e2e0945725008a20ec0bda3840 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 18 Jul 2021 14:45:12 +0200 Subject: [PATCH 12/16] Add Fedora package names to compilation guide (cherry picked from commit 9e1ee3f2634fdbcb9107c3c57be7eafaf5ff87cd) --- docs/compile.dox | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/docs/compile.dox b/docs/compile.dox index 2fe50e50..afd63fae 100644 --- a/docs/compile.dox +++ b/docs/compile.dox @@ -52,6 +52,14 @@ development packages for all of X11. sudo apt install xorg-dev @endcode +On Fedora and its derivatives the X11 extension packages `libXcursor-devel`, +`libXi-devel`, `libXinerama-devel` and `libXrandr-devel` required by GLFW pull +in all its other dependencies. + +@code{.sh} +sudo dnf install libXcursor-devel libXi-devel libXinerama-devel libXrandr-devel +@endcode + On FreeBSD the X11 headers are installed along the end-user X11 packages, so if you have an X server running you should have the headers as well. If not, install the `xorgproto` package. @@ -79,6 +87,13 @@ On Debian and derivates like Ubuntu you will need the `libwayland-dev`, sudo apt install libwayland-dev libxkbcommon-dev wayland-protocols extra-cmake-modules @endcode +On Fedora and its derivatives you will need the `wayland-devel`, +`libxkbcommon-devel`, `wayland-protocols-devel` and `extra-cmake-modules` packages. + +@code{.sh} +sudo dnf install wayland-devel libxkbcommon-devel wayland-protocols-devel extra-cmake-modules +@endcode + On FreeBSD you will need the `wayland`, `libxkbcommon`, `wayland-protocols` and `kf5-extra-cmake-modules` packages. From 44ad296813e1210b3719367fd8b911c13e83d828 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 18 Jul 2021 14:55:02 +0200 Subject: [PATCH 13/16] Expand list of distro derivatives slightly (cherry picked from commit 3dc7349c3518c4bb38fbf406707bccd6c510a333) --- docs/compile.dox | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/compile.dox b/docs/compile.dox index afd63fae..d618d024 100644 --- a/docs/compile.dox +++ b/docs/compile.dox @@ -45,16 +45,16 @@ Linux and FreeBSD you will need a few extra packages. To compile GLFW for X11, you need to have the X11 development packages installed. They are not needed to build or run programs that use GLFW. -On Debian and derivates like Ubuntu the `xorg-dev` meta-package pulls in the -development packages for all of X11. +On Debian and derivates like Ubuntu and Linux Mint the `xorg-dev` meta-package +pulls in the development packages for all of X11. @code{.sh} sudo apt install xorg-dev @endcode -On Fedora and its derivatives the X11 extension packages `libXcursor-devel`, -`libXi-devel`, `libXinerama-devel` and `libXrandr-devel` required by GLFW pull -in all its other dependencies. +On Fedora and derivatives like Red Hat the X11 extension packages +`libXcursor-devel`, `libXi-devel`, `libXinerama-devel` and `libXrandr-devel` +required by GLFW pull in all its other dependencies. @code{.sh} sudo dnf install libXcursor-devel libXi-devel libXinerama-devel libXrandr-devel @@ -80,14 +80,14 @@ To compile GLFW for Wayland, you need to have the Wayland and xkbcommon development packages installed. They are not needed to build or run programs that use GLFW. -On Debian and derivates like Ubuntu you will need the `libwayland-dev`, +On Debian and derivates like Ubuntu and Linux Mint you will need the `libwayland-dev`, `libxkbcommon-dev`, `wayland-protocols` and `extra-cmake-modules` packages. @code{.sh} sudo apt install libwayland-dev libxkbcommon-dev wayland-protocols extra-cmake-modules @endcode -On Fedora and its derivatives you will need the `wayland-devel`, +On Fedora and derivatives like Red Hat you will need the `wayland-devel`, `libxkbcommon-devel`, `wayland-protocols-devel` and `extra-cmake-modules` packages. @code{.sh} From 20a7962a9bd3b7b8561a5ccf0c2bd82225b6419e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 19 Jul 2021 19:05:32 +0200 Subject: [PATCH 14/16] Improve error description for invalid scancodes (cherry picked from commit 56092814f3a1338a219dcab275b22463d6f95182) --- src/cocoa_window.m | 2 +- src/win32_window.c | 2 +- src/x11_window.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 6f442134..3ee0e72d 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -1541,7 +1541,7 @@ const char* _glfwPlatformGetScancodeName(int scancode) if (scancode < 0 || scancode > 0xff || _glfw.ns.keycodes[scancode] == GLFW_KEY_UNKNOWN) { - _glfwInputError(GLFW_INVALID_VALUE, "Invalid scancode"); + _glfwInputError(GLFW_INVALID_VALUE, "Invalid scancode %i", scancode); return NULL; } diff --git a/src/win32_window.c b/src/win32_window.c index d17b6da4..2fa4f2e1 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -2067,7 +2067,7 @@ const char* _glfwPlatformGetScancodeName(int scancode) if (scancode < 0 || scancode > (KF_EXTENDED | 0xff) || _glfw.win32.keycodes[scancode] == GLFW_KEY_UNKNOWN) { - _glfwInputError(GLFW_INVALID_VALUE, "Invalid scancode"); + _glfwInputError(GLFW_INVALID_VALUE, "Invalid scancode %i", scancode); return NULL; } diff --git a/src/x11_window.c b/src/x11_window.c index d52ebc4d..e5333d4e 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -2886,7 +2886,7 @@ const char* _glfwPlatformGetScancodeName(int scancode) if (scancode < 0 || scancode > 0xff || _glfw.x11.keycodes[scancode] == GLFW_KEY_UNKNOWN) { - _glfwInputError(GLFW_INVALID_VALUE, "Invalid scancode"); + _glfwInputError(GLFW_INVALID_VALUE, "Invalid scancode %i", scancode); return NULL; } From b3b82cdd7864cf2157f28ee965a4491e3be96cd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 28 Jun 2021 23:52:07 +0200 Subject: [PATCH 15/16] Add custom target for updating gamepad mappings (cherry picked from commit 01778329ec0ccc485eab2a90cc42d3ff88624c35) --- docs/input.dox | 5 +++++ src/CMakeLists.txt | 9 +++++++++ src/mappings.h | 2 +- src/mappings.h.in | 2 +- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/docs/input.dox b/docs/input.dox index 45ee07f7..d9c27a67 100644 --- a/docs/input.dox +++ b/docs/input.dox @@ -794,6 +794,11 @@ glfwUpdateGamepadMappings(mappings); This function supports everything from single lines up to and including the unmodified contents of the whole `gamecontrollerdb.txt` file. +If you are compiling GLFW from source with CMake you can update the built-in mappings by +building the _update_mappings_ target. This runs the `GenerateMappings.cmake` CMake +script, which downloads `gamecontrollerdb.txt` and regenerates the `mappings.h` header +file. + Below is a description of the mapping format. Please keep in mind that __this description is not authoritative__. The format is defined by the SDL and SDL_GameControllerDB projects and their documentation and code takes precedence. diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6fbf7f69..b6dd86c5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -5,6 +5,15 @@ set(common_HEADERS internal.h mappings.h "${GLFW_SOURCE_DIR}/include/GLFW/glfw3native.h") set(common_SOURCES context.c init.c input.c monitor.c vulkan.c window.c) +add_custom_target(update_mappings + COMMAND "${CMAKE_COMMAND}" -P "${GLFW_SOURCE_DIR}/CMake/GenerateMappings.cmake" mappings.h.in mappings.h + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + COMMENT "Updating gamepad mappings from upstream repository" + SOURCES mappings.h.in "${GLFW_SOURCE_DIR}/CMake/GenerateMappings.cmake" + VERBATIM) + +set_target_properties(update_mappings PROPERTIES FOLDER "GLFW3") + if (_GLFW_COCOA) set(glfw_HEADERS ${common_HEADERS} cocoa_platform.h cocoa_joystick.h posix_thread.h nsgl_context.h egl_context.h osmesa_context.h) diff --git a/src/mappings.h b/src/mappings.h index 606824a6..a40dd06a 100644 --- a/src/mappings.h +++ b/src/mappings.h @@ -31,7 +31,7 @@ // all available in SDL_GameControllerDB. Do not edit this file. Any gamepad // mappings not specific to GLFW should be submitted to SDL_GameControllerDB. // This file can be re-generated from mappings.h.in and the upstream -// gamecontrollerdb.txt with the GenerateMappings.cmake script. +// gamecontrollerdb.txt with the 'update_mappings' CMake target. //======================================================================== // All gamepad mappings not labeled GLFW are copied from the diff --git a/src/mappings.h.in b/src/mappings.h.in index 72460b0d..33e86bfb 100644 --- a/src/mappings.h.in +++ b/src/mappings.h.in @@ -31,7 +31,7 @@ // all available in SDL_GameControllerDB. Do not edit this file. Any gamepad // mappings not specific to GLFW should be submitted to SDL_GameControllerDB. // This file can be re-generated from mappings.h.in and the upstream -// gamecontrollerdb.txt with the GenerateMappings.cmake script. +// gamecontrollerdb.txt with the 'update_mappings' CMake target. //======================================================================== // All gamepad mappings not labeled GLFW are copied from the From d3317b49373ced81a458008316dd5b6115d26df8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 29 Jun 2021 00:42:31 +0200 Subject: [PATCH 16/16] Add gamepad mapping filtering by backend This fixes gamepad mappings being included in GLFW binaries that would then never use them because they were for a different platform. (cherry picked from commit 0c90e1a33f3099bf1ec6f96dac9c6c07d722bd3c) --- CMake/GenerateMappings.cmake | 17 ++++++++++++++++- src/cocoa_joystick.h | 1 + src/linux_joystick.h | 1 + src/mappings.h | 26 ++++++++------------------ src/mappings.h.in | 13 ++++++++++++- src/win32_joystick.h | 1 + 6 files changed, 39 insertions(+), 20 deletions(-) diff --git a/CMake/GenerateMappings.cmake b/CMake/GenerateMappings.cmake index 7a88e3d4..5e5aad3d 100644 --- a/CMake/GenerateMappings.cmake +++ b/CMake/GenerateMappings.cmake @@ -24,7 +24,22 @@ endif() file(STRINGS "${source_path}" lines) foreach(line ${lines}) if ("${line}" MATCHES "^[0-9a-fA-F].*$") - set(GLFW_GAMEPAD_MAPPINGS "${GLFW_GAMEPAD_MAPPINGS}\"${line}\",\n") + if ("${line}" MATCHES "platform:Windows") + if (GLFW_WIN32_MAPPINGS) + set(GLFW_WIN32_MAPPINGS "${GLFW_WIN32_MAPPINGS}\n") + endif() + set(GLFW_WIN32_MAPPINGS "${GLFW_WIN32_MAPPINGS}\"${line}\",") + elseif ("${line}" MATCHES "platform:Mac OS X") + if (GLFW_COCOA_MAPPINGS) + set(GLFW_COCOA_MAPPINGS "${GLFW_COCOA_MAPPINGS}\n") + endif() + set(GLFW_COCOA_MAPPINGS "${GLFW_COCOA_MAPPINGS}\"${line}\",") + elseif ("${line}" MATCHES "platform:Linux") + if (GLFW_LINUX_MAPPINGS) + set(GLFW_LINUX_MAPPINGS "${GLFW_LINUX_MAPPINGS}\n") + endif() + set(GLFW_LINUX_MAPPINGS "${GLFW_LINUX_MAPPINGS}\"${line}\",") + endif() endif() endforeach() diff --git a/src/cocoa_joystick.h b/src/cocoa_joystick.h index b4448778..0de86785 100644 --- a/src/cocoa_joystick.h +++ b/src/cocoa_joystick.h @@ -33,6 +33,7 @@ #define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE struct { int dummyJoystick; } #define _GLFW_PLATFORM_MAPPING_NAME "Mac OS X" +#define GLFW_BUILD_COCOA_MAPPINGS // Cocoa-specific per-joystick data // diff --git a/src/linux_joystick.h b/src/linux_joystick.h index 2eabfa13..25a2a2ee 100644 --- a/src/linux_joystick.h +++ b/src/linux_joystick.h @@ -32,6 +32,7 @@ #define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE _GLFWlibraryLinux linjs #define _GLFW_PLATFORM_MAPPING_NAME "Linux" +#define GLFW_BUILD_LINUX_MAPPINGS // Linux-specific joystick data // diff --git a/src/mappings.h b/src/mappings.h index a40dd06a..f932c5b8 100644 --- a/src/mappings.h +++ b/src/mappings.h @@ -60,6 +60,7 @@ const char* _glfwDefaultMappings[] = { +#if defined(GLFW_BUILD_WIN32_MAPPINGS) "03000000fa2d00000100000000000000,3DRUDDER,leftx:a0,lefty:a1,rightx:a5,righty:a2,platform:Windows,", "03000000022000000090000000000000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Windows,", "03000000203800000900000000000000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Windows,", @@ -199,6 +200,9 @@ const char* _glfwDefaultMappings[] = "03000000450c00002043000000000000,XEOX Gamepad SL-6556-BK,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,", "03000000172700004431000000000000,XiaoMi Game Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b20,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a7,rightx:a2,righty:a5,start:b11,x:b3,y:b4,platform:Windows,", "03000000786901006e70000000000000,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows,", +#endif // GLFW_BUILD_WIN32_MAPPINGS + +#if defined(GLFW_BUILD_COCOA_MAPPINGS) "03000000203800000900000000010000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Mac OS X,", "03000000022000000090000001000000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Mac OS X,", "03000000102800000900000000000000,8Bitdo SFC30 GamePad Joystick,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Mac OS X,", @@ -276,6 +280,9 @@ const char* _glfwDefaultMappings[] = "030000005e040000e002000003090000,Xbox Wireless Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Mac OS X,", "03000000172700004431000029010000,XiaoMi Game Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b15,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a6,rightx:a2,righty:a5,start:b11,x:b3,y:b4,platform:Mac OS X,", "03000000120c0000100e000000010000,ZEROPLUS P4 Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,", +#endif // GLFW_BUILD_COCOA_MAPPINGS + +#if defined(GLFW_BUILD_LINUX_MAPPINGS) "05000000203800000900000000010000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,", "03000000022000000090000011010000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,", "05000000c82d00002038000000010000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,", @@ -452,25 +459,8 @@ const char* _glfwDefaultMappings[] = "05000000172700004431000029010000,XiaoMi Game Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b20,leftshoulder:b6,leftstick:b13,lefttrigger:a7,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a6,rightx:a2,righty:a5,start:b11,x:b3,y:b4,platform:Linux,", "03000000c0160000e105000001010000,Xin-Mo Xin-Mo Dual Arcade,a:b4,b:b3,back:b6,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b9,leftshoulder:b2,leftx:a0,lefty:a1,rightshoulder:b5,start:b7,x:b1,y:b0,platform:Linux,", "03000000120c0000100e000011010000,ZEROPLUS P4 Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,", -"64633436313965656664373634323364,Microsoft X-Box 360 pad,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,x:b2,y:b3,platform:Android,", -"61363931656135336130663561616264,NVIDIA Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android,", -"4e564944494120436f72706f72617469,NVIDIA Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android,", -"37336435666338653565313731303834,NVIDIA Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android,", -"35643031303033326130316330353564,PS4 Controller,a:b1,b:b17,back:b15,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b5,leftshoulder:b3,leftstick:b4,lefttrigger:+a3,leftx:a0,lefty:a1,rightshoulder:b18,rightstick:b6,righttrigger:+a4,rightx:a2,righty:a5,start:b16,x:b0,y:b2,platform:Android,", -"05000000de2800000511000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Android,", -"5477696e20555342204a6f7973746963,Twin USB Joystick,a:b22,b:b21,back:b28,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b26,leftstick:b30,lefttrigger:b24,leftx:a0,lefty:a1,rightshoulder:b27,rightstick:b31,righttrigger:b25,rightx:a3,righty:a2,start:b29,x:b23,y:b20,platform:Android,", -"34356136633366613530316338376136,Xbox Wireless Controller,a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b3,leftstick:b15,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b18,rightstick:b16,righttrigger:a5,rightx:a3,righty:a4,x:b17,y:b2,platform:Android,", -"4d466947616d65706164010000000000,MFi Extended Gamepad,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a5,rightx:a3,righty:a4,start:b6,x:b2,y:b3,platform:iOS,", -"4d466947616d65706164020000000000,MFi Gamepad,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,rightshoulder:b5,start:b6,x:b2,y:b3,platform:iOS,", -"05000000de2800000511000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:iOS,", +#endif // GLFW_BUILD_LINUX_MAPPINGS -"78696e70757401000000000000000000,XInput Gamepad (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,", -"78696e70757402000000000000000000,XInput Wheel (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,", -"78696e70757403000000000000000000,XInput Arcade Stick (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,", -"78696e70757404000000000000000000,XInput Flight Stick (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,", -"78696e70757405000000000000000000,XInput Dance Pad (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,", -"78696e70757406000000000000000000,XInput Guitar (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,", -"78696e70757408000000000000000000,XInput Drum Kit (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,", NULL }; diff --git a/src/mappings.h.in b/src/mappings.h.in index 33e86bfb..58fc44d8 100644 --- a/src/mappings.h.in +++ b/src/mappings.h.in @@ -60,7 +60,8 @@ const char* _glfwDefaultMappings[] = { -@GLFW_GAMEPAD_MAPPINGS@ +#if defined(GLFW_BUILD_WIN32_MAPPINGS) +@GLFW_WIN32_MAPPINGS@ "78696e70757401000000000000000000,XInput Gamepad (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,", "78696e70757402000000000000000000,XInput Wheel (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,", "78696e70757403000000000000000000,XInput Arcade Stick (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,", @@ -68,6 +69,16 @@ const char* _glfwDefaultMappings[] = "78696e70757405000000000000000000,XInput Dance Pad (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,", "78696e70757406000000000000000000,XInput Guitar (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,", "78696e70757408000000000000000000,XInput Drum Kit (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,", +#endif // GLFW_BUILD_WIN32_MAPPINGS + +#if defined(GLFW_BUILD_COCOA_MAPPINGS) +@GLFW_COCOA_MAPPINGS@ +#endif // GLFW_BUILD_COCOA_MAPPINGS + +#if defined(GLFW_BUILD_LINUX_MAPPINGS) +@GLFW_LINUX_MAPPINGS@ +#endif // GLFW_BUILD_LINUX_MAPPINGS + NULL }; diff --git a/src/win32_joystick.h b/src/win32_joystick.h index 9ba46d90..d591a826 100644 --- a/src/win32_joystick.h +++ b/src/win32_joystick.h @@ -28,6 +28,7 @@ #define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE struct { int dummyLibraryJoystick; } #define _GLFW_PLATFORM_MAPPING_NAME "Windows" +#define GLFW_BUILD_WIN32_MAPPINGS // Joystick element (axis, button or slider) //