[Teton/Voyageurs] Subscribe to scancodes in teton and print them to screen.
Right now there appears to be an error with the font so that the proper character is received but we write an incorect character to the screen (off by one?).
This commit is contained in:
parent
ea17c143cc
commit
1b7d2b9085
|
@ -47,4 +47,12 @@ glcr::ErrorCode PortServer::PollForIntCap(uint64_t *msg, uint64_t *cap) {
|
|||
return glcr::OK;
|
||||
}
|
||||
|
||||
glcr::ErrorOr<char> PortServer::RecvChar() {
|
||||
uint64_t bytes = 1;
|
||||
uint64_t caps = 0;
|
||||
char byte;
|
||||
RET_ERR(ZPortRecv(port_cap_, &bytes, &byte, &caps, nullptr));
|
||||
return byte;
|
||||
}
|
||||
|
||||
} // namespace mmth
|
||||
|
|
|
@ -18,6 +18,8 @@ class PortServer {
|
|||
glcr::ErrorCode RecvCap(uint64_t* num_bytes, char* msg, uint64_t* cap);
|
||||
glcr::ErrorCode PollForIntCap(uint64_t* msg, uint64_t* cap);
|
||||
|
||||
glcr::ErrorOr<char> RecvChar();
|
||||
|
||||
z_cap_t cap() { return port_cap_; }
|
||||
|
||||
private:
|
||||
|
|
|
@ -13,6 +13,7 @@ target_link_libraries(teton
|
|||
glacier
|
||||
mammoth
|
||||
victoriafalls_yunq
|
||||
voyageurs_yunq
|
||||
yellowstone_yunq
|
||||
)
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#include <mammoth/ipc/port_server.h>
|
||||
#include <mammoth/util/debug.h>
|
||||
#include <mammoth/util/init.h>
|
||||
#include <victoriafalls/victoriafalls.yunq.client.h>
|
||||
#include <voyageurs/voyageurs.yunq.client.h>
|
||||
#include <yellowstone/yellowstone.yunq.client.h>
|
||||
|
||||
#include "framebuffer/console.h"
|
||||
|
@ -28,13 +30,33 @@ uint64_t main(uint64_t init_port) {
|
|||
Psf psf("/default8x16.psfu");
|
||||
psf.DumpHeader();
|
||||
|
||||
// 3. Write a line to the screen.
|
||||
Console console(fbuf, psf);
|
||||
console.WriteString("Hello World!\n");
|
||||
for (uint8_t i = 0x20; i < 0x7E; i++) {
|
||||
console.WriteChar(i);
|
||||
}
|
||||
|
||||
// 3. Write a line to the screen.
|
||||
GetEndpointRequest req;
|
||||
req.set_endpoint_name("voyageurs");
|
||||
Endpoint endpoint;
|
||||
RET_ERR(client.GetEndpoint(req, endpoint));
|
||||
|
||||
VoyageursClient voyaguers(endpoint.endpoint());
|
||||
ASSIGN_OR_RETURN(mmth::PortServer server, mmth::PortServer::Create());
|
||||
KeyboardListener listener;
|
||||
ASSIGN_OR_RETURN(mmth::PortClient pclient, server.CreateClient());
|
||||
listener.set_port_capability(pclient.cap());
|
||||
None n;
|
||||
RET_ERR(voyaguers.RegisterKeyboardListener(listener, n));
|
||||
|
||||
while (true) {
|
||||
ASSIGN_OR_RETURN(char c, server.RecvChar());
|
||||
if (c != '\0') {
|
||||
console.WriteChar(c);
|
||||
dbgln("{}", c);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,92 @@
|
|||
|
||||
#include <mammoth/util/debug.h>
|
||||
|
||||
namespace {
|
||||
|
||||
char ScancodeToChar(uint8_t code) {
|
||||
switch (code) {
|
||||
case 0x02:
|
||||
return '1';
|
||||
case 0x03:
|
||||
return '2';
|
||||
case 0x04:
|
||||
return '3';
|
||||
case 0x05:
|
||||
return '4';
|
||||
case 0x06:
|
||||
return '5';
|
||||
case 0x07:
|
||||
return '6';
|
||||
case 0x08:
|
||||
return '7';
|
||||
case 0x09:
|
||||
return '8';
|
||||
case 0x0A:
|
||||
return '9';
|
||||
case 0x0B:
|
||||
return '0';
|
||||
case 0x10:
|
||||
return 'Q';
|
||||
case 0x11:
|
||||
return 'W';
|
||||
case 0x12:
|
||||
return 'E';
|
||||
case 0x13:
|
||||
return 'R';
|
||||
case 0x14:
|
||||
return 'T';
|
||||
case 0x15:
|
||||
return 'Y';
|
||||
case 0x16:
|
||||
return 'U';
|
||||
case 0x17:
|
||||
return 'I';
|
||||
case 0x18:
|
||||
return 'O';
|
||||
case 0x19:
|
||||
return 'P';
|
||||
case 0x1E:
|
||||
return 'A';
|
||||
case 0x1F:
|
||||
return 'S';
|
||||
case 0x20:
|
||||
return 'D';
|
||||
case 0x21:
|
||||
return 'F';
|
||||
case 0x22:
|
||||
return 'G';
|
||||
case 0x23:
|
||||
return 'H';
|
||||
case 0x24:
|
||||
return 'J';
|
||||
case 0x25:
|
||||
return 'K';
|
||||
case 0x26:
|
||||
return 'L';
|
||||
case 0x2C:
|
||||
return 'Z';
|
||||
case 0x2D:
|
||||
return 'X';
|
||||
case 0x2E:
|
||||
return 'Y';
|
||||
case 0x2F:
|
||||
return 'C';
|
||||
case 0x30:
|
||||
return 'V';
|
||||
case 0x31:
|
||||
return 'B';
|
||||
case 0x32:
|
||||
return 'N';
|
||||
case 0x33:
|
||||
return 'M';
|
||||
}
|
||||
|
||||
dbgln("Unhandled scancode {x}", code);
|
||||
return '\0';
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void InterruptEnter(void* void_keyboard) {
|
||||
KeyboardDriver* keyboard = static_cast<KeyboardDriver*>(void_keyboard);
|
||||
|
||||
|
@ -28,7 +114,7 @@ void KeyboardDriver::InterruptLoop() {
|
|||
dbgln("Scan {x}", scancode);
|
||||
|
||||
for (mmth::PortClient& client : listeners_) {
|
||||
client.WriteByte(scancode);
|
||||
client.WriteByte(ScancodeToChar(scancode));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue