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;
|
2023-11-30 11:51:53 +01:00
|
|
|
deltaX = mouseX - lastMouseX;
|
|
|
|
|
deltaY = mouseY - lastMouseY;
|
|
|
|
|
lastMouseX = mouseX;
|
|
|
|
|
lastMouseY = mouseY;
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|