Input Manager

From WiiUBrew
(Redirected from /dev/im)
Jump to navigation Jump to search

The Input Manager (IM) handles the Energy Saver functionality of the Wii U, including Screen Burn-In Reduction and Auto Power-Down (APD). The Input Manager is responsible for monitoring all user input devices and discerning the lack of user activity. If no activity is detected for the specified timeout, the Input Manager triggers video screen burn-in reduction (auto-dimming) or a shutdown request. Its IOSU device node for the RM is /dev/im. Its PPC shim is in coreinit.rpl.

wut reference: wut/include/coreinit/im.h

Process

The IM service thread checks the values set for the amount of time of inactivity that should pass before the screen is dimmed or the console automatically shuts down. vpadbase.rpl and padscore.rpl interact with /dev/im via the PPC shim to report on controller inputs. /dev/usb/btrm accesses IM to report on any SYNC button presses received from the Bluetooth firmware. When the SYNC button is pressed, IM broadcasts the event which is obtained by the HOME Menu and opens the SYNC menu.

User Inputs

The following sensors are evaluated by the Input Manager for screen burn-in reduction and auto power-down:

  • Wii U GamePad: Digital Buttons, Analog Sticks, Accelerometer, Gyroscope, Touch panel, NFC
  • Wii Remote: Digital Buttons, DPD, Accelerometer, Gyroscope, Attachments (Classic Controller, Nunchuk, Wii MotionPlus)
  • Wii Balance Board: Balance sensor
  • Wii U Pro Controller: Digital Buttons, Analog Sticks

Examples of sensors that are ignored:

  • Wii U GamePad: Camera, Microphone

And because these do not have IM implementation in their respective libraries...

  • USB microphone
  • Microphone (USB or wireless)
  • Nintendo 3DS

Auto Power-Down

The console can automatically shut down to conserve power. The timeout period for APD is specified in 1-hour increments, from 1 to 12 hours. APD can also be enabled and disabled on a system-wide basis. APD can be configured via System Settings or System Config Tool.

When a shutdown is called, a message is printed to the log:

------------------------
  AUTOMATIC POWER DOWN
------------------------

Then, a power button event is sent to /dev/pm with the system mode of PM_WIIRETURN.

Screen Burn-In Reduction

The console can automatically reduce the brightness of the TV and GamePad video output to prevent screen burn-in. Auto-dimming can be enabled and disabled on a system-wide basis in System Settings and System Config Tool, but the timeout period is not intended to be configured outside a developer environment. A dimming event is broadcast and obtained by avm.rpl which sends a dimming command to dc.rpl. The TV screen is reduced to 25% brightness, and the GamePad screen is reduced to 30% brightness (which is actually misworded in the SDK docs which says "reduced by" instead of "reduced to").

Reset

Kiosk consoles make use of a reset feature which will reboot the console after a specified inactive period. On other consoles, the setting is set to disabled.

The Kiosk Menu, which handles the launching of title on kiosk consoles, the reset period is set on each launch based on if the console is a 'full game unit' or not. This information is obtained by what type of Nintendo SES is connected.

NO_INPUT_RESET_SECONDS = 120 // 2 minutes
NO_INPUT_RESET_SECONDS_FULL_GAME = 300 // 5 minutes

Upon a reset, a reboot request will be sent to /dev/pm (Ioctl 0xE3).

History

The Input Manager was added to the Wii U's OS sometime between SDK 2.06.02 (Jul 2012) and 2.06.05 (Sep 2012), with initial reference to APD in June 2012 (SDK 2.06.00 or .01).

List of Functions (Ioctlv)

Command Name Description
0x1 IM_SetNvParameter Sets non-volatile IM parameters in im_cfg.xml.
0x2 IM_SetParameter
0x3 IM_GetParameter
0x4 IM_SetDeviceState

IM_SetDeviceStateEx

0x5 IM_GetEventNotify
0x6 IM_CancelGetEventNotify
0x7 IM_GetHomeButtonParams
0x8 IM_GetTimerRemaining
0x9 IM_GetNvParameter Gets non-volatile IM parameters in im_cfg.xml
0xA IM_SetTimerElpasedSeconds
0xB IM_SetHomeButtonParams

Interestingly, for the access of non-volatile parameters in im_cfg.xml, the user is not required to access this directly via /dev/usr_cfg since /dev/im acts as a nested shim in this instance.

Types, Structs & Defines

IMPadType

typedef enum {
   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;

IMDeviceState

typedef enum {
   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;

IMParameter

typedef enum
{
   IM_PARAMETER_INACTIVE_SECONDS = 0,
   IM_PARAMETER_DIM_ENABLED      = 1,
   IM_PARAMETER_DIM_PERIOD       = 2,
   IM_PARAMETER_APD_ENABLED      = 3,
   IM_PARAMETER_APD_PERIOD       = 4,
   IM_PARAMETER_RESET_ENABLE     = 5,
   IM_PARAMETER_RESET_SECONDS    = 6,
   IM_PARAMETER_POWER_OFF_ENABLE = 7,
   IM_PARAMETER_APD_OCCURED      = 8,
   IM_PARAMETER_DIM_ENABLE_TV    = 9,
   IM_PARAMETER_DIM_ENABLE_DRC   = 10,
   IM_PARAMETER_MAX              = 11,
} IMParameter;

IMTimer

typedef enum
{
   IM_TIMER_DIM = 0,
   IM_TIMER_APD = 1,
} IMTimer;

IMEvent

typedef enum
{
   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;

IMParameters

typedef struct {
    u32 inactive_seconds;
    u32 dim_enable;
    u32 dim_seconds;
    u32 apd_enable;
    u32 apd_seconds;

} IMParameters;

IMHomeButtonParams

typedef struct {
   //! The controller type which pressed the home button
   IMPadType type;
   //! The controller index which pressed the home button
   s32 index;
} IMHomeButtonParams;

IMDeviceStateEx

typedef struct {
   IMDeviceState state;
   IMHomeButtonParams params;
} IMDeviceStateEx;