Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

[WORKAROUND] Apple tv remote swipes return multiple key values
Started by avlepel Dec 06 2015 02:33 PM

31 replies to this topic
[TOPIC CONTROLS]
Page 2 of 2 1 2
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#26

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 26,081 posts
  • Enterprise

[TOPIC: post.html]
#27

avlepel

[GLOBAL: userInfoPane.html]
avlepel
  • Contributor

  • 132 posts
  • Corona SDK

Just one word of caution:

 

Whoever uses this workaround needs to pay close attention to the fixes done by Coronalabs:

 

As soon as the normal key behavior is fixed and the system key events are thrown again for up / down / left / right you then will get all directions twice - you then need to take out my temporary fix.

 

A permanent solution would be to change the custom keys thrown to "customUp", "customDown", "customRight" and "customLeft" and then listen for these keys names. It then would be no problem if one day the normal key events are thrown again, because "up", "down" etc. are ignored.

 

Best

Andreas



[TOPIC: post.html]
#28

JonPM

[GLOBAL: userInfoPane.html]
JonPM
  • Corona Geek

  • 1,077 posts
  • Corona SDK

Andreas, thank you very much for the code snippet.  I was able to get it working immediately.  

 

One question I have is how do you modify this so that when the user swipes right AND the finger remains down the "right" event keeps repeating.  Imagine if you will the behavior when the on screen keyboard is shown, you can continue swiping across multiple letters while holding your finger down (no need to keep physically swiping right across each letter).  I am needing to replicate this.  Any help is appreciated!



[TOPIC: post.html]
#29

avlepel

[GLOBAL: userInfoPane.html]
avlepel
  • Contributor

  • 132 posts
  • Corona SDK

Hi Jon,

 

I'm traveling right now for a week, and I don't have my Apple TV with me. ;-)

 

So just an idea:

 

The problem is to know when the swipe ended. And there is no kind of "fingerUp" event.

 

But maybe you can check if the touch traveled more than a absolute normalized distance of 0.3 multiplied with a counter that starts with 1 and is incremented after each key event dispatched.

 

In the beginning you check for the touch travel distance of > 0.3 * counter (and counter = 1 by default), and if the distance is > 0.3 you dispatch the first key and inc the counter.

 

Then you automatically check again for distance > 0.3 * counter (now this is evaluates to checking for > 0.6, because counter is 2) and if this value is reached you dispatch the next key event and inc the counter again, etc.

 

For the breaking condition to break this distance check you can test if the touch traveled a minimum distance between two events. Or check if the time between two events is too big. Both cases would indicate that the user stopped the swipe. Now you reset everything, and you start again to watch for the next swipe.

 

I guess with this method you get what you want, and then you can play around with the numbers a little bit, e.g. use a check for > 0.4 if the method is too sensitive.

 

Good luck, and when you solve it feel free to post your solution, I would be interested to see how you solved this!

 

Best

Andreas



[TOPIC: post.html]
#30

JonPM

[GLOBAL: userInfoPane.html]
JonPM
  • Corona Geek

  • 1,077 posts
  • Corona SDK

Thanks Andreas I'll see what I can come up with



[TOPIC: post.html]
#31

avlepel

[GLOBAL: userInfoPane.html]
avlepel
  • Contributor

  • 132 posts
  • Corona SDK

Hi Jon,

 

found something, maybe this bridge was already crossed and you can use or adapt the code posted here:

https://forums.coronalabs.com/topic/57554-detecting-separate-swipe-without-lifting-finger/ 

 

If you are successful with this please tell me! :-)

 

Best

Andreas



[TOPIC: post.html]
#32

JonPM

[GLOBAL: userInfoPane.html]
JonPM
  • Corona Geek

  • 1,077 posts
  • Corona SDK

Andreas I haven't ignored you :)   I am still trying to get a workable solution, but not having any luck.  I wish CL would simplify things and ramp up the support for the remote, see how it is THE most important part of the platform.  




[topic_controls]
Page 2 of 2 1 2
 
[/topic_controls]