(Roaming Gamer) Green Throttle Tools for Corona SDK - Early Adopter Release

Hello everyone.  If you watched the CoronaGeek hangout this week (#41), you will recall that I demoed a new toolkit: the ‘Green Throttle Toolkit for Corona SDK

In short, this tool kit is designed to convert from the Green Throttle polling model to the more familiar ‘dispatch’ model like that used for touch and collision events.  Additionally, this toolkit lets you test  your apps on the Simulator using a android device as a bridge to send Green Throttle events to the simulator.

That’s right: This toolkit lets you … send Green Throttle events to the simulator.

The (Early Adopter) version of the tool kit includes these features:

  • gtevents.lua - Module to convert from polling to ‘Runtime’ dispatch model.
  • gtsender.lua - Module to send Green Throttle events to simulator.
  • gtreceiver.lua - Module to receive Green Throttle events on simulator.

The kit also comes with 5 demos showing the above features.

Here is a quick video of the ‘visualdumper’ running on the simulator and getting Green Throttle inputs via a Nexus 7 (acting as a bridge).

http://www.youtube.com/watch?v=zT7S6J0opL4

  • Waiting for Green Throttle controller to connect (red screen)
  • Device connects (background turns green)
  • Right joystick moved
  • A,B,X,Y buttons pressed
  • R2 Trigger (Analog 0…25) Pressed
  • L2 Trigger (Analog 0…25) Pressed
  • L1 then L2 Buttons pressed
  • Home button pressed.
  • Start and Back buttons pressed.
  • Left Joystick moved (notice aliasing to dpad cardinal positions)
  • DPad Buttons pressed
  • Simultaneous joysticks
  • Various
  • Home button held 5 seconds
  • Device disconnects (background turns red)

I will probably be releasing a ‘light’ version of this kit, but for now the only version available is the ‘Early Adopter’ version here: http://gum.co/fzOt

That is very cool.  I can’t wait to have a play with my Green Throttle kit and Corona.

I ordered my controllers (stupidly, I didn’t sign up for a developer account first…) during the call on Monday.  Too bad I probably won’t get them until next week since it’s coming ground from the other side of the country.

Hi folks.  Just a quick update.  You can now get this from GumRoad and Sellfy (for PayPal users).  Remember, you get lifetime updates for free (links mailed right to your inbox), so get it now while it is still Early Adopter priced.

GumRoad (CC users) - http://gum.co/fzOt

Sellfy (PayPal users) - https://sellfy.com/p/H0s4

Also, if you’re on the fence about this that’s cool.  I’m working on a lite version that should come out today or tomorrow (mostly likely).  This version will support converting polling to events on a single controller and the code will necessarily be obfuscated.  I’ll announce when this is released.

I don’t want to be completely ignorant here, but I’ve never used AutoLAN before.  I can add this code to my Simulator no problem.  That seems straight forward.  But how does the controllers talk to the sim?  Do I need an app on my Nexus 7 to broadcast the information?   Is that a build of the app I’m building or is there just a broadcaster somewhere?

Thanks

Rob

@All - I just  released a new update to the Pro Version see features list below).  Additionally, there is now a lite version for those who want to try it first: LITE VERSION.

@Rob

Sure, let me explain what my tool kit does for you

#1 Changes Green Throttle to a events based model versus polling. 

Normally, if you wanted to check whether the A button on a controller was pressed you’d write this code (may have errors, written from memory): 

local greenthrottle = require('plugin.greenthrottle') local function onEnterFrame()    gt\_startFrame() -- Get latest inputs     -- If device is connected continue with polling...    if(greenthrottle.getConnectedState( greenthrottle.CONTROLLER\_1 )) then       -- Is BUTTON\_A down?       if( greenthrottle.getButtonState( greenthrottle.BUTTON\_STATE\_DOWN,                                          greenthrottle.CONTROLLER\_1,                                          greenthrottle.BUTTON\_A) ) then print("Button A on controller 1 was just pressed!")          -- Do something....       end    -- Want to check for more states and more inputs?  The code gets longer fast.    end    return false end Runtime:addEventListner( "enterFrame", onEnterFrame ) 

Not only is this long, but it in’t like touch processing at all, which makes it a bit harder to deal with for less experienced Corona SDK users.  

With my toolkit you can achieve the same code like this:

local gtevent = require "gttools.gtevent" gtevent.start() local function onButtonA( event )    if(event.phase == "began") then       if(event.num == 1) then           print("Button A on controller 1 was just pressed!")       end    end    return true end Runtime:addEventListener( "gt\_a", onButtonA ) 

#2 Allows you to route Green Throttle device inputs back to the simulator. - Yes, all Corona SDK Pro users can include the standard greenthrottle plugin by adding it to their build.settings file.  This gives you access to stubbed out versions of the polling functions.  These don’t do anything on the simulator, but get linked up to the plugin when built for the device.  In short, while you can write and run your code on the simulator you can’t actually test it till it’s on the device.  My toolkit has code in it that let’s you route back to the simulator.  The above code could be run on the simulator as follows:

A. Modify above code to look like this:

local gtevent = require "gttools.gtevent" gtevent.start() if( system.getInfo( "environment" ) == "simulator" ) then    local gtreceiver = require "gttools.gtreceiver"        gtreceiver.start() else    local gtsender = require "gttools.gtsender"        gtsender.start()  end local function onButtonA( event )    if(event.phase == "began") then       if(event.num == 1) then           print("Button A on controller 1 was just pressed!")       end    end    return true end Runtime:addEventListener( "gt\_a", onButtonA )  

B. Build it and install it on an Android device that has been paired with a Green Throttle controller.

C. Run the Android copy.

D. Run the simluator.

E. Turn on your controller and push button A.  The simulator will print this:

Button A on controller 1 was just pressed!

So, how does this work?  Well… without giving up the secret sauce…

I bundle up the events on the android device and send them over WiFi  (via a UDP connection) to the simulator.  

I originally wrote my own UDP code for this, but found that the (free) AutoLAN library worked better because M.Y. Developers did a nicer job of configuring sockets as well as packing/coalescing the data before sending it.  In short, they send bigger packets at a higher rate.  So, since its free and has a nice license I used their code as the backbone for the UDP connection.

#3 More features… - I’m still working on this product, but I have added all of these features so far:

  • Polling to events conversion - Discussed above.
  • Green Throttle to Simulator Event Forwarding - Discussed above.  Note: This can also be used to send one controller’s inputs to multiple devices (of any type) so you can test on multiple devices simultaneously.  Not sure how useful this would be, but it is technically possible.
  • Smart Polling - I added the ability to configure the event convert to selectively poll for only those inputs you care about.  This can be set on a per controller basis.
  • Overall Polling Rate - I added the ability to easily change from checking inputs every frame to every 2nd, 3rd, …
  • Digital Polling Rate - Like the overall polling rate, I added a separate way to poll digital inputs more slowly.  You usually want to check analog inputs every frame, but digital inputs can be checked every 4th … 8th frame (at 60FPS) with no noticeable effect on usability.  This will save battery life.
  • Controller enabling/disabling - Of course, you can selectively ignore devices to save more juice.  No need to check for devices that will never be attached.
  • Examples: Lots of examples, including  simple, sender/receiver, event dumper, visual event dumper, single player pong (joysticks control paddles), and the latest one a game framework with a splash scree, main menu, and blank play/options/credit GUIS, all hooked up to the controller.
  •  - More features and documentation are coming.  

The following video shows Green Throttle controlled code running on the simulator :

http://www.youtube.com/watch?v=PwL2LZ1VAt0

(Note: The pong example looks a little jerky because tied the analog sticks directly to the position of the paddles which is not the right way to make a smooth positional control.  You’d be better off treating the sticks like digital inputs  [which you can do] and then moving the paddles up or down at fixed rates.)

If anyone is still reading and want to get this, you can get it using one of these links.

Gum Road (for CC users) - https://gumroad.com/l/fzOt

Sellfy (for Pay Pal users) - https://sellfy.com/p/H0s4

I guess I’m still not clear on this.  Is there an app that I install on my Nexus 7 that is the transmitter/receiver out of the box.  Just build one of them and install it?  I think your instructions would be much better if you had a step that said:

2.  Build the XYZ app, install it and run it on your device.

or better yet, include an already build .apk file (debug keystore would be fine) and just have us install it.  I think the goal would be for the android device to transmit all activity to and from the controller.  I’ll play with this more tonight.

Second question… I purchased this last night.  Shortly afterwards, I got an email saying there was an update, but it didn’t have a zip file attached nor did it have a link to get the update.   How can I make sure I have the latest code?

Okay I got it working.   Install the transmitter app on your device.

@Rob,

Cool!  Glad to hear it.  Don’t forget, there is an updated version with another example.  Also, it fixes a networking timeout problem that sometimes occurred with the first release.

If you have any troubles with this kit please let me know.  Also, I value any kind of feedback so, if you see something (good or bad) let me know.

Expect another update (nicer docs and a new feature or two) later this week.  

***** UPDATE BELOW *****

Rob,

You should be able to get the latest version by going to the original e-mail you got when buying the kit.  

Meanwhile, I’ll give priority to updating the docs so there is no confusion.  I’ll also be sure to clearly mark the version so folks aren’t wondering if they have the latest.

Finally, I see you bought through Sellfy.  You say the update e-mail did not include a link?  

