Fixing PS2 examples

This commit is contained in:
Rodrigo Alfonso 2024-04-21 20:57:59 -03:00
parent c23056e51a
commit 232a834c3b
2 changed files with 7 additions and 4 deletions

View File

@ -6,6 +6,7 @@
#include "../../../lib/LinkPS2Keyboard.hpp"
void log(std::string text);
static std::string scanCodes = "";
static std::string output = "";
static u32 irqs = 0;
inline void VBLANK() {}
@ -15,9 +16,9 @@ void SERIAL() {
}
// (1) Create a LinkPS2Keyboard instance
LinkPS2Keyboard* linkPS2Keyboard = new LinkPS2Keyboard([](u8 event) {
LinkPS2Keyboard* linkPS2Keyboard = new LinkPS2Keyboard([](u8 scanCode) {
// (4) Handle events in the callback sent to LinkPS2Keyboard's constructor!
output += std::to_string(event) + "|";
scanCodes += std::to_string(scanCode) + "|";
});
void init() {
@ -49,6 +50,8 @@ int main() {
VBlankIntrWait();
continue;
}
} else {
output += std::to_string(irqs) + " - " + scanCodes;
}
// Print

View File

@ -45,8 +45,8 @@ int main() {
// (4) Get a report
int data[3];
linkPS2Mouse->report(data);
log(std::to_string(data[0]) + ": " + "(" + std::to_string(data[1]) +
", " + std::to_string(data[2]) + ")");
output += std::to_string(data[0]) + ": " + "(" + std::to_string(data[1]) +
", " + std::to_string(data[2]) + ")";
}
// Print