libctru  v2.4.1
Data Structures | Macros | Enumerations | Functions | Variables
hid.h File Reference

HID service. More...

Go to the source code of this file.

Data Structures

struct  touchPosition
 Touch position. More...
 
struct  circlePosition
 Circle Pad position. More...
 
struct  accelVector
 Accelerometer vector. More...
 
struct  angularRate
 Gyroscope angular rate. More...
 

Macros

#define scanKeys   hidScanInput
 Compatibility macro for hidScanInput.
 
#define keysHeld   hidKeysHeld
 Compatibility macro for hidKeysHeld.
 
#define keysDown   hidKeysDown
 Compatibility macro for hidKeysDown.
 
#define keysUp   hidKeysUp
 Compatibility macro for hidKeysUp.
 
#define touchRead   hidTouchRead
 Compatibility macro for hidTouchRead.
 
#define circleRead   hidCircleRead
 Compatibility macro for hidCircleRead.
 

Enumerations

enum  {
  KEY_A = BIT(0) ,
  KEY_B = BIT(1) ,
  KEY_SELECT = BIT(2) ,
  KEY_START = BIT(3) ,
  KEY_DRIGHT = BIT(4) ,
  KEY_DLEFT = BIT(5) ,
  KEY_DUP = BIT(6) ,
  KEY_DDOWN = BIT(7) ,
  KEY_R = BIT(8) ,
  KEY_L = BIT(9) ,
  KEY_X = BIT(10) ,
  KEY_Y = BIT(11) ,
  KEY_ZL = BIT(14) ,
  KEY_ZR = BIT(15) ,
  KEY_TOUCH = BIT(20) ,
  KEY_CSTICK_RIGHT = BIT(24) ,
  KEY_CSTICK_LEFT = BIT(25) ,
  KEY_CSTICK_UP = BIT(26) ,
  KEY_CSTICK_DOWN = BIT(27) ,
  KEY_CPAD_RIGHT = BIT(28) ,
  KEY_CPAD_LEFT = BIT(29) ,
  KEY_CPAD_UP = BIT(30) ,
  KEY_CPAD_DOWN = BIT(31) ,
  KEY_UP = KEY_DUP | KEY_CPAD_UP ,
  KEY_DOWN = KEY_DDOWN | KEY_CPAD_DOWN ,
  KEY_LEFT = KEY_DLEFT | KEY_CPAD_LEFT ,
  KEY_RIGHT = KEY_DRIGHT | KEY_CPAD_RIGHT
}
 Key values. More...
 
enum  HID_Event {
  HIDEVENT_PAD0 = 0 ,
  HIDEVENT_PAD1 ,
  HIDEVENT_Accel ,
  HIDEVENT_Gyro ,
  HIDEVENT_DebugPad ,
  HIDEVENT_MAX
}
 HID events. More...
 

Functions

Result hidInit (void)
 Initializes HID.
 
void hidExit (void)
 Exits HID.
 
void hidSetRepeatParameters (u32 delay, u32 interval)
 Sets the key repeat parameters for hidKeysRepeat. More...
 
void hidScanInput (void)
 Scans HID for input data.
 
u32 hidKeysHeld (void)
 Returns a bitmask of held buttons. More...
 
u32 hidKeysDown (void)
 Returns a bitmask of newly pressed buttons, this frame. More...
 
u32 hidKeysDownRepeat (void)
 Returns a bitmask of newly pressed or repeated buttons, this frame. More...
 
u32 hidKeysUp (void)
 Returns a bitmask of newly released buttons, this frame. More...
 
void hidTouchRead (touchPosition *pos)
 Reads the current touch position. More...
 
void hidCircleRead (circlePosition *pos)
 Reads the current circle pad position. More...
 
void hidAccelRead (accelVector *vector)
 Reads the current accelerometer data. More...
 
void hidGyroRead (angularRate *rate)
 Reads the current gyroscope data. More...
 
void hidWaitForEvent (HID_Event id, bool nextEvent)
 Waits for an HID event. More...
 
Result hidWaitForAnyEvent (bool nextEvents, Handle cancelEvent, s64 timeout)
 Waits for any HID or IRRST event. More...
 
