1 #ifndef JUGIMAP_INPUT_H
2 #define JUGIMAP_INPUT_H
29 bool released =
false;
31 void _Set(
bool _down);
32 void Reset(){ pressed = down = released =
false; }
33 void ResetPerUpdateFlags(){ pressed = released =
false; }
183 void ResetPerUpdateFlags();
184 void _SetKeyState(
KeyCode _keyCode,
bool _keyDown);
185 std::array<ButtonState,256> & GetKeys(){
return keys; }
186 std::vector<std::string> & GetKeysNames(){
return keyNames; }
189 std::array<ButtonState,256>keys;
190 std::vector<char>printableASCIIcodes;
191 std::vector<std::string>keyNames;
192 char charPressed = 0;
276 void ResetPerUpdateFlags();
277 void _SetPosition(
Vec2i _pos) { posChanged = ! _pos.
Equals(pos); pos = _pos; }
278 void _SetWheel(
Vec2i _wheel);
279 void _SetButtonState(
MouseButton _mouseButton,
bool _down);
286 std::array<ButtonState,4> buttons;
288 bool wheelYChanged =
false;
289 bool wheelXChanged =
false;
290 bool posChanged =
false;
293 Sprite *cursorSprite =
nullptr;
307 struct Finger :
public ButtonState
330 int GetFingerX(
int _finger){
return fingers[_finger].position.x; }
333 int GetFingerY(
int _finger){
return fingers[_finger].position.y; }
345 void ResetPerUpdateFlags();
348 void _SetFingerState(
int _finger,
bool _down,
Vec2i _position);
352 std::array<Finger, 10>fingers;
386 static std::string DbgGetPOV_Xstring(
POV_X _pov);
387 static std::string DbgGetPOV_Ystring(
POV_Y _pov);
394 bool IsButtonDown(
int _buttonIndex){
return buttons[_buttonIndex].down; }
441 void ResetPerUpdateFlags();
444 void _SetPOV_X(
POV_X _povX);
445 void _SetPOV_Y(
POV_Y _povY);
446 void _SetXaxis(
float _xAxis){ xAxis = _xAxis;}
447 void _SetYaxis(
float _yAxis){ yAxis = _yAxis;}
448 void _SetZaxis(
float _zAxis){ zAxis = _zAxis;}
449 void _SetButtonState(
int _buttonIndex,
bool _down);
450 void _SetConnected(
bool _connected){ connected = _connected; }
451 void _SetName(
const std::string &_name){ name = _name; }
455 std::array<ButtonState,16>buttons;
456 std::array<ButtonState,3>povXButtons;
457 std::array<ButtonState,3>povYButtons;
463 bool connected =
false;
464 std::string name =
"Generic joystick";
480 #endif // JUGIMAP_INPUT_H
bool IsButtonPressed(int _buttonIndex)
Returns true if a button with the given *_buttonIndex* is pressed; otherwise returns false.
Definition: jmInput.h:391
char GetCharPressed()
Returns the ascii code of a printable character if pressed; otherwise returns 0;.
Definition: jmInput.h:176
bool IsConnected()
Returns true if this joystick is connected; otherwise returns false.
Definition: jmInput.h:427
bool IsPOV_XPressed(POV_X _povX)
Returns true if the given *_povX* button is pressed; otherwise returns false.
Definition: jmInput.h:400
bool IsKeyReleased(KeyCode _keyCode)
Returns true if a key with the given *_keyCode* is released; otherwise returns false.
Definition: jmInput.cpp:241
bool IsButtonReleased(MouseButton _mouseButton)
Returns true if the given *_mouse button* is released; otherwise returns false.
Definition: jmInput.h:256
bool IsButtonDown(int _buttonIndex)
Returns true if a button with the given *_buttonIndex* is hold down; otherwise returns false.
Definition: jmInput.h:394
POV_X
POV X values.
Definition: jmInput.h:370
POV_Y
POV Y values.
Definition: jmInput.h:378
bool IsButtonDown(MouseButton _mouseButton)
Returns true if the given *_mouse button* is hold down; otherwise returns false.
Definition: jmInput.h:253
bool IsPOV_YDown(POV_Y _povY)
Returns true if the given *_povY* button is hold down; otherwise returns false.
Definition: jmInput.h:412
int GetFingerX(int _finger)
Returns the x coordinate of the given *_finger* on screen.
Definition: jmInput.h:330
bool IsButtonReleased(int _buttonIndex)
Returns true if a button with the given *_buttonIndex* is released; otherwise returns false.
Definition: jmInput.h:397
Vec2< int > Vec2i
Vec2 struct in integer precision.
Definition: jmCommon.h:166
bool IsPOV_XReleased(POV_X _povX)
Returns true if the given *_povX* button is released; otherwise returns false.
Definition: jmInput.h:406
bool IsButtonPressed(MouseButton _mouseButton)
Returns true if the given *_mouse button* is pressed; otherwise returns false.
Definition: jmInput.h:250
bool IsWheelXChanged()
Returns true if the value of horizontal wheel changed; otherwise returns false.
Definition: jmInput.h:243
int GetX()
Returns the x coordinate of the mouse cursor on screen.
Definition: jmInput.h:221
The Joystick class provide information about joystick input.
Definition: jmInput.h:365
int GetY()
Returns the y coordinate of the mouse cursor on screen.
Definition: jmInput.h:224
bool IsKeyDown(KeyCode _keyCode)
Returns true if a key with the given *_keyCode* is hold down; otherwise returns false.
Definition: jmInput.cpp:229
bool IsPositionChanged()
Returns true if the position of the cursor changed; otherwise returns false.
Definition: jmInput.h:230
Sprite * GetCursorSprite()
Returns the cursor sprite if exists; otherwise returns nullptr.
Definition: jmInput.h:269
The Touch class provide information about touch input.
Definition: jmInput.h:315
T x
The x coordinate.
Definition: jmCommon.h:25
std::string GetName()
Return the joystick name.
Definition: jmInput.h:438
The Sprite is the base sprite class.
Definition: jmSprites.h:32
int GetWheelY()
Returns the value of vertical wheel.
Definition: jmInput.h:237
bool IsWheelYChanged()
Returns true if the value of horizontal wheel changed; otherwise returns false.
Definition: jmInput.h:246
bool IsFingerDown(int _finger)
Returns true if the given *_finger* is hold down; otherwise returns false.
Definition: jmInput.h:324
void SetCursorSprite(jugimap::Sprite *_cursorSprite)
Set the cursor sprite to the given *_cursorSprite*.
Definition: jmInput.cpp:321
std::array< Finger, 10 > & GetFingers()
Returns a reference to the vector of finger states.
Definition: jmInput.h:339
The Keyboard class provide information about keyboard input.
Definition: jmInput.h:160
bool IsFingerPressed(int _finger)
Returns true if the given *_finger* is pressed; otherwise returns false.
Definition: jmInput.h:321
bool Equals(const Vec2< T > &v, float epsilon=0.00001f) const
Returns true if the given vectors v is equal to this vector; otherwise returns false....
Definition: jmCommon.h:46
T y
The y coordinate.
Definition: jmCommon.h:26
void ClearCursorSprite()
Clear the cursor sprite.
Definition: jmInput.cpp:329
Vec2i GetPos()
Returns the position of the mouse cursor on screen.
Definition: jmInput.h:227
The Mouse class provide information about mouse input.
Definition: jmInput.h:216
bool IsPOV_YReleased(POV_Y _povY)
Returns true if the given *_povY* button is released; otherwise returns false.
Definition: jmInput.h:415
int GetWheelX()
Returns the value of horizontal wheel.
Definition: jmInput.h:234
float GetYaxis()
Returns the value of y axis.
Definition: jmInput.h:421
void Reset()
Reset all key states.
Definition: jmInput.cpp:247
std::array< ButtonState, 16 > & GetButtons()
Returns a reference to the array of button states.
Definition: jmInput.h:433
Vec2i GetWheel()
Returns the values of vertical and horizonatal wheel.
Definition: jmInput.h:240
float GetXaxis()
Returns the value of x axis.
Definition: jmInput.h:418
void Reset()
Reset all finger states.
Definition: jmInput.cpp:349
bool IsFingerReleased(int _finger)
Returns true if the given *_finger* is released; otherwise returns false.
Definition: jmInput.h:327
bool IsPOV_XDown(POV_X _povX)
Returns true if the given *_povX* button is hold down; otherwise returns false.
Definition: jmInput.h:403
void Reset()
Reset all buttons states.
Definition: jmInput.cpp:273
bool IsPOV_YPressed(POV_Y _povY)
Returns true if the given *_povY* button is pressed; otherwise returns false.
Definition: jmInput.h:409
bool IsKeyPressed(KeyCode _keyCode)
Returns true if a key with the given *_keyCode* is pressed; otherwise returns false.
Definition: jmInput.cpp:235
int GetFingerY(int _finger)
Returns the y coordinate of the given *_finger* on screen.
Definition: jmInput.h:333
float GetZaxis()
Returns the value of z axis.
Definition: jmInput.h:424
Vec2i GetFingerPos(int _finger)
Returns position of the given *_finger* on screen.
Definition: jmInput.h:336
void Reset()
Reset all button states.
Definition: jmInput.cpp:416