1 /*---------------------------------------------------------------------------*
2   Project:  Controller utility demo
3   File:     contdemo.c
4 
5   Copyright (C) 2000-2006 Nintendo.  All rights reserved.
6 
7   These coded instructions, statements, and computer programs contain
8   proprietary information of Nintendo of America Inc. and/or Nintendo
9   Company Ltd., and are protected by Federal copyright law.  They may
10   not be disclosed to third parties or copied or duplicated in any form,
11   in whole or in part, without the prior written consent of Nintendo.
12 
13   $Log: contdemo.c,v $
14   Revision 1.1  02/02/2006 06:11:49  yasuh-to
15   Initial import
16 
17 
18     10    5/21/01 10:25a Shiki
19     Removed analog A/B output.
20 
21     9     5/18/01 8:43p Shiki
22     Fixed the default analog mode.
23 
24     8     01/04/11 12:46:00 Shiki
25     Revised using escape sequences for smoother screen update.
26 
27     7     01/03/22 21:09:00 Shiki
28     Revised.
29 
30     6     01/03/06 17:18 Shiki
31     Modified InitCont() to support controller recalibration.
32 
33     5     01/03/05 11:00 Shiki
34     Revised.
35 
36     4     12/01/00 6:45p Shiki
37     Removed PADSetSpec().
38 
39     3     11/21/00 9:52p Shiki
40     #ifdef EMU to deal with emulators.
41 
42     2     11/20/00 6:10p Shiki
43     Added PADSetSpec() line for DS4.
44 
45     1     11/13/00 6:02p Shiki
46     Initial check-in.
47   $NoKeywords: $
48  *---------------------------------------------------------------------------*/
49 
50 #include <revolution.h>
51 #include "cont.h"
52 
PrintCont(void)53 static void PrintCont(void)
54 {
55     int chan;
56 
57     OSReport("\033[H");     // Home
58     OSReport("Port  AB XY S ZLR +Pad Left         Right        Trigger\n");
59     //        1[-2] AB XY S ZLR <>^v (1234, 1234) (1234, 1234) (123, 123)
60 
61     for (chan = 0; chan < PAD_MAX_CONTROLLERS + 1; chan++)
62     {
63         OSReport("%d[%-2d] %c%c %c%c %c %c%c%c %c%c%c%c (%4d, %4d) (%4d, %4d) (%3d, %3d)\n",
64             chan,
65             Conts[chan].err,
66             (Conts[chan].button & PAD_BUTTON_A) ? 'O' : '_',
67             (Conts[chan].button & PAD_BUTTON_B) ? 'O' : '_',
68             (Conts[chan].button & PAD_BUTTON_X) ? 'O' : '_',
69             (Conts[chan].button & PAD_BUTTON_Y) ? 'O' : '_',
70             (Conts[chan].button & PAD_BUTTON_START) ? 'O' : '_',
71             (Conts[chan].button & PAD_TRIGGER_Z) ? 'O' : '_',
72             (Conts[chan].button & PAD_TRIGGER_L) ? 'O' : '_',
73             (Conts[chan].button & PAD_TRIGGER_R) ? 'O' : '_',
74 
75             (Conts[chan].button & PAD_BUTTON_LEFT)  ? '<' : '_',
76             (Conts[chan].button & PAD_BUTTON_RIGHT) ? '>' : '_',
77             (Conts[chan].button & PAD_BUTTON_UP)    ? '^' : '_',
78             (Conts[chan].button & PAD_BUTTON_DOWN)  ? 'v' : '_',
79 
80             Conts[chan].stickX,
81             Conts[chan].stickY,
82             Conts[chan].substickX,
83             Conts[chan].substickY,
84             Conts[chan].triggerLeft,
85             Conts[chan].triggerRight);
86 
87     }
88 }
89 
main(void)90 void main(void)
91 {
92     BOOL reset = FALSE;
93 
94     VIInit();
95     PADInit();
96     InitCont(0, FALSE);
97     OSReport("\033c");   // Resets the terminal
98 
99     for (;;)
100     {
101         ReadCont();
102         if (reset)
103         {
104             if (!OSGetResetSwitchState())
105             {
106                 reset = FALSE;
107             }
108             continue;
109         }
110 
111         PrintCont();
112 
113         if (OSGetResetSwitchState())
114         {
115             reset = TRUE;
116             InitCont(0, TRUE);
117             OSReport("\033c");   // Resets the terminal
118         }
119         VIWaitForRetrace();
120     }
121 }
122