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 What framework you used to implement multiplayer?
Well, by āusā I meant ācocos2d-x communityā. These are not my games Dot Munch Fight Club is not multiplayer, opponents are bots.
I see. Haha I got fooled Iām playing online
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.