Possible to detect a double press vs a single press for media buttons via bluetooth?

573 views
Skip to first unread message

Frank O

unread,
Oct 14, 2011, 9:40:57 AM10/14/11
to Tasker
I'm trying to use Tasker to bring up Voice Commands via bluetooth
headset button (via my car's media controls). I can get Tasker to
detect a single button push, but not a long press or double press. My
car is a 2011 Subaru Forester and it really only has forward/back
buttons available to send via bluetooth.. so I'd like to figure some
sort of method out to get my media buttons working for single presses
(as it does now, without Tasker) and either a double press or long
press to bring up voice commands. I think long press will not work, as
the Subaru interface seems to drop the button command if I send it too
long (I tried switching my single press command to use Long Press and
it didn't work at all).

Ideally I'd like:
Single forward -> next song
Single back -> prev song

Double forward -> voice commands


I sort of had an idea with setting variables, but I can't really time
out a variable set can I? i.e. set variable to 1, if no button press
within 2 seconds set variable back to 0.

Any ideas? Thanks! :)

Avi

unread,
Nov 14, 2011, 1:06:01 AM11/14/11
to Tasker
I would like to be able to detect long/double press as well.
Any way of doing that?


On Oct 14, 3:40 pm, Frank O <algorhy...@gmail.com> wrote:
> I'm trying to use Tasker to bring up Voice Commands viabluetooth
> headset button (via my car's media controls).  I can get Tasker to
> detect a single button push, but not alongpressor doublepress.  My
> car is a 2011 Subaru Forester and it really only has forward/back
> buttons available to send viabluetooth.. so I'd like to figure some
> sort of method out to get my media buttons working for single presses
> (as it does now, without Tasker) and either a doublepressorlongpressto bring up voice commands. I thinklongpresswill not work, as

V Oz

unread,
Nov 14, 2011, 3:46:02 AM11/14/11
to tas...@googlegroups.com

Profile: OneClick (137)
Event: Variable Set [ Variable:%DOUBLE_CLICK Value:* ]
Enter: Anon (149)
A1: Wait [MS:0 Seconds:3 Minutes:0 Hours:0 Days:0]
A2: Flash [Text:one Long:Off] Flash [ %DOUBLE_CLICK Is Set ]
A3: Variable Clear [Name:%DOUBLE_CLICK Pattern Matching:Off]

Profile: DblClick (73)
Priority: 9 CoolDown: 0
State: Media Button [ Button:Play Held Down:Off Grab:On Stop Event:Off ]
Enter: Anon (103)
A1: Variable Set [Name:%time To:%TIMES Do Maths:Off Append:Off]
A2: If [ %DOUBLE_CLICK ! Set ]
A3: Variable Set [Name:%DOUBLE_CLICK To:%time Do Maths:Off Append:Off]
A4: Else
A5: Variable Set [Name:%diff To:%time-%DOUBLE_CLICK Do Maths:On Append:Off]
A6: Flash [Text:diff is %diff secs Long:On]
A7: Variable Clear [Name:%DOUBLE_CLICK Pattern Matching:Off]
A8: End If

Frank O

unread,
Nov 23, 2011, 10:03:34 AM11/23/11
to Tasker
Hi V,

Thanks for that, unfortunately it did not work. The phone got very
confused between single and double pressing. I double pressed and the
OneClick flash kept flashing every second or two.

V Oz

unread,
Nov 24, 2011, 1:31:35 AM11/24/11
to tas...@googlegroups.com
Little trick is there :) You have to make two "oneclicks" with a short pause in between. Tasker grabs media button clicks, detects how long the pause was and if it less then threshold says "that was double-click" and vice versa.
You have to run some experiments with my suggestion and tune it for Your environment.

P.S. I didn't use it myself, because sometimes delay from one click without Tasker's grabbing is too long. Maybe the cause in the hard load of CPU with other tasks (continuous video recording, Tasker's tasks, etc.). So, if I'll put it through Tasker it'll be much more, even with 10-th priority of profiles. This DoubleClick was a next  brain-twister, only.
What about run it on QUAD-core platform? LOL

Reply all
Reply to author
Forward
0 new messages