[WORKAROUND] Apple tv remote swipes return multiple key values

Hi,

when I implemented the navigation for my level selection screen (5 rows with 5 levels each) I used the swipe controls on the tv remote:

With the up / down / left / right swipes you can navigate to the level of your choice.

Now when I test on the Apple tv using the real remote I get multiple keys for each swipe gesture.

Take this code for testing:

local appPurpose = display.newText( "Apple tv remote key tester", 160, 64, native.systemFontBold, 18 ) local function onKey( event ) local phase = event.phase local keyName = event.keyName if phase == "down" then print( "keyName: ", keyName ) end return true end Runtime:addEventListener( "key", onKey )

Just run the program on the Apple tv and I get the following output in Xcode:

When I swipe DOWN:

Dec  6 23:19:56 Apple-TV KeyTest[180] <Warning>: keyName: right

Dec  6 23:19:56 Apple-TV KeyTest[180] <Warning>: keyName: down

or

Dec  6 23:22:28 Apple-TV KeyTest[180] <Warning>: keyName:  left

Dec  6 23:22:28 Apple-TV KeyTest[180] <Warning>: keyName:  down

or 

Dec  6 23:21:45 Apple-TV KeyTest[180] <Warning>: keyName: right

Dec  6 23:21:45 Apple-TV KeyTest[180] <Warning>: keyName: down

Dec  6 23:21:45 Apple-TV KeyTest[180] <Warning>: keyName: left

The same happens with the other directions.

It looks as if the swipe gesture down creates multiple key events:

One event for the direction I was swiping, “down”, as show as the second event that happened.

And one event for the second direction the swipe was heading to - you will never swipe exactly down, there always will be some deviation to the left or right, and this is send as another key event.

If this would be always the case I could live with it, I would always take the second event.

But sometimes even three key events happen, as shown above. 

I attached the test project with build and config files.

Thanks & best

Andreas

Thanks for the report. I’m not sure if reading the touch pad as an Axis instead of key events would help if you’re trying to detect swipes.

Rob

Hi Rob, I don’t exactly need swipes, I just want to know the correct direction of the user input when I listen for the keys. And I thought that listening for the up, down, left right keys will give me just this direction, the same as giving me the buttonA and buttonX key events. I of course can start to code my own translate-axis-movements-on-the-touch-area-to-keys method, but I was hoping that this would just be corrected SDK side. Or are you implying that it is already implemented the way it should work? That these double or triple key events are intentional? Thanks & best Andreas

What I was suggesting is that if the key events are too sensitive, you could use the axis events and basically roll your own events that would give you more control.

Rob

This is definitely an issue. Can you send a bug report with the attached project and post the case number back in this topic?

Hi Michael,

done:  (Case 44134) Apple tv remote swipes return multiple key values

Thanks for looking into it. It’s great that Corona continually supports the tvOS Alpha, so we can continue to convert our games!

Best

Andreas 

@Rob:

Yes, if I would need more control I would implement my own swipe code. But I need these controls only for navigating the menus.

The rotating levels in “Freeze! 2 - Brothers” are now controlled using the accelerometer. And yes, there is some small lag as always with the accelerometer, but that doesn’t hurt - it really is fun to play the game this way (otherwise I wouldn’t publish it).

Hi Michael,

I tested this issue with daily build 2795 (tvOS BETA), and the problem still exists. And it’s a bad one, the multiple keys returned per swipe makes navigating e.g. a level menu using directional swipes almost impossible.

As you decided to go to BETA, did you check this issue first? Or did you get a different result running the demo code on the device?

Thanks & best

Andreas

Hi Andreas,

We definitely do see this issue, and it’s one we need to fix. It did not make it to the beta list.

I suggest using the raw axis values (listen to “axis” events instead of “key” events) for now.

  • Michael

Hi Michael,

thanks for the lightning fast feedback - on a Sunday night! I now feel bad that you had to answer at the weekend!

Good to know that you see this issue. 

Thanks & best

Andreas

I can’t access my Apple TV at the moment to test, but are you getting multiple “Up” phases during the swipe? Or is it a series of “Down”'s followed by one “Up”?

