summaryrefslogtreecommitdiffstats
path: root/Graphic_Equalizer_v1.0/src/mouse.hcc
diff options
context:
space:
mode:
Diffstat (limited to 'Graphic_Equalizer_v1.0/src/mouse.hcc')
-rw-r--r--Graphic_Equalizer_v1.0/src/mouse.hcc131
1 files changed, 131 insertions, 0 deletions
diff --git a/Graphic_Equalizer_v1.0/src/mouse.hcc b/Graphic_Equalizer_v1.0/src/mouse.hcc
new file mode 100644
index 0000000..84c324f
--- /dev/null
+++ b/Graphic_Equalizer_v1.0/src/mouse.hcc
@@ -0,0 +1,131 @@
+/*! \file mouse.hcc
+ *
+ * \section generic This module takes care of mouse input. The mouse
+ * input function itself is however performed by the
+ * touchscreen of the RC200.
+ *
+ * \section project Project information.
+ * Project Graphic Equalizer\n
+ * \author O.M. Schinagl
+ * \date 20041011
+ * \version 0.1
+ *
+ * \section copyright Copyright
+ * Copyright ©2004 Koninklijke Philips Electronics N.V. All rights reserved
+ *
+ * \section history Change history
+ * 20041011: O.M. Schinagl\n Initial version
+ *
+ ********************************************************************/
+
+/******** System Includes *************/
+#include <stdlib.hch>
+
+#include "pal_master.hch"
+#include "pal_mouse.hch"
+
+/******** Application Includes ********/
+#include "configuration.hch"
+#include "mouse_shared.hch"
+#include "mouse.hch"
+
+#if HAVE_DEBUG
+ #include "debug.hch"
+#endif
+
+
+
+/*! \fn void mouse_main(mousedata_t *mousedata);
+ * \brief Main mousedriver. This function never returns! It calls the
+ * main mousehandler and returns the States and coordinates
+ * into a shared store.
+ *
+ * \param *mousedata Storage for all mousedata and states.
+ *
+ * \return Never Returns.
+ * \retval void
+ */
+inline void mouse_main(mousedata_t *mousedata) {
+ unsigned 18 touch_sampler;
+ unsigned 10 x, oldx;
+ unsigned 9 y, oldy;
+ unsigned 3 mousestate, oldmousestate;
+ unsigned 1 touch, touched, oldtouched;
+
+ /*
+ * We only check for mouse states once every 2^18 time. This to
+ * overcome the sampling of the 'Touch' state of the RC200 libs. When
+ * using newer libs this might be overkill, e.g. smaller values may
+ * work or sampling all together will be redundant.
+ */
+ touch_sampler = 1;
+ while (TRUE) {
+ if (!touch_sampler) {
+ /*
+ * We are here ready to set mouse states. We compare
+ * current and previous states and thereby determine
+ * the state to send to others
+ */
+ if (touched) {
+ if(oldtouched) {
+ mousestate = MOUSE_STATE_DOWN;
+ } else {
+ mousestate = MOUSE_STATE_ON_PRESS;
+ }
+ oldtouched = TRUE;
+ } else {
+ if(oldtouched) {
+ mousestate = MOUSE_STATE_ON_RELEASE;
+ } else {
+ mousestate = MOUSE_STATE_UP;
+ }
+ oldtouched = FALSE;
+ }
+ /*
+ * We have now processed our Touch. Reset it for the
+ * next run.
+ */
+ touched = FALSE;
+
+ /*
+ * In the rare occurance that we receive values
+ * beyond our range, we set them to some sane
+ * values here.
+ */
+ x = (x > 639) ? 0 : x;
+ y = (y > 479) ? 0 : y;
+
+ /*
+ * Compare Previous States and Coordinates to determine
+ * wether they have changed. If so, Copy them into
+ * shared memory, notify the listening processes and
+ * Set the new as previous values for the next run. We
+ * can only do this when the display has handled all
+ * changes.
+ */
+ if (((oldmousestate != mousestate) || (oldx != x) || (oldy != y)) && (MOUSE_NOT_UPDATED == mousedata->status)) {
+ //par {
+ oldx = x;
+ oldy = y;
+ oldmousestate = mousestate;
+ mousedata->x = 0 @ x;
+ mousedata->y = 0 @ y;
+ mousedata->state = mousestate;
+ mousedata->status = MOUSE_UPDATED;
+ //}
+ }
+ }
+
+ /*
+ * Read the current X and Y of the 'cursor' and register wether
+ * the display was touched. If touched store this in a local
+ * store. This we do to catch the sampling of the RC200 lib.
+ */
+ RC200TouchScreenReadScaled(&x, &y, &touch);
+ if (touch) {
+ touched = TRUE;
+ }
+
+ touch_sampler++;
+ }
+} /* --- mouse_main() --- */