Subversion Repositories Projects

Rev

Rev 140 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 140 Rev 483
Line 1... Line 1...
1
#include "config.h"
1
#include "config.h"
Line -... Line 2...
-
 
2
 
2
 
3
 
3
 
4
 
Line 4... Line 5...
4
char *input_evdev_name;
5
char *input_evdev_name;
-
 
6
char *input_joydev_name;
Line 5... Line 7...
5
char *input_joydev_name;
7
 
6
 
8
char *bluetooth_mac;
Line 7... Line -...
7
char *bluetooth_mac;
-
 
8
 
-
 
9
int  mk_socket_port=0;
9
char *mk_tty;
10
int  loop_delay=0;
10
 
11
 
11
int  mk_socket_port=0;
12
 
12
int  loop_delay=0;
Line 20... Line 20...
20
double nick_add=0.3f;
20
double nick_add=0.3f;
21
double roll_add=0.3f;
21
double roll_add=0.3f;
22
double gier_add=0.3f;
22
double gier_add=0.3f;
23
double gas_add=0.3f;
23
double gas_add=0.3f;
Line 24... Line -...
24
 
-
 
25
 
24
 
26
int rel_axis_nick=1;
25
int rel_axis_nick;
27
int rel_axis_roll=0;
26
int rel_axis_roll;
28
int rel_axis_gier=5;
27
int rel_axis_gier;
29
int rel_axis_gas=2;
-
 
Line 30... Line 28...
30
 
28
int rel_axis_gas;
Line -... Line 29...
-
 
29
 
-
 
30
cfg_bool_t exit_after_init = cfg_false;
31
 
31
 
32
cfg_bool_t exit_after_init = cfg_false;
32
 
Line 33... Line 33...
33
 
33
int input_count=0;
-
 
34
 
-
 
35
int parse_config(char* fname)
-
 
