9 #include "../services/hid.h"
12 #define PAD_ANY_ID_MASK 0x1000100FFUL
48 #define padInitialize(_pad, ...) ({ \
49 const HidNpadIdType _pad_ids[] = { __VA_ARGS__ }; \
51 for (unsigned _pad_i = 0; _pad_i < (sizeof(_pad_ids)/sizeof(_pad_ids[0])); ++_pad_i) \
52 _pad_mask |= 1UL << (_pad_ids[_pad_i]); \
53 padInitializeWithMask((_pad), _pad_mask); \
94 return pad->active_handheld;
106 return pad->active_id_mask &
BIT(
id);
108 return pad->active_handheld;
120 return pad->style_set;
130 return pad->attributes;
150 return pad->buttons_cur;
160 return ~pad->buttons_old & pad->buttons_cur;
170 return pad->buttons_old & ~pad->buttons_cur;
181 return pad->sticks[i];
193 return pad->gc_triggers[i];
223 return r->counter == 0 ? r->button_mask : 0;
@ HidNpadAttribute_IsConnected
IsConnected.
Definition: hid.h:320
HidNpadIdType
HID controller IDs.
Definition: hid.h:214
@ HidNpadIdType_Handheld
Handheld mode controls.
Definition: hid.h:224
@ HidNpadIdType_No8
Player 8 controller.
Definition: hid.h:222
@ HidNpadIdType_No1
Player 1 controller.
Definition: hid.h:215
static u64 padGetButtonsUp(const PadState *pad)
Retrieves the set of buttons that are newly released.
Definition: pad.h:169
void padInitializeWithMask(PadState *pad, u64 mask)
Same as padInitialize, but taking a bitfield of controller IDs directly.
static bool padIsNpadActive(const PadState *pad, HidNpadIdType id)
Retrieves whether the specified controller is an active input source (i.e.
Definition: pad.h:104
void padConfigureInput(u32 max_players, u32 style_set)
Configures the input layout supported by the application.
void padUpdate(PadState *pad)
Updates pad state by reading from the controller input sources specified during initialization.
#define PAD_ANY_ID_MASK
Mask including all existing controller IDs.
Definition: pad.h:12
static u64 padGetButtons(const PadState *pad)
Retrieves the current set of pressed buttons across all selected controller input sources.
Definition: pad.h:149
static u32 padGetGcTriggerPos(const PadState *pad, unsigned i)
Retrieves the position of an analog trigger in a GameCube controller.
Definition: pad.h:192
static HidAnalogStickState padGetStickPos(const PadState *pad, unsigned i)
Retrieves the position of an analog stick in a controller.
Definition: pad.h:180
static bool padIsConnected(const PadState *pad)
Retrieves whether any of the selected controller input sources is connected.
Definition: pad.h:139
static u64 padRepeaterGetButtons(const PadRepeater *r)
Retrieves the set of buttons that are being repeated according to the parameters specified in padRepe...
Definition: pad.h:222
void padRepeaterUpdate(PadRepeater *r, u64 button_mask)
Updates pad repeat state.
static u32 padGetAttributes(const PadState *pad)
Retrieves the set of attributes reported by the system for the selected controller input sources.
Definition: pad.h:129
static void padRepeaterInitialize(PadRepeater *r, u16 delay, u16 repeat)
Initializes a PadRepeater object with the specified settings.
Definition: pad.h:202
static void padInitializeAny(PadState *pad)
Same as padInitialize, but including every single controller input source.
Definition: pad.h:68
#define padInitialize(_pad,...)
Initializes a PadState object to read input from one or more controller input sources.
Definition: pad.h:48
static bool padIsHandheld(const PadState *pad)
Retrieves whether HidNpadIdType_Handheld is an active input source (i.e.
Definition: pad.h:93
static u64 padGetButtonsDown(const PadState *pad)
Retrieves the set of buttons that are newly pressed.
Definition: pad.h:159
static u32 padGetStyleSet(const PadState *pad)
Retrieves the set of input styles supported by the selected controller input sources.
Definition: pad.h:119
static void padInitializeDefault(PadState *pad)
Same as padInitialize, but including HidNpadIdType_No1 and HidNpadIdType_Handheld.
Definition: pad.h:77
HidAnalogStickState.
Definition: hid.h:584
Pad button repeater state object.
Definition: pad.h:29
Pad state object.
Definition: pad.h:15
#define NX_INLINE
Flags a function as (always) inline.
Definition: types.h:86
#define BIT(n)
Creates a bitmask from a bit number.
Definition: types.h:54
uint64_t u64
64-bit unsigned integer.
Definition: types.h:22
uint8_t u8
8-bit unsigned integer.
Definition: types.h:19
uint16_t u16
16-bit unsigned integer.
Definition: types.h:20
#define NX_CONSTEXPR
Flags a function as constexpr in C++14 and above; or as (always) inline otherwise.
Definition: types.h:92
int32_t s32
32-bit signed integer.
Definition: types.h:27
uint32_t u32
32-bit unsigned integer.
Definition: types.h:21