当前位置: 首页>>代码示例>>C++>>正文


C++ Keystrokes类代码示例

本文整理汇总了C++中Keystrokes的典型用法代码示例。如果您正苦于以下问题:C++ Keystrokes类的具体用法?C++ Keystrokes怎么用?C++ Keystrokes使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Keystrokes类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: LOG

void
CKeyState::fakeKeyEvents(const Keystrokes& keys, UInt32 count)
{
	// do nothing if no keys or no repeats
	if (count == 0 || keys.empty()) {
		return;
	}

	// generate key events
	LOG((CLOG_DEBUG2 "keystrokes:"));
	for (Keystrokes::const_iterator k = keys.begin(); k != keys.end(); ) {
		if (k->m_repeat) {
			// repeat from here up to but not including the next key
			// with m_repeat == false count times.
			Keystrokes::const_iterator start = k;
			while (count-- > 0) {
				// send repeating events
				for (k = start; k != keys.end() && k->m_repeat; ++k) {
					fakeKeyEvent(k->m_key, k->m_press, true);
				}
			}

			// note -- k is now on the first non-repeat key after the
			// repeat keys, exactly where we'd like to continue from.
		}
		else {
			// send event
			fakeKeyEvent(k->m_key, k->m_press, false);

			// next key
			++k;
		}
	}
}
开发者ID:svn2github,项目名称:synergy-plus,代码行数:34,代码来源:CKeyState.cpp

示例2:

void
CKeyState::fakeToggle(KeyModifierMask modifier)
{
	const KeyButtons& buttons = m_maskToKeys[getIndexForModifier(modifier)];
	if (buttons.empty() || !isToggle(modifier)) {
		return;
	}
	KeyButton button = buttons[0];

	// get the sequence of keys to simulate key toggle
	Keystrokes keys;
	Keystroke keystroke;
	keystroke.m_key    = button;
	keystroke.m_press  = true;
	keystroke.m_repeat = false;
	keys.push_back(keystroke);
	keystroke.m_press  = false;
	keys.push_back(keystroke);

	// generate key events
	fakeKeyEvents(keys, 1);

	// note the toggle
	m_keys[button] ^= kToggled;
	m_mask         ^= modifier;
}
开发者ID:svn2github,项目名称:synergy-plus,代码行数:26,代码来源:CKeyState.cpp

示例3: pollActiveGroup

void
CKeyState::fakeKeyRepeat(
				KeyID id, KeyModifierMask mask,
				SInt32 count, KeyButton serverID)
{
	serverID &= kButtonMask;

	// if we haven't seen this button go down then ignore it
	KeyButton oldLocalID = m_serverKeys[serverID];
	if (oldLocalID == 0) {
		return;
	}

	// get keys for key repeat
	Keystrokes keys;
	ModifierToKeys oldActiveModifiers = m_activeModifiers;
	const CKeyMap::KeyItem* keyItem =
		m_keyMap.mapKey(keys, id, pollActiveGroup(),
								m_activeModifiers, m_mask, mask, true);
	if (keyItem == NULL) {
		return;
	}
	KeyButton localID = (KeyButton)(keyItem->m_button & kButtonMask);
	if (localID == 0) {
		return;
	}

	// if the KeyButton for the auto-repeat is not the same as for the
	// initial press then mark the initial key as released and the new
	// key as pressed.  this can happen when we auto-repeat after a
	// dead key.  for example, a dead accent followed by 'a' will
	// generate an 'a with accent' followed by a repeating 'a'.  the
	// KeyButtons for the two KeyIDs might be different.
	if (localID != oldLocalID) {
		// replace key up with previous KeyButton but leave key down
		// alone so it uses the new KeyButton.
		for (Keystrokes::iterator index = keys.begin();
								index != keys.end(); ++index) {
			if (index->m_type == Keystroke::kButton &&
				index->m_data.m_button.m_button == localID) {
				index->m_data.m_button.m_button = oldLocalID;
				break;
			}
		}

		// note that old key is now up
		--m_keys[oldLocalID];
		--m_syntheticKeys[oldLocalID];

		// 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, count);
}
开发者ID:svn2github,项目名称:synergy-plus,代码行数:60,代码来源:CKeyState.cpp

示例4:

void
CKeyState::fakeAllKeysUp()
{
	Keystrokes keys;
	for (KeyButton i = 0; i < IKeyState::kNumButtons; ++i) {
		if (m_syntheticKeys[i] > 0) {
			keys.push_back(Keystroke(i, false, false, m_keyClientData[i]));
			m_keys[i]          = 0;
			m_syntheticKeys[i] = 0;
		}
	}
	fakeKeys(keys, 1);
}
开发者ID:svn2github,项目名称:synergy-plus,代码行数:13,代码来源:CKeyState.cpp

示例5: sizeof

void
CKeyState::fakeAllKeysUp()
{
	Keystrokes keys;
	for (KeyButton i = 0; i < IKeyState::kNumButtons; ++i) {
		if (m_syntheticKeys[i] > 0) {
			keys.push_back(Keystroke(i, false, false, m_keyClientData[i]));
			m_keys[i]          = 0;
			m_syntheticKeys[i] = 0;
		}
	}
	fakeKeys(keys, 1);
	memset(&m_serverKeys, 0, sizeof(m_serverKeys));
	m_activeModifiers.clear();
	m_mask = pollActiveModifiers();
}
开发者ID:dbkr,项目名称:synergy-onnaf,代码行数:16,代码来源:CKeyState.cpp

示例6: if

bool
CKeyState::mapModifier(Keystrokes& keys, Keystrokes& undo,
				KeyModifierMask mask, bool desireActive, bool force) const
{
	// look up modifier
	const KeyButtons& buttons = m_maskToKeys[getIndexForModifier(mask)];
	if (buttons.empty()) {
		return false;
	}

	// ignore if already in desired state
	if (!force && isModifierActive(mask) == desireActive) {
		return true;
	}

	// initialize keystroke
	Keystroke keystroke;
	keystroke.m_repeat = false;

	// handle toggles
	if (isToggle(mask)) {
		keystroke.m_key   = buttons[0];
		keystroke.m_press = true;
		keys.push_back(keystroke);
		keystroke.m_press = false;
		keys.push_back(keystroke);
		keystroke.m_press = false;
		undo.push_back(keystroke);
		keystroke.m_press = true;
		undo.push_back(keystroke);
	}

	else if (desireActive) {
		// press
		keystroke.m_key   = buttons[0];
		keystroke.m_press = true;
		keys.push_back(keystroke);
		keystroke.m_press = false;
		undo.push_back(keystroke);
	}

	else {
		// releasing a modifier is quite different from pressing one.
		// when we release a modifier we have to release every keycode that
		// is assigned to the modifier since the modifier is active if any
		// one of them is down.  when we press a modifier we just have to
		// press one of those keycodes.
		for (KeyButtons::const_iterator j = buttons.begin();
								j != buttons.end(); ++j) {
			if (isKeyDown(*j)) {
				keystroke.m_key   = *j;
				keystroke.m_press = false;
				keys.push_back(keystroke);
				keystroke.m_press = true;
				undo.push_back(keystroke);
			}
		}
	}

	return true;
}
开发者ID:svn2github,项目名称:synergy-plus,代码行数:61,代码来源:CKeyState.cpp


注:本文中的Keystrokes类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。