2000-10-31 18:15:46 +00:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/* */
|
|
|
|
|
/* mouse.h */
|
|
|
|
|
/* */
|
|
|
|
|
/* Mouse API */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
2004-03-21 22:12:06 +00:00
|
|
|
|
/* (C) 2003-2004 Ullrich von Bassewitz */
|
2003-12-28 21:26:11 +00:00
|
|
|
|
/* R<>merstra<72>e 52 */
|
|
|
|
|
/* D-70794 Filderstadt */
|
|
|
|
|
/* EMail: uz@cc65.org */
|
|
|
|
|
/* */
|
|
|
|
|
/* */
|
2000-10-31 18:15:46 +00:00
|
|
|
|
/* */
|
|
|
|
|
/* */
|
|
|
|
|
/* This software is provided 'as-is', without any expressed or implied */
|
|
|
|
|
/* warranty. In no event will the authors be held liable for any damages */
|
|
|
|
|
/* arising from the use of this software. */
|
|
|
|
|
/* */
|
|
|
|
|
/* Permission is granted to anyone to use this software for any purpose, */
|
|
|
|
|
/* including commercial applications, and to alter it and redistribute it */
|
|
|
|
|
/* freely, subject to the following restrictions: */
|
|
|
|
|
/* */
|
|
|
|
|
/* 1. The origin of this software must not be misrepresented; you must not */
|
|
|
|
|
/* claim that you wrote the original software. If you use this software */
|
|
|
|
|
/* in a product, an acknowledgment in the product documentation would be */
|
|
|
|
|
/* appreciated but is not required. */
|
|
|
|
|
/* 2. Altered source versions must be plainly marked as such, and must not */
|
|
|
|
|
/* be misrepresented as being the original software. */
|
|
|
|
|
/* 3. This notice may not be removed or altered from any source */
|
|
|
|
|
/* distribution. */
|
|
|
|
|
/* */
|
|
|
|
|
/*****************************************************************************/
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef _MOUSE_H
|
|
|
|
|
#define _MOUSE_H
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2000-11-16 23:05:00 +00:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/* Definitions */
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
2000-11-16 23:40:09 +00:00
|
|
|
|
|
2003-12-28 21:26:11 +00:00
|
|
|
|
/* Error codes */
|
|
|
|
|
#define MOUSE_ERR_OK 0 /* No error */
|
|
|
|
|
#define MOUSE_ERR_NO_DRIVER 1 /* No driver available */
|
|
|
|
|
#define MOUSE_ERR_CANNOT_LOAD 2 /* Error loading driver */
|
|
|
|
|
#define MOUSE_ERR_INV_DRIVER 3 /* Invalid driver */
|
|
|
|
|
#define MOUSE_ERR_NO_DEVICE 4 /* Mouse hardware not found */
|
2004-03-05 18:33:56 +00:00
|
|
|
|
#define MOUSE_ERR_INV_IOCTL 5 /* Invalid ioctl code */
|
2000-11-16 23:40:09 +00:00
|
|
|
|
|
|
|
|
|
/* Mouse button masks */
|
|
|
|
|
#define MOUSE_BTN_LEFT 0x10
|
2001-09-08 20:04:21 +00:00
|
|
|
|
#define MOUSE_BTN_RIGHT 0x01
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
2001-09-08 15:44:48 +00:00
|
|
|
|
/* Structure containing the mouse coordinates */
|
|
|
|
|
struct mouse_pos {
|
|
|
|
|
int x;
|
|
|
|
|
int y;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* Structure containing information about the mouse */
|
|
|
|
|
struct mouse_info {
|
2001-09-08 20:04:21 +00:00
|
|
|
|
struct mouse_pos pos; /* Mouse position */
|
2001-09-08 15:44:48 +00:00
|
|
|
|
unsigned char buttons; /* Mouse button mask */
|
|
|
|
|
};
|
|
|
|
|
|
2003-12-28 21:26:11 +00:00
|
|
|
|
/* Structure containing mouse callback functions. These functions are declared
|
|
|
|
|
* in C notation here, but they cannot be C functions (at least not easily),
|
|
|
|
|
* since they may be called from within an interrupt.
|
|
|
|
|
*/
|
|
|
|
|
struct mouse_callbacks {
|
|
|
|
|
|
|
|
|
|
void (*hide) (void);
|
|
|
|
|
/* Hide the mouse cursor. */
|
|
|
|
|
|
|
|
|
|
void (*show) (void);
|
|
|
|
|
/* Show the mouse cursor */
|
|
|
|
|
|
2005-11-21 20:40:56 +00:00
|
|
|
|
void __fastcall__ (*movex) (int x);
|
2004-03-21 22:12:06 +00:00
|
|
|
|
/* Move the mouse cursor to the new X coordinate. This function is called,
|
|
|
|
|
* even when the cursor is currently invisible.
|
|
|
|
|
*/
|
|
|
|
|
|
2005-11-21 20:40:56 +00:00
|
|
|
|
void __fastcall__ (*movey) (int y);
|
2004-03-21 22:12:06 +00:00
|
|
|
|
/* Move the mouse cursor to the new Y coordinate. This function is called,
|
|
|
|
|
* even when the cursor is currently invisible.
|
2003-12-28 21:26:11 +00:00
|
|
|
|
*/
|
|
|
|
|
};
|
|
|
|
|
|
2004-03-21 22:12:06 +00:00
|
|
|
|
/* The default mouse callbacks */
|
|
|
|
|
extern const struct mouse_callbacks mouse_def_callbacks;
|
|
|
|
|
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
|
|
|
2000-10-31 18:15:46 +00:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/* Functions */
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2004-03-21 22:12:06 +00:00
|
|
|
|
unsigned char __fastcall__ mouse_load_driver (const struct mouse_callbacks* c,
|
|
|
|
|
const char* driver);
|
2003-12-28 21:26:11 +00:00
|
|
|
|
/* Load and install a mouse driver, return an error code. */
|
|
|
|
|
|
|
|
|
|
unsigned char __fastcall__ mouse_unload (void);
|
|
|
|
|
/* Uninstall, then unload the currently loaded driver. */
|
|
|
|
|
|
2004-03-21 22:12:06 +00:00
|
|
|
|
unsigned char __fastcall__ mouse_install (const struct mouse_callbacks* c,
|
|
|
|
|
void* driver);
|
2003-12-28 21:26:11 +00:00
|
|
|
|
/* Install an already loaded driver. Returns an error code. */
|
|
|
|
|
|
|
|
|
|
unsigned char __fastcall__ mouse_uninstall (void);
|
|
|
|
|
/* Uninstall the currently loaded driver. Returns an error code. */
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
2004-11-07 12:41:18 +00:00
|
|
|
|
const char* __fastcall__ mouse_geterrormsg (unsigned char code);
|
|
|
|
|
/* Get an error message describing the error in code. */
|
|
|
|
|
|
2001-09-08 15:44:48 +00:00
|
|
|
|
void __fastcall__ mouse_hide (void);
|
2003-12-28 21:26:11 +00:00
|
|
|
|
/* Hide the mouse. The function manages a counter and may be called more than
|
|
|
|
|
* once. For each call to mouse_hide there must be a call to mouse_show to make
|
2000-05-28 13:40:48 +00:00
|
|
|
|
* the mouse visible again.
|
|
|
|
|
*/
|
|
|
|
|
|
2001-09-08 15:44:48 +00:00
|
|
|
|
void __fastcall__ mouse_show (void);
|
2003-12-28 21:26:11 +00:00
|
|
|
|
/* Show the mouse. See mouse_hide for more information. */
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
|
|
void __fastcall__ mouse_box (int minx, int miny, int maxx, int maxy);
|
|
|
|
|
/* Set the bounding box for the mouse pointer movement. The mouse X and Y
|
|
|
|
|
* coordinates will never go outside the given box.
|
|
|
|
|
* NOTE: The function does *not* check if the mouse is currently inside the
|
|
|
|
|
* given margins. The proper way to use this function therefore is:
|
|
|
|
|
*
|
|
|
|
|
* - Hide the mouse
|
|
|
|
|
* - Set the bounding box
|
|
|
|
|
* - Place the mouse at the desired position
|
|
|
|
|
* - Show the mouse again.
|
|
|
|
|
*
|
|
|
|
|
* NOTE2: When setting the box to something that is larger than the actual
|
2004-05-12 13:18:00 +00:00
|
|
|
|
* screen, the positioning of the mouse cursor can fail. If such margins
|
2000-05-28 13:40:48 +00:00
|
|
|
|
* are really what you want, you have to use your own cursor routines.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
void __fastcall__ mouse_move (int x, int y);
|
|
|
|
|
/* Set the mouse cursor to the given position. If a mouse cursor is defined
|
|
|
|
|
* and currently visible, the mouse cursor is also moved.
|
|
|
|
|
* NOTE: This function does not check if the given position is valid and
|
|
|
|
|
* inside the bounding box.
|
|
|
|
|
*/
|
|
|
|
|
|
2001-09-08 15:44:48 +00:00
|
|
|
|
unsigned char __fastcall__ mouse_buttons (void);
|
2000-11-16 23:40:09 +00:00
|
|
|
|
/* Return a bit mask encoding the states of the mouse buttons. Use the
|
|
|
|
|
* MOUSE_BTN_XXX flags to decode a specific button.
|
2000-11-16 23:05:00 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2001-09-08 15:44:48 +00:00
|
|
|
|
void __fastcall__ mouse_pos (struct mouse_pos* pos);
|
|
|
|
|
/* Return the current mouse position */
|
|
|
|
|
|
|
|
|
|
void __fastcall__ mouse_info (struct mouse_info* info);
|
|
|
|
|
/* Return the state of the mouse buttons and the position of the mouse */
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
2004-03-05 18:33:56 +00:00
|
|
|
|
unsigned char __fastcall__ mouse_ioctl (unsigned char code, void* data);
|
2004-03-18 09:42:44 +00:00
|
|
|
|
/* Call the driver specific ioctl function. NON PORTABLE! Returns an error
|
|
|
|
|
* code.
|
2004-03-05 18:33:56 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
2001-09-12 13:49:08 +00:00
|
|
|
|
|
2000-05-28 13:40:48 +00:00
|
|
|
|
/* End of mouse.h */
|
|
|
|
|
#endif
|
|
|
|
|
|
2001-09-12 13:49:08 +00:00
|
|
|
|
|
|
|
|
|
|