src/keyboard.h

Tue, 01 Mar 2011 21:33:32 +0000

author
Philip Pemberton <philpem@philpem.me.uk>
date
Tue, 01 Mar 2011 21:33:32 +0000
changeset 96
45ae4c97155b
parent 91
781c15e60012
permissions
-rw-r--r--

Add keyboard patch from Andrew Warkentin <andreww591 gmail com>

I fixed the keyboard in FreeBee. I looked at the keyboard driver source available on a few sites, and it appears that BEGKBD/KEY_BEGIN_KEYBOARD is only supposed to be sent after the end of mouse data, and that KLAST/KEY_LIST_END is not a separate code, but a flag that is set on the last non-KALLUP/KEY_ALL_UP code in a list. I have attached a patch that implements these changes. I have also attached a patch that adds the 60Hz timer interrupt (I'm not sure if it's totally correct, though, since the cursor blinks rather slowly).

Received-From: Andrew Warkentin <andreww591 gmail com>
Signed-Off-By: Philip Pemberton <philpem@philpem.me.uk>

     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 	uint8_t 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;
    28 	/// Receive Interrupt Enable
    29 	bool rxie;
    31 	/// "Keyboard State Changed" flag
    32 	bool update_flag;
    33 } KEYBOARD_STATE;
    35 /**
    36  * Initialise a keyboard state block.
    37  *
    38  * Call this once when the keyboard is added to the emulation.
    39  */
    40 void keyboard_init(KEYBOARD_STATE *ks);
    42 /**
    43  * SDL_Event delegation routine.
    44  *
    45  * Call this when an SDL keyup or keydown event is received.
    46  */
    47 void keyboard_event(KEYBOARD_STATE *ks, SDL_Event *ev);
    49 /**
    50  * Keyboard scan routine.
    51  *
    52  * Call this periodically to scan the keyboard. 60 times/sec should be fine.
    53  */
    54 void keyboard_scan(KEYBOARD_STATE *ks);
    56 bool keyboard_get_irq(KEYBOARD_STATE *ks);
    57 uint8_t keyboard_read(KEYBOARD_STATE *ks, uint8_t addr);
    58 void keyboard_write(KEYBOARD_STATE *ks, uint8_t addr, uint8_t val);
    60 #endif