Skip to content

Changed render of shoulder and trigger UI visuals#14

Merged
nefarius merged 1 commit into
masterfrom
shoulder-ui-rework
Apr 11, 2026
Merged

Changed render of shoulder and trigger UI visuals#14
nefarius merged 1 commit into
masterfrom
shoulder-ui-rework

Conversation

@nefarius

@nefarius nefarius commented Apr 11, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • Bug Fixes
    • Adjusted controller bumper and trigger positioning and sizing for improved layout accuracy across Xbox and PlayStation controller layouts.
    • Refined trigger rendering behavior to better scale fill proportions dynamically based on rectangle dimensions.

@coderabbitai

coderabbitai Bot commented Apr 11, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Updated 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

Cohort / File(s) Summary
Gamepad Renderer Layout & Trigger Logic
src/gamepad_renderer.cpp
Modified bumper rectangle coordinates for both XBOX_LAYOUT and SONY_LAYOUT. Repositioned trigger rectangles from vertical sidebar placement to horizontal grip-positioned layout. Enhanced DrawTrigger rendering to calculate width/height from corner vectors, compute corner radius with clamping, and scale filled region height proportionally using computed height rather than direct coordinate difference.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰✨ The bumpers shift, the triggers rest,
On sides where paws can grip the best,
With rounded corners, smooth and tight,
The gamepad layout feels just right! 🎮

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly describes the main change: refactoring the rendering of shoulder (bumper) and trigger UI visuals in the gamepad renderer.

✏️ 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/gamepad_renderer.cpp (1)

245-247: Defensively clamp trigger value before fill math.

src/hidapi_backend.cpp currently 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

📥 Commits

Reviewing files that changed from the base of the PR and between 2eb4d5c and a49da8e.

📒 Files selected for processing (1)
  • src/gamepad_renderer.cpp

@nefarius nefarius merged commit a5b51bf into master Apr 11, 2026
2 checks passed
@nefarius nefarius deleted the shoulder-ui-rework branch April 11, 2026 01:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant