Is there a way to tell between two keyboards?

I’m working on a project that involves using an old USB keyboard to create a new interface device (the idea of having to program a USB controller was overwhelming). I know Applescript best, so I’m planning on using it to interpret the input. I have determined that hooking two keyboards up to my box doesn’t do anything strange by simply trying it. But typing on either keyboard acts like it’s just one keyboard – hitting the “a” key on either inputs an “a”. Anybody know of a way to identify which keyboard a keystroke comes from?

Model: Power Mac G4 dual 533
Browser: Firefox 3.5.7
Operating System: Mac OS X (10.4)

I don’t think ControllerMate itself is scriptable, but maybe it can offer another avenue of exploration because it can tell the difference between two different brands of keyboards, or different version of the same keyboard in some cases.

I use this to run an X-Keys Button Panel and X-Keys Desktop which run various scripts and macros.

I vaguely recall that the tool for distinguishing between USB devices is NSDistributedNotificationCenter, if that helps at all.

Not to be rude, but… not really!

I looked up that class on MacDeveloper. I just klunk along in AS, I’m not very good at C at all. How would I get info from that class via Applescript?

Model: Power Mac G4 dual 533
Browser: Firefox 3.5.7
Operating System: Mac OS X (10.4)

This is not something you can do with AppleScript. To access information about USB you need to use the IOKit framework which is all C.

You might find some thing in the result of ‘ioreg -c IOHIDSystem

Normally it will be a name and a state (number)

 set keyboard to do shell script "ioreg -c IOHIDSystem |grep -i keyboard"

But if that leads you to be able to control or read from each keyboard…???

Which USB device has produced the latest input (e.g., like a keycode from a keyboard) is pretty low-level stuff, srmcurator, as you can see from the posts following mine. I don’t know of any high-level software that distinguishes between mice or keyboards, not even if they are not both USB. For example, if I move my Magic Mouse, the cursor moves, and a USB mouse just moves it further from wherever the first move ended. I’m willing to bet that you aren’t going to get where you want to be with AppleScript.