Пример #1
0
void
KeyState::fakeKeyDown(KeyID id, KeyModifierMask mask, KeyButton serverID)
{
    // if this server key is already down then this is probably a
    // mis-reported autorepeat.
    serverID &= kButtonMask;
    if (m_serverKeys[serverID] != 0) {
        fakeKeyRepeat(id, mask, 1, serverID);
        return;
    }

    // ignore certain keys
    if (isIgnoredKey(id, mask)) {
        LOG((CLOG_DEBUG1 "ignored key %04x %04x", id, mask));
        return;
    }

    // get keys for key press
    Keystrokes keys;
    ModifierToKeys oldActiveModifiers = m_activeModifiers;
    const barrier::KeyMap::KeyItem* keyItem =
        m_keyMap.mapKey(keys, id, pollActiveGroup(), m_activeModifiers,
                                getActiveModifiersRValue(), mask, false);
    if (keyItem == NULL) {
        // a media key won't be mapped on mac, so we need to fake it in a
        // special way
        if (id == kKeyAudioDown || id == kKeyAudioUp ||
            id == kKeyAudioMute || id == kKeyAudioPlay ||
            id == kKeyAudioPrev || id == kKeyAudioNext ||
            id == kKeyBrightnessDown || id == kKeyBrightnessUp
            ) {
            LOG((CLOG_DEBUG1 "emulating media key"));
            fakeMediaKey(id);
        }
        
        return;
    }
    
    KeyButton localID = (KeyButton)(keyItem->m_button & kButtonMask);
    updateModifierKeyState(localID, oldActiveModifiers, m_activeModifiers);
    if (localID != 0) {
        // note keys down
        ++m_keys[localID];
        ++m_syntheticKeys[localID];
        m_keyClientData[localID] = keyItem->m_client;
        m_serverKeys[serverID]   = localID;
    }

    // generate key events
    fakeKeys(keys, 1);
}
Пример #2
0
void
CKeyState::fakeKeyDown(KeyID id, KeyModifierMask mask, KeyButton serverID)
{
	// ignore key if serverID is bogus
	serverID &= kButtonMask;
	if (serverID == 0) {
		LOG((CLOG_DEBUG1 "ignored fake key for %04x with serverID of 0", id));
		return;
	}

	// if this server key is already down then this is probably a
	// mis-reported autorepeat.
	if (m_serverKeys[serverID] != 0) {
		fakeKeyRepeat(id, mask, 1, serverID);
		return;
	}

	// ignore certain keys
	if (isIgnoredKey(id, mask)) {
		LOG((CLOG_DEBUG1 "ignored key %04x %04x", id, mask));
		return;
	}

	// get keys for key press
	Keystrokes keys;
	ModifierToKeys oldActiveModifiers = m_activeModifiers;
	const CKeyMap::KeyItem* keyItem =
		m_keyMap.mapKey(keys, id, pollActiveGroup(),
								m_activeModifiers, m_mask, mask, false);
	if (keyItem == NULL) {
		return;
	}
	KeyButton localID = (KeyButton)(keyItem->m_button & kButtonMask);
	if (localID != 0) {
		// note keys down
		updateModifierKeyState(localID, oldActiveModifiers, m_activeModifiers);
		++m_keys[localID];
		++m_syntheticKeys[localID];
		m_keyClientData[localID] = keyItem->m_client;
		m_serverKeys[serverID]   = localID;
	}

	// generate key events
	fakeKeys(keys, 1);
}