e->u.u.type = KeyRelease; SetLockLED (FALSE);
if (e->u.u.type == KeyRelease) return; if (BitIsOn (dev->key->down, lastkey)) { e->u.u.type = KeyRelease; SetLockLED (FALSE); } else SetLockLED (TRUE);
ProcessLK201Input (e, pdev)	register xEvent *e;	DevicePtr pdev;{    register unsigned int   key, bits;    register	      int   idx;    DeviceIntPtr	    dev = (DeviceIntPtr) pdev;    key = e->u.u.detail;    if (key > MAXSPECIAL || (key >= BASEKEY && key < MINSPECIAL))    {	lastkey = key;	idx = key >> 5;	key &= 0x1f;	key = 1 << key;	if (keymodes[idx] & key)	/* an up down type */	{	    if ((keys[idx] ^= key) & key)		e->u.u.type = KeyPress;	    else		e->u.u.type = KeyRelease;	    if (dev->key->modifierMap[lastkey] & LockMask)	    {		if (e->u.u.type == KeyRelease)		    return;		if (BitIsOn (dev->key->down, lastkey))		{		    e->u.u.type = KeyRelease;		    SetLockLED (FALSE);		}		else		    SetLockLED (TRUE);	    }	    (*pdev->processInputProc)(e, dev, 1);	}	else	{	    e->u.u.type = KeyPress;	    (*pdev->processInputProc)(e, dev, 1);	    e->u.u.type = KeyRelease;	    (*pdev->processInputProc)(e, dev, 1);	}    }    else    {	switch (key)	{	    case METRONOME: 		e->u.u.type = KeyPress;		e->u.u.detail = lastkey;		(*pdev->processInputProc)(e, dev, 1);		e->u.u.type = KeyRelease;		(*pdev->processInputProc)(e, dev, 1);		break;	    case ALLUPS: 		idx = 7;		e->u.u.type = KeyRelease;		do		{		    if (bits = keys[idx])		    {			keys[idx] = 0;			key = 0;			do			{			    if (bits & 1)			    {				e->u.u.detail = (idx << 5) | key;				if (!(dev->key->modifierMap[e->u.u.detail] & LockMask))				    (*pdev->processInputProc)(e, dev, 1);			    }			    key++;			} while (bits >>= 1);		    }		} while (--idx >= 0);		break;	    case POWERUP_ERROR: 	    case KEYDOWN_ERROR: 	    case OUTPUT_ERROR: 	    case INPUT_ERROR: 	    /* 	    Warning ("keyboard error");    XXX */		break;	}    }}