📄 x_hil.c
字号:
{ *hil_code = ((info->dev_data)[pending_index] << 8) | (info->dev_data)[pending_index+1]; pending_index += 2; } /* Check if cursor keys are repeating. */ switch (*hil_code) { case DOWN_DOWN_ARROW : case UP_DOWN_ARROW : case UP_LEFT_ARROW : case DOWN_LEFT_ARROW : case UP_RIGHT_ARROW : case DOWN_RIGHT_ARROW : case UP_UP_ARROW : case DOWN_UP_ARROW : last_arrow = *hil_code; break; case REPEAT_ARROW : if ((keyset==HILPRH_KEYSET1) && last_arrow!=REPEAT_ARROW) *hil_code = last_arrow; break; default: break; } if (phys->dev_type == BARCODE) hil_code = ascii_to_code[*hil_code]; for (count=0; (count==0 || *hil_code != 0); count++) {#ifdef XINPUT /* proximity HIL codes cause a different event type. However, proximity is not reported for devices being used as the X pointer, unless they have no buttons (like a touchscreen), in which case the proximity is treated as button 1. */ kcode = ((u_char) *hil_code) >> 1; /* same code up & down*/ kcode += MIN_KEYCODE; /* avoid mouse codes. */ /* Check to see if this is a "down" keycode for a key that is already down. If so, and autorepeat has been disabled for this key, ignore the key and return. */ if (!(*hil_code % 2) && KeyIsDown(dev,kcode) && !KeyIsRepeating(dev,kcode)) return; bcode = *(hil_code++); if ((h->iob & HILIOB_PIO) && kcode == HIL_PROXIMITY) if (dev!=inputInfo.pointer) { type = (bcode & UP_MASK) ? ProximityOut : ProximityIn; ev= format_ev (type, 0, info->timestamp, phys, NULL); return; } else if (h->p_button_count == 0) bcode -= 0x0e; /* make it button 1 */ else return; /* proximity not reported for X pointer */#endif /* XINPUT */ if (bcode >= BUTTON_BASE && bcode < PROXIMITY_IN) { if (phys == hptablet_extension && phys->open_cnt == 0) return; if (dev==inputInfo.pointer) if (bcode & UP_MASK) type = ButtonRelease; else type = ButtonPress; else if (bcode & UP_MASK) type = DeviceButtonRelease; else type = DeviceButtonPress; ev= format_ev (type, kcode, info->timestamp, phys, NULL); process_button (ev, dev, info, bcode, h->p_button_count); } else { if (dev==inputInfo.keyboard) if (bcode & UP_MASK) type = KeyRelease; else type = KeyPress; else if (bcode & UP_MASK) type = DeviceKeyRelease; else type = DeviceKeyPress; ev= format_ev (type, kcode, info->timestamp, phys, NULL); parse_keycode (dev, phys, ev); } } } } }/**************************************************************************** * * process the serial data packet and generate X input events as needed. * */static u_int s_code[2];static void process_serial_data (dev, phys, info) DeviceIntPtr dev; HPInputDevice *phys; struct dev_info *info; { xEvent *ev; int count; u_int *hil_code; u_char type, kcode; int button_count = phys->hil_header.p_button_count; while (pending_index < pending_bytes ) { if (info->poll_hdr & MOTION_DATA) { handle_motion_event (dev, phys, info); } hil_code = s_code; if (phys->hpflags & DATA_IS_8_BITS) *hil_code = (info->dev_data)[pending_index++]; else if (phys->hpflags & DATA_IS_16_BITS) { *hil_code = ((info->dev_data)[pending_index+1] << 8) | (info->dev_data)[pending_index]; pending_index += 2; } else if (phys->hpflags & DATA_IS_32_BITS) { *hil_code = ((info->dev_data)[pending_index+3] << 24) | (info->dev_data)[pending_index+2] << 16 | (info->dev_data)[pending_index+1] << 8 | (info->dev_data)[pending_index]; pending_index += 4; } if (info->poll_hdr & KEY_DATA) { /* Check to see if this is a "down" keycode for a key that is already down. If so, and autorepeat has been disabled for this key, ignore the key and return. */ kcode = (u_char) (*hil_code >> 1); /* same code up & down */ if (*hil_code & UP_MASK) if (dev==inputInfo.keyboard) type = KeyRelease; else type = DeviceKeyRelease; else { if (KeyIsDown(dev,kcode) && !KeyIsRepeating(dev,kcode)) return; if (dev==inputInfo.keyboard) type = KeyPress; else type = DeviceKeyPress; } ev= format_ev (type, kcode, info->timestamp, phys, NULL); parse_keycode (dev, phys, ev); } else if (info->poll_hdr & BUTTON_DATA) { if (*hil_code & UP_MASK) if (dev==inputInfo.pointer) type = ButtonRelease; else type = DeviceButtonRelease; else if (dev==inputInfo.pointer) type = ButtonPress; else type = DeviceButtonPress; kcode = *hil_code + BUTTON_BASE; if (dev==inputInfo.pointer && kcode > PROXIMITY_OUT) return; if (phys == hptablet_extension && phys->open_cnt == 0) return; ev= format_ev (type,kcode,info->timestamp,phys,NULL); process_button (ev, dev, info, kcode, button_count); }#ifdef XINPUT else if (info->poll_hdr & PROXIMITY_DATA) { /* proximity HIL codes cause a different event type. However, proximity is not reported for devices being used as the X pointer, unless they have no buttons (like a touchscreen), in which case the proximity is treated as button 1. */ if (dev!=inputInfo.pointer) { type = (*hil_code & UP_MASK) ? ProximityOut : ProximityIn; ev= format_ev (type, 0, info->timestamp, phys, NULL); return; } else if (button_count == 0) { kcode = 1; /* make it button 1 */ ev= format_ev (type, kcode, info->timestamp, phys, NULL); if (phys == hptablet_extension && phys->open_cnt == 0) return; process_button (ev, dev, info, kcode, button_count); } else return; /* proximity not reported for X pointer */ }#endif /* XINPUT */ } }/******************************************************************* * * handle_motion_event() * */handle_motion_event (dev, phys, info) DeviceIntPtr dev; HPInputDevice *phys; struct dev_info *info; { int i, type, bytes_coord; int tmp, coords[MAX_AXES]; char *sdata; u_char *udata; HPInputDevice *log; if (dev==inputInfo.pointer) { type = MotionNotify; log = hpPointer; } else { type = DeviceMotionNotify; log = phys; } if (phys->hpflags & DATA_IS_32_BITS) bytes_coord = 4; else if (phys->hpflags & DATA_IS_16_BITS) bytes_coord = 2; else bytes_coord = 1; pending_index += phys->hil_header.ax_num * bytes_coord; if (phys->hil_header.flags & HIL_ABSOLUTE) /* absolute device */ { udata = info->dev_data; for (i=0; i < (u_char) phys->hil_header.ax_num; i++, udata+=bytes_coord) if (bytes_coord == 1) coords[i] = *udata; else if (bytes_coord == 2) coords[i] = *udata | *(udata+1) << 8; else if (bytes_coord == 4) coords[i] = *udata | (*(udata+1) << 8) | (*(udata+2) << 16) | (*(udata+3) << 24); if (!check_subset_and_scale (&dev, phys, &log, coords)) return; } else { sdata = (char *) info->dev_data; for (i=0; i < (u_char) phys->hil_header.ax_num; i++, sdata+=bytes_coord) if (bytes_coord == 1) coords[i] = *sdata; else if (bytes_coord == 2) coords[i] = *(sdata+1) << 8 | (*sdata & 0x0ff); else if (bytes_coord == 2) coords[i] = (*(sdata+3) << 24) | ((*(sdata+2) << 16) & 0x0ff)| ((*(sdata+1) << 8) & 0xff) | (*sdata & 0x0ff); } if (phys==hpPointer && axes_changed) { tmp = coords[0]; coords[0] = coords[x_axis]; if (y_axis==0) coords[1] = tmp; else coords[1] = coords[y_axis]; } if (!(phys->hil_header.flags & HIL_ABSOLUTE) && phys->dev_type != NINE_KNOB) coords[1] = -coords[1]; process_motion (dev, phys, log, coords); (void) format_ev (type, 0, info->timestamp, log, &xE); }/******************************************************************* * * check_subset_and_scale() * all we care about is the x and y coordinates. * */staticcheck_subset_and_scale (dev, phys, log, c) DeviceIntPtr *dev; HPInputDevice *phys; HPInputDevice **log; int c[]; { extern u_char screen_change_amt; if (tablet_width) if (c[0]< tablet_xorg || c[0] > tablet_xlimit || c[1]> tablet_yorg || c[1] < tablet_ylimit) { in_tablet_extension = TRUE; *dev = tablet_extension_device; *log = hptablet_extension; } else { in_tablet_extension = FALSE; } if (*log == hpPointer) { if (*dev == screen_change_dev) c[0] = (float) (c[0]-tablet_xorg) * phys->scaleX-screen_change_amt; else c[0] = (float) (c[0]-tablet_xorg) * phys->scaleX; c[1] = (*log)->pScreen->height - ((float) (c[1]-tablet_ylimit) * phys->scaleY); } else { if (*dev == screen_change_dev) c[0] -= screen_change_amt; c[1] = phys->hil_header.size_y - c[1]; /* Y-coord reversed.*/ } if (c[0]==(*log)->coords[0] && c[1]==(*log)->coords[1]) return (FALSE); c[0] -= (*log)->coords[0]; c[1] -= (*log)->coords[1]; return (TRUE); }unsigned char lockcode = CAPSCODE;/**************************************************************************** * * parse_keycode (dev, phys, ev, x_type) * Parse keycode information. * Buttons from a three-button mouse also end up here. * */#if defined(__hpux) || defined(__hp_osf) || defined(hp9000)struct _LedCmd { int on; int off; } LedCmd[] = {{HILP1,HILA1},{HILP2,HILA2},{HILP3,HILA3},{HILP3,HILA3}};#endifint parse_keycode (dev, phys, ev) DeviceIntPtr dev; HPInputDevice *phys; xEvent *ev; {#ifdef XTESTEXT1 extern u_char xtest_command_key; /* defined in xtestext1dd.c */#endif /* XTESTEXT1 */ u_char down_mods; char ioctl_data[12]; if (hpPointer->x_type == KEYBOARD) if (hpKeyboard->hpflags & SECOND_LOGICAL_DEVICE && ((ev->u.keyButtonPointer.pad1==hpKeyboard->dev_id || ev->u.keyButtonPointer.pad1==hpPointer->dev_id ) && move_sprite (dev, hpPointer, ev))) return; else if (ev->u.keyButtonPointer.pad1==hpPointer->dev_id && (move_sprite (dev, hpPointer, ev))) return; /* allow borrow-mode switching on Domain/OS machines */#ifdef __apollo if (ev->u.u.detail==borrow_mode) if ((hpKeyboard->hpflags & SECOND_LOGICAL_DEVICE && (ev->u.keyButtonPointer.pad1==hpKeyboard->dev_id || ev->u.keyButtonPointer.pad1==hpPointer->dev_id)) || ev->u.keyButtonPointer.pad1==hpKeyboard->dev_id) { get_down_modifiers (inputInfo.keyboard->key->down, &down_mods); if ((bw_mods & down_mods) == bw_mods) { extern unsigned char last_code; /* in smd_input.c */ unsigned long timestamp; timestamp = ev->u.keyButtonPointer.time; deallocate_event (ev); /* eat the borrow mode key */ ev = format_ev (KeyRelease, borrow_mode_mods[0]+MIN_KEYCODE, timestamp, phys, NULL); ev = format_ev (KeyRelease, borrow_mode_mods[1]+MIN_KEYCODE, timestamp, phys, NULL); last_code = 0; leave_X(); } }#endif /* __apollo */ /* allow reset only from the X system keyboard, and only if reset is enabled. */ if (ev->u.u.detail==reset && reset_enabled) if ((hpKeyboard->hpflags & SECOND_LOGICAL_DEVICE && (ev->u.keyButtonPointer.pad1==hpKeyboard->dev_id || ev->u.keyButtonPointer.pad1==hpPointer->dev_id)) || ev->u.keyButtonPointer.pad1==hpKeyboard->dev_id) { get_down_modifiers (inputInfo.keyboard->key->down, &down_mods);#ifdef NOT_DONE /* We don't have hp extensions, thus no ResetManager */ if (((rs_mods & down_mods) == rs_mods) && !SendEventToResetManager()) GiveUp(); }#else if ((rs_mods & down_mods) == rs_mods) GiveUp(); }#endif#if defined(__hpux) || defined(__hp_osf) || defined(hp9000) /* Special case handling for the Caps Lock modifier and LED. If a key is pressed that is bound to the Lock modifier, turn on the Caps Lock LED and treat the key as latched. However, do this only if a client has not overridden the default use of the Caps Lock LED via the HPConfigureInput protocol request. */ if (IsLockKey(dev, ev->u.u.detail)) /* lock modifier pressed */ { if (ev->u.u.detail != lockcode) /* was changed by xmodmap*/ { UnlatchKey(phys, lockcode); LatchKey(phys, ev->u.u.detail); lockcode = ev->u.u.detail; } } else if (ev->u.u.detail == lockcode) /* is former lock modifier */ { UnlatchKey(phys, lockcode); lockcode = 0xff; } if (KeyIsLatched(phys, ev->u.u.detail)) if (KeyIsIgnored(phys,ev->u.u.detail)) { if (KeyDownEvent(ev)) UnignoreKey(phys,ev->u.u.detail); deallocate_event (ev); return; } else if (KeyDownEvent(ev)) IgnoreKey(phys,ev->u.u.detail); if (DeviceHasLeds(phys) && KeyHasLed(dev,phys,ev->u.u.detail)) if (KeyUpEvent(ev)) LedOff(dev, phys, ev->u.u.detail, ioctl_data); else LedOn(dev, phys, ev->u.u.detail, ioctl_data);#endif /* __hpux */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -