Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
AppleTV support — Gideros Forum

AppleTV support

acalatravaacalatrava Member
edited September 2015 in General questions
Since Apple released a week ago a new SDK for the upcoming Apple TV I started to think how great would be to use Gideros to create games or other apps on this new platform. Since Apple TV runs iOS underneath, it should be easy to port Gideros to it.

I started looking around the Gideros code and I have been able to accommodate and compile the iOS libraries and tweak the iOS Template in order to work with Gideros. There are some classes unavailable like UIAlertView so I rewrote them using UIAlertController (in fact UIAlertView is deprecated on iOS8). And there are other API missing like CoreMotion or CoreLocation.

Here you can see the game I did some time ago with Gideros running on the AppleTV Simulator:
image

Unfortunately since AppleTV has no touch screen you need to use the new Apple Remote to control the AppleTV. This new remote should be recognized as a GCController (GCMicroGamepad profile), there are some code (Gideros Labs/Controller) already available to work with controllers but unfortunately I wasn't able to get it working with my (sort of) controller (I'm using a Wii controller through MFI Wrapper). So I decided to create my own plugin that should be compatible with MFI controllers (iOS7 and above). It works on my iPhone but it won't work on the AppleTV simulator because the available seed won't support GameController API yet... but it should work on an upcoming seed.

So I think most of the work is done and I would like to know if you people could be interested on this so I will try to integrate it on Gideros (by forking the code and doing a pull request). I'm not sure how difficult will that be since I don't know the structure of the code or how to compile everything, but if you are interested I will try to!

BTW, sorry but it won't allow me to post links
Gideros Game: Tiny Neo --> http://tinyneo.com

Other apps:
http://OwnSpy.com
http://iGotYa.com
+1 -1 (+4 / -0 )Share on Facebook
«1

Comments

  • Wow, that actually sounds amazing.

    Surely would be interested and if you have any questions about code etc. Let us know.

    If you can create a template for export I can add it as an export option. As I think there will be no way to create universal template, right?
  • @acalatrava +1 to add it to the repo. :)

    @ar2rsawseen You can apparently make Universal apps that include iPad, iPhone and AppleTV. I don't know what is involved though.
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • @acalatrava Why did it not work with the GiderosController plugin lib? I thought it supported MFI ?
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • Fantastic! Impressive stuff @acalatrava. Would love to play with this. Interested to see how the controller works, to re-map the controls of my current games.
    My Gideros games: www.totebo.com
  • btw I actually did not test ios controller lib since ios 6 or 7, don't remember. as I don't have MFI compatible device.

    If someone could check it, it would be great.
  • @SinisterSoft it should support MFI (alpha stage) but it didn't work for me... I started to tweak it to make it work but there is a non-defined function (findKeyCode) in the sample code that I'm not sure what it refers to... However the library I made is working fine and it is very simple, but it will only work for MFI controllers.

    @ar2rsawseen & @SinisterSoft There is no way to create Universal apps including iPad, iPhone and AppleTV since the SDK is different (ios vs appletvos). However I *might* be able to create a universal template with two different targets... I will try to and get back to you.

    @totebo I'm still defining the protocol but basically you will receive an event on connection or disconnection of the controller, on every button pressed/released and on dpad analog changes.
    Gideros Game: Tiny Neo --> http://tinyneo.com

    Other apps:
    http://OwnSpy.com
    http://iGotYa.com
  • @acalatrava I'm was sure they said the the announcement that Universal apps were going to be possible.

    Looks like it must be just 'universal purchase'...

    "Empower customers to enjoy their favorite apps on both iOS and the new Apple TV with a single purchase by enabling universal purchase for your app on the App Store."

    https://developer.apple.com/tvos/
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • I just created a new iOS & AppleTV Template that just works! I dropped it to the Gideros Studio Mac bundle, export a game and you can compile the game for both iOS and AppleTV :)

    @ar2rsawseen I just created a pull request with the changes made. Please note that the new MFIController is alpha state, but it should work when the new XCode 7.1-beta seed is available. I'm uploading a compiled a functional template to dropbox but I can't post links, how should I send you?

    @SinisterSoft you are right, there is no way to create Universal apps but you are able to link them on the iTunes Connect page so you can purchase both just once.

    @totebo the first release of MFIController will be something like this:
    		require "mficontroller"
     
    		local function onConnected(event)
    			print("gc type: "..mficontroller:getControllerType(mficontroller:getAmountControllers() -1))
    		end
     
    		local function onDisconnected(event)
    			print ("Controller has been disconnected!")
    		end
     
    		local function onButton(event) 
    			if (event.isPressed) then
    				if (event.buttonIndex == ButtonCode.BUTTON_A) then
    					--do something with button A
    				end
    				if (event.buttonIndex == ButtonCode.BUTTON_B) then
    					--do something with button B
    				end
    				if (event.buttonIndex == ButtonCode.BUTTON_B) then
    					--do something with button B
    				end
    			else 
    				print("button released: "..event.buttonIndex)
    			end
    		end
     
    		local function onPause(event) 
    			--pause or resume the game
    		end
     
    		mficontroller:addEventListener(Event.BUTTON_EVENT, onButton)
    		mficontroller:addEventListener(Event.CONNECTED_GC_EVENT, onConnected)
    		mficontroller:addEventListener(Event.DISCONNECTED_GC_EVENT, onDisconnected)
    		mficontroller:addEventListener(Event.PAUSE_EVENT, onPause)
     
    		if (mficontroller:isAvailable()) then onConnected(nil) end
    You have the following ButtonCode's available:
    ButtonCode.BUTTON_A
    ButtonCode.BUTTON_B
    ButtonCode.BUTTON_X
    ButtonCode.BUTTON_Y
    ButtonCode.BUTTON_LEFT_SHOULDER
    ButtonCode.BUTTON_RIGHT_SHOULDER
    ButtonCode.DPAD_UP
    ButtonCode.DPAD_DOWN
    ButtonCode.DPAD_LEFT
    ButtonCode.DPAD_RIGHT
    In the future I will implement analog sticks events too.
    Gideros Game: Tiny Neo --> http://tinyneo.com

    Other apps:
    http://OwnSpy.com
    http://iGotYa.com
    +1 -1 (+4 / -0 )Share on Facebook
  • john26john26 Maintainer
    I really am amazed by how quickly you got this working. I'm looking through the pull request now on github and it's a substantial amount of changes so well done for doing that. I like the way you've used #ifdef statements to prevent any problems with the existing iOS export.

    It sounds a bit like WinRT where you have a universal solution that contains two projects, one for Windows and one for Windows Phone, and which can share most of the code. I think the iOS/tvOS thing is similar.. But correct me if I am wrong!
  • acalatravaacalatrava Member
    edited September 2015
    I completed the AppleTV support code and I sent a pull request so I hope it will be mainstream soon.

    I created a universal template that compile to iOS or AppleTV and works with the current Gideros Studio simply by replacing the iOS Template.

    Unfortunately I don't have an AppleTV Dev Kit so I'm still waiting for the next tvOS SDK seed that will enable GCController API and confirm that the MFIController plugin I made will work fine on the tvOS.

    I think this is very interesting but keep in mind your business strategy since ads won't work on the AppleTV because there is no browser! So if your game depends on ads you will need to think in something else...

    Gideros is now the first Cross Platform Game Engine that supports the AppleTV!
    Gideros Game: Tiny Neo --> http://tinyneo.com

    Other apps:
    http://OwnSpy.com
    http://iGotYa.com
  • This is great news! So how do you make money with Apple TV? Paid for apps?
    My Gideros games: www.totebo.com
  • Question about your MFIController plugin, would it be possible to wrap it around gcontroller binding?
    https://github.com/gideros/gideros/blob/master/plugins/controller/source/controllerbinder.cpp

    So it would be the dropin replacement for those who use the plugin (or I can even merge and replace my ios part since it does not work anymore)

    Likes: SinisterSoft

    +1 -1 (+1 / -0 )Share on Facebook
  • @totebo Yes, either paid apps or freemium... IAP is available.

    @ar2rsawseen mmm... the problem is that I need to implement other things like GCMotion and it is not defined on that binding... I think the best solution would be to replace the iOS part and extend the gcontroller to support motion... Unfortunately without an actual AppleTV to test it is going to be difficult to debug it... So I will try to replace your iOS part and handle the motion thing when the AppleTV is in my hands (I may need help then to fully understand the gcontroller class)
    Gideros Game: Tiny Neo --> http://tinyneo.com

    Other apps:
    http://OwnSpy.com
    http://iGotYa.com
  • Hm, what is GCMotion and what is the purpose for it? Isn't it the same as accelerometer data?
  • Yes, it is accelerometer data. Is it defined on the controller?
    Gideros Game: Tiny Neo --> http://tinyneo.com

    Other apps:
    http://OwnSpy.com
    http://iGotYa.com
  • Since accelerometer is something like axis, i think axisJoystick can be used.
    So it something like X = axis 1, y = axis 2, and z = axis 3?
  • yubaroyubaro Member
    edited September 2015
    Wow, its amazing!
  • My point was, that there is already an Accelerometer class, is GCMotion something different?

    http://docs.giderosmobile.com/reference/gideros/Accelerometer#Accelerometer
  • The main difference is that this acceleration is not related to the device, but related to the controller... Also the GCMotion provides attitude and rotation rate that I think are equivalent to the Device Gyroscope (but again, related to the controller).

    So if you have 2 controllers attached you will have 2 different acceleration data... So this is why we should deliver this information using the controller plugin, and not the Accelerometer class. I know that in most games where there is only one player this info will be the same and the game will just works... but it's not the right way.

    Maybe we could do a lua lib to "translate" the controller motion to accelerometer data and therefore not to change a line of the current game code.
    Gideros Game: Tiny Neo --> http://tinyneo.com

    Other apps:
    http://OwnSpy.com
    http://iGotYa.com
  • ar2rsawseenar2rsawseen Maintainer
    edited September 2015
    Sorry, I still seem to miss it, how does acceleration data is related to controller?

    Aren't there simply 2 sticks each with 2 axis and thumbs? or ios has some other controllers I am not aware of?

    Or there is accelerometer in the controller allowing you detect how whole controller is moving?
  • ah I see, so it is a remote control and not a game controller.

    Well it could be either wrapped in Stick axes or added new needed events to gcontroller plugin, so it would be easier for others to use. But it's up to you, I don't do iOS anymore :)
  • iOS is my platform of choice, so very pleased this is worked on whichever way it's integrated. You'll come back to iOS eventually @ar2rsawseen and make games for the living room!
    My Gideros games: www.totebo.com
  • I actually love making controller based games, my current favorite platform is OUYA.

    But I'm not doing it for the money, but for the fun :)
    +1 -1 (+2 / -0 )Share on Facebook
  • @ar2rsawseen speaking of Ouya, don't forget new IAP libs so you can also sell on the Razer... :)
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • I know what you mean with controllers; a flat touch screen is quite limited. Would be interested to play with the Apple remote to see if it could be better for games.
    My Gideros games: www.totebo.com
  • Yes @ar2rsawseen the Apple Remote is detected as controller and it has a built in accelerometer. I thought there was more controllers out ther with accelerometers (like the wii) but I'm don't know much about games (I don't like playing video games, I just purchased the wii long ago because of the controller!)

    I think the new Apple TV will be a huge market. You know iOS people are use to purchase content so I think payable games will work. Also you can connect MFI controllers to it that will be better than the remote. You should port your OUYA games! ;)

    Also there is a limitation on the AppleTV: your app can't save data. Instead you need to use iCloud for that. Also your maximum app size is 200MB so you will need to download the content from iCloud to use it... Is it iCloud plugin available?

    I guess that when you save data with the |D| prefix will fail on AppleTV...
    Gideros Game: Tiny Neo --> http://tinyneo.com

    Other apps:
    http://OwnSpy.com
    http://iGotYa.com
  • That is why I hate iOS, too much dealing with Apple shit. Losing all fun that I get from creating a game :)

    About cloud plugin, yes there was one in GamingInterface, but I am not sure again if it is still working
  • I think the AppleTV will be huge, it might/should also boost the AndroidTV market too.

    Likes: MobAmuse

    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
    +1 -1 (+1 / -0 )Share on Facebook
  • SinisterSoftSinisterSoft Maintainer
    edited October 2015
    @acalatrava We have almost got it working on a real AppleTV. There are some teething problems, but I managed to get my game running when playing from the assets folder.

    The main problem is that you can't store files on the device, so getting the player to work is a bit of a problem (files are sent to the device and stored locally). @ar2rsawseen is working on a possible solution and hopefully we will have Gideros fully working on AppleTV in the next few days. :)

    Likes: totebo

    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
    +1 -1 (+1 / -0 )Share on Facebook
Sign In or Register to comment.