Grumble, grumble…sigh… Hmm…

I use GumRoad and Sellfy for selling kits.  It seems, that GumRoad automatically adds the link and it seems Sellfy does not.  Also GumRoad is nice because it always sends me the update e-mail so I can see what the customer sees when s/he gets it.  

Alright, I’ll figure the link issue before the next update.  Thanks a bunch for letting me know.  

Cheers,

Ed

Is this working on iOS yet?

Yes and no.  Currently Green Throttle itself does not have a driver for iOS development.

That said, you can use my toolkit to route Green Throttle inputs to your iOS device in the same fashion that you route them to the simulator.

Here is how it would work:

On iOS device

  1. Write your iOS game/app.

  2. Include my gtevent.lua AND gtreceiver.lua modules.

  3. Run the getevent and gtreceiver.

On an Android device (with Green Throttle paired to it; acts as WiFi bridge to send GT events to any receiver):

  1. Run the gtsender app included with my kit.

Now, start the android app followed by the ios app and you can test your GT enabled app/game on your iOS device.

GT Controller --> Android Device —> WIFI —> iOS Device.

Yes, it’s weird, but I mainly want to demonstrate the flexibility of my kit.  Also, assuming iOS does eventually support Green Throttle, you are ready to go.  Just disable gtreceiver in you iOS app and run it like usual.

I’ll be making a video over the next few days demonstrating this and some other weird/cool things you can do with my tooolkit.

That is very cool.  I can’t wait to have a play with my Green Throttle kit and Corona.

I ordered my controllers (stupidly, I didn’t sign up for a developer account first…) during the call on Monday.  Too bad I probably won’t get them until next week since it’s coming ground from the other side of the country.

Hi folks.  Just a quick update.  You can now get this from GumRoad and Sellfy (for PayPal users).  Remember, you get lifetime updates for free (links mailed right to your inbox), so get it now while it is still Early Adopter priced.

GumRoad (CC users) - http://gum.co/fzOt

Sellfy (PayPal users) - https://sellfy.com/p/H0s4

Also, if you’re on the fence about this that’s cool.  I’m working on a lite version that should come out today or tomorrow (mostly likely).  This version will support converting polling to events on a single controller and the code will necessarily be obfuscated.  I’ll announce when this is released.

I don’t want to be completely ignorant here, but I’ve never used AutoLAN before.  I can add this code to my Simulator no problem.  That seems straight forward.  But how does the controllers talk to the sim?  Do I need an app on my Nexus 7 to broadcast the information?   Is that a build of the app I’m building or is there just a broadcaster somewhere?

Thanks

Rob

@All - I just  released a new update to the Pro Version see features list below).  Additionally, there is now a lite version for those who want to try it first: LITE VERSION.

@Rob

Sure, let me explain what my tool kit does for you

#1 Changes Green Throttle to a events based model versus polling. 

Normally, if you wanted to check whether the A button on a controller was pressed you’d write this code (may have errors, written from memory): 

local greenthrottle = require('plugin.greenthrottle') local function onEnterFrame()    gt\_startFrame() -- Get latest inputs     -- If device is connected continue with polling...    if(greenthrottle.getConnectedState( greenthrottle.CONTROLLER\_1 )) then       -- Is BUTTON\_A down?       if( greenthrottle.getButtonState( greenthrottle.BUTTON\_STATE\_DOWN,                                          greenthrottle.CONTROLLER\_1,                                          greenthrottle.BUTTON\_A) ) then print("Button A on controller 1 was just pressed!")          -- Do something....       end    -- Want to check for more states and more inputs?  The code gets longer fast.    end    return false end Runtime:addEventListner( "enterFrame", onEnterFrame ) 

Not only is this long, but it in’t like touch processing at all, which makes it a bit harder to deal with for less experienced Corona SDK users.  

With my toolkit you can achieve the same code like this:

local gtevent = require "gttools.gtevent" gtevent.start() local function onButtonA( event )    if(event.phase == "began") then       if(event.num == 1) then           print("Button A on controller 1 was just pressed!")       end    end    return true end Runtime:addEventListener( "gt\_a", onButtonA ) 

#2 Allows you to route Green Throttle device inputs back to the simulator. - Yes, all Corona SDK Pro users can include the standard greenthrottle plugin by adding it to their build.settings file.  This gives you access to stubbed out versions of the polling functions.  These don’t do anything on the simulator, but get linked up to the plugin when built for the device.  In short, while you can write and run your code on the simulator you can’t actually test it till it’s on the device.  My toolkit has code in it that let’s you route back to the simulator.  The above code could be run on the simulator as follows:

A. Modify above code to look like this:

