if (ptrPriv != NULL) { if (fe->type == WSCONS_EVENT_KEY_UP) { if (keycode == MOUSE_EMUL_KEY) { pPriv->bkeydown = 0; skipKeyEvent = 1;  if (!ptrPriv->ebdown && ptrPriv->bemask) { xEvent xbE; int button;  xbE.u.u.type = ButtonRelease; while ((button = ffs(ptrPriv->bemask) - 1) > 0) { ptrPriv->bemask &= ~(1 << button); xbE.u.u.detail = button; mieqEnqueue (&xbE); } } } else if (MOUSE_EMUL_KEY1 <= keycode && keycode <= MOUSE_EMUL_KEY5) { int button = keycode - 0x0a + 1; int bmask = 1 << button;  if (pPriv->bkeynrmask & bmask) skipKeyEvent = 1;  pPriv->bkeymask &= ~bmask;  if (pPriv->bkeydown && ptrPriv->ebdown) { ptrPriv->bemask &= ~bmask;  if (!(ptrPriv->brmask & bmask)) { xEvent xbE;  xbE.u.u.type = ButtonRelease; xbE.u.u.detail = button; mieqEnqueue (&xbE); } } } } else {  if (keycode == MOUSE_EMUL_KEY) { pPriv->bkeydown = 1; skipKeyEvent = 1;  if (ptrPriv->ebdown && pPriv->bkeymask) { xEvent xbE; int button;  xbE.u.u.type = ButtonPress; while ((button = ffs(pPriv->bkeymask & ~ptrPriv->bemask) - 1) > 0) { ptrPriv->bemask &= ~(1 << button); xbE.u.u.detail = button; mieqEnqueue (&xbE); } } } else if (MOUSE_EMUL_KEY1 <= keycode && keycode <= MOUSE_EMUL_KEY5) { int button = keycode - 0x0a + 1; int bmask = 1 << button;  if (pPriv->bkeydown) { pPriv->bkeynrmask |= bmask; pPriv->bkeymask |= bmask; skipKeyEvent = 1;  if (ptrPriv->ebdown && !(ptrPriv->bemask & bmask)) { ptrPriv->bemask |= bmask; if (!(ptrPriv->brmask & bmask)) { xEvent xbE;  xbE.u.u.type = ButtonPress; xbE.u.u.detail = button; mieqEnqueue (&xbE); } } } else if (pPriv->bkeynrmask & bmask) pPriv->bkeynrmask &= ~bmask; } }  if (skipKeyEvent) return;  }
hpcKbdEnqueueEvent (device, fe)    DeviceIntPtr  device;    hpcEvent	  *fe;{    xEvent		xE;    BYTE		keycode;    CARD8		keyModifiers;    keycode = (fe->value & 0xff) + MIN_KEYCODE;    keyModifiers = device->key->modifierMap[keycode];#if 0 /* XXX */#ifdef XKB    if (noXkbExtension) {#endif    if (autoRepeatKeyDown && (keyModifiers == 0) &&	((fe->value == VKEY_DOWN) || (keycode == autoRepeatEvent.u.u.detail))) {	/*	 * Kill AutoRepeater on any real non-modifier key down, or auto key up	 */	autoRepeatKeyDown = 0;    }#ifdef XKB    }#endif#endif /* 0 XXX */    xE.u.keyButtonPointer.time = TSTOMILLI(fe->time);    xE.u.u.type = ((fe->type == WSCONS_EVENT_KEY_UP) ? KeyRelease : KeyPress);    xE.u.u.detail = keycode;#if 0 /* XXX */#ifdef XKB    if (noXkbExtension) {#endif    if (DoSpecialKeys(device, &xE, fe))	return;#ifdef XKB    }#endif /* ! XKB */#endif /* 0 XXX */    mieqEnqueue (&xE);}