]> git.sur5r.net Git - cc65/blobdiff - include/mouse.h
New function dio_query_sectcount and cosmetic changes
[cc65] / include / mouse.h
index 9eaccb990db68a76e13a98bd9d0f089122ba0795..1a8745572677941d30a977a05ba1b5631f22d089 100644 (file)
@@ -6,10 +6,12 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 1999-2000 Ullrich von Bassewitz                                       */
-/*               Wacholderweg 14                                             */
-/*               D-70597 Stuttgart                                           */
-/* EMail:        uz@musoftware.de                                            */
+/* (C) 2003-2004 Ullrich von Bassewitz                                       */
+/*               Römerstraße 52                                              */
+/*               D-70794 Filderstadt                                         */
+/* EMail:        uz@cc65.org                                                 */
+/*                                                                           */
+/*                                                                           */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
 
 
 
-/* Define __MOUSE__ for systems that support a mouse */
-#if defined(__ATARI__) || defined(__C64__) || defined(__C128__)
-#  define __MOUSE__
-#endif
-
-
-
 /*****************************************************************************/
 /*                               Definitions                                */
 /*****************************************************************************/
 
 
 
-/* The different mouse types */
-#define MOUSE_TRAKBALL                 0
-#define MOUSE_ST               1
-#define MOUSE_AMIGA            2
-#define MOUSE_C64              3      /* 1351 mouse */
+/* 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 */
+#define MOUSE_ERR_INV_IOCTL     5       /* Invalid ioctl code */
 
 /* Mouse button masks */
 #define MOUSE_BTN_LEFT      0x10
@@ -73,6 +70,32 @@ struct mouse_info {
     unsigned char       buttons;       /* Mouse button mask */
 };
 
+/* 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 */
+
+    void (*movex) (void);
+    /* Move the mouse cursor to the new X coordinate. This function is called,
+     * even when the cursor is currently invisible.
+     */
+
+    void (*movey) (void);
+    /* Move the mouse cursor to the new Y coordinate. This function is called,
+     * even when the cursor is currently invisible.
+     */
+};
+
+/* The default mouse callbacks */
+extern const struct mouse_callbacks mouse_def_callbacks;
+
 
 
 /*****************************************************************************/
@@ -81,43 +104,31 @@ struct mouse_info {
 
 
 
-unsigned char __fastcall__ mouse_init (unsigned char port,
-                                      unsigned char sprite,
-                                      unsigned char type);
-/* Setup the mouse interrupt handler. If the sprite value is != zero, the
- * mouse routines will manage the sprite with this number. That means, it
- * is moved if the mouse is moved (provided that the mouse cursor is visible),
- * and switched on and off in the show and hide functions.
- * The port parameter gives the joystick port used for the mouse and is only
- * needed to read the mouse button state.
- * The type parameter is needed on some systems to determine the type of
- * the mouse connected to the given port.
- * After calling this function, the mouse is invisble, the cursor is placed
- * at 0/0 (upper left corner), and the bounding box is reset to cover the
- * whole screen. Call mouse_show once to make the mouse cursor visible.
- * The function will return zero if a mouse was not found and a non zero
- * value if the mouse was found and initialized (or if there is no way to
- * detect a mouse reliably).
- */
+unsigned char __fastcall__ mouse_load_driver (const struct mouse_callbacks* c,
+                                              const char* driver);
+/* Load and install a mouse driver, return an error code. */
 
-void __fastcall__ mouse_done (void);
-/* Disable the mouse, remove the interrupt handler. This function MUST be
- * called before terminating the program, otherwise odd things may happen.
- * If in doubt, install an exit handler (using atexit) that calls this
- * function.
- */
+unsigned char __fastcall__ mouse_unload (void);
+/* Uninstall, then unload the currently loaded driver. */
+
+unsigned char __fastcall__ mouse_install (const struct mouse_callbacks* c,
+                                          void* driver);
+/* Install an already loaded driver. Returns an error code. */
+
+unsigned char __fastcall__ mouse_uninstall (void);
+/* Uninstall the currently loaded driver. Returns an error code. */
+
+const char* __fastcall__ mouse_geterrormsg (unsigned char code);
+/* Get an error message describing the error in code. */
 
 void __fastcall__ mouse_hide (void);
-/* Hide the mouse. This function doesn't do anything visible if no sprite is
- * used. 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
+/* 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
  * the mouse visible again.
  */
 
 void __fastcall__ mouse_show (void);
-/* Show the mouse. This function doesn't do anything visible if no sprite is
- * used. See mouse_hide for more information.
- */
+/* Show the mouse. See mouse_hide for more information. */
 
 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
@@ -131,7 +142,7 @@ void __fastcall__ mouse_box (int minx, int miny, int maxx, int maxy);
  *     - Show the mouse again.
  *
  * NOTE2: When setting the box to something that is larger than the actual
- * screen, the positioning of the mouse cursor will fail. If such margins
+ * screen, the positioning of the mouse cursor can fail. If such margins
  * are really what you want, you have to use your own cursor routines.
  */
 
@@ -153,7 +164,15 @@ void __fastcall__ mouse_pos (struct mouse_pos* pos);
 void __fastcall__ mouse_info (struct mouse_info* info);
 /* Return the state of the mouse buttons and the position of the mouse */
 
+unsigned char __fastcall__ mouse_ioctl (unsigned char code, void* data);
+/* Call the driver specific ioctl function. NON PORTABLE! Returns an error
+ * code.
+ */
+
+
 
 /* End of mouse.h */
 #endif
 
+
+