local gtevent = require "gttools.gtevent" gtevent.start() if( system.getInfo( "environment" ) == "simulator" ) then    local gtreceiver = require "gttools.gtreceiver"        gtreceiver.start() else    local gtsender = require "gttools.gtsender"        gtsender.start()  end local function onButtonA( event )    if(event.phase == "began") then       if(event.num == 1) then           print("Button A on controller 1 was just pressed!")       end    end    return true end Runtime:addEventListener( "gt\_a", onButtonA )  

B. Build it and install it on an Android device that has been paired with a Green Throttle controller.

C. Run the Android copy.

D. Run the simluator.

E. Turn on your controller and push button A.  The simulator will print this:

Button A on controller 1 was just pressed!

So, how does this work?  Well… without giving up the secret sauce…

I bundle up the events on the android device and send them over WiFi  (via a UDP connection) to the simulator.  

I originally wrote my own UDP code for this, but found that the (free) AutoLAN library worked better because M.Y. Developers did a nicer job of configuring sockets as well as packing/coalescing the data before sending it.  In short, they send bigger packets at a higher rate.  So, since its free and has a nice license I used their code as the backbone for the UDP connection.

#3 More features… - I’m still working on this product, but I have added all of these features so far:

  • Polling to events conversion - Discussed above.
  • Green Throttle to Simulator Event Forwarding - Discussed above.  Note: This can also be used to send one controller’s inputs to multiple devices (of any type) so you can test on multiple devices simultaneously.  Not sure how useful this would be, but it is technically possible.
  • Smart Polling - I added the ability to configure the event convert to selectively poll for only those inputs you care about.  This can be set on a per controller basis.
  • Overall Polling Rate - I added the ability to easily change from checking inputs every frame to every 2nd, 3rd, …
  • Digital Polling Rate - Like the overall polling rate, I added a separate way to poll digital inputs more slowly.  You usually want to check analog inputs every frame, but digital inputs can be checked every 4th … 8th frame (at 60FPS) with no noticeable effect on usability.  This will save battery life.
  • Controller enabling/disabling - Of course, you can selectively ignore devices to save more juice.  No need to check for devices that will never be attached.
  • Examples: Lots of examples, including  simple, sender/receiver, event dumper, visual event dumper, single player pong (joysticks control paddles), and the latest one a game framework with a splash scree, main menu, and blank play/options/credit GUIS, all hooked up to the controller.
  •  - More features and documentation are coming.  

The following video shows Green Throttle controlled code running on the simulator :

http://www.youtube.com/watch?v=PwL2LZ1VAt0

(Note: The pong example looks a little jerky because tied the analog sticks directly to the position of the paddles which is not the right way to make a smooth positional control.  You’d be better off treating the sticks like digital inputs  [which you can do] and then moving the paddles up or down at fixed rates.)

If anyone is still reading and want to get this, you can get it using one of these links.

Gum Road (for CC users) - https://gumroad.com/l/fzOt

Sellfy (for Pay Pal users) - https://sellfy.com/p/H0s4

I guess I’m still not clear on this.  Is there an app that I install on my Nexus 7 that is the transmitter/receiver out of the box.  Just build one of them and install it?  I think your instructions would be much better if you had a step that said:

2.  Build the XYZ app, install it and run it on your device.

or better yet, include an already build .apk file (debug keystore would be fine) and just have us install it.  I think the goal would be for the android device to transmit all activity to and from the controller.  I’ll play with this more tonight.

Second question… I purchased this last night.  Shortly afterwards, I got an email saying there was an update, but it didn’t have a zip file attached nor did it have a link to get the update.   How can I make sure I have the latest code?

Okay I got it working.   Install the transmitter app on your device.

@Rob,

Cool!  Glad to hear it.  Don’t forget, there is an updated version with another example.  Also, it fixes a networking timeout problem that sometimes occurred with the first release.

If you have any troubles with this kit please let me know.  Also, I value any kind of feedback so, if you see something (good or bad) let me know.

Expect another update (nicer docs and a new feature or two) later this week.  

***** UPDATE BELOW *****

Rob,

You should be able to get the latest version by going to the original e-mail you got when buying the kit.  

Meanwhile, I’ll give priority to updating the docs so there is no confusion.  I’ll also be sure to clearly mark the version so folks aren’t wondering if they have the latest.

Finally, I see you bought through Sellfy.  You say the update e-mail did not include a link?  

Grumble, grumble…sigh… Hmm…

I use GumRoad and Sellfy for selling kits.  It seems, that GumRoad automatically adds the link and it seems Sellfy does not.  Also GumRoad is nice because it always sends me the update e-mail so I can see what the customer sees when s/he gets it.  

Alright, I’ll figure the link issue before the next update.  Thanks a bunch for letting me know.  

Cheers,

Ed

Is this working on iOS yet?