libnx
Data Structures | Macros | Enumerations | Functions
hid.h File Reference

Human input device (hid) service IPC wrapper. More...

#include <assert.h>
#include "../types.h"
#include "../services/sm.h"

Go to the source code of this file.

Data Structures

struct  touchPosition
 
struct  JoystickPosition
 
struct  MousePosition
 
struct  HidTouchScreenHeader
 
struct  HidTouchScreenEntryHeader
 
struct  HidTouchScreenEntryTouch
 
struct  HidTouchScreenEntry
 
struct  HidTouchScreen
 
struct  HidMouseHeader
 
struct  HidMouseEntry
 
struct  HidMouse
 
struct  HidKeyboardHeader
 
struct  HidKeyboardEntry
 
struct  HidKeyboard
 
struct  HidControllerMAC
 
struct  HidControllerHeader
 
struct  HidControllerLayoutHeader
 
struct  HidControllerInputEntry
 
struct  HidControllerLayout
 
struct  HidController
 
struct  HidSharedMemory
 
struct  HidVibrationDeviceInfo
 
struct  HidVibrationValue
 

Macros

#define JOYSTICK_MAX   (0x8000)
 
#define JOYSTICK_MIN   (-0x8000)
 

Enumerations

enum  HidMouseButton {
  MOUSE_LEFT = (1U<<( 0 )),
  MOUSE_RIGHT = (1U<<( 1 )),
  MOUSE_MIDDLE = (1U<<( 2 )),
  MOUSE_FORWARD = (1U<<( 3 )),
  MOUSE_BACK = (1U<<( 4 ))
}
 
enum  HidKeyboardModifier {
  KBD_MOD_LCTRL = (1U<<( 0 )),
  KBD_MOD_LSHIFT = (1U<<( 1 )),
  KBD_MOD_LALT = (1U<<( 2 )),
  KBD_MOD_LMETA = (1U<<( 3 )),
  KBD_MOD_RCTRL = (1U<<( 4 )),
  KBD_MOD_RSHIFT = (1U<<( 5 )),
  KBD_MOD_RALT = (1U<<( 6 )),
  KBD_MOD_RMETA = (1U<<( 7 )),
  KBD_MOD_CAPSLOCK = (1U<<( 8 )),
  KBD_MOD_SCROLLLOCK = (1U<<( 9 )),
  KBD_MOD_NUMLOCK = (1U<<( 10 ))
}
 
enum  HidKeyboardScancode {
  KBD_NONE = 0x00,
  KBD_ERR_OVF = 0x01,
  KBD_A = 0x04,
  KBD_B = 0x05,
  KBD_C = 0x06,
  KBD_D = 0x07,
  KBD_E = 0x08,
  KBD_F = 0x09,
  KBD_G = 0x0a,
  KBD_H = 0x0b,
  KBD_I = 0x0c,
  KBD_J = 0x0d,
  KBD_K = 0x0e,
  KBD_L = 0x0f,
  KBD_M = 0x10,
  KBD_N = 0x11,
  KBD_O = 0x12,
  KBD_P = 0x13,
  KBD_Q = 0x14,
  KBD_R = 0x15,
  KBD_S = 0x16,
  KBD_T = 0x17,
  KBD_U = 0x18,
  KBD_V = 0x19,
  KBD_W = 0x1a,
  KBD_X = 0x1b,
  KBD_Y = 0x1c,
  KBD_Z = 0x1d,
  KBD_1 = 0x1e,
  KBD_2 = 0x1f,
  KBD_3 = 0x20,
  KBD_4 = 0x21,
  KBD_5 = 0x22,
  KBD_6 = 0x23,
  KBD_7 = 0x24,
  KBD_8 = 0x25,
  KBD_9 = 0x26,
  KBD_0 = 0x27,
  KBD_ENTER = 0x28,
  KBD_ESC = 0x29,
  KBD_BACKSPACE = 0x2a,
  KBD_TAB = 0x2b,
  KBD_SPACE = 0x2c,
  KBD_MINUS = 0x2d,
  KBD_EQUAL = 0x2e,
  KBD_LEFTBRACE = 0x2f,
  KBD_RIGHTBRACE = 0x30,
  KBD_BACKSLASH = 0x31,
  KBD_HASHTILDE = 0x32,
  KBD_SEMICOLON = 0x33,
  KBD_APOSTROPHE = 0x34,
  KBD_GRAVE = 0x35,
  KBD_COMMA = 0x36,
  KBD_DOT = 0x37,
  KBD_SLASH = 0x38,
  KBD_CAPSLOCK = 0x39,
  KBD_F1 = 0x3a,
  KBD_F2 = 0x3b,
  KBD_F3 = 0x3c,
  KBD_F4 = 0x3d,
  KBD_F5 = 0x3e,
  KBD_F6 = 0x3f,
  KBD_F7 = 0x40,
  KBD_F8 = 0x41,
  KBD_F9 = 0x42,
  KBD_F10 = 0x43,
  KBD_F11 = 0x44,
  KBD_F12 = 0x45,
  KBD_SYSRQ = 0x46,
  KBD_SCROLLLOCK = 0x47,
  KBD_PAUSE = 0x48,
  KBD_INSERT = 0x49,
  KBD_HOME = 0x4a,
  KBD_PAGEUP = 0x4b,
  KBD_DELETE = 0x4c,
  KBD_END = 0x4d,
  KBD_PAGEDOWN = 0x4e,
  KBD_RIGHT = 0x4f,
  KBD_LEFT = 0x50,
  KBD_DOWN = 0x51,
  KBD_UP = 0x52,
  KBD_NUMLOCK = 0x53,
  KBD_KPSLASH = 0x54,
  KBD_KPASTERISK = 0x55,
  KBD_KPMINUS = 0x56,
  KBD_KPPLUS = 0x57,
  KBD_KPENTER = 0x58,
  KBD_KP1 = 0x59,
  KBD_KP2 = 0x5a,
  KBD_KP3 = 0x5b,
  KBD_KP4 = 0x5c,
  KBD_KP5 = 0x5d,
  KBD_KP6 = 0x5e,
  KBD_KP7 = 0x5f,
  KBD_KP8 = 0x60,
  KBD_KP9 = 0x61,
  KBD_KP0 = 0x62,
  KBD_KPDOT = 0x63,
  KBD_102ND = 0x64,
  KBD_COMPOSE = 0x65,
  KBD_POWER = 0x66,
  KBD_KPEQUAL = 0x67,
  KBD_F13 = 0x68,
  KBD_F14 = 0x69,
  KBD_F15 = 0x6a,
  KBD_F16 = 0x6b,
  KBD_F17 = 0x6c,
  KBD_F18 = 0x6d,
  KBD_F19 = 0x6e,
  KBD_F20 = 0x6f,
  KBD_F21 = 0x70,
  KBD_F22 = 0x71,
  KBD_F23 = 0x72,
  KBD_F24 = 0x73,
  KBD_OPEN = 0x74,
  KBD_HELP = 0x75,
  KBD_PROPS = 0x76,
  KBD_FRONT = 0x77,
  KBD_STOP = 0x78,
  KBD_AGAIN = 0x79,
  KBD_UNDO = 0x7a,
  KBD_CUT = 0x7b,
  KBD_COPY = 0x7c,
  KBD_PASTE = 0x7d,
  KBD_FIND = 0x7e,
  KBD_MUTE = 0x7f,
  KBD_VOLUMEUP = 0x80,
  KBD_VOLUMEDOWN = 0x81,
  KBD_CAPSLOCK_ACTIVE = 0x82,
  KBD_NUMLOCK_ACTIVE = 0x83,
  KBD_SCROLLLOCK_ACTIVE = 0x84,
  KBD_KPCOMMA = 0x85,
  KBD_KPLEFTPAREN = 0xb6,
  KBD_KPRIGHTPAREN = 0xb7,
  KBD_LEFTCTRL = 0xe0,
  KBD_LEFTSHIFT = 0xe1,
  KBD_LEFTALT = 0xe2,
  KBD_LEFTMETA = 0xe3,
  KBD_RIGHTCTRL = 0xe4,
  KBD_RIGHTSHIFT = 0xe5,
  KBD_RIGHTALT = 0xe6,
  KBD_RIGHTMETA = 0xe7,
  KBD_MEDIA_PLAYPAUSE = 0xe8,
  KBD_MEDIA_STOPCD = 0xe9,
  KBD_MEDIA_PREVIOUSSONG = 0xea,
  KBD_MEDIA_NEXTSONG = 0xeb,
  KBD_MEDIA_EJECTCD = 0xec,
  KBD_MEDIA_VOLUMEUP = 0xed,
  KBD_MEDIA_VOLUMEDOWN = 0xee,
  KBD_MEDIA_MUTE = 0xef,
  KBD_MEDIA_WWW = 0xf0,
  KBD_MEDIA_BACK = 0xf1,
  KBD_MEDIA_FORWARD = 0xf2,
  KBD_MEDIA_STOP = 0xf3,
  KBD_MEDIA_FIND = 0xf4,
  KBD_MEDIA_SCROLLUP = 0xf5,
  KBD_MEDIA_SCROLLDOWN = 0xf6,
  KBD_MEDIA_EDIT = 0xf7,
  KBD_MEDIA_SLEEP = 0xf8,
  KBD_MEDIA_COFFEE = 0xf9,
  KBD_MEDIA_REFRESH = 0xfa,
  KBD_MEDIA_CALC = 0xfb
}
 
