PS2SDK
PS2 Homebrew Libraries
Loading...
Searching...
No Matches
sio2Cmds.c
Go to the documentation of this file.
1/*
2 * Copyright (c) 2007 Lukasz Bruun <mail@lukasz.dk>
3 *
4 * See the file LICENSE included with this distribution for licensing terms.
5 */
6
12#include "irx.h"
13#include "types.h"
14#include "sio2Cmds.h"
15
16typedef struct
17{
18 u8 id;
19 u8 pad[3];
20 void (*readdata)(u8 *);
21 u32 (*getportctrl1)(u32, u32);
22 u32 (*getportctrl2)(u32);
23 u32 (*reg_data)(void);
24 u32 (*size1)(void);
25 u32 (*size2)(void);
26 u32 (*enterconfigmode)(u8 *);
27 u32 (*exitconfigmode)(u8 *);
28 u32 (*querymodel)(u8 *);
29 u32 (*queryact)(u8 *);
30 u32 (*querycomb)(u8 *);
31 u32 (*querymode)(u8 *);
32 u32 (*querybuttonmask)(u8 *);
33 u32 (*setbuttoninfo)(u8 *);
34 u32 (*setvrefparam)(u8 *);
35 u32 (*setmainmode)(u8 *);
36 u32 (*setactalign)(u8 *);
38
39static sio2Cmds_t sio2Cmds[SIO2_CMD_MAX];
40static int numControllers;
41
42void sio2cmdReset(void)
43{
44 int i;
45
46 for(i=0; i < SIO2_CMD_MAX; i++)
47 sio2Cmds[i].id = 0;
48
49 numControllers = 0;
50}
51
52static int SetupCmds(const sio2Cmds_t *s)
53{
54 if( ((numControllers+1) < SIO2_CMD_MAX) && (s != NULL) )
55 {
56 if(numControllers > 0)
57 {
58 int i = 0;
59
60 // Check if the controller was already registered (if so, do nothing).
61 do
62 {
63 if(s->id == sio2Cmds[i].id)
64 return 0;
65
66 i++;
67 } while(numControllers > i);
68 }
69
70 //Register new controller
71 int i = numControllers;
72
73 sio2Cmds[i].id = s->id;
74 sio2Cmds[i].readdata = s->readdata;
75 sio2Cmds[i].getportctrl1 = s->getportctrl1;
76 sio2Cmds[i].getportctrl2 = s->getportctrl2;
77 sio2Cmds[i].reg_data = s->reg_data;
78 sio2Cmds[i].size1 = s->size1;
79 sio2Cmds[i].size2 = s->size2;
80 sio2Cmds[i].enterconfigmode = s->enterconfigmode;
81 sio2Cmds[i].exitconfigmode = s->exitconfigmode;
82 sio2Cmds[i].querymodel = s->querymodel;
83 sio2Cmds[i].queryact = s->queryact;
84 sio2Cmds[i].querycomb = s->querycomb;
85 sio2Cmds[i].querymode = s->querymode;
86 sio2Cmds[i].querybuttonmask = s->querybuttonmask;
87 sio2Cmds[i].setbuttoninfo = s->setbuttoninfo;
88 sio2Cmds[i].setvrefparam = s->setvrefparam;
89 sio2Cmds[i].setmainmode = s->setmainmode;
90 sio2Cmds[i].setactalign = s->setactalign;
91
92 numControllers++;
93
94 return 1;
95 }
96 else
97 {
98 return 0;
99 }
100}
101
102/*******************************************************************************
103 FindPads
104*******************************************************************************/
105
106static void FindPadsReadData(u8 *a)
107{
108 a[0] = 1;
109 a[1] = 0x42;
110 a[2] = 0;
111 a[3] = 0;
112 a[4] = 0;
113}
114
115static u32 FindPadsGetPortCtrl1(u32 a, u32 b)
116{
117 (void)b;
118
119 if(a == 0)
120 return 0xFFC00505;
121 else
122 return 0xFF060505;
123}
124
125static u32 FindPadsGetPortCtrl2(u32 a)
126{
127 if(a == 0)
128 return 0x2000A;
129 else
130 return 0x2012C;
131}
132
133static u32 FindPadsGetSize1(void)
134{
135 return 0x5;
136}
137
138static u32 FindPadsGetSize2(void)
139{
140 return 0x5;
141}
142
143static u32 FindPadsRegData(void)
144{
145 u32 res1, res2;
146
147 res1 = FindPadsGetSize1();
148
149 res1 = ((res1 & 0x1FF) << 8) | 0x40;
150
151 res2 = FindPadsGetSize2();
152
153 res2 = (res2 & 0x1FF) << 18;
154
155 return (res1 | res2);
156}
157
158static u32 FindPadsEnterConfigMode(u8 *a)
159{
160 (void)a;
161
162 return 0;
163}
164
165void sio2cmdInitFindPads(void)
166{
167 sio2Cmds_t s;
168
169 s.id = PAD_ID_HI(PAD_ID_FINDPADS);
170
171 s.readdata = &FindPadsReadData;
172 s.getportctrl1 = &FindPadsGetPortCtrl1;
173 s.getportctrl2 = &FindPadsGetPortCtrl2;
174 s.reg_data = &FindPadsRegData;
175 s.size1 = &FindPadsGetSize1;
176 s.size2 = &FindPadsGetSize2;
177 s.enterconfigmode = &FindPadsEnterConfigMode;
178 s.exitconfigmode = NULL;
179 s.querymodel = NULL;
180 s.queryact = NULL;
181 s.querycomb = NULL;
182 s.querymode = NULL;
183 s.querybuttonmask = NULL;
184 s.setbuttoninfo = NULL;
185 s.setvrefparam = NULL;
186 s.setmainmode = NULL;
187 s.setactalign = NULL;
188
189 SetupCmds(&s);
190}
191
192/*******************************************************************************
193 Mouse
194*******************************************************************************/
195
196static void MouseReadData(u8* a)
197{
198 a[0] = 1;
199 a[1] = 0x42;
200 a[2] = 0;
201 a[3] = 0;
202 a[4] = 0;
203 a[5] = 0;
204 a[6] = 0;
205}
206
207static u32 MouseGetPortCtrl1(u32 a, u32 b)
208{
209 (void)b;
210
211 if(a == 0)
212 return 0xFFC00505;
213 else
214 return 0xFF060505;
215}
216
217static u32 MouseGetPortCtrl2(u32 a)
218{
219 if(a == 0)
220 return 0x20014;
221 else
222 return 0x2012C;
223}
224
225static u32 MouseRegData(void)
226{
227 return 0x1c0740;
228}
229
230static u32 MouseSize1(void)
231{
232 return 0x7;
233}
234
235static u32 MouseSize2(void)
236{
237 return 0x7;
238}
239
240static u32 MouseEnterConfigMode(u8 *a)
241{
242 a[0] = 0x1;
243 a[1] = 0x43;
244 a[2] = 0;
245 a[3] = 0x1;
246 a[4] = 0;
247 a[5] = 0;
248 a[6] = 0;
249
250 return 0x7;
251}
252
253void sio2cmdInitMouse(void)
254{
255 sio2Cmds_t s;
256
257 s.id = PAD_ID_HI(PAD_ID_MOUSE);
258
259 s.readdata = &MouseReadData;
260 s.getportctrl1 = &MouseGetPortCtrl1;
261 s.getportctrl2 = &MouseGetPortCtrl2;
262 s.reg_data = &MouseRegData;
263 s.size1 = &MouseSize1;
264 s.size2 = &MouseSize2;
265 s.enterconfigmode = &MouseEnterConfigMode;
266 s.exitconfigmode = NULL;
267 s.querymodel = NULL;
268 s.queryact = NULL;
269 s.querycomb = NULL;
270 s.querymode = NULL;
271 s.querybuttonmask = NULL;
272 s.setbuttoninfo = NULL;
273 s.setvrefparam = NULL;
274 s.setmainmode = NULL;
275 s.setactalign = NULL;
276
277
278 SetupCmds(&s);
279}
280
281/*******************************************************************************
282 Negicon
283*******************************************************************************/
284
285static void NegiconReadData(u8* a)
286{
287 a[0] = 1;
288 a[1] = 0x42;
289 a[2] = 0;
290 a[3] = 0;
291 a[4] = 0;
292 a[5] = 0;
293 a[6] = 0;
294 a[7] = 0;
295 a[8] = 0;
296}
297
298static u32 NegiconGetPortCtrl1(u32 a, u32 b)
299{
300 (void)b;
301
302 if(a == 0)
303 return 0xFFC00505;
304 else
305 return 0xFF060505;
306}
307
308
309static u32 NegiconGetPortCtrl2(u32 a)
310{
311 if(a == 0)
312 return 0x20014;
313 else
314 return 0x2012C;
315}
316
317static u32 NegiconRegData(void)
318{
319 return 0x240940;
320}
321
322static u32 NegiconSize1(void)
323{
324 return 0x9;
325}
326
327static u32 NegiconSize2(void)
328{
329 return 0x9;
330}
331
332static u32 NegiconEnterConfigMode(u8 *a)
333{
334 a[0] = 0x1;
335 a[1] = 0x43;
336 a[2] = 0;
337 a[3] = 0x1;
338 a[4] = 0;
339 a[5] = 0;
340 a[6] = 0;
341 a[7] = 0;
342 a[8] = 0;
343
344 return 0x9;
345}
346
347void sio2cmdInitNegicon(void)
348{
349 sio2Cmds_t s;
350
351 s.id = PAD_ID_HI(PAD_ID_NEGICON);
352
353 s.readdata = &NegiconReadData;
354 s.getportctrl1 = &NegiconGetPortCtrl1;
355 s.getportctrl2 = &NegiconGetPortCtrl2;
356 s.reg_data = &NegiconRegData;
357 s.size1 = &NegiconSize1;
358 s.size2 = &NegiconSize2;
359 s.enterconfigmode = &NegiconEnterConfigMode;
360 s.exitconfigmode = NULL;
361 s.querymodel = NULL;
362 s.queryact = NULL;
363 s.querycomb = NULL;
364 s.querymode = NULL;
365 s.querybuttonmask = NULL;
366 s.setbuttoninfo = NULL;
367 s.setvrefparam = NULL;
368 s.setmainmode = NULL;
369 s.setactalign = NULL;
370
371 SetupCmds(&s);
372}
373
374/*******************************************************************************
375 Konami Gun
376*******************************************************************************/
377
378static void KonamiGunReadData(u8* a)
379{
380 a[0] = 1;
381 a[1] = 0x42;
382 a[2] = 0;
383 a[3] = 0;
384 a[4] = 0;
385}
386
387static u32 KonamiGunGetPortCtrl1(u32 a, u32 b)
388{
389 (void)b;
390
391 if(a == 0)
392 return 0xFFC00505;
393 else
394 return 0xFF060505;
395}
396
397static u32 KonamiGunGetPortCtrl2(u32 a)
398{
399 if(a == 0)
400 return 0x20014;
401 else
402 return 0x2012C;
403}
404
405static u32 KonamiGunRegData(void)
406{
407 return 0x140540;
408}
409
410static u32 KonamiGunSize1(void)
411{
412 return 0x5;
413}
414
415static u32 KonamiGunSize2(void)
416{
417 return 0x5;
418}
419
420static u32 KonamiGunEnterConfigMode(u8 *a)
421{
422 a[0] = 0x1;
423 a[1] = 0x43;
424 a[2] = 0;
425 a[3] = 0x1;
426 a[4] = 0;
427
428 return 0x5;
429}
430
431void sio2cmdInitKonamiGun(void)
432{
433 sio2Cmds_t s;
434
435 s.id = PAD_ID_HI( PAD_ID_KONAMIGUN );
436
437 s.readdata = &KonamiGunReadData;
438 s.getportctrl1 = &KonamiGunGetPortCtrl1;
439 s.getportctrl2 = &KonamiGunGetPortCtrl2;
440 s.reg_data = &KonamiGunRegData;
441 s.size1 = &KonamiGunSize1;
442 s.size2 = &KonamiGunSize2;
443 s.enterconfigmode = &KonamiGunEnterConfigMode;
444 s.exitconfigmode = NULL;
445 s.querymodel = NULL;
446 s.queryact = NULL;
447 s.querycomb = NULL;
448 s.querymode = NULL;
449 s.querybuttonmask = NULL;
450 s.setbuttoninfo = NULL;
451 s.setvrefparam = NULL;
452 s.setmainmode = NULL;
453 s.setactalign = NULL;
454
455 SetupCmds(&s);
456}
457
458/*******************************************************************************
459 Digital
460*******************************************************************************/
461
462static void DigitalReadData(u8* a)
463{
464 a[0] = 1;
465 a[1] = 0x42;
466 a[2] = 0;
467 a[3] = 0;
468 a[4] = 0;
469}
470
471static u32 DigitalGetPortCtrl1(u32 a, u32 b)
472{
473 (void)b;
474
475 if(a == 0)
476 return 0xFFC00505;
477 else
478 return 0xFF060505;
479}
480
481static u32 DigitalGetPortCtrl2(u32 a)
482{
483 if(a == 0)
484 return 0x20014;
485 else
486 return 0x2012C;
487}
488
489static u32 DigitalRegData(void)
490{
491 return 0x140540;
492}
493
494static u32 DigitalSize1(void)
495{
496 return 0x5;
497}
498
499static u32 DigitalSize2(void)
500{
501 return 0x5;
502}
503
504static u32 DigitalEnterConfigMode(u8 *a)
505{
506 a[0] = 0x1;
507 a[1] = 0x43;
508 a[2] = 0;
509 a[3] = 0x1;
510 a[4] = 0;
511
512 return 0x5;
513}
514
515void sio2cmdInitDigital(void)
516{
517 sio2Cmds_t s;
518
519 s.id = PAD_ID_HI(PAD_ID_DIGITAL);
520
521 s.readdata = &DigitalReadData;
522 s.getportctrl1 = &DigitalGetPortCtrl1;
523 s.getportctrl2 = &DigitalGetPortCtrl2;
524 s.reg_data = &DigitalRegData;
525 s.size1 = &DigitalSize1;
526 s.size2 = &DigitalSize2;
527 s.enterconfigmode = &DigitalEnterConfigMode;
528 s.exitconfigmode = NULL;
529 s.querymodel = NULL;
530 s.queryact = NULL;
531 s.querycomb = NULL;
532 s.querymode = NULL;
533 s.querybuttonmask = NULL;
534 s.setbuttoninfo = NULL;
535 s.setvrefparam = NULL;
536 s.setmainmode = NULL;
537 s.setactalign = NULL;
538
539 SetupCmds(&s);
540}
541
542/*******************************************************************************
543 Joystick
544*******************************************************************************/
545
546static void JoystickReadData(u8* a)
547{
548 a[0] = 1;
549 a[1] = 0x42;
550 a[2] = 0;
551 a[3] = 0;
552 a[4] = 0;
553 a[5] = 0;
554 a[6] = 0;
555 a[7] = 0;
556 a[8] = 0;
557}
558
559static u32 JoystickGetPortCtrl1(u32 a, u32 b)
560{
561 (void)b;
562
563 if(a == 0)
564 return 0xFFC00505;
565 else
566 return 0xFF060505;
567}
568
569static u32 JoystickGetPortCtrl2(u32 a)
570{
571 if(a == 0)
572 return 0x20014;
573 else
574 return 0x2012C;
575}
576
577static u32 JoystickRegData(void)
578{
579 return 0x240940;
580}
581
582static u32 JoystickSize1(void)
583{
584 return 0x9;
585}
586
587static u32 JoystickSize2(void)
588{
589 return 0x9;
590}
591
592static u32 JoystickEnterConfigMode(u8 *a)
593{
594 a[0] = 0x1;
595 a[1] = 0x43;
596 a[2] = 0;
597 a[3] = 0x1;
598 a[4] = 0;
599 a[5] = 0;
600 a[6] = 0;
601 a[7] = 0;
602 a[8] = 0;
603
604 return 0x9;
605}
606
607void sio2cmdInitJoystick(void)
608{
609 sio2Cmds_t s;
610
611 s.id = PAD_ID_HI( PAD_ID_JOYSTICK );
612
613 s.readdata = &JoystickReadData;
614 s.getportctrl1 = &JoystickGetPortCtrl1;
615 s.getportctrl2 = &JoystickGetPortCtrl2;
616 s.reg_data = &JoystickRegData;
617 s.size1 = &JoystickSize1;
618 s.size2 = &JoystickSize2;
619 s.enterconfigmode = &JoystickEnterConfigMode;
620 s.exitconfigmode = NULL;
621 s.querymodel = NULL;
622 s.queryact = NULL;
623 s.querycomb = NULL;
624 s.querymode = NULL;
625 s.querybuttonmask = NULL;
626 s.setbuttoninfo = NULL;
627 s.setvrefparam = NULL;
628 s.setmainmode = NULL;
629 s.setactalign = NULL;
630
631 SetupCmds(&s);
632}
633
634/*******************************************************************************
635 Namco Gun
636*******************************************************************************/
637
638static void NamcoGunReadData(u8* a)
639{
640 a[0] = 1;
641 a[1] = 0x42;
642 a[2] = 0;
643 a[3] = 0;
644 a[4] = 0;
645 a[5] = 0;
646 a[6] = 0;
647 a[7] = 0;
648 a[8] = 0;
649}
650
651static u32 NamcoGunGetPortCtrl1(u32 a, u32 b)
652{
653 (void)b;
654
655 if(a == 0)
656 return 0xFFC00505;
657 else
658 return 0xFF060505;
659}
660
661static u32 NamcoGunGetPortCtrl2(u32 a)
662{
663 if(a == 0)
664 return 0x20014;
665 else
666 return 0x2012C;
667}
668
669static u32 NamcoGunRegData(void)
670{
671 return 0x240940;
672}
673
674static u32 NamcoGunSize1(void)
675{
676 return 0x9;
677}
678
679static u32 NamcoGunSize2(void)
680{
681 return 0x9;
682}
683
684static u32 NamcoGunEnterConfigMode(u8 *a)
685{
686 a[0] = 0x1;
687 a[1] = 0x43;
688 a[2] = 0;
689 a[3] = 0x1;
690 a[4] = 0;
691 a[5] = 0;
692 a[6] = 0;
693 a[7] = 0;
694 a[8] = 0;
695
696 return 0x9;
697}
698
699void sio2cmdInitNamcoGun(void)
700{
701 sio2Cmds_t s;
702
703 s.id = PAD_ID_HI(PAD_ID_NAMCOGUN);
704
705 s.readdata = &NamcoGunReadData;
706 s.getportctrl1 = &NamcoGunGetPortCtrl1;
707 s.getportctrl2 = &NamcoGunGetPortCtrl2;
708 s.reg_data = &NamcoGunRegData;
709 s.size1 = &NamcoGunSize1;
710 s.size2 = &NamcoGunSize2;
711 s.enterconfigmode = &NamcoGunEnterConfigMode;
712 s.exitconfigmode = NULL;
713 s.querymodel = NULL;
714 s.queryact = NULL;
715 s.querycomb = NULL;
716 s.querymode = NULL;
717 s.querybuttonmask = NULL;
718 s.setbuttoninfo = NULL;
719 s.setvrefparam = NULL;
720 s.setmainmode = NULL;
721 s.setactalign = NULL;
722
723 SetupCmds(&s);
724}
725
726/*******************************************************************************
727 Analog
728*******************************************************************************/
729
730static void AnalogReadData(u8* a)
731{
732 a[0] = 1;
733 a[1] = 0x42;
734 a[2] = 0;
735 a[3] = 0;
736 a[4] = 0;
737 a[5] = 0;
738 a[6] = 0;
739 a[7] = 0;
740 a[8] = 0;
741 a[9] = 0;
742 a[10] = 0;
743 a[11] = 0;
744 a[12] = 0;
745 a[13] = 0;
746 a[14] = 0;
747}
748
749static u32 AnalogGetPortCtrl1(u32 a, u32 b)
750{
751 if(a != 0)
752 return 0xFF060505;
753 else
754 {
755 u32 val1, val2, val3 ;
756
757 if((b & 0x2) == 0)
758 val1 = 0x5;
759 else
760 val1 = 0xA;
761
762 if((b & 0x2) == 0)
763 val2 = 0x5;
764 else
765 val2 = 0xA;
766
767 val1 &= 0xFFFF00FF;
768
769 val3 = val1 | ( val2 << 8);
770
771 if((b & 0x2) == 0)
772 val1 = 0xC0;
773 else
774 val1 = 0x60;
775
776 val3 &= 0xFF00FFFF;
777 val3 = val3 | (val1 << 16) | 0xFF000000;
778
779 return val3;
780 }
781}
782
783static u32 AnalogGetPortCtrl2(u32 a)
784{
785 if(a == 0)
786 return 0x20014;
787 else
788 return 0x2012C;
789}
790
791static u32 AnalogEnterConfigMode(u8 *a)
792{
793 a[0] = 0x1;
794 a[1] = 0x43;
795 a[2] = 0;
796 a[3] = 0x1;
797 a[4] = 0;
798 a[5] = 0;
799 a[6] = 0;
800 a[7] = 0;
801 a[8] = 0;
802 a[9] = 0;
803 a[10] = 0;
804 a[11] = 0;
805 a[12] = 0;
806 a[13] = 0;
807 a[14] = 0;
808
809 return 0x15;
810}
811
812void sio2cmdInitAnalog(void)
813{
814 sio2Cmds_t s;
815
816 s.id = PAD_ID_HI(PAD_ID_ANALOG);
817
818 s.readdata = &AnalogReadData;
819 s.getportctrl1 = &AnalogGetPortCtrl1;
820 s.getportctrl2 = &AnalogGetPortCtrl2;
821 s.reg_data = NULL;
822 s.size1 = NULL;
823 s.size2 = NULL;
824 s.enterconfigmode = &AnalogEnterConfigMode;
825 s.exitconfigmode = NULL;
826 s.querymodel = NULL;
827 s.queryact = NULL;
828 s.querycomb = NULL;
829 s.querymode = NULL;
830 s.querybuttonmask = NULL;
831 s.setbuttoninfo = NULL;
832 s.setvrefparam = NULL;
833 s.setmainmode = NULL;
834 s.setactalign = NULL;
835
836 SetupCmds(&s);
837}
838
839/*******************************************************************************
840 Jogcon
841*******************************************************************************/
842
843static void JogconReadData(u8* a)
844{
845 a[0] = 1;
846 a[1] = 0x42;
847 a[2] = 0;
848 a[3] = 0;
849 a[4] = 0;
850 a[5] = 0;
851 a[6] = 0;
852 a[7] = 0;
853 a[8] = 0;
854 a[9] = 0;
855 a[10] = 0;
856 a[11] = 0;
857 a[12] = 0;
858}
859
860static u32 JogconGetPortCtrl1(u32 a, u32 b)
861{
862 (void)b;
863
864 if(a == 0)
865 return 0xFFC00505;
866 else
867 return 0xFF060505;
868}
869
870static u32 JogconGetPortCtrl2(u32 a)
871{
872 if(a == 0)
873 return 0x20014;
874 else
875 return 0x2012C;
876}
877
878static u32 JogconRegData(void)
879{
880 return 0x340d40;
881}
882
883static u32 JogconSize1(void)
884{
885 return 0xD;
886}
887
888static u32 JogconSize2(void)
889{
890 return 0xD;
891}
892
893static u32 JogconEnterConfigMode(u8 *a)
894{
895 a[0] = 0x1;
896 a[1] = 0x43;
897 a[2] = 0;
898 a[3] = 0x1;
899 a[4] = 0;
900 a[5] = 0;
901 a[6] = 0;
902 a[7] = 0;
903 a[8] = 0;
904 a[9] = 0;
905 a[10] = 0;
906 a[11] = 0;
907 a[12] = 0;
908
909 return 0xD;
910}
911
912void sio2cmdInitJogcon(void)
913{
914 sio2Cmds_t s;
915
916 s.id = PAD_ID_HI(PAD_ID_JOGCON);
917
918 s.readdata = &JogconReadData;
919 s.getportctrl1 = &JogconGetPortCtrl1;
920 s.getportctrl2 = &JogconGetPortCtrl2;
921 s.reg_data = &JogconRegData;
922 s.size1 = &JogconSize1;
923 s.size2 = &JogconSize2;
924 s.enterconfigmode = &JogconEnterConfigMode;
925 s.exitconfigmode = NULL;
926 s.querymodel = NULL;
927 s.queryact = NULL;
928 s.querycomb = NULL;
929 s.querymode = NULL;
930 s.querybuttonmask = NULL;
931 s.setbuttoninfo = NULL;
932 s.setvrefparam = NULL;
933 s.setmainmode = NULL;
934 s.setactalign = NULL;
935
936 SetupCmds(&s);
937}
938
939/*******************************************************************************
940 Config
941*******************************************************************************/
942
943static void ConfigReadData(u8* a)
944{
945 a[0] = 1;
946 a[1] = 0x42;
947 a[2] = 0;
948 a[3] = 0x5A;
949 a[4] = 0x5A;
950 a[5] = 0x5A;
951 a[6] = 0x5A;
952 a[7] = 0x5A;
953 a[8] = 0x5A;
954}
955
956static u32 ConfigGetPortCtrl1(u32 a, u32 b)
957{
958 (void)b;
959
960 if(a == 0)
961 return 0xFFC00505;
962 else
963 return 0xFF060505;
964}
965
966static u32 ConfigGetPortCtrl2(u32 a)
967{
968 if(a == 0)
969 return 0x20014;
970 else
971 return 0x2012C;
972}
973
974static u32 ConfigRegData(void)
975{
976 return 0x240940;
977}
978
979static u32 ConfigSize1(void)
980{
981 return 0x9;
982}
983
984static u32 ConfigSize2(void)
985{
986 return 0x9;
987}
988
989static u32 ConfigExitConfigMode(u8 *a)
990{
991 a[0] = 1;
992 a[1] = 0x43;
993 a[2] = 0x0;
994 a[3] = 0x0;
995 a[4] = 0x5a;
996 a[5] = 0x5a;
997 a[6] = 0x5a;
998 a[7] = 0x5a;
999 a[8] = 0x5a;
1000
1001 return 9;
1002}
1003
1004static u32 ConfigQueryModel(u8 *a)
1005{
1006 a[0] = 1;
1007 a[1] = 0x45;
1008 a[2] = 0x0;
1009 a[3] = 0x5a;
1010 a[4] = 0x5a;
1011 a[5] = 0x5a;
1012 a[6] = 0x5a;
1013 a[7] = 0x5a;
1014 a[8] = 0x5a;
1015
1016 return 9;
1017}
1018
1019static u32 ConfigQueryAct(u8 *a)
1020{
1021 a[0] = 1;
1022 a[1] = 0x46;
1023 a[2] = 0x0;
1024 a[3] = 0x0;
1025 a[4] = 0x5a;
1026 a[5] = 0x5a;
1027 a[6] = 0x5a;
1028 a[7] = 0x5a;
1029 a[8] = 0x5a;
1030
1031 return 9;
1032}
1033
1034static u32 ConfigQueryComb(u8 *a)
1035{
1036 a[0] = 1;
1037 a[1] = 0x47;
1038 a[2] = 0x0;
1039 a[3] = 0x0;
1040 a[4] = 0x5a;
1041 a[5] = 0x5a;
1042 a[6] = 0x5a;
1043 a[7] = 0x5a;
1044 a[8] = 0x5a;
1045
1046 return 9;
1047}
1048
1049static u32 ConfigQueryMode(u8 *a)
1050{
1051 a[0] = 1;
1052 a[1] = 0x4c;
1053 a[2] = 0x0;
1054 a[3] = 0x0;
1055 a[4] = 0x5a;
1056 a[5] = 0x5a;
1057 a[6] = 0x5a;
1058 a[7] = 0x5a;
1059 a[8] = 0x5a;
1060
1061 return 9;
1062}
1063
1064static u32 ConfigQueryButtonMask(u8 *a)
1065{
1066 a[0] = 1;
1067 a[1] = 0x41;
1068 a[2] = 0x0;
1069 a[3] = 0x5a;
1070 a[4] = 0x5a;
1071 a[5] = 0x5a;
1072 a[6] = 0x5a;
1073 a[7] = 0x5a;
1074 a[8] = 0x5a;
1075
1076 return 9;
1077}
1078
1079static u32 ConfigSetButtonInfo(u8 *a)
1080{
1081 a[0] = 1;
1082 a[1] = 0x4F;
1083 a[2] = 0x0;
1084 a[3] = 0x0;
1085 a[4] = 0x0;
1086 a[5] = 0x0;
1087 a[6] = 0x0;
1088 a[7] = 0x0;
1089 a[8] = 0x0;
1090
1091 return 9;
1092}
1093
1094static u32 ConfigSetVrefParam(u8 *a)
1095{
1096 a[0] = 1;
1097 a[1] = 0x40;
1098 a[2] = 0x0;
1099 a[3] = 0x0;
1100 a[4] = 0x0;
1101 a[5] = 0x0;
1102 a[6] = 0x0;
1103 a[7] = 0x0;
1104 a[8] = 0x0;
1105
1106 return 9;
1107}
1108
1109static u32 ConfigSetMainMode(u8 *a)
1110{
1111 a[0] = 1;
1112 a[1] = 0x44;
1113 a[2] = 0x0;
1114 a[3] = 0x0;
1115 a[4] = 0x0;
1116 a[5] = 0x0;
1117 a[6] = 0x0;
1118 a[7] = 0x0;
1119 a[8] = 0x0;
1120
1121 return 9;
1122}
1123
1124static u32 ConfigSetSetActAlign(u8 *a)
1125{
1126 a[0] = 1;
1127 a[1] = 0x4d;
1128 a[2] = 0x0;
1129 a[3] = 0x0;
1130 a[4] = 0x0;
1131 a[5] = 0x0;
1132 a[6] = 0x0;
1133 a[7] = 0x0;
1134 a[8] = 0x0;
1135
1136 return 9;
1137}
1138
1139void sio2cmdInitConfig(void)
1140{
1141 sio2Cmds_t s;
1142
1143 s.id = PAD_ID_HI( PAD_ID_CONFIG );
1144
1145 s.readdata = &ConfigReadData;
1146 s.getportctrl1 = &ConfigGetPortCtrl1;
1147 s.getportctrl2 = &ConfigGetPortCtrl2;
1148 s.reg_data = &ConfigRegData;
1149 s.size1 = &ConfigSize1;
1150 s.size2 = &ConfigSize2;
1151 s.enterconfigmode = NULL;
1152 s.exitconfigmode = &ConfigExitConfigMode;
1153 s.querymodel = &ConfigQueryModel;
1154 s.queryact = &ConfigQueryAct;
1155 s.querycomb = &ConfigQueryComb;
1156 s.querymode = &ConfigQueryMode;
1157 s.querybuttonmask = &ConfigQueryButtonMask;
1158 s.setbuttoninfo = &ConfigSetButtonInfo;
1159 s.setvrefparam = &ConfigSetVrefParam;
1160 s.setmainmode = &ConfigSetMainMode;
1161 s.setactalign = &ConfigSetSetActAlign;
1162
1163 SetupCmds(&s);
1164}
1165
1166/*******************************************************************************
1167*******************************************************************************/
1168
1169u32 sio2cmdCheckId(u8 id)
1170{
1171 int i;
1172 id = PAD_ID_HI(id);
1173
1174 for(i=0; i < numControllers; i++)
1175 {
1176 if( sio2Cmds[i].id == id )
1177 return 1;
1178 }
1179
1180 return 0;
1181}
1182
1183
1184u32 sio2CmdGetPortCtrl1(u8 id, u32 b, u8 c)
1185{
1186 int i;
1187 id = PAD_ID_HI(id);
1188
1189 for(i=0; i < numControllers; i++)
1190 {
1191 if(sio2Cmds[i].id == id)
1192 {
1193 if(sio2Cmds[i].getportctrl1 != NULL)
1194 return sio2Cmds[i].getportctrl1(b, c);
1195 }
1196 }
1197
1198 return 0;
1199}
1200
1201u32 sio2CmdGetPortCtrl2(u32 id, u32 b)
1202{
1203 int i;
1204 id = PAD_ID_HI(id);
1205
1206 for(i=0; i < numControllers; i++)
1207 {
1208 if(sio2Cmds[i].id == id)
1209 {
1210 if(sio2Cmds[i].getportctrl2 != NULL)
1211 return sio2Cmds[i].getportctrl2(b);
1212 }
1213 }
1214
1215 return 0;
1216}
1217
1218void sio2CmdSetReadData(u32 id, u8 *buf)
1219{
1220 int i;
1221 id = PAD_ID_HI(id);
1222
1223 for(i=0; i < numControllers; i++)
1224 {
1225 if(sio2Cmds[i].id == id)
1226 {
1227 if(sio2Cmds[i].readdata != NULL)
1228 {
1229 sio2Cmds[i].readdata(buf);
1230 return;
1231 }
1232 }
1233 }
1234}
1235
1236u32 sio2CmdSetEnterConfigMode(u32 id, u8 *buf)
1237{
1238 int i;
1239 id = PAD_ID_HI(id);
1240
1241 for(i=0; i < numControllers; i++)
1242 {
1243 if(sio2Cmds[i].id == id)
1244 {
1245 if(sio2Cmds[i].enterconfigmode != NULL)
1246 return sio2Cmds[i].enterconfigmode(buf);
1247 }
1248
1249 }
1250
1251 return 0;
1252}
1253
1254u32 sio2CmdSetQueryModel(u32 id, u8 *buf)
1255{
1256 int i;
1257 id = PAD_ID_HI(id);
1258
1259 for(i=0; i < numControllers; i++)
1260 {
1261 if( sio2Cmds[i].id == id )
1262 {
1263 if( sio2Cmds[i].querymodel != NULL)
1264 return sio2Cmds[i].querymodel(buf);
1265 }
1266 }
1267
1268 return 0;
1269}
1270
1271u32 sio2CmdSetSetMainMode(u32 id, u8 *buf)
1272{
1273 int i;
1274 id = PAD_ID_HI(id);
1275
1276 for(i=0; i < numControllers; i++)
1277 {
1278 if( sio2Cmds[i].id == id )
1279 {
1280 if( sio2Cmds[i].setmainmode != NULL)
1281 return sio2Cmds[i].setmainmode(buf);
1282 }
1283 }
1284
1285 return 0;
1286}
1287
1288u32 sio2CmdSetQueryAct(u32 id, u8 *buf)
1289{
1290 int i;
1291 id = PAD_ID_HI(id);
1292
1293 for(i=0; i < numControllers; i++)
1294 {
1295 if( sio2Cmds[i].id == id )
1296 {
1297 if( sio2Cmds[i].queryact != NULL)
1298 return sio2Cmds[i].queryact(buf);
1299 }
1300 }
1301
1302 return 0;
1303}
1304
1305u32 sio2CmdSetQueryComb(u32 id, u8 *buf)
1306{
1307 int i;
1308 id = PAD_ID_HI(id);
1309
1310 for(i=0; i < numControllers; i++)
1311 {
1312 if( sio2Cmds[i].id == id )
1313 {
1314 if( sio2Cmds[i].querycomb != NULL)
1315 return sio2Cmds[i].querycomb(buf);
1316 }
1317 }
1318
1319 return 0;
1320}
1321
1322u32 sio2CmdSetQueryMode(u32 id, u8 *buf)
1323{
1324 int i;
1325 id = PAD_ID_HI(id);
1326
1327 for(i=0; i < numControllers; i++)
1328 {
1329 if( sio2Cmds[i].id == id )
1330 {
1331 if( sio2Cmds[i].querymode != NULL)
1332 return sio2Cmds[i].querymode(buf);
1333 }
1334 }
1335
1336 return 0;
1337}
1338
1339u32 sio2CmdSetExitConfigMode(u32 id, u8 *buf)
1340{
1341 int i;
1342 id = PAD_ID_HI(id);
1343
1344 for(i=0; i < numControllers; i++)
1345 {
1346 if( sio2Cmds[i].id == id )
1347 {
1348 if( sio2Cmds[i].exitconfigmode != NULL)
1349 return sio2Cmds[i].exitconfigmode(buf);
1350 }
1351 }
1352
1353 return 0;
1354}
1355
1356u32 sio2CmdSetSetActAlign(u32 id, u8 *buf)
1357{
1358 int i;
1359 id = PAD_ID_HI(id);
1360
1361 for(i=0; i < numControllers; i++)
1362 {
1363 if( sio2Cmds[i].id == id )
1364 {
1365 if( sio2Cmds[i].setactalign != NULL)
1366 return sio2Cmds[i].setactalign(buf);
1367 }
1368 }
1369
1370 return 0;
1371}
1372
1373u32 sio2CmdSetQueryButtonMask(u32 id, u8 *buf)
1374{
1375 int i;
1376 id = PAD_ID_HI(id);
1377
1378 for(i=0; i < numControllers; i++)
1379 {
1380 if( sio2Cmds[i].id == id )
1381 {
1382 if( sio2Cmds[i].querybuttonmask != NULL)
1383 return sio2Cmds[i].querybuttonmask(buf);
1384 }
1385 }
1386
1387 return 0;
1388}
1389
1390u32 sio2CmdSetSetVrefParam(u32 id, u8 *buf)
1391{
1392 int i;
1393 id = PAD_ID_HI(id);
1394
1395 for(i=0; i < numControllers; i++)
1396 {
1397 if( sio2Cmds[i].id == id )
1398 {
1399 if( sio2Cmds[i].setvrefparam != NULL)
1400 return sio2Cmds[i].setvrefparam(buf);
1401 }
1402 }
1403
1404 return 0;
1405
1406}
1407
1408u32 sio2CmdSetSetButtonInfo(u32 id, u8 *buf)
1409{
1410 int i;
1411 id = PAD_ID_HI(id);
1412
1413 for(i=0; i < numControllers; i++)
1414 {
1415 if( sio2Cmds[i].id == id )
1416 {
1417 if( sio2Cmds[i].setbuttoninfo != NULL)
1418 return sio2Cmds[i].setbuttoninfo(buf);
1419 }
1420 }
1421
1422 return 0;
1423
1424}