Subversion Repositories shark

Rev

Rev 1120 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1120 pj 1
/*
2
 * Project: S.Ha.R.K.
3
 *
4
 * Coordinators:
5
 *   Giorgio Buttazzo    <giorgio@sssup.it>
6
 *   Paolo Gai           <pj@gandalf.sssup.it>
7
 *
8
 * Authors     :
9
 *   Paolo Gai           <pj@gandalf.sssup.it>
10
 *   (see the web pages for full authors list)
11
 *
12
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
13
 *
14
 * http://www.sssup.it
15
 * http://retis.sssup.it
16
 * http://shark.sssup.it
17
 */
18
 
19
/*
20
 * Copyright (C) 2000 Giorgio Buttazzo, Paolo Gai
21
 *
22
 * This program is free software; you can redistribute it and/or modify
23
 * it under the terms of the GNU General Public License as published by
24
 * the Free Software Foundation; either version 2 of the License, or
25
 * (at your option) any later version.
26
 *
27
 * This program is distributed in the hope that it will be useful,
28
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
30
 * GNU General Public License for more details.
31
 *
32
 * You should have received a copy of the GNU General Public License
33
 * along with this program; if not, write to the Free Software
34
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
35
 *
36
 *
1144 pj 37
 * CVS :        $Id: mousfind.c,v 1.2 2003-03-24 11:18:19 pj Exp $
1120 pj 38
 */
39
 
40
/*
41
 * Copyright (C) 2000 Paolo Gai, Massimiliano Giorgi
42
 *
43
 * This program is free software; you can redistribute it and/or modify
44
 * it under the terms of the GNU General Public License as published by
45
 * the Free Software Foundation; either version 2 of the License, or
46
 * (at your option) any later version.
47
 *
48
 * This program is distributed in the hope that it will be useful,
49
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
50
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
51
 * GNU General Public License for more details.
52
 *
53
 * You should have received a copy of the GNU General Public License
54
 * along with this program; if not, write to the Free Software
55
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
56
 *
57
 */
58
 
59
#include <kernel/kern.h>
60
#include <drivers/mouse.h>
61
#include <drivers/keyb.h>
62
 
63
/* don't include this into real applications!!! */
1144 pj 64
#include <../drivers/oldchar/_mouse.h>
1120 pj 65
 
66
int done;
67
 
68
void my_mouse_hook(MOUSE_EVT *m)
69
{
70
  static int buttons=-1;
71
  if (buttons!=m->buttons) {
72
    buttons=m->buttons;
73
    //mouse_off();
74
    if (isLeftButton(*m)) puts_xy(9,22,RED,"active");
75
    else                  puts_xy(9,22,RED,"      ");
76
    if (isCentralButton(*m)) puts_xy(9,23,RED,"active");
77
    else                     puts_xy(9,23,RED,"      ");
78
    if (isRightButton(*m)) puts_xy(9,24,RED,"active");
79
    else                   puts_xy(9,24,RED,"      ");
80
    //mouse_on();
81
  }
82
 
83
 
84
  /*
85
  if (tindex>20&&first) {
86
    int i;
87
    cprintf("\nSTART\n");
88
    for (i=0;i<tindex;i++) {
89
      cprintf("%i\n",(int)tdata[i]);
90
    }
91
    for (i=1;i<tindex;i++) {
92
      cprintf("%i ",(int)(tdata[i]-tdata[i-1]));
93
    }
94
    first=0;
95
  }
96
  */
97
 
98
}
99
 
100
int main(int argc,char *argv[])
101
{
102
  MOUSE_PARMS mouse=BASE_MOUSE;
103
  int ch,running,nm;
104
  int sens=5;
105
 
106
  /* screen */
107
  clear();
108
 
109
  nm=0;
110
  while (*vmouse[nm].name!='\0') {
111
    cprintf("%c %s:\t %s\n",(char)('a'+nm),vmouse[nm].name,vmouse[nm].desc);
112
    nm++;
113
  }
114
 
115
  cprintf("\n[a-%c]\t select a mouse server\n",(char)(nm+'a'-1));
116
  cprintf("[z]\t decrement mouse threshold\n");
117
  cprintf("[x]\t incremnet mouse threshold\n");
118
  cprintf("[1-4]\t COM port\n");
119
  cprintf("[ENTER]\t exit\n");
120
  place(0,20);
121
  cputs("mouse server:\n");
122
  cputs("threshold:\n");
123
  cputs("left   :\n");
124
  cputs("central:\n");
125
  cputs("right  :");
126
  CRSR_OFF();
127
 
128
  /* main loop */
129
  running=done=0;
130
 
131
  mouse_def_ms(mouse,0);
132
 
133
  while (!done) {
134
    ch=keyb_getch(TRUE);
135
    switch(ch) {
136
 
137
      /* exit demo */
138
 
139
    case ENTER:
140
      done = 1;
141
      break;
142
 
143
      /* decrement threshold */
144
 
145
    case 'z':
146
      sens--;
147
      if (sens<2) sens=2;
148
      mouse_threshold(sens);
149
      /* threshold */
150
      place(11,21);
151
      cprintf("%i    ",sens);
152
      break;
153
 
154
      /* increment threshold */
155
 
156
    case 'x':
157
      sens++;
158
      if (sens>100) sens=100;
159
      mouse_threshold(sens);
160
      /* threshold */
161
      place(11,21);
162
      cprintf("%i    ",sens);
163
      break;
164
 
165
      /* change mouse protocol */
166
 
167
    default:
168
      if (ch>='a'&&ch<='a'+nm-1) {
169
        /* don't use this method to change a mouse protocol */
170
        /* use mouse_def_???? macros instead */
171
        mouse.type=ch-'a';
172
      } else
173
      if (ch>='1'&&ch<='4') {
174
        /* don't use this method to change a mouse com port */
175
        /* use mouse_def_???? macros instead */
176
        mouse.port = ch-'1';
177
      }
178
      else
179
        break;
180
 
181
      /* check if a mouse server is running... */
182
      if (running) {
183
        /* disable autocursor */
184
        mouse_txtcursor(DISABLE);
185
        /* destroy actual mouse server */
186
        mouse_end();
187
      }
188
      /* mouse server name */
189
      puts_xy(14,20,GREEN,"                ");
190
      puts_xy(14,20,GREEN,vmouse[mouse.type].name);
191
      /* threshold */
192
      place(11,21);
193
      cprintf("%i    ",sens);
194
      /* start a new server */
195
      running=(mouse_init(&mouse)==0?1:0);
196
      /* if running ...*/
197
      if (running) {
198
        /* set mouse limit */
199
        mouse_limit(0,0,cons_columns-1,cons_rows-1);
200
        /* enable autocursor */
201
        mouse_txtcursor(ENABLE|AUTOOFF);
202
        /* hook my function */
203
        mouse_hook(my_mouse_hook);
204
        /* show mouse cursor */
205
        mouse_on();
206
      }
207
      break;
208
 
209
    }    
210
  }
211
 
212
  CRSR_STD();
213
  clear();
214
  sys_end();
215
  return 0;
216
}