Norbert's Game Engine v200
Loading...
Searching...
No Matches
eKeyboard Class Reference

#include <Keyboard.hpp>

Inheritance diagram for eKeyboard:
eInput eBase

Public Member Functions

const bool GetKeyPressed (const int key)
 
const bool GetKeyDown (const int key)
 
const bool GetKeyReleased (const int key)
 
const int GetScancode (const int key)
 
const int GetKeyState (const int key)
 
const bool CheckKeyState (const int keyState, const int mode)
 
void SetStickyMode (const int vl)
 
const bool GetAnyKeyDown ()
 
const bool GetAnyKeyPressed ()
 
void SetCharCallback (NGE_KEYBOARD_CHARCALLBACK callback)
 
void SetKeyCallback (NGE_KEYBOARD_KEYCALLBACK callback)
 
const char * GetKeyName (const int key, const int scancode)
 
- Public Member Functions inherited from eInput
void SetWindow (eWindow *window)
 
eWindow * GetWindow ()
 
GLFWwindow * GetGLFWwindow ()
 
void SetInputMode (const int mode, const int value)
 
- Public Member Functions inherited from eBase
template<typename T >
T * Cast (eBase *obj)
 Cast class to base.
 

Detailed Description

Keyboard input

Use macro 'NGE_INPUT_KEYBOARD_LAYOUT_GERMAN' before including this file to switch the z and y key for german keyboard layout!

Definition at line 150 of file Keyboard.hpp.

Member Function Documentation

◆ CheckKeyState()

const bool eKeyboard::CheckKeyState ( const int keyState,
const int mode )

Definition at line 84 of file Keyboard.cpp.

85{
86 if (keyState == mode)
87 return true;
88 return false;
89}

◆ GetAnyKeyDown()

const bool eKeyboard::GetAnyKeyDown ( )

Definition at line 61 of file Keyboard.cpp.

62{
63 for (int key = NGE_INPUT_KEY_SPACE; key <= NGE_INPUT_KEY_LAST; key++)
64 {
65 if (glfwGetKey(GetGLFWwindow(), key) == GLFW_PRESS)
66 return true;
67 }
68 return false;
69}

◆ GetAnyKeyPressed()

const bool eKeyboard::GetAnyKeyPressed ( )

Definition at line 71 of file Keyboard.cpp.

72{
73 for (int key = NGE_INPUT_KEY_SPACE; key <= NGE_INPUT_KEY_LAST; key++)
74 {
75 if (glfwGetKey(GetGLFWwindow(), key) == GLFW_PRESS)
76 {
77 mAnyKey = key;
78 break;
79 }
80 }
81 return GetKeyPressed(mAnyKey);
82}

◆ GetKeyDown()

const bool eKeyboard::GetKeyDown ( const int key)

Definition at line 37 of file Keyboard.cpp.

38{
39 if (glfwGetKey(GetGLFWwindow(), key) == GLFW_PRESS)
40 return true;
41 return false;
42}

◆ GetKeyName()

const char * eKeyboard::GetKeyName ( const int key,
const int scancode )

Definition at line 106 of file Keyboard.cpp.

107{
108 return glfwGetKeyName(key, scancode);
109}

◆ GetKeyPressed()

const bool eKeyboard::GetKeyPressed ( const int key)

Definition at line 6 of file Keyboard.cpp.

7{
8 bool isDown = false;
9 int location = 0;
10 for (int i = 0; i < mKeyPressed.size(); i++)
11 {
12 if (mKeyPressed[i] == key)
13 {
14 location = i;
15 isDown = true;
16 break;
17 }
18 }
19
20 if (isDown)
21 {
22 if (GetKeyReleased(key))
23 mKeyPressed.erase(mKeyPressed.begin() + location);
24 return false;
25 }
26 else
27 {
28 if (GetKeyDown(key))
29 {
30 mKeyPressed.push_back(key);
31 return true;
32 }
33 }
34 return false;
35}

◆ GetKeyReleased()

const bool eKeyboard::GetKeyReleased ( const int key)

Definition at line 44 of file Keyboard.cpp.

45{
46 if (glfwGetKey(GetGLFWwindow(), key) == GLFW_RELEASE)
47 return true;
48 return false;
49}

◆ GetKeyState()

const int eKeyboard::GetKeyState ( const int key)

Definition at line 56 of file Keyboard.cpp.

57{
58 return glfwGetKey(GetGLFWwindow(), key);
59}

◆ GetScancode()

const int eKeyboard::GetScancode ( const int key)

Definition at line 51 of file Keyboard.cpp.

52{
53 return glfwGetKeyScancode(key);
54}

◆ SetCharCallback()

void eKeyboard::SetCharCallback ( NGE_KEYBOARD_CHARCALLBACK callback)

Definition at line 96 of file Keyboard.cpp.

97{
98 glfwSetCharCallback(GetGLFWwindow(), callback);
99}

◆ SetKeyCallback()

void eKeyboard::SetKeyCallback ( NGE_KEYBOARD_KEYCALLBACK callback)

Definition at line 101 of file Keyboard.cpp.

102{
103 glfwSetKeyCallback(GetGLFWwindow(), callback);
104}

◆ SetStickyMode()

void eKeyboard::SetStickyMode ( const int vl)

Definition at line 91 of file Keyboard.cpp.

92{
93 glfwSetInputMode(GetGLFWwindow(), GLFW_STICKY_KEYS, vl);
94}

The documentation for this class was generated from the following files: