MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / ProcessMouse_SDL

Function ProcessMouse_SDL

engine/Poseidon/Input/InputProcessingSdl.cpp:217–248  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

215
216void SDLInput_BufferMouseWheel(float dy)
217{
218 GInput.mouse.BufferWheel(dy);
219}
220
221void ProcessMouse_SDL(DWORD timeDelta)
222{
223 if (!GWorld->IsUserInputEnabled())
224 {
225 GInput.mouse.DiscardBuffered();
226 return;
227 }
228
229 // Compute cursor clamp from aspect settings
230 MouseState::CursorClamp clamp;
231 const MouseState::CursorClamp* clampPtr = nullptr;
232 if (::Poseidon::GEngine)
233 {
234 AspectSettings as;
235 ::Poseidon::GEngine->GetAspectSettings(as);
236 float screenTopX = as.uiTopLeftX / (as.uiTopLeftX - as.uiBottomRightX);
237 float screenTopY = as.uiTopLeftY / (as.uiTopLeftY - as.uiBottomRightY);
238 float screenBotX = (1 - as.uiTopLeftX) / (as.uiBottomRightX - as.uiTopLeftX);
239 float screenBotY = (1 - as.uiTopLeftY) / (as.uiBottomRightY - as.uiTopLeftY);
240 clamp.minX = screenTopX * 2 - 1;
241 clamp.maxX = screenBotX * 2 - 1;
242 clamp.minY = screenTopY * 2 - 1;
243 clamp.maxY = screenBotY * 2 - 1;
244 clampPtr = &clamp;
245 }
246
247 // Aiming spans the full window, so it uses the window aspect ratio
248 // (Width/Height). The cursor's coordinates are relative to the HUD region,
249 // so it uses that region's aspect ratio (Width2D/Height2D) — this keeps its
250 // speed consistent and unaffected by the HUD width limit. Both fall back to
251 // the 4:3 reference when the engine size is unavailable.

Callers 1

ProcessMouseFunction · 0.85

Calls 4

IsUserInputEnabledMethod · 0.80
GetAspectSettingsMethod · 0.80
DiscardBufferedMethod · 0.45
UpdateMethod · 0.45

Tested by

no test coverage detected