36
{
-
 
37
 
-
 
38
 
-
 
39
  static cfg_opt_t input_opts[] = {
-
 
40
    CFG_STR("name", 0, CFGF_NONE),    
-
 
41
 
-
 
42
    CFG_FLOAT("nick_mul", 1.0,CFGF_NONE),
-
 
43
    CFG_FLOAT("roll_mul", 1.0,CFGF_NONE),
-
 
44
    CFG_FLOAT("gier_mul", 1.0,CFGF_NONE),
-
 
45
    CFG_FLOAT("gas_mul", 1.0,CFGF_NONE),
-
 
46
 
-
 
47
    CFG_FLOAT("nick_add", 0,CFGF_NONE),
-
 
48
    CFG_FLOAT("roll_add", 0,CFGF_NONE),
-
 
49
    CFG_FLOAT("gier_add", 0,CFGF_NONE),
-
 
50
    CFG_FLOAT("gas_add", 0,CFGF_NONE),
-
 
51
   
-
 
52
    CFG_INT("rel_axis_nick",  -1,CFGF_NONE),
-
 
53
    CFG_INT("rel_axis_roll",  -1,CFGF_NONE),
-
 
54
    CFG_INT("rel_axis_gier",  -1,CFGF_NONE),
-
 
55
    CFG_INT("rel_axis_gas", -1,CFGF_NONE),
-
 
56
 
-
 
57
    CFG_INT("nick_up_btn",  -1,CFGF_NONE),
-
 
58
    CFG_INT("nick_down_btn",  -1,CFGF_NONE),
Line -... Line 59...
-
 
59
    CFG_INT("roll_left_btn",  -1,CFGF_NONE),
-
 
60
    CFG_INT("roll_right_btn", -1,CFGF_NONE),
-
 
61
 
-
 
62
 
-
 
63
 
-
 
64
 
34
 
65
 
Line -... Line 66...
-
 
66
 
-
 
67
    CFG_END()
35
int parse_config(char* fname)
68
  };
36
{
69
 
37
 
70
  cfg_opt_t opts[] = {
38
 
71
    CFG_SEC("input", input_opts, CFGF_MULTI | CFGF_TITLE),
39
  cfg_opt_t opts[] = {
72
    CFG_SIMPLE_STR("bluetooth_mac", &bluetooth_mac),    
Line 59... Line 92...
59
    CFG_SIMPLE_INT("rel_axis_nick", &rel_axis_nick),
92
    CFG_SIMPLE_INT("rel_axis_nick", &rel_axis_nick),
60
    CFG_SIMPLE_INT("rel_axis_roll", &rel_axis_roll),
93
    CFG_SIMPLE_INT("rel_axis_roll", &rel_axis_roll),
61
    CFG_SIMPLE_INT("rel_axis_gier", &rel_axis_gier),
94
    CFG_SIMPLE_INT("rel_axis_gier", &rel_axis_gier),
62
    CFG_SIMPLE_INT("rel_axis_gas", &rel_axis_gas),
95
    CFG_SIMPLE_INT("rel_axis_gas", &rel_axis_gas),
Line 63... Line -...
63
 
-
 
64
 
-
 
65
 
-
 
66
   
96
   
67
    CFG_END()
97
    CFG_END()
Line 68... Line 98...
68
  };
98
  };
Line 75... Line 105...
75
  cfg = cfg_init(opts, 0);
105
  cfg = cfg_init(opts, 0);
Line 76... Line 106...
76
 
106
 
Line -... Line 107...
-
 
107
  cfg_parse(cfg,fname);
-
 
108
 
-
 
109
 
-
 
110
  input_count=cfg_size(cfg,"input");
-
 
111
 
-
 
112
  printf("%d inputs configured\n", input_count);
-
 
113
  int i;
-
 
114
  int act_input=0;
-
 
115
  for (i=0;i<input_count;i++)
-
 
116
    {
-
 
117
      cfg_t *input_sect=cfg_getnsec(cfg,"input",i);
-
 
118
 
-
 
119
 
-
 
120
      printf("processing input: %s\n",cfg_getstr( input_sect, "name"));
-
 
121
      int evdev_i=0;
-
 
122
     
-
 
123
      for (evdev_i=0;evdev_i<evdevs_count;evdev_i++)
-
 
124
        if (!strcmp(cfg_getstr( input_sect, "name"),evdevs[evdev_i].name))
-
 
125
          {
-
 
126
            sprintf( inputs[act_input].fname,"%s",evdevs[evdev_i].fname);
-
 
127
         
-
 
128
            // todo check lengt
-
 
129
            sprintf(inputs[act_input].name,"processing input: %s\n",cfg_getstr( input_sect, "name"));
-
 
130
           
-
 
131
            inputs[act_input].nick_mul=cfg_getfloat(input_sect,"nick_mul");
-
 
132
            inputs[act_input].roll_mul=cfg_getfloat(input_sect,"roll_mul");
-
 
133
            inputs[act_input].gier_mul=cfg_getfloat(input_sect,"gier_mul");
-
 
134
            inputs[act_input].gas_mul=cfg_getfloat(input_sect,"gas_mul");
-
 
135
           
-
 
136
            inputs[act_input].nick_add=cfg_getfloat(input_sect,"nick_add");
-
 
137
            inputs[act_input].roll_add=cfg_getfloat(input_sect,"roll_add");
-
 
138
            inputs[act_input].gier_add=cfg_getfloat(input_sect,"gier_add");
-
 
139
            inputs[act_input].gas_add=cfg_getfloat(input_sect,"gas_add");
-
 
140
 
-
 
141
 
-
 
142
            inputs[act_input].nick_up_btn=cfg_getint(input_sect,"nick_up_btn");
-
 
143
            inputs[act_input].nick_down_btn=cfg_getint(input_sect,"nick_down_btn");
-
 
144
 
-
 
145
            inputs[act_input].roll_left_btn=cfg_getint(input_sect,"roll_left_btn");        
-
 
146
            inputs[act_input].roll_right_btn=cfg_getint(input_sect,"roll_right_btn");
-
 
147
 
-
 
148
 
-
 
149
            inputs[act_input].rel_axis_nick=cfg_getint(input_sect,"rel_axis_nick");
-
 
150
            inputs[act_input].rel_axis_roll=cfg_getint(input_sect,"rel_axis_roll");
-
 
151
 
-
 
152
            inputs[act_input].rel_axis_gier=cfg_getint(input_sect,"rel_axis_gier");
-
 
153
            inputs[act_input].rel_axis_gas=cfg_getint(input_sect,"rel_axis_gas");
-
 
154
 
-
 
155
 
-
 
156
 
-
 
157
            act_input++;
-
 
158
          }
-
 
159
 
-
 
160
 
-
 
161
    }
77
  cfg_parse(cfg,fname);
162
 
78
 
163
  input_count=act_input;
-
 
164
  printf("%d inputs matching\n", input_count);
-
 
165
  return 0;