1 /*---------------------------------------------------------------------------*
2 Project: Simple game pad API demo
3 File: main.c
4
5 Copyright (C) 1998-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: simple.c,v $
14 Revision 1.1 02/02/2006 06:11:49 yasuh-to
15 Initial import
16
17
18 3 01/04/11 11:41 Shiki
19 Revised.
20
21 2 01/03/22 21:08 Shiki
22 Revised.
23
24 1 3/01/00 11:48p Shiki
25 Initial check-in.
26 $NoKeywords: $
27 *---------------------------------------------------------------------------*/
28
29 #include <revolution.h>
30
31 PADStatus Pads[PAD_MAX_CONTROLLERS];
32
main(void)33 void main(void)
34 {
35 u16 button = 0; // Previous button status
36 u16 down; // Buttons just pressed down
37 u16 up; // Buttons just released
38
39 VIInit(); // VI must be initialized before PAD
40 PADInit();
41
42 do {
43 PADRead(Pads);
44
45 if (Pads[0].err != PAD_ERR_NONE)
46 continue;
47
48 down = PADButtonDown(button, Pads[0].button);
49 up = PADButtonUp (button, Pads[0].button);
50 button = Pads[0].button;
51
52 PADClamp(Pads);
53
54 OSReport("Buttons: %c%c%c%c Stick: (%3d, %3d) Sub: (%3d, %3d) LR: (%3d, %3d) Down: %c%c Up: %c%c\n",
55 (Pads[0].button & PAD_BUTTON_A) ? 'A' : '_',
56 (Pads[0].button & PAD_BUTTON_B) ? 'B' : '_',
57 (Pads[0].button & PAD_BUTTON_X) ? 'X' : '_',
58 (Pads[0].button & PAD_BUTTON_Y) ? 'Y' : '_',
59 Pads[0].stickX,
60 Pads[0].stickY,
61 Pads[0].substickX,
62 Pads[0].substickY,
63 Pads[0].triggerLeft,
64 Pads[0].triggerRight,
65 (down & PAD_BUTTON_A) ? 'A' : '_',
66 (down & PAD_BUTTON_B) ? 'B' : '_',
67 (up & PAD_BUTTON_A) ? 'A' : '_',
68 (up & PAD_BUTTON_B) ? 'B' : '_');
69 } while (!(button & PAD_BUTTON_START));
70 }
71