Unify input behind Engine::Input facade; fix Ctrl+P and Pause button
New Engine/Core/Input.h/.cpp: static input facade with a Key/MouseButton enum (values map to GLFW key codes internally) so scripts and game logic no longer touch GLFW directly - window backend becomes swappable and the facade is the surface to expose when embedding scripting later. Wired up in Application's constructor; Camera (editor camera WASD/RMB/MMB), the WASDMove script and SandboxApp key handling now query Input only. Ctrl+P hotkey fix: the !m_Playing guard made the hotkey dead exactly when it was needed - after pressing Play. Now toggles both ways. Toolbar Pause button now reads "Resume" while paused (tooltip follows).
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include "GLFW/glfw3.h"
|
||||
#include "Engine/Core/Input.h" // 键查询走统一输入门面(不依赖 GLFW)
|
||||
|
||||
namespace Engine {
|
||||
|
||||
@@ -35,9 +35,9 @@ namespace Engine {
|
||||
// 光标型交互互斥共用捕获;编辑器模式 flyRequiresRMB=true 时
|
||||
// 移动键仅 RMB 按住生效(否则与 Gizmo W/E/R 热键冲突)----
|
||||
const bool wantLook = m_MouseLookEnabled &&
|
||||
window.IsMouseButtonPressed(GLFW_MOUSE_BUTTON_RIGHT);
|
||||
Input::IsMouseButtonDown(Input::MouseButton::Right);
|
||||
const bool wantOrbit = m_MouseLookEnabled &&
|
||||
window.IsMouseButtonPressed(GLFW_MOUSE_BUTTON_MIDDLE);
|
||||
Input::IsMouseButtonDown(Input::MouseButton::Middle);
|
||||
|
||||
if (wantLook || wantOrbit)
|
||||
{
|
||||
@@ -70,7 +70,7 @@ namespace Engine {
|
||||
|
||||
if (wantOrbit)
|
||||
{
|
||||
if (window.IsKeyPressed(GLFW_KEY_LEFT_SHIFT))
|
||||
if (Input::IsKeyDown(Input::Key::LeftShift))
|
||||
{
|
||||
// ---- 屏幕平面平移:内容跟手(拖右 → 相机左移、
|
||||
// 拖下 → 相机上移),pivot 同步平移保持环绕点的
|
||||
@@ -120,12 +120,12 @@ namespace Engine {
|
||||
if (wantLook || !flyRequiresRMB)
|
||||
{
|
||||
const f32 speed = m_MoveSpeed * deltaTime;
|
||||
if (window.IsKeyPressed(GLFW_KEY_W)) { transform.SetPosition(transform.GetPosition() + forward * speed); }
|
||||
if (window.IsKeyPressed(GLFW_KEY_S)) { transform.SetPosition(transform.GetPosition() - forward * speed); }
|
||||
if (window.IsKeyPressed(GLFW_KEY_A)) { transform.SetPosition(transform.GetPosition() - right * speed); }
|
||||
if (window.IsKeyPressed(GLFW_KEY_D)) { transform.SetPosition(transform.GetPosition() + right * speed); }
|
||||
if (window.IsKeyPressed(GLFW_KEY_SPACE)) { transform.SetPosition(transform.GetPosition() + glm::vec3(0, speed, 0)); }
|
||||
if (window.IsKeyPressed(GLFW_KEY_LEFT_SHIFT)) { transform.SetPosition(transform.GetPosition() - glm::vec3(0, speed, 0)); }
|
||||
if (Input::IsKeyDown(Input::Key::W)) { transform.SetPosition(transform.GetPosition() + forward * speed); }
|
||||
if (Input::IsKeyDown(Input::Key::S)) { transform.SetPosition(transform.GetPosition() - forward * speed); }
|
||||
if (Input::IsKeyDown(Input::Key::A)) { transform.SetPosition(transform.GetPosition() - right * speed); }
|
||||
if (Input::IsKeyDown(Input::Key::D)) { transform.SetPosition(transform.GetPosition() + right * speed); }
|
||||
if (Input::IsKeyDown(Input::Key::Space)) { transform.SetPosition(transform.GetPosition() + glm::vec3(0, speed, 0)); }
|
||||
if (Input::IsKeyDown(Input::Key::LeftShift)) { transform.SetPosition(transform.GetPosition() - glm::vec3(0, speed, 0)); }
|
||||
}
|
||||
|
||||
// ---- 滚轮推拉:有 pivot 时改环绕距离(指数步进,近处精细/
|
||||
|
||||
Reference in New Issue
Block a user