feat: add firstpersoncontroller
This commit is contained in:
@@ -46,11 +46,11 @@ void InputManager::BeginFrame() {
|
||||
|
||||
m_textInput.clear();
|
||||
|
||||
// Update mouse delta based on last known position
|
||||
m_mouseDX = m_mouseX - m_prevMouseX;
|
||||
m_mouseDY = m_mouseY - m_prevMouseY;
|
||||
m_prevMouseX = m_mouseX;
|
||||
m_prevMouseY = m_mouseY;
|
||||
// Relative mouse accumulators are filled during SDL event processing
|
||||
// and consumed by game code each frame. Reset them here (before events
|
||||
// are processed) so this frame accumulates fresh deltas.
|
||||
m_mouseRelDX = 0;
|
||||
m_mouseRelDY = 0;
|
||||
|
||||
// Clear controller "edge" sets + snapshot axes
|
||||
for (auto& [id, pad]: m_pads) {
|
||||
@@ -60,6 +60,12 @@ void InputManager::BeginFrame() {
|
||||
}
|
||||
}
|
||||
|
||||
void InputManager::SetMouseCaptured(bool captured) {
|
||||
if (captured == m_MouseCaptured) return;
|
||||
m_MouseCaptured = captured;
|
||||
SDL_SetRelativeMouseMode(captured ? SDL_TRUE : SDL_FALSE);
|
||||
}
|
||||
|
||||
void InputManager::AddController(int deviceIndex) {
|
||||
if (!SDL_IsGameController(deviceIndex)) return;
|
||||
|
||||
@@ -134,6 +140,8 @@ bool InputManager::ProcessEvent(const SDL_Event& e) {
|
||||
case SDL_MOUSEMOTION: {
|
||||
m_mouseX = e.motion.x;
|
||||
m_mouseY = e.motion.y;
|
||||
m_mouseRelDX += e.motion.xrel;
|
||||
m_mouseRelDY += e.motion.yrel;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user