本文整理汇总了C++中KeyCode类的典型用法代码示例。如果您正苦于以下问题:C++ KeyCode类的具体用法?C++ KeyCode怎么用?C++ KeyCode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了KeyCode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: flags
void
SimultaneousKeyPresses::push_remapped(bool isKeyDown, const DeviceIdentifier& deviceIdentifier)
{
EventType eventType = isKeyDown ? EventType::DOWN : EventType::UP;
KeyCode key = virtualkey_;
if (isToRaw_) {
key = toKey_raw_;
}
if (key == KeyCode::VK_NONE) return;
Flags flags(0);
if (isKeyDown) {
flags.add(key.getModifierFlag());
flags.stripNONE();
}
// ----------------------------------------
Params_KeyboardEventCallBack::auto_ptr ptr(Params_KeyboardEventCallBack::alloc(eventType, flags, key, CommonData::getcurrent_keyboardType(), false));
if (! ptr) return;
Params_KeyboardEventCallBack& params = *ptr;
bool retainFlagStatusTemporaryCount = false;
bool push_back = false;
EventInputQueue::enqueue_(params, retainFlagStatusTemporaryCount, deviceIdentifier, push_back);
}
示例2: changeKeyState
void KeypadWidget::changeKeyState(KeyCode keycode, bool press, bool toggleHold) {
if (Key *key = m_keys[keycode.row()][keycode.col()]) {
bool wasSelected = key->isSelected();
key->setPressed(press);
if (toggleHold) {
key->toggleHeld();
}
bool selected = key->isSelected();
if (selected != wasSelected) {
update(m_transform.mapRect(key->keyGeometry()));
keypad_key_event(keycode.row(), keycode.col(), selected);
}
}
}
示例3: isKeyDownOrModifierDown
// ------------------------------------------------------------
bool EventType::isKeyDownOrModifierDown(KeyCode key, Flags flags) const {
if (*this == EventType::DOWN) return true;
if (*this == EventType::MODIFY) {
return flags.isOn(key.getModifierFlag());
}
return false;
}
示例4: Item
void
PressDownKeys::add(KeyCode key, KeyboardType keyboardType) {
if (key == KeyCode::VK_NONE) return;
list_.push_back(new Item(key, keyboardType));
IOLOG_DEVEL("PressDownKeys::add key:%d, keyboardType:%d\n", key.get(), keyboardType.get());
}
示例5: push_remapped
void SimultaneousKeyPresses::push_remapped(bool isKeyDown, const DeviceIdentifier& deviceIdentifier, const ListHookedDevice::WeakPointer_Item& device) {
EventType eventType = isKeyDown ? EventType::DOWN : EventType::UP;
KeyCode key = virtualkey_;
if (isToRaw_) {
key = toKey_raw_;
}
if (key == KeyCode::VK_NONE) return;
Flags flags(0);
if (isKeyDown) {
flags.add(key.getModifierFlag());
}
// ----------------------------------------
Params_KeyboardEventCallBack params(eventType, flags, key, CommonData::getcurrent_keyboardType(), false);
bool retainFlagStatusTemporaryCount = false;
bool push_back = false;
bool isSimultaneousKeyPressesTarget = false;
EventInputQueue::enqueue_(params, retainFlagStatusTemporaryCount, deviceIdentifier, device, push_back, isSimultaneousKeyPressesTarget);
}
示例6: onKeyButtonReleased
void BerkeliumWidget::onKeyButtonReleased(KeyCode _key)
{
if (mWindow != nullptr)
{
InputManager& manager = InputManager::getInstance();
int mod = 0;
if (manager.isControlPressed())
mod |= Berkelium::CONTROL_MOD;
if (manager.isShiftPressed())
mod |= Berkelium::SHIFT_MOD;
mWindow->keyEvent(false, mod, input::ScanCodeToVirtualKey(_key.toValue()), 0);
}
Base::onKeyButtonReleased(_key);
}
示例7:
void
PressDownKeys::remove(KeyCode key, KeyboardType keyboardType) {
Item* p = static_cast<Item*>(list_.safe_front());
for (;;) {
if (!p) break;
if (p->key == key &&
p->keyboardType == keyboardType) {
p = static_cast<Item*>(list_.erase_and_delete(p));
} else {
p = static_cast<Item*>(p->getnext());
}
}
IOLOG_DEVEL("PressDownKeys::remove key:%d, keyboardType:%d\n", key.get(), keyboardType.get());
}
示例8: if
void
KeyboardRepeat::set(EventType eventType,
Flags flags,
KeyCode key,
KeyboardType keyboardType,
int delayUntilRepeat,
int keyRepeat)
{
if (! queue_) return;
if (key == KeyCode::VK_NONE) return;
if (eventType == EventType::MODIFY) {
goto cancel;
} else if (eventType == EventType::UP) {
// The repetition of plural keys is controlled by manual operation.
// So, we ignore it.
if (queue_->size() != 1) return;
// We stop key repeat only when the repeating key is up.
KeyboardRepeat::Item* p = static_cast<KeyboardRepeat::Item*>(queue_->front());
if (p && (p->params).type == ParamsUnion::KEYBOARD) {
Params_KeyboardEventCallBack* params = (p->params).params.params_KeyboardEventCallBack;
if (params && key == params->key) {
goto cancel;
}
}
} else if (eventType == EventType::DOWN) {
cancel();
primitive_add(eventType, flags, key, keyboardType, Item::TYPE_NORMAL);
primitive_start(delayUntilRepeat, keyRepeat);
IOLOG_DEVEL("KeyboardRepeat::set key:%d flags:0x%x\n", key.get(), flags.get());
} else {
goto cancel;
}
return;
cancel:
cancel();
}
示例9: stfc
void
EventOutputQueue::FireKey::fire_downup(Flags flags, KeyCode key, KeyboardType keyboardType)
{
ModifierFlag f = key.getModifierFlag();
if (f != ModifierFlag::ZERO) {
FlagStatus::ScopedTemporaryFlagsChanger stfc(FlagStatus::globalFlagStatus(), flags);
// We operate FlagStatus for the case "key == KeyCode::CAPSLOCK".
FlagStatus::globalFlagStatus().increase(f);
{
Params_KeyboardEventCallBack::auto_ptr ptr(Params_KeyboardEventCallBack::alloc(EventType::MODIFY,
FlagStatus::globalFlagStatus().makeFlags(),
key,
keyboardType,
false));
if (! ptr) return;
FireKey::fire(*ptr);
}
FlagStatus::globalFlagStatus().decrease(f);
{
Params_KeyboardEventCallBack::auto_ptr ptr(Params_KeyboardEventCallBack::alloc(EventType::MODIFY,
FlagStatus::globalFlagStatus().makeFlags(),
key,
keyboardType,
false));
if (! ptr) return;
FireKey::fire(*ptr);
}
} else {
{
Params_KeyboardEventCallBack::auto_ptr ptr(Params_KeyboardEventCallBack::alloc(EventType::DOWN, flags, key, keyboardType, false));
if (! ptr) return;
FireKey::fire(*ptr);
}
{
Params_KeyboardEventCallBack::auto_ptr ptr(Params_KeyboardEventCallBack::alloc(EventType::UP, flags, key, keyboardType, false));
if (! ptr) return;
FireKey::fire(*ptr);
}
}
}
示例10: set
void KeyboardRepeat::set(EventType eventType,
Flags flags,
KeyCode key,
KeyboardType keyboardType,
int delayUntilRepeat,
int keyRepeat) {
if (key == KeyCode::VK_NONE) return;
if (eventType == EventType::MODIFY) {
goto cancel;
} else if (eventType == EventType::UP) {
// The repetition of multiple keys is controlled by manual operation.
// So, we ignore it.
if (queue_.size() != 1) return;
// We stop key repeat only when the repeating key is up.
KeyboardRepeat::Item* p = static_cast<KeyboardRepeat::Item*>(queue_.safe_front());
if (p) {
auto params = (p->getParamsBase()).get_Params_KeyboardEventCallBack();
if (params && key == params->key) {
goto cancel;
}
}
} else if (eventType == EventType::DOWN) {
cancel();
primitive_add(eventType, flags, key, keyboardType);
primitive_start(delayUntilRepeat, keyRepeat);
IOLOG_DEVEL("KeyboardRepeat::set key:%d flags:0x%x\n", key.get(), flags.get());
} else {
goto cancel;
}
return;
cancel:
cancel();
}
示例11: onKeyButtonPressed
void BerkeliumWidget::onKeyButtonPressed(KeyCode _key, Char _char)
{
if (mWindow != nullptr)
{
InputManager& manager = InputManager::getInstance();
int mod = 0;
if (manager.isControlPressed())
mod |= Berkelium::CONTROL_MOD;
if (manager.isShiftPressed())
mod |= Berkelium::SHIFT_MOD;
mWindow->keyEvent(true, mod, input::ScanCodeToVirtualKey(_key.toValue()), 0);
if (_char != 0)
{
wchar_t text = (wchar_t)_char;
mWindow->textEvent(&text, 1);
}
}
Base::onKeyButtonPressed(_key, _char);
}
示例12: log
// ----------------------------------------
static void log(bool isCaught, EventType eventType, Flags flags, KeyCode key, KeyboardType keyboardType, bool repeat) {
IOLOG_DEBUG("KeyboardEventCallback [%7s]: eventType %2d, flags 0x%08x, key 0x%04x, kbdType %3d, repeat = %d\n",
isCaught ? "caught" : "sending",
eventType.get(), flags.get(), key.get(), keyboardType.get(), repeat);
}
示例13: add
void add(KeyToKeyType::Value type, KeyCode newval) { add(type, BRIDGE_DATATYPE_KEYCODE, newval.get()); }
示例14: retractInput
bool
KeyToKey::remap(RemapParams& remapParams)
{
if (remapParams.isremapped) return false;
if (! fromkeychecker_.isFromKey(remapParams.params.ex_iskeydown, remapParams.params.key, FlagStatus::makeFlags(), fromKey_.key, fromKey_.flags)) return false;
remapParams.isremapped = true;
// ------------------------------------------------------------
// handle EventType & Modifiers
// Let's consider the following setting.
// __KeyToKey__ KeyCode::SHIFT_R, ModifierFlag::SHIFT_R | ModifierFlag::NONE, KeyCode::A, ModifierFlag::SHIFT_R
// In this setting, we need decrease SHIFT_R only once.
// So, we transform values of fromKey_.
//
// [before]
// fromKey_.key : KeyCode::SHIFT_R
// fromKey_.flags : ModifierFlag::SHIFT_R | ModifierFlag::NONE
//
// [after]
// fromKey_.key : KeyCode::SHIFT_R
// fromKey_.flags : ModifierFlag::NONE
//
// Note: we need to apply this transformation after calling fromkeychecker_.isFromKey.
Flags fromFlags = fromKey_.flags;
fromFlags.remove(fromKey_.key.getModifierFlag());
if (remapParams.params.ex_iskeydown) {
retractInput();
} else {
restoreInput();
}
// ----------------------------------------
// Handle beforeKeys_
if (remapParams.params.ex_iskeydown) {
FlagStatus::temporary_decrease(fromFlags);
for (size_t i = 0; i < beforeKeys_.size(); ++i) {
FlagStatus::temporary_increase(beforeKeys_[i].flags);
Flags f = FlagStatus::makeFlags();
KeyboardType keyboardType = remapParams.params.keyboardType;
EventOutputQueue::FireKey::fire_downup(f, beforeKeys_[i].key, keyboardType);
FlagStatus::temporary_decrease(beforeKeys_[i].flags);
}
FlagStatus::temporary_increase(fromFlags);
}
// ----------------------------------------
// Handle toKeys_
switch (toKeys_.size()) {
case 0:
break;
case 1:
{
EventType newEventType = remapParams.params.ex_iskeydown ? EventType::DOWN : EventType::UP;
KeyCode toKey = toKeys_[0].key;
ModifierFlag toModifierFlag = toKey.getModifierFlag();
if (toModifierFlag == ModifierFlag::NONE && ! VirtualKey::isKeyLikeModifier(toKey)) {
// toKey
FlagStatus::temporary_decrease(fromFlags);
FlagStatus::temporary_increase(toKeys_[0].flags);
} else {
// toModifier or VirtualKey::isKeyLikeModifier
if (toModifierFlag != ModifierFlag::NONE) {
newEventType = EventType::MODIFY;
}
if (remapParams.params.ex_iskeydown) {
FlagStatus::increase(toKeys_[0].flags | toModifierFlag);
FlagStatus::decrease(fromFlags);
} else {
FlagStatus::decrease(toKeys_[0].flags | toModifierFlag);
FlagStatus::increase(fromFlags);
}
}
// ----------------------------------------
Params_KeyboardEventCallBack::auto_ptr ptr(Params_KeyboardEventCallBack::alloc(newEventType,
FlagStatus::makeFlags(),
toKey,
remapParams.params.keyboardType,
remapParams.params.repeat));
if (! ptr) return false;
Params_KeyboardEventCallBack& params = *ptr;
if (remapParams.params.ex_iskeydown && ! isRepeatEnabled_) {
KeyboardRepeat::cancel();
} else {
KeyboardRepeat::set(params);
}
EventOutputQueue::FireKey::fire(params);
//.........这里部分代码省略.........
示例15: add
void add(KeyToKeyType::Value type, KeyCode newval) {
add(type, AddDataType(BRIDGE_DATATYPE_KEYCODE), AddValue(newval.get()));
}