summaryrefslogtreecommitdiff
path: root/libs/raylib/src/external/glfw/CMake/GenerateMappings.cmake
diff options
context:
space:
mode:
authorLuca Sas <sas.luca.alex@gmail.com>2020-03-06 17:48:44 +0000
committerLuca Sas <sas.luca.alex@gmail.com>2020-03-06 17:48:44 +0000
commit581538a8b371c0a9003dc0f1bf081222b8c4fdd9 (patch)
treef5759a699424211d4a66e24365a596072818ab33 /libs/raylib/src/external/glfw/CMake/GenerateMappings.cmake
downloadgamejam-slgj-2024-581538a8b371c0a9003dc0f1bf081222b8c4fdd9.tar.gz
gamejam-slgj-2024-581538a8b371c0a9003dc0f1bf081222b8c4fdd9.tar.bz2
gamejam-slgj-2024-581538a8b371c0a9003dc0f1bf081222b8c4fdd9.zip
Setup the project
Diffstat (limited to 'libs/raylib/src/external/glfw/CMake/GenerateMappings.cmake')
-rw-r--r--libs/raylib/src/external/glfw/CMake/GenerateMappings.cmake33
1 files changed, 33 insertions, 0 deletions
diff --git a/libs/raylib/src/external/glfw/CMake/GenerateMappings.cmake b/libs/raylib/src/external/glfw/CMake/GenerateMappings.cmake
new file mode 100644
index 0000000..7a88e3d
--- /dev/null
+++ b/libs/raylib/src/external/glfw/CMake/GenerateMappings.cmake
@@ -0,0 +1,33 @@
+# Usage:
+# cmake -P GenerateMappings.cmake <path/to/mappings.h.in> <path/to/mappings.h>
+
+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}")
+set(target_path "${CMAKE_ARGV4}")
+
+if (NOT EXISTS "${template_path}")
+ message(FATAL_ERROR "Failed to find template file ${template_path}")
+endif()
+
+file(DOWNLOAD "${source_url}" "${source_path}"
+ STATUS download_status
+ TLS_VERIFY on)
+
+list(GET download_status 0 status_code)
+list(GET download_status 1 status_message)
+
+if (status_code)
+ message(FATAL_ERROR "Failed to download ${source_url}: ${status_message}")
+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")
+ endif()
+endforeach()
+
+configure_file("${template_path}" "${target_path}" @ONLY NEWLINE_STYLE UNIX)
+file(REMOVE "${source_path}")
+