pcsxr-1.9.92
[pcsx_rearmed.git] / plugins / dfinput / cfg.c
1 /*
2  * Copyright (c) 2009, Wei Mingzhi <whistler@openoffice.org>.
3  * All Rights Reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, see <http://www.gnu.org/licenses>.
17  */
18
19 #include "pad.h"
20
21 #define CONFIG_FILE             "dfinput.cfg"
22
23 GLOBALDATA                      g;
24
25 static void SetDefaultConfig() {
26         memset(&g.cfg, 0, sizeof(g.cfg));
27
28         g.cfg.Threaded = 1;
29
30         g.cfg.PadDef[0].DevNum = 0;
31         g.cfg.PadDef[1].DevNum = 1;
32
33         g.cfg.PadDef[0].Type = PSE_PAD_TYPE_STANDARD;
34         g.cfg.PadDef[1].Type = PSE_PAD_TYPE_STANDARD;
35
36         // Pad1 keyboard
37         g.cfg.PadDef[0].KeyDef[DKEY_SELECT].Key = XK_c;
38         g.cfg.PadDef[0].KeyDef[DKEY_START].Key = XK_v;
39         g.cfg.PadDef[0].KeyDef[DKEY_UP].Key = XK_Up;
40         g.cfg.PadDef[0].KeyDef[DKEY_RIGHT].Key = XK_Right;
41         g.cfg.PadDef[0].KeyDef[DKEY_DOWN].Key = XK_Down;
42         g.cfg.PadDef[0].KeyDef[DKEY_LEFT].Key = XK_Left;
43         g.cfg.PadDef[0].KeyDef[DKEY_L2].Key = XK_e;
44         g.cfg.PadDef[0].KeyDef[DKEY_R2].Key = XK_t;
45         g.cfg.PadDef[0].KeyDef[DKEY_L1].Key = XK_w;
46         g.cfg.PadDef[0].KeyDef[DKEY_R1].Key = XK_r;
47         g.cfg.PadDef[0].KeyDef[DKEY_TRIANGLE].Key = XK_d;
48         g.cfg.PadDef[0].KeyDef[DKEY_CIRCLE].Key = XK_x;
49         g.cfg.PadDef[0].KeyDef[DKEY_CROSS].Key = XK_z;
50         g.cfg.PadDef[0].KeyDef[DKEY_SQUARE].Key = XK_s;
51
52         // Pad1 joystick
53         g.cfg.PadDef[0].KeyDef[DKEY_SELECT].JoyEvType = BUTTON;
54         g.cfg.PadDef[0].KeyDef[DKEY_SELECT].J.Button = 8;
55         g.cfg.PadDef[0].KeyDef[DKEY_START].JoyEvType = BUTTON;
56         g.cfg.PadDef[0].KeyDef[DKEY_START].J.Button = 9;
57         g.cfg.PadDef[0].KeyDef[DKEY_UP].JoyEvType = AXIS;
58         g.cfg.PadDef[0].KeyDef[DKEY_UP].J.Axis = -2;
59         g.cfg.PadDef[0].KeyDef[DKEY_RIGHT].JoyEvType = AXIS;
60         g.cfg.PadDef[0].KeyDef[DKEY_RIGHT].J.Axis = 1;
61         g.cfg.PadDef[0].KeyDef[DKEY_DOWN].JoyEvType = AXIS;
62         g.cfg.PadDef[0].KeyDef[DKEY_DOWN].J.Axis = 2;
63         g.cfg.PadDef[0].KeyDef[DKEY_LEFT].JoyEvType = AXIS;
64         g.cfg.PadDef[0].KeyDef[DKEY_LEFT].J.Axis = -1;
65         g.cfg.PadDef[0].KeyDef[DKEY_L2].JoyEvType = BUTTON;
66         g.cfg.PadDef[0].KeyDef[DKEY_L2].J.Button = 4;
67         g.cfg.PadDef[0].KeyDef[DKEY_L1].JoyEvType = BUTTON;
68         g.cfg.PadDef[0].KeyDef[DKEY_L1].J.Button = 6;
69         g.cfg.PadDef[0].KeyDef[DKEY_R2].JoyEvType = BUTTON;
70         g.cfg.PadDef[0].KeyDef[DKEY_R2].J.Button = 5;
71         g.cfg.PadDef[0].KeyDef[DKEY_R1].JoyEvType = BUTTON;
72         g.cfg.PadDef[0].KeyDef[DKEY_R1].J.Button = 7;
73         g.cfg.PadDef[0].KeyDef[DKEY_TRIANGLE].JoyEvType = BUTTON;
74         g.cfg.PadDef[0].KeyDef[DKEY_TRIANGLE].J.Button = 0;
75         g.cfg.PadDef[0].KeyDef[DKEY_CIRCLE].JoyEvType = BUTTON;
76         g.cfg.PadDef[0].KeyDef[DKEY_CIRCLE].J.Button = 1;
77         g.cfg.PadDef[0].KeyDef[DKEY_CROSS].JoyEvType = BUTTON;
78         g.cfg.PadDef[0].KeyDef[DKEY_CROSS].J.Button = 2;
79         g.cfg.PadDef[0].KeyDef[DKEY_SQUARE].JoyEvType = BUTTON;
80         g.cfg.PadDef[0].KeyDef[DKEY_SQUARE].J.Button = 3;
81
82         // Pad2 joystick
83         g.cfg.PadDef[1].KeyDef[DKEY_SELECT].JoyEvType = BUTTON;
84         g.cfg.PadDef[1].KeyDef[DKEY_SELECT].J.Button = 8;
85         g.cfg.PadDef[1].KeyDef[DKEY_START].JoyEvType = BUTTON;
86         g.cfg.PadDef[1].KeyDef[DKEY_START].J.Button = 9;
87         g.cfg.PadDef[1].KeyDef[DKEY_UP].JoyEvType = AXIS;
88         g.cfg.PadDef[1].KeyDef[DKEY_UP].J.Axis = -2;
89         g.cfg.PadDef[1].KeyDef[DKEY_RIGHT].JoyEvType = AXIS;
90         g.cfg.PadDef[1].KeyDef[DKEY_RIGHT].J.Axis = 1;
91         g.cfg.PadDef[1].KeyDef[DKEY_DOWN].JoyEvType = AXIS;
92         g.cfg.PadDef[1].KeyDef[DKEY_DOWN].J.Axis = 2;
93         g.cfg.PadDef[1].KeyDef[DKEY_LEFT].JoyEvType = AXIS;
94         g.cfg.PadDef[1].KeyDef[DKEY_LEFT].J.Axis = -1;
95         g.cfg.PadDef[1].KeyDef[DKEY_L2].JoyEvType = BUTTON;
96         g.cfg.PadDef[1].KeyDef[DKEY_L2].J.Button = 4;
97         g.cfg.PadDef[1].KeyDef[DKEY_L1].JoyEvType = BUTTON;
98         g.cfg.PadDef[1].KeyDef[DKEY_L1].J.Button = 6;
99         g.cfg.PadDef[1].KeyDef[DKEY_R2].JoyEvType = BUTTON;
100         g.cfg.PadDef[1].KeyDef[DKEY_R2].J.Button = 5;
101         g.cfg.PadDef[1].KeyDef[DKEY_R1].JoyEvType = BUTTON;
102         g.cfg.PadDef[1].KeyDef[DKEY_R1].J.Button = 7;
103         g.cfg.PadDef[1].KeyDef[DKEY_TRIANGLE].JoyEvType = BUTTON;
104         g.cfg.PadDef[1].KeyDef[DKEY_TRIANGLE].J.Button = 0;
105         g.cfg.PadDef[1].KeyDef[DKEY_CIRCLE].JoyEvType = BUTTON;
106         g.cfg.PadDef[1].KeyDef[DKEY_CIRCLE].J.Button = 1;
107         g.cfg.PadDef[1].KeyDef[DKEY_CROSS].JoyEvType = BUTTON;
108         g.cfg.PadDef[1].KeyDef[DKEY_CROSS].J.Button = 2;
109         g.cfg.PadDef[1].KeyDef[DKEY_SQUARE].JoyEvType = BUTTON;
110         g.cfg.PadDef[1].KeyDef[DKEY_SQUARE].J.Button = 3;
111 }
112
113 void LoadPADConfig() {
114         FILE            *fp;
115         char            buf[256];
116         int                     current, a, b, c;
117
118         SetDefaultConfig();
119
120         fp = fopen(CONFIG_FILE, "r");
121         if (fp == NULL) {
122                 return;
123         }
124
125         current = 0;
126
127         while (fgets(buf, 256, fp) != NULL) {
128                 if (strncmp(buf, "Threaded=", 9) == 0) {
129                         g.cfg.Threaded = atoi(&buf[9]);
130                 } else if (strncmp(buf, "[PAD", 4) == 0) {
131                         current = atoi(&buf[4]) - 1;
132                         if (current < 0) {
133                                 current = 0;
134                         } else if (current > 1) {
135                                 current = 1;
136                         }
137                 } else if (strncmp(buf, "DevNum=", 7) == 0) {
138                         g.cfg.PadDef[current].DevNum = atoi(&buf[7]);
139                 } else if (strncmp(buf, "Type=", 5) == 0) {
140                         g.cfg.PadDef[current].Type = atoi(&buf[5]);
141                 } else if (strncmp(buf, "Select=", 7) == 0) {
142                         sscanf(buf, "Select=%d,%d,%d", &a, &b, &c);
143                         g.cfg.PadDef[current].KeyDef[DKEY_SELECT].Key = a;
144                         g.cfg.PadDef[current].KeyDef[DKEY_SELECT].JoyEvType = b;
145                         g.cfg.PadDef[current].KeyDef[DKEY_SELECT].J.d = c;
146                 } else if (strncmp(buf, "L3=", 3) == 0) {
147                         sscanf(buf, "L3=%d,%d,%d", &a, &b, &c);
148                         g.cfg.PadDef[current].KeyDef[DKEY_L3].Key = a;
149                         g.cfg.PadDef[current].KeyDef[DKEY_L3].JoyEvType = b;
150                         g.cfg.PadDef[current].KeyDef[DKEY_L3].J.d = c;
151                 } else if (strncmp(buf, "R3=", 3) == 0) {
152                         sscanf(buf, "R3=%d,%d,%d", &a, &b, &c);
153                         g.cfg.PadDef[current].KeyDef[DKEY_R3].Key = a;
154                         g.cfg.PadDef[current].KeyDef[DKEY_R3].JoyEvType = b;
155                         g.cfg.PadDef[current].KeyDef[DKEY_R3].J.d = c;
156                 } else if (strncmp(buf, "Start=", 6) == 0) {
157                         sscanf(buf, "Start=%d,%d,%d", &a, &b, &c);
158                         g.cfg.PadDef[current].KeyDef[DKEY_START].Key = a;
159                         g.cfg.PadDef[current].KeyDef[DKEY_START].JoyEvType = b;
160                         g.cfg.PadDef[current].KeyDef[DKEY_START].J.d = c;
161                 } else if (strncmp(buf, "Up=", 3) == 0) {
162                         sscanf(buf, "Up=%d,%d,%d", &a, &b, &c);
163                         g.cfg.PadDef[current].KeyDef[DKEY_UP].Key = a;
164                         g.cfg.PadDef[current].KeyDef[DKEY_UP].JoyEvType = b;
165                         g.cfg.PadDef[current].KeyDef[DKEY_UP].J.d = c;
166                 } else if (strncmp(buf, "Right=", 6) == 0) {
167                         sscanf(buf, "Right=%d,%d,%d", &a, &b, &c);
168                         g.cfg.PadDef[current].KeyDef[DKEY_RIGHT].Key = a;
169                         g.cfg.PadDef[current].KeyDef[DKEY_RIGHT].JoyEvType = b;
170                         g.cfg.PadDef[current].KeyDef[DKEY_RIGHT].J.d = c;
171                 } else if (strncmp(buf, "Down=", 5) == 0) {
172                         sscanf(buf, "Down=%d,%d,%d", &a, &b, &c);
173                         g.cfg.PadDef[current].KeyDef[DKEY_DOWN].Key = a;
174                         g.cfg.PadDef[current].KeyDef[DKEY_DOWN].JoyEvType = b;
175                         g.cfg.PadDef[current].KeyDef[DKEY_DOWN].J.d = c;
176                 } else if (strncmp(buf, "Left=", 5) == 0) {
177                         sscanf(buf, "Left=%d,%d,%d", &a, &b, &c);
178                         g.cfg.PadDef[current].KeyDef[DKEY_LEFT].Key = a;
179                         g.cfg.PadDef[current].KeyDef[DKEY_LEFT].JoyEvType = b;
180                         g.cfg.PadDef[current].KeyDef[DKEY_LEFT].J.d = c;
181                 } else if (strncmp(buf, "L2=", 3) == 0) {
182                         sscanf(buf, "L2=%d,%d,%d", &a, &b, &c);
183                         g.cfg.PadDef[current].KeyDef[DKEY_L2].Key = a;
184                         g.cfg.PadDef[current].KeyDef[DKEY_L2].JoyEvType = b;
185                         g.cfg.PadDef[current].KeyDef[DKEY_L2].J.d = c;
186                 } else if (strncmp(buf, "R2=", 3) == 0) {
187                         sscanf(buf, "R2=%d,%d,%d", &a, &b, &c);
188                         g.cfg.PadDef[current].KeyDef[DKEY_R2].Key = a;
189                         g.cfg.PadDef[current].KeyDef[DKEY_R2].JoyEvType = b;
190                         g.cfg.PadDef[current].KeyDef[DKEY_R2].J.d = c;
191                 } else if (strncmp(buf, "L1=", 3) == 0) {
192                         sscanf(buf, "L1=%d,%d,%d", &a, &b, &c);
193                         g.cfg.PadDef[current].KeyDef[DKEY_L1].Key = a;
194                         g.cfg.PadDef[current].KeyDef[DKEY_L1].JoyEvType = b;
195                         g.cfg.PadDef[current].KeyDef[DKEY_L1].J.d = c;
196                 } else if (strncmp(buf, "R1=", 3) == 0) {
197                         sscanf(buf, "R1=%d,%d,%d", &a, &b, &c);
198                         g.cfg.PadDef[current].KeyDef[DKEY_R1].Key = a;
199                         g.cfg.PadDef[current].KeyDef[DKEY_R1].JoyEvType = b;
200                         g.cfg.PadDef[current].KeyDef[DKEY_R1].J.d = c;
201                 } else if (strncmp(buf, "Triangle=", 9) == 0) {
202                         sscanf(buf, "Triangle=%d,%d,%d", &a, &b, &c);
203                         g.cfg.PadDef[current].KeyDef[DKEY_TRIANGLE].Key = a;
204                         g.cfg.PadDef[current].KeyDef[DKEY_TRIANGLE].JoyEvType = b;
205                         g.cfg.PadDef[current].KeyDef[DKEY_TRIANGLE].J.d = c;
206                 } else if (strncmp(buf, "Circle=", 7) == 0) {
207                         sscanf(buf, "Circle=%d,%d,%d", &a, &b, &c);
208                         g.cfg.PadDef[current].KeyDef[DKEY_CIRCLE].Key = a;
209                         g.cfg.PadDef[current].KeyDef[DKEY_CIRCLE].JoyEvType = b;
210                         g.cfg.PadDef[current].KeyDef[DKEY_CIRCLE].J.d = c;
211                 } else if (strncmp(buf, "Cross=", 6) == 0) {
212                         sscanf(buf, "Cross=%d,%d,%d", &a, &b, &c);
213                         g.cfg.PadDef[current].KeyDef[DKEY_CROSS].Key = a;
214                         g.cfg.PadDef[current].KeyDef[DKEY_CROSS].JoyEvType = b;
215                         g.cfg.PadDef[current].KeyDef[DKEY_CROSS].J.d = c;
216                 } else if (strncmp(buf, "Square=", 7) == 0) {
217                         sscanf(buf, "Square=%d,%d,%d", &a, &b, &c);
218                         g.cfg.PadDef[current].KeyDef[DKEY_SQUARE].Key = a;
219                         g.cfg.PadDef[current].KeyDef[DKEY_SQUARE].JoyEvType = b;
220                         g.cfg.PadDef[current].KeyDef[DKEY_SQUARE].J.d = c;
221                 } else if (strncmp(buf, "LeftAnalogXP=", 13) == 0) {
222                         sscanf(buf, "LeftAnalogXP=%d,%d,%d", &a, &b, &c);
223                         g.cfg.PadDef[current].AnalogDef[ANALOG_LEFT][ANALOG_XP].Key = a;
224                         g.cfg.PadDef[current].AnalogDef[ANALOG_LEFT][ANALOG_XP].JoyEvType = b;
225                         g.cfg.PadDef[current].AnalogDef[ANALOG_LEFT][ANALOG_XP].J.d = c;
226                 } else if (strncmp(buf, "LeftAnalogXM=", 13) == 0) {
227                         sscanf(buf, "LeftAnalogXM=%d,%d,%d", &a, &b, &c);
228                         g.cfg.PadDef[current].AnalogDef[ANALOG_LEFT][ANALOG_XM].Key = a;
229                         g.cfg.PadDef[current].AnalogDef[ANALOG_LEFT][ANALOG_XM].JoyEvType = b;
230                         g.cfg.PadDef[current].AnalogDef[ANALOG_LEFT][ANALOG_XM].J.d = c;
231                 } else if (strncmp(buf, "LeftAnalogYP=", 13) == 0) {
232                         sscanf(buf, "LeftAnalogYP=%d,%d,%d", &a, &b, &c);
233                         g.cfg.PadDef[current].AnalogDef[ANALOG_LEFT][ANALOG_YP].Key = a;
234                         g.cfg.PadDef[current].AnalogDef[ANALOG_LEFT][ANALOG_YP].JoyEvType = b;
235                         g.cfg.PadDef[current].AnalogDef[ANALOG_LEFT][ANALOG_YP].J.d = c;
236                 } else if (strncmp(buf, "LeftAnalogYM=", 13) == 0) {
237                         sscanf(buf, "LeftAnalogYM=%d,%d,%d", &a, &b, &c);
238                         g.cfg.PadDef[current].AnalogDef[ANALOG_LEFT][ANALOG_YM].Key = a;
239                         g.cfg.PadDef[current].AnalogDef[ANALOG_LEFT][ANALOG_YM].JoyEvType = b;
240                         g.cfg.PadDef[current].AnalogDef[ANALOG_LEFT][ANALOG_YM].J.d = c;
241                 } else if (strncmp(buf, "RightAnalogXP=", 14) == 0) {
242                         sscanf(buf, "RightAnalogXP=%d,%d,%d", &a, &b, &c);
243                         g.cfg.PadDef[current].AnalogDef[ANALOG_RIGHT][ANALOG_XP].Key = a;
244                         g.cfg.PadDef[current].AnalogDef[ANALOG_RIGHT][ANALOG_XP].JoyEvType = b;
245                         g.cfg.PadDef[current].AnalogDef[ANALOG_RIGHT][ANALOG_XP].J.d = c;
246                 } else if (strncmp(buf, "RightAnalogXM=", 14) == 0) {
247                         sscanf(buf, "RightAnalogXM=%d,%d,%d", &a, &b, &c);
248                         g.cfg.PadDef[current].AnalogDef[ANALOG_RIGHT][ANALOG_XM].Key = a;
249                         g.cfg.PadDef[current].AnalogDef[ANALOG_RIGHT][ANALOG_XM].JoyEvType = b;
250                         g.cfg.PadDef[current].AnalogDef[ANALOG_RIGHT][ANALOG_XM].J.d = c;
251                 } else if (strncmp(buf, "RightAnalogYP=", 14) == 0) {
252                         sscanf(buf, "RightAnalogYP=%d,%d,%d", &a, &b, &c);
253                         g.cfg.PadDef[current].AnalogDef[ANALOG_RIGHT][ANALOG_YP].Key = a;
254                         g.cfg.PadDef[current].AnalogDef[ANALOG_RIGHT][ANALOG_YP].JoyEvType = b;
255                         g.cfg.PadDef[current].AnalogDef[ANALOG_RIGHT][ANALOG_YP].J.d = c;
256                 } else if (strncmp(buf, "RightAnalogYM=", 14) == 0) {
257                         sscanf(buf, "RightAnalogYM=%d,%d,%d", &a, &b, &c);
258                         g.cfg.PadDef[current].AnalogDef[ANALOG_RIGHT][ANALOG_YM].Key = a;
259                         g.cfg.PadDef[current].AnalogDef[ANALOG_RIGHT][ANALOG_YM].JoyEvType = b;
260                         g.cfg.PadDef[current].AnalogDef[ANALOG_RIGHT][ANALOG_YM].J.d = c;
261                 }
262         }
263
264         fclose(fp);
265 }
266
267 void SavePADConfig() {
268         FILE            *fp;
269         int                     i;
270
271         fp = fopen(CONFIG_FILE, "w");
272         if (fp == NULL) {
273                 return;
274         }
275
276         fprintf(fp, "[CONFIG]\n");
277         fprintf(fp, "Threaded=%d\n", g.cfg.Threaded);
278         fprintf(fp, "\n");
279
280         for (i = 0; i < 2; i++) {
281                 fprintf(fp, "[PAD%d]\n", i + 1);
282                 fprintf(fp, "DevNum=%d\n", g.cfg.PadDef[i].DevNum);
283                 fprintf(fp, "Type=%d\n", g.cfg.PadDef[i].Type);
284
285                 fprintf(fp, "Select=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_SELECT].Key,
286                         g.cfg.PadDef[i].KeyDef[DKEY_SELECT].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_SELECT].J.d);
287                 fprintf(fp, "L3=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_L3].Key,
288                         g.cfg.PadDef[i].KeyDef[DKEY_L3].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_L3].J.d);
289                 fprintf(fp, "R3=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_R3].Key,
290                         g.cfg.PadDef[i].KeyDef[DKEY_R3].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_R3].J.d);
291                 fprintf(fp, "Start=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_START].Key,
292                         g.cfg.PadDef[i].KeyDef[DKEY_START].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_START].J.d);
293                 fprintf(fp, "Up=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_UP].Key,
294                         g.cfg.PadDef[i].KeyDef[DKEY_UP].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_UP].J.d);
295                 fprintf(fp, "Right=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_RIGHT].Key,
296                         g.cfg.PadDef[i].KeyDef[DKEY_RIGHT].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_RIGHT].J.d);
297                 fprintf(fp, "Down=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_DOWN].Key,
298                         g.cfg.PadDef[i].KeyDef[DKEY_DOWN].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_DOWN].J.d);
299                 fprintf(fp, "Left=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_LEFT].Key,
300                         g.cfg.PadDef[i].KeyDef[DKEY_LEFT].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_LEFT].J.d);
301                 fprintf(fp, "L2=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_L2].Key,
302                         g.cfg.PadDef[i].KeyDef[DKEY_L2].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_L2].J.d);
303                 fprintf(fp, "R2=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_R2].Key,
304                         g.cfg.PadDef[i].KeyDef[DKEY_R2].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_R2].J.d);
305                 fprintf(fp, "L1=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_L1].Key,
306                         g.cfg.PadDef[i].KeyDef[DKEY_L1].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_L1].J.d);
307                 fprintf(fp, "R1=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_R1].Key,
308                         g.cfg.PadDef[i].KeyDef[DKEY_R1].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_R1].J.d);
309                 fprintf(fp, "Triangle=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_TRIANGLE].Key,
310                         g.cfg.PadDef[i].KeyDef[DKEY_TRIANGLE].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_TRIANGLE].J.d);
311                 fprintf(fp, "Circle=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_CIRCLE].Key,
312                         g.cfg.PadDef[i].KeyDef[DKEY_CIRCLE].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_CIRCLE].J.d);
313                 fprintf(fp, "Cross=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_CROSS].Key,
314                         g.cfg.PadDef[i].KeyDef[DKEY_CROSS].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_CROSS].J.d);
315                 fprintf(fp, "Square=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_SQUARE].Key,
316                         g.cfg.PadDef[i].KeyDef[DKEY_SQUARE].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_SQUARE].J.d);
317                 fprintf(fp, "LeftAnalogXP=%d,%d,%d\n", g.cfg.PadDef[i].AnalogDef[ANALOG_LEFT][ANALOG_XP].Key,
318                         g.cfg.PadDef[i].AnalogDef[ANALOG_LEFT][ANALOG_XP].JoyEvType,
319                         g.cfg.PadDef[i].AnalogDef[ANALOG_LEFT][ANALOG_XP].J.d);
320                 fprintf(fp, "LeftAnalogXM=%d,%d,%d\n", g.cfg.PadDef[i].AnalogDef[ANALOG_LEFT][ANALOG_XM].Key,
321                         g.cfg.PadDef[i].AnalogDef[ANALOG_LEFT][ANALOG_XM].JoyEvType,
322                         g.cfg.PadDef[i].AnalogDef[ANALOG_LEFT][ANALOG_XM].J.d);
323                 fprintf(fp, "LeftAnalogYP=%d,%d,%d\n", g.cfg.PadDef[i].AnalogDef[ANALOG_LEFT][ANALOG_YP].Key,
324                         g.cfg.PadDef[i].AnalogDef[ANALOG_LEFT][ANALOG_YP].JoyEvType,
325                         g.cfg.PadDef[i].AnalogDef[ANALOG_LEFT][ANALOG_YP].J.d);
326                 fprintf(fp, "LeftAnalogYM=%d,%d,%d\n", g.cfg.PadDef[i].AnalogDef[ANALOG_LEFT][ANALOG_YM].Key,
327                         g.cfg.PadDef[i].AnalogDef[ANALOG_LEFT][ANALOG_YM].JoyEvType,
328                         g.cfg.PadDef[i].AnalogDef[ANALOG_LEFT][ANALOG_YM].J.d);
329                 fprintf(fp, "RightAnalogXP=%d,%d,%d\n", g.cfg.PadDef[i].AnalogDef[ANALOG_RIGHT][ANALOG_XP].Key,
330                         g.cfg.PadDef[i].AnalogDef[ANALOG_RIGHT][ANALOG_XP].JoyEvType,
331                         g.cfg.PadDef[i].AnalogDef[ANALOG_RIGHT][ANALOG_XP].J.d);
332                 fprintf(fp, "RightAnalogXM=%d,%d,%d\n", g.cfg.PadDef[i].AnalogDef[ANALOG_RIGHT][ANALOG_XM].Key,
333                         g.cfg.PadDef[i].AnalogDef[ANALOG_RIGHT][ANALOG_XM].JoyEvType,
334                         g.cfg.PadDef[i].AnalogDef[ANALOG_RIGHT][ANALOG_XM].J.d);
335                 fprintf(fp, "RightAnalogYP=%d,%d,%d\n", g.cfg.PadDef[i].AnalogDef[ANALOG_RIGHT][ANALOG_YP].Key,
336                         g.cfg.PadDef[i].AnalogDef[ANALOG_RIGHT][ANALOG_YP].JoyEvType,
337                         g.cfg.PadDef[i].AnalogDef[ANALOG_RIGHT][ANALOG_YP].J.d);
338                 fprintf(fp, "RightAnalogYM=%d,%d,%d\n", g.cfg.PadDef[i].AnalogDef[ANALOG_RIGHT][ANALOG_YM].Key,
339                         g.cfg.PadDef[i].AnalogDef[ANALOG_RIGHT][ANALOG_YM].JoyEvType,
340                         g.cfg.PadDef[i].AnalogDef[ANALOG_RIGHT][ANALOG_YM].J.d);
341
342                 fprintf(fp, "\n");
343         }
344
345         fclose(fp);
346 }