Blame |
Last modification |
View Log
| RSS feed
/*
* Project: HARTIK (HA-rd R-eal TI-me K-ernel)
*
* Coordinators: Giorgio Buttazzo <giorgio@sssup.it>
* Gerardo Lamastra <gerardo@sssup.it>
*
* Authors : Paolo Gai <pj@hartik.sssup.it>
* (see authors.txt for full list of hartik's authors)
*
* ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
*
* http://www.sssup.it
* http://retis.sssup.it
* http://hartik.sssup.it
*/
/**
------------
CVS : $Id: testn.c,v 1.1.1.1 2002-09-02 09:37:48 pj Exp $
File: $File$
Revision: $Revision: 1.1.1.1 $
Last update: $Date: 2002-09-02 09:37:48 $
------------
Test Number 23 (N):
This is the mousfind.c Hartik's example.
It find the mouse...
**/
/*
* Copyright (C) 2000 Paolo Gai
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <kernel/kern.h>
#include <drivers/mouse.h>
#include <drivers/keyb.h>
/* don't include this into real applications*/
#include <../drivers/char/_mouse.h>
#define cons_columns 80
#define cons_rows 25
int done;
void my_ctrlC_function(KEY_EVT *k)
{
CRSR_STD();
done=1;
//sys_status(0xffff);
sys_end();
l1_exit(0);
}
//extern int tindex;
//extern DWORD tdata[];
//int first=1;
void my_mouse_hook(MOUSE_EVT *m)
{
static int buttons=-1;
if (buttons!=m->buttons) {
buttons=m->buttons;
//mouse_off();
if (isLeftButton(*m)) puts_xy(9,22,RED,"active");
else puts_xy(9,22,RED," ");
if (isCentralButton(*m)) puts_xy(9,23,RED,"active");
else puts_xy(9,23,RED," ");
if (isRightButton(*m)) puts_xy(9,24,RED,"active");
else puts_xy(9,24,RED," ");
//mouse_on();
}
/*
if (tindex>20&&first) {
int i;
cprintf("\nSTART\n");
for (i=0;i<tindex;i++) {
cprintf("%i\n",(int)tdata[i]);
}
for (i=1;i<tindex;i++) {
cprintf("%i ",(int)(tdata[i]-tdata[i-1]));
}
first=0;
}
*/
}
int main(int argc,char *argv[])
{
// KEYB_PARMS keyb =BASE_KEYB;
MOUSE_PARMS mouse=BASE_MOUSE;
int ch,running,nm;
int sens=5;
/* keyboard initialization */
// keyb_def_ctrlC(keyb,my_ctrlC_function);
// keyb_init(&keyb);
/* screen */
clear();
nm=0;
while (*vmouse[nm].name!='\0') {
cprintf("%c %s:\t %s\n",(char)('a'+nm),vmouse[nm].name,vmouse[nm].desc);
nm++;
}
cprintf("\n[a-%c]\t select a mouse server\n",(char)(nm+'a'-1));
cprintf("[z]\t decrement mouse threshold\n");
cprintf("[x]\t incremnet mouse threshold\n");
cprintf("[ctrl-c]\t exit\n");
place(0,20);
cputs("mouse server:\n");
cputs("threshold:\n");
cputs("left :\n");
cputs("central:\n");
cputs("right :");
CRSR_OFF();
/* main loop */
running=done=0;
while (!done) {
ch=keyb_getch(TRUE);
switch(ch) {
/* decrement threshold */
case 'z':
sens--;
if (sens<2) sens=2;
mouse_threshold(sens);
/* threshold */
place(11,21);
cprintf("%i ",sens);
break;
/* increment threshold */
case 'x':
sens++;
if (sens>100) sens=100;
mouse_threshold(sens);
/* threshold */
place(11,21);
cprintf("%i ",sens);
break;
/* change mouse protocol */
default:
if (ch>='a'&&ch<='a'+nm-1) {
/* check if a mouse server is running... */
if (running) {
/* disable autocursor */
mouse_txtcursor(DISABLE);
/* destroy actual mouse server */
mouse_end();
}
/* mouse server name */
puts_xy(14,20,GREEN," ");
puts_xy(14,20,GREEN,vmouse[ch-'a'].name);
/* threshold */
place(11,21);
cprintf("%i ",sens);
/* don't use this method to change a mouse protocol */
/* use mouse_def_???? macros instead */
mouse.type=ch-'a';
/* start a new server */
running=(mouse_init(&mouse)==0?1:0);
/* if running ...*/
if (running) {
/* set mouse limit */
mouse_limit(0,0,cons_columns-1,cons_rows-1);
/* enable autocursor */
mouse_txtcursor(ENABLE|AUTOOFF);
/* hook my function */
mouse_hook(my_mouse_hook);
/* show mouse cursor */
mouse_on();
}
}
break;
}
}
CRSR_STD();
sys_end();
return 0;
}