enum  HidControllerType {
  TYPE_PROCONTROLLER = (1U<<( 0 )),
  TYPE_HANDHELD = (1U<<( 1 )),
  TYPE_JOYCON_PAIR = (1U<<( 2 )),
  TYPE_JOYCON_LEFT = (1U<<( 3 )),
  TYPE_JOYCON_RIGHT = (1U<<( 4 ))
}
 
enum  HidControllerLayoutType {
  LAYOUT_PROCONTROLLER = 0,
  LAYOUT_HANDHELD = 1,
  LAYOUT_SINGLE = 2,
  LAYOUT_LEFT = 3,
  LAYOUT_RIGHT = 4,
  LAYOUT_DEFAULT_DIGITAL = 5,
  LAYOUT_DEFAULT = 6
}
 
enum  HidControllerColorDescription { COLORS_NONEXISTENT = (1U<<( 1 )) }
 
enum  HidControllerKeys {
  KEY_A = (1U<<( 0 )),
  KEY_B = (1U<<( 1 )),
  KEY_X = (1U<<( 2 )),
  KEY_Y = (1U<<( 3 )),
  KEY_LSTICK = (1U<<( 4 )),
  KEY_RSTICK = (1U<<( 5 )),
  KEY_L = (1U<<( 6 )),
  KEY_R = (1U<<( 7 )),
  KEY_ZL = (1U<<( 8 )),
  KEY_ZR = (1U<<( 9 )),
  KEY_PLUS = (1U<<( 10 )),
  KEY_MINUS = (1U<<( 11 )),
  KEY_DLEFT = (1U<<( 12 )),
  KEY_DUP = (1U<<( 13 )),
  KEY_DRIGHT = (1U<<( 14 )),
  KEY_DDOWN = (1U<<( 15 )),
  KEY_LSTICK_LEFT = (1U<<( 16 )),
  KEY_LSTICK_UP = (1U<<( 17 )),
  KEY_LSTICK_RIGHT = (1U<<( 18 )),
  KEY_LSTICK_DOWN = (1U<<( 19 )),
  KEY_RSTICK_LEFT = (1U<<( 20 )),
  KEY_RSTICK_UP = (1U<<( 21 )),
  KEY_RSTICK_RIGHT = (1U<<( 22 )),
  KEY_RSTICK_DOWN = (1U<<( 23 )),
  KEY_SL = (1U<<( 24 )),
  KEY_SR = (1U<<( 25 )),
  KEY_TOUCH = (1U<<( 26 )),
  KEY_JOYCON_RIGHT = (1U<<( 0 )),
  KEY_JOYCON_DOWN = (1U<<( 1 )),
  KEY_JOYCON_UP = (1U<<( 2 )),
  KEY_JOYCON_LEFT = (1U<<( 3 )),
  KEY_UP = KEY_DUP | KEY_LSTICK_UP | KEY_RSTICK_UP,
  KEY_DOWN = KEY_DDOWN | KEY_LSTICK_DOWN | KEY_RSTICK_DOWN,
  KEY_LEFT = KEY_DLEFT | KEY_LSTICK_LEFT | KEY_RSTICK_LEFT,
  KEY_RIGHT = KEY_DRIGHT | KEY_LSTICK_RIGHT | KEY_RSTICK_RIGHT
}
 
