1 // Copyright (C) 2001 MandrakeSoft S.A.
5 // 75002 Paris - France
6 // http://www.linux-mandrake.com/
7 // http://www.mandrakesoft.com/
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU Lesser General Public
11 // License as published by the Free Software Foundation; either
12 // version 2 of the License, or (at your option) any later version.
14 // This library is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 // Lesser General Public License for more details.
19 // You should have received a copy of the GNU Lesser General Public
20 // License along with this library; if not, write to the Free Software
21 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 #include "keysymbols.h"
31 #define BX_KBD_ELEMENTS 16
32 #define BX_MOUSE_BUFF_SIZE 48
35 # define BX_KEY_SMF static
36 # define BX_KEY_THIS bx_keyboard.
39 # define BX_KEY_THIS this->
42 extern bx_keyb_c bx_keyboard;
44 class bx_keyb_c : public logfunctions {
49 BX_KEY_SMF void init(keyboard *kbd_comp);
51 BX_KEY_SMF void init(bx_devices_c *d, bx_cmos_c *cmos);
53 BX_KEY_SMF void gen_scancode(Bit32u scancode);
54 BX_KEY_SMF Bit8u get_kbd_enable(void);
55 BX_KEY_SMF void mouse_motion(int delta_x, int delta_y, unsigned button_state);
56 BX_KEY_SMF void mouse_button(unsigned mouse_state);
58 BX_KEY_SMF int SaveState( class state_file *fd );
59 BX_KEY_SMF int LoadState( class state_file *fd );
61 BX_KEY_SMF unsigned periodic( Bit32u usec_delta );
62 BX_KEY_SMF void put_scancode( unsigned char *code, int count );
66 static Bit32u read_handler(void *this_ptr, Bit32u address, unsigned io_len);
67 static void write_handler(void *this_ptr, Bit32u address, Bit32u value, unsigned io_len);
72 void write(Bit32u address, Bit32u value, unsigned io_len);
73 Bit32u read(Bit32u address, unsigned io_len);
85 Boolean c_d; /* 1=command to port 64h, 0=data to port 60h */
91 Boolean kbd_clock_enabled;
92 Boolean aux_clock_enabled;
95 Bit8u kbd_output_buffer;
96 Bit8u aux_output_buffer;
98 Bit8u expecting_port60h;
99 Bit8u expecting_mouse_parameter;
100 Bit8u last_mouse_command;
101 Bit32u timer_pending;
102 Boolean irq1_requested;
103 Boolean irq12_requested;
108 Bit8u resolution_cpmm; // resolution in counts per mm
113 Bit8u get_status_byte ()
116 // we're always in stream mode (right?)
117 ret |= (enable << 5);
118 ret |= (scaling == 1) ? 0 : (1 << 4);
119 ret |= ((button_status & 0x1) << 2);
120 ret |= ((button_status & 0x2) << 0);
124 Bit8u get_resolution_byte ()
128 switch (resolution_cpmm) {
144 #if BX_SUPPORT_SID==0
146 #define LOG_THIS bx_keyboard.
147 BX_PANIC(("mouse: invalid resolution_cpmm"));
159 Bit8u buffer[BX_KBD_ELEMENTS];
161 Boolean expecting_typematic;
162 Boolean expecting_led_write;
166 Boolean scanning_enabled;
167 } kbd_internal_buffer;
171 Bit8u buffer[BX_MOUSE_BUFF_SIZE];
173 } mouse_internal_buffer;
174 #define BX_KBD_CONTROLLER_QSIZE 5
175 Bit8u controller_Q[BX_KBD_CONTROLLER_QSIZE];
176 unsigned controller_Qsize;
177 unsigned controller_Qsource; // 0=keyboard, 1=mouse
178 } s; // State information for saving/loading
180 keyboard *kbd_component;
182 bx_devices_c *devices;
184 BX_KEY_SMF void resetinternals(Boolean powerup);
185 BX_KEY_SMF void set_kbd_clock_enable(Bit8u value);
186 BX_KEY_SMF void set_aux_clock_enable(Bit8u value);
187 BX_KEY_SMF void kbd_ctrl_to_kbd(Bit8u value);
188 BX_KEY_SMF void kbd_ctrl_to_mouse(Bit8u value);
189 BX_KEY_SMF void kbd_enQ(Bit8u scancode);
190 BX_KEY_SMF void kbd_enQ_imm(Bit8u val);
191 BX_KEY_SMF void activate_timer(void);
192 BX_KEY_SMF void controller_enQ(Bit8u data, unsigned source);
193 BX_KEY_SMF Boolean mouse_enQ_packet(Bit8u b1, Bit8u b2, Bit8u b3);
194 BX_KEY_SMF void mouse_enQ(Bit8u mouse_data);
198 #endif // #ifndef _PCKEY_H