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>
40 print_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",
55 main(
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') {
137 }
else if (key ==
' ') {
139 }
else if (key ==
'2') {
141 }
else if (key ==
'3') {
143 }
else if (key ==
'4') {
145 }
else if (key ==
'5') {
147 }
else if (key ==
'6') {
149 }
else if (key ==
'7') {
151 }
else if (key ==
'8') {
153 }
else if (key ==
'9') {
155 }
else if (key ==
'0') {
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.
static const uint32_t BUTTON_10
BUTTON_10 constant.
static const uint32_t BUTTON_5
BUTTON_5 constant.
static const uint32_t BUTTON_2
BUTTON_2 constant.
static const uint32_t BUTTON_7
BUTTON_7 constant.
static const uint32_t BUTTON_6
BUTTON_6 constant.
static const uint32_t BUTTON_8
BUTTON_8 constant.
static const uint32_t BUTTON_3
BUTTON_3 constant.
static const uint32_t BUTTON_4
BUTTON_4 constant.
static const uint32_t BUTTON_1
BUTTON_1 constant.
static const uint32_t BUTTON_9
BUTTON_9 constant.
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.