]> git.kernelconcepts.de Git - karo-tx-redboot.git/blob - packages/services/gfx/mw/v2_0/src/drivers/mwselect_rtems.c
unified MX27, MX25, MX37 trees
[karo-tx-redboot.git] / packages / services / gfx / mw / v2_0 / src / drivers / mwselect_rtems.c
1 /*
2 /////////////////////////////////////////////////////////////////////////////
3 // $Header$
4 //
5 // Copyright (c) 2000 - Rosimildo da Silva
6 //  
7 // MODULE DESCRIPTION: 
8 // This module implements the "GsSelect()" function for MicroWindows.
9 //
10 // MODIFICATION/HISTORY:
11 //
12 // $Log$
13 // Revision 1.1.9.1  2009-06-15 14:11:07  lothar
14 // unified MX27, MX25, MX37 trees
15 //
16 // Revision 1.1.1.1  2001/06/21 06:32:41  greg
17 // Microwindows pre8 with patches
18 //
19 // Revision 1.1.1.1  2001/06/05 03:44:01  root
20 // First import of 5/5/2001 Microwindows to CVS
21 //
22 //
23 /////////////////////////////////////////////////////////////////////////////
24 */
25 #include <stdio.h>
26 #include <errno.h>
27
28 #include <rtems/mw_uid.h>
29 #include "device.h"
30 #include "windef.h"
31
32 extern MWBOOL MwCheckMouseEvent();
33 extern MWBOOL MwCheckKeyboardEvent();
34
35 #if ANIMATEPALETTE
36 static int fade = 0;
37 #endif
38
39 extern struct MW_UID_MESSAGE m_kbd;
40 extern struct MW_UID_MESSAGE m_mou;
41
42 extern HWND  dragwp;     /* window user is dragging*/
43 /*
44  * "Select() routine called by the Microwindows framework to receive events 
45  * from the input devices.
46  */
47 void MwSelect(void)
48 {
49   struct MW_UID_MESSAGE m;
50   int rc;
51   unsigned int timeout = 0;
52
53   /* perform pre-select duties, if any*/
54   if(scrdev.PreSelect)
55   {
56      scrdev.PreSelect(&scrdev);
57   }
58         /* Set up the timeout for the main select().  If
59          * the mouse is captured we're probably moving a window,
60          * so poll quickly to allow other windows to repaint while
61          * checking for more event input.
62          */
63         if( !dragwp )
64    {
65                 timeout = MwGetNextTimeoutValue();      /* returns ms*/
66 #if ANIMATEPALETTE
67                 if(fade < 100)
68                         timeout = 40;
69                 else 
70 #endif
71                 if(timeout == 0)
72                         timeout = 10;   /* 10ms required for vt fb switch*/
73         }
74
75   /* let's make sure that the type is invalid */
76   m.type = MV_UID_INVALID;
77
78   /* wait up to 100 milisecons for events */
79   rc = uid_read_message( &m, timeout );
80
81   /* return if timed-out or something went wrong */
82   if( rc < 0 )
83   {
84      if( errno != ETIMEDOUT )
85         EPRINTF( " rc= %d, errno=%d\n", rc, errno );
86      else
87      {
88 #if ANIMATEPALETTE
89        if(fade <= 100) {
90                         setfadelevel( &scrdev, fade );
91                            fade += 5;
92                  }
93 #endif
94                 MwHandleTimers();
95      }
96      return;
97   }
98
99   /* let's pass the event up to microwindows */
100   switch( m.type )
101   {
102     /* Mouse or Touch Screen event */
103     case MV_UID_REL_POS:
104     case MV_UID_ABS_POS:
105         m_mou = m;
106         while( MwCheckMouseEvent() )
107                          continue;
108         break;
109
110     /* KBD event */
111     case MV_UID_KBD:
112         m_kbd = m;
113         MwCheckKeyboardEvent();
114         break;
115
116     /* micro-windows does nothing with those.. */
117     case MV_UID_TIMER:
118     case MV_UID_INVALID:
119     default:
120        ;
121   }
122 }
123