Result HIDUSER_GetHandles (Handle *outMemHandle, Handle *eventpad0, Handle *eventpad1, Handle *eventaccel, Handle *eventgyro, Handle *eventdebugpad)
 Gets the handles for HID operation. More...
 
Result HIDUSER_EnableAccelerometer (void)
 Enables the accelerometer.
 
Result HIDUSER_DisableAccelerometer (void)
 Disables the accelerometer.
 
Result HIDUSER_EnableGyroscope (void)
 Enables the gyroscope.
 
Result HIDUSER_DisableGyroscope (void)
 Disables the gyroscope.
 
Result HIDUSER_GetGyroscopeRawToDpsCoefficient (float *coeff)
 Gets the gyroscope raw to dps coefficient. More...
 
Result HIDUSER_GetSoundVolume (u8 *volume)
 Gets the current volume slider value. More...
 

Variables

Handle hidMemHandle
 HID shared memory handle.
 
vu32hidSharedMem
 HID shared memory.
 

Detailed Description

HID service.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Key values.

Enumerator
KEY_A 

A.

KEY_B 

B.

KEY_SELECT 

Select.

KEY_START 

Start.

KEY_DRIGHT 

D-Pad Right.

KEY_DLEFT 

D-Pad Left.

KEY_DUP 

D-Pad Up.

KEY_DDOWN 

D-Pad Down.

KEY_R 

R.

KEY_L 

L.

KEY_X 

X.

KEY_Y 

Y.

KEY_ZL 

ZL (New 3DS only)

KEY_ZR 

ZR (New 3DS only)

KEY_TOUCH 

Touch (Not actually provided by HID)

KEY_CSTICK_RIGHT 

C-Stick Right (New 3DS only)

KEY_CSTICK_LEFT 

C-Stick Left (New 3DS only)

KEY_CSTICK_UP 

C-Stick Up (New 3DS only)

KEY_CSTICK_DOWN 

C-Stick Down (New 3DS only)

KEY_CPAD_RIGHT 

Circle Pad Right.

KEY_CPAD_LEFT 

Circle Pad Left.

KEY_CPAD_UP 

Circle Pad Up.

KEY_CPAD_DOWN 

Circle Pad Down.

KEY_UP 

D-Pad Up or Circle Pad Up.

KEY_DOWN 

D-Pad Down or Circle Pad Down.

KEY_LEFT 

D-Pad Left or Circle Pad Left.

KEY_RIGHT 

D-Pad Right or Circle Pad Right.

◆ HID_Event

enum HID_Event

HID events.

Enumerator
HIDEVENT_PAD0 

Event signaled by HID-module, when the sharedmem+0(PAD/circle-pad)/+0xA8(touch-screen) region was updated.

HIDEVENT_PAD1 

Event signaled by HID-module, when the sharedmem+0(PAD/circle-pad)/+0xA8(touch-screen) region was updated.

HIDEVENT_Accel 

Event signaled by HID-module, when the sharedmem accelerometer state was updated.

HIDEVENT_Gyro 

Event signaled by HID-module, when the sharedmem gyroscope state was updated.

HIDEVENT_DebugPad 

Event signaled by HID-module, when the sharedmem DebugPad state was updated.

HIDEVENT_MAX 

Used to know how many events there are.

Function Documentation

◆ hidAccelRead()

void hidAccelRead ( accelVector vector)

Reads the current accelerometer data.

Parameters
vectorPointer to output the accelerometer data to.

◆ hidCircleRead()

void hidCircleRead ( circlePosition pos)

Reads the current circle pad position.

Parameters
posPointer to output the circle pad position to.
Examples
input/read-controls/source/main.c.

◆ hidGyroRead()

void hidGyroRead ( angularRate rate)

Reads the current gyroscope data.

Parameters
ratePointer to output the gyroscope data to.

◆ hidKeysDown()

u32 hidKeysDown ( void  )

Returns a bitmask of newly pressed buttons, this frame.

Individual buttons can be extracted using binary AND.

Returns
32-bit bitmask of newly pressed buttons.
Examples
app_launch/source/main.c, audio/filters/source/main.c, audio/mic/source/main.c, audio/streaming/source/main.c, camera/image/source/main.c, camera/video/source/main.c, get_system_language/source/main.c, graphics/bitmap/24bit-color/source/main.c, graphics/gpu/both_screens/source/main.c, graphics/gpu/fragment_light/source/main.c, graphics/gpu/geoshader/source/main.c, graphics/gpu/gpusprites/source/main.c, graphics/gpu/immediate/source/main.c, graphics/gpu/lenny/source/main.c, graphics/gpu/loop_subdivision/source/main.c, graphics/gpu/mipmap_fog/source/main.c, graphics/gpu/particles/source/main.c, graphics/gpu/proctex/source/main.c, graphics/gpu/simple_tri/source/main.c, graphics/gpu/textured_cube/source/main.c, graphics/gpu/toon_shading/source/main.c, graphics/printing/both-screen-text/source/main.c, graphics/printing/colored-text/source/main.c, graphics/printing/hello-world/source/main.c, graphics/printing/multiple-windows-text/source/main.c, graphics/printing/system-font/source/main.c, input/read-controls/source/main.c, input/software-keyboard/source/main.c, input/touch-screen/source/main.c, libapplet_launch/source/main.c, mvd/source/main.c, network/boss/source/main.c, network/http/source/main.c, network/http_post/source/main.c, network/sockets/source/sockets.c, network/sslc/source/ssl.c, network/uds/source/uds.c, nfc/source/main.c, romfs/source/main.c, threads/event/source/main.c, threads/thread-basic/source/main.c, and time/rtc/source/main.c.

◆ hidKeysDownRepeat()

u32 hidKeysDownRepeat ( void  )

Returns a bitmask of newly pressed or repeated buttons, this frame.

Individual buttons can be extracted using binary AND.

Returns
32-bit bitmask of newly pressed or repeated buttons.

◆ hidKeysHeld()

u32 hidKeysHeld ( void  )

◆ hidKeysUp()

u32 hidKeysUp ( void  )

Returns a bitmask of newly released buttons, this frame.

Individual buttons can be extracted using binary AND.

Returns
32-bit bitmask of newly released buttons.
Examples
audio/mic/source/main.c, and input/read-controls/source/main.c.

◆ hidSetRepeatParameters()

void hidSetRepeatParameters ( u32  delay,
u32  interval 
)

Sets the key repeat parameters for hidKeysRepeat.

Parameters
delayInitial delay.
intervalRepeat interval.

◆ hidTouchRead()

void hidTouchRead ( touchPosition pos)

Reads the current touch position.

Parameters
posPointer to output the touch position to.
Examples
input/touch-screen/source/main.c.

◆ HIDUSER_GetGyroscopeRawToDpsCoefficient()

Result HIDUSER_GetGyroscopeRawToDpsCoefficient ( float *  coeff)

Gets the gyroscope raw to dps coefficient.

Parameters
coeffPointer to output the coefficient to.

◆ HIDUSER_GetHandles()

Result HIDUSER_GetHandles ( Handle outMemHandle,
Handle eventpad0,
Handle eventpad1,
Handle eventaccel,
Handle eventgyro,
Handle eventdebugpad 
)

Gets the handles for HID operation.

Parameters
outMemHandlePointer to output the shared memory handle to.
eventpad0Pointer to output the pad 0 event handle to.
eventpad1Pointer to output the pad 1 event handle to.
eventaccelPointer to output the accelerometer event handle to.
eventgyroPointer to output the gyroscope event handle to.
eventdebugpadPointer to output the debug pad event handle to.

◆ HIDUSER_GetSoundVolume()

Result HIDUSER_GetSoundVolume ( u8 volume)

Gets the current volume slider value.

(0-63)

Parameters
volumePointer to write the volume slider value to.

◆ hidWaitForAnyEvent()

Result hidWaitForAnyEvent ( bool  nextEvents,
Handle  cancelEvent,
s64  timeout 
)

Waits for any HID or IRRST event.

Parameters
nextEventsWhether to discard the current events and wait for the next events.
cancelEventOptional additional handle to wait on, otherwise 0.
timeoutTimeout.

◆ hidWaitForEvent()

void hidWaitForEvent ( HID_Event  id,
bool  nextEvent 
)

Waits for an HID event.

Parameters
idID of the event.
nextEventWhether to discard the current event and wait for the next event.