Rev 127 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 127 | Rev 130 | ||
---|---|---|---|
Line 9... | Line 9... | ||
9 | * |
9 | * |
10 | **************************************************/ |
10 | **************************************************/ |
Line 11... | Line 11... | ||
11 | 11 | ||
Line 12... | Line -... | ||
12 | #include "riddim.h" |
- | |
13 | - | ||
Line 14... | Line -... | ||
14 | #define FALSE 0 |
- | |
Line 15... | Line 12... | ||
15 | #define TRUE 1 |
12 | #include "riddim.h" |
Line 16... | Line -... | ||
16 | - | ||
17 | #define test_bit(bit, array) (array[bit/8] & (1<<(bit%8))) |
- | |
18 | - | ||
19 | int state=STATEID_SCANNING; |
- | |
Line 20... | Line -... | ||
20 | - | ||
21 | - | ||
22 | // from config |
- | |
23 | char *input_evdev_name; |
- | |
Line 24... | Line -... | ||
24 | int mk_socket_port=0; |
- | |
25 | int loop_delay=0; |
- | |
26 | - | ||
27 | - | ||
Line 28... | Line -... | ||
28 | - | ||
29 | double nick_mul=0.3f; |
- | |
30 | double roll_mul=0.3f; |
- | |
31 | double gier_mul=0.3f; |
- | |
32 | double gas_mul=0.3f; |
- | |
33 | - | ||
34 | - | ||
35 | int rel_axis_nick=1; |
- | |
36 | int rel_axis_roll=0; |
- | |
37 | int rel_axis_gier=5; |
- | |
38 | int rel_axis_gas=2; |
- | |
39 | - | ||
40 | - | ||
41 | cfg_bool_t exit_after_init = cfg_false; |
- | |
42 | - | ||
43 | // time struct for measuring |
13 | |
44 | struct timeval time_struct1; |
14 | |
Line 45... | Line 15... | ||
45 | struct timeval time_struct2; |
15 | |
Line 46... | Line 16... | ||
46 | 16 | int state=STATEID_SCANNING; |
|
47 | 17 | ||
Line 48... | Line -... | ||
48 | char RxBuffer[150]; |
- | |
49 | - | ||
50 | - | ||
51 | int status; |
- | |
52 | - | ||
53 | - | ||
54 | - | ||
55 | - | ||
56 | int x52_input_fd, *axis=NULL, num_of_axis=0, num_of_buttons=0, x; |
- | |
57 | char *button=NULL,*button_trigger=NULL, name_of_joystick[80]; |
- | |
58 | 18 | ||
59 | struct js_event x52_event_struct; |
- | |
60 | - | ||
61 | int engines_on=0; |
- | |
62 | int old_engines_on=0; |
- | |
63 | - | ||
64 | char in_char; |
- | |
65 | - | ||
66 | struct x52 *x52_output; |
- | |
67 | - | ||
68 | int selected_bt_device=0; |
- | |
69 | - | ||
70 | int yalv; /* loop counter */ |
- | |
71 | size_t read_bytes; /* how many bytes were read */ |
- | |
72 | struct input_event ev[64]; /* the events (up to 64 at once) */ |
- | |
73 | - | ||
74 | int evdev_fd; |
- | |
75 | int evdev_out_fd; |
- | |
76 | - | ||
77 | int evdev_rw=TRUE; |
- | |
78 | - | ||
79 | int connect_evdev() |
- | |
80 | { |
- | |
81 | - | ||
82 | struct input_devinfo { |
- | |
83 | uint16_t bustype; |
- | |
84 | uint16_t vendor; |
- | |
85 | uint16_t product; |
- | |
86 | uint16_t version; |
- | |
87 | }; |
- | |
88 | struct input_devinfo device_info; |
- | |
89 | - | ||
90 | if ((evdev_out_fd = open(input_evdev_name, O_WRONLY)) < 0) |
- | |
91 | { |
- | |
92 | printf(" cant open evdev read/write - trying readonly\n"); |
- | |
93 | evdev_rw=FALSE; |
- | |
94 | } |
- | |
95 | if ((evdev_fd = open(input_evdev_name, O_RDONLY)) < 0) |
- | |
96 | { |
- | |
97 | printf(" cant open evdev !"); |
- | |
98 | return 0; |
- | |
99 | } |
- | |
100 | - | ||
101 | ioctl(evdev_fd,EVIOCGID,&device_info); |
- | |
102 | - | ||
103 | printf("vendor 0x%04hx product 0x%04hx version 0x%04hx \n", |
- | |
104 | device_info.vendor, device_info.product, |
- | |
105 | device_info.version); |
- | |
106 | - | ||
107 | - | ||
108 | char name[256]= "Unknown"; |
- | |
109 | - | ||
110 | if(ioctl(evdev_fd, EVIOCGNAME(sizeof(name)), name) < 0) { |
- | |
111 | perror("evdev ioctl"); |
- | |
112 | } |
- | |
113 | - | ||
114 | printf("EVDEV reports name: %s\n", name); |
- | |
115 | - | ||
116 | /* this macro is used to tell if "bit" is set in "array" |
- | |
117 | * it selects a byte from the array, and does a boolean AND |
- | |
118 | * operation with a byte that only has the relevant bit set. |
- | |
119 | * eg. to check for the 12th bit, we do (array[1] & 1<<4) |
- | |
120 | */ |
- | |
121 | - | ||
122 | - | ||
123 | uint8_t evtype_bitmask[EV_MAX/8 + 1]; |
- | |
124 | - | ||
125 | if(ioctl(evdev_fd, EVIOCGBIT(0, sizeof(evtype_bitmask)), evtype_bitmask) < 0) |
- | |
126 | perror("evdev ioctl"); |
- | |
127 | - | ||
128 | printf("Supported event types:\n"); |
- | |
129 | for (yalv = 0; yalv < EV_MAX; yalv++) { |
- | |
130 | if (test_bit(yalv, evtype_bitmask)) { |
- | |
131 | /* this means that the bit is set in the event types list */ |
- | |
132 | printf(" Event type 0x%02x ", yalv); |
- | |
133 | switch ( yalv) |
- | |
134 | { |
- | |
135 | case EV_KEY : |
- | |
136 | printf(" (Keys or Buttons)\n"); |
- | |
137 | break; |
- | |
138 | case EV_ABS : |
- | |
139 | printf(" (Absolute Axes)\n"); |
- | |
140 | break; |
- | |
141 | case EV_LED : |
- | |
142 | printf(" (LEDs)\n"); |
- | |
143 | break; |
- | |
144 | case EV_REP : |
- | |
145 | printf(" (Repeat)\n"); |
- | |
146 | break; |
- | |
147 | case EV_SYN : |
- | |
148 | printf(" (Sync?)\n"); |
- | |
149 | break; |
- | |
150 | case EV_REL : |
- | |
151 | printf(" (Relative Axis)\n"); |
- | |
152 | break; |
- | |
153 | case EV_MSC : |
- | |
154 | printf(" (Misc)\n"); |
- | |
155 | break; |
- | |
156 | default: |
- | |
157 | printf(" (Unknown event type: 0x%04hx)\n", yalv); |
- | |
158 | }}} |
- | |
159 | - | ||
160 | return 1; |
- | |
161 | } |
- | |
162 | - | ||
163 | int connect_joy() |
- | |
164 | { |
19 | |
165 | - | ||
166 | axis = (int *) calloc( 100, sizeof( int ) ); |
- | |
167 | button = (char *)calloc( 100, sizeof( char ) ); |
- | |
168 | button_trigger = (char *) calloc( 100, sizeof( char ) ); |
- | |
169 | - | ||
170 | - | ||
171 | // axis = (int *) calloc( num_of_axis, sizeof( int ) ); |
- | |
172 | // button = (char *)calloc( num_of_buttons, sizeof( char ) ); |
- | |
173 | // button_trigger = (char *) calloc( num_of_buttons, sizeof( char ) ); |
- | |
174 | - | ||
175 | - | ||
176 | if( ( x52_input_fd = open( JOY_DEV, O_RDONLY ) ) < 0 ) |
- | |
177 | { |
- | |
178 | printf( "Couldn't open joystick device %s\n", JOY_DEV ); |
- | |
179 | printf( "try modprobe joydev\n" ); |
- | |
Line -... | Line 20... | ||
- | 20 | ||
Line -... | Line 21... | ||
- | 21 | ||
Line -... | Line 22... | ||
- | 22 | ||
- | 23 | ||
Line 180... | Line 24... | ||
180 | return 0; |
24 | |
181 | } |
25 | |
182 | 26 | int x52_input_fd, num_of_axis=0, num_of_buttons=0; |
|
Line 238... | Line 82... | ||
238 | for(i=0;i<bt_device_count;i++) |
82 | for(i=0;i<bt_device_count;i++) |
239 | printf("device%i->%s\n",i,names[i]); |
83 | printf("device%i->%s\n",i,names[i]); |
240 | } |
84 | } |
Line 241... | Line 85... | ||
241 | 85 | ||
242 | 86 | ||
243 | int r=0; |
87 | |
Line 244... | Line 88... | ||
244 | int count=0; |
88 | int count=0; |
Line 254... | Line 98... | ||
254 | printf("Starting Riddim \n"); |
98 | printf("Starting Riddim \n"); |
255 | printf("\tRemote Interactive Digital Drone Interface Mashup\n"); |
99 | printf("\tRemote Interactive Digital Drone Interface Mashup\n"); |
256 | printf("\nusage:\n"); |
100 | printf("\nusage:\n"); |
257 | printf("\t riddim [config_file]\n\n"); |
101 | printf("\t riddim [config_file]\n\n"); |
Line -... | Line 102... | ||
- | 102 | ||
Line 258... | Line -... | ||
258 | - | ||
259 | - | ||
260 | cfg_opt_t opts[] = { |
- | |
261 | - | ||
262 | CFG_SIMPLE_BOOL("exit_after_init", &exit_after_init), |
- | |
263 | CFG_SIMPLE_STR("input_evdev", &input_evdev_name), |
- | |
264 | CFG_SIMPLE_INT("loop_delay", &loop_delay), |
- | |
265 | CFG_SIMPLE_INT("mk_socket_port", &mk_socket_port), |
- | |
266 | - | ||
267 | CFG_SIMPLE_FLOAT("nick_mul", &nick_mul), |
- | |
268 | CFG_SIMPLE_FLOAT("roll_mul", &roll_mul), |
- | |
269 | CFG_SIMPLE_FLOAT("gier_mul", &gier_mul), |
- | |
270 | CFG_SIMPLE_FLOAT("gas_mul", &gas_mul), |
- | |
271 | - | ||
272 | CFG_SIMPLE_INT("rel_axis_nick", &rel_axis_nick), |
- | |
273 | CFG_SIMPLE_INT("rel_axis_roll", &rel_axis_roll), |
- | |
Line 274... | Line 103... | ||
274 | CFG_SIMPLE_INT("rel_axis_gier", &rel_axis_gier), |
103 | // bt_host_init(); |
- | 104 | ||
275 | CFG_SIMPLE_INT("rel_axis_gas", &rel_axis_gas), |
105 | |
276 | - | ||
277 | CFG_END() |
106 | if (argv[1]) |
Line 278... | Line -... | ||
278 | }; |
- | |
279 | - | ||
Line 280... | Line -... | ||
280 | cfg_t *cfg; |
- | |
Line 281... | Line -... | ||
281 | - | ||
282 | // input_evdev_name=strdup("/dev/event0"); |
- | |
283 | printf("Parsing config file "); |
- | |
284 | - | ||
285 | cfg = cfg_init(opts, 0); |
- | |
286 | - | ||
287 | if (argv[1]) |
- | |
288 | { |
- | |
289 | printf("%s\n ",argv[1]); |
- | |
290 | cfg_parse(cfg, argv[1]); |
- | |
291 | } |
107 | parse_config(argv[1]); |
- | 108 | else |
|
- | 109 | parse_config("/etc/riddim.conf"); |
|
- | 110 | ||
Line 292... | Line 111... | ||
292 | else |
111 | |
- | 112 | ||
- | 113 | printf("input %s:\n",input_evdev_name); |
|
- | 114 | /* |
|
293 | { |
115 | if (bluetooth_mac) |
294 | printf("/etc/riddim.conf\n"); |
116 | { |
295 | cfg_parse(cfg, "/etc/riddim.conf"); |
117 | |
296 | } |
118 | printf("Connecting via Bluetooth to %s\n",bluetooth_mac); |
Line 297... | Line 119... | ||
297 | printf("input %s:\n",input_evdev_name); |
119 | if (connect_mk_bluetooth(bluetooth_mac));; |
298 | 120 | connected=TRUE; |
|
299 | // 1st argument -> Bluetooth adrees to bypass scanning ( takes to long for short testing roundtrips ) |
121 | } |
300 | 122 | */ |
|
301 | if (mk_socket_port) |
123 | if (mk_socket_port) |
302 | { |
124 | { |
303 | printf("connecting to local port: %i\n",mk_socket_port); |
125 | printf("connecting to local port: %i\n",mk_socket_port); |
304 | 126 | ||
Line 305... | Line 127... | ||
305 | if (connect_mk_localhost_socket(mk_socket_port)==-1) |
127 | if (connect_mk_localhost_socket(mk_socket_port)==-1) |
- | 128 | printf("cant connect !!"); |
|
Line -... | Line 129... | ||
- | 129 | else |
|
306 | printf("cant connect !!"); |
130 | { |
307 | else |
131 | printf("connected !-)"); |
308 | { |
132 | connected=TRUE; |
309 | printf("connected to QC at adress: %s\n",argv[1]); |
133 | } |
310 | connected=TRUE; |
134 | } |
311 | } |
135 | |
312 | } |
136 | // todo reenable bluetooth connection |
313 | 137 | ||
- | 138 | ||
Line -... | Line 139... | ||
- | 139 | /* |
|
- | 140 | printf("\nInitializing X-52 input ..\n"); |
|
314 | int i; |
141 | if (connect_joy()) |
- | 142 | { |
|
315 | 143 | printf(".. done");// |
|
316 | printf("\nInitializing X-52 input ..\n"); |
144 | input=INPUT_JOYDEV; |
317 | if (connect_joy()) |
145 | } |
318 | { |
146 | else |
319 | printf(".. done");// |
147 | printf(".. ERROR ");// |
320 | input=INPUT_JOYDEV; |
148 | */ |
321 | } |
149 | |
- | 150 | if (input_evdev_name) |
|
Line 322... | Line 151... | ||
322 | else |
151 | { |
Line 323... | Line 152... | ||
323 | printf(".. ERROR ");// |
152 | printf("\nInitializing evdev input (%s) ..\n",input_evdev_name); |
Line 355... | Line 184... | ||
355 | printf(" %d Devices found \n",bt_device_count); |
184 | printf(" %d Devices found \n",bt_device_count); |
356 | print_device_list() ; |
185 | print_device_list() ; |
357 | } |
186 | } |
358 | */ |
187 | */ |
Line 359... | Line 188... | ||
359 | 188 | ||
360 | int v_old; |
189 | // int v_old; |
Line 361... | Line 190... | ||
361 | int polls=0; |
190 | int polls=0; |
362 | 191 | ||
363 | int retval; |
192 | |
364 | if (exit_after_init) |
193 | if (exit_after_init) |
Line 365... | Line -... | ||
365 | exit(0); |
- | |
366 | printf("starting loop ..\n"); |
- | |
- | 194 | exit(0); |
|
Line 367... | Line 195... | ||
367 | 195 | printf("starting loop ..\n"); |
|
368 | struct input_event led_event; |
- | |
369 | led_event.type=EV_LED; |
- | |
370 | - | ||
371 | int complete_misses=0; |
196 | |
372 | if (evdev_out_fd) |
- | |
373 | { |
197 | |
Line 374... | Line 198... | ||
374 | led_event.code = LED_MISC; |
198 | |
375 | led_event.value = 1; |
- | |
376 | retval = write(evdev_out_fd, &led_event, sizeof(struct input_event)); |
- | |
Line -... | Line 199... | ||
- | 199 | int complete_misses=0; |
|
- | 200 | int complete_matches=0; |
|
377 | } |
201 | |
- | 202 | ||
- | 203 | int confirm_misses; |
|
378 | 204 | ||
379 | int confirm_misses; |
- | |
380 | while( 1 ) |
- | |
381 | { |
- | |
382 | - | ||
383 | if (evdev_out_fd) |
- | |
384 | { |
- | |
Line -... | Line 205... | ||
- | 205 | ||
- | 206 | ||
385 | if (led_event.value) |
207 | init_evdevstatus_led(); |
386 | led_event.value = 0; |
208 | |
387 | else |
209 | while( TRUE ) |
Line 399... | Line 221... | ||
399 | break; |
221 | break; |
Line 400... | Line 222... | ||
400 | 222 | ||
401 | case INPUT_EVDEV: |
223 | case INPUT_EVDEV: |
Line 402... | Line -... | ||
402 | printf("input evdev\n"); |
- | |
403 | - | ||
404 | struct timeval tv; |
- | |
405 | int retval; |
- | |
406 | fd_set rfds; |
- | |
Line 407... | Line -... | ||
407 | FD_ZERO(&rfds); |
- | |
408 | FD_SET(evdev_fd,&rfds); |
- | |
409 | - | ||
410 | tv.tv_sec = 0; |
- | |
411 | tv.tv_usec = 5; |
- | |
412 | - | ||
413 | retval = select(evdev_fd+1, &rfds, NULL, NULL, &tv); |
- | |
414 | - | ||
415 | if (retval==-1) |
- | |
416 | printf("error in select!!!!!!!!\n"); |
- | |
417 | else if (retval) |
- | |
418 | { |
- | |
419 | read_bytes = read(evdev_fd, ev, sizeof(struct input_event) * 64); |
- | |
420 | 224 | printf("input evdev\n"); |
|
421 | if (read_bytes < (int) sizeof(struct input_event)) { |
- | |
422 | perror("evtest: short read"); |
- | |
423 | exit (1); |
- | |
424 | } |
- | |
425 | - | ||
426 | for (yalv = 0; yalv < (int) (read_bytes / sizeof(struct input_event)); yalv++) |
- | |
427 | { |
- | |
428 | - | ||
429 | printf("%d type:%d code:%d val:%d \n",yalv,ev[yalv].type,ev[yalv].code,ev[yalv].value); |
- | |
430 | if (ev[yalv].type==EV_REL) axis[ ev[yalv].code]= ev[yalv].value; |
- | |
431 | if (ev[yalv].type==EV_KEY) button[ ev[yalv].code-256]= ev[yalv].value; |
- | |
432 | } |
- | |
433 | - | ||
434 | - | ||
435 | for (yalv=0;yalv<10;yalv++) |
- | |
436 | printf("A%d %d -" , yalv, axis[yalv] ); |
- | |
437 | printf("\n"); |
- | |
438 | - | ||
439 | for (yalv=0;yalv<10;yalv++) |
- | |
440 | printf("B%d %d -" , yalv, button[yalv] ); |
- | |
441 | // printf("input read done: nick:%d roll:%d gier:%d gas:%d\n",axis[3] , axis[4] , axis[5] , axis[2]); |
- | |
Line 442... | Line 225... | ||
442 | } |
225 | |
Line 443... | Line 226... | ||
443 | else |
226 | |
444 | printf("no data from evdev data from evdev: \n"); |
227 | poll_evdev(); |
Line 463... | Line 246... | ||
463 | case JS_EVENT_BUTTON: |
246 | case JS_EVENT_BUTTON: |
464 | button [ x52_event_struct.number ] = x52_event_struct.value; |
247 | button [ x52_event_struct.number ] = x52_event_struct.value; |
465 | break; |
248 | break; |
466 | } |
249 | } |
467 | } |
250 | } |
468 | 251 | int x; |
|
469 | for( x=0 ; x<num_of_buttons ; ++x ) |
252 | for( x=0 ; x<num_of_buttons ; ++x ) |
470 | if( button[x]==0) |
253 | if( button[x]==0) |
471 | button_trigger[x]=0; |
254 | button_trigger[x]=0; |
472 | else |
255 | else |
473 | { |
256 | { |
Line 483... | Line 266... | ||
483 | 266 | ||
Line 484... | Line 267... | ||
484 | 267 | ||
485 | case STATEID_SCANNING: |
268 | case STATEID_SCANNING: |
486 | 269 | ||
487 | state=STATEID_CONNECTING; |
270 | state=STATEID_CONNECTING; |
488 | 271 | /* |
|
489 | ExternControl.Digital[0]=0; |
272 | ExternControl.Digital[0]=0; |
Line 524... | Line 307... | ||
524 | if (button_trigger[BUTTON_UP]==1) |
307 | if (button_trigger[BUTTON_UP]==1) |
525 | if (selected_bt_device<bt_device_count-1) selected_bt_device++; |
308 | if (selected_bt_device<bt_device_count-1) selected_bt_device++; |
Line 526... | Line 309... | ||
526 | 309 | |
|
- | 310 | ||
527 | 311 | } |
|
Line 528... | Line 312... | ||
528 | } |
312 | */ |
Line 529... | Line 313... | ||
529 | break; |
313 | break; |
530 | 314 | ||
- | 315 | case STATEID_CONNECTING: |
|
- | 316 | ||
- | 317 | ||
- | 318 | confirm_misses=0; |
|
531 | case STATEID_CONNECTING: |
319 | printf("connected:%d",connected); |
532 | 320 | RxBuffer[1]=0; |
|
Line 533... | Line 321... | ||
533 | 321 | if (connected) |
|
- | 322 | ||
- | 323 | ||
- | 324 | while (RxBuffer[1]!='t') |
|
Line 534... | Line 325... | ||
534 | confirm_misses=0; |
325 | { |
- | 326 | ||
535 | printf("connected:%d",connected); |
327 | RxBuffer[1]=0; |
536 | if (connected) while (RxBuffer[1]!='t') |
328 | read_from_mk(); |
Line 537... | Line 329... | ||
537 | { |
329 | // bt_host_send(RxBuffer,rx_last_length); |
538 | - | ||
Line 539... | Line -... | ||
539 | RxBuffer[1]=0; |
- | |
540 | - | ||
541 | - | ||
542 | // ftime(&time_struct); |
- | |
543 | printf("waiting for confirm frame ( misses:%d )\n",confirm_misses); |
- | |
544 | RxBuffer[2]=0; |
- | |
545 | - | ||
546 | - | ||
547 | - | ||
548 | r=0; |
- | |
549 | in_char='#'; |
- | |
550 | - | ||
551 | while(in_char!='\n') |
- | |
552 | { |
- | |
553 | count=read(mk_socket,&in_char,1); |
- | |
554 | if (in_char!=0) |
330 | printf("sending to host: %s",PrintableRxBuffer); |
- | 331 | ||
555 | { |
332 | |
556 | RxBuffer[r++]=in_char; |
333 | // ftime(&time_struct); |
557 | } |
334 | |
558 | else |
335 | printf("waiting for confirm frame ( confirmed:%d misses:%d )\n",complete_matches,complete_misses); |
559 | { |
336 | RxBuffer[2]=0; |
- | 337 | ||
- | 338 | ||
560 | RxBuffer[r++]='0'; |
339 | |
561 | } |
340 | // r=0; |
562 | // printf("\ncount:%d r:%d %d %c \n",count , r, in_char, in_char); |
341 | |
563 | } |
342 | // new |
564 | RxBuffer[r++]='\0'; |
343 | /* |
565 | printf("%d--->%s\n",complete_misses,RxBuffer); |
344 | if (button_trigger[12]>1) |
566 | // new |
345 | { |
567 | if (button_trigger[12]>1) |
346 | SendOutData('s', 0, (unsigned char *)&ExternControl, sizeof(ExternControl)); |
568 | { |
347 | button_trigger[12]=0; |
- | 348 | } |
|
569 | SendOutData('s', 0, (unsigned char *)&ExternControl, sizeof(ExternControl)); |
349 | */ |
Line 570... | Line 350... | ||
570 | button_trigger[12]=0; |
350 | ExternControl.Frame='t'; |
571 | } |
351 | if (++confirm_misses>4) |
Line 572... | Line 352... | ||
572 | if (++confirm_misses>4) |
352 | { |
Line 573... | Line 353... | ||
573 | { |
353 | complete_misses++; |
574 | complete_misses++; |
354 | printf("sending again\n"); |
575 | printf("sending again\n"); |
355 | SendOutData('b', 0, (unsigned char *)&ExternControl, sizeof(ExternControl)); |
576 | SendOutData('b', 0, (unsigned char *)&ExternControl, sizeof(ExternControl)); |
356 | } |
577 | } |
357 | } |
Line 578... | Line 358... | ||
578 | } |
358 | else |
579 | else |
359 | printf("not connected to mk\n"); |
Line 633... | Line 413... | ||
633 | } |
413 | } |
634 | */ |
414 | */ |
635 | ExternControl.Digital[0]=0; |
415 | ExternControl.Digital[0]=0; |
636 | ExternControl.Digital[1]=0; |
416 | ExternControl.Digital[1]=0; |
637 | ExternControl.RemoteTasten=0; |
417 | ExternControl.RemoteTasten=0; |
638 | ExternControl.Nick=act_nick; //(axis[1]>>8)*(-1)/2; |
- | |
639 | // printf("nick%d\n",ExternControl.Nick); |
- | |
640 | ExternControl.Roll=act_roll*(-1); //(axis[0]>>8)*(-1)/2; |
- | |
641 | ExternControl.Gier=(axis[5]>>8); |
- | |
642 | ExternControl.Gier=act_gier; // ************ |
- | |
643 | ExternControl.Gas=(axis[2]>>8)*(-1)+127; |
- | |
644 | ExternControl.Gas=act_gas; // ************ |
- | |
645 | // ExternControl.Gas=0; // ************ |
- | |
646 | ExternControl.Higt=0; |
418 | ExternControl.Higt=0; |
647 | ExternControl.free=0; |
419 | ExternControl.free=0; |
648 | ExternControl.Frame='t'; |
420 | ExternControl.Frame='t'; |
649 | - | ||
650 | ExternControl.Config=1; |
421 | ExternControl.Config=1; |
651 | printf("---+++act_mode %d , act_nick %d , act_roll %d , act_gier %d , act_gas %d",act_mode , act_nick , act_roll , act_gier , act_gas); |
- | |
Line -... | Line 422... | ||
- | 422 | ||
- | 423 | ||
- | 424 | ExternControl.Nick=act_nick; //(axis[1]>>8)*(-1)/2; |
|
- | 425 | ExternControl.Roll=act_roll*(-1); //(axis[0]>>8)*(-1)/2; |
|
- | 426 | ExternControl.Gier=act_gier; // ************ |
|
- | 427 | ExternControl.Gas=act_gas; // ************ |
|
- | 428 | ||
- | 429 | complete_matches++; |
|
Line 652... | Line 430... | ||
652 | 430 | ||
653 | 431 | printf("---+++act_mode %d , act_nick %d , act_roll %d , act_gier %d , act_gas %d",act_mode , act_nick , act_roll , act_gier , act_gas); |
|
654 | 432 | ||
Line 663... | Line 441... | ||
663 | 441 | ||
664 | // printf("sleeping\n"); |
442 | // printf("sleeping\n"); |
665 | // for (polls=0;polls<100;polls++) // FIXME - better Polling |
443 | // for (polls=0;polls<100;polls++) // FIXME - better Polling |
Line 666... | Line 444... | ||
666 | // printf("end_sleep\n"); |
444 | // printf("end_sleep\n"); |
667 | 445 | ||
668 | int v=axis[6]/655+50; |
446 | // int v=axis[6]/655+50; |
Line 669... | Line 447... | ||
669 | if (v!=v_old)if (x52_output) x52_setbri(x52_output, 0,v ); |
447 | // if (v!=v_old)if (x52_output) x52_setbri(x52_output, 0,v ); |
Line -... | Line 448... | ||
- | 448 | // v_old=v; |
|
670 | v_old=v; |
449 | |
671 | 450 | // printf("v: %d \n",v); |
|
Line 672... | Line 451... | ||
672 | printf("v: %d \n",v); |
451 | |
Line 673... | Line 452... | ||
673 | 452 | ||
- | 453 | /* |
|
Line 674... | Line 454... | ||
674 | 454 | for (i=0;i<num_of_axis;i++) |
|
675 | for (i=0;i<num_of_axis;i++) |
455 | printf("A%d: %d ", i,axis[i]>>8 ); |
Line 676... | Line 456... | ||
676 | printf("A%d: %d ", i,axis[i]>>8 ); |
456 | |
677 | 457 | for( x=0 ; x<num_of_buttons ; ++x ) |
|
678 | for( x=0 ; x<num_of_buttons ; ++x ) |
458 | |
Line 679... | Line 459... | ||
679 | 459 | printf("B%d: %d ", x, button[x] ); |
|
Line 680... | Line 460... | ||
680 | printf("B%d: %d ", x, button[x] ); |
460 | */ |