Пример #1
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();
	}
}
Пример #2
0
/*
 * shift key press / relea
 */
LOCAL void ieShift( InnerEvent *evt )
{
	ShiftKeyKind	shift;
	KpMetaBut	*meta = (KpMetaBut*)&kpMgrInfo.kpState.stat;
	BOOL		chg = FALSE;

	if ( evt->type == IE_S_PRESS ) {
                /* set press status (press) */
		kpMgrInfo.spress |= evt->i.sft.kind;
	} else {
                /* set press status (release) */
		kpMgrInfo.spress &= ~evt->i.sft.kind;

                /* switch temporary shift or simple lock modes */
		chg = kpChangeShiftLock(evt->type, evt->i.sft.kind);
	}

        /* shift status */
	shift = meta->u.tmpShift | meta->u.shiftLock | kpMgrInfo.spress;

	if ( shift != meta->u.shift || chg ) {

                /* change shift status */
		meta->u.shift = shift;

                /* notify meta key status change event */
		kpNotifyMetaEvent();
	}
}
Пример #3
0
/*
 * PD button up / down, move
 */
LOCAL void iePd( InnerEvent *evt )
{
	InnEvtType	type = evt->type;
	TDEvtTyp	devEvt = 0;
	BOOL		qpress = FALSE;
	UW		nodsp;

	if ( (type & IE_PDMOVE) != 0 ) {
                /* move */
		devEvt = kpPdMoveEvent(evt);
	}
	if ( (type & IE_PDBUT) != 0 ) {
                /* button change */
		devEvt = kpPdButEvent(evt);

                /* is this a quick press? */
		qpress = ( (type & IE_MBUT) == IE_MBUTDOWN
				&& evt->i.pd.stat.o.qpress
				&& kpMgrInfo.pd.pdMode.attr.qpress );
	}

	if ( devEvt != 0 ) {
                /* notify PD event */
		kpNotifyPdEvent(devEvt, nodsp = evt->i.pd.stat.o.nodsp);

		if ( qpress ) {
                        /* quickpress */
			kpMgrInfo.kpState.stat.main = 0;
			kpNotifyPdEvent(TDE_PDBUT, nodsp);

			kpMgrInfo.kpState.stat.main = 1;
			kpNotifyPdEvent(TDE_PDBUT, nodsp);
		}

                /* switch temporary shift or simple lock modes */
		if ( kpChangeShiftLock(evt->type, NoShift) ) {
                        /* notify meta key status change event */
			kpNotifyMetaEvent();
		}
	}
}
Пример #4
0
/*
 * lock key down
 *      if a code is processed as lock key, then return TRUE
 */
