75,24 → 75,28 |
int input=INPUT_NONE; |
|
|
|
int main(int argc, char**argv) |
{ |
|
printf("Starting Riddim \n"); |
printf("Starting Riddim %d.%d \n",RIDDIM_VERSION_MAJOR,RIDDIM_VERSION_MINOR ); |
printf("\tRemote Interactive Digital Drone Interface Mashup\n"); |
printf("\nusage:\n"); |
printf("\t riddim [config_file]\n\n"); |
|
// bt_host_init(); |
|
|
collect_evdev_devices(); |
|
bt_host_init(); |
|
if (argv[1]) |
parse_config(argv[1]); |
else |
parse_config("/etc/riddim.conf"); |
|
// exit(0); |
|
|
printf("input %s:\n",input_evdev_name); |
/* |
if (bluetooth_mac) |
103,9 → 107,22 |
connected=TRUE; |
} |
*/ |
|
if (mk_tty) |
{ |
printf("connecting to mk via tty: %s\n",mk_tty); |
if (!connect_mk_tty(mk_tty)) |
printf("cant connect !!"); |
else |
{ |
printf("connected !-)"); |
connected=TRUE; |
} |
} |
|
if (mk_socket_port) |
{ |
printf("connecting to local port: %i\n",mk_socket_port); |
printf("connecting to mk via local port: %i\n",mk_socket_port); |
|
if (connect_mk_localhost_socket(mk_socket_port)==-1) |
printf("cant connect !!"); |
118,6 → 135,9 |
|
// todo reenable bluetooth connection |
|
connect_evdev(); |
|
/* |
if ((input_evdev_name)) |
{ |
printf("\nInitializing evdev input (%s) ..\n",input_evdev_name); |
130,7 → 150,7 |
else |
printf(".. ERROR ");// |
} |
|
*/ |
if (input_joydev_name) |
{ |
printf("\nInitializing joystick input from %s ..\n",input_joydev_name); |
188,14 → 208,19 |
|
|
|
init_evdevstatus_led(); |
// init_evdevstatus_led(); |
|
while( TRUE ) |
{ |
|
blink_evdev_led(); |
// bt_host_tick(mk_socket); |
// blink_evdev_led(); |
bt_host_tick(mk_socket); |
usleep(loop_delay); |
|
|
|
poll_evdev(); |
|
switch (input) |
{ |
|
206,7 → 231,7 |
|
case INPUT_EVDEV: |
printf("processing input evdev\n"); |
poll_evdev(); |
|
|
break; |
|
297,23 → 322,21 |
|
confirm_misses=0; |
|
RxBuffer[1]=0; |
RxBuffer[2]=0; |
if (connected) |
|
|
while (RxBuffer[1]!='t') |
while (RxBuffer[2]!='B') |
{ |
|
RxBuffer[1]=0; |
read_from_mk(); |
// bt_host_send(RxBuffer,rx_last_length); |
printf("sending to host: %s",PrintableRxBuffer); |
bt_host_send(RxBuffer,rx_last_length); |
printf("sending to host: %s",PrintableRxBuffer); |
|
|
// ftime(&time_struct); |
|
printf("waiting for confirm frame ( confirmed:%d misses:%d )\n",complete_matches,complete_misses); |
RxBuffer[2]=0; |
printf("waiting for confirm frame ( confirmed:%d misses:%d %c)\n",complete_matches,complete_misses,RxBuffer[2]); |
// RxBuffer[2]=0; |
|
// r=0; |
|
350,15 → 373,74 |
|
|
|
/* Mix input values */ |
|
act_gas=0; |
act_nick=0; |
act_roll=0; |
act_gier=0; |
|
int act_input=0; |
for (act_input=0;act_input<input_count;act_input++) |
{ |
//process buttons |
if (inputs[act_input].nick_up_btn!=-1) |
{ |
if (inputs[act_input].evdev_button[inputs[act_input].nick_up_btn]!=0) |
act_nick=100; |
|
} |
|
if (inputs[act_input].nick_down_btn!=-1) |
{ |
if (inputs[act_input].evdev_button[inputs[act_input].nick_down_btn]!=0) |
act_nick=-100; |
|
} |
|
if (inputs[act_input].roll_left_btn!=-1) |
{ |
if (inputs[act_input].evdev_button[inputs[act_input].roll_left_btn]!=0) |
act_roll=100; |
|
} |
|
if (inputs[act_input].roll_right_btn!=-1) |
{ |
if (inputs[act_input].evdev_button[inputs[act_input].roll_right_btn]!=0) |
act_roll=-100; |
|
} |
|
// process axis |
|
if (inputs[act_input].rel_axis_nick!=-1) |
act_nick=inputs[act_input].evdev_rel_axis[inputs[act_input].rel_axis_nick]*inputs[act_input].nick_mul; |
|
if (inputs[act_input].rel_axis_roll!=-1) |
act_roll=inputs[act_input].evdev_rel_axis[inputs[act_input].rel_axis_roll]*inputs[act_input].roll_mul; |
|
|
if (inputs[act_input].rel_axis_gier!=-1) |
act_gier=inputs[act_input].evdev_rel_axis[inputs[act_input].rel_axis_gier]*inputs[act_input].gier_mul; |
|
|
if (inputs[act_input].rel_axis_gas!=-1) |
act_gas=inputs[act_input].evdev_rel_axis[inputs[act_input].rel_axis_gas]*inputs[act_input].gas_mul; |
|
|
|
} |
|
switch(input) |
{ |
case INPUT_EVDEV: |
|
/* |
act_nick=(evdev_rel_axis[rel_axis_nick]-nick_add)*nick_mul; |
act_roll=(evdev_rel_axis[rel_axis_roll]-nick_add)*roll_mul; |
act_gier=(evdev_rel_axis[rel_axis_gier]-nick_add)*gier_mul; |
act_gas=(evdev_rel_axis[rel_axis_gas]-nick_add)*gas_mul; |
|
*/ |
|
break; |
|
428,6 → 510,7 |
ExternControl.Roll=act_roll*(-1); //(axis[0]>>8)*(-1)/2; |
ExternControl.Gier=act_gier; // ************ |
ExternControl.Gas=act_gas; // ************ |
ExternControl.Gas=255; // ************ |
|
|
|