Changed render of shoulder and trigger UI visuals#14
Conversation
📝 WalkthroughWalkthroughUpdated gamepad controller layout geometry for Xbox and Sony layouts by adjusting bumper and trigger rectangle coordinates. Refined the DrawTrigger rendering function to compute dimensions from corner vectors, apply clamped corner radius logic, and scale trigger fill height based on computed dimensions. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/gamepad_renderer.cpp (1)
245-247: Defensively clamp trigger value before fill math.
src/hidapi_backend.cppcurrently normalizes to[0,1], but a local clamp here would make rendering resilient if another backend/path ever violates that contract.Optional hardening diff
- if (value > 0.01f) { - float fillH = h * value; + const float clampedValue = std::clamp(value, 0.0f, 1.0f); + if (clampedValue > 0.01f) { + float fillH = h * clampedValue; ImVec2 ftl(tl.x, br.y - fillH); dl->AddRectFilled(ftl, br, IM_COL32(100, 200, 255, 220), rnd); }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/gamepad_renderer.cpp` around lines 245 - 247, Clamp the trigger axis value before computing the filled height so rendering is resilient to out-of-range inputs: ensure the local variable used in the fill calculation (the one named value used to compute float fillH = h * value) is clamped to [0.0f, 1.0f] (e.g., via std::clamp or equivalent) immediately before calculating fillH/ftl and calling dl->AddRectFilled(ftl, br, ..., rnd); this prevents negative or >1 values from producing incorrect ftl/br math in gamepad_renderer.cpp.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/gamepad_renderer.cpp`:
- Around line 245-247: Clamp the trigger axis value before computing the filled
height so rendering is resilient to out-of-range inputs: ensure the local
variable used in the fill calculation (the one named value used to compute float
fillH = h * value) is clamped to [0.0f, 1.0f] (e.g., via std::clamp or
equivalent) immediately before calculating fillH/ftl and calling
dl->AddRectFilled(ftl, br, ..., rnd); this prevents negative or >1 values from
producing incorrect ftl/br math in gamepad_renderer.cpp.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: c90ed28a-70ed-47e4-8240-bf0a3eeff980
📒 Files selected for processing (1)
src/gamepad_renderer.cpp
Summary by CodeRabbit