Xperia 10 iii: make Google assistant button a camera trigger

In that case, think it would be out of place to suggest using the Google Assistant button as a Flashlight toggle instead?

2 Likes

So… is there a way to handle that button programmatically? It almost hurts how it’s been there completely unused while it could be such a nice flashlight toggle or play/pause key…

3 Likes

Please no. We have had such a button on the Xperia X. It made screenshots involuntarily when holding the phone.

I would prefer if it was possible to assign any of the topmenu shortcuts to this.
So you can have it as flashlight, or wifi toggle, or mute/dnd switch.

3 Likes

I’m sure we’re talking about an optional feature, i.e. one that could be enabled or not.

Anyway, evdev_trace -t reports pressing that button as KEY_01c9 (event3). so I’ve tried to make mce use it by this name and assign another button’s function to it, e.g.

printf "[EVDEV]\nKEY_01c9=KEY_VOLUMEDOWN\n" > /etc/mce/99-unused-button.ini
systemctl restart mce

Sadly, to no avail. Will keep trying.

3 Likes

I’ve posted somewhat relevant stuff earlier, regarding that button

1 Like

I tried something similar, getting the key event to some MCE-“known” button through udev hwdb:

/etc/udev/hwdb.d/70-xperia10iii-assistant-button.hwdb

#  - Generic input devices match:
#
# E: MODALIAS=input:b0019v0001p0001e0100-e0,1,k72,1C9,ramlsfw
evdev:input:b0019v0001p0001e0100*
 KEYBOARD_KEY_01c9=controlpanel
# KEYBOARD_KEY_01c9=camera

and then in /etc/mce/99-xperia10iii-assistant-button.ini

[EVDEV_TYPE]

evdev:input:b0019v0001p0001e0100=INPUT;KEYBOARD;MOUSE;DOUBLE_TAP;ACTIVITY


[EVDEV]

# see https://github.com/sailfishos/mce/blob/master/evdev.inc#L607
# and https://github.com/sailfishos/mce/blob/master/evdev.inc#L29
#KEY_01c9=SW_KEYPAD_SLIDE
#KEY_01c9=SW_POWER
#KEY_01c9=SW_RFKILL_ALL
#KEY_01c9=KEY_RFKILL
#KEY_01c9=KEY_MICMUTE
#KEY_CONTROLPANEL=SW_RFKILL_ALL
#KEY_CONTROLPANEL=KEY_RFKILL
KEY_CONTROLPANEL=KEY_MICMUTE

But this also does nothing :slightly_frowning_face:

3 Likes

I guess I’ve tried everything that came to my mind. Can’t make that damn button recognized :woozy_face: KEY_VOLUMEDOWN which is the same device and handled by the same event3 can be reassigned without any problems whereas this KEY_01c9 just doesn’t react.

1 Like

I have a hunch there is some additional glue needed in XKB config to map it to a proper event. Not sure.

Also, if I understand the mce code correctly, only some specific keys are recognized by mce, so mapping just any key can’t work.

Yay! Success!

Patched it to be handled as a “Home” key, which is already handled in MCE and Lipstick:

https://build.merproject.org/package/show/home:nephros:sailfishos/mce

FAT WARNING: this is a crucial system package. Do NOT just download an RPM from a random dude on a forum and install it.
Hence I have disabled publishing RPMs for that package.

But you can take the patch and build it yourself.

But now MCE recognizes a KEY_ASSISTANT, you can use /etc/mce/99-evdevfoo.ini to map it to another.

12 Likes

Cool! Now we need to pressure Jolla to upstream it.

But if they upstream exactly the current changes, Assistant button being Home button is not exactly desireable, and only useful for people who will later remap it.
So Jolla would probably need to create a new function of camera button in a few packages anyways.
But it is cool to see it works!

Wow, great! I’m lazy so I’ve just grabbed your rpm from obs and I’ll give it a try :grinning:

Another hint: The “home” key event is actually handled in /usr/share/lipstick-jolla-home-qt5/compositor.qml around line 1762 (search for “home-key”).

If you are an adventurous QML hacker you can make it do stuff there.
You can also use the dbus code there to do things in applications.

Be wewwy wewwy careful though, making a mistake in that file will make Lipstick not start.

2 Likes

I’ve already mentioned that I am lazy so instead of installing it I actually just replaced /usr/sbin/mce with the one you built, extracted from your rpm.

Works PERFECTLY FINE, thank you @nephros!

Edit: Via /etc/mce/99-something.ini I was only able to remap this key to KEY_POWER. Attempts to remap it to other keys doesn’t seem to work.

I would really love to be able to assign it to KEY_PLAYPAUSE. I guess I will need to do it via /usr/share/lipstick-jolla-home-qt5/compositor.qml… I’ll play with it tomorrow.

P.S. build.sailfishos.org permanently times out. build.merproject.org works but “Sign up is disabled”. So how to sign up?

1 Like

Yeah if I read mce code correctly it has two paths handling key events: evdev and powerkey.

The evdev path ignores any powerkey events. Probably that is why only that mapping works.

But my C comprehension skills are low, I might be wrong.

About OBS, accounts must be requested through mal or lbt on IRC, there is no online sign up.

And yes, b.s.o has been acting up lately, but b.m.o works reliably.

1 Like

About Lipstick, you can see it listens for that event on the mce dbus, you probably can copy that code somewhere else to do more things (but need to disable the original handler).

2 Likes

EDIT: I managed to make it work as mpris PlayPause by making this simple patch:

--- /usr/share/lipstick-jolla-home-qt5/compositor.qml	2022-08-06 22:26:20.000000000 +0200
+++ /usr/share/lipstick-jolla-home-qt5/compositor.qml	2022-08-06 22:48:32.000000000 +0200
@@ -21,6 +21,7 @@
 import Sailfish.Silica.private 1.0
 import Sailfish.Lipstick 1.0
 import com.jolla.lipstick 0.1
+import org.nemomobile.mpris 1.0
 
 import "layers"
 import "launcher"
@@ -310,6 +311,8 @@
             alarmLayerItem.parent = alarmApplicationForeground
         }
     }
+    
+    MprisManager { id: mprisManager }
 
     FileWatcher {
         id: initDoneFile
@@ -1761,7 +1764,7 @@
                 root.showUnlockScreen()
             } else if (argument === "home-key") {
                 if (!root.systemGesturesDisabled) {
-                    root.goToSwitcher(true)
+                  mprisManager.playPause() //  root.goToSwitcher(true)
                 }
             }
         }

Hurray!

One sad thing, though, is that the button is no longer read when the phone goes to sleep. So it takes waking up the device (e.g. by pressing one of the remaining buttons or using the fingerprint sensor) in order to use it. Which kind of contradicts its purpose.

I’d say that in this case Jolla is trying to save power not where they should. How much power draw can be saved by disabling button click monitoring? Microamperes?

3 Likes

Just had another idea how to use that.

As we have the Guest user function, make the button switch that account on long press.

That would enable you to hand the phone to someone, and sneakily hold that button while doing so.

They will have a functional but empty environment to examine, even though they just saw you using it. Magic!

I call it the Secret Agent Magic button, SAM.

6 Likes

Do you know what other arguments nokia.com.mce.signal provides? Compositor.qml uses “home-key” and “double-power-key”. So maybe there’s more, e.g. “double-home-key”, or some “long-press-home-key”…