Browse Source

Detect keyboard devices on Linux

rdb 10 years ago
parent
commit
bfea37f64d
2 changed files with 15 additions and 2 deletions
  1. 7 0
      panda/src/device/evdevInputDevice.cxx
  2. 8 2
      panda/src/device/inputDevice.cxx

+ 7 - 0
panda/src/device/evdevInputDevice.cxx

@@ -274,6 +274,10 @@ init_device() {
       }
       }
     }
     }
 
 
+    if (test_bit(KEY_A, keys) && test_bit(KEY_Z, keys)) {
+      _flags |= IDF_has_keyboard;
+    }
+
     // Check device type.
     // Check device type.
     if (test_bit(BTN_GAMEPAD, keys)) {
     if (test_bit(BTN_GAMEPAD, keys)) {
       _device_class = DC_gamepad;
       _device_class = DC_gamepad;
@@ -286,6 +290,9 @@ init_device() {
 
 
     } else if (test_bit(BTN_WHEEL, keys)) {
     } else if (test_bit(BTN_WHEEL, keys)) {
       _device_class = DC_steering_wheel;
       _device_class = DC_steering_wheel;
+
+    } else if (_flags & IDF_has_keyboard) {
+      _device_class = DC_keyboard;
     }
     }
   }
   }
 
 

+ 8 - 2
panda/src/device/inputDevice.cxx

@@ -283,11 +283,17 @@ output(ostream &out) const {
   }
   }
 
 
   if (_buttons.size() > 0) {
   if (_buttons.size() > 0) {
-    out << ", " << _buttons.size() << " buttons";
+    out << ", " << _buttons.size() << " button";
+    if (_buttons.size() != 1) {
+      out.put('s');
+    }
   }
   }
 
 
   if (_controls.size() > 0) {
   if (_controls.size() > 0) {
-    out << ", " << _controls.size() << " controls";
+    out << ", " << _controls.size() << " control";
+    if (_controls.size() != 1) {
+      out.put('s');
+    }
   }
   }
 
 
   if (_flags & IDF_has_pointer) {
   if (_flags & IDF_has_pointer) {