JNGL
Namespaces | Enumerations | Functions
input.hpp File Reference

Input related functions. More...

#include "Vec2.hpp"
#include <functional>
#include <memory>
#include <vector>
Include dependency graph for input.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

 jngl
 JNGL's main namespace.
 

Enumerations

enum  KeyType {
  Left, Up, Right, Down,
  PageUp, PageDown, Home, End,
  BackSpace, Tab, Clear, Return,
  Pause, Escape, Delete, ControlL,
  ControlR, CapsLock, AltL, AltR,
  SuperL, SuperR, Space, ShiftL,
  ShiftR, F1, F2, F3,
  F4, F5, F6, F7,
  F8, F9, F10, F11,
  F12, Any
}
 Keyboard keys. More...
 
enum  KeyboardType { Default, Numpad }
 Whether a normal or a numbers-only keyboard should appear.
 
enum  Button { Left, Middle, Right }
 Mouse buttons.
 
enum  Button {
  LeftStickX, LeftStickXInverse, LeftStickY, LeftStickYInverse,
  RightStickX, RightStickXInverse, RightStickY, RightStickYInverse,
  A, B, X, Y,
  LeftButton, RightButton, LeftTrigger, RightTrigger,
  Start, Back, DpadUp, DpadDown,
  DpadLeft, DpadRight, LeftStick, RightStick,
  Last
}
 Gamepad buttons. More...
 

Functions

void setKeyboardVisible (bool)
 Display onscreen keyboard for touch devices.
 
void setKeyboardType (KeyboardType)
 Type of the onscreen keyboard.
 
KeyboardType getKeyboardType ()
 Currently active type of onscreen keyboard.
 
void setKeyPressed (const std::string &key, bool)
 Overwrite what keyPressed() should return.
 
void setKeyPressed (key::KeyType key, bool)
 Overwrite what keyPressed() should return.
 
bool keyDown (key::KeyType key)
 Whether key is down.
 
bool keyDown (char key)
 Whether key is down.
 
bool keyDown (const std::string &key)
 Whether key is down, where key should be exactly one UTF-8 character.
 
bool keyPressed (key::KeyType key)
 Whether key has been pressed since the next to last call to updateInput()
 
bool keyPressed (char key)
 Whether key has been pressed since the next to last call to updateInput()
 
bool keyPressed (const std::string &key)
 Whether key has been pressed since the next to last call to updateInput(), where key should be exactly one UTF-8 character.
 
void setRelativeMouseMode (bool relative)
 
bool getRelativeMouseMode ()
 
void setMouseVisible (bool visible)
 
bool isMouseVisible ()
 
bool isMultitouch ()
 Returns true when there's more than one finger touching the screen.
 
std::vector< jngl::Vec2getTouchPositions ()
 Returns all positions where a finger touches the screen. More...
 
Vec2 getMousePos ()
 Mouse position in screen coordinates.
 
int getMouseX ()
 Retrieve mouse position in pixels. More...
 
int getMouseY ()
 Retrieve mouse position in pixels. More...
 
double getMouseWheel ()
 Returns mouse wheel movement between -100 and 100 (0 if the mousewheel doesn't move)
 
bool mouseDown (mouse::Button button=mouse::Left)
 Returns whether button is currently held down.
 
void setMouseDown (mouse::Button button, bool)
 Overwrite what mouseDown() should return.
 
bool mousePressed (mouse::Button button=mouse::Left)
 Whether button has been pressed since the next to last call to updateInput()
 
void setMousePressed (jngl::mouse::Button, bool)
 Overwrite what mouseDown() should return.
 
void setMouse (Vec2 position)
 Moves the mouse (does nothing on iOS and Android)
 
std::vector< std::shared_ptr< Controller > > getConnectedControllers ()
 Returns all controllers (gamepads) that are connected. More...
 
void onControllerChanged (std::function< void()> callback)
 Specify a function which gets called, whenever a controller gets added or removed. More...
 
std::string getTextInput ()
 Returns a string of characters that have been pressed since the last call to updateInput()
 

Detailed Description

Input related functions.

Definition in file input.hpp.

Enumeration Type Documentation

◆ KeyType

enum KeyType

Keyboard keys.

Enumerator
SuperL 

Left Windows key.

SuperR 

Right Windows key.

Definition at line 17 of file input.hpp.

◆ Button

enum Button

Gamepad buttons.

Enumerator
LeftStickX 

x axis of left stick, -1 to 1

LeftStickXInverse 

-LeftStickX

LeftStickY 

y axis of left stick, -1 to 1

LeftStickYInverse 

-LeftStickY

RightStickX 

x axis of right stick, -1 to 1

RightStickXInverse 

-RightStickX

RightStickY 

y axis of right stick, -1 to 1

RightStickYInverse 

-RightStickY

LeftButton 

Left shoulder button.

RightButton 

Right shoulder button.

Start 

Start, or Options button.

Back 

Back, Menu, or Share button.

Definition at line 152 of file input.hpp.