Skip to content

Commit

Permalink
Fix for not properly setting unknown USB devices
Browse files Browse the repository at this point in the history
  • Loading branch information
tuxudo committed Sep 22, 2021
1 parent a975345 commit b502aa4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion scripts/usb.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def main():
info = get_usb_info()
result = flatten_usb_info(info)

# Write bluetooth results to cache
# Write usb results to cache
cachedir = '%s/cache' % os.path.dirname(os.path.realpath(__file__))
output_plist = os.path.join(cachedir, 'usbinfo.plist')
plistlib.writePlist(result, output_plist)
Expand Down
8 changes: 6 additions & 2 deletions usb_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function process($plist)

// Map name to device type
$device_types = array(
'Camera' => 'isight|camera|video|facetime',
'Camera' => 'isight|camera|video|facetime|webcam',
'USB Hub' => 'hub',
'Keyboard' => 'keyboard|keykoard|usb kb',
'IR Receiver' => 'ir receiver',
Expand All @@ -103,17 +103,21 @@ function process($plist)
'iPod' => 'ipod',
'Mouse' => 'mouse|ps2 orbit|trackpad',
'Mass Storage' => 'card reader|os x install disk|apple usb superdrive|ultra fast media reader|usb to serial-ata bridge',
'Audio Device' => 'audio|sound|headset|microphone|akm',
'Display' => 'displaylink|display|monitor|touchscreen',
'Composite Device' => 'composite device',
'Network' => 'network|ethernet|modem|bcm',
'UPS' => 'ups',
'Audio Device' => 'audio|sound|headset|microphone|akm',
'iBridge' => 'ibridge',
'Scanner' => 'scanner',
'Wacom Tablet' => 'wacom|ptz-|intuos|ctl-',
'Interactive Board' => 'smartboard|activboard'
);

// Set device type to be default of unknown
$device['type'] = "unknown";

// Set new device type based on device name
$device_name = strtolower($device['name']);
foreach($device_types as $type => $pattern){
if (preg_match('/'.$pattern.'/', $device_name)){
Expand Down

0 comments on commit b502aa4

Please sign in to comment.