1 /*---------------------------------------------------------------------------*
2   Project:  Dolphin DEMO library
3   File:     DEMOPad.h
4 
5   Copyright 1998-2001 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: DEMOPad.h,v $
14   Revision 1.1.1.1  2005/05/12 02:41:06  yasuh-to
15   Ported from dolphin source tree.
16 
17 
18     1     2001/05/09 9:37p Hirose
19     separated from demo.h
20 
21   $NoKeywords: $
22  *---------------------------------------------------------------------------*/
23 
24 #ifndef __DEMOPAD_H__
25 #define __DEMOPAD_H__
26 
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 /*---------------------------------------------------------------------------*
33     DEMOPad.c
34  *---------------------------------------------------------------------------*/
35 // used to detect which direction is the stick(s) pointing
36 #define DEMO_STICK_THRESHOLD      48
37 
38 #define DEMO_STICK_UP             0x1000
39 #define DEMO_STICK_DOWN           0x2000
40 #define DEMO_STICK_LEFT           0x4000
41 #define DEMO_STICK_RIGHT          0x8000
42 #define DEMO_SUBSTICK_UP          0x0100
43 #define DEMO_SUBSTICK_DOWN        0x0200
44 #define DEMO_SUBSTICK_LEFT        0x0400
45 #define DEMO_SUBSTICK_RIGHT       0x0800
46 
47 // extended pad status structure
48 typedef struct
49 {
50     // contains PADStatus structure
51     PADStatus   pst;
52 
53     // extended field
54     u16         buttonDown;
55     u16         buttonUp;
56     u16         dirs;
57     u16         dirsNew;
58     u16         dirsReleased;
59     s16         stickDeltaX;
60     s16         stickDeltaY;
61     s16         substickDeltaX;
62     s16         substickDeltaY;
63 } DEMOPadStatus;
64 
65 // the entity which keeps current pad status
66 extern DEMOPadStatus    DemoPad[PAD_MAX_CONTROLLERS];
67 extern u32              DemoNumValidPads;
68 
69 // main function prototypes
70 extern void     DEMOPadInit( void );
71 extern void     DEMOPadRead( void );
72 
73 // inline functions for getting each component
DEMOPadGetButton(u32 i)74 static inline u16 DEMOPadGetButton(u32 i)
75     { return DemoPad[i].pst.button; }
76 
DEMOPadGetButtonUp(u32 i)77 static inline u16 DEMOPadGetButtonUp(u32 i)
78     { return DemoPad[i].buttonUp; }
79 
DEMOPadGetButtonDown(u32 i)80 static inline u16 DEMOPadGetButtonDown(u32 i)
81     { return DemoPad[i].buttonDown; }
82 
DEMOPadGetDirs(u32 i)83 static inline u16 DEMOPadGetDirs(u32 i)
84     { return DemoPad[i].dirs; }
85 
DEMOPadGetDirsNew(u32 i)86 static inline u16 DEMOPadGetDirsNew(u32 i)
87     { return DemoPad[i].dirsNew; }
88 
DEMOPadGetDirsReleased(u32 i)89 static inline u16 DEMOPadGetDirsReleased(u32 i)
90     { return DemoPad[i].dirsReleased; }
91 
DEMOPadGetStickX(u32 i)92 static inline s8  DEMOPadGetStickX(u32 i)
93     { return DemoPad[i].pst.stickX; }
94 
DEMOPadGetStickY(u32 i)95 static inline s8  DEMOPadGetStickY(u32 i)
96     { return DemoPad[i].pst.stickY; }
97 
DEMOPadGetSubStickX(u32 i)98 static inline s8  DEMOPadGetSubStickX(u32 i)
99     { return DemoPad[i].pst.substickX; }
100 
DEMOPadGetSubStickY(u32 i)101 static inline s8  DEMOPadGetSubStickY(u32 i)
102     { return DemoPad[i].pst.substickY; }
103 
DEMOPadGetTriggerL(u32 i)104 static inline u8  DEMOPadGetTriggerL(u32 i)
105     { return DemoPad[i].pst.triggerLeft; }
106 
DEMOPadGetTriggerR(u32 i)107 static inline u8  DEMOPadGetTriggerR(u32 i)
108     { return DemoPad[i].pst.triggerRight; }
109 
DEMOPadGetAnalogA(u32 i)110 static inline u8  DEMOPadGetAnalogA(u32 i)
111     { return DemoPad[i].pst.analogA; }
112 
DEMOPadGetAnalogB(u32 i)113 static inline u8  DEMOPadGetAnalogB(u32 i)
114     { return DemoPad[i].pst.analogB; }
115 
DEMOPadGetErr(u32 i)116 static inline s8  DEMOPadGetErr(u32 i)
117     { return DemoPad[i].pst.err; }
118 
119 /*---------------------------------------------------------------------------*/
120 
121 #ifdef __cplusplus
122 }
123 #endif
124 
125 #endif // __DEMOPAD_H__
126 
127 /*===========================================================================*/
128