Skip to content

Commit bc3c55f

Browse files
committed
(Build) Fixed compilation after commit from stupid linux user.
1 parent 3b9f668 commit bc3c55f

4 files changed

Lines changed: 42 additions & 26 deletions

File tree

inc/Utils/Platform/Platform.h

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -136,19 +136,14 @@ namespace SR_UTILS_NS::Platform {
136136
SR_COMMON_DLL_API extern void SetMousePos(const SR_MATH_NS::IVector2& pos);
137137
SR_COMMON_DLL_API extern void SetCursorVisible(bool isVisible);
138138
SR_COMMON_DLL_API extern void ConfineCursor(); // TODO: add ability to confine cursor to a specific window
139-
SR_COMMON_DLL_API extern void
140-
ReleaseCursorConfinement(); // TODO: add ability to confine cursor to a specific window
139+
SR_COMMON_DLL_API extern void ReleaseCursorConfinement(); // TODO: add ability to confine cursor to a specific window
141140
SR_COMMON_DLL_API extern void SetThreadPriority(void* nativeHandle, ThreadPriority priority);
142-
SR_COMMON_DLL_API extern void
143-
CopyPermissions(const SR_UTILS_NS::Path& source, const SR_UTILS_NS::Path& destination);
141+
SR_COMMON_DLL_API extern void CopyPermissions(const SR_UTILS_NS::Path& source, const SR_UTILS_NS::Path& destination);
144142

145-
/// Wayland cursor lock support: relative pointer delta accumulation.
146-
/// When the Wayland pointer is locked, relative motion deltas are accumulated here
147-
/// and consumed by InputSystem instead of computing deltas from warped positions.
148143
SR_COMMON_DLL_API extern void AccumulateMouseDelta(const SR_MATH_NS::FVector2& delta);
149144
SR_COMMON_DLL_API extern SR_MATH_NS::FVector2 ConsumeAccumulatedMouseDelta();
150-
SR_COMMON_DLL_API extern void SetWaylandCursorLockActive(bool active);
151-
SR_COMMON_DLL_API extern bool IsWaylandCursorLockActive();
145+
SR_COMMON_DLL_API extern void SetCursorLockActive(bool active);
146+
SR_COMMON_DLL_API extern bool IsCursorLockActive();
152147

153148
struct SR_COMMON_DLL_API PlatformHooks {
154149
decltype(&ReadFile) originalReadFile = nullptr;

src/Utils/Input/InputSystem.cpp

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ namespace SR_UTILS_NS {
3737
const bool isLocked = IsAppFocused() && pActiveLock;
3838

3939
if (isLocked) {
40-
if (SR_PLATFORM_NS::IsWaylandCursorLockActive()) {
40+
#ifdef SR_LINUX
41+
if (SR_PLATFORM_NS::IsCursorLockActive()) {
4142
/// Wayland path: pointer is locked by compositor, relative deltas are accumulated
4243
/// via the zwp_relative_pointer_v1 protocol. No warp needed.
4344
if (!m_isLocked) {
@@ -48,22 +49,22 @@ namespace SR_UTILS_NS {
4849
m_mouseDrag = SR_PLATFORM_NS::ConsumeAccumulatedMouseDelta();
4950
}
5051
/// Cursor visibility is managed by WaylandWindow
51-
} else {
52-
/// X11/Windows path: warp mouse to center each frame
53-
m_mousePrev = pActiveLock->lockRect ? pActiveLock->lockRect->Center() : m_focusedWindowRect->Center();
54-
m_mousePrev = m_mousePrev.Round();
55-
56-
if (!m_isLocked) {
57-
m_mouse = m_mousePrev;
58-
m_isLocked = true;
59-
} else {
60-
m_mouse = mouseState.position;
61-
}
52+
}
53+
#else
54+
m_mousePrev = pActiveLock->lockRect ? pActiveLock->lockRect->Center() : m_focusedWindowRect->Center();
55+
m_mousePrev = m_mousePrev.Round();
6256

63-
SetCursorVisible(false);
64-
SR_PLATFORM_NS::SetMousePos(m_mousePrev.CastToInt());
65-
m_mouseDrag = m_mouse - m_mousePrev;
57+
if (!m_isLocked) {
58+
m_mouse = m_mousePrev;
59+
m_isLocked = true;
60+
} else {
61+
m_mouse = mouseState.position;
6662
}
63+
64+
SetCursorVisible(false);
65+
SR_PLATFORM_NS::SetMousePos(m_mousePrev.CastToInt());
66+
m_mouseDrag = m_mouse - m_mousePrev;
67+
#endif
6768
} else {
6869
m_mousePrev = m_mouse;
6970
m_mouse = mouseState.position;

src/Utils/Platform/PlatformCommon.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,26 @@ namespace SR_PLATFORM_NS {
2222
}
2323
}
2424

25+
#ifndef SR_LINUX
26+
void AccumulateMouseDelta(const SR_MATH_NS::FVector2& delta) {
27+
SRHalt("Platform::AccumulateMouseDelta() : not implemented!");
28+
}
29+
30+
SR_MATH_NS::FVector2 ConsumeAccumulatedMouseDelta() {
31+
SRHalt("Platform::ConsumeAccumulatedMouseDelta() : not implemented!");
32+
return {};
33+
}
34+
35+
void SetCursorLockActive(bool active) {
36+
SRHalt("Platform::SetCursorLockActive() : not implemented!");
37+
}
38+
39+
bool IsCursorLockActive() {
40+
SRHalt("Platform::IsCursorLockActive() : not implemented!");
41+
return false;
42+
}
43+
#endif
44+
2545
void KeyboardState::Set(KeyCode key, const bool isPressed) {
2646
const bool current = keyStates[static_cast<uint8_t>(key)];
2747
if (current == isPressed) {

src/Utils/Platform/PlatformLinux.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ namespace SR_PLATFORM_NS {
5555
return delta;
5656
}
5757

58-
void SetWaylandCursorLockActive(bool active) { g_waylandCursorLockActive.store(active); }
58+
void SetCursorLockActive(bool active) { g_waylandCursorLockActive.store(active); }
5959

60-
bool IsWaylandCursorLockActive() { return g_waylandCursorLockActive.load(); }
60+
bool IsCursorLockActive() { return g_waylandCursorLockActive.load(); }
6161

6262
void SegmentationHandler(int sig) {
6363
WriteConsoleError("Crash stacktrace: \n" + SR_UTILS_NS::GetStacktrace());

0 commit comments

Comments
 (0)