-
-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Disable vibration strength preference
Perform haptic feedback on virtual button release
- Loading branch information
1 parent
23cc6a9
commit 00119a3
Showing
4 changed files
with
25 additions
and
6 deletions.
There are no files selected for viewing
16 changes: 14 additions & 2 deletions
16
app/src/main/java/me/magnum/melonds/ui/emulator/input/FeedbackInputHandler.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,23 @@ | ||
package me.magnum.melonds.ui.emulator.input | ||
|
||
import android.view.HapticFeedbackConstants | ||
import android.view.View | ||
import me.magnum.melonds.common.vibration.TouchVibrator | ||
|
||
abstract class FeedbackInputHandler(inputListener: IInputListener, private val enableHapticFeedback: Boolean, private val touchVibrator: TouchVibrator) : BaseInputHandler(inputListener) { | ||
protected fun performHapticFeedback() { | ||
|
||
enum class HapticFeedbackType { | ||
KEY_PRESS, | ||
KEY_RELEASE | ||
} | ||
|
||
protected fun performHapticFeedback(view: View, type: HapticFeedbackType) { | ||
if (enableHapticFeedback) { | ||
touchVibrator.performTouchHapticFeedback() | ||
val feedbackType = when (type) { | ||
HapticFeedbackType.KEY_PRESS -> HapticFeedbackConstants.KEYBOARD_TAP | ||
HapticFeedbackType.KEY_RELEASE -> HapticFeedbackConstants.CLOCK_TICK | ||
} | ||
view.performHapticFeedback(feedbackType) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
00119a3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you make the vibaration strength follow the device settings
I mean if I set to light, medium or strong vaibration on my device. Melonds vibration would be the same