mirror of
https://github.com/allankoechke/raylib-cpp.git
synced 2026-11-30 17:19:27 +00:00
65
include/Keyboard.hpp
Normal file
65
include/Keyboard.hpp
Normal file
@@ -0,0 +1,65 @@
|
||||
#ifndef RAYLIB_CPP_INCLUDE_KEYBOARD_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_KEYBOARD_HPP_
|
||||
|
||||
#include "./raylib.hpp"
|
||||
|
||||
namespace raylib {
|
||||
/**
|
||||
* Input-related functions: keyboard
|
||||
*/
|
||||
class Keyboard {
|
||||
public:
|
||||
/**
|
||||
* Detect if a key has been pressed once
|
||||
*/
|
||||
static bool IsKeyPressed(int key) {
|
||||
return ::IsKeyPressed(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect if a key has been pressed again (Only PLATFORM_DESKTOP)
|
||||
*/
|
||||
static bool IsKeyPressedRepeat(int key) {
|
||||
return ::IsKeyPressedRepeat(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect if a key is being pressed
|
||||
*/
|
||||
static bool IsKeyDown(int key) {
|
||||
return ::IsKeyDown(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect if a key has been released once
|
||||
*/
|
||||
static bool IsKeyReleased(int key) {
|
||||
return ::IsKeyReleased(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect if a key is NOT being pressed
|
||||
*/
|
||||
static bool IsKeyUp(int key) {
|
||||
return ::IsKeyUp(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get key pressed (keycode), call it multiple times for keys queued, returns 0 when the queue is empty
|
||||
*/
|
||||
static bool GetKeyPressed() {
|
||||
return ::GetKeyPressed();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get char pressed (unicode), call it multiple times for chars queued, returns 0 when the queue is empty
|
||||
*/
|
||||
static bool GetCharPressed() {
|
||||
return ::GetCharPressed();
|
||||
}
|
||||
};
|
||||
} // namespace raylib
|
||||
|
||||
using RKeyboard = raylib::Keyboard;
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_KEYBOARD_HPP_
|
||||
@@ -76,6 +76,13 @@ class Window {
|
||||
return ::WindowShouldClose();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a custom key to exit program (default is ESC)
|
||||
*/
|
||||
bool SetExitKey(int key) {
|
||||
return ::SetExitKey(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close window and unload OpenGL context
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user