⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 x_hilinit.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 5 页
字号:
#if defined(__hpux) || defined(__hp_osf) || defined(hp9000)		if (h->iob & HILIOB_NPA) /* PS2 kbd */		    {		    keyId = hil_to_kbd_id(h->id + 0x20);		    pHPDev->id_detail = HP_HIL | PC101_KBD;		    }		else		    keyId = hil_to_kbd_id(h->id);#endif#ifdef __apollo		/*		 * Detect keyboard type and do initialization accordingly.		 * Note:		 *   If the keyboard is "3x" but not one of the known types, its		 *     probably an ISO keyboard.  The Swedish/Finish keymap is		 *     a superset of ISO (according to Dan G) so I use that.		 *   Otherwise, use North American as a default.		 */		smd_$inq_kbd_type(SHORT_STRLEN, kbdtypestr, &kbdtypestrlen, &status);		kbdtype    = (kbdtypestrlen > 0) ? kbdtypestr[0] : '2';		kbdsubtype = (kbdtypestrlen > 1) ? kbdtypestr[1] : ' '; 		keyId = 33;	/* assume North American (subtype ' ') */		if (kbdtype == '3')		    switch (kbdsubtype)			{			case ' ': keyId = 33; break;	/* North American */			case 'a': keyId = 34; break;	/* German */			case 'b': keyId = 35; break;	/* French */			case 'c': keyId = 36; break;	/* Norwegian/Danish */			case 'd': keyId = 37; break;	/* Swedish/Finish */			case 'e': keyId = 38; break;	/* UK */			case 'g': keyId = 39; break;	/* Swiss */			case 'f': keyId = 40; break;	/* Japanese */			default:  keyId = 37;		/* unknown - ISO ? */			}#endif /* __apollo */		if (pHPDev->hpflags & IS_SERIAL_DEVICE)		    {		    if (!HPKget_kb_info_by_name(nptr, &keysym_rec, &the_modmap)			&& pHPDev==hpKeyboard)			FatalError ("Can't find a keymap in the /usr/lib/X11/XHPKeymaps file for the X keyboard device.\n");		    }		else		    HPKget_maps_by_id(keyId, &keysym_rec, &the_modmap);		key_syms = &keysym_rec;		if (dev->id == inputInfo.keyboard->id)		    {		    InitKeyboardDeviceStruct(pDev, key_syms,		 	the_modmap, hpBell, hpChangeKeyboardControl);		    }#ifdef XINPUT		else		    {		    InitKeyClassDeviceStruct (dev, key_syms, the_modmap);		    InitKbdFeedbackClassDeviceStruct (dev, hpBell,			hpChangeKeyboardControl);		    InitFocusClassDeviceStruct (dev);		    }		}	    if (h->num_leds && dev->id != inputInfo.pointer->id && 		dev->id != inputInfo.keyboard->id)		{		LedFeedbackPtr led;		InitLedFeedbackClassDeviceStruct(dev,hpChangeLedControl);		for (i=0; i<h->num_leds; i++)		    mask |= (1 << i);		for (led=dev->leds; led; led = led->next)		    led->ctrl.led_mask = mask;		}#endif /* XINPUT */	    if (h->ax_num)		{		if (dev->id == inputInfo.pointer->id)		    {		    if (pHPDev->dev_type == NULL_DEVICE)			{	        	pHPDev->coords[0] = pHPDev->pScreen->width;	        	pHPDev->coords[1] = pHPDev->pScreen->height;			}		    else			{	        	pHPDev->coords[0] = pHPDev->pScreen->width / 2;	        	pHPDev->coords[1] = pHPDev->pScreen->height / 2;			}#ifdef __apollo		    smd_$pos_t pos;		    extern smd_unit_event_data_t olddata;				    pos.column = pHPDev->coords[0];		    pos.line = pHPDev->coords[1];		    olddata.pos = pos;		    smd_$set_unit_cursor_pos (1, pos, &status);#endif /* __apollo */		    InitPointerDeviceStruct (pDev, ptr_button_map, button_count,			hpGetDeviceMotionEvents, hpChangePointerControl, 			    MOTION_BUFFER_SIZE);		    }#ifdef XINPUT		else		    {		    InitFocusClassDeviceStruct (dev);#if defined(__hpux) || defined(__hp_osf) || defined(hp9000)		    if (h->iob & HILIOB_PIO)			InitProximityClassDeviceStruct (dev);#endif /* __hpux */		    InitValuatorClassDeviceStruct (dev, h->ax_num, 			hpGetDeviceMotionEvents, 100, 			(h->flags & HIL_ABSOLUTE)?1:0);		    InitPtrFeedbackClassDeviceStruct (dev, 			hpChangePointerControl);		    for (i=2; i < (u_char) h->ax_num; i++)			InitValuatorAxisStruct (dev, i, 0, 0, 0, 0, 0);		    }		InitValuatorAxisStruct (dev, 0, 0, (unsigned int) h->size_x, 		    (unsigned int) h->resx, 0, (unsigned int) h->resx);		InitValuatorAxisStruct (dev, 1, 0, (unsigned int) h->size_y, 		    (unsigned int) h->resy, 0, (unsigned int) h->resy);		dpmotionBuf[dev->id] = (int *) Xalloc (mbufsiz);		memset (dpmotionBuf[dev->id], 0, mbufsiz);		dheadmotionBuf[dev->id] = dpmotionBuf[dev->id];		}	    if (h->p_button_count)    		InitButtonClassDeviceStruct (dev, button_count, identity_map);#endif /* XINPUT */ 	    break;	case DEVICE_ON: 	    pDev->on = TRUE;	    if ( pHPDev != NULL) 		{#ifndef __hp_osf        	if (pHPDev->dev_type != NULL_DEVICE)		    AddEnabledDevice( pHPDev->file_ds );#endif /* __hp_osf */		if (h->ax_num)		    set_scale_and_screen_change (pHPDev);	        }	    SetAutoRepeat(pHPDev, TRUE);	    break;	case DEVICE_OFF:	    pDev->on = FALSE;	    if (dev->id != inputInfo.pointer->id &&		pHPDev->file_ds == hpPointer->file_ds)		break;	    if (pHPDev != NULL && pHPDev->file_ds >= 0)		{#ifndef __hp_osf		RemoveEnabledDevice(pHPDev->file_ds);#endif /* __hp_osf */	        SetAutoRepeat(pHPDev, FALSE);    	        close_device (pHPDev);		}	    break;	case DEVICE_CLOSE: 	    if ( pHPDev != NULL && pHPDev->file_ds >= 0)		{	        SetAutoRepeat(pHPDev, FALSE);#ifndef __hp_osf		RemoveEnabledDevice( pHPDev->file_ds);#endif /* __hp_osf */    	        close_device (pHPDev);		}#ifdef XINPUT	    if (dheadmotionBuf[dev->id])		{		Xfree (dheadmotionBuf[dev->id]);		dheadmotionBuf[dev->id] = NULL;		dpmotionBuf[dev->id] = NULL;		}#endif /* XINPUT */	    if (dev->id == inputInfo.pointer->id)		close (beeper_fd);	    break;	}    return(Success);    }/**************************************************************************** * * InitInput -- *	Initialize pointer and keyboard devices. * */ InitInput(argc, argv)    int     	  argc;    char    	  **argv;    {    int	i, j;    DeviceIntPtr x_init_device();    int CheckInput();      /* Initialize lastEventTime.  Also used to fake an input event for       *   TimeSinceLastInputEvent() so that the screen saver timeouts work       *   correctly when all clients die (in WaitForSomething()).  --CD       */    x_axis = 0;    y_axis = 1;    axes_changed = FALSE;    hpPointer = NULL;    hpKeyboard = NULL;    hptablet_extension = NULL;    tablet_width = 0;    otherndx = 2;    device_ndx = MAX_POSITIONS - 1;    lastEventTime = 0;    for (i=0; i<NUM_DEV_TYPES; i++)	count[i] = 0;#ifdef __hp_osf    if (!hil_qp)    {    if ((beeper_fd = open(BEEPER_DEVICE,O_RDWR)) < 0) 	ErrorF ("Unable to open beeper device \"%s\".\n",BEEPER_DEVICE);#ifdef SPECIAL_68K_OSF    if ((ioctl (beeper_fd, HILALLOCQ, &hil_qd)) < 0)	FatalError ("Error allocating HIL event queue.\n");    if ((int) (hil_qp = (HILQ *) mmap (0, sizeof(HILQ), PROT_READ|PROT_WRITE,	MAP_FILE|MAP_SHARED, beeper_fd, hil_qd*sizeof(HILQ))) <0)	FatalError("Unable to map /dev/rhil\n");#else    if ((ioctl (beeper_fd, HILALLOCQ, &hil_qp)) < 0)	FatalError ("Error allocating HIL event queue.\n");#endif /* SPECIAL_68K_OSF */    SetInputCheck(&hil_qp->hil_evqueue.head, &hil_qp->hil_evqueue.tail);    }    /* discard all the current input events  */    hil_qp->hil_evqueue.head = hil_qp->hil_evqueue.tail;    AddEnabledDevice (beeper_fd);#endif /* __hp_osf */    RegisterBlockAndWakeupHandlers (NoopDDA, CheckInput, NULL);    loopnum = atoi(display);    hilpath[0] = '\0';    ldigit = '\0';    get_pointerkeys();    fix_modifierkeys();    init_l_devs ();    init_events_queue ( &ev_queue);#if defined(__hpux) || defined(hp9000)    init_beeper();			/* beeper_fd = /dev/rhil */#endif /* __hpux */    /*     * Now initialize the devices as far as X is concerned.     */    for (i=0, j=0; i<MAX_DEVICES && j < MAX_LOGICAL_DEVS; j++) 	{	if (l_devs[j].hil_header.id == 1 ||		/* inaccessible device*/	    (l_devs[j].dev_type == NULL_DEVICE && 	     !(l_devs[j].hpflags & OPEN_THIS_DEVICE)))		continue;	if (l_devs[j].file_ds != -1)	    {	    (void) x_init_device (&l_devs[j], TRUE);	    l_devs[j].open_cnt=1;	    }	else	    (void) x_init_device (&l_devs[j], FALSE);	i++;	}    }/*********************************************************** * * Perform X initialization for the device. * */DeviceIntPtrx_init_device (dev, start_it)    HPInputDevice *dev;    Bool start_it;    {    DevicePtr	pXDev;    pXDev = hpAddInputDevice(hpDeviceProc, start_it, dev);    if (dev==hpKeyboard)	{	RegisterKeyboardDevice(pXDev);        if (dev->dev_type == KEYBOARD)	    xhp_kbdid = dev->hil_header.id - 0xA0;	}    else if (dev==hpPointer)	{	RegisterPointerDevice(pXDev);#ifdef SPECIAL_68K_OSF	miRegisterPointerDevice(screenInfo.screens[0], pXDev);#endif	if (dev->x_type == KEYBOARD)	    InitKbdFeedbackClassDeviceStruct (pXDev, hpBell,		hpChangeKeyboardControl);	screen_change_dev = (DeviceIntPtr) pXDev;	if (screen_change_amt == SCREEN_CHANGE_DEFAULT)	    if (dev->hil_header.flags & HIL_ABSOLUTE)		screen_change_amt = 0;	    else		screen_change_amt = 30;	}#ifdef XINPUT    else    	{	RegisterOtherDevice(pXDev);	if (tablet_width && dev->file_ds==hpPointer->file_ds)	    {	    tablet_extension_device = (DeviceIntPtr) pXDev;	    hptablet_extension = dev;	    screen_change_dev = tablet_extension_device;	    }	}#endif /* XINPUT */    return ((DeviceIntPtr) pXDev);    }/***************************************************************** * * Initialize the l_devs array of structures. * There is one per logical input device. * */ int	sdev_num = 2;init_l_devs()    {    int		i;    int		dev_num = 2;    FILE	*fp;    char	fname[MAXNAMLEN];    struct	opendevs opendevs [MAX_LOGICAL_DEVS];    for (i=0; i<MAX_LOGICAL_DEVS; i++)	{	opendevs[i].type = -1;	opendevs[i].pos = -1;	opendevs[i].name[0] = '\0';	opendevs[i].path[0] = '\0';	}    for (i=0; i<MAX_LOGICAL_DEVS; i++)	{        l_devs[i].hil_header.id = 1;        l_devs[i].hpflags = 0;        l_devs[i].mode = ABSOLUTE;	l_devs[i].open_cnt = 0;	l_devs[i].file_ds = -1;	l_devs[i].x_name[0] = '\0';	l_devs[i].dev_type = '\0';#if defined(__hpux) || defined(__hp_osf) || defined(hp9000)        l_devs[i].repeat_rate = HILER1;#endif /* __hpux */	}    (void) sprintf(fname, "%sX%sdevices", DEF_DIRECTORY, display);    fp = fopen ( fname, "r");    if (fp) 	{        dev_num = device_files (fp, opendevs);	fclose (fp);	}    compute_device_names (opendevs, dev_num);#if defined(__hpux) || defined(__hp_osf) || defined(hp9000)    init_hil_devs (opendevs, dev_num);#endif /* __hpux */#ifdef __apollo    init_apollo_devs (opendevs, dev_num);#endif /* __apollo */#ifndef hp9000    /*     * Check for any dynamically loaded input device drivers.     */    init_dynamic_devs (opendevs, sdev_num);#endif    if (hpPointer->x_type == KEYBOARD)	{	hpPointer->hil_header.v_button_count = 8;	hpPointer->hil_header.p_button_count = 8;	hpPointer->hil_header.ax_num = 2;	}    }/******************************************************************** * * Compute the names of the input devices we should use. * If a path for the input devices has been specified, use it. * Otherwise use /dev/hil. * If we have multiple HIL loops (series 800), and the display number * is between 0 and 3, use the corresponding loop.  Otherwise, search * all loops. * */compute_device_names (opendevs, dev_num)    struct	opendevs opendevs [];    int		dev_num;    {    int		ndx = MAX_POSITIONS - 1;    int		i;    int 	hlen = strlen(hilpath);#if defined(__hp9000s800) && !defined(__hp9000s700)    if (hlen > 0 && isdigit (hilpath[hlen-1]))	/* hilpath ends in digit */	{	ldigit = hilpath[hlen-1];	hilpath[hlen-1] = '\0';	}    else if (loopnum >= 0 && loopnum < 4)	/* X invoked with display # */	ldigit = display[0];#endif /* __hp9000s800 */    if (hlen > 0)	allocated_dev_names = TRUE;    else	allocated_dev_names = FALSE;    for (i=0; i<MAX_LOGICAL_DEVS; i++)	{	if (hlen > 0 && i<MAX_POSITIONS)	    {	    if (allocated_dev_names == TRUE)		Xfree (dev_names[i]);	    dev_names[i] = (char *) Xalloc (strlen (hilpath) + 4);	    if (ldigit == '\0' || i < 7)						{		strcpy (dev_names[i], hilpath);		strcat (dev_names[i], suffix[i]);		}	    }	else	    dev_names[i] = default_names[i];	}#if defined(__hp9000s800) && !defined(__hp9000s700)    if (ldigit != '\0')        for (i=0; i<MAX_POSITIONS; i++)	    {	    if (i < 7)						{		suffix [i][0] = ldigit;		dev_names[i][9] = ldigit;		}	    else		{		dev_names[i][0] = '\0';		suffix [i][0] = '\0';		}	    }#endif /* __hp9000s800 */    while (--dev_num >= 0)	{	if (opendevs[dev_num].path[0] == '\0')	    continue;	for (i=0; i<MAX_POSITIONS; i++)	    if (strcmp (opendevs[dev_num].path, dev_names[i]) == 0)		break;	if (i==MAX_POSITIONS)	    strcpy (dev_names[ndx--], opendevs[dev_num].path);	   	}    for (i=0; i<MAX_LOGICAL_DEVS; i++)	strcpy (l_devs[i].dev_name,dev_names[i]);    }/******************************************************************** * * Find the requested key and pointer devices. * If no key or pointer device was named, find a default one. * */#if defined(__hpux) || defined(__hp_osf) || defined(hp9000)static int init_hil_devs (opendevs, numdev)    struct	opendevs opendevs [];    int		numdev;    {    Bool OnlyOpenExplicit = FALSE;    int	i, j;    int	spare = MAX_LOGICAL_DEVS - 2;    HPInputDevice	*d, *last_mouse=NULL, *last_pointer=NULL, 			*last_keyboard=NULL, *last_key_device=NULL;/***************************************************************************** * * Attempt to open all devices and find out what they are. * Find out which will be the default devices. * Count them so that we can assign names by position. * A device that can't be opened is considered not present. * */    if (opendevs[XKEYBOARD].path[0] != '\0' &&        opendevs[XPOINTER].path[0] != '\0')	OnlyOpenExplicit = TRUE;    for (i=0; i<MAX_LOGICAL_DEVS; i++)	{	d = &l_devs[i];	if (OnlyOpenExplicit)	    {	    for (j=0; j<numdev; j++)		if (strcmp (opendevs[j].path, d->dev_name) == 0)		    break;	    if (j==numdev)		continue;	    }	if (open_device (d) >= 0)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -