1 /*****************************************************************************/
9 /* (C) 1999-2000 Ullrich von Bassewitz */
11 /* D-70597 Stuttgart */
12 /* EMail: uz@musoftware.de */
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. */
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: */
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 */
32 /*****************************************************************************/
41 /* Define __MOUSE__ for systems that support a mouse */
42 #if defined(__ATARI__) || defined(__C64__) || defined(__C128__)
48 /*****************************************************************************/
50 /*****************************************************************************/
54 /* The different mouse types */
55 #define MOUSE_TRAKBALL 0
58 #define MOUSE_C64 3 /* 1351 mouse */
60 /* Mouse button masks */
61 #define MOUSE_BTN_LEFT 0x10
62 #define MOUSE_BTN_RIGHT 0x01
64 /* Structure containing the mouse coordinates */
70 /* Structure containing information about the mouse */
72 struct mouse_pos pos; /* Mouse position */
73 unsigned char buttons; /* Mouse button mask */
78 /*****************************************************************************/
80 /*****************************************************************************/
84 unsigned char __fastcall__ mouse_init (unsigned char port,
87 /* Setup the mouse interrupt handler. If the sprite value is != zero, the
88 * mouse routines will manage the sprite with this number. That means, it
89 * is moved if the mouse is moved (provided that the mouse cursor is visible),
90 * and switched on and off in the show and hide functions.
91 * The port parameter gives the joystick port used for the mouse and is only
92 * needed to read the mouse button state.
93 * The type parameter is needed on some systems to determine the type of
94 * the mouse connected to the given port.
95 * After calling this function, the mouse is invisble, the cursor is placed
96 * at 0/0 (upper left corner), and the bounding box is reset to cover the
97 * whole screen. Call mouse_show once to make the mouse cursor visible.
98 * The function will return zero if a mouse was not found and a non zero
99 * value if the mouse was found and initialized (or if there is no way to
100 * detect a mouse reliably).
103 void __fastcall__ mouse_done (void);
104 /* Disable the mouse, remove the interrupt handler. This function MUST be
105 * called before terminating the program, otherwise odd things may happen.
106 * If in doubt, install an exit handler (using atexit) that calls this
110 void __fastcall__ mouse_hide (void);
111 /* Hide the mouse. This function doesn't do anything visible if no sprite is
112 * used. The function manages a counter and may be called more than once.
113 * For each call to mouse_hide there must be a call to mouse_show to make
114 * the mouse visible again.
117 void __fastcall__ mouse_show (void);
118 /* Show the mouse. This function doesn't do anything visible if no sprite is
119 * used. See mouse_hide for more information.
122 void __fastcall__ mouse_box (int minx, int miny, int maxx, int maxy);
123 /* Set the bounding box for the mouse pointer movement. The mouse X and Y
124 * coordinates will never go outside the given box.
125 * NOTE: The function does *not* check if the mouse is currently inside the
126 * given margins. The proper way to use this function therefore is:
129 * - Set the bounding box
130 * - Place the mouse at the desired position
131 * - Show the mouse again.
133 * NOTE2: When setting the box to something that is larger than the actual
134 * screen, the positioning of the mouse cursor will fail. If such margins
135 * are really what you want, you have to use your own cursor routines.
138 void __fastcall__ mouse_move (int x, int y);
139 /* Set the mouse cursor to the given position. If a mouse cursor is defined
140 * and currently visible, the mouse cursor is also moved.
141 * NOTE: This function does not check if the given position is valid and
142 * inside the bounding box.
145 unsigned char __fastcall__ mouse_buttons (void);
146 /* Return a bit mask encoding the states of the mouse buttons. Use the
147 * MOUSE_BTN_XXX flags to decode a specific button.
150 void __fastcall__ mouse_pos (struct mouse_pos* pos);
151 /* Return the current mouse position */
153 void __fastcall__ mouse_info (struct mouse_info* info);
154 /* Return the state of the mouse buttons and the position of the mouse */