LOCAL BOOL lockKeyDown( UH code )
{
	InputMode	mode;
	UW		meta;
	BOOL		chgLED;
	union {
		MetaBut	stat;
		UW	uw;
	} u;

	mode = kpMgrInfo.kpState.stat.mode;
	u.stat = kpMgrInfo.kpState.stat;
	meta = u.uw;

	switch ( code ) {
	  case KC_EIJI:	/* English <-> Japanese swap */
		mode ^= AlphaMode;
		break;
	  case KC_CAPN:	/* Hiragana <-> Katakana swap */
		mode ^= KataMode;
		break;
	  case KC_JPN0_Z: /* Japanese Hiragana & Zenkaku */
		meta &= ~ES_HAN;
	  case KC_JPN0:	/* Japanese Hiragana */
		mode = HiraMode;
		break;
	  case KC_JPN1_Z: /* Japanese Katakana & Zenkaku */
		meta &= ~ES_HAN;
	  case KC_JPN1:	/* Japanese Katanaka */
		mode = KataMode;
		break;
	  case KC_ENG0_H: /* English & Hankaku */
		meta |= ES_HAN;
	  case KC_ENG0:	/* English */
		mode = AlphaMode;
		break;
	  case KC_ENG1_H: /* English CAPS & Hanaku */
		meta |= ES_HAN;
	  case KC_ENG1:	/* English CAPS */
		mode = CapsMode;
		break;
	  case KC_ENGALT:	/* -> English <--> English CAPS */
		if (mode & AlphaMode) mode ^= KataMode;
		else	mode = AlphaMode;
		break;
	  case KC_JPNALT:	/* ->Hiragana<-->Katakana */
		if (mode & AlphaMode) mode = HiraMode;
		else	mode ^= KataMode;
		break;

	  case KC_KBSEL:	/* Kana <--> Roman Input */
		meta ^= ES_KBSEL;
		break;
	  case KC_HAN:		/* Zenkaku <--> Hankaku */
		meta ^= ES_HAN;
		break;
	  default:
                /* not a lock key */
		return FALSE;
	}

	if ( (chgLED = ( mode != kpMgrInfo.kpState.stat.mode ))
	  || meta != u.uw ) {

                /* change input mode */
		u.uw = meta;
		kpMgrInfo.kpState.stat = u.stat;
		kpMgrInfo.kpState.stat.mode = mode;

		if ( chgLED ) {
                        /* change keyboard LED */
			kpChangeKbInputMode(mode);
		}

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

	return TRUE;
}
Пример #5
0
/*
 * set meta key / button status (DN_KPMETABUT)
 */
LOCAL ER setKpMetaBut( MetaBut meta[2] )
{
const	UW	KBMET =	ES_ALPH|ES_KANA
			|ES_LSHFT|ES_RSHFT|ES_EXT|ES_CMD
			|ES_LLSHFT|ES_LRSHFT|ES_LEXT|ES_LCMD
			|ES_TLSHFT|ES_TRSHFT|ES_TEXT|ES_TCMD
			|ES_HAN|ES_KBSEL;
const	UW	PDBUT =	ES_BUT|ES_BUT2;
const	UW	PDMOV =	ES_NODSP;
const	UW	PDSIM =	ES_PDSIM;
	UW	stat, chg;
	ER	err, error = E_OK;
	union {
		MetaBut	stat;
		UW	uw;
	} u;

	u.stat = kpMgrInfo.kpState.stat;
	stat = (u.uw & *(UW*)&meta[0]) | *(UW*)&meta[1];
	chg = stat ^ u.uw;

	if ( (chg & KBMET) != 0 ) {
                /* change meta key status */
		u.stat = kpMgrInfo.kpState.stat;
		u.uw ^= chg & KBMET;
		kpMgrInfo.kpState.stat = u.stat;

		if ( (chg & (ES_ALPH|ES_KANA)) != 0 ) {
                        /* change keyboard LED */
			err = kpChangeKbInputMode(kpMgrInfo.kpState.stat.mode);
			if ( err < E_OK ) error = err;
		}

		err = kpNotifyMetaEvent();
		if ( err < E_OK ) error = err;
	}

	if ( (chg & (PDBUT|PDMOV)) != 0 ) {
                /* change PD status */
		u.stat = kpMgrInfo.kpState.stat;
		u.uw ^= chg & (PDBUT|PDMOV);
		kpMgrInfo.kpState.stat = u.stat;

		err = kpNotifyPdEvent(
			( (chg & PDBUT) != 0 )? DE_PDBUT: DE_PDMOVE,
			kpMgrInfo.kpState.stat.nodsp);
		if ( err < E_OK ) error = err;
	}

	if ( (chg & PDSIM) != 0 ) {
                /* change PD simulation status */
		u.stat = kpMgrInfo.kpState.stat;
		u.uw ^= chg & PDSIM;
		kpMgrInfo.kpState.stat = u.stat;

		err = kpNotifyPdEvent(DE_PDSTATE,
			kpMgrInfo.kpState.stat.nodsp);
		if ( err < E_OK ) error = err;
	}

	return error;
}