1
0
mirror of https://github.com/jscrane/r65emu.git synced 2024-05-29 03:41:36 +00:00

minor kbd changes

This commit is contained in:
Stephen Crane 2014-12-15 14:36:52 +00:00
parent 50110b3525
commit f8371e10df
3 changed files with 83 additions and 54 deletions

View File

@ -7,10 +7,10 @@ public:
virtual void down(byte) = 0;
virtual void reset() = 0;
inline bool isshift(byte scan) {
static inline bool isshift(byte scan) {
return scan == 0x12 || scan == 0x59;
}
inline bool isctrl(byte scan) {
static inline bool isctrl(byte scan) {
return scan == 0x14;
}
};

View File

@ -71,6 +71,31 @@ int PS2Driver::read() {
return buffer[i];
}
unsigned PS2Driver::read2() {
if (head == tail)
return 0;
uint8_t i = tail+1;
if (i == BUFFER_SIZE) i = 0;
tail = i;
if (buffer[i] != 0xf0)
return buffer[i];
return 0x0100 | read2();
}
unsigned PS2Driver::peek() {
if (head == tail)
return 0;
uint8_t i = tail+1;
if (i == BUFFER_SIZE) i = 0;
if (buffer[i] == 0xf0) {
if (++i == BUFFER_SIZE) i = 0;
return 0x0100 | buffer[i];
}
return buffer[i];
}
void PS2Driver::begin(uint8_t data_pin, uint8_t irq_pin)
{
DataPin = data_pin;

View File

@ -28,6 +28,10 @@ public:
* If there is no char available, -1 is returned.
*/
int read();
unsigned peek();
unsigned read2();
};
#define PS2_F1 0x05