bool TouchKeyboard::getKeyCode(uint8_t &keyCode, MetaKeys &metaKeys, bool wait, Point &pressPt, bool returnMeta)
{
	uint8_t scanCode;
	bool result;
	do
	{
		result = getScanCode(scanCode, wait, pressPt);
		if (result)
		{
			if (scanCode > sizeof(scanCodeToVK) - 1)
				return false;
			keyCode = pgm_read_byte_near(&scanCodeToVK[scanCode]);
			if (isMetaKey(keyCode))
			{
				switch (keyCode)
				{
					case VK_CONTROL: toggleMetaKeyState(mkCtrl); break;
					case VK_ALT: toggleMetaKeyState(mkAlt); break;
					case VK_SHIFT: toggleMetaKeyState(mkShift); break;
					case VK_CAPITAL: toggleMetaKeyState(mkCaps); break;
				}
			} else break;
		} else break;
	} while (!returnMeta && isMetaKey(keyCode));
	metaKeys = _metaKeys;
	if (result && !returnMeta)
		clearMetaState();
	return result;
}
Exemple #2
0
/*
 * key up
 */
LOCAL void ieKeyUp( InnerEvent *evt, TMO *tmout )
{
	KeyEvt		keyEvt;
	UH		code;

        /* convert to character code */
	code = kpToKeycode(evt->i.key.keytop, &evt->i.key.meta);

        /* lock key needs no processing */
	if ( isMetaKey(code) ) goto skip;

        /* PD simulation processing */
	if ( kpExecPdSimKeyUp(evt, code, tmout) ) {
                /* process PD simulation only */
		goto skip;
	}

        /* notify key up event */
	keyEvt.h.evttyp = TDE_KEYUP;
	keyEvt.keytop = kpKeyTopCode(evt->i.key.keytop,
				evt->i.key.meta.o.kbsel);
	keyEvt.code = code;
	keyEvt.stat = evt->i.key.meta.o;
	kpNotifyEvent(&keyEvt, sizeof(keyEvt));

skip:
        /* switch temporary shift or simple lock modes */
	if ( kpChangeShiftLock(evt->type, NoShift) ) {

                /* notify meta key status change event */
		kpNotifyMetaEvent();
	}
}