Page 1 of 1

BUTTON Pressed-Trigger

Posted: 17 Jul 2014 23:21
by ammar galala
Hi There :D ,
I was working on a Flow that makes the phone Switch Songs (NEXT / PREVIOUS) in Music Player by PRESSING the VOLUME UP / DOWN (Hardware Buttons) ;) .
I Needed this flow and found it very Useful when DRIVING a CAR.
And if the phone has a PASS or PIN, U'll have to take time opening it then Switching NEXT / PREVIOUS.

I made That Flow Using TRIGGER: Audio Volume. by watching the volume goes Up and Down When H.W Buttons were pressed, It's a Complicated method..

If There was a ( BUTTON-PRESS TRIGGER ) It will be Much Easier :)

I Hope It Will be Something Like This:
TRIGGER: BUTTON PRESSED.
Select Button: Volume UP, Volume DOWN, HOME, MENU, BACK, LOCK, CAMERA...etc.
and if you can add BUTTON PRESS DURATION Option, it will be AWESOME
:D

Thanks a lot
Your Efforts are Appreciated

Re: BUTTON Pressed-Trigger

Posted: 18 Jul 2014 08:42
by Martin
Hi,

I think it's not possible to do this in general on an unmodified version of Android. You could try to use root with trigger Command Output: while true; do getevent -c 1 -l; sleep 1; done to react to input in general. You would still have to filter for the right output (like matches glob *KEY_VOLUMEDOWN*DOWN*). But that's all very device specific so I can not add support for this in Automagic as a built-in trigger.

Regards,
Martin

Re: BUTTON Pressed-Trigger

Posted: 27 Jul 2014 18:15
by raman2466
Bro, go and try xposed additions pro! A module for modification of button actions alone!, u will get al those function, but your device needs to be rooted and should have xposed installer installed!

Re: BUTTON Pressed-Trigger

Posted: 06 Apr 2015 05:59
by RinaldiMe
Martin wrote:Hi,

I think it's not possible to do this in general on an unmodified version of Android. You could try to use root with trigger Command Output: while true; do getevent -c 1 -l; sleep 1; done to react to input in general. You would still have to filter for the right output (like matches glob *KEY_VOLUMEDOWN*DOWN*). But that's all very device specific so I can not add support for this in Automagic as a built-in trigger.

Regards,
Martin
Hi Martin.

Thanks for your suggestion, I tried to create a flow as you described but I failed miserably. Could you please post a example XML with the basics?

Re: BUTTON Pressed-Trigger

Posted: 06 Apr 2015 07:52
by Martin
Hi,

Please try following flow:
http://automagic4android.com/flow.php?i ... 24bd50e3a8

The flow imports to a flow group called _test. Please note that this flow requires a rooted device.
The trigger uses command getevent to listen for input events and executes a vibrate action when the volume down key is pressed down.

When the flow does not work, edit the trigger, press button Test command... and check if the log prints some information when the volume keys are used.

You could optimize the command to listen only to the input device producing the volume key events. To do so check the output using Test command... and then change the command to something like this:
while true; do getevent -c 1 -l /dev/input/event2; sleep 1; done

where /dev/input/event2 should be set to the value seen in the output of the trigger.

Regards,
Martin

Re: BUTTON Pressed-Trigger

Posted: 06 Apr 2015 10:50
by RinaldiMe
Martin wrote:Hi,

Please try following flow:
http://automagic4android.com/flow.php?i ... 24bd50e3a8

The flow imports to a flow group called _test. Please note that this flow requires a rooted device.
The trigger uses command getevent to listen for input events and executes a vibrate action when the volume down key is pressed down.

When the flow does not work, edit the trigger, press button Test command... and check if the log prints some information when the volume keys are used.

You could optimize the command to listen only to the input device producing the volume key events. To do so check the output using Test command... and then change the command to something like this:
while true; do getevent -c 1 -l /dev/input/event2; sleep 1; done

where /dev/input/event2 should be set to the value seen in the output of the trigger.

Regards,
Martin
Hey Martin.

Thanks for the example, it really helped me.

Here the result, a flow (well, actually two) to skip Spotify tracks using the volume key long press.

Feel free to take a look and suggest improvements.

Thanks.

Re: BUTTON Pressed-Trigger

Posted: 24 Jul 2016 09:06
by Sarolf
Since Android 6, the key recognition does not work anymore.
Is there a workaround?

Re: BUTTON Pressed-Trigger

Posted: 12 Nov 2017 00:31
by emaeee
Hello Martin, the flow you posted works fine for my needs (I use it for camera key).
I'd like to know which kind of impact on battery life it has.
I mean, does it check in loop every 1 sec?

Moreover, on the app store there s an app called Button Remapper that uses an accessibility service to remap hardware keys. Would it be possible to do the same with automagic's service (in terms of trigger)?

Re: BUTTON Pressed-Trigger

Posted: 12 Nov 2017 00:42
by emaeee
Sarolf wrote:Since Android 6, the key recognition does not work anymore.
Is there a workaround?
On my Xperia stock 6.0.1 Rom it works fine