add z & w joystick values to sender
This commit is contained in:
36
osc-joy.c
36
osc-joy.c
@@ -54,7 +54,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
int foo, joy_fd;
|
||||
struct js_event js;
|
||||
int x_pos, y_pos, flag;
|
||||
int x_pos, y_pos, z_pos, w_pos, what;
|
||||
char joy_name[128];
|
||||
int opt;
|
||||
char *remote_host = REMOTE_HOST;
|
||||
@@ -107,7 +107,7 @@ if (verbosity) {
|
||||
|
||||
send_data_id(t, my_id);
|
||||
|
||||
x_pos = y_pos = 0;
|
||||
x_pos = y_pos = z_pos = w_pos = 0;
|
||||
for (;;) {
|
||||
foo = read(joy_fd, &js, sizeof(struct js_event));
|
||||
if (8 != foo) {
|
||||
@@ -122,22 +122,38 @@ for (;;) {
|
||||
js.time, js.type, js.number, js.value);
|
||||
}
|
||||
if (2==js.type) { /* oscillating stick */
|
||||
flag = 0;
|
||||
what = 0;
|
||||
switch (js.number) {
|
||||
case 0:
|
||||
x_pos = js.value;
|
||||
flag = 1;
|
||||
what = 1;
|
||||
break;
|
||||
case 1:
|
||||
y_pos = js.value;
|
||||
flag = 1;
|
||||
what = 1;
|
||||
break;
|
||||
case 2:
|
||||
z_pos = js.value;
|
||||
what = 2;
|
||||
break;
|
||||
case 3:
|
||||
w_pos = js.value;
|
||||
what = 2;
|
||||
break;
|
||||
}
|
||||
if (flag) {
|
||||
foo = send_data_xy(t, x_pos, y_pos);
|
||||
flag = 0;
|
||||
}
|
||||
}
|
||||
/* now, send the datas */
|
||||
// fprintf(stderr, "\t\twhat = %d\n", what);
|
||||
switch (what) {
|
||||
case 1:
|
||||
foo = send_data_xy(t, x_pos, y_pos);
|
||||
what = 0;
|
||||
break;
|
||||
case 2:
|
||||
foo = send_data_zw(t, z_pos, w_pos);
|
||||
what = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (1==js.type) { /* it's a button */
|
||||
foo = send_data_button(t, js.number+button_offset,
|
||||
|
||||
Reference in New Issue
Block a user