00001
00021
00022 #include <stdlib.hch>
00023
00024 #include "pal_master.hch"
00025 #include "pal_mouse.hch"
00026
00027
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
00057
00058
00059
00060
00061 touch_sampler = 1;
00062 while (TRUE) {
00063 if (!touch_sampler) {
00064
00065
00066
00067
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
00086
00087
00088 touched = FALSE;
00089
00090
00091
00092
00093
00094
00095 x = (x > 639) ? 0 : x;
00096 y = (y > 479) ? 0 : y;
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106 if (((oldmousestate != mousestate) || (oldx != x) || (oldy != y)) && (MOUSE_NOT_UPDATED == mousedata->status)) {
00107
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
00121
00122
00123
00124 RC200TouchScreenReadScaled(&x, &y, &touch);
00125 if (touch) {
00126 touched = TRUE;
00127 }
00128
00129 touch_sampler++;
00130 }
00131 }