AppleTV support

You can not test it on AppleTV simulator, because Apple does not support using remote controllers on it. You must test it on actual device. I will check out the linker errors later.

Maybe I misunderstood, but by remote controller I mean that little window from screenshot I posted. If youā€™re saying about some pad I just want ordinary remote included with apple tv.

Yes, that little window (virtual remote) can only interact with the GUI. Apple does not support it as a remote controller on the simulator, so it will not work with cocos2d-x or any non-GUI application.

Now I see! Thatā€™s very unfortunate. But itā€™ll work on real remote on real device?

Yes, it works on a real device. Actually we already have two games released with my cocos2d-x branch: ā€œSong of Panā€ and ā€œDot Munch Fight Clubā€.

Great game :smiley: What framework you used to implement multiplayer?

Well, by ā€œusā€ I meant ā€œcocos2d-x communityā€. These are not my games :smile: Dot Munch Fight Club is not multiplayer, opponents are bots.

I see. Haha I got fooled Iā€™m playing online :smiley:

Added ā€œget/setAbsoluteDpadValuesā€ method to Controller, so that you can change how MicroController (AppleTV remote) reports the D-pad values (touch area). When this flag is on, values are reported as absolute values (center of the touch area is 0, sides are 1), but if it is off, coordinates of the first touch are reported as 0 annd all the values are reported as relative to this point (ranging from 0 to 1).

Is there any hack or something to simulate remote? Like keyboard arrows? Iā€™m still waiting for usb-c cable and kinda stuck, because I cannot send any input to interact with my app.

AFAIK there is none.

I think this is working for me. In RootViewController.mm add:

   -(void)pressesBegan:(NSSet*)presses withEvent:(UIPressesEvent *)event {
      UIPress* p = [presses anyObject];
      if ((p.type >= UIPressTypeUpArrow) && (p.type <= UIPressTypeRightArrow)) {
        cocos2d::Scene* myScene = cocos2d::Director::getInstance()->getRunningScene();
            ((Game*)myscene)->arrowPressed(dir);
      }
    }

Itā€™s good for testing only. It may give double keyPresses in the actual device. Not tested yet.

Just got the cable!
Iā€™m trying to figure out how this is working.

I filtered logs to ā€œkey up onlyā€. But itā€™s a bit strange.

I figured out that 1004 code is tapping (clicking) whole touchpad.

But how to recognize swipe in some direction?

Okay so Iā€™ve got some more codes:

1004 = tap
1007 = play/pause
1024 = menu

1010, 1011, 1012, 1013 are popping (logging key up only) when going with finger around, but I canā€™t figure out by what rules itā€™s working and how to recgonize swiping left, right, up or down

also how can I block default ā€œmenuā€ button action? So Iā€™d be able to go to the previous screen (or If itā€™s on first then close app).

Please, as I said in the first post, download the sample app from here: https://github.com/elvman/tvos-test4
It should answer all the questions you asked.

Thanks, sorry I didnā€™t know you just recently added some stuff to your example.

So I got how to handle menu button, thatā€™s solved (just comment 2 lines in RootViewController).

However Iā€™m still struggling with movement.

I figured out that 1010 is up, 1011 is down, 1012 is left and 1013 is right and your latest example confirmed that.
In my app I have 2d tiled grid where you can move character in 4 directions. It look like itā€™s working, but not exactly. When I swipe up Iā€™m getting up event indeed, but if itā€™s not perfect swipe Iā€™m getting 2 events up - left or up - right. But I want up only. How can I solve it?
Also I saw you added mouse events, for what purpose? Using remote triggers only key events (so no mouse events and no touch events).

Of course you will get two events, that is why I asked you to download my sample. If you look at lines 165-180 of MainMenu.cpp, you can see, that I am logging the value of each D-pad arrow (it is a value between 0.0 and 1.0). You should move your character only if a direction is 1.0 (fully pressed). This works similarly on controllers (GCGameController) with physical D-pads (they also report D-pad arrow values from 0.0 to 1.0).

Thanks. 1.0 is too hard to do on my remote, but If Iā€™m going any less Iā€™m getting more wrong turnsā€¦ Whatā€™s this anyway?:

controller->setAbsoluteDpadValues(true);

edit:

problem fixed! works perfectly! I was using key down/up events instead of repeat.

Yes, you have to use keyDown (in case user reaches 1.0 in the first swype) AND keyRepeat. Look a few posts higher to see what setAbsoluteDpadValues does.

Thanks. When I handle menu button how should I close app the right way? I tried Director::getInstance()->end() but app wonā€™t run again.

edit:
Also is this possible to use iphone remote app instead? I tried that it works in apple tv menu, but when I run app I can only see

ā€œController connected Remoteā€ and it only reacts to remote (the physical one), but doesnā€™t see iphone at all.