enum  HidControllerJoystick {
  JOYSTICK_LEFT = 0,
  JOYSTICK_RIGHT = 1,
  JOYSTICK_NUM_STICKS = 2
}
 
enum  HidControllerConnectionState {
  CONTROLLER_STATE_CONNECTED = (1U<<( 0 )),
  CONTROLLER_STATE_WIRED = (1U<<( 1 ))
}
 
enum  HidControllerID {
  CONTROLLER_PLAYER_1 = 0,
  CONTROLLER_PLAYER_2 = 1,
  CONTROLLER_PLAYER_3 = 2,
  CONTROLLER_PLAYER_4 = 3,
  CONTROLLER_PLAYER_5 = 4,
  CONTROLLER_PLAYER_6 = 5,
  CONTROLLER_PLAYER_7 = 6,
  CONTROLLER_PLAYER_8 = 7,
  CONTROLLER_HANDHELD = 8,
  CONTROLLER_UNKNOWN = 9,
  CONTROLLER_P1_AUTO = 10
}
 

Functions

Result hidInitialize (void)
 
void hidExit (void)
 
void hidReset (void)
 
ServicehidGetSessionService (void)
 
void * hidGetSharedmemAddr (void)
 
void hidSetControllerLayout (HidControllerID id, HidControllerLayoutType layoutType)
 
HidControllerLayoutType hidGetControllerLayout (HidControllerID id)
 
void hidScanInput (void)
 
u64 hidKeysHeld (HidControllerID id)
 
u64 hidKeysDown (HidControllerID id)
 
u64 hidKeysUp (HidControllerID id)
 
u64 hidMouseButtonsHeld (void)
 
u64 hidMouseButtonsDown (void)
 
u64 hidMouseButtonsUp (void)
 
void hidMouseRead (MousePosition *pos)
 
bool hidKeyboardModifierHeld (HidKeyboardModifier modifier)
 
bool hidKeyboardModifierDown (HidKeyboardModifier modifier)
 
bool hidKeyboardModifierUp (HidKeyboardModifier modifier)
 
bool hidKeyboardHeld (HidKeyboardScancode key)
 
bool hidKeyboardDown (HidKeyboardScancode key)
 
bool hidKeyboardUp (HidKeyboardScancode key)
 
u32 hidTouchCount (void)
 
void hidTouchRead (touchPosition *pos, u32 point_id)
 
void hidJoystickRead (JoystickPosition *pos, HidControllerID id, HidControllerJoystick stick)
 
bool hidGetHandheldMode (void)
 This can be used to check what CONTROLLER_P1_AUTO uses. More...
 
Result hidSetNpadJoyAssignmentModeSingleByDefault (HidControllerID id)
 Use this if you want to use a single joy-con as a dedicated CONTROLLER_PLAYER_*. More...
 
Result hidSetNpadJoyAssignmentModeDual (HidControllerID id)
 Use this if you want to use a pair of joy-cons as a single CONTROLLER_PLAYER_*. More...
 
