Public Types | Static Public Member Functions | List of all members
cpp3ds::Keyboard Class Reference

Give access to the real-time state of the keyboard. More...

#include <Keyboard.hpp>

Public Types

enum  Key {
  A = 1,
  B = 1 << 1,
  Select = 1 << 2,
  Start = 1 << 3,
  DPadRight = 1 << 4,
  DPadLeft = 1 << 5,
  DPadUp = 1 << 6,
  DPadDown = 1 << 7,
  R = 1 << 8,
  L = 1 << 9,
  X = 1 << 10,
  Y = 1 << 11,
  ZL = 1 << 14,
  ZR = 1 << 15,
  Touchpad = 1 << 20,
  CStickRight = 1 << 24,
  CStickLeft = 1 << 25,
  CStickUp = 1 << 26,
  CStickDown = 1 << 27,
  CPadRight = 1 << 28,
  CPadLeft = 1 << 29,
  CPadUp = 1 << 30,
  CPadDown = 1 << 31,
  Up = DPadUp | CPadUp,
  Down = DPadDown | CPadDown,
  Left = DPadLeft | CPadLeft,
  Right = DPadRight | CPadRight
}
 Key codes. More...
 

Static Public Member Functions

static bool isKeyDown (Key key)
 Check if a key is still being pressed. More...
 
static bool isKeyPressed (Key key)
 Check if a key is now being pressed. More...
 
static bool isKeyReleased (Key key)
 Check if a key is now being released. More...
 
static float getSlider3D ()
 
static float getSliderVolume ()
 
static void update ()
 Update cache values for input. More...
 

Detailed Description

Give access to the real-time state of the keyboard.

cpp3ds::Keyboard provides an interface to the state of the keyboard.

It only contains static functions (a single keyboard is assumed), so it's not meant to be instantiated.

This class allows users to query the keyboard state at any time and directly, without having to deal with a window and its events. Compared to the KeyPressed and KeyReleased events, cpp3ds::Keyboard can retrieve the state of a key at any time (you don't need to store and update a boolean on your side in order to know if a key is pressed or released), and you always get the real state of the keyboard, even if keys are pressed or released when your window is out of focus and no event is triggered.

Usage example:

{
// move left...
}
{
// move right...
}
else if (cpp3ds::Keyboard::isKeyPressed(cpp3ds::Keyboard::Escape))
{
// quit...
}
See also
cpp3ds::Joystick, cpp3ds::Touch

Definition at line 14 of file Keyboard.hpp.

Member Enumeration Documentation

Key codes.

Enumerator

The A button.

The B button.

Select 

The Select button.

Start 

The Start button.

The R button.

The L button.

The X button.

The Y button.

ZL 

The ZL button (New 3DS only)

ZR 

The ZR button (New 3DS only)

Up 

Either DPadUp or CPadUp.

Down 

Either DPadDown or CPadDown.

Left 

Either DPadLeft or CPadLeft.

Right 

Either DPadRight or CPadRight.

Definition at line 21 of file Keyboard.hpp.

Member Function Documentation

static bool cpp3ds::Keyboard::isKeyDown ( Key  key)
static

Check if a key is still being pressed.

Parameters
keyKey to check
Returns
True if the key is pressed, false otherwise
static bool cpp3ds::Keyboard::isKeyPressed ( Key  key)
static

Check if a key is now being pressed.

Parameters
keyKey to check
Returns
True if the key is pressed, false otherwise
static bool cpp3ds::Keyboard::isKeyReleased ( Key  key)
static

Check if a key is now being released.

Parameters
keyKey to check
Returns
True if the key is pressed, false otherwise
static void cpp3ds::Keyboard::update ( )
static

Update cache values for input.


The documentation for this class was generated from the following file: