mirror of
https://github.com/wichtounet/thor-os.git
synced 2025-09-15 23:47:25 -04:00
Read input raw with timeout
This commit is contained in:
parent
e1ab6905d8
commit
f8df91f49f
@ -52,10 +52,17 @@ struct virtual_terminal {
|
||||
|
||||
/*!
|
||||
* \brief Reads non-canonical input in the given buffer
|
||||
* \return the keyboard scan code
|
||||
* \return the keyboard key code
|
||||
*/
|
||||
size_t read_input_raw();
|
||||
|
||||
/*!
|
||||
* \brief Reads non-canonical input in the given buffer, with
|
||||
* a timeout
|
||||
* \return the keyboard key code
|
||||
*/
|
||||
size_t read_input_raw(size_t ms);
|
||||
|
||||
void set_canonical(bool can);
|
||||
|
||||
virtual_terminal(){}
|
||||
|
@ -134,6 +134,20 @@ size_t stdio::virtual_terminal::read_input_raw(){
|
||||
return raw_buffer.pop();
|
||||
}
|
||||
|
||||
size_t stdio::virtual_terminal::read_input_raw(size_t ms){
|
||||
if(raw_buffer.empty()){
|
||||
if(!ms){
|
||||
return static_cast<size_t>(keycode::INVALID);
|
||||
}
|
||||
|
||||
if(!input_queue.sleep(ms)){
|
||||
return static_cast<size_t>(keycode::INVALID);
|
||||
}
|
||||
}
|
||||
|
||||
return raw_buffer.pop();
|
||||
}
|
||||
|
||||
void stdio::virtual_terminal::set_canonical(bool can){
|
||||
logging::logf(logging::log_level::TRACE, "Switched terminal %u canonical mode from %u to %u\n", id, uint64_t(canonical), uint64_t(canonical));
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user