]> git.sur5r.net Git - cc65/blob - include/mouse.h
Check for wrong header file inclusions, add CBM510 stuff
[cc65] / include / mouse.h
1 /*****************************************************************************/
2 /*                                                                           */
3 /*                                  mouse.h                                  */
4 /*                                                                           */
5 /*                                 Mouse API                                 */
6 /*                                                                           */
7 /*                                                                           */
8 /*                                                                           */
9 /* (C) 1999-2001 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 #if defined(__ATARI__) || defined(__C64__) || defined(__C128__) || defined(__CBM510__)
43 #  define __MOUSE__
44 #else
45 #  error The target system does not support a mouse!
46 # endif
47
48
49
50 /*****************************************************************************/
51 /*                                Definitions                                */
52 /*****************************************************************************/
53
54
55
56 /* The different mouse types */
57 #define MOUSE_TRAKBALL          0
58 #define MOUSE_ST                1
59 #define MOUSE_AMIGA             2
60 #define MOUSE_CBM1351           3      /* 1351 mouse */
61
62 /* Mouse button masks */
63 #define MOUSE_BTN_LEFT       0x10
64 #define MOUSE_BTN_RIGHT      0x01
65
66 /* Structure containing the mouse coordinates */
67 struct mouse_pos {
68     int x;
69     int y;
70 };
71
72 /* Structure containing information about the mouse */
73 struct mouse_info {
74     struct mouse_pos    pos;           /* Mouse position */
75     unsigned char       buttons;       /* Mouse button mask */
76 };
77
78
79
80 /*****************************************************************************/
81 /*                                 Functions                                 */
82 /*****************************************************************************/
83
84
85
86 unsigned char __fastcall__ mouse_init (unsigned char type);
87 /* Setup the mouse interrupt handler. The mouse routines will use a predefined
88  * system resource for the mouse port and mouse cursor:
89  *     C64:      Port #0, Sprite #0
90  *     C128:     Port #0, Sprite #0
91  *     GEOS:     System defined port, Sprite #0
92  *     Atari:    Port #0, PM #0
93  * However, the mouse routines will not initialize this cursor or set a
94  * specific shape - this is platform dependent and up to the user program.
95  * The mouse cursor is moved if the mouse is moved (provided that the mouse
96  * cursor is visible), and switched on and off in the show and hide functions.
97  * The type parameter is needed on some systems to determine the type of
98  * the mouse connected to the given port, on others it is ignored.
99  * After calling this function, the mouse is invisble, the cursor is placed
100  * at 0/0 (upper left corner), and the bounding box is reset to cover the
101  * whole screen. Call mouse_show once to make the mouse cursor visible.
102  * The function will return zero if a mouse was not found and a non zero
103  * value if the mouse was found and initialized (or if there is no way to
104  * detect a mouse reliably).
105  */
106
107 void __fastcall__ mouse_done (void);
108 /* Disable the mouse, remove the interrupt handler. This function MUST be
109  * called before terminating the program, otherwise odd things may happen.
110  * If in doubt, install an exit handler (using atexit) that calls this
111  * function.
112  */
113
114 void __fastcall__ mouse_hide (void);
115 /* Hide the mouse. This function doesn't do anything visible if no sprite is
116  * used. The function manages a counter and may be called more than once.
117  * For each call to mouse_hide there must be a call to mouse_show to make
118  * the mouse visible again.
119  */
120
121 void __fastcall__ mouse_show (void);
122 /* Show the mouse. This function doesn't do anything visible if no sprite is
123  * used. See mouse_hide for more information.
124  */
125
126 void __fastcall__ mouse_box (int minx, int miny, int maxx, int maxy);
127 /* Set the bounding box for the mouse pointer movement. The mouse X and Y
128  * coordinates will never go outside the given box.
129  * NOTE: The function does *not* check if the mouse is currently inside the
130  * given margins. The proper way to use this function therefore is:
131  *
132  *      - Hide the mouse
133  *      - Set the bounding box
134  *      - Place the mouse at the desired position
135  *      - Show the mouse again.
136  *
137  * NOTE2: When setting the box to something that is larger than the actual
138  * screen, the positioning of the mouse cursor will fail. If such margins
139  * are really what you want, you have to use your own cursor routines.
140  */
141
142 void __fastcall__ mouse_move (int x, int y);
143 /* Set the mouse cursor to the given position. If a mouse cursor is defined
144  * and currently visible, the mouse cursor is also moved.
145  * NOTE: This function does not check if the given position is valid and
146  * inside the bounding box.
147  */
148
149 unsigned char __fastcall__ mouse_buttons (void);
150 /* Return a bit mask encoding the states of the mouse buttons. Use the
151  * MOUSE_BTN_XXX flags to decode a specific button.
152  */
153
154 void __fastcall__ mouse_pos (struct mouse_pos* pos);
155 /* Return the current mouse position */
156
157 void __fastcall__ mouse_info (struct mouse_info* info);
158 /* Return the state of the mouse buttons and the position of the mouse */
159
160
161
162 /* End of mouse.h */
163 #endif
164
165
166