Files
Seele/src/Engine/System/KeyboardInput.cpp
T

63 lines
1.4 KiB
C++
Raw Normal View History

2023-11-17 22:31:26 +01:00
#include "KeyboardInput.h"
using namespace Seele;
using namespace Seele::System;
KeyboardInput::KeyboardInput(PScene scene)
: ComponentSystem<Component::KeyboardInput>(scene)
{
2023-11-26 09:40:48 +01:00
std::memset(keys.data(), 0, sizeof(keys));
2023-11-17 22:31:26 +01:00
}
KeyboardInput::~KeyboardInput()
{
}
void KeyboardInput::update(Component::KeyboardInput& input)
{
std::memcpy(input.keys.data(), keys.data(), sizeof(keys));
input.deltaX = deltaX;
input.deltaY = deltaY;
input.mouseX = mouseX;
input.mouseY = mouseY;
input.mouse1 = mouse1;
input.mouse2 = mouse2;
input.scrollX = scrollX;
input.scrollY = scrollY;
2023-11-30 11:51:53 +01:00
deltaX = mouseX - lastMouseX;
deltaY = mouseY - lastMouseY;
lastMouseX = mouseX;
lastMouseY = mouseY;
scrollX = 0;
scrollY = 0;
2023-11-17 22:31:26 +01:00
}
2024-01-16 21:11:57 +01:00
void KeyboardInput::keyCallback(KeyCode code, InputAction action, KeyModifier)
2023-11-17 22:31:26 +01:00
{
keys[code] = action != InputAction::RELEASE;
}
void KeyboardInput::mouseCallback(double x, double y)
{
mouseX = x;
mouseY = y;
}
2024-01-16 21:11:57 +01:00
void KeyboardInput::mouseButtonCallback(MouseButton button, InputAction action, KeyModifier)
2023-11-17 22:31:26 +01:00
{
if (button == MouseButton::MOUSE_BUTTON_1)
{
mouse1 = action != InputAction::RELEASE;
}
if (button == MouseButton::MOUSE_BUTTON_2)
{
mouse2 = action != InputAction::RELEASE;
}
}
void KeyboardInput::scrollCallback(double xScroll, double yScroll)
{
scrollX = xScroll;
scrollY = yScroll;
}