Android: option to vibrate on button press#580
Android: option to vibrate on button press#580BigRobCoder wants to merge 3 commits intoaduros:mainfrom
Conversation
|
|
||
| private readonly diskPrefix: string; | ||
|
|
||
| private vibrateLevelIdx = 0; |
There was a problem hiding this comment.
I wasn't sure where to store the vibration level. I tried in virtual-gamepad.ts at first, but didn't see how menu-overlay.ts could access it, so it ended up here.
There was a problem hiding this comment.
I'm defaulting to "OFF" for now, but if feedback is positive I recommend we default to "MEDIUM", I think the vibration really makes it feel more tactile.
|
|
||
| @state() private selectedIdx = 0; | ||
| @state() private netplaySummary: { playerIdx: number, ping: number }[] = []; | ||
| @state() private vibrateLevel = ""; |
There was a problem hiding this comment.
I tried just referencing app.vibrateLevel, but wasn't seeing render updates immediately. Is this the correct pattern? Mirror the setting in a local @state() variable?
|
|
||
| render () { | ||
| if (!this.vibrateLevel) { | ||
| this.vibrateLevel = this.app.vibrateLevel[0]; |
There was a problem hiding this comment.
I tried setting this in the constructor, but looks like app is not yet ready, so moved it to here.
|
Hmm, after some further testing it seems like the vibration stops working after a while. Maybe chrome blocks website vibrations if they are triggered too frequently? |
|
Was testing this for a while tonight on a Samsung Galaxy S21, no issues this time. Tried testing on an iPhone 13 as well, as intended there was no "vibrate" menu option. |
|
Thanks so much for the PR! It looks very clean, and this is a great feature. Some feedback/questions after testing:
|
Very interesting. On my Samsung Galaxy S21, the different vibration do feel different, but it probably depends on the device. The way I have it now, "LOW" should be 1 millisecond of vibration, "MEDIUM" 2, and "HIGH" 4. Maybe I should have more like 10 different levels of vibration, from 1ms to 1024ms?
Yeah, I started out just vibrating on touchdown, but after playing a bunch of games, it just didn't feel right to me, and vibrate both felt more right.
Sure.
Yeah, that makes sense. |
I haven't made a OSS contribution in a while, and web stuff is not my expertise, so any feedback is appreciated!