Module ctr.hid

The hid module.

The circle pad pro is supported, it's keys replace the "3ds only" keys

Usage:

    local hid = require("ctr.hid")

Functions

read () Refresh the HID state.
keys () Return the keys states as state.key in a table.
touch () Return the touch position on the touch screen.
circle () Return the circle pad position.
cstick () (N3DS only) Return the C-stick position.
accel () Return the accelerometer vector
gyro () Return the gyroscope rate.
volume () Return the sound volume.
pos3d () Return the 3D cursor position.

Tables

keys Keys list
states Keys states


Functions

read ()
Refresh the HID state.
keys ()
Return the keys states as state.key in a table.

Returns:

    table keys states

Usage:

    -- Just an example
    hid.read()
    local keys = hid.keys()
    if keys.held.a then
    	-- do stuff
    end
touch ()
Return the touch position on the touch screen. 0,0 is the top-left corner.

Returns:

  1. number X position
  2. number Y position
circle ()
Return the circle pad position. 0,0 is the center position. Warning: the circle pad doesn't always go back to 0,0.

Returns:

  1. number X position
  2. number Y position
cstick () (N3DS only)
Return the C-stick position. 0,0 is the center position, and the stick should return to it if not touched (95% of the time). Range is from -146 to 146 on both X and Y, but these are hard to reach.

Returns:

  1. number X position
  2. number Y position
accel ()
Return the accelerometer vector

Returns:

  1. number X acceleration
  2. number Y acceleration
  3. number Z acceleration
gyro ()
Return the gyroscope rate.

Returns:

  1. number roll
  2. number pitch
  3. number yaw
volume ()
Return the sound volume.

Returns:

    number volume (0 to 63)
pos3d ()
Return the 3D cursor position.

Returns:

    number 3d cursor position (0 to 1)

Tables

keys
Keys list

Fields:

  • a A
  • b B
  • select Select
  • start Start
  • dRight D-Pad right
  • dLeft D-Pad Left
  • dUp D-Pad Up
  • dDown D-Pad Down
  • r R trigger
  • l L trigger
  • x X
  • y Y
  • zl ZL trigger (new3ds only)
  • zr ZR trigger (new3ds only)
  • touch
  • cstickRight C-Stick right (new3ds only)
  • cstickLeft C-Stick left (new3ds only)
  • cstickUp C-Stick up (new3ds only)
  • cstickDown C-Stick down (new3ds only)
  • cpadRight Circle pad right
  • cpadLeft Circle pad left
  • cpadUp Circle pad up
  • cpadDown Circle pad down
  • up Generic up
  • down Generic down
  • left Generic left
  • right Generic right
states
Keys states

Fields:

  • down keys which have been just pressed
  • held keys which are held down
  • up keys whick are been just released
generated by LDoc 1.4.3 Last updated 2017-06-05 14:35:27