1 /*
2 
3 Copyright (C) 2015-2018 Night Dive Studios, LLC.
4 
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License
16 along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 
18 */
19 /*
20  * $Source: n:/project/lib/src/input/test/RCS/mousetst.c $
21  * $Revision: 1.6 $
22  * $Author: kaboom $
23  * $Date: 1993/12/01 06:56:21 $
24  */
25 // Hey, this is a goofy mouse test program
26 
27 #include "lg.h"
28 #include "mouse.h"
29 #include <stdio.h>
30 #include <stdlib.h>
31 
32 extern short mouseInstantX, mouseInstantY, mouseInstantButts;
33 int eventcount = 0;
34 
goofy_callback(mouse_event * e,void * data)35 void goofy_callback(mouse_event* e,void* data)
36 {
37 //   if (e->type == 1) return;
38   eventcount++;
39 }
40 
main()41 void main()
42 {
43 	uchar done = FALSE;
44 	int	 callbackid = -1;
45 
46 	printf ("Click the mouse...\n\n");
47 	mouse_init(16,16);
48 
49 	mouse_set_callback(goofy_callback,(void*)0x600F,&callbackid);
50 	while(!done)
51 	{
52 		short x,y;
53 		mouse_event e;
54 		errtype err = mouse_next(&e);
55 
56 		if(err != OK && err != ERR_DUNDERFLOW)
57 			printf ("Error %d from mouse_next",err);
58 
59 		if (err == OK)
60 		{
61 			printf("Event: [%d](%d,%d)@%d %d\n",e.type,e.x,e.y,e.timestamp,e.buttons);
62 			eventcount++;
63 		}
64 
65 		mouse_get_xy(&x,&y);
66 //		mouse_check_btn(0,&done);
67 if (eventcount > 3)
68 	done = TRUE;
69 	}
70 	mouse_shutdown();
71 	printf("Event count = %d\n",eventcount);
72 }
73