-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
FR: Add rumble support #5374
Comments
References <koreader#5374>.
@Frenzie: I do like the idea but after a quick search I think the implementation on android could have some problems:
Also I would like to finish koreader/android-luajit-launcher#183 first and these days I'm very busy trying to find time for both my daily job and my family. |
Certainly not in SDL. If it's blocking in Android then right now I'd be inclined to think of that as an issue for the device implementation to deal with.
I'm just asking for some feedback on the device abstraction logic. ;-) Job & family take precedence of course! |
References <koreader#5374>.
@Frenzie: I did a first implementation in koreader/android-luajit-launcher#190 We're fine running vibration in the Ui Thread so the call doesn't block and works great on the keyboard. But needs a lot of testing and tweaking because default intensity values are far from perfect (at least in 8.0+) I'm currently testing with this changes on the frontend: diff --git a/frontend/device/android/device.lua b/frontend/device/android/device.lua
index 4deee2c1..b194da09 100644
--- a/frontend/device/android/device.lua
+++ b/frontend/device/android/device.lua
@@ -70,6 +70,7 @@ local Device = Generic:new{
canRestart = no,
firmware_rev = android.app.activity.sdkVersion,
display_dpi = android.lib.AConfiguration_getDensity(android.app.config),
+ isHapticFeedbackEnabled = function() return android.canVibrate() end,
hasClipboard = yes,
hasOTAUpdates = canUpdateApk,
canOpenLink = yes,
@@ -225,6 +226,15 @@ function Device:initNetworkManager(NetworkMgr)
end
end
+function Device:performHapticFeedback(type)
+ local short, long = 80, 160 -- milliseconds
+ if type == "CONTEXT_CLICK" or type == "LONG_PRESS" then
+ android.vibrate(long)
+ elseif type == "KEYBOARD_TAP" then
+ android.vibrate(short)
+ end
+end
+
function Device:retrieveNetworkInfo()
local ssid, ip, gw = android.getNetworkInfo()
if ip == "0" or gw == "0" then |
If it comes to Android, it would be nice if it was toggable via a menu checkbox. |
Sure, I'm the first that want vibration disabled. But I'm starting to change my mind about the keyboard feedback because it can be really nice. In any case Having other things (duration, intensity) modificable via UI would be nice too. |
@poire-z @pazos That's an advantage I neglected to mention in koreader/android-luajit-launcher#190 (comment) Because then it is, in system settings. |
That is awesome 👍 Also the implementation is really simple. New PR in koreader/android-luajit-launcher#192 Works with the following change in the frontend: diff --git a/frontend/device/android/device.lua b/frontend/device/android/device.lua
index 4deee2c1..885731c6 100644
--- a/frontend/device/android/device.lua
+++ b/frontend/device/android/device.lua
@@ -70,6 +70,7 @@ local Device = Generic:new{
canRestart = no,
firmware_rev = android.app.activity.sdkVersion,
display_dpi = android.lib.AConfiguration_getDensity(android.app.config),
+ isHapticFeedbackEnabled = yes,
hasClipboard = yes,
hasOTAUpdates = canUpdateApk,
canOpenLink = yes,
@@ -225,6 +226,16 @@ function Device:initNetworkManager(NetworkMgr)
end
end
+function Device:performHapticFeedback(type)
+ if type == "CONTEXT_CLICK" then
+ android.hapticFeedback(C.AHAPTIC_CONTEXT_CLICK)
+ elseif type == "LONG_PRESS" then
+ android.hapticFeedback(C.AHAPTIC_LONG_PRESS)
+ elseif type == "KEYBOARD_TAP" then
+ android.hapticFeedback(C.AHAPTIC_KEYBOARD_TAP)
+ end
+end
+
function Device:retrieveNetworkInfo()
local ssid, ip, gw = android.getNetworkInfo()
if ip == "0" or gw == "0" then |
Given that I named them after the Android constants because they seemed sensible enough, you should be able to just use C["AHAPTIC_"..type]. |
References <koreader#5374>.
More of a brainstorm than an FR. Linkdump without commentary incoming.
Docs:
https://wiki.libsdl.org/SDL_HapticOpenFromJoystick
https://developer.android.com/reference/android/os/Vibrator
https://davidgow.net/handmadepenguin/ch6.html
Background:
https://medium.com/@sdrzn/make-your-ios-app-feel-better-a-comprehensive-guide-over-taptic-engine-and-haptic-feedback-724dec425f10
The text was updated successfully, but these errors were encountered: