1 /*****************************************************************************/
9 /* (C) 2003-2013, Ullrich von Bassewitz */
10 /* Roemerstrasse 52 */
11 /* D-70794 Filderstadt */
12 /* EMail: uz@cc65.org */
17 /* This software is provided 'as-is', without any expressed or implied */
18 /* warranty. In no event will the authors be held liable for any damages */
19 /* arising from the use of this software. */
21 /* Permission is granted to anyone to use this software for any purpose, */
22 /* including commercial applications, and to alter it and redistribute it */
23 /* freely, subject to the following restrictions: */
25 /* 1. The origin of this software must not be misrepresented; you must not */
26 /* claim that you wrote the original software. If you use this software */
27 /* in a product, an acknowledgment in the product documentation would be */
28 /* appreciated but is not required. */
29 /* 2. Altered source versions must be plainly marked as such, and must not */
30 /* be misrepresented as being the original software. */
31 /* 3. This notice may not be removed or altered from any source */
34 /*****************************************************************************/
43 /*****************************************************************************/
45 /*****************************************************************************/
50 #define MOUSE_ERR_OK 0 /* No error */
51 #define MOUSE_ERR_NO_DRIVER 1 /* No driver available */
52 #define MOUSE_ERR_CANNOT_LOAD 2 /* Error loading driver */
53 #define MOUSE_ERR_INV_DRIVER 3 /* Invalid driver */
54 #define MOUSE_ERR_NO_DEVICE 4 /* Mouse hardware not found */
55 #define MOUSE_ERR_INV_IOCTL 5 /* Invalid ioctl code */
57 /* Mouse button masks */
58 #define MOUSE_BTN_LEFT 0x10
59 #define MOUSE_BTN_RIGHT 0x01
61 /* Structure containing the mouse coordinates */
67 /* Structure containing information about the mouse */
69 struct mouse_pos pos; /* Mouse position */
70 unsigned char buttons; /* Mouse button mask */
73 /* Structure used for getbox/setbox */
81 /* Structure containing mouse callback functions. These functions are declared
82 ** in C notation here, but they cannot be C functions (at least not easily),
83 ** since they may be called from within an interrupt.
85 struct mouse_callbacks {
88 /* Hide the mouse cursor. */
91 /* Show the mouse cursor. */
94 /* Prepare to move the mouse cursor. This function is called,
95 ** even when the cursor is currently invisible.
99 /* Draw the mouse cursor. This function is called,
100 ** even when the cursor is currently invisible.
103 void __fastcall__ (*movex) (int x);
104 /* Move the mouse cursor to the new X coordinate. This function is called,
105 ** even when the cursor is currently invisible.
108 void __fastcall__ (*movey) (int y);
109 /* Move the mouse cursor to the new Y coordinate. This function is called,
110 ** even when the cursor is currently invisible.
116 /*****************************************************************************/
118 /*****************************************************************************/
122 /* The default mouse callbacks */
123 extern const struct mouse_callbacks mouse_def_callbacks;
127 /* The default mouse pointer shape used by the default mouse callbacks */
128 extern const unsigned char mouse_def_pointershape[63];
130 /* The default mouse pointer color used by the default mouse callbacks */
131 extern const unsigned char mouse_def_pointercolor;
135 /* The name of the standard mouse driver for a platform */
136 extern const char mouse_stddrv[];
138 /* The address of the static standard mouse driver for a platform */
139 extern const void mouse_static_stddrv[];
143 /*****************************************************************************/
145 /*****************************************************************************/
149 unsigned char __fastcall__ mouse_load_driver (const struct mouse_callbacks* c,
151 /* Load and install a mouse driver, return an error code. */
153 unsigned char mouse_unload (void);
154 /* Uninstall, then unload the currently loaded driver. */
156 unsigned char __fastcall__ mouse_install (const struct mouse_callbacks* c,
158 /* Install an already loaded driver. Return an error code. */
160 unsigned char mouse_uninstall (void);
161 /* Uninstall the currently loaded driver. Return an error code. */
163 const char* __fastcall__ mouse_geterrormsg (unsigned char code);
164 /* Get an error message describing the error in code. */
166 void mouse_hide (void);
167 /* Hide the mouse. The function manages a counter and may be called more than
168 ** once. For each call to mouse_hide there must be a call to mouse_show to make
169 ** the mouse visible again.
172 void mouse_show (void);
173 /* Show the mouse. See mouse_hide() for more information. */
175 void __fastcall__ mouse_setbox (const struct mouse_box* box);
176 /* Set the bounding box for the mouse pointer movement. The mouse X and Y
177 ** coordinates will never go outside the given box.
178 ** NOTE: The function does *not* check if the mouse is currently inside the
179 ** given margins. The proper way to use this function therefore is:
182 ** - Set the bounding box
183 ** - Place the mouse at the desired position
184 ** - Show the mouse again.
186 ** NOTE2: When setting the box to something that is larger than the actual
187 ** screen, the positioning of the mouse cursor can fail. If such margins
188 ** are really what you want, you have to use your own cursor routines.
191 void __fastcall__ mouse_getbox (struct mouse_box* box);
192 /* Get the current bounding box for the mouse pointer movement. */
194 void __fastcall__ mouse_move (int x, int y);
195 /* Set the mouse cursor to the given position. If a mouse cursor is defined
196 ** and currently visible, the mouse cursor is also moved.
197 ** NOTE: This function does not check if the given position is valid and
198 ** inside the bounding box.
201 unsigned char mouse_buttons (void);
202 /* Return a bit mask encoding the states of the mouse buttons. Use the
203 ** MOUSE_BTN_XXX flags to decode a specific button.
206 void __fastcall__ mouse_pos (struct mouse_pos* pos);
207 /* Return the current mouse position. */
209 void __fastcall__ mouse_info (struct mouse_info* info);
210 /* Return the state of the mouse buttons and the position of the mouse. */
212 unsigned char __fastcall__ mouse_ioctl (unsigned char code, void* data);
213 /* Call the driver-specific ioctl function. Return an error code.