BUTTON Pressed-Trigger

Post your feature requets for new triggers, conditions, actions and other improvements.

Moderator: Martin

Post Reply
User avatar
ammar galala
Posts: 1
Joined: 17 Jul 2014 19:58
Location: Iraq

BUTTON Pressed-Trigger

Post by ammar galala » 17 Jul 2014 23:21

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

User avatar
Martin
Posts: 4437
Joined: 09 Nov 2012 14:23

Re: BUTTON Pressed-Trigger

Post by Martin » 18 Jul 2014 08:42

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

raman2466
Posts: 20
Joined: 05 Dec 2013 18:05

Re: BUTTON Pressed-Trigger

Post by raman2466 » 27 Jul 2014 18:15

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!

User avatar
RinaldiMe
Posts: 6
Joined: 04 Jun 2014 18:50

Re: BUTTON Pressed-Trigger

Post by RinaldiMe » 06 Apr 2015 05:59

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?

User avatar
Martin
Posts: 4437
Joined: 09 Nov 2012 14:23

Re: BUTTON Pressed-Trigger

Post by Martin » 06 Apr 2015 07:52

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

User avatar
RinaldiMe
Posts: 6
Joined: 04 Jun 2014 18:50

Re: BUTTON Pressed-Trigger

Post by RinaldiMe » 06 Apr 2015 10:50

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.
Attachments
exported_data_20150406_074708.xml
(11.44 KiB) Downloaded 718 times

Sarolf
Posts: 11
Joined: 15 Mar 2016 09:57

Re: BUTTON Pressed-Trigger

Post by Sarolf » 24 Jul 2016 09:06

Since Android 6, the key recognition does not work anymore.
Is there a workaround?

emaeee
Posts: 19
Joined: 10 Nov 2017 22:37

Re: BUTTON Pressed-Trigger

Post by emaeee » 12 Nov 2017 00:31

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)?

emaeee
Posts: 19
Joined: 10 Nov 2017 22:37

Re: BUTTON Pressed-Trigger

Post by emaeee » 12 Nov 2017 00:42

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

Post Reply