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

📄 x_hil.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 4 页
字号:
#ifdef	XTESTEXT1    if (on_steal_input)	{ 	XTestStealKeyData(ev->u.u.detail, ev->u.u.type, phys->x_type, 	    ev->u.keyButtonPointer.rootX, ev->u.keyButtonPointer.rootY);	if (exclusive_steal)	    { 	    if (ev->u.u.detail != xtest_command_key)		deallocate_event (ev);	    }	else if (ev->u.u.detail == xtest_command_key)	    deallocate_event (ev);	}#endif /* XTESTEXT1 */    }/************************************************************************ * * This routine checks to see if the key should be interpreted as a  * sprite movement or a button. * */static move_sprite (dev, phys, ev)    DeviceIntPtr	dev;    HPInputDevice	*phys;    xEvent		*ev;    {    u_char      down_mods;    u_char      key = ev->u.u.detail;    u_char      type = ev->u.u.type;    int		inc;    Bool	motion_mods;    get_down_modifiers (dev->key->down, &down_mods);    if (down_mods & (~ptr_mods & ~mv_mods))	motion_mods = FALSE;    else if ((down_mods & ptr_mods) == ptr_mods)	motion_mods = TRUE;    else	motion_mods = FALSE;    if (!(down_mods & mv_mods))        inc = pointer_move;    else if ((down_mods & mv_mods) == pointer_amt_bits[0])        inc = pointer_mod1_amt;    else if ((down_mods & mv_mods) == pointer_amt_bits[1])        inc = pointer_mod2_amt;    else if ((down_mods & mv_mods) == pointer_amt_bits[2])        inc = pointer_mod3_amt;    else	motion_mods = FALSE;    k_down_incy[DOWN] = inc;    k_down_incx[RIGHT] = inc;    k_down_incy[UP] = inc * -1;    k_down_incx[LEFT] = inc * -1;    if (key==cursor_down && type==KeyPress && motion_mods)        return (send_motion (phys, ev, 0, inc, DOWN));    else if (key==cursor_down && type==KeyRelease)        {        k_down_flag[DOWN] = 0;        return (1);        }    else if (key==cursor_left && type==KeyPress && motion_mods)        return (send_motion (phys, ev, inc * -1, 0, LEFT));    else if (key==cursor_left && type==KeyRelease)        {        k_down_flag[LEFT] = 0;        return (1);        }    else if (key==cursor_right && type==KeyPress && motion_mods)        return (send_motion (phys, ev, inc, 0, RIGHT));    else if (key==cursor_right && type==KeyRelease)        {        k_down_flag[RIGHT] = 0;        return (1);        }    else if (key==cursor_up && type==KeyPress && motion_mods)        return (send_motion (phys, ev, 0, inc * -1, UP));    else if (key==cursor_up && type==KeyRelease)        {        k_down_flag[UP] = 0;        return (1);        }    else 	{	if (type==KeyPress)	    type = ButtonPress;	if (type==KeyRelease)	    type = ButtonRelease;	if (key == button_1)	    return (send_button (ev, type, 1));	else if (key == button_2)	    return (send_button (ev, type, 2));	else if (key == button_3)	    return (send_button (ev, type, 3));	else if (key == button_4)	    return (send_button (ev, type, 4));	else if (key == button_5)	    return (send_button (ev, type, 5));	else if (key == button_6)	    return (send_button (ev, type, 6));	else if (key == button_7)	    return (send_button (ev, type, 7));	else if (key == button_8)	    return (send_button (ev, type, 8));	}    return (0);    }/**************************************************************************** * * Send motion information from the keyboard, when it is the pointer device. * */static send_motion (phys, ev, x, y, which)    HPInputDevice	*phys;    xEvent		*ev;    int 		x, y, which;    {    int 		coords[MAX_AXES];    int	i;    for (i=0; i<4; i++)        if (i != which && k_down_flag[i] != 0)            {            x += k_down_incx[i];            y += k_down_incy[i];            }    coords[0] = x;    coords[1] = y;    k_down_flag[which] = 1;    deallocate_event(ev);    process_motion (inputInfo.pointer, phys, hpPointer, coords);    ev = format_ev (MotionNotify, 0, ev->u.keyButtonPointer.time,hpPointer,&xE);    return (1);    }/**************************************************************************** * * Send button information from the keyboard, when it is the pointer device. * */static send_button (ev, direction, bcode)    xEvent *ev;    u_char direction, bcode;    {    if (bcode == last_key && direction == last_direction)	deallocate_event(ev);    else	{	ev->u.u.type = direction;	ev->u.u.detail = bcode;	last_key = bcode;	last_direction = direction;#ifdef XTESTEXT1	if (on_steal_input)	    XTestStealKeyData(ev->u.u.detail, ev->u.u.type, MOUSE, 		ev->u.keyButtonPointer.rootX, ev->u.keyButtonPointer.rootY);#endif /* XTESTEXT1 */	}    return (1);    }/**************************************************************************** * * process_motion (hil_info) * * This function may also be called from x_threebut.c and x_tablet.c. * It requires the motion passed to be a relative amount. * dev_hp and dev are the logical devices, phys is the actual device. * */#define DEF_ACCELERATION	1#define EDGE_L			1 << 0#define EDGE_R			1 << 1#define EDGE_T			1 << 2#define EDGE_B			1 << 3#define OffRightEdge(log)  (log->coords[0] > (log->change_xmax + \			    (int) log->change_amt) ? EDGE_R : 0)#define OffLeftEdge(log)   (log->coords[0] < (log->change_xmin - \			    (int) log->change_amt) ? EDGE_L : 0) #define OffTopEdge(log)    (log->coords[1] < (log->change_ymin - \			    (int) log->change_amt) ? EDGE_T : 0) #define OffBottomEdge(log) (log->coords[1] > (log->change_ymax + \			    (int) log->change_amt) ? EDGE_B : 0) process_motion (dev, phys, log, c)    DeviceIntPtr dev;    HPInputDevice *phys, *log;    int	c[];    {    int		i;    unsigned int state = 0;#ifdef XTESTEXT1    extern int playback_on;#endif       /* Compute x,y taking care of desired threshold and acceleration     * No acceleration if we're playing back a recorded test script.     * No acceleration for absolute pointing devices.     * No acceleration if we're using the default (1) acceleration.     */#ifdef XTESTEXT1    if (!playback_on)#endif	{	if (!(phys->hil_header.flags & HIL_ABSOLUTE) && 	    (acceleration > DEF_ACCELERATION))	    {	    for (i=0; i < (u_char) log->hil_header.ax_num; i++)	        if ( (c[i] - threshold) > 0)		    c[i] = threshold + (c[i] - threshold) * acceleration;	        else if ( (c[i] + threshold) < 0)		    c[i] = (c[i] + threshold) * acceleration - threshold;	    }	}    /*     * If this is the pointer or a device whose input is merged     * with the pointer, accumulate the motion and maintain a current position.     * If this is an relative device, save the current movement.     */    if (log == hpPointer || (phys->hil_header.flags & HIL_ABSOLUTE))	for (i=0; i< (int) log->hil_header.ax_num; i++)	    log->coords[i] = log->coords[i] + c[i];    else	for (i=0; i< (u_char) log->hil_header.ax_num; i++)	    log->coords[i] = c[i];    /*     * Active Zaphod implementation:     *    Change the screen if we have more than one screen,     *	  and the screen change device has gone off one of the edges,     *    and the device is not grabbed and confined.     */#if defined(__hpux) || defined(__hp_osf) || defined(hp9000)    if ( screenInfo.numScreens > 1 && 	 log->dev_id == screen_change_dev->id &&        (!dev->grab || !dev->grab->confineTo))	{	if (state = (OffRightEdge(log) | OffLeftEdge(log) | 	    OffTopEdge(log) | OffBottomEdge(log)))	    {	    if (!screen_was_changed)		change_the_screen (dev, phys, log, state);	    }	else 	    /*	     * Needed for the case where a tablet is the X pointer device.	     * Once we change screens, we want to avoid immediately changing	     * back.  We change when we enter the screen change area and 	     * do not change again until after we have left it.	     */	    screen_was_changed = FALSE;	}#endif /* __hpux */    if (phys == hptablet_extension && log->open_cnt == 0)	return;    /*     * Clip the cursor to stay within the bound of screen.     */    if (log == hpPointer &&        (!hpConstrainXY (&log->coords[0], &log->coords[1])))	   return;    move_mouse (log, lastEventTime);    }/**************************************************************************** * * change_the_screen() * We have more than one screen, and the screen_change_device has been moved  * off one of the edges.  Change to another screen. * */#if defined(__hpux) || defined(__hp_osf) || defined(hp9000)#define INCREMENT_SCREEN_BY_ONE(p,l) (screenInfo.screens[(p->myNum+1) % \    screenInfo.numScreens])#define DECREMENT_SCREEN_BY_ONE(p,l) (p->myNum != 0 ? \    screenInfo.screens[p->myNum-1] : \    screenInfo.screens[screenInfo.numScreens - 1])#define INCREMENT_SCREEN_BY_TWO(p,l) (screenInfo.screens[(p->myNum+2) % \    screenInfo.numScreens])#define DECREMENT_SCREEN_BY_TWO(p,l) (p->myNum > 1 ? \    screenInfo.screens[p->myNum-2] : \    screenInfo.screens[p->myNum + screenInfo.numScreens - 2])change_the_screen (dev, phys, log, state)    DeviceIntPtr dev;    HPInputDevice *phys, *log;				/* logical device */    unsigned int state;    {    ScreenPtr  	pScreen;    WindowPtr	pRootWin;    int		tx, ty;    if (screen_col_wrap == DEFAULT)	{	if (screen_orientation == VERTICAL)	    screen_col_wrap = WRAP;	else	    screen_col_wrap = NOWRAP;	}    if (screen_row_wrap == DEFAULT)	{	if (screen_orientation == HORIZONTAL)	    screen_row_wrap = WRAP;	else	    screen_row_wrap = NOWRAP;	}    pScreen = log->pScreen;    switch (state)	{	case EDGE_L:	    if (screen_row_wrap == NOWRAP &&		(screen_orientation == VERTICAL ||	        (pScreen->myNum == 0  ||	        (pScreen->myNum == 2 && screen_orientation == MATRIX ))))		return;	    if (screen_orientation == VERTICAL)		{		if (screen_row_wrap == CHANGE_BY_TWO)		    {		    log->pScreen = DECREMENT_SCREEN_BY_TWO(pScreen,log);		    }		}	    else if (screen_orientation == HORIZONTAL)		{		log->pScreen = DECREMENT_SCREEN_BY_ONE(pScreen,log);		}	    else if (screen_orientation == MATRIX)		{		if (pScreen->myNum % 2)		    {		    log->pScreen = DECREMENT_SCREEN_BY_ONE(pScreen,log);		    }	        else if (screen_row_wrap == WRAP)		    {		    if (!(screenInfo.numScreens == 3 && pScreen->myNum == 2))	    	        {		        log->pScreen = INCREMENT_SCREEN_BY_ONE(pScreen,log);		        }		    }		else		    break;		}    	    if (!(log->hil_header.flags & HIL_ABSOLUTE))		log->coords[0] += (log->pScreen->width - log->change_xmin);	    break;	case EDGE_R:	    if (screen_row_wrap == NOWRAP &&		(screen_orientation == VERTICAL ||	        (pScreen->myNum == 3  ||	        (pScreen->myNum == 1 && screen_orientation == MATRIX ))))		return;	    if (screen_orientation == VERTICAL)		{		if (screen_row_wrap == CHANGE_BY_TWO)		    {		    log->pScreen = INCREMENT_SCREEN_BY_TWO(pScreen,log);		    }		}	    else if (screen_orientation == HORIZONTAL)		{		log->pScreen = INCREMENT_SCREEN_BY_ONE(pScreen,log);		}	    else if (screen_orientation == MATRIX)		{	        if (pScreen->myNum % 2)		    {	            if (screen_row_wrap == WRAP)		        {		        log->pScreen = DECREMENT_SCREEN_BY_ONE(pScreen,log);		        }		    else			break;		    }		else if (!(screenInfo.numScreens == 3 && pScreen->myNum == 2))		    {		    log->pScreen = INCREMENT_SCREEN_BY_ONE(pScreen,log);		    }		else if (screen_row_wrap != WRAP)		    break;		}	    if (!(log->hil_header.flags & HIL_ABSOLUTE))		log->coords[0] -= (pScreen->width);	    break;	case EDGE_T:	    if (screen_col_wrap == NOWRAP &&		(screen_orientation == HORIZONTAL ||	        (pScreen->myNum == 3  ||	        (pScreen->myNum == 2 && screen_orientation == MATRIX ))))		return;	    if (screen_orientation == HORIZONTAL)		{		if (screen_col_wrap == CHANGE_BY_TWO)		    {		    log->pScreen = INCREMENT_SCREEN_BY_TWO(pScreen,log);		    }		}	    else if (screen_orientation == VERTICAL)		{		log->pScreen = INCREMENT_SCREEN_BY_ONE(pScreen,log);		}	    else if (screen_orientation == MATRIX)	        {		if (pScreen->myNum >= 2) 		    {		    if (screen_col_wrap == WRAP)		        {		        log->pScreen = DECREMENT_SCREEN_BY_TWO(pScreen,log);		        }		    else			break;		    }		else if (!(screenInfo.numScreens == 3 && pScreen->myNum == 1))		    {		    log->pScreen = INCREMENT_SCREEN_BY_TWO(pScreen,log);		    }		else if (screen_col_wrap != WRAP)		    break;		}    	    if (!(log->hil_header.flags & HIL_ABSOLUTE))		log->coords[1] += (pScreen->height);	    break;	case EDGE_B:	    if (screen_col_wrap == NOWRAP &&		(screen_orientation == HORIZONTAL ||	        (pScreen->myNum == 0  ||	        (pScreen->myNum == 1 && screen_orientation == MATRIX))))		return;	    if (screen_orientation == HORIZONTAL)		{		if (screen_col_wrap == CHANGE_BY_TWO)		    {		    log->pScreen = DECREMENT_SCREEN_BY_TWO(pScreen,log);		    }		}	    else if (screen_orientation == VERTICAL)		{		log->pScreen = DECREMENT_SCREEN_BY_ONE(pScreen,log);		}	    else if (screen_orientation == MATRIX)	        {		if (pScreen->myNum >= 2) 		    {		    log->pScreen = DECREMENT_SCREEN_BY_TWO(pScreen,log);		    }		else if (screen_col_wrap == WRAP)		    {		    if (! (screenInfo.numScreens == 3 && pScreen->myNum == 1))		        {		        log->pScreen = INCREMENT_SCREEN_BY_TWO(pScreen,log);		        }		    }		else		    break;		}	    if (!(log->hil_header.flags & HIL_ABSOLUTE))		log->coords[1] -= (pScreen->height);

⌨️ 快捷键说明

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