Main Page | Data Structures | Directories | File List | Data Fields | Globals

mouse.hcc

Go to the documentation of this file.
00001 
00021 /******** System Includes *************/
00022 #include <stdlib.hch>
00023 
00024 #include "pal_master.hch"
00025 #include "pal_mouse.hch"
00026 
00027 /******** Application Includes ********/
00028 #include "configuration.hch"
00029 #include "mouse_shared.hch"
00030 #include "mouse.hch"
00031 
00032 #if HAVE_DEBUG
00033         #include "debug.hch"
00034 #endif
00035 
00036 
00037 
00048 void mouse_main(mousedata_t *mousedata) {
00049         unsigned 18 touch_sampler;
00050         unsigned 10 x, oldx;
00051         unsigned 9 y, oldy;
00052         unsigned 3 mousestate, oldmousestate;
00053         unsigned 1 touch, touched, oldtouched;
00054 
00055         /*
00056          * We only check for mouse states once every 2^18 time. This to
00057          * overcome the sampling of the 'Touch' state of the RC200 libs. When
00058          * using newer libs this might be overkill, e.g. smaller values may
00059          * work or sampling all together will be redundant.
00060          */
00061         touch_sampler = 1;
00062         while (TRUE) {
00063                 if (!touch_sampler) {
00064                         /*
00065                          * We are here ready to set mouse states. We compare
00066                          * current and previous states and thereby determine
00067                          * the state to send to others
00068                          */
00069                         if (touched) {
00070                                 if(oldtouched) {
00071                                         mousestate = MOUSE_STATE_DOWN;
00072                                 } else {
00073                                         mousestate = MOUSE_STATE_ON_PRESS;
00074                                 }
00075                                 oldtouched = TRUE;
00076                         } else {
00077                                 if(oldtouched) {
00078                                         mousestate = MOUSE_STATE_ON_RELEASE;
00079                                 } else {
00080                                         mousestate = MOUSE_STATE_UP;
00081                                 }
00082                                 oldtouched = FALSE;
00083                         }
00084                         /*
00085                          * We have now processed our Touch. Reset it for the
00086                          * next run.
00087                          */
00088                         touched = FALSE;
00089 
00090                         /*
00091                          * In the rare occurance that we receive values
00092                          * beyond our range, we set them to some sane
00093                          * values here.
00094                          */
00095                          x = (x > 639) ? 0 : x;
00096                          y = (y > 479) ? 0 : y;
00097 
00098                         /*
00099                          * Compare Previous States and Coordinates to determine
00100                          * wether they have changed. If so, Copy them into
00101                          * shared memory, notify the listening processes and
00102                          * Set the new as previous values for the next run. We
00103                          * can only do this when the display has handled all
00104                          * changes.
00105                          */
00106                         if (((oldmousestate != mousestate) || (oldx != x) || (oldy != y)) && (MOUSE_NOT_UPDATED == mousedata->status)) {
00107                                 //par {
00108                                         oldx = x;
00109                                         oldy = y;
00110                                         oldmousestate = mousestate;
00111                                         mousedata->x = x;
00112                                         mousedata->y = 0 @ y;
00113                                         mousedata->state = mousestate;
00114                                         mousedata->status = MOUSE_UPDATED;
00115                                 //}
00116                         }
00117                 }
00118 
00119                 /*
00120                  * Read the current X and Y of the 'cursor' and register wether
00121                  * the display was touched. If touched store this in a local
00122                  * store. This we do to catch the sampling of the RC200 lib.
00123                  */
00124                 RC200TouchScreenReadScaled(&x, &y, &touch);
00125                 if (touch) {
00126                         touched = TRUE;
00127                 }
00128 
00129                 touch_sampler++;
00130         }
00131 } /* --- mouse_main() --- */

Generated on Thu Dec 9 14:37:07 2004 for Graphic Equalizer 2 by  doxygen 1.3.9.1