From 8275311fec7996fed0135f3fb10cf8474bdd9fe5 Mon Sep 17 00:00:00 2001 From: GaryOderNichts <12049776+GaryOderNichts@users.noreply.github.com> Date: Thu, 30 Mar 2023 20:41:53 +0200 Subject: [PATCH] Separate vpadbase from vpad --- include/vpad/input.h | 193 +------------- include/vpadbase/base.h | 237 ++++++++++++++++++ include/vpadbase/vpadbase.dox | 5 + libraries/libirc/include/irc/irc.h | 2 +- libraries/libirc/src/cdc.c | 2 +- .../test_compile_headers_list.h | 1 + 6 files changed, 246 insertions(+), 194 deletions(-) create mode 100644 include/vpadbase/base.h create mode 100644 include/vpadbase/vpadbase.dox diff --git a/include/vpad/input.h b/include/vpad/input.h index 281cfe621..2b5415c9e 100644 --- a/include/vpad/input.h +++ b/include/vpad/input.h @@ -1,5 +1,6 @@ #pragma once #include +#include /** * \defgroup vpad_input VPAD Input @@ -79,15 +80,6 @@ typedef enum VPADButtons VPAD_STICK_L_EMULATION_DOWN = 0x08000000, } VPADButtons; -//! Wii U GamePad channel. -typedef enum VPADChan -{ - //! Channel 0. - VPAD_CHAN_0 = 0, - //! Channel 1. - VPAD_CHAN_1 = 1, -} VPADChan; - //! Touch pad validity. typedef enum VPADTouchPadValidity { @@ -323,13 +315,6 @@ WUT_CHECK_OFFSET(VPADStatus, 0xA2, micStatus); WUT_CHECK_OFFSET(VPADStatus, 0xA3, slideVolumeEx); WUT_CHECK_SIZE(VPADStatus, 0xAC); -typedef enum { - //! Indicates that there is pending data which can be received - VPAD_IRC_STATUS_FLAG_HAS_DATA = 1, - //! Indicates that another device is connected - VPAD_IRC_STATUS_FLAG_CONNECTED = 2, -} VPADIRCStatusFlags; - typedef void(*VPADSamplingCallback)(VPADChan chan); /** @@ -481,40 +466,6 @@ VPADGetTPCalibratedPointEx(VPADChan chan, VPADTouchData *calibratedData, const VPADTouchData *uncalibratedData); -/** - * Return a count representing the amount of time left for the given Gamepad's - * rumble pattern. - * - * \note - * Retail Wii U systems have a single Gamepad on \link VPADChan::VPAD_CHAN_0 - * VPAD_CHAN_0. \endlink - * - * \param chan - * Denotes which channel to get the rumble time from. - */ -int32_t -VPADBASEGetMotorOnRemainingCount(VPADChan chan); - -/** - * Set a count representing the amount of time left for the given Gamepad's - * rumble pattern. - * - * \note - * Retail Wii U systems have a single Gamepad on \link VPADChan::VPAD_CHAN_0 - * VPAD_CHAN_0. \endlink - * - * \param chan - * Denotes which channel to set the rumble count for. - * - * \param counter - * The value of the new rumble count. - * - * - */ -int32_t -VPADBASESetMotorOnRemainingCount(VPADChan chan, - int32_t counter); - void VPADSetAccParam(VPADChan chan, float playRadius, @@ -860,120 +811,6 @@ int32_t VPADGetLcdMode(VPADChan chan, VPADLcdMode *outLcdMode); -void -VPADBASESetSensorBarSetting(VPADChan chan, - int8_t setting); - -void -VPADBASEGetSensorBarSetting(VPADChan chan, - int8_t *outSetting); - -/** - * Get the headphone status. - * - * \note - * Retail Wii U systems have a single Gamepad on \link VPADChan::VPAD_CHAN_0 - * VPAD_CHAN_0. \endlink - * - * \param chan - * The channel of the Gamepad to get the headphone status from. - * - * \returns - * Returns 1 if headphones are connected, 0 otherwise. - */ -int32_t -VPADBASEGetHeadphoneStatus(VPADChan chan); - -/** - * Get the controller mode. - * - * \note - * Retail Wii U systems have a single Gamepad on \link VPADChan::VPAD_CHAN_0 - * VPAD_CHAN_0. \endlink - * - * \param chan - * The channel of the Gamepad to get the controller mode from. - * - * \param mode - * Pointer to write a value of the controller mode into. - */ -void -VPADBASEGetGameControllerMode(VPADChan chan, - int32_t* mode); - -/** - * Set the controller mode. - * - * \note - * Retail Wii U systems have a single Gamepad on \link VPADChan::VPAD_CHAN_0 - * VPAD_CHAN_0. \endlink - * - * \param chan - * The channel of the Gamepad to set the controller mode to. - * - * \param mode - * Any non-zero mode will turn off the display, like the "Display Off" button under Controller Settings. - * Inputs are not disabled. - */ -void -VPADBASESetGameControllerMode(VPADChan chan, - int32_t mode); - -/** - * Get the POWER button press status. - * - * \note - * Retail Wii U systems have a single Gamepad on \link VPADChan::VPAD_CHAN_0 - * VPAD_CHAN_0. \endlink - * - * \param chan - * The channel of the Gamepad to get the POWER button press status from. - * - * \param tick - * The value given by \link OSGetTick \endlink when the button was pressed. - * - * \param status - * The status is set to 0 if the POWER button is not pressed. - */ -void -VPADBASEGetPowerButtonPressStatus(VPADChan chan, - uint32_t* tick, - uint32_t *status); - -/** - * Set the POWER button press status. - * - * \param chan - * The channel of the Gamepad to set the POWER button press status to. - * - * \param tick - * The tick value to set. - * - * \param status - * The status to set. - */ -void -VPADBASESetPowerButtonPressStatus(VPADChan chan, - uint32_t tick, - uint32_t status); - -/** - * Set the POWER button mode. - * - * \param chan - * The channel of the Gamepad to set the POWER button disable mode to. - * - * \param mode - * Set to 0 to enable and set to 1 to disable. - * - * \sa - * - \link VPADDisablePowerButton \endlink - * - \link VPADEnablePowerButton \endlink - */ -void -VPADBASESetPowerButtonDisableMode(VPADChan chan, - uint32_t mode); - /** * Turn the given Gamepad's sensor bar on or off. Enabling the sensor bar allows * any Wii Remote to position itself relative to the GamePad. @@ -999,35 +836,7 @@ VPADSamplingCallback VPADSetSamplingCallback(VPADChan chan, VPADSamplingCallback callback); -/** - * Checks if VPADBASE is initialized. - * - * \returns - * \c TRUE if initialized. - */ -BOOL -VPADBASEIsInit(); -/** - * Clear pending IRC events. - * - * \param chan - * The channel of the Gamepad. - */ -void -VPADBASEClearIRCEvent(VPADChan chan); - -/** - * Get the current IRC status. - * - * \param chan - * The channel of the Gamepad. - * - * \returns - * The current status flags (see \link VPADIRCStatusFlags \endlink). - */ -uint32_t -VPADBASEGetIRCStatus(VPADChan chan); #ifdef __cplusplus } diff --git a/include/vpadbase/base.h b/include/vpadbase/base.h new file mode 100644 index 000000000..c6ecb3dd0 --- /dev/null +++ b/include/vpadbase/base.h @@ -0,0 +1,237 @@ +#pragma once +#include + +/** + * \defgroup vpadbase_base VPAD Base + * \ingroup vpadbase + * @{ + */ + +#ifdef __cplusplus +extern "C" { +#endif + +//! Wii U GamePad channel. +typedef enum VPADChan +{ + //! Channel 0. + VPAD_CHAN_0 = 0, + //! Channel 1. + VPAD_CHAN_1 = 1, +} VPADChan; + +typedef enum +{ + //! Indicates that there is pending data which can be received + VPAD_IRC_STATUS_FLAG_HAS_DATA = 1, + //! Indicates that another device is connected + VPAD_IRC_STATUS_FLAG_CONNECTED = 2, +} VPADIRCStatusFlags; + +/** + * Initializes the VPADBASE library for use. + * + * \note + * This is internally called by vpad and does not need to be called manually. + * + * \sa + * - \link VPADBASEShutdown \endlink + */ +void +VPADBASEInit(); + +/** + * Deinitializes the VPADBASE library. + * + * \note + * This is internally called by vpad and does not need to be called manually. + * + * \sa + * - \link VPADBASEInit \endlink + */ +void +VPADBASEShutdown(); + +/** + * Checks if VPADBASE is initialized. + * + * \returns + * \c TRUE if initialized. + */ +BOOL +VPADBASEIsInit(); + +/** + * Return a count representing the amount of time left for the given Gamepad's + * rumble pattern. + * + * \note + * Retail Wii U systems have a single Gamepad on \link VPADChan::VPAD_CHAN_0 + * VPAD_CHAN_0. \endlink + * + * \param chan + * Denotes which channel to get the rumble time from. + */ +int32_t +VPADBASEGetMotorOnRemainingCount(VPADChan chan); + +/** + * Set a count representing the amount of time left for the given Gamepad's + * rumble pattern. + * + * \note + * Retail Wii U systems have a single Gamepad on \link VPADChan::VPAD_CHAN_0 + * VPAD_CHAN_0. \endlink + * + * \param chan + * Denotes which channel to set the rumble count for. + * + * \param counter + * The value of the new rumble count. + * + * + */ +int32_t +VPADBASESetMotorOnRemainingCount(VPADChan chan, + int32_t counter); + +void +VPADBASESetSensorBarSetting(VPADChan chan, + int8_t setting); + +void +VPADBASEGetSensorBarSetting(VPADChan chan, + int8_t *outSetting); + +/** + * Get the headphone status. + * + * \note + * Retail Wii U systems have a single Gamepad on \link VPADChan::VPAD_CHAN_0 + * VPAD_CHAN_0. \endlink + * + * \param chan + * The channel of the Gamepad to get the headphone status from. + * + * \returns + * Returns 1 if headphones are connected, 0 otherwise. + */ +int32_t +VPADBASEGetHeadphoneStatus(VPADChan chan); + +/** + * Get the controller mode. + * + * \note + * Retail Wii U systems have a single Gamepad on \link VPADChan::VPAD_CHAN_0 + * VPAD_CHAN_0. \endlink + * + * \param chan + * The channel of the Gamepad to get the controller mode from. + * + * \param mode + * Pointer to write a value of the controller mode into. + */ +void +VPADBASEGetGameControllerMode(VPADChan chan, + int32_t *mode); + +/** + * Set the controller mode. + * + * \note + * Retail Wii U systems have a single Gamepad on \link VPADChan::VPAD_CHAN_0 + * VPAD_CHAN_0. \endlink + * + * \param chan + * The channel of the Gamepad to set the controller mode to. + * + * \param mode + * Any non-zero mode will turn off the display, like the "Display Off" button under Controller Settings. + * Inputs are not disabled. + */ +void +VPADBASESetGameControllerMode(VPADChan chan, + int32_t mode); + +/** + * Get the POWER button press status. + * + * \note + * Retail Wii U systems have a single Gamepad on \link VPADChan::VPAD_CHAN_0 + * VPAD_CHAN_0. \endlink + * + * \param chan + * The channel of the Gamepad to get the POWER button press status from. + * + * \param tick + * The value given by \link OSGetTick \endlink when the button was pressed. + * + * \param status + * The status is set to 0 if the POWER button is not pressed. + */ +void +VPADBASEGetPowerButtonPressStatus(VPADChan chan, + uint32_t *tick, + uint32_t *status); + +/** + * Set the POWER button press status. + * + * \param chan + * The channel of the Gamepad to set the POWER button press status to. + * + * \param tick + * The tick value to set. + * + * \param status + * The status to set. + */ +void +VPADBASESetPowerButtonPressStatus(VPADChan chan, + uint32_t tick, + uint32_t status); + +/** + * Set the POWER button mode. + * + * \param chan + * The channel of the Gamepad to set the POWER button disable mode to. + * + * \param mode + * Set to 0 to enable and set to 1 to disable. + * + * \sa + * - \link VPADDisablePowerButton \endlink + * - \link VPADEnablePowerButton \endlink + */ +void +VPADBASESetPowerButtonDisableMode(VPADChan chan, + uint32_t mode); + +/** + * Clear pending IRC events. + * + * \param chan + * The channel of the Gamepad. + */ +void +VPADBASEClearIRCEvent(VPADChan chan); + +/** + * Get the current IRC status. + * + * \param chan + * The channel of the Gamepad. + * + * \returns + * The current status flags (see \link VPADIRCStatusFlags \endlink). + */ +VPADIRCStatusFlags +VPADBASEGetIRCStatus(VPADChan chan); + +#ifdef __cplusplus +} +#endif + +/** @} */ diff --git a/include/vpadbase/vpadbase.dox b/include/vpadbase/vpadbase.dox new file mode 100644 index 000000000..fb4e5c5d2 --- /dev/null +++ b/include/vpadbase/vpadbase.dox @@ -0,0 +1,5 @@ +/** + * \defgroup vpadbase vpadbase + * + * Wii U Gamepad base library. + */ diff --git a/libraries/libirc/include/irc/irc.h b/libraries/libirc/include/irc/irc.h index 8d2d76412..925c3d68c 100644 --- a/libraries/libirc/include/irc/irc.h +++ b/libraries/libirc/include/irc/irc.h @@ -1,6 +1,6 @@ #pragma once #include -#include +#include #include /** diff --git a/libraries/libirc/src/cdc.c b/libraries/libirc/src/cdc.c index a605f2c02..678824712 100644 --- a/libraries/libirc/src/cdc.c +++ b/libraries/libirc/src/cdc.c @@ -1,7 +1,7 @@ #include "irc/cdc.h" #include -#include +#include #include diff --git a/tests/test_compile_headers_common/test_compile_headers_list.h b/tests/test_compile_headers_common/test_compile_headers_list.h index 895d17156..d11c609a6 100644 --- a/tests/test_compile_headers_common/test_compile_headers_list.h +++ b/tests/test_compile_headers_common/test_compile_headers_list.h @@ -147,6 +147,7 @@ #include #include #include +#include #include #include #include