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

📄 x_threebut.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 2 页
字号:
		    if (!(hil_info->poll_hdr & BUTTON_DATA))			return;		    hil_info->dev_data[pending_index] += BUTTON_BASE; 		    }		else		    {		    get_hil_event (button_ds, hil_info);		    if (!(hil_info->poll_hdr & SET1_KEY_MASK))			return;		    if (hil_info->poll_hdr & MOTION_MASK)			{			handle_motion_event (dev, hil_info->hil_dev, hil_info);			hil_info->poll_hdr &= ~MOTION_MASK;			}		    }		}    	    }#endif /* __hpux */#if defined(__apollo)	/*	 * If data_cnt is > 0, the button has been read into a global buffer.	 * If not, select on the proper device and wait 100ms.	 *	 */	{	int	mask = 1 << button_ds;        struct	timeval	  wait_time;			/* wait 1/10 second */	wait_time.tv_sec = 0;	wait_time.tv_usec = 100000;	if (hil_info->hil_dev->hpflags & IS_SERIAL_DEVICE)            if (data_cnt != 0)		{	        get_serial_event (hil_info);		if (!(hil_info->poll_hdr & BUTTON_DATA))		    return;		hil_info->dev_data[pending_index] += BUTTON_BASE; 		}	    else if (select (button_ds+1, &mask, NULL, NULL, &wait_time) <= 0)		return;	    else		{		pkt_ptr = buf;		data_cnt = read (button_ds, buf, READ_SIZ);		if (data_cnt <= 0)		    return;		get_serial_event (hil_info);		if (!(hil_info->poll_hdr & BUTTON_DATA))		    return;		hil_info->dev_data[pending_index] += BUTTON_BASE; 		}	else	    {	    select (0, NULL, NULL, NULL, &wait_time);	    if (!get_next_button (hil_info))		return;	    }	}#endif /* __apollo */	if (hil_info->hil_dev->hpflags & DATA_IS_8_BITS)	    nxt_button = (hil_info->dev_data)[pending_index++];	else if (hil_info->hil_dev->hpflags & DATA_IS_16_BITS)	    {	    nxt_button = ((hil_info->dev_data)[pending_index+1] << 8) |		(hil_info->dev_data)[pending_index];	    pending_index += 2;	    }	else if (hil_info->hil_dev->hpflags & DATA_IS_32_BITS)	    {	    nxt_button = ((hil_info->dev_data)[pending_index+3] << 24) |		(hil_info->dev_data)[pending_index+2] << 16 |		(hil_info->dev_data)[pending_index+1] << 8 |		(hil_info->dev_data)[pending_index];	    pending_index += 4;	    }        }    /*     * We've read another button, now see if it's valid and check that it is     * a combination that causes button chording.     *     */    curstate = next_device_state (dev, *ev, nxt_button);    if (curstate == ILLEGAL)	{        deallocate_event(*ev);        return;	}    bd->button_state = curstate;    if (curstate == 3 && num_buttons == 2)        {        *code = 0x84;        bd->ignoremask = 0x03;        bd->savebutton = 0x85;	return;        }    else if (curstate == 3 && num_buttons == 3)        {        *code = 0x86;        bd->ignoremask = 0x03;        bd->savebutton = 0x87;	return;        }    else if (curstate == 6 && num_buttons == 3)        {        *code = 0x88;        bd->ignoremask = 0x06;        bd->savebutton = 0x89;	return;        }    else if (curstate == 5)	{        if (num_buttons == 4)	    {	    *code = 0x88;	    bd->ignoremask = 0x05;	    bd->savebutton = 0x89;	    return;	    }	else if (button_latching==LATCHING_ON)	    {	    button_latch_enabled = ~button_latch_enabled;	    for (i=1; i<=bd->hil_header.v_button_count; i++)		if (button_latch_enabled)		    LatchButton(bd,i);		else		    UnlatchButton(bd,i);	    *code = 0;	    bd->ignoremask = 0x05;	    bd->savebutton = 0;	    return;	    }        }    put_button_event (dev, *ev, hil_info, bd, *code);    *code = nxt_button;    *ev = format_ev ((*ev)->u.u.type, *code, hil_info->timestamp, bd, 	NULL);    }/**************************************************************** * * next_device_state (button) *	 * */static intnext_device_state (dev, ev, code)    DeviceIntPtr dev;    xEvent *ev;    int	code;    {	    int	illegal;    int	button;    int	mask;    int	new_state = bd->button_state;    button =  (code - BUTTON_1_OFFSET) / 2;    mask = 1 << button-1;    if (code & 1)        illegal = !(new_state & mask);    else        illegal = new_state & mask;    if (illegal)        {        generate_buttons (dev, ev);        return (ILLEGAL);        }    if (code & 1)        new_state &= ~mask;    else        new_state |= mask;    return (new_state);    }/************************************************************************* *  * generate_buttons ()	 *	If we get here, it is because the HIL driver has lost some data. *	This can happen if the server is busy and the driver's buffer *	overflows.   *	If we have lost a single button release, ignore the next press and the *	corresponding release will fix it. *      If both buttons are down, or the middle button is down, we can't tell *      if we lost one or both of the button releases.  We assume we lost both. *       */static voidgenerate_buttons (dev, ev)    DeviceIntPtr dev;    xEvent *ev;    {    bd->button_state &= ~bd->ignoremask;    if (bd->ignoremask != 0)        put_button_event (dev, ev, devinfo, bd, bd->savebutton);    if (bd->button_state & 1)        put_button_event (dev, ev, devinfo, bd, 0x81);    if (bd->button_state & 2)        put_button_event (dev, ev, devinfo, bd, 0x83);    if (bd->button_state & 4)        put_button_event (dev, ev, devinfo, bd, 0x85);    if (bd->button_state & 8)        put_button_event (dev, ev, devinfo, bd, 0x87);    bd->button_state = 0;    }/*********************************************************************** * * put_button_event (hil_info) * * The event is on the server's internal queue and will be sent to DIX, * unless we "deallocate" it (remove it from that queue) here.   * We deallocate it if: * * 1). It's an up transition, the first of a chorded pair.  For example, if *     the left and middle mouse buttons have been chorded to generate button 4, *     and the left button goes up, we want to ignore it until the middle button *     also goes up, then send the up transition for button 4. * * 2). It has a code of 0.  This means that it was the left-right button *     combination used to turn on button latching. * * 3). It's an up transition and button latching is enabled.  We'll send the *     up transition the second time the button is pressed. * * 4). Some test process is stealing these buttons and doesn't want real clients *     to see them. * */static voidput_button_event (dev, ev, hil_info, p, code)    DeviceIntPtr	dev;    xEvent 		*ev;    struct dev_info	*hil_info;    HPInputDevice	*p;    int			code;    {	#ifdef	XTESTEXT1    extern int	on_steal_input;		/* steal input mode is on.	*/    extern int	exclusive_steal;#endif  /* XTESTEXT1 */    if (bd->sent_button)			/* sent a chorded button */	if (bd->button_state & bd->ignoremask)	/* first of pair is going up */	    {	    deallocate_event(ev);		/* remove it from the queue */            return;	    }	else if (bd->ignoremask != 0)		/* second of pair is going up */	    {	    bd->ignoremask = 0;	    bd->sent_button = 0;	    code = bd->savebutton;		/* use saved chorded code */	    }    if (bd->ignoremask != 0)			/* This is a chorded button */	bd->sent_button = 1;    if (code==0)				/* "enable latching" case   */	{	deallocate_event(ev);	return;	}    ev->u.u.detail = button_map[(code-BUTTON_BASE)/2] + 1;    if (ButtonIsLatched(hil_info->hil_dev, ev->u.u.detail))	if (ButtonIsIgnored(hil_info->hil_dev,ev->u.u.detail))	    {	    if (ButtonDownEvent(ev))	        UnignoreButton(hil_info->hil_dev,ev->u.u.detail);	    deallocate_event (ev);	    return;	    }	else if (ButtonDownEvent(ev))	    IgnoreButton(hil_info->hil_dev,ev->u.u.detail);    if (code & UP_MASK)			/* up event was generated */	if (dev==inputInfo.pointer)	    ev->u.u.type = ButtonRelease;	else	    ev->u.u.type = DeviceButtonRelease;    else	if (dev==inputInfo.pointer)	    ev->u.u.type = ButtonPress;	else	    ev->u.u.type = DeviceButtonPress;#ifdef	XTESTEXT1    if (on_steal_input)	XTestStealKeyData(ev->u.u.detail, ev->u.u.type, MOUSE, p->coords[0], 		p->coords[1]);    if (exclusive_steal)	deallocate_event(ev);#endif	/* XTESTEXT1 */    }

⌨️ 快捷键说明

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