]> git.sur5r.net Git - cc65/blob - include/mouse.h
Allow system specific common and runtime files
[cc65] / include / mouse.h
1 /*****************************************************************************/
2 /*                                                                           */
3 /*                                  mouse.h                                  */
4 /*                                                                           */
5 /*                                 Mouse API                                 */
6 /*                                                                           */
7 /*                                                                           */
8 /*                                                                           */
9 /* (C) 1999-2000 Ullrich von Bassewitz                                       */
10 /*               Wacholderweg 14                                             */
11 /*               D-70597 Stuttgart                                           */
12 /* EMail:        uz@musoftware.de                                            */
13 /*                                                                           */
14 /*                                                                           */
15 /* This software is provided 'as-is', without any expressed or implied       */
16 /* warranty.  In no event will the authors be held liable for any damages    */
17 /* arising from the use of this software.                                    */
18 /*                                                                           */
19 /* Permission is granted to anyone to use this software for any purpose,     */
20 /* including commercial applications, and to alter it and redistribute it    */
21 /* freely, subject to the following restrictions:                            */
22 /*                                                                           */
23 /* 1. The origin of this software must not be misrepresented; you must not   */
24 /*    claim that you wrote the original software. If you use this software   */
25 /*    in a product, an acknowledgment in the product documentation would be  */
26 /*    appreciated but is not required.                                       */
27 /* 2. Altered source versions must be plainly marked as such, and must not   */
28 /*    be misrepresented as being the original software.                      */
29 /* 3. This notice may not be removed or altered from any source              */
30 /*    distribution.                                                          */
31 /*                                                                           */
32 /*****************************************************************************/
33
34
35
36 #ifndef _MOUSE_H
37 #define _MOUSE_H
38
39
40
41 /* Define __MOUSE__ for systems that support a mouse */
42 #ifdef __C64__
43 #  define __MOUSE__
44 #endif
45 #ifdef __C128__
46 #  define __MOUSE__
47 #endif
48 #ifdef __ATARI__
49 #  define __MOUSE__
50 #endif
51
52
53
54 /*****************************************************************************/
55 /*                                Definitions                                */
56 /*****************************************************************************/
57
58
59
60 /* The different mouse types */
61 #define MOUSE_TRAKBALL          0
62 #define MOUSE_ST                1
63 #define MOUSE_AMIGA             2
64 #define MOUSE_C64               3      /* 1351 mouse */
65
66 /* Mouse button masks */
67 #define MOUSE_BTN_LEFT       0x10
68
69
70
71 /*****************************************************************************/
72 /*                                 Functions                                 */
73 /*****************************************************************************/
74
75
76
77 unsigned char __fastcall__ mouse_init (unsigned char port, 
78                                        unsigned char sprite, 
79                                        unsigned char type);
80 /* Setup the mouse interrupt handler. If the sprite value is != zero, the
81  * mouse routines will manage the sprite with this number. That means, it
82  * is moved if the mouse is moved (provided that the mouse cursor is visible),
83  * and switched on and off in the show and hide functions.
84  * The port parameter gives the joystick port used for the mouse and is only
85  * needed to read the mouse button state.
86  * The type parameter is needed on some systems to determine the type of
87  * the mouse connected to the given port.
88  * After calling this function, the mouse is invisble, the cursor is placed
89  * at 0/0 (upper left corner), and the bounding box is reset to cover the
90  * whole screen. Call mouse_show once to make the mouse cursor visible.
91  * The function will return zero if a mouse was not found and a non zero
92  * value if the mouse was found and initialized (or if there is no way to
93  * detect a mouse reliably).
94  */
95
96 void mouse_done (void);
97 /* Disable the mouse, remove the interrupt handler. This function MUST be
98  * called before terminating the program, otherwise odd things may happen.
99  * If in doubt, install an exit handler (using atexit) that calls this
100  * function.
101  */
102
103 void mouse_hide (void);
104 /* Hide the mouse. This function doesn't do anything visible if no sprite is
105  * used. The function manages a counter and may be called more than once.
106  * For each call to mouse_hide there must be a call to mouse_show to make
107  * the mouse visible again.
108  */
109
110 void mouse_show (void);
111 /* Show the mouse. This function doesn't do anything visible if no sprite is
112  * used. See mouse_hide for more information.
113  */
114
115 void __fastcall__ mouse_box (int minx, int miny, int maxx, int maxy);
116 /* Set the bounding box for the mouse pointer movement. The mouse X and Y
117  * coordinates will never go outside the given box.
118  * NOTE: The function does *not* check if the mouse is currently inside the
119  * given margins. The proper way to use this function therefore is:
120  *
121  *      - Hide the mouse
122  *      - Set the bounding box
123  *      - Place the mouse at the desired position
124  *      - Show the mouse again.
125  *
126  * NOTE2: When setting the box to something that is larger than the actual
127  * screen, the positioning of the mouse cursor will fail. If such margins
128  * are really what you want, you have to use your own cursor routines.
129  */
130
131 void __fastcall__ mouse_move (int x, int y);
132 /* Set the mouse cursor to the given position. If a mouse cursor is defined
133  * and currently visible, the mouse cursor is also moved.
134  * NOTE: This function does not check if the given position is valid and
135  * inside the bounding box.
136  */
137
138 unsigned char mouse_buttons (void);
139 /* Return a bit mask encoding the states of the mouse buttons. Use the
140  * MOUSE_BTN_XXX flags to decode a specific button.
141  */
142
143 void mouse_info (void);
144 /* Hmmm...
145  */
146
147
148 /* End of mouse.h */
149 #endif
150