upkie 6.1.0
Open-source wheeled biped robots
Loading...
Searching...
No Matches
upkie::cpp::sensors::Keyboard Class Reference

Sensor for reading Keyboard inputs. More...

#include <Keyboard.h>

Public Member Functions

 Keyboard ()
 Constructor sets up the terminal in non-canonical mode where input is available immediately without waiting for a newline.
 
 ~Keyboard () override
 Destructor.
 
std::string prefix () const noexcept final
 Prefix of output in the observation dictionary. More...
 
void write (Dictionary &output) final
 Write output to a dictionary. More...
 
- Public Member Functions inherited from upkie::cpp::sensors::Sensor
virtual ~Sensor ()
 Destructor is virtual to deallocate lists of observers properly.
 
virtual std::string prefix () const noexcept
 Prefix of output in the observation dictionary. More...
 
virtual void write (Dictionary &observation)
 Write output to a dictionary. More...
 

Detailed Description

Sensor for reading Keyboard inputs.

Note
This sensor reads from the standard input, and does not listen to Keyboard events. It can only read one key at a time.
Long key presses will yield an output boolean that goes to true, then false, then stays at true until the key is released. This behavior is tied to the key repetition delay of the keyboard: https://github.com/upkie/upkie/cpp/issues/49

Member Function Documentation

◆ prefix()

std::string upkie::cpp::sensors::Keyboard::prefix ( ) const
inlinefinalvirtualnoexcept

Prefix of output in the observation dictionary.

Reimplemented from upkie::cpp::sensors::Sensor.

◆ write()

void upkie::cpp::sensors::Keyboard::write ( Dictionary &  output)
finalvirtual

Write output to a dictionary.

Parameters
[out]outputDictionary to write observations to.

Reimplemented from upkie::cpp::sensors::Sensor.


The documentation for this class was generated from the following files: