// Dispatch a keyboard event to any registered handlers void EventDispatcher::handleKeyboard(KeyboardEvent& evt) { HANDLE dev = evt.getDeviceHandle(); { // Set the device info if it's available ScopedCriticalSection kMutex(&kdLock); if(keyboardDevices.count(dev) > 0) { evt.setDeviceInfo(keyboardDevices[dev]); } else { // It's an unknown device, let's see what we can find out about it. ScopedNonCriticalSection unlock(&kdLock); KeyboardInfo *kbd = unknownKeyboardDevice(dev); if(kbd) { evt.setDeviceInfo(kbd); } } } { // Run the chain, let someone make a decision about this event ScopedCriticalSection kecMutex(&kecLock); if(kbdEventChains.count(dev) > 0 && kbdEventChains[dev]->chainSize() > 0) { // We've got a real handler, give it to them (and hard) kbdEventChains[dev]->runKeyboardEventChain(evt); } else { // Ain't nobody here. Do something? } } }