summaryrefslogtreecommitdiffstats
path: root/Graphic_Equalizer_v1.0/doc/html/mouse_8hcc-source.html
blob: dfb8298d7e1772b90e62947f975fc67758c607c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Graphic Equalizer 2: C:/Project  Marcel &amp; Oliver/Graphic_Equalizer/src/mouse.hcc Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.3.9.1 -->
<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="dirs.html">Directories</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
<div class="nav">
<a class="el" href="dir_000000.html">C:</a>&nbsp;/&nbsp;<a class="el" href="dir_000001.html">Project  Marcel &amp; Oliver</a>&nbsp;/&nbsp;<a class="el" href="dir_000002.html">Graphic_Equalizer</a>&nbsp;/&nbsp;<a class="el" href="dir_000004.html">src</a></div>
<h1>mouse.hcc</h1><a href="mouse_8hcc.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment">00001 
00021 <span class="comment">/******** System Includes *************/</span>
00022 <span class="preprocessor">#include &lt;stdlib.hch&gt;</span>
00023 
00024 <span class="preprocessor">#include "pal_master.hch"</span>
00025 <span class="preprocessor">#include "pal_mouse.hch"</span>
00026 
00027 <span class="comment">/******** Application Includes ********/</span>
00028 <span class="preprocessor">#include "<a class="code" href="configuration_8hch.html">configuration.hch</a>"</span>
00029 <span class="preprocessor">#include "<a class="code" href="mouse__shared_8hch.html">mouse_shared.hch</a>"</span>
00030 <span class="preprocessor">#include "<a class="code" href="mouse_8hch.html">mouse.hch</a>"</span>
00031 
00032 <span class="preprocessor">#if HAVE_DEBUG</span>
00033 <span class="preprocessor"></span><span class="preprocessor">        #include "debug.hch"</span>
00034 <span class="preprocessor">#endif</span>
00035 <span class="preprocessor"></span>
00036 
00037 
<a name="l00048"></a><a class="code" href="mouse_8hcc.html#a0">00048</a> <span class="keywordtype">void</span> <a class="code" href="mouse_8hcc.html#a0">mouse_main</a>(<a class="code" href="structmousedata__t.html">mousedata_t</a> *mousedata) {
00049         <span class="keywordtype">unsigned</span> 18 touch_sampler;
00050         <span class="keywordtype">unsigned</span> 10 x, oldx;
00051         <span class="keywordtype">unsigned</span> 9 y, oldy;
00052         <span class="keywordtype">unsigned</span> 3 mousestate, oldmousestate;
00053         <span class="keywordtype">unsigned</span> 1 touch, touched, oldtouched;
00054 
00055         <span class="comment">/*</span>
00056 <span class="comment">         * We only check for mouse states once every 2^18 time. This to</span>
00057 <span class="comment">         * overcome the sampling of the 'Touch' state of the RC200 libs. When</span>
00058 <span class="comment">         * using newer libs this might be overkill, e.g. smaller values may</span>
00059 <span class="comment">         * work or sampling all together will be redundant.</span>
00060 <span class="comment">         */</span>
00061         touch_sampler = 1;
00062         <span class="keywordflow">while</span> (TRUE) {
00063                 <span class="keywordflow">if</span> (!touch_sampler) {
00064                         <span class="comment">/*</span>
00065 <span class="comment">                         * We are here ready to set mouse states. We compare</span>
00066 <span class="comment">                         * current and previous states and thereby determine</span>
00067 <span class="comment">                         * the state to send to others</span>
00068 <span class="comment">                         */</span>
00069                         <span class="keywordflow">if</span> (touched) {
00070                                 <span class="keywordflow">if</span>(oldtouched) {
00071                                         mousestate = MOUSE_STATE_DOWN;
00072                                 } <span class="keywordflow">else</span> {
00073                                         mousestate = MOUSE_STATE_ON_PRESS;
00074                                 }
00075                                 oldtouched = TRUE;
00076                         } <span class="keywordflow">else</span> {
00077                                 <span class="keywordflow">if</span>(oldtouched) {
00078                                         mousestate = MOUSE_STATE_ON_RELEASE;
00079                                 } <span class="keywordflow">else</span> {
00080                                         mousestate = MOUSE_STATE_UP;
00081                                 }
00082                                 oldtouched = FALSE;
00083                         }
00084                         <span class="comment">/*</span>
00085 <span class="comment">                         * We have now processed our Touch. Reset it for the</span>
00086 <span class="comment">                         * next run.</span>
00087 <span class="comment">                         */</span>
00088                         touched = FALSE;
00089 
00090                         <span class="comment">/*</span>
00091 <span class="comment">                         * In the rare occurance that we receive values</span>
00092 <span class="comment">                         * beyond our range, we set them to some sane</span>
00093 <span class="comment">                         * values here.</span>
00094 <span class="comment">                         */</span>
00095                          x = (x &gt; 639) ? 0 : x;
00096                          y = (y &gt; 479) ? 0 : y;
00097 
00098                         <span class="comment">/*</span>
00099 <span class="comment">                         * Compare Previous States and Coordinates to determine</span>
00100 <span class="comment">                         * wether they have changed. If so, Copy them into</span>
00101 <span class="comment">                         * shared memory, notify the listening processes and</span>
00102 <span class="comment">                         * Set the new as previous values for the next run. We</span>
00103 <span class="comment">                         * can only do this when the display has handled all</span>
00104 <span class="comment">                         * changes.</span>
00105 <span class="comment">                         */</span>
00106                         <span class="keywordflow">if</span> (((oldmousestate != mousestate) || (oldx != x) || (oldy != y)) &amp;&amp; (<a class="code" href="mouse__shared_8hch.html#a1">MOUSE_NOT_UPDATED</a> == mousedata-&gt;<a class="code" href="structmousedata__t.html#o3">status</a>)) {
00107                                 <span class="comment">//par {</span>
00108                                         oldx = x;
00109                                         oldy = y;
00110                                         oldmousestate = mousestate;
00111                                         mousedata-&gt;<a class="code" href="structmousedata__t.html#o0">x</a> = x;
00112                                         mousedata-&gt;<a class="code" href="structmousedata__t.html#o1">y</a> = 0 @ y;
00113                                         mousedata-&gt;<a class="code" href="structmousedata__t.html#o2">state</a> = mousestate;
00114                                         mousedata-&gt;<a class="code" href="structmousedata__t.html#o3">status</a> = MOUSE_UPDATED;
00115                                 <span class="comment">//}</span>
00116                         }
00117                 }
00118 
00119                 <span class="comment">/*</span>
00120 <span class="comment">                 * Read the current X and Y of the 'cursor' and register wether</span>
00121 <span class="comment">                 * the display was touched. If touched store this in a local</span>
00122 <span class="comment">                 * store. This we do to catch the sampling of the RC200 lib.</span>
00123 <span class="comment">                 */</span>
00124                 RC200TouchScreenReadScaled(&amp;x, &amp;y, &amp;touch);
00125                 <span class="keywordflow">if</span> (touch) {
00126                         touched = TRUE;
00127                 }
00128 
00129                 touch_sampler++;
00130         }
00131 } <span class="comment">/* --- mouse_main() --- */</span>
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Dec 9 14:37:07 2004 for Graphic Equalizer 2 by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.3.9.1 </small></address>
</body>
</html>