Rev 140 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 140 | Rev 483 | ||
---|---|---|---|
Line 73... | Line 73... | ||
73 | 73 | ||
Line -... | Line 74... | ||
- | 74 | ||
74 | 75 | int input=INPUT_NONE; |
|
75 | int input=INPUT_NONE; |
76 | |
Line 76... | Line 77... | ||
76 | 77 | ||
77 | 78 | ||
78 | int main(int argc, char**argv) |
79 | int main(int argc, char**argv) |
79 | { |
80 | { |
Line 80... | Line -... | ||
80 | - | ||
Line -... | Line 81... | ||
- | 81 | ||
- | 82 | printf("Starting Riddim %d.%d \n",RIDDIM_VERSION_MAJOR,RIDDIM_VERSION_MINOR ); |
|
- | 83 | printf("\tRemote Interactive Digital Drone Interface Mashup\n"); |
|
- | 84 | printf("\nusage:\n"); |
|
81 | printf("Starting Riddim \n"); |
85 | printf("\t riddim [config_file]\n\n"); |
82 | printf("\tRemote Interactive Digital Drone Interface Mashup\n"); |
86 | |
83 | printf("\nusage:\n"); |
87 | |
84 | printf("\t riddim [config_file]\n\n"); |
88 | |
Line 85... | Line 89... | ||
85 | 89 | collect_evdev_devices(); |
|
Line 86... | Line 90... | ||
86 | // bt_host_init(); |
90 | |
87 | 91 | bt_host_init(); |
|
88 | 92 | ||
89 | if (argv[1]) |
93 | if (argv[1]) |
Line 101... | Line 105... | ||
101 | printf("Connecting via Bluetooth to %s\n",bluetooth_mac); |
105 | printf("Connecting via Bluetooth to %s\n",bluetooth_mac); |
102 | if (connect_mk_bluetooth(bluetooth_mac));; |
106 | if (connect_mk_bluetooth(bluetooth_mac));; |
103 | connected=TRUE; |
107 | connected=TRUE; |
104 | } |
108 | } |
105 | */ |
109 | */ |
- | 110 | ||
- | 111 | if (mk_tty) |
|
- | 112 | { |
|
- | 113 | printf("connecting to mk via tty: %s\n",mk_tty); |
|
- | 114 | if (!connect_mk_tty(mk_tty)) |
|
- | 115 | printf("cant connect !!"); |
|
- | 116 | else |
|
- | 117 | { |
|
- | 118 | printf("connected !-)"); |
|
- | 119 | connected=TRUE; |
|
- | 120 | } |
|
- | 121 | } |
|
- | 122 | ||
106 | if (mk_socket_port) |
123 | if (mk_socket_port) |
107 | { |
124 | { |
108 | printf("connecting to local port: %i\n",mk_socket_port); |
125 | printf("connecting to mk via local port: %i\n",mk_socket_port); |
Line 109... | Line 126... | ||
109 | 126 | ||
110 | if (connect_mk_localhost_socket(mk_socket_port)==-1) |
127 | if (connect_mk_localhost_socket(mk_socket_port)==-1) |
111 | printf("cant connect !!"); |
128 | printf("cant connect !!"); |
112 | else |
129 | else |
Line 116... | Line 133... | ||
116 | } |
133 | } |
117 | } |
134 | } |
Line 118... | Line 135... | ||
118 | 135 | ||
Line -... | Line 136... | ||
- | 136 | // todo reenable bluetooth connection |
|
- | 137 | ||
- | 138 | connect_evdev(); |
|
119 | // todo reenable bluetooth connection |
139 | |
120 | 140 | /* |
|
121 | if ((input_evdev_name)) |
141 | if ((input_evdev_name)) |
Line 122... | Line 142... | ||
122 | { |
142 | { |
Line 128... | Line 148... | ||
128 | input=INPUT_EVDEV; |
148 | input=INPUT_EVDEV; |
129 | } |
149 | } |
130 | else |
150 | else |
131 | printf(".. ERROR ");// |
151 | printf(".. ERROR ");// |
132 | } |
152 | } |
133 | 153 | */ |
|
134 | if (input_joydev_name) |
154 | if (input_joydev_name) |
135 | { |
155 | { |
136 | printf("\nInitializing joystick input from %s ..\n",input_joydev_name); |
156 | printf("\nInitializing joystick input from %s ..\n",input_joydev_name); |
137 | if (connect_joy()) |
157 | if (connect_joy()) |
138 | { |
158 | { |
Line 186... | Line 206... | ||
186 | 206 | ||
Line 187... | Line 207... | ||
187 | int confirm_misses; |
207 | int confirm_misses; |
Line 188... | Line 208... | ||
188 | 208 | ||
189 | 209 | ||
Line 190... | Line 210... | ||
190 | 210 | ||
191 | init_evdevstatus_led(); |
211 | // init_evdevstatus_led(); |
192 | 212 | ||
- | 213 | while( TRUE ) |
|
- | 214 | { |
|
- | 215 | ||
- | 216 | // blink_evdev_led(); |
|
- | 217 | bt_host_tick(mk_socket); |
|
193 | while( TRUE ) |
218 | usleep(loop_delay); |
194 | { |
219 | |
Line 195... | Line 220... | ||
195 | 220 | ||
196 | blink_evdev_led(); |
221 | |
197 | // bt_host_tick(mk_socket); |
222 | poll_evdev(); |
Line 198... | Line 223... | ||
198 | usleep(loop_delay); |
223 | |
199 | switch (input) |
224 | switch (input) |
200 | { |
- | |
- | 225 | { |
|
Line 201... | Line 226... | ||
201 | 226 | ||
Line 202... | Line 227... | ||
202 | 227 | ||
203 | case INPUT_NONE: |
228 | case INPUT_NONE: |
Line 295... | Line 320... | ||
295 | case STATEID_CONNECTING: |
320 | case STATEID_CONNECTING: |
Line 296... | Line 321... | ||
296 | 321 | ||
Line 297... | Line 322... | ||
297 | 322 | ||
298 | confirm_misses=0; |
323 | confirm_misses=0; |
299 | - | ||
300 | RxBuffer[1]=0; |
- | |
301 | if (connected) |
324 | |
302 | 325 | RxBuffer[2]=0; |
|
Line 303... | Line 326... | ||
303 | 326 | if (connected) |
|
304 | while (RxBuffer[1]!='t') |
327 | while (RxBuffer[2]!='B') |
305 | { |
328 | { |
306 | 329 | ||
Line 307... | Line 330... | ||
307 | RxBuffer[1]=0; |
330 | RxBuffer[1]=0; |
Line 308... | Line 331... | ||
308 | read_from_mk(); |
331 | read_from_mk(); |
309 | // bt_host_send(RxBuffer,rx_last_length); |
332 | bt_host_send(RxBuffer,rx_last_length); |
Line 310... | Line 333... | ||
310 | printf("sending to host: %s",PrintableRxBuffer); |
333 | printf("sending to host: %s",PrintableRxBuffer); |
Line 311... | Line 334... | ||
311 | 334 | ||
312 | 335 | ||
Line 348... | Line 371... | ||
348 | // act_nick=(evdev_rel_axis[rel_axis_nick]-128)*nick_mul; |
371 | // act_nick=(evdev_rel_axis[rel_axis_nick]-128)*nick_mul; |
Line -... | Line 372... | ||
- | 372 | ||
- | 373 | ||
- | 374 | ||
- | 375 | ||
- | 376 | /* Mix input values */ |
|
- | 377 | ||
- | 378 | act_gas=0; |
|
- | 379 | act_nick=0; |
|
- | 380 | act_roll=0; |
|
- | 381 | act_gier=0; |
|
- | 382 | ||
- | 383 | int act_input=0; |
|
- | 384 | for (act_input=0;act_input<input_count;act_input++) |
|
- | 385 | { |
|
- | 386 | //process buttons |
|
- | 387 | if (inputs[act_input].nick_up_btn!=-1) |
|
- | 388 | { |
|
- | 389 | if (inputs[act_input].evdev_button[inputs[act_input].nick_up_btn]!=0) |
|
- | 390 | act_nick=100; |
|
- | 391 | ||
- | 392 | } |
|
- | 393 | ||
- | 394 | if (inputs[act_input].nick_down_btn!=-1) |
|
- | 395 | { |
|
- | 396 | if (inputs[act_input].evdev_button[inputs[act_input].nick_down_btn]!=0) |
|
- | 397 | act_nick=-100; |
|
- | 398 | ||
- | 399 | } |
|
- | 400 | ||
- | 401 | if (inputs[act_input].roll_left_btn!=-1) |
|
- | 402 | { |
|
- | 403 | if (inputs[act_input].evdev_button[inputs[act_input].roll_left_btn]!=0) |
|
- | 404 | act_roll=100; |
|
- | 405 | ||
- | 406 | } |
|
- | 407 | ||
- | 408 | if (inputs[act_input].roll_right_btn!=-1) |
|
- | 409 | { |
|
- | 410 | if (inputs[act_input].evdev_button[inputs[act_input].roll_right_btn]!=0) |
|
- | 411 | act_roll=-100; |
|
- | 412 | ||
- | 413 | } |
|
- | 414 | ||
- | 415 | // process axis |
|
- | 416 | ||
- | 417 | if (inputs[act_input].rel_axis_nick!=-1) |
|
- | 418 | act_nick=inputs[act_input].evdev_rel_axis[inputs[act_input].rel_axis_nick]*inputs[act_input].nick_mul; |
|
- | 419 | ||
- | 420 | if (inputs[act_input].rel_axis_roll!=-1) |
|
- | 421 | act_roll=inputs[act_input].evdev_rel_axis[inputs[act_input].rel_axis_roll]*inputs[act_input].roll_mul; |
|
- | 422 | ||
- | 423 | ||
- | 424 | if (inputs[act_input].rel_axis_gier!=-1) |
|
- | 425 | act_gier=inputs[act_input].evdev_rel_axis[inputs[act_input].rel_axis_gier]*inputs[act_input].gier_mul; |
|
- | 426 | ||
- | 427 | ||
- | 428 | if (inputs[act_input].rel_axis_gas!=-1) |
|
- | 429 | act_gas=inputs[act_input].evdev_rel_axis[inputs[act_input].rel_axis_gas]*inputs[act_input].gas_mul; |
|
- | 430 | ||
349 | 431 | ||
350 | 432 | ||
351 | 433 | } |
|
352 | 434 | ||
353 | switch(input) |
435 | switch(input) |
354 | { |
436 | { |
355 | case INPUT_EVDEV: |
437 | case INPUT_EVDEV: |
356 | 438 | /* |
|
357 | act_nick=(evdev_rel_axis[rel_axis_nick]-nick_add)*nick_mul; |
439 | act_nick=(evdev_rel_axis[rel_axis_nick]-nick_add)*nick_mul; |
Line 358... | Line 440... | ||
358 | act_roll=(evdev_rel_axis[rel_axis_roll]-nick_add)*roll_mul; |
440 | act_roll=(evdev_rel_axis[rel_axis_roll]-nick_add)*roll_mul; |
Line 359... | Line 441... | ||
359 | act_gier=(evdev_rel_axis[rel_axis_gier]-nick_add)*gier_mul; |
441 | act_gier=(evdev_rel_axis[rel_axis_gier]-nick_add)*gier_mul; |
360 | act_gas=(evdev_rel_axis[rel_axis_gas]-nick_add)*gas_mul; |
442 | act_gas=(evdev_rel_axis[rel_axis_gas]-nick_add)*gas_mul; |
Line 426... | Line 508... | ||
426 | 508 | ||
427 | ExternControl.Nick=act_nick; //(axis[1]>>8)*(-1)/2; |
509 | ExternControl.Nick=act_nick; //(axis[1]>>8)*(-1)/2; |
428 | ExternControl.Roll=act_roll*(-1); //(axis[0]>>8)*(-1)/2; |
510 | ExternControl.Roll=act_roll*(-1); //(axis[0]>>8)*(-1)/2; |
429 | ExternControl.Gier=act_gier; // ************ |
511 | ExternControl.Gier=act_gier; // ************ |
- | 512 | ExternControl.Gas=act_gas; // ************ |
|
Line 430... | Line 513... | ||
430 | ExternControl.Gas=act_gas; // ************ |
513 | ExternControl.Gas=255; // ************ |