Skip to content

feat(gamepad-tester): add button images #233

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 2, 2025

Conversation

ReenigneArcher
Copy link
Member

@ReenigneArcher ReenigneArcher commented May 1, 2025

Description

This PR adds button images and moves the gamepad-helper.js to the new https://github.com/LizardByte/gamepad-helper library.

Buttons icons change depending on the type of gamepad connected.

TODO:

  • attribution

Screenshot

image

Issues Fixed or Closed

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Dependency update (updates to dependencies)
  • Documentation update (changes to documentation)
  • Repository update (changes to repository files, e.g. .github/...)

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated the in code docstring/documentation-blocks for new or existing methods/components

@ReenigneArcher ReenigneArcher marked this pull request as ready for review May 1, 2025 23:32
@ReenigneArcher ReenigneArcher requested a review from Copilot May 1, 2025 23:33
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces button images into the gamepad tester UI and migrates to an externally hosted gamepad helper library. Key changes include updating the HTML to load the new dependency and tweaking UI labels, as well as refactoring gamepad-tester.js to call methods on a gamepadHelper instance instead of a static GamepadHelper object.

Reviewed Changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.

File Description
gamepad-tester.html Adds external dependency and updates UI text for stick labels.
assets/js/gamepad-tester.js Instantiates gamepadHelper, updates helper method calls, and improves DOM creation.
assets/js/gamepad-helper.js Removal of the local helper in favor of the externally maintained library.
Files not reviewed (1)
  • _sass/circular-progress.scss: Language not supported
Comments suppressed due to low confidence (1)

gamepad-tester.html:9

  • Verify that the external gamepad-helper library provides all the necessary methods (including getButtonImagePath) and that its version is compatible with the current integration.
  - https://cdn.jsdelivr.net/npm/@lizardbyte/[email protected]/dist/gamepad-helper.js

Comment on lines +148 to +176
// Create the progress elements
const progressLeft = document.createElement('span');
progressLeft.className = 'progress-left';
progressLeft.innerHTML = `<span class="progress-bar" id="progress-bar-left-${i}"></span>`;

const progressRight = document.createElement('span');
progressRight.className = 'progress-right';
progressRight.innerHTML = `<span class="progress-bar" id="progress-bar-right-${i}"></span>`;

// Create the button content
const buttonContent = document.createElement('div');
buttonContent.className = 'button-content';

// Add either image with fallback text, or just text
if (buttonImagePath) {
buttonContent.innerHTML = `
<div class="button-image-container">
<img src="${buttonImagePath}" alt="${buttonName}" class="button-image" onerror="this.style.display='none'; this.nextElementSibling.style.display='block';">
<div class="button-name" style="display: none;">${buttonName}</div>
</div>
<div class="button-value" id="button-value-${i}">0.00</div>
`;
} else {
buttonContent.innerHTML = `
<div class="button-name">${buttonName}</div>
<div class="button-value" id="button-value-${i}">0.00</div>
</div>
`;
`;
}

Copy link
Preview

Copilot AI May 1, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider refactoring the repeated DOM creation logic for progress elements and button content into a separate helper function to improve code maintainability.

Copilot uses AI. Check for mistakes.

@@ -1,4 +1,6 @@
document.addEventListener('DOMContentLoaded', function() {
const gamepadHelper = new GamepadHelper()
const gamepadHelperVersion = '2025.501.232754'
Copy link
Preview

Copilot AI May 1, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider externalizing the version constant to a centralized configuration so that updates to the dependency version can be managed more easily.

Copilot uses AI. Check for mistakes.

@ReenigneArcher ReenigneArcher merged commit f7df433 into master May 2, 2025
12 checks passed
@ReenigneArcher ReenigneArcher deleted the feat/gamepad-tester/add-button-images branch May 2, 2025 02:40
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