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

📄 qd.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 5 页
字号:
			     !(adder->status&ID_SCROLL_READY); --i)			      ;			if (i == 0) {			    printf("qd%d: qdaint: timeout on ID_SCROLL_READY\n",				qd);				return;			}			adder->ID_scroll_data = scroll[qd]->viper_constant;			adder->ID_scroll_command = ID_LOAD | SCROLL_CONSTANT;			adder->y_scroll_constant =				scroll[qd]->y_scroll_constant;			adder->y_offset_pending = scroll[qd]->y_offset;			if (scroll[qd]->status & LOAD_INDEX) {				adder->x_index_pending = 					scroll[qd]->x_index_pending;				adder->y_index_pending = 					scroll[qd]->y_index_pending;			}			scroll[qd]->status = 0x00;		}	}}/* *  DUART input interrupt service routine * *  XXX - this routine should be broken out - it is essentially *	      straight line code. */qdiint(qd)	register qd;{	register struct _vs_event *event;	register struct qdinput *eqh;	struct dga *dga;	struct duart *duart;	struct mouse_report *new_rep;	struct uba_device *ui;	struct tty *tp;	u_short chr;	u_short status;	u_short data;	u_short key;	char do_wakeup = 0;		/* flag to do a select wakeup call */	char a, b, c;			/* mouse button test variables */	(void)spl4(); 			/* allow interval timer in */	eqh = eq_header[qd];		/* optimized as a register */	new_rep = &current_rep[qd];	duart = (struct duart *) qdmap[qd].duart;	/*	* if the graphic device is turned on..		*/	if (qdflags[qd].inuse & GRAPHIC_DEV) {		/*		* empty DUART 		*/		while (duart->statusA&RCV_RDY || duart->statusB&RCV_RDY) {			/*			 * pick up LK-201 input (if any) 			 */			if (duart->statusA&RCV_RDY) {				/* if error condition, then reset it */				if (duart->statusA&0x70) {					duart->cmdA = 0x40;					continue;				}				/* event queue full now? (overflow condition) */				if (ISFULL(eqh) == TRUE) {					printf(					 "qd%d: qdiint: event queue overflow\n",					   qd);					break;				}				/*				* Check for various keyboard errors  */				key = duart->dataA & 0xFF;				if (key==LK_POWER_ERROR ||				    key==LK_KDOWN_ERROR ||				    key == LK_INPUT_ERROR || 				    key == LK_OUTPUT_ERROR) {					printf(				    "qd%d: qdiint: keyboard error, code = %x\n",					qd,key);					return;				}				if (key < LK_LOWEST)				    return;				++do_wakeup;  /* request a select wakeup call */				event = PUTBEGIN(eqh);				PUTEND(eqh);				event->vse_key = key;				event->vse_key &= 0x00FF;				event->vse_x = eqh->curs_pos.x;				event->vse_y = eqh->curs_pos.y;				event->vse_time = TOY;				event->vse_type = VSE_BUTTON;				event->vse_direction = VSE_KBTRAW;				event->vse_device = VSE_DKB;			}			/*			* pick up the mouse input (if any)  */			if ((status = duart->statusB) & RCV_RDY  &&			    qdflags[qd].pntr_id == MOUSE_ID) {				if (status & 0x70) {					duart->cmdB = 0x40;					continue;				}				/* event queue full now? (overflow condition) */				if (ISFULL(eqh) == TRUE) {					printf(					"qd%d: qdiint: event queue overflow\n",					     qd);					break;				}				data = duart->dataB;      /* get report byte */				++new_rep->bytcnt; /* bump report byte count */				/*				* if 1st byte of report.. */				if ( data & START_FRAME) {					new_rep->state = data;					if (new_rep->bytcnt > 1) {						/* start of new frame */						new_rep->bytcnt = 1;    						/* ..continue looking */						continue;		    					}				}				/*				* if 2nd byte of report.. */				else if (new_rep->bytcnt == 2) {					new_rep->dx = data & 0x00FF;				}				/*				* if 3rd byte of report, load input event queue */				else if (new_rep->bytcnt == 3) {					new_rep->dy = data & 0x00FF;					new_rep->bytcnt = 0;					/*					* if mouse position has changed.. */					if (new_rep->dx != 0  ||  new_rep->dy != 0) {						/*						* calculate acceleration factor, if needed	*/						if (qdflags[qd].curs_acc > ACC_OFF) {							if (qdflags[qd].curs_thr <= new_rep->dx)							    new_rep->dx +=							    (new_rep->dx - qdflags[qd].curs_thr)							    * qdflags[qd].curs_acc;							if (qdflags[qd].curs_thr <= new_rep->dy)							    new_rep->dy +=							    (new_rep->dy - qdflags[qd].curs_thr)							    * qdflags[qd].curs_acc;						}						/*						* update cursor position coordinates */						if (new_rep->state & X_SIGN) {							eqh->curs_pos.x += new_rep->dx;							if (eqh->curs_pos.x > 1023)							    eqh->curs_pos.x = 1023;						}						else {							eqh->curs_pos.x -= new_rep->dx;							if (eqh->curs_pos.x < -15)							    eqh->curs_pos.x = -15;						}						if (new_rep->state & Y_SIGN) {							eqh->curs_pos.y -= new_rep->dy;							if (eqh->curs_pos.y < -15)							    eqh->curs_pos.y = -15;						}						else {							eqh->curs_pos.y += new_rep->dy;							if (eqh->curs_pos.y > 863)							    eqh->curs_pos.y = 863;						}						/*						* update cursor screen position */						dga = (struct dga *) qdmap[qd].dga;						dga->x_cursor = TRANX(eqh->curs_pos.x);						dga->y_cursor = TRANY(eqh->curs_pos.y);						/*						* if cursor is in the box, no event report */						if (eqh->curs_pos.x <= eqh->curs_box.right	&&						    eqh->curs_pos.x >= eqh->curs_box.left  &&						    eqh->curs_pos.y >= eqh->curs_box.top  &&						    eqh->curs_pos.y <= eqh->curs_box.bottom ) {							goto GET_MBUTTON;						}						/*						* report the mouse motion event */						event = PUTBEGIN(eqh);						PUTEND(eqh);						++do_wakeup;   /* request a select wakeup call */						event->vse_x = eqh->curs_pos.x;						event->vse_y = eqh->curs_pos.y;						event->vse_device = VSE_MOUSE;  /* mouse */						event->vse_type = VSE_MMOTION;  /* pos changed */						event->vse_key = 0;						event->vse_direction = 0;						event->vse_time = TOY;	/* time stamp */					}GET_MBUTTON:					/*					* if button state has changed */					a = new_rep->state & 0x07;    /*mask nonbutton bits */					b = last_rep[qd].state & 0x07;					if (a ^ b) {						for ( c = 1;  c < 8; c <<= 1) {							if (!( c & (a ^ b))) /* this button change? */							    continue;							/* event queue full? (overflow condition) */							if (ISFULL(eqh) == TRUE) {								printf("qd%d: qdiint: event queue overflow\n", qd);								break;							}							event = PUTBEGIN(eqh);	/* get new event */							PUTEND(eqh);							++do_wakeup;   /* request select wakeup */							event->vse_x = eqh->curs_pos.x;							event->vse_y = eqh->curs_pos.y;							event->vse_device = VSE_MOUSE;	/* mouse */							event->vse_type = VSE_BUTTON; /* new button */							event->vse_time = TOY;	      /* time stamp */							/* flag changed button and if up or down */							if (c == RIGHT_BUTTON)							    event->vse_key = VSE_RIGHT_BUTTON;							else if (c == MIDDLE_BUTTON)							    event->vse_key = VSE_MIDDLE_BUTTON;							else if (c == LEFT_BUTTON)							    event->vse_key = VSE_LEFT_BUTTON;							/* set bit = button depressed */							if (c & a)							    event->vse_direction = VSE_KBTDOWN;							else								event->vse_direction = VSE_KBTUP;						}					}					/* refresh last report */					last_rep[qd] = current_rep[qd];				}  /* get last byte of report */			} else if ((status = duart->statusB)&RCV_RDY &&			           qdflags[qd].pntr_id == TABLET_ID) {				/*				* pickup tablet input, if any  				*/				if (status&0x70) {					duart->cmdB = 0x40;					continue;				}				/* 				 * event queue full now? (overflow condition) 				 */				if (ISFULL(eqh) == TRUE) {					printf("qd%d: qdiint: event queue overflow\n", qd);					break;				}				data = duart->dataB;      /* get report byte */				++new_rep->bytcnt;	      /* bump report byte count */				/*				* if 1st byte of report.. */				if (data & START_FRAME) {					new_rep->state = data;					if (new_rep->bytcnt > 1) {						new_rep->bytcnt = 1;    /* start of new frame */						continue;		    /* ..continue looking */					}				}				/*				* if 2nd byte of report.. */				else if (new_rep->bytcnt == 2) {					new_rep->dx = data & 0x3F;				}				/*				* if 3rd byte of report.. */				else if (new_rep->bytcnt == 3) {					new_rep->dx |= (data & 0x3F) << 6;				}				/*				* if 4th byte of report.. */				else if (new_rep->bytcnt == 4) {					new_rep->dy = data & 0x3F;				}				/*				* if 5th byte of report, load input event queue */				else if (new_rep->bytcnt == 5) {					new_rep->dy |= (data & 0x3F) << 6;					new_rep->bytcnt = 0;					/*					* update cursor position coordinates */					new_rep->dx /= qdflags[qd].tab_res;					new_rep->dy = (2200 - new_rep->dy)					    / qdflags[qd].tab_res;					if (new_rep->dx > 1023) {						new_rep->dx = 1023;					}					if (new_rep->dy > 863) {						new_rep->dy = 863;					}					/*					* report an event if the puck/stylus has moved					*/					if (eqh->curs_pos.x != new_rep->dx ||					    eqh->curs_pos.y != new_rep->dy) {						eqh->curs_pos.x = new_rep->dx;						eqh->curs_pos.y = new_rep->dy;						/*						* update cursor screen position */						dga = (struct dga *) qdmap[qd].dga;						dga->x_cursor = TRANX(eqh->curs_pos.x);						dga->y_cursor = TRANY(eqh->curs_pos.y);						/*						* if cursor is in the box, no event report						*/						if (eqh->curs_pos.x <= eqh->curs_box.right	&&						    eqh->curs_pos.x >= eqh->curs_box.left  &&						    eqh->curs_pos.y >= eqh->curs_box.top  &&						    eqh->curs_pos.y <= eqh->curs_box.bottom ) {							goto GET_TBUTTON;						}						/*						* report the tablet motion event */						event = PUTBEGIN(eqh);						PUTEND(eqh);						++do_wakeup;   /* request a select wakeup call */						event->vse_x = eqh->curs_pos.x;						event->vse_y = eqh->curs_pos.y;						event->vse_device = VSE_TABLET;  /* tablet */						/*						* right now, X handles tablet motion the same						* as mouse motion						*/						event->vse_type = VSE_MMOTION;   /* pos changed */						event->vse_key = 0;						event->vse_direction = 0;						event->vse_time = TOY;	/* time stamp */					}GET_TBUTTON:					/*					* if button state has changed */					a = new_rep->state & 0x1E;   /* mask nonbutton bits */					b = last_rep[qd].state & 0x1E;					if (a ^ b) {						/* event queue full now? (overflow condition) */						if (ISFULL(eqh) == TRUE) {							printf("qd%d: qdiint: event queue overflow\n",qd);							break;						}						event = PUTBEGIN(eqh);  /* get new event */						PUTEND(eqh);						++do_wakeup;   /* request a select wakeup call */						event->vse_x = eqh->curs_pos.x;						event->vse_y = eqh->curs_pos.y;						event->vse_device = VSE_TABLET;  /* tablet */						event->vse_type = VSE_BUTTON; /* button changed */						event->vse_time = TOY;	   /* time stamp */						/* define the changed button and if up or down */						for ( c = 1;  c <= 0x10; c <<= 1) {							if (c & (a ^ b)) {								if (c == T_LEFT_BUTTON)								    event->vse_key = VSE_T_LEFT_BUTTON;								else if (c == T_FRONT_BUTTON)								    event->vse_key = VSE_T_FRONT_BUTTON;								else if (c == T_RIGHT_BUTTON)								    event->vse_key = VSE_T_RIGHT_BUTTON;								else if (c == T_BACK_BUTTON)								    event->vse_key = VSE_T_BACK_BUTTON;								break;							}						}						/* set bit = button depressed */						if (c & a)						    event->vse_direction = VSE_KBTDOWN;						else							event->vse_direction = VSE_KBTUP;					}					/* refresh last report */					last_rep[qd] = current_rep[qd];				} /* get last byte of report */			} /* pick up tablet input */		} /* while input available.. */		/*		* do select wakeup			*/		if (qdrsel[qd] && do_wakeup && qdflags[qd].selmask & SEL_READ) {			selwakeup(qdrsel[qd], 0);			qdrsel[qd] = 0;			qdflags[qd].selmask &= ~SEL_READ;			do_wakeup = 0;		}	} else {		/*		 * if the graphic device is not turned on, this is console input		 */		if (qdpolling)			return;		ui = qdinfo

⌨️ 快捷键说明

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