Skip to content

Commit

Permalink
Display and keyboard driver implementation source file.
Browse files Browse the repository at this point in the history
  • Loading branch information
nthnn committed May 19, 2024
1 parent 71c01f1 commit 7824bcd
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 0 deletions.
22 changes: 22 additions & 0 deletions sdk/librishka_drivers_display.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include "librishka.h"
#include "librishka_impl.hpp"

i32 Display::screen_height() {
return (i32) rishka_sc_0(RISHKA_SC_DISPLAY_SCREEN_HEIGHT);
}

i32 Display::screen_width() {
return (i32) rishka_sc_0(RISHKA_SC_DISPLAY_SCREEN_WIDTH);
}

i32 Display::viewport_height() {
return (i32) rishka_sc_0(RISHKA_SC_DISPLAY_VIEWPORT_HEIGHT);
}

i32 Display::viewport_width() {
return (i32) rishka_sc_0(RISHKA_SC_DISPLAY_VIEWPORT_WIDTH);
}

i32 Display::supported_colors() {
return (i32) rishka_sc_0(RISHKA_SC_DISPLAY_SUPPORTED_COLORS);
}
54 changes: 54 additions & 0 deletions sdk/librishka_drivers_keyboard.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#include "librishka.h"
#include "librishka_impl.hpp"

string Keyboard::layout_name() {
return get_rt_string(rishka_sc_0(RISHKA_SC_KB_LAYOUT_NAME));
}

string Keyboard::layout_desc() {
return get_rt_string(rishka_sc_0(RISHKA_SC_KB_LAYOUT_DESC));
}

PS2Device Keyboard::device_type() {
return (PS2Device) rishka_sc_0(RISHKA_SC_KB_DEVICE_TYPE);
}

bool Keyboard::is_num_lock() {
return (bool) rishka_sc_0(RISHKA_SC_KB_LED_GET_NUM);
}

bool Keyboard::is_caps_lock() {
return (bool) rishka_sc_0(RISHKA_SC_KB_LED_GET_CAPS);
}

bool Keyboard::is_scroll_lock() {
return (bool) rishka_sc_0(RISHKA_SC_KB_LED_GET_SCROLL);
}

void Keyboard::num_lock(bool state) {
rishka_sc_1(RISHKA_SC_KB_LED_SET_NUM, (i64) state);
}

void Keyboard::caps_lock(bool state) {
rishka_sc_1(RISHKA_SC_KB_LED_SET_CAPS, (i64) state);
}

void Keyboard::scroll_lock(bool state) {
rishka_sc_1(RISHKA_SC_KB_LED_SET_SCROLL, (i64) state);
}

u32 Keyboard::next_scancode(i32 timeout, bool resend) {
return (u32) rishka_sc_2(RISHKA_SC_KB_NEXT_SCAN_CODE, (i64) timeout, (i64) resend);
}

void Keyboard::lock(i32 timeout) {
rishka_sc_1(RISHKA_SC_KB_LOCK, (i64) timeout);
}

void Keyboard::unlock() {
rishka_sc_0(RISHKA_SC_KB_UNLOCK);
}

void Keyboard::reset() {
rishka_sc_0(RISHKA_SC_KB_RESET);
}

0 comments on commit 7824bcd

Please sign in to comment.