void GsSelect(void) { struct MW_UID_MESSAGE m; int rc; unsigned int timeout = 10; /* perform pre-select duties, if any*/ if(scrdev.PreSelect) { scrdev.PreSelect(&scrdev); } /* let's make sure that the type is invalid */ m.type = MV_UID_INVALID; /* wait up to 100 milisecons for events */ rc = uid_read_message( &m, timeout ); /* return if timed-out or something went wrong */ if( rc < 0 ) { if( errno != ETIMEDOUT ) EPRINTF( " rc= %d, errno=%d\n", rc, errno ); else { /* timeout handling */ } return; } /* let's pass the event up to microwindows */ switch( m.type ) { /* Mouse or Touch Screen event */ case MV_UID_REL_POS: case MV_UID_ABS_POS: m_mou = m; while(GsCheckMouseEvent()) continue; break; /* KBD event */ case MV_UID_KBD: m_kbd = m; GsCheckKeyboardEvent(); break; /* micro-windows does nothing with those.. */ case MV_UID_TIMER: case MV_UID_INVALID: default: ; } }
void receive_uid_message(void) { int rc; struct MW_UID_MESSAGE uid; rc = uid_read_message( &uid, 0 ); if ( rc != sizeof(struct MW_UID_MESSAGE) ) return; printf_uid_message( &uid ); }
void MwSelect (void) { struct MW_UID_MESSAGE m; int rc; unsigned int timeout = 0; /* perform pre-select duties, if any*/ if (scrdev.PreSelect) scrdev.PreSelect (&scrdev); /* Set up the timeout for the main select(). * If the mouse is captured we're probably moving a window, * so poll quickly to allow other windows to repaint while * checking for more event input. */ if (!dragwp) { timeout = MwGetNextTimeoutValue (); /* returns ms*/ if (timeout < 10) timeout = 10; /* 10ms required for vt fb switch*/ } /* let's make sure that the type is invalid */ m.type = MV_UID_INVALID; /* wait up to 100 milisecons for events */ rc = uid_read_message (&m, timeout); /* return if timed-out or something went wrong */ if (rc < 0) { if ( errno != ETIMEDOUT ) EPRINTF (" rc= %d, errno=%d\n", rc, errno); else { MwHandleTimers (); } return; } /* let's pass the event up to microwindows */ switch (m.type) { case MV_UID_REL_POS: /* Mouse or Touch Screen event */ case MV_UID_ABS_POS: m_mou = m; while (MwCheckMouseEvent ()) continue; break; case MV_UID_KBD: /* KBD event */ m_kbd = m; MwCheckKeyboardEvent(); break; case MV_UID_TIMER: /* Microwindows does nothing with these.. */ case MV_UID_INVALID: default: break; } }
void GsSelect (GR_TIMEOUT timeout) { struct MW_UID_MESSAGE m; long uid_timeout; GR_EVENT_GENERAL *gp; int rc; #if MW_FEATURE_TIMERS struct timeval tout; #endif /* perform pre-select duties, if any*/ if (scrdev.PreSelect) scrdev.PreSelect(&scrdev); /* let's make sure that the type is invalid */ m.type = MV_UID_INVALID; /* wait up for events */ if (timeout == (GR_TIMEOUT) -1) uid_timeout = 0; else { #if MW_FEATURE_TIMERS if (GdGetNextTimeout(&tout, timeout)) uid_timeout = tout.tv_sec * 1000 + (tout.tv_usec + 500) / 1000; else #endif { if (timeout == 0) uid_timeout = (unsigned long) -1; else uid_timeout = timeout; } } rc = uid_read_message (&m, uid_timeout); /* return if timed-out or something went wrong */ if (rc < 0) { if (errno != ETIMEDOUT) EPRINTF(" rc= %d, errno=%d\n", rc, errno); else { #if MW_FEATURE_TIMERS /* check for timer timeouts and service if found*/ if (GdTimeout()) #else if (timeout != 0) #endif { /* * Timeout has occured. Currently return a timeout event * regardless of whether client has selected for it. */ if ((gp = (GR_EVENT_GENERAL *)GsAllocEvent(curclient)) != NULL) gp->type = GR_EVENT_TYPE_TIMEOUT; } } return; } /* let's pass the event up to Microwindows */ switch (m.type) { case MV_UID_REL_POS: /* Mouse or Touch Screen event */ case MV_UID_ABS_POS: m_mou = m; while (GsCheckMouseEvent()) continue; break; case MV_UID_KBD: /* KBD event */ m_kbd = m; GsCheckKeyboardEvent (); break; case MV_UID_TIMER: /* Microwindows does nothing with these.. */ case MV_UID_INVALID: default: break; } }