Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

coreinit/im: Add IM_SetDeviceState and missing IMEvents #343

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 64 additions & 9 deletions include/coreinit/im.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,28 @@ extern "C" {
typedef struct IMRequest IMRequest;
typedef struct IMHomeButtonParams IMHomeButtonParams;
typedef struct IMParameters IMParameters;
typedef struct IMDeviceStateEx IMDeviceStateEx;
typedef uint32_t IMEventMask;

typedef enum IMPadType
{
IM_PAD_TYPE_NONE = 0,
IM_PAD_TYPE_WII_REMOTE = 1,
IM_PAD_TYPE_WIIU_PRO_CONTROLLER = 2,
IM_PAD_TYPE_WII_REMOTE_EXTENSION = 3,
IM_PAD_TYPE_WIIU_GAMEPAD = 4,
} IMPadType;

typedef enum IMDeviceState
{
IM_DEVICE_STATE_CLEAR = 0,
IM_DEVICE_STATE_INACTIVE = 1,
IM_DEVICE_STATE_ACTIVE = 2,
IM_DEVICE_STATE_HOME = 3,
IM_DEVICE_STATE_POWER = 4,
IM_DEVICE_STATE_SYNC = 5,
} IMDeviceState;

struct WUT_PACKED IMRequest
{
uint8_t args[0x80];
Expand All @@ -42,8 +62,13 @@ WUT_CHECK_SIZE(IMRequest, 0xB4);

struct IMHomeButtonParams
{
WUT_UNKNOWN_BYTES(0x8);
//! The controller type which pressed the home button
IMPadType type;
//! The controller index which pressed the home button
int32_t index;
};
WUT_CHECK_OFFSET(IMHomeButtonParams, 0x0, type);
WUT_CHECK_OFFSET(IMHomeButtonParams, 0x4, index);
WUT_CHECK_SIZE(IMHomeButtonParams, 0x8);

struct IMParameters
Expand All @@ -61,6 +86,15 @@ WUT_CHECK_OFFSET(IMParameters, 0x0C, apdEnabled);
WUT_CHECK_OFFSET(IMParameters, 0x10, apdPeriod);
WUT_CHECK_SIZE(IMParameters, 0x14);

struct IMDeviceStateEx
{
IMDeviceState state;
IMHomeButtonParams params;
};
WUT_CHECK_OFFSET(IMDeviceStateEx, 0x0, state);
WUT_CHECK_OFFSET(IMDeviceStateEx, 0x4, params);
WUT_CHECK_SIZE(IMDeviceStateEx, 0xC);

typedef enum IMParameter
{
IM_PARAMETER_INACTIVE_SECONDS = 0,
Expand All @@ -85,14 +119,21 @@ typedef enum IMTimer

typedef enum IMEvent
{
IM_EVENT_UNK1 = 1 << 1,
IM_EVENT_UNK2 = 1 << 2,
IM_EVENT_UNK3 = 1 << 3,
IM_EVENT_APD = 1 << 4,
IM_EVENT_UNK5 = 1 << 5,
IM_EVENT_UNK6 = 1 << 6,
IM_EVENT_SYNC = 1 << 7,
IM_EVENT_UNK8 = 1 << 8,
IM_EVENT_ACTIVE = 1 << 0,
IM_EVENT_INACTIVE = 1 << 1,
IM_EVENT_DIM = 1 << 2,
IM_EVENT_UNDIM = 1 << 3,
//! Automatic power down
IM_EVENT_APD = 1 << 4,
//! Controller power button was pressed
IM_EVENT_POWER = 1 << 5,
//! Home button was pressed
IM_EVENT_HOME = 1 << 6,
//! Console sync button was pressed
IM_EVENT_SYNC = 1 << 7,
IM_EVENT_RESET = 1 << 8,
//! Event notify was cancelled
IM_EVENT_CANCELLED = 1 << 31,
} IMEvent;

IOSHandle
Expand Down Expand Up @@ -172,6 +213,20 @@ IM_CancelGetEventNotify(IOSHandle handle,
IOSAsyncCallbackFn asyncCallback,
void *asyncCallbackContext);

IOSError
IM_SetDeviceState(IOSHandle handle,
IMRequest *request,
IMDeviceState state,
IOSAsyncCallbackFn asyncCallback,
void *asyncCallbackContext);

IOSError
IM_SetDeviceStateEx(IOSHandle handle,
IMRequest *request,
IMDeviceStateEx *state,
IOSAsyncCallbackFn asyncCallback,
void *asyncCallbackContext);

#ifdef __cplusplus
}
#endif
Expand Down