23#include "remote_bb_poster.h"
25#include <core/exceptions/system.h>
26#include <interfaces/JoystickInterface.h>
27#include <logging/console.h>
28#include <utils/system/argparser.h>
29#include <utils/system/getkey.h>
30#include <utils/time/time.h>
40print_usage(
const char *program_name)
42 printf(
"Usage: %s [-h] [-r host[:port]]\n"
43 " -h This help message\n"
44 " -r host[:port] Remote host (and optionally port) to connect to\n"
45 " -d device Joystick device to use\n"
46 " -l Start in logging mode - print data read from bb\n",
55main(
int argc,
char **argv)
60 if (argp.has_arg(
"h")) {
66 char * host = (
char *)
"localhost";
67 unsigned short int port = 1910;
68 bool free_host = argp.parse_hostport(
"r", &host, &port);
72 jbp.joystick_plugged(3, 10);
73 float axis[3], new_axis[3];
74 unsigned int button, new_button;
77 axis[0] = axis[1] = 0.;
79 new_axis[0] = new_axis[1] = new_axis[2] = 0.;
80 button = new_button = 0;
91 if ((now - &last) < 0.5) {
98 new_axis[0] = new_axis[1] = 0;
101 }
else if (key == 27) {
105 new_axis[0] = new_axis[1] = 0;
116 case 65: new_axis[0] = +1.;
break;
117 case 66: new_axis[0] = -1.;
break;
118 case 67: new_axis[1] = -1.;
break;
119 case 68: new_axis[1] = +1.;
break;
123 }
else if (key ==
'+') {
124 if ((axis[2] + 0.1) <= 1.0) {
129 }
else if (key ==
'-') {
130 if ((axis[2] - 0.1) >= 0.) {
135 }
else if (key ==
'1') {
136 new_button = JoystickInterface::BUTTON_1;
137 }
else if (key ==
' ') {
138 new_button = JoystickInterface::BUTTON_1;
139 }
else if (key ==
'2') {
140 new_button = JoystickInterface::BUTTON_2;
141 }
else if (key ==
'3') {
142 new_button = JoystickInterface::BUTTON_3;
143 }
else if (key ==
'4') {
144 new_button = JoystickInterface::BUTTON_4;
145 }
else if (key ==
'5') {
146 new_button = JoystickInterface::BUTTON_5;
147 }
else if (key ==
'6') {
148 new_button = JoystickInterface::BUTTON_6;
149 }
else if (key ==
'7') {
150 new_button = JoystickInterface::BUTTON_7;
151 }
else if (key ==
'8') {
152 new_button = JoystickInterface::BUTTON_8;
153 }
else if (key ==
'9') {
154 new_button = JoystickInterface::BUTTON_9;
155 }
else if (key ==
'0') {
156 new_button = JoystickInterface::BUTTON_10;
159 if ((axis[0] != new_axis[0]) || (axis[1] != new_axis[1]) || (axis[2] != new_axis[2])
160 || (button != new_button)) {
161 axis[0] = new_axis[0];
162 axis[1] = new_axis[1];
163 axis[2] = new_axis[2];
165 jbp.joystick_changed(button, axis);
169 jbp.joystick_unplugged();
175 printf(
"Error: Unknown Argument\n\n");
176 print_usage(argv[0]);
Glue to post new data to a RemoteBlackBoard.
Parse command line arguments.
Interface for logging to stderr.
A class for handling time.
Time & stamp()
Set this time to the current time.
Thrown if unknown argument was supplied.
Fawkes library namespace.
char getkey(int timeout_decisecs)
Get value of a single key-press non-blocking.