• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Which keyboard (barcode scanner) did the event come from?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Which keyboard (barcode scanner) did the event come from?


  • Subject: Which keyboard (barcode scanner) did the event come from?
  • From: Gerd Knops <email@hidden>
  • Date: Mon, 9 Feb 2009 16:47:24 -0600

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@hidden)

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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Which keyboard (barcode scanner) did the event come from?
      • From: Kevin Gessner <email@hidden>
  • Prev by Date: Re: Where is ${EXECUTABLE_NAME} defined?
  • Next by Date: Re: Distributed Objects question
  • Previous by thread: Re: Where is ${EXECUTABLE_NAME} defined?
  • Next by thread: Re: Which keyboard (barcode scanner) did the event come from?
  • Index(es):
    • Date
    • Thread