Skip to content

fix: remove pooling from gamepad store#20

Merged
Hachi-R merged 4 commits intomainfrom
feature/hyd-869
Jun 7, 2025
Merged

fix: remove pooling from gamepad store#20
Hachi-R merged 4 commits intomainfrom
feature/hyd-869

Conversation

@Hachi-R
Copy link
Copy Markdown
Contributor

@Hachi-R Hachi-R commented Jun 6, 2025

No description provided.

@vercel
Copy link
Copy Markdown

vercel bot commented Jun 6, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
hydra-web-staging ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 7, 2025 7:09pm

Copy link
Copy Markdown

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

Major refactor of gamepad handling system, replacing polling-based state management with an event-driven approach for improved performance and reduced CPU usage.

  • Removed legacy polling initialization from src/pages/_app.tsx in favor of event-based state management
  • Implemented state diffing in src/services/gamepad.service.ts to prevent unnecessary updates
  • Added stateChangeCallbacks system in gamepad service for efficient state propagation
  • Streamlined src/stores/gamepad.store.ts by removing unused fields and implementing caching for connected gamepads
  • Modified src/hooks/use-gamepad.hook.ts to use store-provided service access instead of direct singleton usage

4 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile

getButtonValue: (button: GamepadButtonType) => number;
getAxisValue: (axis: GamepadAxisType) => number;
vibrate: (options: GamepadVibrationOptions) => void;
connectedGamepads: Array<{ index: number; name: string; layout: string }>;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Use { index: number; name: string; layout: string }[] here instead

const service = getService();
const {
duration = 200,
weakMagnitude = 0.5,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Could you please move these magic numbers to constants? EX const DEFAULT_WEAK_MAGNITUDE or something more descriptive

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Jun 7, 2025

@Hachi-R Hachi-R merged commit e0f5151 into main Jun 7, 2025
7 of 8 checks passed
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.

2 participants