prism2.device: Compiler delint
[AROS.git] / arch / i386-pc / drivers / mouse.hidd / mouse.h
blob88c3943388e26a6af8dc8a97ce5a0f08728257ac
1 #ifndef _MOUSE_H
2 #define _MOUSE_H
4 /*
5 Copyright © 1995-2010, The AROS Development Team. All rights reserved.
6 $Id$
8 Desc: Include for the mouse native HIDD.
9 Lang: English.
12 #ifndef EXEC_LIBRARIES_H
13 # include <exec/libraries.h>
14 #endif
16 #ifndef OOP_OOP_H
17 # include <oop/oop.h>
18 #endif
20 #ifndef EXEC_SEMAPHORES_H
21 # include <exec/semaphores.h>
22 #endif
24 #include <hidd/mouse.h>
26 /* defines for buttonstate */
28 #define LEFT_BUTTON 1
29 #define RIGHT_BUTTON 2
30 #define MIDDLE_BUTTON 4
32 #define INTELLIMOUSE_SUPPORT 1
34 #define PS2_PROTOCOL_STANDARD 0
35 #define PS2_PROTOCOL_INTELLIMOUSE 1
37 /***** Mouse HIDD *******************/
39 /* IDs */
40 #define IID_Hidd_PCmouse "hidd.bus.mouse"
41 #define CLID_Hidd_PCmouse "hidd.bus.mouse"
43 /* Methods */
44 enum
46 moHidd_Mouse_HandleEvent
49 struct pHidd_Mouse_HandleEvent
51 OOP_MethodID mID;
52 ULONG event;
55 VOID Hidd_Mouse_HandleEvent(OOP_Object *o, ULONG event);
57 /* misc */
59 struct mouse_staticdata
61 struct SignalSemaphore sema; /* Protexting this whole struct */
63 OOP_AttrBase hiddMouseAB;
65 OOP_Class *mouseclass;
67 OOP_Object *mousehidd;
70 struct mousebase
72 struct Library library;
74 struct mouse_staticdata msd;
77 /* 488 byte long ring buffer used to read data with timeout defined */
79 #define RingSize 488
81 struct Ring
83 char ring[RingSize];
84 int top, ptr;
87 /* Object data */
89 struct mouse_data
91 VOID (*mouse_callback)(APTR, struct pHidd_Mouse_Event *);
92 APTR callbackdata;
94 UWORD buttonstate;
96 char *mouse_name;
97 char type; /* type of mouse (usb, ps2, serial) */
98 /* Driver specific data */
100 union
102 struct
104 OOP_Object *usbhidd;
105 } usb;
106 struct
108 struct Interrupt irq;
109 UBYTE mouse_data[5];
110 UBYTE mouse_collected_bytes;
111 UBYTE mouse_protocol;
112 UBYTE mouse_packetsize;
113 UBYTE expected_mouse_acks;
114 UBYTE packetsize;
116 struct pHidd_Mouse_Event event;
117 } ps2;
118 struct
120 OOP_Object *serial;
121 OOP_Object *unit;
122 struct Library *shidd;
123 UBYTE mouse_data[5];
124 UBYTE mouse_collected_bytes;
125 UBYTE mouse_protocol;
126 UBYTE mouse_inth_state;
128 struct pHidd_Mouse_Event event;
129 struct Ring *rx; /* Ring structure for mouse init */
130 } ser;
131 } u;
134 #define MDT_UNKNOWN 0
135 #define MDT_USB 1
136 #define MDT_SERIAL 2
137 #define MDT_PS2 3
139 /* Mouse types */
140 #define P_MS 0 /* Microsoft */
141 #define P_MSC 1 /* Mouse Systems Corp */
142 #define P_MM 2 /* MMseries */
143 #define P_LOGI 3 /* Logitech */
144 #define P_BM 4 /* BusMouse ??? */
145 #define P_LOGIMAN 5 /* MouseMan / TrackMan */
146 #define P_PS2 6 /* PS/2 mouse */
147 #define P_MMHIT 7 /* MM_HitTab */
148 #define P_GLIDEPOINT 8 /* ALPS serial GlidePoint */
149 #define P_IMSERIAL 9 /* Microsoft serial IntelliMouse */
150 #define P_THINKING 10 /* Kensington serial ThinkingMouse */
151 #define P_IMPS2 11 /* Microsoft PS/2 IntelliMouse */
152 #define P_THINKINGPS2 12 /* Kensington PS/2 ThinkingMouse */
153 #define P_MMANPLUSPS2 13 /* Logitech PS/2 MouseMan+ */
154 #define P_GLIDEPOINTPS2 14 /* ALPS PS/2 GlidePoint */
155 #define P_NETPS2 15 /* Genius PS/2 NetMouse */
156 #define P_NETSCROLLPS2 16 /* Genius PS/2 NetScroll */
157 #define P_SYSMOUSE 17 /* SysMouse */
158 #define P_AUTO 18 /* automatic */
159 #define P_ACECAD 19 /* ACECAD protocol */
161 /****************************************************************************************/
163 #define KBD_STATUS_OBF 0x01 /* keyboard output buffer full */
164 #define KBD_STATUS_IBF 0x02 /* keyboard input buffer full */
165 #define KBD_STATUS_MOUSE_OBF 0x20 /* Mouse output buffer full */
166 #define KBD_STATUS_GTO 0x40 /* General receive/xmit timeout */
167 #define KBD_STATUS_PERR 0x80 /* Parity error */
169 #define KBD_CTRLCMD_READ_MODE 0x20
170 #define KBD_CTRLCMD_WRITE_MODE 0x60
171 #define KBD_CTRLCMD_GET_VERSION 0xA1
172 #define KBD_CTRLCMD_MOUSE_DISABLE 0xA7
173 #define KBD_CTRLCMD_MOUSE_ENABLE 0xA8
174 #define KBD_CTRLCMD_TEST_MOUSE 0xA9
175 #define KBD_CTRLCMD_SELF_TEST 0xAA
176 #define KBD_CTRLCMD_KBD_TEST 0xAB
177 #define KBD_CTRLCMD_KBD_DISABLE 0xAD
178 #define KBD_CTRLCMD_KBD_ENABLE 0xAE
179 #define KBD_CTRLCMD_WRITE_AUX_OBUF 0xD3
180 #define KBD_CTRLCMD_WRITE_MOUSE 0xD4
182 #define KBD_OUTCMD_SET_RES 0xE8
183 #define KBD_OUTCMD_SET_SCALE11 0xE6
184 #define KBD_OUTCMD_SET_SCALE21 0xE7
185 #define KBD_OUTCMD_STATUS_REQUEST 0xE9
186 #define KBD_OUTCMD_SET_STREAM_MODE 0xEA
187 #define KBD_OUTCMD_READ_DATA 0xEB
188 #define KBD_OUTCMD_SET_REMOTE_MODE 0xF0
189 #define KBD_OUTCMD_GET_ID 0xF2
190 #define KBD_OUTCMD_SET_RATE 0xF3
191 #define KBD_OUTCMD_SET_STREAM 0xEA
192 #define KBD_OUTCMD_ENABLE 0xF4
193 #define KBD_OUTCMD_DISABLE 0xF5
194 #define KBD_OUTCMD_RESET 0xFF
196 #define KBD_STATUS_REG 0x64
197 #define KBD_CONTROL_REG 0x64
198 #define KBD_DATA_REG 0x60
200 #define KBD_REPLY_POR 0xAA /* Power on reset */
201 #define KBD_REPLY_ACK 0xFA /* Command ACK */
202 #define KBD_REPLY_RESEND 0xFE /* Command NACK, send the cmd again */
204 #define KBD_MODE_KBD_INT 0x01 /* Keyboard data generate IRQ1 */
205 #define KBD_MODE_MOUSE_INT 0x02 /* Mouse data generate IRQ12 */
206 #define KBD_MODE_SYS 0x04 /* The system flag (?) */
207 #define KBD_MODE_NO_KEYLOCK 0x08 /* The keylock doesn't affect the keyboard if set */
208 #define KBD_MODE_DISABLE_KBD 0x10 /* Disable keyboard interface */
209 #define KBD_MODE_DISABLE_MOUSE 0x20 /* Disable mouse interface */
210 #define KBD_MODE_KCC 0x40 /* Scan code conversion to PC format */
211 #define KBD_MODE_RFU 0x80
213 /****************************************************************************************/
215 #ifdef inb
216 #undef inb
217 #endif
218 static inline unsigned char inb(unsigned short port)
220 unsigned char _v;
222 __asm__ __volatile__
223 ("inb %w1,%0"
224 : "=a" (_v)
225 : "Nd" (port)
228 return _v;
231 #ifdef outb
232 #undef outb
233 #endif
234 static inline void outb(unsigned char value, unsigned short port)
236 __asm__ __volatile__
237 ("outb %b0,%w1"
239 : "a" (value), "Nd" (port)
243 /****************************************************************************************/
245 #define mouse_read_input() inb(0x60) //KBD_DATA_REG)
246 #define mouse_read_status() inb(0x64) //KBD_STATUS_REG)
247 #define mouse_write_output(val) outb(val, 0x60) //KBD_DATA_REG)
248 #define mouse_write_command(val) outb(val, 0x64) //KBD_CONTROL_REG)
250 /****************************************************************************************/
253 #define MSD(cl) (&((struct mousebase *)cl->UserData)->msd)
255 #endif /* _MOUSE_H */