How can I define a Trigger for a Volume Button being pressed twice in quick succession?

allanremu

New member
Hi,
Apologies if this is a dumb question - I searched for Double Tap, Double press etc - but could not find anything...
I want to program certain sound profiles when the Volume Up button is pressed twice or Volume Down is pressed twice in quick succession - i.e. double press / double tap.
So, I set the Trigger to Volume Up + Volume Up
But the action still gets triggered on a single press - is this because there is no time limit between the 1st and 2nd press?
Any way round this?
Thanks.
 

tanutanu

Well-known member
Hi,
Apologies if this is a dumb question - I searched for Double Tap, Double press etc - but could not find anything...
I want to program certain sound profiles when the Volume Up button is pressed twice or Volume Down is pressed twice in quick succession - i.e. double press / double tap.
So, I set the Trigger to Volume Up + Volume Up
But the action still gets triggered on a single press - is this because there is no time limit between the 1st and 2nd press?
Any way round this?
Thanks.
It works as you want. Set the variable " isUnihertzDevice" false(if you have true is better though) before running and press volume down. It detects single, double and triple.
It uses a little tricky MD macro " habit" that the followings run immediately while previous one is on wait action when the same macro fired multiply
 
Last edited:

allanremu

New member
ok - for now, I enabled the long press using the ADB hack - and mapped to Long press - but will try and modify yours to do what I want on double tap. Thanks
 

tanutanu

Well-known member
Thanks for sharing - woah - that looks complex :)
Will try and customise/simplify it for my needs.
Yeah, it's better. I made it for devices which have PPT key in the first place, it's meaningless for any other though.
It supports 3 types of long tap by the length of time with volume up + long volume down, 2 stroke key press, as well. You can set any actions in the later if clauses.
 
Last edited:

tanutanu

Well-known member
ok - for now, I enabled the long press using the ADB hack - and mapped to Long press - but will try and modify yours to do what I want on double tap. Thanks
For double and triple tapping, simply press volume down key 2 or 3 times while the threshold.
2 stroke key press for long tap is another feature.
 

tanutanu

Well-known member
Hi @tanutanu - sorry but what is PPT key?
I have a Pixel 6 phone...
OOOOPS:oops: I made a typo🙃
PTT(aka Push to Talk) key is a extra hardware button working like a walkie-talkie.
My Unihertz, a Chinese minor manufacturer, cell phone has the programmable key and walkie-talkie app is installed for it. The customized OS support assigning some functions like gesture bar app working on screen.
It also has a feature to detect key up and down(just the moment of start pressing and release your finger as the ending of the press) code separately as an intent, so I catch both up and down to work for multi click and long press in my macro comfortably.
Unfortunately, most devices has no PTT key, so I replaced these key pressing to the volume button for the standard mobiles.
 
Last edited:

allanremu

New member
Ok - thanks - so I guess your Macro is not going to work for me?
Sorry - all this is new to me - so confused?

If someone has a simpler macro that would help me that would be great.
For now I have done the ADB hack and programmed the Long Press to switch Sound Profiles (https://play.google.com/store/apps/details?id=Orion.Soft)
But I would prefer the double tap if possible.
I have just upgraded to the Pro version - in case the functionality is limited to the Pro version.
Thanks
 

tanutanu

Well-known member
Ok - thanks - so I guess your Macro is not going to work for me?
Sorry - all this is new to me - so confused?

If someone has a simpler macro that would help me that would be great.
For now I have done the ADB hack and programmed the Long Press to switch Sound Profiles (https://play.google.com/store/apps/details?id=Orion.Soft)
But I would prefer the double tap if possible.
I have just upgraded to the Pro version - in case the functionality is limited to the Pro version.
Thanks
My macro works for you when you set the variable "isUnihertzDevice" is false. It set when you unlock the screen automatically if you didn't delete any statements. I tested it on my Xiaomi as well.
You don't need to change system configure variables for my macro by ADB hack. It use the triggers via Accessibility version, so you have to activate MD accessibility service instead.

EDITED: when "isUnihertzDevice" is false;
1. The device volume down key accepts single, double and triple tap.
single - open MD drawer
double - press back button
triple - expand status bar
2. Volume up -> down long press works as 3 different long press,
0-3sec. shorter - Take screenshot by default
3-5sec. mid - open camera
5-10sec longer - launch MD
3. You can change the click threshold by the variable "decMultiClickThreshold." 350ms is default.

You can find if - elseif - endif code blocks to redefine the commands in later half.
 

Attachments

  • IMG_20211110_220007.jpg
    IMG_20211110_220007.jpg
    227.9 KB · Views: 17
  • IMG_20211110_220247.jpg
    IMG_20211110_220247.jpg
    175.1 KB · Views: 18
  • IMG_20211110_230256.jpg
    IMG_20211110_230256.jpg
    412.4 KB · Views: 16
  • IMG_20211110_230346.jpg
    IMG_20211110_230346.jpg
    337.3 KB · Views: 16
Last edited:

Sir Archibald

New member
I don't have an option to set variable "isUnihertzDevice".

This is confusing. Can someone explain, can you set double tap value as a trigger or not?
 
Top