Result hidInitializeVibrationDevices (u32 *VibrationDeviceHandles, size_t total_handles, HidControllerID id, HidControllerType type)
 
Result hidGetVibrationDeviceInfo (u32 *VibrationDeviceHandle, HidVibrationDeviceInfo *VibrationDeviceInfo)
 Gets HidVibrationDeviceInfo for the specified VibrationDeviceHandle.
 
Result hidSendVibrationValue (u32 *VibrationDeviceHandle, HidVibrationValue *VibrationValue)
 Send the VibrationValue to the specified VibrationDeviceHandle.
 
Result hidGetActualVibrationValue (u32 *VibrationDeviceHandle, HidVibrationValue *VibrationValue)
 Gets the current HidVibrationValue for the specified VibrationDeviceHandle.
 
Result hidPermitVibration (bool flag)
 Sets whether vibration is allowed, this also affects the config displayed by System Settings.
 
Result hidIsVibrationPermitted (bool *flag)
 Gets whether vibration is allowed.
 
Result hidSendVibrationValues (u32 *VibrationDeviceHandles, HidVibrationValue *VibrationValues, size_t count)
 Send VibrationValues[index] to VibrationDeviceHandles[index], where count is the number of entries in the VibrationDeviceHandles/VibrationValues arrays.
 

Detailed Description

Human input device (hid) service IPC wrapper.

Author
shinyquagsire23
yellows8

Enumeration Type Documentation

Enumerator
KEY_A 

A.

KEY_B 

B.

KEY_X 

X.

KEY_Y 

Y.

KEY_LSTICK 

Left Stick Button.

KEY_RSTICK 

Right Stick Button.

KEY_L 

L.

KEY_R 

R.

KEY_ZL 

ZL.

KEY_ZR 

ZR.

KEY_PLUS 

Plus.

KEY_MINUS 

Minus.

KEY_DLEFT 

D-Pad Left.

KEY_DUP 

D-Pad Up.

KEY_DRIGHT 

D-Pad Right.

KEY_DDOWN 

D-Pad Down.

KEY_LSTICK_LEFT 

Left Stick Left.

KEY_LSTICK_UP 

Left Stick Up.

KEY_LSTICK_RIGHT 

Left Stick Right.

KEY_LSTICK_DOWN 

Left Stick Down.

KEY_RSTICK_LEFT 

Right Stick Left.

KEY_RSTICK_UP 

Right Stick Up.

KEY_RSTICK_RIGHT 

Right Stick Right.

KEY_RSTICK_DOWN 

Right Stick Down.

KEY_SL 

SL.

KEY_SR 

SR.

KEY_UP 

D-Pad Up or Sticks Up.

KEY_DOWN 

D-Pad Down or Sticks Down.

KEY_LEFT 

D-Pad Left or Sticks Left.

KEY_RIGHT 

D-Pad Right or Sticks Right.

Function Documentation

bool hidGetHandheldMode ( void  )

This can be used to check what CONTROLLER_P1_AUTO uses.

Returns 0 when CONTROLLER_PLAYER_1 is connected, otherwise returns 1 for handheld-mode.

Result hidSetNpadJoyAssignmentModeDual ( HidControllerID  id)

Use this if you want to use a pair of joy-cons as a single CONTROLLER_PLAYER_*.

Only necessary if you want to use this mode in your application after hidSetNpadJoyAssignmentModeSingleByDefault was used with this pair of joy-cons. Used automatically during app startup/exit for all controllers. When used, both joy-cons in a pair should be used with this (CONTROLLER_PLAYER_1 and CONTROLLER_PLAYER_2 for example). id must be CONTROLLER_PLAYER_*.

Result hidSetNpadJoyAssignmentModeSingleByDefault ( HidControllerID  id)

Use this if you want to use a single joy-con as a dedicated CONTROLLER_PLAYER_*.

When used, both joy-cons in a pair should be used with this (CONTROLLER_PLAYER_1 and CONTROLLER_PLAYER_2 for example). id must be CONTROLLER_PLAYER_*.