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