Skip to content

Add option "Haptic feedback on key repeat" #626

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 22, 2024
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 @@ -62,6 +62,8 @@ class AppPrefs(private val sharedPreferences: SharedPreferences) {
"haptic_on_keyup",
false
) { hapticOnKeyPress.getValue() != InputFeedbackMode.Disabled }
val hapticOnRepeat = switch(R.string.haptic_on_repeat, "haptic_on_repeat", false)

val buttonPressVibrationMilliseconds: ManagedPreference.PInt
val buttonLongPressVibrationMilliseconds: ManagedPreference.PInt

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ abstract class BaseKeyboard(

private val vivoKeypressWorkaround by prefs.advanced.vivoKeypressWorkaround

private val hapticOnRepeat by prefs.keyboard.hapticOnRepeat

var popupActionListener: PopupActionListener? = null

private val selectionSwipeThreshold = dp(10f)
Expand Down Expand Up @@ -162,7 +164,7 @@ abstract class BaseKeyboard(
swipeRepeatEnabled = true
swipeThresholdX = selectionSwipeThreshold
swipeThresholdY = disabledSwipeThreshold
onGestureListener = OnGestureListener { _, event ->
onGestureListener = OnGestureListener { view, event ->
when (event.type) {
GestureType.Move -> when (val count = event.countX) {
0 -> false
Expand All @@ -172,6 +174,7 @@ abstract class BaseKeyboard(
val action = KeyAction.SymAction(KeySym(sym), KeyStates.Empty)
repeat(count.absoluteValue) {
onAction(action)
if (hapticOnRepeat) InputFeedbacks.hapticFeedback(view)
}
true
}
Expand All @@ -184,12 +187,13 @@ abstract class BaseKeyboard(
swipeRepeatEnabled = true
swipeThresholdX = selectionSwipeThreshold
swipeThresholdY = disabledSwipeThreshold
onGestureListener = OnGestureListener { _, event ->
onGestureListener = OnGestureListener { view, event ->
when (event.type) {
GestureType.Move -> {
val count = event.countX
if (count != 0) {
onAction(KeyAction.MoveSelectionAction(count))
if (hapticOnRepeat) InputFeedbacks.hapticFeedback(view)
true
} else false
}
Expand All @@ -216,8 +220,9 @@ abstract class BaseKeyboard(
}
is KeyDef.Behavior.Repeat -> {
repeatEnabled = true
onRepeatListener = { _ ->
onRepeatListener = { view ->
onAction(it.action)
if (hapticOnRepeat) InputFeedbacks.hapticFeedback(view)
}
}
is KeyDef.Behavior.Swipe -> {
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 @@ -283,4 +283,5 @@
<string name="restart_fcitx_instance_confirm">Fcitx instance will be destroyed and reinitialized. Proceed?</string>
<string name="ignore_system_window_insets">Ignore system WindowInsets</string>
<string name="browse_user_data_dir">Browse user data directory</string>
<string name="haptic_on_repeat">Haptic feedback on key repeat</string>
</resources>
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy