// ----------------------------------------------------------------------------- // CTestSDKCFD::TestEHKEYConstructFromResourceL // ----------------------------------------------------------------------------- // TInt CTestSDKEIKHKEYT::TestEHKEYConstructFromResourceL( CStifItemParser& /*aItem*/ ) { CEikHotKeyTable* hotkeytableptr = new( ELeave ) CEikHotKeyTable; CleanupStack::PushL( hotkeytableptr ); hotkeytableptr->ConstructFromResourceL( R_TEST_HOTKEYS ); TResourceReader reader; CCoeEnv::Static()->CreateResourceReaderLC(reader,R_TEST_HOTKEYS); TInt numberPlain( KZero ); numberPlain = reader.ReadInt16(); if( numberPlain ) { const SEikHotKey* ptr=(const SEikHotKey*)reader.Ptr(); reader.Advance(numberPlain*sizeof(SEikHotKey)); TBool flag(EFalse); TInt keycode( KZero ); TInt commandId( KZero ); TInt modifires( KZero ); commandId = ptr->iCommandId; flag = hotkeytableptr->HotKeyFromCommandId( commandId, keycode, modifires ); STIF_ASSERT_TRUE( flag ); } TInt numberCtrl( KZero ); numberCtrl = reader.ReadInt16(); if( numberCtrl ) { const SEikHotKey* ptr=(const SEikHotKey*)reader.Ptr(); reader.Advance(numberCtrl*sizeof(SEikHotKey)); TBool flag(EFalse); TInt keycode( KZero ); TInt commandId( KZero ); TInt modifires(EModifierCtrl); commandId = ptr->iCommandId; flag = hotkeytableptr->HotKeyFromCommandId( commandId, keycode, modifires ); STIF_ASSERT_TRUE( flag ); } TInt numberShiftCtrl( KZero ); numberShiftCtrl = reader.ReadInt16(); if( numberShiftCtrl ) { const SEikHotKey* ptr=(const SEikHotKey*)reader.Ptr(); reader.Advance(numberShiftCtrl*sizeof(SEikHotKey)); TBool flag(EFalse); TInt keycode( KZero ); TInt commandId( KZero ); TInt modifires(EModifierShift|EModifierCtrl); commandId = ptr->iCommandId; flag = hotkeytableptr->HotKeyFromCommandId( commandId, keycode, modifires ); STIF_ASSERT_TRUE( flag ); } CleanupStack::PopAndDestroy( KTwo );//reader, hotkeytableptr return KErrNone; }
// ----------------------------------------------------------------------------- // CTestSDKCFD::TestEHKEYRemoveItem // ----------------------------------------------------------------------------- // TInt CTestSDKEIKHKEYT::TestEHKEYRemoveItemL( CStifItemParser& /*aItem*/ ) { CEikHotKeyTable* hotkeytableptr = new( ELeave ) CEikHotKeyTable; CleanupStack::PushL( hotkeytableptr ); TInt commandId( KOne ); TInt keycode( KTwo ); TInt modifiers( KZero ); hotkeytableptr->AddItemL( commandId, keycode, modifiers ); TBool flag; TInt returnkeycode; TInt returncommandId; flag = hotkeytableptr->HotKeyFromCommandId( commandId, returnkeycode, modifiers ); returncommandId = hotkeytableptr->CommandIdFromHotKey( keycode, modifiers ); STIF_ASSERT_TRUE( flag ); STIF_ASSERT_EQUALS( keycode, returnkeycode ); STIF_ASSERT_EQUALS( commandId, returncommandId ); hotkeytableptr->RemoveItem( commandId ); returnkeycode = 0; flag = hotkeytableptr->HotKeyFromCommandId( commandId, returnkeycode, modifiers ); returncommandId = hotkeytableptr->CommandIdFromHotKey( keycode, modifiers ); STIF_ASSERT_FALSE( flag ); STIF_ASSERT_NOT_EQUALS( keycode, returnkeycode ); STIF_ASSERT_NOT_EQUALS( commandId, returncommandId ); CleanupStack::PopAndDestroy( hotkeytableptr ); return KErrNone; }
// ----------------------------------------------------------------------------- // CTestSDKCFD::TestEHKEYHotKeyFromCommandId // ----------------------------------------------------------------------------- // TInt CTestSDKEIKHKEYT::TestEHKEYHotKeyFromCommandIdL( CStifItemParser& /*aItem*/ ) { CEikHotKeyTable* hotkeytableptr; hotkeytableptr = new( ELeave ) CEikHotKeyTable; CleanupStack::PushL( hotkeytableptr ); TInt commandId( KOne ); TInt keycode( KTwo ); TInt modifiers( KZero ); hotkeytableptr->AddItemL( commandId, keycode, modifiers ); TInt commandId2( KTwo ); TInt keycode2( KThree ); TInt modifiers2( KZero ); hotkeytableptr->AddItemL( commandId2, keycode2, modifiers2 ); TInt returnkeycode; TInt returnkeycode2; TBool flag; TBool flag2; flag = hotkeytableptr->HotKeyFromCommandId( commandId, returnkeycode, modifiers ); STIF_ASSERT_TRUE( flag ); flag2 = hotkeytableptr->HotKeyFromCommandId( commandId2, returnkeycode2, modifiers2 ); STIF_ASSERT_TRUE( flag2 ); STIF_ASSERT_NOT_EQUALS( returnkeycode, returnkeycode2 ); CleanupStack::PopAndDestroy( hotkeytableptr ); return KErrNone; }
// ----------------------------------------------------------------------------- // CTestSDKCFD::TestEHKEYCommandIdFromHotKey // ----------------------------------------------------------------------------- // TInt CTestSDKEIKHKEYT::TestEHKEYCommandIdFromHotKeyL( CStifItemParser& /*aItem*/ ) { CEikHotKeyTable* hotkeytableptr = new( ELeave ) CEikHotKeyTable; CleanupStack::PushL( hotkeytableptr ); TInt commandId( KOne); TInt keycode( KTwo ); TInt modifiers( KZero ); hotkeytableptr->AddItemL( commandId, keycode, modifiers ); TInt commandId2( KTwo ); TInt keycode2( KThree ); TInt modifiers2( KZero ); hotkeytableptr->AddItemL( commandId2, keycode2, modifiers2 ); TInt returncommandId; TInt returncommandId2; returncommandId = hotkeytableptr->CommandIdFromHotKey( keycode, modifiers ); returncommandId2 = hotkeytableptr->CommandIdFromHotKey( keycode2, modifiers2 ); STIF_ASSERT_NOT_EQUALS( returncommandId, returncommandId2 ); CleanupStack::PopAndDestroy( hotkeytableptr ); return KErrNone; }
/*! Returns true if this QDeviceButton is equal to \a e. */ bool QDeviceButton::operator==(const QDeviceButton &e) const { return ((keycode() == e.keycode()) && (userText() == e.userText()) && (context() == e.context()) && (pressedAction() == e.pressedAction()) && (heldAction() == e.heldAction()) && (releasedAction() == e.releasedAction())); }
static void AppendShortcutToMenuOption( wxMenuItem& item, const char* id ) { // this is NOT how a dictionary works but it has like 30 entries so this should still perform okay auto* dict = &wxGetApp().GlobalAccels; for ( auto it = ( *dict )->begin(); it != ( *dict )->end(); ++it ) { if ( strcmp( it->second->Id, id ) == 0 ) { wxString text = item.GetItemLabel(); size_t tabPos = text.rfind( L'\t' ); KeyAcceleratorCode keycode( (wxKeyCode)it->first ); item.SetItemLabel( text.Mid( 0, tabPos ) + L"\t" + keycode.ToString() ); } } }
bool VirtualKey::VK_DEFINED_IN_USERSPACE::handleAfterEnqueued(const Params_KeyboardEventCallBack& params) { for (size_t i = 0; i < items_.size(); ++i) { RemapClass* remapclass = items_[i].remapclass; KeyCode keycode(items_[i].keycode); uint32_t notification_type = items_[i].notification_type; if (!remapclass) return false; if (params.key == keycode) { if (params.ex_iskeydown && params.repeat == false) { org_pqrs_driver_Karabiner_UserClient_kext::send_notification_to_userspace(notification_type, params.key.get()); } return true; } } return false; }
static Key* getkey(const char *name) { Key *k, *r; char buf[128]; char *seq[8]; char *kstr; int mask; uint i, toks; static ushort id = 1; r = nil; if((k = name2key(name))) { ungrabkey(k); return k; } utflcpy(buf, name, sizeof buf); toks = tokenize(seq, 8, buf, ','); for(i = 0; i < toks; i++) { if(!k) r = k = emallocz(sizeof *k); else { k->next = emallocz(sizeof *k); k = k->next; } utflcpy(k->name, name, sizeof k->name); if(parsekey(seq[i], &mask, &kstr)) { k->key = keycode(kstr); k->mod = mask; } if(k->key == 0) { freekey(r); return nil; } } if(r) { r->id = id++; r->lnext = key; key = r; } return r; }