1 /* 2 3 Copyright (C) 2015-2018 Night Dive Studios, LLC. 4 Copyright (C) 2019 Shockolate Project 5 6 This program is free software: you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation, either version 3 of the License, or 9 (at your option) any later version. 10 11 This program is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with this program. If not, see <http://www.gnu.org/licenses/>. 18 19 */ 20 // Mouse.H Mouse library header file 21 // MAHK Leblanc 2/19/93 22 /* 23 * $Source: n:/project/lib/src/input/RCS/mouse.h $ 24 * $Revision: 1.11 $ 25 * $Author: unknown $ 26 * $Date: 1993/09/01 00:19:18 $ 27 * 28 * $Log: mouse.h $ 29 * Revision 1.11 1993/09/01 00:19:18 unknown 30 * Changed left-handedness api 31 * 32 * Revision 1.10 1993/08/29 03:12:35 mahk 33 * Added mousemask and lefty support. 34 * 35 * Revision 1.9 1993/08/27 14:05:06 mahk 36 * Added shift factors 37 * 38 * Revision 1.8 1993/07/28 18:15:58 jak 39 * Added mouse_extremes() function 40 * 41 * Revision 1.7 1993/06/28 02:04:59 mahk 42 * Bug fixes for the new regime 43 * 44 * Revision 1.6 1993/06/27 22:17:32 mahk 45 * Added timestamps and button state to the mouse event structure. 46 * 47 * Revision 1.5 1993/05/04 14:34:27 mahk 48 * mouse_init no longer takes a screen mode argument. 49 * 50 * Revision 1.4 1993/04/14 12:08:46 mahk 51 * Hey, I got my mouse ups and downs backwards. 52 * 53 * Revision 1.3 1993/03/19 18:46:57 mahk 54 * Added RCS header 55 * 56 * 57 */ 58 59 #ifndef MOUSE_H 60 #define MOUSE_H 61 62 #include "lg.h" 63 #include "error.h" 64 #include <stdbool.h> 65 #include <stdint.h> 66 //#include <Carbon/Carbon.h> 67 68 typedef struct _mouse_event { 69 short x; // position 70 short y; 71 uint16_t type; // Event mask, bits defined below 72 uint32_t timestamp; 73 uchar buttons; 74 uchar modifiers; // Added for Mac version 75 char pad[4]; // pad to sixteen bytes 76 } ss_mouse_event; 77 78 #define MOUSE_MOTION 1u // Event mask bits 79 #define MOUSE_LDOWN 2u 80 #define MOUSE_LUP 4u 81 #define MOUSE_RDOWN 8u 82 #define MOUSE_RUP 16u 83 #define MOUSE_CDOWN 32u 84 #define MOUSE_CUP 64u 85 // bits 7..9 are used for double click events, see UI/Source/event.h 86 #define MOUSE_WHEELUP (1 << 10) 87 #define MOUSE_WHEELDN (1 << 11) 88 89 // Mask of events that are allowed into the queue. 90 extern ubyte mouseMask; 91 92 // type of mouse interrupt callback func 93 typedef void (*mouse_callfunc)(ss_mouse_event *e, void *data); 94 95 #define NUM_MOUSE_BTNS 3 96 #define MOUSE_LBUTTON 0 97 #define MOUSE_RBUTTON 1 98 #define MOUSE_CBUTTON 2 99 100 #define MOUSE_BTN2DOWN(num) (1 << (1 + 2 * (num))) 101 #define MOUSE_BTN2UP(num) (1 << (2 + 2 * (num))) 102 103 // Initialize the mouse, specifying screen size. 104 errtype mouse_init(short xsize, short ysize); 105 106 // shutdown mouse system 107 errtype mouse_shutdown(void); 108 109 // Tell the mouse library where to get timestamps from. 110 // errtype mouse_set_timestamp_register(ulong *tstamp); 111 112 // Get the current mouse timestamp 113 uint32_t mouse_get_time(void); 114 115 // Get the mouse position 116 errtype mouse_get_xy(short *x, short *y); 117 118 // Set the mouse position 119 errtype mouse_put_xy(short x, short y); 120 121 // Check the state of a mouse button 122 // errtype mouse_check_btn(short button, bool *result); 123 124 // look at the next mouse event. 125 // errtype mouse_look_next(ss_mouse_event *result); 126 127 // get & pop the next mouse event 128 errtype mouse_next(ss_mouse_event *result); 129 130 // Flush the mouse queue 131 errtype mouse_flush(void); 132 133 // Add an event to the back of the mouse queue 134 errtype mouse_generate(ss_mouse_event e); 135 136 // Set up an interrupt callback 137 errtype mouse_set_callback(mouse_callfunc f, void *data, int *id); 138 139 // Remove an interrupt callback 140 errtype mouse_unset_callback(int id); 141 142 // Constrain the mouse coordinates 143 errtype mouse_constrain_xy(short xl, short yl, short xh, short yh); 144 145 // Set the mouse rate and accelleration threshhold 146 // errtype mouse_set_rate(short xr, short yr, short thold); 147 148 // Get the mouse rate and accelleration threshhold 149 // errtype mouse_get_rate(short *xr, short *yr, short *thold); 150 151 // Sets the mouse coordinate bounds to (0,0) - (x-1,y-1), 152 // and scales the current values of the mouse sensitivity accordingly. 153 // errtype mouse_set_screensize(short x, short y); 154 155 // Find the min and max "virtual" coordinates of the mouse position 156 // errtype mouse_extremes(short *xmin, short *ymin, short *xmax, short *ymax); 157 158 // Sets mouse handedness (true for left-handed) 159 // errtype mouse_set_lefty(uchar lefty); 160 161 #endif // _MOUSE_H 162