src/keyboard.h

Wed, 09 Feb 2011 15:03:31 +0000

author
Philip Pemberton <philpem@philpem.me.uk>
date
Wed, 09 Feb 2011 15:03:31 +0000
changeset 80
9581358e92b0
child 90
934ae2efdd01
permissions
-rw-r--r--

implement some more of the keyboard controller

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