📄 x_hilinit.c
字号:
/* $Header: /host/debretts/disk2/X11R5/R5-hp300/mit/server/ddx/hpbsd/input/RCS/x_hilinit.c,v 1.2 1993/04/21 21:44:37 root Exp $ *//*********************************************************************** *********************************************************** *** * File: ddx/hp/hp/x_hilinit.c** *** * Contents: Input initialization routines for the** * X/Starbase Merged Server** *** * Created: 4/28/88** *** * Last Change: 12/06/88** *** * Last Release: IC2** *** * Revision: A.01.00** *** * Author: --gms** *** * Copyright: (c) 1988 Hewlett-Packard Company** *** *********************************************************** ********************************************************************//*''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''Copyright (c) 1988 by Hewlett-Packard CompanyCopyright (c) 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts, and the Massachusetts Institute of Technology, Cambridge, MassachusettsPermission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the names of Hewlett-Packard, Digital or M.I.T. not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission.DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDINGALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALLDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES ORANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THISSOFTWARE.'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''*/#define MAXNAMLEN 255#define NEED_EVENTS#include <stdio.h>#include <errno.h>#if defined(__hpux) || defined(__hp_osf) || defined(hp9000)#ifdef hp9000#define BEEPER_DEVICE "/dev/hil0"#else#define BEEPER_DEVICE "/dev/rhil"#endif#ifdef hp9000# include <sys/types.h># include <sys/ioctl.h># include <hilioctl.h># undef HILER1# undef HILDKR# define HILER1 HILIOCAR1# define HILDKR HILIOCAROFF#else#ifdef __hp_osf#include <hp/hilioctl.h>#include <sys/mman.h>#else#include <sys/hilioctl.h>#endif#endif#include <fcntl.h>#ifndef hp9000#include <dl.h>#endif#endif /* __hpux */#include "X.h"#include "Xproto.h"#include "hildef.h"#include "XHPproto.h" /* extension constants */#include "x_hilinit.h"#include "x_hil.h"#include "x_serialdrv.h"#include "inputstr.h"#include "../../../os/osdep.h"#ifdef XINPUT#include "XI.h"#include "XIproto.h"#else#define Relative 0#define Absolute 1#endif /* XINPUT */#ifdef __apollo#include "screenint.h"#include "../apollo/apollo.h"#include "../apollo/smd.h"#endif /* __apollo *//****************************************************************** * * Externs and global variables that may be referenced by other files. * */int num_serial_devices;SerialProcs serialprocs[MAX_DEVICES];HPInputDevice *hpKeyboard;HPInputDevice *hpPointer;HPInputDevice *hptablet_extension;#ifdef __hp_osfHILQ *hil_qp;int hil_qd;#endif /* __hp_osf */#ifdef __apolloextern long *apECV;extern long *apLastECV;static int fdApollo = 0;status_$t status;#endif /* __apollo */#ifdef XINPUTextern int BadDevice;extern int BadMode;extern int IReqCode;extern int DeviceKeyPress;extern int DeviceKeyRelease;extern int DeviceButtonPress;extern int DeviceButtonRelease;extern int DeviceMotionNotify; #ifdef NOT_DONEextern XID hp_device_ids[];#endifXID x_device_ids[MAX_DEVICES];#endif /* XINPUT */extern int *dpmotionBuf[];extern int *dheadmotionBuf[];extern void SetBellAttributes();extern void hpBell();extern u_char identity_map[];extern u_char mv_mods, ptr_mods, rs_mods, bw_mods;extern u_char pointer_amt_bits[];extern char *display; /* display number as a string */extern int queue_events_free;extern struct x11EventQueue *events_queue;extern InputInfo inputInfo;int lastEventTime;int axes_changed = FALSE;int keyboard_click;int allocated_dev_names = FALSE;int x_axis, y_axis;int otherndx;int beeper_fd = -1;char ldigit = '\0';unsigned char xhp_kbdid;unsigned tablet_xlimit;unsigned tablet_ylimit;unsigned tablet_xorg;unsigned tablet_yorg;struct inputs_selected valid_inputs;HPInputDevice l_devs[MAX_LOGICAL_DEVS];DeviceIntPtr LookupDeviceIntRec ();DeviceIntPtr tablet_extension_device;DeviceIntPtr screen_change_dev;int HPType;int device_ndx;/****************************************************************** * * Variables that are global to this file only. * */static int init_hil_devs ();static int get_device_details();static void SetAutoRepeat ();static int device_files ();static DevicePtr hpAddInputDevice();static void RecordOpenRequest();static void SetInputDevice();static void mask_from_kcodes();static int loopnum;static char hilpath[MAXNAMLEN+1];void ProcessOtherEvent();static xHPEvent events_array[MAX_EVENTS]; /* input event buffer*/static struct x11EventQueue ev_queue;static int count [NUM_DEV_TYPES];#if defined(__hpux) || defined(__hp_osf) || defined(hp9000)static int prompt[] = {HILP, HILP1, HILP2, HILP3, HILP4, HILP5, HILP6, HILP7};static int ack[] = {HILA, HILA1, HILA2, HILA3, HILA4, HILA5, HILA6, HILA7};#endif /* __hpux */static char *dev_names[MAX_LOGICAL_DEVS];#if defined(__hp9000s300) || defined(__hp9000s700) || defined(__hp_osf) || defined(hp300)static char *default_names[MAX_LOGICAL_DEVS] = { "/dev/hil1", "/dev/hil2", "/dev/hil3", "/dev/hil4", "/dev/hil5", "/dev/hil6", "/dev/hil7", "", "/dev/null"};#else /* building for s800 */char beeper_name[] = "/dev/hilkbd ";static char *default_names[MAX_LOGICAL_DEVS] = { "/dev/hil_0.1", "/dev/hil_0.2", "/dev/hil_0.3", "/dev/hil_0.4", "/dev/hil_0.5", "/dev/hil_0.6", "/dev/hil_0.7", "/dev/hil_1.1", "/dev/hil_1.2", "/dev/hil_1.3", "/dev/hil_1.4", "/dev/hil_1.5", "/dev/hil_1.6", "/dev/hil_1.7", "/dev/hil_2.1", "/dev/hil_2.2", "/dev/hil_2.3", "/dev/hil_2.4", "/dev/hil_2.5", "/dev/hil_2.6", "/dev/hil_2.7", "/dev/hil_3.1", "/dev/hil_3.2", "/dev/hil_3.3", "/dev/hil_3.4", "/dev/hil_3.5", "/dev/hil_3.6", "/dev/hil_3.7", "", "/dev/null"};#endif /* building on __hp9000s300 or for s700 *//**************************************************************************** * * Change acceleration & threshold. * The DIX routine that handles the ChangePointerControl request has * already validity checked the values and copied them into the * DeviceIntRec. This routine just copies them into fields that are * the same no matter what kind of device we're dealing with. * */static void hpChangePointerControl(pDevice, ctrl) DevicePtr pDevice; PtrCtrl *ctrl; {#ifdef XINPUT PtrFeedbackPtr b; b = ((DeviceIntPtr) pDevice)->ptrfeed; b->ctrl = *ctrl;#else extern int threshold; extern int acceleration; threshold = ctrl->threshold; acceleration = ctrl->num; if (acceleration <= 0) acceleration = 1;#endif /* XINPUT */#ifdef __apollo { smd_$pos_t pos; extern smd_unit_event_data_t olddata; HPInputDevice *d; if ((DeviceIntPtr) pDevice == inputInfo.pointer) { d = GET_HPINPUTDEVICE ((DeviceIntPtr) pDevice); pos.column = d->coords[0]; pos.line = d->coords[1]; olddata.pos = pos; smd_$set_unit_cursor_pos (1, pos, &status); } }#endif /* __apollo */ }/**************************************************************************** * * Turn LEDs on or off. * */static void SetLeds (d, leds, mask) HPInputDevice *d; unsigned int leds, mask; { int i, iob; char ioctl_data[12]; HPLedFeedbackControl ctrl;#if defined(__hpux) || defined(__hp_osf) || defined(hp9000) if (d->hil_header.iob & HILIOB_PAA) /* general prompt */ { if (leds & 1) ioctl (d->file_ds, HILP, ioctl_data); else ioctl (d->file_ds, HILA, ioctl_data); leds >>= 1; } if (iob = ((u_char) (d->hil_header.iob & HILIOB_NPA) >> 4))/* prompt 1-7 */ for (i=1; i<=iob; i++) { if (leds & 1) ioctl (d->file_ds, prompt[i], ioctl_data); else ioctl (d->file_ds, ack[i], ioctl_data); leds >>= 1; }#endif /* __hpux */ if (d->hpflags & IS_SERIAL_DEVICE) for (i=0; i<num_serial_devices; i++) if (d->file_ds==serialprocs[i].fd) { ctrl.class = LedFeedbackClass; ctrl.led_values = leds; ctrl.led_mask = mask; (void) (*(serialprocs[i].write)) (d->file_ds, _XChangeFeedbackControl, &ctrl ); break; } }/**************************************************************************** * * The members of the ledCtrl structure have the following values: * * mask: 1 bit per LED. * value: if mask set, turn it on or off. * */static void hpChangeLedControl(pDevice, ctrl) DevicePtr pDevice; LedCtrl *ctrl; { HPInputDevice *d; d = GET_HPINPUTDEVICE ((DeviceIntPtr) pDevice); SetLeds(d, ctrl->led_values, ctrl->led_mask); }/**************************************************************************** * * The members of the keybdCtrl structure have the following values: * * click: 0(off) - 100 (loud); -1 => default; * bell: 0(off) - 100 (loud); -1 => default; * bell_pitch: Pitch of the bell in Hz;-1 => default; * bell_duration: in miliseconds; -1 => default; * * keyboard_click is checked whenever a key is pressed, in x_hil.c. */static void hpChangeKeyboardControl(pDevice, ctrl) DevicePtr pDevice; KeybdCtrl *ctrl; { HPInputDevice *d; if (inputInfo.keyboard && ((DeviceIntPtr) pDevice)->id==inputInfo.keyboard->id) keyboard_click = (int)((double)(ctrl->click) * 15.0 / 100.0); d = GET_HPINPUTDEVICE ((DeviceIntPtr) pDevice); SetAutoRepeat(d, ctrl->autoRepeat); SetBellAttributes(d, ctrl); SetLeds(d, ctrl->leds, 0xffffffff); }/**************************************************************************** * * hpGetDeviceMotionEvents. * */static int hpGetDeviceMotionEvents (dev, buff, start, stop) DeviceIntPtr dev; CARD32 start, stop; char *buff; { HPInputDevice *pHPDev = (HPInputDevice *) dev->public.devicePrivate; int i; int evcount = 0; int size = pHPDev->hil_header.ax_num + 1; int *first, *last, *curr; int *buffp = (int *) buff; int *pmBuf = dpmotionBuf[dev->id]; int *hmBuf = dheadmotionBuf[dev->id]; if (pmBuf == hmBuf) { if (*pmBuf == 0) /* no events yet */ return 0; else last = hmBuf + (99 * size); } else last = pmBuf-size; if (*pmBuf == 0) /* haven't wrapped yet */ first = hmBuf; else first = pmBuf; if (start > *last) /* start time > last time */ return 0; else { curr = first; while (*curr < start) { curr += size; if (curr == hmBuf+(100*size)) curr = hmBuf; if (curr == first) return 0; } while (*curr <= stop && *curr != 0) { if (dev == inputInfo.pointer) /*X pointer is 16 bits/axis */ { *buffp++ = *curr++; /* copy the time */ *buffp++ = *curr << 16 | *(curr+1); /* copy data for 2 axes */ curr += 2; } else /* other devices are 32 bits */ for (i=0; i<size; i++) *buffp++ = *curr++; evcount++; if (curr == hmBuf+(100*size)) curr = hmBuf; if (curr == first) break; } } return (evcount); }/**************************************************************************** * * NOTE: The first parameter passed to this routine is really a DeviceIntPtr. * The declaration used here works because the first element of the * structure pointed to by the DeviceIntPtr is a DeviceRec. * */static Bool hpDeviceProc(pDev, onoff) DevicePtr pDev; int onoff; { int keyId; unsigned int mask; KeySymsRec *key_syms, keysym_rec; CARD8 *the_modmap;#ifdef __apollo#define SHORT_STRLEN 4 char kbdtypestr[SHORT_STRLEN]; short kbdtypestrlen; static char kbdtype, kbdsubtype;#endif /* __apollo */ DeviceIntPtr dev = (DeviceIntPtr) pDev; HPInputDevice *pHPDev = (HPInputDevice *) pDev->devicePrivate; struct hil_desc_record *h = &pHPDev->hil_header; int i; int button_count = h->v_button_count ? h->v_button_count : 3; int mbufsiz = (h->ax_num * sizeof(int) + sizeof(Time)) * MOTION_BUFFER_SIZE;#ifdef XINPUT char *strchr(); char *nptr;#endif /* XINPUT */ switch (onoff) { case DEVICE_INIT: pDev->on = FALSE; pHPDev->pScreen = screenInfo.screens[0]; nptr = strchr (pHPDev->x_name, '_'); AssignTypeAndName (pDev, pHPDev->x_atom, ++nptr); if (h->num_keys) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -