1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-07-17 13:29:02 +00:00
CLK/Machines/Apple/ADB/Keyboard.cpp
Thomas Harte a51d143c35 Corrects reactive-device transmission logic.
Albeit that I'm still not properly responding to register 3 stuff, so the ADB bus needn't believe anything is out there. Also, without VSYNC being piped to the microcontroller it may well just not be polling anyway.
2021-02-14 18:54:22 -05:00

59 lines
1.1 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// Keyboard.cpp
// Clock Signal
//
// Created by Thomas Harte on 13/02/2021.
// Copyright © 2021 Thomas Harte. All rights reserved.
//
#include "Keyboard.hpp"
using namespace Apple::ADB;
Keyboard::Keyboard(Bus &bus) : ReactiveDevice(bus, 2) {}
void Keyboard::perform_command(const Command &command) {
if(command.type == Command::Type::Talk) {
switch(command.reg) {
case 0:
// Post up to two key events, or nothing if there are
// no events pending.
//
// Events are:
//
// b7 = 0 for down 1, for up;
// b6b0: key code (mostly 7-bit ASCII)
// post_response({0x00, 0x00});
break;
case 2:
/*
In all cases below: 0 = pressed/on; 1 = released/off.
b15: None (reserved)
b14: Delete
b13: Caps lock
b12: Reset
b11: Control
b10: Shift
b9: Option
b8: Command
-- From here onwards, available only on the extended keyboard.
b7: Num lock/clear
b6: Scroll lock
b53: None (reserved)
b2: Scroll Lock LED
b1: Caps Lock LED
b0: Num Lock LED
*/
post_response({0xff, 0xff});
break;
default: break;
}
return;
}
}