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

📄 gx.c

📁 <B>Digital的Unix操作系统VAX 4.2源码</B>
💻 C
📖 第 1 页 / 共 5 页
字号:
		        qep = &gx_events[i];		        if(qep->type == MOTION_TYPE) 			{			    qep->x = gxp->mouse.x;			    qep->y = gxp->mouse.y;			    qep->time = millis;			    qep->device = MOUSE_DEVICE;			    goto mbuttons;			}		    }		    /*		     * Put event into queue and do select		     */		    qep = &gx_events[gxp->qe.eTail];		    qep->type = MOTION_TYPE;		    qep->time = millis;		    qep->x = gxp->mouse.x;		    qep->y = gxp->mouse.y;		    qep->device = MOUSE_DEVICE;                    gxp->qe.eTail = EVROUND(gxp->qe.eTail+1);		    GX_DEBUG(GX_YOW,			     gx_putevent(qep);			     );		}		/*		 * See if mouse buttons have changed.		 */	     mbuttons:		new_switch = new_rep->state & 0x07;		old_switch = gx_last_rep.state & 0x07;		temp = old_switch ^ new_switch;		if( temp ) 		{		    for (j = 1; j < 8; j <<= 1) 		    {		/* check each button */			if (!(j & temp)) /* did this button change? */			    continue;			/*			 * Check for room in the queue			 */                        if ((i = EVROUND(gxp->qe.eTail+1)) == gxp->qe.eHead) 			    return(0);			/* put event into queue and do select */                        qep = &gx_events[gxp->qe.eTail];			switch (j) {			 case RIGHT_BUTTON:			    qep->key = EVENT_RIGHT_BUTTON;			    break;			 case MIDDLE_BUTTON:			    qep->key = EVENT_MIDDLE_BUTTON;			    break;			 case LEFT_BUTTON:			    qep->key = EVENT_LEFT_BUTTON;			    break;			}			if (new_switch & j)			    qep->type = BUTTON_DOWN_TYPE;			else			    qep->type = BUTTON_UP_TYPE;			qep->device = MOUSE_DEVICE;			qep->time = TOY;			qep->x = gxp->mouse.x;			qep->y = gxp->mouse.y;			gxp->qe.eTail = i;		    }		    /* update the last report */		    gx_last_rep = current_rep;		    gxp->mswitches = new_switch;		}	    }			/* Pick up mouse input */	    else if ((unit == 1) && (pointer_id == TABLET_ID)) 	    {		/* tablet coordinates are scaled to match root window */		new_rep->dx = 		    ((new_rep->dx * gxp->max_x) / 2200) - /*hotX*/gxp->tablet.x;		new_rep->dy =		    (((2200 - new_rep->dy) * gxp->max_y) / 2200)			- /*hotY*/gxp->tablet.y;		/* constrain cursor */		if( new_rep->dx > gxp->max_cur_x )		    new_rep->dx = gxp->max_cur_x;		if( new_rep->dx < gxp->min_cur_x )		    new_rep->dx = gxp->min_cur_x;		if( new_rep->dy > gxp->max_cur_y )		    new_rep->dy = gxp->max_cur_y;		if( new_rep->dy < gxp->min_cur_y )		    new_rep->dy = gxp->min_cur_y;		/*		 * see if the puck/stylus has moved		 */		if (gxp->mouse.x != new_rep->dx ||		    gxp->mouse.y != new_rep->dy) 		{		    /*		     * update cursor position		     */		    gxp->mouse.x = new_rep->dx;		    gxp->mouse.y = new_rep->dy;		    if( tp->t_state & TS_ISOPEN )			gx_pos_cur( gxp->mouse.x, gxp->mouse.y );		    gx_tcs[gxp->qe.tcNext].time = TOY;		    gx_tcs[gxp->qe.tcNext].x = gxp->mouse.x;		    gx_tcs[gxp->qe.tcNext].y = gxp->mouse.y;		    if (++(gxp->qe.tcNext) >= MOTION_BUFFER_SIZE)			gxp->qe.tcNext = 0;		    if (gxp->mouse.y < gxp->mbox.bottom &&			gxp->mouse.y >=  gxp->mbox.top &&			gxp->mouse.x < gxp->mbox.right &&			gxp->mouse.x >=  gxp->mbox.left) goto tbuttons;		    gxp->mbox.bottom = 0; /* trash box */		    if (EVROUND(gxp->qe.eTail+1) == gxp->qe.eHead)			goto tbuttons;		    /*		     * Put event into queue and do select		     */		    qep = &gx_events[gxp->qe.eTail];		    qep->type = MOTION_TYPE;		    qep->device = TABLET_DEVICE;		    qep->x = gxp->mouse.x;		    qep->y = gxp->mouse.y;		    qep->key = 0;		    qep->time = TOY;		    gxp->qe.eTail = EVROUND(gxp->qe.eTail+1);		    GX_DEBUG(GX_YOW,			     gx_putevent(qep);			     );		}		/*		 * See if tablet buttons have changed.		 */	     tbuttons:		new_switch = new_rep->state & 0x1e;		old_switch = gx_last_rep.state & 0x1e;		temp = old_switch ^ new_switch;		if( temp ) 		{		    /* define the changed button and if up or down */		    for (j = 1; j <= 0x10; j <<= 1) 		    {			/* check each button */			if (!(j & temp)) /* did this button change? */			    continue;			if((i=EVROUND(gxp->qe.eTail+1)) == gxp->qe.eHead) 			    return(0);			/* put event into queue and do select */			qep = &gx_events[gxp->qe.eTail];			switch (j) 			    {			     case T_RIGHT_BUTTON:				qep->key = EVENT_T_RIGHT_BUTTON;				break;			     case T_FRONT_BUTTON:				qep->key = EVENT_T_FRONT_BUTTON;				break;			     case T_BACK_BUTTON:				qep->key = EVENT_T_BACK_BUTTON;				break;			     case T_LEFT_BUTTON:				qep->key = EVENT_T_LEFT_BUTTON;				break;			    }		    	if (new_switch & j)			    qep->type = BUTTON_DOWN_TYPE;		    	else			    qep->type = BUTTON_UP_TYPE;			qep->device = TABLET_DEVICE;			qep->x = gxp->mouse.x;			qep->y = gxp->mouse.y;			qep->time = TOY;			gxp->qe.eTail =  i;		    }		    /* update the last report */		    gx_last_rep = current_rep;		}	    }				/* Pick up tablet input */	}				/* While input available */	/*	 * If we have proc waiting, and event has happened, wake him up	 */	if(gx_rsel && (gxp->qe.eHead != gxp->qe.eTail)) 	{	    GX_DEBUG(GX_YOW,		     gx_puts("gxkint: select wakeup\n");		     );	    selwakeup(gx_rsel,0);	    gx_rsel = 0;	} else if (gxp->qe.eHead != gxp->qe.eTail) {	    ttwakeup(tp);	}    }    else     {	/*	 * If the graphic device is not turned on, this is console input	 */	/*	 * Get a character from the keyboard.	 */	if (unit == 0) 	{	    register int s;	    data = ch & 0xff;	    /*	     * Check for various keyboard errors	     */	    if (data == LK_POWER_ERROR || data == LK_KDOWN_ERROR ||		data == LK_INPUT_ERROR || data == LK_OUTPUT_ERROR) 	    {		if(!gx_inkbdreset) { /* gets recursive */		    mprintf("gx0: Keyboard error, code = %x\n",data);		    gx_kbdreset();		}		return(0);	    }	    if( data < LK_LOWEST ) 		return(0);	    /*	     * See if its a state change key	     */	    switch ( data ) 	    {	     case LOCK:		gx_keyboard.lock ^= 0xffff; /* toggle */		IPLTTY(s);		if( gx_keyboard.lock )		    (*slu.kbd_putc)( LK_LED_ENABLE );		else		    (*slu.kbd_putc)( LK_LED_DISABLE );		(*slu.kbd_putc)( LED_3 );		splx(s);		return;	     case SHIFT:		gx_keyboard.shift ^= 0xffff;		return;		     case CNTRL:		gx_keyboard.cntrl ^= 0xffff;		return;	     case ALLUP:		gx_keyboard.cntrl = gx_keyboard.shift = 0;		return;	     case REPEAT:		c = gx_keyboard.last;		break;	     case HOLD:		/*		 * "Hold Screen" key was pressed, we treat it as 		 *  if ^s or ^q was typed.  		 */		if (gx_keyboard.hold == 0) 		{		    if((tp->t_state & TS_TTSTOP) == 0) 		    {			register int s;			c = q_key[CHAR_S];			IPLTTY(s);			(*slu.kbd_putc)( LK_LED_ENABLE );			(*slu.kbd_putc)( LED_4 );			gx_keyboard.hold = 1;			splx(s);		    } else			c = q_key[CHAR_Q];		}		else 		{		    register int s;		    c = q_key[CHAR_Q];		    IPLTTY(s);		    (*slu.kbd_putc)( LK_LED_DISABLE );		    (*slu.kbd_putc)( LED_4 );		    gx_keyboard.hold = 0;		    splx(s);		}		if( c >= ' ' && c <= '~' )		    c &= 0x1f;		else if (c >= 0xA1 && c <= 0xFE)		    c &= 0x9F;		(*linesw[tp->t_line].l_rint)(c, tp);		return;	     default:		/*		 * Test for control characters. If set, see if the 		 * character is elligible to become a control 		 * character.		 */		if( gx_keyboard.cntrl ) 		{		    c = q_key[ data ];		    if( c >= ' ' && c <= '~' )			c &= 0x1f;		} else if( gx_keyboard.lock || gx_keyboard.shift )		    c = q_shift_key[ data ];		else		    c = q_key[ data ];		break;		    }	    gx_keyboard.last = c;	    /*	     * Check for special function keys	     */	    if( c & 0x100 ) 	    {		register char *string;		string = q_special[ c & 0x7f ];		while( *string )		    (*linesw[tp->t_line].l_rint)(*string++, tp);	    } 	    else 	    {		if (tp->t_iflag & ISTRIP) /* Strip to 7 bits. */		    c &= 0177;			else 		{		/* Take the full 8-bits */		    /*		     * If ISTRIP is not set a valid character of 377		     * is read as 0377,0377 to avoid ambiguity with		     * the PARMARK sequence.		     */ 		    if ((c == 0377) && (tp->t_line == TERMIODISC) &&			(tp->t_iflag & PARMRK))			(*linesw[tp->t_line].l_rint)(0377,tp);				}	        (*linesw[tp->t_line].l_rint)(c, tp);	    }	    if (gx_keyboard.hold &&((tp->t_state & TS_TTSTOP) == 0)) 	    {		register int s;		IPLTTY(s);		(*slu.kbd_putc)( LK_LED_DISABLE );		(*slu.kbd_putc)( LED_4 );		gx_keyboard.hold = 0;		splx(s);	    }	}    }    return(0);}/* gxkint */gx_kbdreset(){    register int i;    gx_inkbdreset = 1;    (*slu.kbd_putc) (LK_DEFAULTS);    DELAY(100000);    for (i=1; i < 15; i++)	(*slu.kbd_putc) (gx_divdefaults[i] | (i << 3));    DELAY(100000);    for (i = 0; i < KBD_INIT_LENGTH; i++)	(*slu.kbd_putc) (gx_kbdinitstring[i]);    gx_inkbdreset = 0;}/* end gx_kbdreset *//****************************************************************** **                                                              ** ** Routine to start transmission. 				** **                                                              ** ******************************************************************/gxstart(tp)    register struct tty *tp;{    register int unit, c;    register struct tty *tp0;    register int s, xcons_status;    unit = minor(tp->t_dev);    IPLTTY(s);    /*     * If it's currently active, or delaying, no need to do anything.     */    if (tp->t_state&(TS_TIMEOUT|TS_BUSY|TS_TTSTOP))	goto out;    /*     * Display chars until the queue is empty, if the second subchannel      * is open irect them there. Drop characters from any lines other      * than 0 on the floor. TANDEM is set on second subchannel for flow      * control.     */    while( tp->t_outq.c_cc ) {	if (unit == 0) {		/* console device */	    xcons_status = xcons_chkq();	    	    switch (xcons_status) {	      case XCONS_CLOSED:		c = getc(&tp->t_outq);		gx_blitc(c & 0xff);		break;			      case XCONS_BLOCKED:		goto out;		break;			      case XCONS_OK:		c = getc(&tp->t_outq);		xconsrint(c);		break;	    }	} else	    c = getc(&tp->t_outq);    }    /*     * Position the cursor to the next character location.     */    if (!(gx_dev_inuse & GRAPHIC_DEV))	GX_POS_CUR( gxp->col*_TEXT_WIDTH, gxp->row*_TEXT_HEIGHT );    /*     * If there are sleepers, and output has drained below low     * water mark, wake up the sleepers.     */    tp->t_state &= ~TS_BUSY; out:    if ( tp->t_outq.c_cc<=TTLOWAT(tp) )	if (tp->t_state&TS_ASLEEP)	{	    tp->t_state &= ~TS_ASLEEP;	    wakeup((caddr_t)&tp->t_outq);	}    splx(s);}/* gxstart *//****************************************************************** **                                                              ** ** Routine to stop output on the graphic device, e.g. for ^S/^Q ** ** or output flush.                                             ** **                                                              ** ******************************************************************//*ARGSUSED*/gxstop(tp, flag)    register struct tty *tp;{    register int s;    /*     * Block interrupts while modifying the state.     */    IPLTTY(s);    if (tp->t_state & TS_BUSY)	if ((tp->t_state&TS_TTSTOP)==0)	    tp->t_state |= TS_FLUSH;	else	    tp->t_state &= ~TS_BUSY;    splx(s);}/* gxstop */gx_rect(x, y, h, w, rgb, buf)    /* <x,y> = top-left corner of rectangle */    int x, y, h/*eight*/, w/*idth*/, rgb, buf;{    register int *ip, *stampPacket, lw;    if (stampPacket = ip = (*_gx_getPacket)())    {	GX_DEBUG(GX_YOW,		 gx_printf("gx_rect(x=%d,y=%d,w=%d,h=%d,0x%6x,%d) pkt=0x%x\n",			   x, y, w, h, rgb, stampPacket, buf);

⌨️ 快捷键说明

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