Reply
Thread Tools
Posts: 986 | Thanked: 1,526 times | Joined on Jul 2010
#1
so many years later, finally implemented a hardware button monitor for sailfish!

functionality is similar to n9-button-monitor.

you can use sf-button-monitor to run arbitrary commands while the phone is locked, or unlocked.

tested and working on Xperia X and Xperia X Compact, YMMV

NOTE: core functionality provided by simply reading from:
Code:
/dev/input/by-path/platform-gpio_keys.105-event
dependencies:
perl
dbus-send (for all CONDITIONS, and for all ACTIONS except cmd(SHELL_CMD))

the following unrelated hacks make this script more useful:
-dont unlock the screen when pressing volume/camera
-dont control media volume when screen is locked
-write window title to a file so window() condition can tell which program is running


https://github.com/teleshoes/sf-button-monitor
__________________
~ teleshoes ~

Last edited by wolke; 2020-09-05 at 15:40.
 

The Following 16 Users Say Thank You to wolke For This Useful Post:
Posts: 986 | Thanked: 1,526 times | Joined on Jul 2010
#2
ALSO: this script is only useful if you turn off display-unlock-with-volume/camera with mcetool:
Code:
mcetool --set-exception-length-volume=0
mcetool --set-exception-length-camera=0
and also if you modify lipstick to not modify media volume while screen is locked:
/usr/share/lipstick-jolla-home-qt5/volumecontrol/VolumeControl.qml
Code:
*** 473,478 ****
--- 473,481 ----
          }
          onVolumeChanged: restartHideTimerIfWindowVisibleAndWarningNotVisible()
          onVolumeKeyPressed: {
+             if (Lipstick.compositor.screenIsLocked) {
+               return
+             }
              if (keyRepeat.running || keyRepeatDelay.running) {
                  if (Lipstick.compositor.visible) {
                      screenshotTimer.restart()
__________________
~ teleshoes ~
 

The Following 5 Users Say Thank You to wolke For This Useful Post:
Posts: 1,335 | Thanked: 3,931 times | Joined on Jul 2010 @ Brittany, France
#3
I'll be trying that soon on the Proš, it should be very useful, thanks!

Can this be used for events like the following (keyboard open/closed state)?

Code:
/dev/input/event2: 1579511420.010 - 0x05/EV_SW - 0x00a/SW_KEYPAD_SLIDE - 0
Code:
/dev/input/event2: 1579511420.010 - 0x05/EV_SW - 0x00a/SW_KEYPAD_SLIDE - 1
 

The Following 4 Users Say Thank You to Kabouik For This Useful Post:
mosen's Avatar
Community Council | Posts: 1,669 | Thanked: 10,225 times | Joined on Nov 2014 @ Lower Rhine
#4
Very Cool!
On Proš there are different files.

Code:
cat /dev/input/by-path/platform-c17a000.i2c-event-kbd
produces following output when hammering the harware kbd:
Code:
�&^S
�&^S
�&^��%�&^���&^�%�&^��&^��%�&^���&^B�%�&^B��&^�
                                              %�&^�
�&^����&^��^C^Z -�&^Z   �&^3C��&^3C�&^�7��&^�7�&^�v�&^
When i copy that path into your scripts $INPUT_DEV i get no output from your script however.

For kbd open/close, volume and powerbutton i get same formated values from

Code:
cat /dev/input/by-path/platform-soc\:gpio_keys-event
there is a 3rd file in that folder that i could not quench cat output from.
Code:
platform-1711a000.sound-tavil-event
 

The Following 5 Users Say Thank You to mosen For This Useful Post:
Posts: 986 | Thanked: 1,526 times | Joined on Jul 2010
#5
on x compact, SFOS 3.2.1.20, the key is in the 10th byte and the value (press/release) is in the 12th. (each key press/release produces 16 bytes)

just cat it to a file, press a single key, ctrl+c, and then read the bytes (with hexdump or something). do it 3x with the same key, and 3x with a different key and compare/contrast
__________________
~ teleshoes ~
 

The Following 4 Users Say Thank You to wolke For This Useful Post:
mosen's Avatar
Community Council | Posts: 1,669 | Thanked: 10,225 times | Joined on Nov 2014 @ Lower Rhine
#6
Will try. Thanks for the explanation!

But i have to correct, your script with adapted path to that of the Proš gives output on exactly one key of the hardware keyboard.

It is the w key on QWERTZ / q key on QWERTY that does that if pressed multiple times in a row:
Code:
EVENT: CAM_HALF => press              1239ms  (ch-press)
EVENT: CAM_HALF => release              87ms  (ch)
EVENT: CAM_HALF => press               197ms  (ch ch-press)
EVENT: CAM_HALF => release              86ms  (ch ch)
EVENT: CAM_HALF => press               148ms  (ch ch ch-press)
EVENT: CAM_HALF => release              62ms  (ch ch ch)
EVENT: CAM_HALF => press               119ms  (ch ch ch ch-press)
EVENT: CAM_HALF => release              61ms  (ch ch ch ch)
EVENT: CAM_HALF => press               103ms  (ch ch ch ch ch-press)
EVENT: CAM_HALF => release              81ms  (ch ch ch ch ch)
EVENT: CAM_HALF => press                94ms  (ch ch ch ch ch ch-press)
EVENT: CAM_HALF => release              76ms  (ch ch ch ch ch ch)
EVENT: CAM_HALF => press                99ms  (ch ch ch ch ch ch ch-press)
EVENT: CAM_HALF => release              89ms  (ch ch ch ch ch ch ch)
EDIT:
https://mosushi.de/misc/keyboard-single1.txt
Above link is cat > keyboard-single1.txt with only the "1" pressed once.

https://mosushi.de/misc/keyboard-3x1.txt
This is the cat > keyboard-3x1.txt if i press the "1" key three times followed by "2" key three times.
Trying to makes sense of the output, figure to still post it quick since you all are faster. lol.

Last edited by mosen; 2020-01-21 at 15:15.
 

The Following 2 Users Say Thank You to mosen For This Useful Post:
Posts: 986 | Thanked: 1,526 times | Joined on Jul 2010
#7
in that case: modify my script, adding this line after line 195:
print "$buttonId ($value)\n";

then run it, press those buttons you want to do, and then add lines around 112 like this:
Code:
  [qw(16   KEY_W kw)],
__________________
~ teleshoes ~
 

The Following 3 Users Say Thank You to wolke For This Useful Post:
mosen's Avatar
Community Council | Posts: 1,669 | Thanked: 10,225 times | Joined on Nov 2014 @ Lower Rhine
#8
Perfect, thank you.
Now i understand some more of the script.
I can print the assigned value to every key if i add them all in the block around line 115.

Specific to Proš:
"sym" is code 249.
"FX" is code 125.
"Yellow Mod" is code 100.
I guess the 100 is due to TheKits kernel mod to make it usable in sfos xkbd, right @kabouik?
 

The Following 3 Users Say Thank You to mosen For This Useful Post:
Posts: 986 | Thanked: 1,526 times | Joined on Jul 2010
#9
btw, if you get something cool working for you, please pull request your changes. i might not add them to master since i cannot test it in any way (i ONLY have xperias), but others might benefit from it, and i might buy an fxtec soon myself
__________________
~ teleshoes ~
 

The Following 4 Users Say Thank You to wolke For This Useful Post:
mosen's Avatar
Community Council | Posts: 1,669 | Thanked: 10,225 times | Joined on Nov 2014 @ Lower Rhine
#10
Originally Posted by wolke View Post
btw, if you get something cool working for you, please pull request your changes. i might not add them to master since i cannot test it in any way (i ONLY have xperias), but others might benefit from it, and i might buy an fxtec soon myself
Do you think it is possible to do a patchmanager3 patch from that script and execute code on Key events? Or is it a potential battery hog?

EDIT:
Now i have the script altered for gpio read out and found code 10 is the state of the Keyboard.
10 - release is opened
10 - pressed is closed

EDIT 2:
Now i am able to switch on the keyboard backlight when it opens with this action in sf-button-monitor.conf
Code:
action=cmd(echo 1 > /sys/class/leds/keyboard-backlight/brightness),kb,always
where "kb" is defined as following in the script:
Code:
  [qw(10   KBD_STATE kb)],
I have not quite figured out how to set the backlight back to 0 on kbd close. But that is done anyway when the display goes off.

EDIT 3:
I just created a .desktop file in /user/share/applications/ to start the script from app-grid.
Works for now :P

Last edited by mosen; 2020-01-21 at 18:35.
 

The Following 3 Users Say Thank You to mosen For This Useful Post:
Reply


 
Forum Jump


All times are GMT. The time now is 16:07.