cmdfx 0.2.1
Lightweight game engine for your terminal
Loading...
Searching...
No Matches
device.hpp
Go to the documentation of this file.
1
11#pragma once
12
13extern "C" {
14 #include "cmdfx/core/device.h"
15}
16
17#include <vector>
18
19namespace CmdFX {
23 namespace Device {
33 std::vector<bool> getKeyboardKeysPressed() {
34 std::vector<bool> keysPressed;
35 keysPressed.reserve(256);
36
38 if (arr == nullptr) return keysPressed;
39
40 for (int i = 0; i < 256; i++) {
41 keysPressed.push_back(arr[i]);
42 }
43
44 return keysPressed;
45 }
46 char fromKeyCode(int keyCode) { return Device_fromKeyCode(keyCode); }
47
57 std::vector<bool> getMouseButtonsPressed() {
58 std::vector<bool> buttonsPressed;
59 buttonsPressed.reserve(3);
60
62 if (arr == nullptr) return buttonsPressed;
63
64 for (int i = 0; i < 3; i++) {
65 buttonsPressed.push_back(arr[i]);
66 }
67
68 return buttonsPressed;
69 }
70 };
71}
Device command functions.
char Device_fromKeyCode(int keyCode)
Converts a key code to a character.
bool * Device_getMouseButtonsPressed()
Gets the current mouse button being pressed.
bool * Device_getKeyboardKeysPressed()
Gets the current keys being pressed.
C++ wrapper for the CmdFX Device API.
Definition device.hpp:23
std::vector< bool > getMouseButtonsPressed()
Gets a vector of mouse buttons that are currently pressed.
Definition device.hpp:57
std::vector< bool > getKeyboardKeysPressed()
Gets a vector of booleans representing the state of the keyboard keys.
Definition device.hpp:33
Primary namespace for CmdFX.
Definition cmdfx.hpp:22