Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ object InputFeedbacks {
private val soundOnKeyPress by AppPrefs.getInstance().keyboard.soundOnKeyPress
private val soundOnKeyPressVolume by AppPrefs.getInstance().keyboard.soundOnKeyPressVolume
private val hapticOnKeyPress by AppPrefs.getInstance().keyboard.hapticOnKeyPress
private val hapticOnKeyUp by AppPrefs.getInstance().keyboard.hapticOnKeyUp
private val buttonPressVibrationMilliseconds by AppPrefs.getInstance().keyboard.buttonPressVibrationMilliseconds
private val buttonLongPressVibrationMilliseconds by AppPrefs.getInstance().keyboard.buttonLongPressVibrationMilliseconds
private val buttonPressVibrationAmplitude by AppPrefs.getInstance().keyboard.buttonPressVibrationAmplitude
Expand All @@ -53,13 +54,13 @@ object InputFeedbacks {

private val audioManager = appContext.audioManager

fun hapticFeedback(view: View, longPress: Boolean = false) {
fun hapticFeedback(view: View, longPress: Boolean = false, keyUp: Boolean = false) {
when (hapticOnKeyPress) {
InputFeedbackMode.Enabled -> {}
InputFeedbackMode.Disabled -> return
InputFeedbackMode.FollowingSystem -> if (!systemHapticFeedback) return
}

if (keyUp && !hapticOnKeyUp) return
val duration: Long
val amplitude: Int
val hfc: Int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ class AppPrefs(private val sharedPreferences: SharedPreferences) {
R.string.disabled
)
)
val hapticOnKeyUp = switch(
R.string.button_up_haptic_feedback,
"haptic_on_keyup",
false
) { hapticOnKeyPress.getValue() != InputFeedbackMode.Disabled }
val buttonPressVibrationMilliseconds: ManagedPreference.PInt
val buttonLongPressVibrationMilliseconds: ManagedPreference.PInt

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ open class CustomGestureView(ctx: Context) : FrameLayout(ctx) {
}
MotionEvent.ACTION_UP -> {
isPressed = false
InputFeedbacks.hapticFeedback(this, longPress = true, keyUp = true)
dispatchGestureEvent(GestureType.Up, event.x, event.y)
val shouldPerformClick = !(touchMovedOutside ||
longPressTriggered ||
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<string name="hide_key_config">隐藏快捷键配置</string>
<string name="_not_available_">(不可用)</string>
<string name="button_haptic_feedback">按键时振动</string>
<string name="button_up_haptic_feedback">按键松开时振动</string>
<string name="button_vibration_milliseconds">按键振动时长</string>
<string name="button_press">短按</string>
<string name="button_long_press">长按</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<string name="hide_key_config">Hide hotkey configurations</string>
<string name="_not_available_">(Not Available)</string>
<string name="button_haptic_feedback">Haptic feedback on keypress</string>
<string name="button_up_haptic_feedback">Haptic feedback on keyup</string>
<string name="button_vibration_milliseconds">Keypress vibration duration</string>
<string name="button_press">Press</string>
<string name="button_long_press">Long press</string>
Expand Down