Fix rumble on devices such as Ayn Odin 2#538
Fix rumble on devices such as Ayn Odin 2#538kiequoo wants to merge 1 commit intoutkarshdalal:masterfrom
Conversation
The rumble poller now always runs when the gamepad buffer exists, regardless of virtual gamepad mode or controller detection state. This ensures vibration works on devices with built-in controllers (like Ayn Odin 2) even when the on-screen controller overlay is disabled. The existing fallback logic (try controller vibrator → fall back to device vibration) ensures both external controllers and built-in controllers work correctly.
📝 WalkthroughWalkthroughThe changes refactor vibration handling in WinHandler.java to always poll the rumble buffer when available, prioritize physical controller vibration attempts, and use device vibrator as the fallback mechanism instead of phone vibrator, with corresponding variable naming updates. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. 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 (2)
app/src/main/java/com/winlator/winhandler/WinHandler.java (2)
636-648: Naming inconsistency withstopVibration.
startVibrationnow usesdeviceVibrator/finalDeviceAmplitude, butstopVibration(line 665) still usesphoneVibratorand the comment on line 664 says "phone's vibration." They reference the same system service, so there's no functional bug, but the inconsistent naming is confusing.Suggested rename in stopVibration for consistency
// Always attempt to stop the phone's vibration - Vibrator phoneVibrator = (Vibrator) activity.getSystemService(Context.VIBRATOR_SERVICE); - if (phoneVibrator != null) { - phoneVibrator.cancel(); + // Always attempt to stop the device's vibration + Vibrator deviceVibrator = (Vibrator) activity.getSystemService(Context.VIBRATOR_SERVICE); + if (deviceVibrator != null) { + deviceVibrator.cancel(); }
639-650: System service fetched on every vibration event.
activity.getSystemService(Context.VIBRATOR_SERVICE)is called every timestartVibrationfires (up to 50 times/second from the poller). The same applies tostopVibration. Consider caching theVibratorinstance as a field during construction, similar to howactivityis already stored.Example
private Context activity; +private Vibrator deviceVibrator; ... // In constructor: this.activity = xServerView.getContext(); +this.deviceVibrator = (Vibrator) activity.getSystemService(Context.VIBRATOR_SERVICE);Then use the cached field directly in
startVibrationandstopVibration.
There was a problem hiding this comment.
No issues found across 1 file
Since this is your first cubic review, here's how it works:
- cubic automatically reviews your code and comments on bugs and improvements
- Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
- Add one-off context when rerunning by tagging
@cubic-dev-aiwith guidance or docs links (includingllms.txt) - Ask questions if you need clarification on any suggestion
|
Can you clarify if this is for rumble or vibration? Right now the only thing we have connected to vibration for onscreen controls is a small vibration when you press a button on screen. |
Hi! this is for rumble (to clarfiy: when the game itself wants the device to shake). The problem was that on devices such as the Odin 2 (which has a built-in controller) rumble didn't work. There is a trick to make it work, which is to enable the on-screen controls and then edit it, deleting all the individual elements. But this is a bit of a hack and most people wouldn't know to do this (plus it seems you need to turn on the on screen controller each time you load a game) By removing the |
|
just tried this on my AYN Thor, worked like a charm! |
The rumble poller now always runs when the gamepad buffer exists, regardless of virtual gamepad mode or controller detection state. This ensures rumble works on devices with built-in controllers (like Ayn Odin 2) even when the on-screen controller overlay is disabled.
The existing fallback logic (try controller vibrator -> fall back to device rumble) ensures both external controllers and built-in controllers work correctly.
Summary by cubic
Fixes missing vibration when on-screen controls are disabled by always polling the rumble buffer. Restores haptics for built-in controllers like the Ayn Odin 2 while keeping a safe fallback to device vibration.
Written for commit 990db2c. Summary will update on new commits.
Summary by CodeRabbit