Assuming I have two identical USB keyboards (actually barcode scanners) connected to a mac, is there any way to tell which of them a keyboard event came from?

I can get to the keyboard type easily enough, but that only helps when I have different keyboards:

- (void)sendEvent:(NSEvent *)anEvent {
        
        NSEventType     type=[anEvent type];
        
        if(type==NSKeyDown)
        {
                EventRef        ce=(EventRef)[anEvent eventRef];
                
                if(ce)
                {
                        unsigned        kbt;
                        
                        GetEventParameter(
                                ce,
                                kEventParamKeyboardType,
                                typeUInt32, NULL,
                                sizeof kbt,
                                NULL,
                                &kbt
                        );
                        
                        NSLog(@"Keyboard type: %d",kbt);
                }
        }
        [super sendEvent:anEvent];
}

Is there some way to, say, get a unique USB device ID or something like that from an NSEvent or a EventRef?

Thanks

Gerd

_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to