Fixes #2271, Add KD detection under CMake by Scott Percival
authorGabriel Jacobo <gabomdq@gmail.com>
Tue, 26 Nov 2013 11:50:54 -0300
changeset 8032 e2096994e8b8
parent 8031 edf58197a910
child 8033 8181c3a4a055
Fixes #2271, Add KD detection under CMake by Scott Percival
CMakeLists.txt
include/SDL_config.h.cmake
--- a/CMakeLists.txt	Tue Nov 26 11:47:52 2013 -0300
+++ b/CMakeLists.txt	Tue Nov 26 11:50:54 2013 -0300
@@ -651,6 +651,17 @@
         #endif
         int main(int argc, char** argv) {}" HAVE_INPUT_EVENTS)
 
+    check_c_source_compiles("
+        #include <linux/kd.h>
+        #include <linux/keyboard.h>
+
+        int main(int argc, char **argv) 
+        {
+            struct kbentry kbe;
+            kbe.kb_table = KG_CTRL;
+            ioctl(0, KDGKBENT, &kbe);
+        }" HAVE_INPUT_KD)
+
     file(GLOB CORE_SOURCES ${SDL2_SOURCE_DIR}/src/core/linux/*.c)
     set(SOURCE_FILES ${SOURCE_FILES} ${CORE_SOURCES})
 
@@ -665,6 +676,10 @@
       set(HAVE_SDL_HAPTIC TRUE)
     endif(SDL_HAPTIC AND HAVE_INPUT_EVENTS)
 
+    if(HAVE_INPUT_KD)
+      set(SDL_INPUT_LINUXKD 1)
+    endif(HAVE_INPUT_KD)
+
     check_include_file("libudev.h" HAVE_LIBUDEV_H)
 
     # !!! FIXME: this needs pkg-config to find the include path, I think.
--- a/include/SDL_config.h.cmake	Tue Nov 26 11:47:52 2013 -0300
+++ b/include/SDL_config.h.cmake	Tue Nov 26 11:50:54 2013 -0300
@@ -215,6 +215,7 @@
 
 /* Enable various input drivers */
 #cmakedefine SDL_INPUT_LINUXEV @SDL_INPUT_LINUXEV@
+#cmakedefine SDL_INPUT_LINUXKD @SDL_INPUT_LINUXKD@
 #cmakedefine SDL_INPUT_TSLIB @SDL_INPUT_TSLIB@
 #cmakedefine SDL_JOYSTICK_HAIKU @SDL_JOYSTICK_HAIKU@
 #cmakedefine SDL_JOYSTICK_DINPUT @SDL_JOYSTICK_DINPUT@