Subversion Repositories Projects

Compare Revisions

Ignore whitespace Rev 140 → Rev 139

/Riddim/riddim.c
12,9 → 12,20
#include "riddim.h"
 
 
 
int state=STATEID_SCANNING;
 
 
 
 
 
 
 
 
 
int x52_input_fd, num_of_axis=0, num_of_buttons=0;
char *button_trigger=NULL, name_of_joystick[80];
 
struct js_event x52_event_struct;
 
int engines_on=0;
23,10 → 34,16
int *axis;
char *button;
 
 
 
struct x52 *x52_output;
 
int selected_bt_device=0;
 
//int evdev_fd;
//int evdev_out_fd;
 
 
void write_display(int line,char* text)
{
if (x52_output) x52_settext(x52_output, line , text, strlen(text));
118,8 → 135,20
 
// todo reenable bluetooth connection
 
if ((input_evdev_name))
/*
printf("\nInitializing X-52 input ..\n");
if (connect_joy())
{
printf(".. done");//
input=INPUT_JOYDEV;
}
else
printf(".. ERROR ");//
*/
 
if (input_evdev_name)
{
printf("\nInitializing evdev input (%s) ..\n",input_evdev_name);
if (connect_evdev(input_evdev_name))
131,19 → 160,6
printf(".. ERROR ");//
}
 
if (input_joydev_name)
{
printf("\nInitializing joystick input from %s ..\n",input_joydev_name);
if (connect_joy())
{
printf(".. done");//
input=INPUT_JOYDEV;
}
else
printf(".. ERROR ");//
}
 
 
printf("\nInitializing X-52 output ..");
 
x52_output = x52_init();
201,22 → 217,24
 
case INPUT_NONE:
printf("processing input none\n");
printf("starting input none\n");
break;
 
case INPUT_EVDEV:
printf("processing input evdev\n");
printf("input evdev\n");
 
poll_evdev();
break;
 
case INPUT_JOYDEV:
printf("processing input joydev\n");
printf("input joydev\n");
// poll values from input device
for (polls=0;polls<100;polls++) // FIXME - better Polling
{
read(joy_input_fd, &x52_event_struct, sizeof(struct js_event));
read(x52_input_fd, &x52_event_struct, sizeof(struct js_event));
/* see what to do with the event */
239,12 → 257,14
if (button_trigger[x]<100)button_trigger[x]++;
}
break;
} // switch (input)
}
 
printf("input done\n");
switch(state)
{
 
case STATEID_SCANNING:
state=STATEID_CONNECTING;
296,8 → 316,8
 
confirm_misses=0;
 
RxBuffer[1]=0;
printf("connected:%d",connected);
RxBuffer[1]=0;
if (connected)
 
 
315,6 → 335,8
printf("waiting for confirm frame ( confirmed:%d misses:%d )\n",complete_matches,complete_misses);
RxBuffer[2]=0;
 
 
 
// r=0;
 
// new
338,7 → 360,7
 
gettimeofday(&time_struct2,NULL);
 
printf("last trip: %d\n",(int)(time_struct2.tv_usec-time_struct1.tv_usec));
printf("last trip: %d",(int)(time_struct1.tv_usec-time_struct2.tv_usec));
// act_mode=button[24] | (button[25]<<1);
 
 
345,38 → 367,13
 
// Step converting axis data to nick/roll/gier/gas/..
 
// act_nick=(evdev_rel_axis[rel_axis_nick]-128)*nick_mul;
act_nick=evdev_rel_axis[rel_axis_nick]*nick_mul;
act_roll=evdev_rel_axis[rel_axis_roll]*roll_mul;
act_gier=evdev_rel_axis[rel_axis_gier]*gier_mul;
act_gas=evdev_rel_axis[rel_axis_gas]*gas_mul;
act_gas=255;
 
 
 
 
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;
 
case INPUT_JOYDEV:
act_nick=(axis[rel_axis_nick])*nick_mul;
act_roll=(axis[rel_axis_roll])*roll_mul;
act_gier=(axis[rel_axis_gier])*gier_mul;
act_gas=(axis[rel_axis_gas]*-1+33000)*gas_mul;
break;
}
 
// act values clipping to usefull vals
// act_gas=0;
 
// act_gas=255;
 
 
/*
switch (act_mode)
{
429,13 → 426,12
ExternControl.Gier=act_gier; // ************
ExternControl.Gas=act_gas; // ************
complete_matches++;
 
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);
 
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);
 
if (connected)
{
complete_matches++;
printf("sending data\n");
SendOutData('b', 0, (unsigned char *)&ExternControl, sizeof(ExternControl));
469,13 → 465,12
printf("\n");
fflush(stdout);
printf("loop fin ( confirmed:%d misses:%d | debug_sets:%d )\n",complete_matches,complete_misses,debug_sets);
printf("------------------------------------------------------------------------\n");
}
 
 
/******************** Cleanup **********************/
close(joy_input_fd);
close(x52_input_fd);
close(mk_socket);
 
if (x52_output) x52_close(x52_output);