cmdfx 0.3.2
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
20{
24namespace Device
25{
35std::vector<bool> getKeyboardKeysPressed() {
36 std::vector<bool> keysPressed;
37 keysPressed.reserve(256);
38
40 if (arr == nullptr) return keysPressed;
41
42 for (int i = 0; i < 256; i++) {
43 keysPressed.push_back(arr[i]);
44 }
45
46 return keysPressed;
47}
48char fromKeyCode(int keyCode) {
49 return Device_fromKeyCode(keyCode);
50}
51
62std::vector<bool> getMouseButtonsPressed() {
63 std::vector<bool> buttonsPressed;
64 buttonsPressed.reserve(3);
65
67 if (arr == nullptr) return buttonsPressed;
68
69 for (int i = 0; i < 3; i++) {
70 buttonsPressed.push_back(arr[i]);
71 }
72
73 return buttonsPressed;
74}
75}; // namespace Device
76} // namespace CmdFX
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:25
std::vector< bool > getMouseButtonsPressed()
Gets a vector of mouse buttons that are currently pressed.
Definition device.hpp:62
std::vector< bool > getKeyboardKeysPressed()
Gets a vector of booleans representing the state of the keyboard keys.
Definition device.hpp:35
Primary namespace for CmdFX.
Definition cmdfx.hpp:26