Wed, 09 Feb 2011 16:35:49 +0000
major work on keyboard driver
1 #ifndef _KEYBOARD_H
2 #define _KEYBOARD_H
4 #include "SDL.h"
6 /// Keyboard buffer size in bytes
7 #define KEYBOARD_BUFFER_SIZE 256
9 typedef struct {
10 /// Key states
11 int keystate[0x80];
13 /// Keyboard buffer
14 char buffer[KEYBOARD_BUFFER_SIZE];
16 /// Read pointer
17 size_t readp;
19 /// Write pointer
20 size_t writep;
22 /// Number of bytes in keyboard buffer
23 size_t buflen;
25 /// Transmit Interrupt Enable
26 bool txie;
27 /// Receive Interrupt Enable
28 bool rxie;
29 } KEYBOARD_STATE;
31 /**
32 * Initialise a keyboard state block.
33 *
34 * Call this once when the keyboard is added to the emulation.
35 */
36 void keyboard_init(KEYBOARD_STATE *ks);
38 /**
39 * SDL_Event delegation routine.
40 *
41 * Call this when an SDL keyup or keydown event is received.
42 */
43 void keyboard_event(KEYBOARD_STATE *ks, SDL_Event *ev);
45 /**
46 * Keyboard scan routine.
47 *
48 * Call this periodically to scan the keyboard. 60 times/sec should be fine.
49 */
50 void keyboard_scan(KEYBOARD_STATE *ks);
52 bool keyboard_get_irq(KEYBOARD_STATE *ks);
53 uint8_t keyboard_read(KEYBOARD_STATE *ks, uint8_t addr);
54 void keyboard_write(KEYBOARD_STATE *ks, uint8_t addr, uint8_t val);
56 #endif