Browse Source

Grab the input device while engine is running on a Raspberry Pi so that the keystrokes intended for Urho3D do not redundantly get echoed out in the virtual terminal or shell that starts the engine.

Wei Tjong Yao 12 years ago
parent
commit
320d6fd9e6
1 changed files with 5 additions and 1 deletions
  1. 5 1
      ThirdParty/SDL/src/video/raspi/SDL_raspievents.c

+ 5 - 1
ThirdParty/SDL/src/video/raspi/SDL_raspievents.c

@@ -147,10 +147,13 @@ RASPI_InitInput(_THIS)
     char device[32];
     char device[32];
     for (i = 0; i < NUM_INPUT_DEVICE; ++i) {
     for (i = 0; i < NUM_INPUT_DEVICE; ++i) {
         sprintf(device, "/dev/input/event%i", i);
         sprintf(device, "/dev/input/event%i", i);
-        event_fd[i] = open(device, O_RDONLY | O_NONBLOCK);
+        event_fd[i] = open(device, O_RDWR | O_NONBLOCK);
         if (event_fd[i] < 0) {
         if (event_fd[i] < 0) {
             return SDL_SetError("Couldn't open %s", device);
             return SDL_SetError("Couldn't open %s", device);
         }
         }
+        if (ioctl(event_fd[i], EVIOCGRAB, 1/*grab*/) < 0) {
+            return SDL_SetError("Couldn't grab %s", device);
+        }
     }
     }
 
 
     /* Set Linux scancode to SDL key mapping */
     /* Set Linux scancode to SDL key mapping */
@@ -164,6 +167,7 @@ RASPI_QuitInput(_THIS)
 {
 {
     int i;
     int i;
     for (i = 0; i < NUM_INPUT_DEVICE; ++i) {
     for (i = 0; i < NUM_INPUT_DEVICE; ++i) {
+        ioctl(event_fd[i], EVIOCGRAB, 0/*release*/);
         close(event_fd[i]);
         close(event_fd[i]);
         event_fd[i] = -1;
         event_fd[i] = -1;
     }
     }