Rob

Hi Rob,

I just tested with 2795 after updating my device to tvOS 9.1, and the issue is still the same as described at the top:

When I e.g. swipe DOWN:

 

Dec  6 23:19:56 Apple-TV KeyTest[180] <Warning>: keyName: right

Dec  6 23:19:56 Apple-TV KeyTest[180] <Warning>: keyName: down

 

or

 

Dec  6 23:22:28 Apple-TV KeyTest[180] <Warning>: keyName:  left

Dec  6 23:22:28 Apple-TV KeyTest[180] <Warning>: keyName:  down

 

or 

 

Dec  6 23:21:45 Apple-TV KeyTest[180] <Warning>: keyName: right

Dec  6 23:21:45 Apple-TV KeyTest[180] <Warning>: keyName: down

Dec  6 23:21:45 Apple-TV KeyTest[180] <Warning>: keyName: left

 

 

So I get the main direction “down”, accompanied by a “left” or “right” or even both - these are the variations of my downswipe, so if I swipe down and slightly to the left I get an additional “left”, if i swipe a little bit to the right I get an additional “right”. Or even both.

 

It is of course impossible to swipe exactly down. :slight_smile:

 

I guess these variations of the main swipe direction should be filtered out.

 

Best

Andreas

What I did was ignore left and right. I’m only paying attention to up and down.

Rob

Hi Rob,

Yes, but that won’t work for me or any games that e.g. use a 5x5 grid to select one of 25 levels for a world, like in “Where’s my Water” or “Freeze!”, to name just two great examples in one sentence. :wink:

The Apple guidelines state that it’s not enough to just walk sequentially through all levels in a screen like this, the user must be able to navigate freely up, down, left right.

But for this I will just wait till it is fixed, got enough other things still to do to convert the game for tvOS.

Best
Andreas

Hi Michael,

I was quite happy when I saw the daily build notes for .2796:

  • tvOS: Removing directional key events. 

 

Well, and then, when I tested it (with .2796 up to .2799) I saw that this was meant literally:

 

Not only the wrong additional directional key events for each swipe were removed, you removed all directional key events, the only events I get reported now are “buttonA”, “buttonX” and “menu”.

 

Ok, this certainly takes care of the bug in a way, there are no multiple key events anymore. :slight_smile:

 

But I was hoping for something more like a fix, so if the user swipes to the right we get back a “right” key event, nothing more, nothing less.

 

But enough said, hope you have a nice christmas vacation and maybe tackle this problem in January. 

 

Best

Andreas

We removed it until we could come back and implement it correctly.

For now, please look at axis events.You can look at these values and write a lua wrapper to synthesize your own up/down/left/right events.

Damn, now the navigation in my app is broken.

It was a very convenient feature imho.

Any idea when we can expect this to return?

Cheers,

Tommy

I don’t have an ETA. Perhaps I should do a tutorial on using axis events to make your own key events that lets you adjust the sensitivity of what triggers an event until we can get something more formal from engineering.

Or if you’re not needing a specific feature of a daily build, don’t update yet.

Rob

Hey, you removed a key feature! :smiley:

[Sorry, as a German I couldn’t resist the pun.]

Certainly there is the workaround to look for the swipes myself by interpreting the axis events. And I guess I will do that for the next time. And yes, a tutorial would always be welcome, will save me some time.

But in the released game I would like to have support for the original keys returned by tvOS. The users will be used to them and it will not be possible to emulate the exact feeling of the swipes with your own custom implementation.

Thanks and best
Andreas

[EDIT: Strange, whenever I post something using my iPad Air and Safari after posting all line breaks are removed. When I edit the post again all line breaks are still there, they just disappear when the post is published.]

[EDIT 2: Even stranger, after I edited the post and added the first EDIT and published the post now all line breaks show up. Feel free to test.]

Thanks for bringing up the forum line breaks issue. I thought it was just me.

It seems to happen when using the mobile theme, regardless of the browser used.

I’ll pass this on to the web guys.

Merry Christmas, and best of luck with Freeze 2 :slight_smile:

Such a tutorial would be much appreciated, thanks

Cheers