Jakt toolchain for TempleOS development
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
unholy-jakt/input.jakt

40 lines
1.1 KiB

import extern c "input.h" {
extern function input_key_down(scancode: u8) -> bool
extern function input_mouse_left() -> bool
extern function input_mouse_right() -> bool
extern function input_mouse_x() -> i64
extern function input_mouse_y() -> i64
extern function input_press_a_key() -> bool
}
struct Input {
function get_string(message: String) throws -> String {
mut s = StringBuilder::create()
unsafe {
cpp {
"char const *chars = input_get_string(message.c_string());
TRY(s.append_c_string(chars));
delete(chars);"
}
}
return s.to_string()
}
function key_down(scancode: u8) -> bool {
return input_key_down(scancode)
}
function mouse_left() -> bool {
return input_mouse_left()
}
function mouse_right() -> bool {
return input_mouse_right()
}
function mouse_x() -> i64 {
return input_mouse_x()
}
function mouse_y() -> i64 {
return input_mouse_y()
}
function press_a_key() {
input_press_a_key()
}
}