瀏覽代碼

Add custom target for updating gamepad mappings

(cherry picked from commit 01778329ec0ccc485eab2a90cc42d3ff88624c35)
Camilla Löwy 4 年之前
父節點
當前提交
b3b82cdd78
共有 4 個文件被更改,包括 16 次插入2 次删除
  1. 5 0
      docs/input.dox
  2. 9 0
      src/CMakeLists.txt
  3. 1 1
      src/mappings.h
  4. 1 1
      src/mappings.h.in

+ 5 - 0
docs/input.dox

@@ -794,6 +794,11 @@ glfwUpdateGamepadMappings(mappings);
 This function supports everything from single lines up to and including the
 This function supports everything from single lines up to and including the
 unmodified contents of the whole `gamecontrollerdb.txt` file.
 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
 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
 description is not authoritative__.  The format is defined by the SDL and
 SDL_GameControllerDB projects and their documentation and code takes precedence.
 SDL_GameControllerDB projects and their documentation and code takes precedence.

+ 9 - 0
src/CMakeLists.txt

@@ -5,6 +5,15 @@ set(common_HEADERS internal.h mappings.h
                    "${GLFW_SOURCE_DIR}/include/GLFW/glfw3native.h")
                    "${GLFW_SOURCE_DIR}/include/GLFW/glfw3native.h")
 set(common_SOURCES context.c init.c input.c monitor.c vulkan.c window.c)
 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)
 if (_GLFW_COCOA)
     set(glfw_HEADERS ${common_HEADERS} cocoa_platform.h cocoa_joystick.h
     set(glfw_HEADERS ${common_HEADERS} cocoa_platform.h cocoa_joystick.h
                      posix_thread.h nsgl_context.h egl_context.h osmesa_context.h)
                      posix_thread.h nsgl_context.h egl_context.h osmesa_context.h)

+ 1 - 1
src/mappings.h

@@ -31,7 +31,7 @@
 // all available in SDL_GameControllerDB.  Do not edit this file.  Any gamepad
 // all available in SDL_GameControllerDB.  Do not edit this file.  Any gamepad
 // mappings not specific to GLFW should be submitted to SDL_GameControllerDB.
 // mappings not specific to GLFW should be submitted to SDL_GameControllerDB.
 // This file can be re-generated from mappings.h.in and the upstream
 // 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
 // All gamepad mappings not labeled GLFW are copied from the

+ 1 - 1
src/mappings.h.in

@@ -31,7 +31,7 @@
 // all available in SDL_GameControllerDB.  Do not edit this file.  Any gamepad
 // all available in SDL_GameControllerDB.  Do not edit this file.  Any gamepad
 // mappings not specific to GLFW should be submitted to SDL_GameControllerDB.
 // mappings not specific to GLFW should be submitted to SDL_GameControllerDB.
 // This file can be re-generated from mappings.h.in and the upstream
 // 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
 // All gamepad mappings not labeled GLFW are copied from the