📄 x_hil.c
字号:
break; } getPrivScreenPtr(pScreen)->CursorOff(pScreen); pScreen = log->pScreen; screen_was_changed = TRUE; set_scale_and_screen_change (log); getPrivScreenPtr(pScreen)->ChangeScreen(pScreen); if (phys == hptablet_extension) { tx = phys->coords[0] < tablet_xorg ? 0 : pScreen->width; ty = (float) phys->coords[1] * phys->scaleY; NewCurrentScreen(pScreen, tx, ty); } else NewCurrentScreen(pScreen, log->coords[0], log->coords[1]); hpActiveScreen = pScreen->myNum; if (dev->grab && dev->grab->cursor) pScreen->DisplayCursor(pScreen,dev->grab->cursor); else if (!(pRootWin = WindowTable[pScreen->myNum])) pScreen->DisplayCursor(pScreen,(CursorPtr) NULL); else pScreen->DisplayCursor(pScreen,pRootWin->optional->cursor); }#endif /* __hpux || __hp_osf *//**************************************************************************** * * move_mouse () * move the sprite, if the device is the pointer. * Also move it if some other device is sending MotionNotify events. * In any case, send a motion event to dix. * * This routine may also be called from xtest1dd.c * */staticmove_mouse (log, event_time) HPInputDevice *log; /* logical device */ int event_time; /* event timestamp */ { int i; int id = log->dev_id; int axes = log->hil_header.ax_num; #if defined(__hpux) || defined(__hp_osf) || defined(hp9000) register hpPrivScreenPtr phpPriv = getPrivScreenPtr(log->pScreen); if (log == hpPointer)#ifdef SPECIAL_68K_OSF miPointerMoveCursor(log->pScreen, log->coords[0], log->coords[1], 1);#else (*phpPriv->MoveMouse) (log->pScreen, log->coords[0], log->coords[1], 1);#endif#endif /* __hpux */#ifdef __apollo if (log == hpPointer) { xshScreenPrivPtr pScreenPriv; pScreenPriv = XSH_SCREEN_PRIV (log->pScreen); (*pScreenPriv->MoveCursor) (pScreenPriv,log->coords[0],log->coords[1]);#ifdef XTESTEXT1 if (on_steal_input) check_for_motion_steal (log->coords[0], log->coords[1]);#endif /* XTESTEXT1 */ }#endif /* __apollo */ *dpmotionBuf[id]++ = event_time; for (i=0; i<axes; i++) *dpmotionBuf[id]++ = log->coords[i]; if((dheadmotionBuf[id] + 100 * (axes+1)) == dpmotionBuf[id]) dpmotionBuf[id] = dheadmotionBuf[id]; }/************************************************************************** * * Called by: hpMouseProc during device initialization, process_motion * whenever we change screens. * * This routine sets the scaling factor to be used for absolute pointing * devices like graphics tablets. Input from these devices is scaled to * the screen size. If we have a multi-screen environment, the scaling * factor must be changed whenever the screen changes. * * This routine also sets the margin at the screen edge that will be used * to change screens. For tablets, this is initially 0, allowing the * entire tablet surface to be used by the application. If a tablet is * the X pointer and a multi-screen environment is being used, the * screen_change_amt variable should be initialized to some value (like 30) * to define a area at the tablet edges that will cause the screen to change. * * Tablet subsetting adds more complications. The user can define a subset * area that used as the X pointer, while the remainder of the tablet surface * is treated as a second logical device. It is this second logical device * that controls screen changes. * */set_scale_and_screen_change (d) HPInputDevice *d; { int tmp, resx_mm, resy_mm; /* Absolute device: graphics tablet or touchscreen */ if (d->hil_header.flags & HIL_ABSOLUTE) { resx_mm = d->hil_header.resx / 1000; resy_mm = d->hil_header.resy / 1000; /* Tablet subsetting enabled and this is the pointer region. This is called only during initialization, since when we change screens, the device is the second logical device. */ if (tablet_width && d->dev_id == inputInfo.pointer->id) { tablet_xorg = tablet_xorigin * resx_mm; tablet_xlimit = tablet_xorg + tablet_width * resx_mm; tmp = d->hil_header.size_y - (tablet_yorigin * resy_mm); tablet_yorg = tmp > 0 ? tmp : 0; tmp = tablet_yorg - (tablet_height * resy_mm); if (tmp > 0) tablet_ylimit = tmp; else { tablet_ylimit = 0; tablet_height = tablet_yorg / resy_mm; } d->scaleX = ((float) d->pScreen->width) / ((float)tablet_width * resx_mm ); d->scaleY = ((float) d->pScreen->height) / ((float)tablet_height * resy_mm ); d->change_xmin = 0; d->change_xmax = d->pScreen->width; d->change_amt = 0; } else /* This code is called if we are initializing the second logical device, or if tablet subsetting is not enabled. It is also called when we are changing screens with a tablet as the X pointer device. */ { /* Set scale for the case where the tablet is the X pointer. The scale is also returned to clients via XHPListInputDevices. */ d->scaleX = ((float) (d->pScreen->width+2*screen_change_amt)) / ((float)d->hil_header.size_x); d->scaleY = ((float)d->pScreen->height) / ((float)d->hil_header.size_y); if (tablet_width) { /* If this is the second logical device, we must also change the scale of the X pointer. Since input from absolute extension devices is not scaled, the screen change amounts units are tablet counts. */ hpPointer->scaleX = ((float) d->pScreen->width) / ((float)tablet_width * resx_mm ); hpPointer->scaleY = ((float) d->pScreen->height) / ((float)tablet_height * resy_mm ); d->change_xmin = resx_mm * screen_change_amt; d->change_xmax = d->hil_header.size_x - d->change_xmin; d->change_ymin = resy_mm * screen_change_amt; d->change_ymax = d->hil_header.size_y - d->change_xmin; d->change_amt = 0; } else /* The tablet is the X pointer. Screen change units are in pixels, since the input will be scaled. */ { d->change_xmin = 1; d->change_xmax = d->pScreen->width - 2; d->change_ymin = 1; d->change_ymax = d->pScreen->height - 2; d->change_amt = 0; } } } else /* This code is called when a relative device is initialized, and when we are changing screens with a relative device. These devices (mice, trackballs, dialboxes, spaceballs) cause us to change screens by generating values that are beyond the edge of the screen. */ { d->change_xmin = 0; d->change_xmax = d->pScreen->width; d->change_ymin = 0; d->change_ymax = d->pScreen->height; d->change_amt = screen_change_amt; } }/**************************************************************************** * * queue_motion_event () * This is a convenience routine for xosSetCursorPosition. * It is used to artifically generate a motion event when WarpPointer * request is made. * */queue_motion_event (dev_p) HPInputDevice *dev_p; { int coords[MAX_AXES]; extern TimeStamp currentTime; coords[0] = 0; coords[1] = 0; process_motion (inputInfo.pointer, dev_p, dev_p, coords); (void) format_ev (MotionNotify, 0, currentTime.milliseconds, dev_p, NULL); xE.b.u.u.type = 0; }/**************************************************************************** * * format_ev ( ) * format one or more key, button, motion or proximity xEvents. * This routine assumes devices have less than 6 axes, or report only * one axis per event. */#define AXES_PER_EVENT 6xEvent *format_ev (type, detail, event_time, log, event) u_char type; u_char detail; unsigned int event_time; HPInputDevice *log; xHPEvent *event; { int i, j; int n_axes = log->hil_header.ax_num; INT32 *ip; xEvent *ret = NULL; for (i=0; i<=n_axes/AXES_PER_EVENT; i++) { if (event==NULL) { if (xE.b.u.u.type != 0) /* we have a previous motion event */ { event = allocate_event();/* queue it before the new event */ *event = xE; xE.b.u.u.type = 0; } event = allocate_event(); } if (!ret) ret = (xEvent *) event; event->b.u.u.type = type; event->b.u.u.detail = detail; event->b.u.keyButtonPointer.time = event_time; event->b.u.keyButtonPointer.rootX = hpPointer->coords[0]; event->b.u.keyButtonPointer.rootY = hpPointer->coords[1]; event->b.u.keyButtonPointer.pad1 = log->dev_id;#ifdef XINPUT if (type >= FIRST_EXTENSION_EVENT) { event->b.u.keyButtonPointer.pad1 |= MORE_EVENTS; event->x.type = DeviceValuator; event->x.deviceid = log->dev_id; if (log->hpflags & NON_CONTIGUOUS_DATA) for (j=0; j < (u_char) log->hil_header.ax_num; j++) { if (log->coords[j]!=0) { event->x.num_valuators = 1; event->x.first_valuator = j; event->x.valuator0 = log->coords[j]; return (ret); } } else { event->x.num_valuators = log->hil_header.ax_num; event->x.first_valuator = 0; ip = &event->x.valuator0; for (j=0; j<6; j++) if ( i < (u_char) log->hil_header.ax_num) *ip++ = log->coords[j]; else *ip++ = 0; } }#endif /* XINPUT */ } return (ret); }/******************************************************************** * * ProcessInputEvents() * This routine is invoked from the dispatcher to route events. * It invokes the dix routines to do this. * */#define CLICK_VOICE 2ProcessInputEvents() { int click, id, i; INT32 *ip; int count; xHPEvent *event; DeviceIntPtr dev; Bool checkedscreensave = FALSE;#if defined(__hp_osf) if (hil_qp->hil_evqueue.head != hil_qp->hil_evqueue.tail) read_shmhil();#endif /* __hp_osf */ while ( events_queue->head != events_queue->tail) { if (!checkedscreensave) { if (screenIsSaved==SCREEN_SAVER_ON && !display_borrowed) SaveScreens (SCREEN_SAVER_OFF, ScreenSaverReset); checkedscreensave = TRUE; } event = &((events_queue->events)[(events_queue->head)]); switch (event->b.u.u.type) { case KeyPress: if (keyboard_click) beep(CLICK_VOICE,800,keyboard_click,1); case KeyRelease: dev = (DeviceIntPtr) LookupKeyboardDevice (); (*dev->public.processInputProc) (event, dev, 1); break; case ButtonPress: case ButtonRelease: case MotionNotify: dev = (DeviceIntPtr) LookupPointerDevice (); (*dev->public.processInputProc) (event, dev, 1); break; default:#ifdef XINPUT id = event->b.u.keyButtonPointer.pad1 & DEVICE_BITS; if (!(event->b.u.keyButtonPointer.pad1 & MORE_EVENTS)) count=1; else count=2; dev = LookupDeviceIntRec (id); if (dev == NULL) break; if (event->b.u.u.type == DeviceKeyPress) { if (dev->kbdfeed) click = (int)((double)(dev->kbdfeed->ctrl.click) * 15.0 / 100.0); if (click) beep(CLICK_VOICE,800,click,1); } else if (event->b.u.u.type == DeviceMotionNotify) { ip = &event->x.valuator0; for (i=0; i < (u_char) event->x.num_valuators; i++) dev->valuator->axisVal[i] = *(ip+i); } (*dev->public.processInputProc) (event, dev, count);#endif /* XINPUT */ break; } if (events_queue->head == WR_EVENTS) events_queue->head = 0; else events_queue->head++; } queue_events_free = WR_EVENTS; }#ifdef __hp_osf/****************************************************************** * * This routine removes data from the HIL shared memory event queue, * and processes it through the server ddx input event processing code. * */#define NONDATA_BYTES 7#define MAXNAMLEN 255read_shmhil() { int i, head; char dev_name[MAXNAMLEN]; u_char *buf; DeviceIntPtr dev; void process_hil_data(); xHPEvent *xHP; while (hil_qp->hil_evqueue.head != hil_qp->hil_evqueue.tail) { head = hil_qp->hil_evqueue.head; sprintf (dev_name, "/dev/hil%d", hil_qp->hil_event[head].dev); for (i=0; i<MAX_LOGICAL_DEVS; i++) if (strcmp (l_devs[i].dev_name, dev_name) == 0) break; if (i==MAX_LOGICAL_DEVS) FatalError ("Can't find input device %s\n queue head = %d\n queue tail = %d\n event timestamp = 0x%x\n event pollheader = 0x%x\n event size = %d\n", dev_name, head,hil_qp->hil_evqueue.tail, hil_qp->hil_event[head].tstamp, hil_qp->hil_event[head].poll_hdr, hil_qp->hil_event[head].size); dev = find_deviceintrec (&l_devs[i]); buf = (u_char *) &hil_qp->hil_event[head].tstamp; hil_info.timestamp = ((*buf & 0x0ff) << 24) | ((*(buf+1) & 0x0ff) << 16) | ((*(buf+2) & 0x0ff) << 8) | ( *(buf+3) & 0x0ff); hil_info.timestamp = (hil_info.timestamp - 1) * 10; hil_info.poll_hdr = hil_qp->hil_event[head].poll_hdr & HIL_POLL_HDR_BITS; pending_bytes = hil_qp->hil_event[head].size - NONDATA_BYTES; pending_index = 0; for (i=0; i < pending_bytes; i++) hil_info.dev_data[i] = hil_qp->hil_event[head].dev_data[i]; lastEventTime = hil_info.timestamp; /* Used by ScreenSaver */ process_hil_data (dev, hil_info.hil_dev, &(hil_info)); hil_qp->hil_evqueue.head = (hil_qp->hil_evqueue.head + 1) % hil_qp->hil_evqueue.size; /* MUST use real head pointer, process_button may have incremented it. */ } if (xE.b.u.u.type != 0) /* at least 1 motion event */ { xHP = allocate_event(); /* get current queue pointer*/ *xHP = xE; /* copy from global struct */ xE.b.u.u.type = 0; /* mark it as processed */ } }#endif /* __hp_osf */Boolget_serial_event (hil_ptr) struct dev_info *hil_ptr; /* holds hil_data */ { int i, status; hil_ptr->timestamp = GetTimeInMillis(); hil_ptr->poll_hdr = 0; pending_index=0; pending_bytes=0; bzero (hil_ptr->dev_data, 36); for (i=0; i<num_serial_devices; i++) if (hil_ptr->hil_dev->file_ds==serialprocs[i].fd) { status = (*(serialprocs[i].read)) (hil_ptr->hil_dev->file_ds, hil_ptr->dev_data, &hil_ptr->poll_hdr, &pending_bytes); break; } if (status==READ_SUCCESS) return(FALSE); else return(TRUE); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -