CoriEngine
Loading...
Searching...
No Matches
Input.cpp
Go to the documentation of this file.
1#include "Input.hpp"
2
3namespace Cori {
4 namespace Core {
5 bool Input::IsKeyDown(const CoriKeycode keycode) {
6 const auto state = SDL_GetKeyboardState(nullptr);
7 return state[keycode] == 1;
8 }
9
11 const auto state = SDL_GetMouseState(nullptr, nullptr);
12 return (state & SDL_BUTTON_MASK(button)) != 0;
13 }
14
15 int32_t Input::GetMouseX() {
16 float x;
17 SDL_GetMouseState(&x, nullptr);
18 return static_cast<int32_t>(x);
19 }
20
21 int32_t Input::GetMouseY() {
22 float y;
23 SDL_GetMouseState(nullptr, &y);
24 return static_cast<int32_t>(y);
25 }
26
28 float x, y;
29 SDL_GetMouseState(&x, &y);
30 return { x, y };
31 }
32 }
33}
static bool IsKeyDown(const CoriKeycode keycode)
Checks if a specific keyboard key is down.
Definition Input.cpp:5
static int32_t GetMouseX()
Retrieves the current mouse X position on screen.
Definition Input.cpp:15
static glm::ivec2 GetMousePosition()
Retrieves the current mouse position on screen.
Definition Input.cpp:27
static int32_t GetMouseY()
Retrieves the current mouse Y position on screen.
Definition Input.cpp:21
static bool IsMouseKeyDown(const CoriMouseKeycode keycode)
Checks if a specific mouse key is down.
Definition Input.cpp:10
Core systems of the engine are here.
CoriKeycode
This is a adaptation of SDL3 scancodes. Taken from 'SDL_scancode.h'.
enum Cori::Core::CoriMouseCode CoriMouseKeycode
An enum of all available mouse buttons.
Global engine namespace.