Skip to content

Commit

Permalink
Implement -location flag
Browse files Browse the repository at this point in the history
Includes locationId in the keyboards identifiers (defaults to false)

Note that the locationId changes when you plug a keyboard in a different port.
Therefore using the locationId in the keyboards identifiers means the
configured language will be associated to a keyboard on a specific port.

fixes #6
  • Loading branch information
jeantil committed Oct 23, 2017
1 parent db53b12 commit fe3c744
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions autokbisw/IOKeyEventMonitor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,15 @@ final internal class IOKeyEventMonitor {
let locationId = String(describing: IOHIDDeviceGetProperty(senderDevice, kIOHIDLocationIDKey as CFString));
let uniqueId = String(describing: IOHIDDeviceGetProperty(senderDevice, kIOHIDUniqueIDKey as CFString));

let keyboard = "\(product) - [\(vendorId)-\(productId)-\(manufacturer)-\(serialNumber)]";
let keyboard =
selfPtr.userOptions.useLocation ?
"\(product)-[\(vendorId)-\(productId)-\(manufacturer)-\(serialNumber)-\(locationId)]" :
"\(product)-[\(vendorId)-\(productId)-\(manufacturer)-\(serialNumber)]";

if(selfPtr.userOptions.verbosity >= UserOptions.TRACE){
print("received event from keyboard \(keyboard) - \(locationId) - \(uniqueId)");
}
selfPtr.onKeyboardEvent(keyboard: keyboard);

selfPtr.onKeyboardEvent(keyboard: keyboard);
}

IOHIDManagerRegisterInputValueCallback( hidManager, myHIDKeyboardCallback, context);
Expand Down

0 comments on commit fe3c744

Please sign in to comment.