corrects how to get the char

This commit is contained in:
Louis-Guillaume DUBOIS 2015-05-02 00:00:28 +02:00
parent b3226f33b9
commit f09c762cb2
3 changed files with 22 additions and 10 deletions

View file

@ -9,18 +9,27 @@ const int Curses::speed_columns = 50;
Curses::Curses() {
initscr();
cbreak();
noecho();
//noecho();
kbd = newwin(kbd_lines, kbd_columns, 0, 0);
speed = newwin(speed_lines, speed_columns,
kbd_lines+1, 0);
speed = newwin(speed_lines, speed_columns, kbd_lines+1, 0);
get = newwin(1,1,kbd_lines+speed_lines+1,2);
print_kbd();
wmove(get, 0, 0);
wrefresh(get);
}
Curses::~Curses() {
delwin(kbd);
delwin(speed);
delwin(get);
endwin();
}
char Curses::getchar()
{
return wgetch(get);
}
void Curses::print_kbd() {
wmove(kbd, 0, 0); waddstr(kbd, " ---------------------");
wmove(kbd, 1, 0); waddstr(kbd, "takeoff>| t|⇑ y|↖ u|↑ i|↗ o|");

View file

@ -13,11 +13,13 @@ class Curses
static const int speed_lines;
static const int speed_columns;
WINDOW* speed;
void print_kbd();
WINDOW* get;
public:
Curses();
~Curses();
void print_kbd();
char getchar();
};
#endif

View file

@ -26,11 +26,12 @@ class Run
void reset()
{ pub_reset.publish(empty); };
float x_speed, y_speed, z_speed, turn;
Curses term;
boost::shared_ptr<Curses> term;
void print_speed() { ; };
public:
Run() :
Run(boost::shared_ptr<Curses> terminal) :
term(terminal),
loop_rate(30),
x_speed(0.2),
y_speed(0.3),
@ -50,7 +51,7 @@ class Run
msg->linear.x = msg->linear.y = msg->linear.z =
msg->angular.x = msg->angular.y = msg->angular.z = 0.;
char c = getch();
char c = term->getchar();
switch(c)
{
@ -212,9 +213,9 @@ int main(int argc, char** argv)
{
setlocale(LC_ALL, "");
ros::init(argc, argv, "keyboard_cmd");
Curses terminal;
terminal.print_kbd();
for(;;) ;
boost::shared_ptr<Curses> term(new Curses());
Run fun(term);
fun();
return 0;
}