Airconsole controller maker

0 favourites
From the Asset Store
Small pixel icons for the 3 most popular controller types.
  • Anonnymitet Just adding some stuff

    cjbruce I'm testing all the possibilities

    X3M,

    Thank you!

    I haven't (yet) figured out how to modify the code in c2runtimectrl.js to lock orientation in landscape. I'll keep poking around and (hopefully) post a solution here once I figure it out.

  • X3M,

    In order to force a landscape orientation, I added {"orientation":"landscape"} to the c2runtimectrl.js:

    So, instead of:

    			_this.airconsole = new AirConsole();[/code:3p6imdde]
    
    I used the following:
    
    [code:3p6imdde]
    			_this.airconsole = new AirConsole({"orientation": "landscape"});[/code:3p6imdde]
    
    Could this capability be added directly to the plugin?
  • cjbruce Done

  • X3M and Psychokiller1888,

    I've played around a bit with the plugin, but have not been able to send messages from the screen back to the controller. A few questions:

    1. I assume that the sendhandshake() message is being sent from the screen to the controller, then back from the controller to the screen, all handled behind the scenes by the AirConsoleController plugin on the controller side and the AirConsole plugin on the screen side. Is this correct?

    2. Since the airconsoleController plugin doesn't have any event triggers or expressions to receive messages, I am using the AirConsole plugin on the controller side to try to receive messages. I have tried the following, neither of which seem to work:

    I need to be able to send the following types of information from the screen to the controller:

    airconsole.nickname

    the current screen to display (loading game, too many players, character selection screen, in-game screen, game over screen)

    Is this something that needs to be handled in the controller plugin or the screen plugin?

    Thanks for your help on this!

  • cjbruce Have you tried creating an Airconsole object in your controller and getting the nickname inside an OnDeviceJoin condition?

    I think that the nickname that you will get is yours, If I'm not wrong. It is worth a try.

  • cjbruce Have you tried creating an Airconsole object in your controller and getting the nickname inside an OnDeviceJoin condition?

    I think that the nickname that you will get is yours, If I'm not wrong. It is worth a try.

    X3M,

    No luck. The OnDeviceJoin condition doesn't fire on the controller side. Just for kicks, I tried an alert with OnDeviceJoin on start of layout, and the alert showed "null" for the airconsole.nicknamejoin because it had not been set yet.

  • X3M,

    Also, the console is seeing a lot of handshake errors in the simulator:

    Message to 0: {\"handshake\":true}

  • X3M and Psychokiller1888,

    I was poking through the code, and realized that the following lines are duplicated for buttons in the AirConsoleController. If I'm not wrong, this means that "sendHandshake()" will get called twice, and it is redeclaring the sendHandshake function:

    var sendHandshake = function () {
    				_this.airconsole.message(AirConsole.SCREEN, {
    					handshake: true
    				});
    			};
    			_this.airconsole.onReady = function () {
    				sendHandshake();
    			};
    			_this.airconsole.onMessage = function (device_id, data) {
    				if (data.handshake) {
    					sendHandshake();
    				}
    			};[/code:21donbb9]
    
    I don't know if the above really affects anything.
    
    Also, I placed an alert in c2runtimectrl.js to verify that messages are getting received by the controller and handled in this.air_console.onMessage (created by the AirConsole plugin, not the AirConsoleController plugin).  My alert fires when I place it directly into the code, but a similar alert for the onMessage trigger placed in a Construct 2 event sheet does not fire.
  • Findings after more testing:

    1. When using a controller created in C2 with the two plugins, OnDeviceJoin is not called in screen.html.

    2. The screen doesn't seem to be resizing correctly on my phone (iPhone 7 plus) or iPad. The screen is resizing correctly in the simulator (Nexus 5).

  • cjbruce Yep that's the issue, there should be only one handshake per controller, I'll update later.

    Edit: That is weird because it is working fine with the pong demo. Have you tried testing on an Android device?

    Edit: Add this line :

    <meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1.0, maximum-scale=1.0"/>[/code:xihrxvd9] To the <head> of controller.html and tell me if it fixes the problem.
  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • cjbruce Yep that's the issue, there should be only one handshake per controller, I'll update later.

    Edit: That is weird because it is working fine with the pong demo. Have you tried testing on an Android device?

    Edit: Add this line :

    <meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1.0, maximum-scale=1.0"/>[/code:3n1l9htq] To the <head> of controller.html and tell me if it fixes the problem.
    

    X3M,

    No luck with the scaling problem. I wonder if it is a javascript issue. My existing code:

    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, minimal-ui" />[/code:3n1l9htq]
    
    The not receiving messages from the screen.html is driving me crazy.  I've spent several hours adding alerts in different spots in c2runtimectrl.js and/or in the event sheet.  All of the alerts I place directly into the code fire properly, but whenever I try to trigger an alert based on an AirConsole condition (OnDeviceJoin, OnMessage, etc.), I get nothing.  I've even tried to fiddle with the ExecJS() expression in Construct 2 to get the status of the message directly, but no luck so far.  Maybe I can create a variable at the beginning of the controller.html called "airconsoleMessageFromTheScreen", and set its value directly?
    
    Also, I still can't get the OnDeviceJoin and OnDeviceLeft conditions to work.
    
    I'm getting really flumoxed, and running out of ideas...
  • cjbruce You surely are doing something wrong , does the Pong example work for you ? I recommend that you go from there and examine the event sheet, remember that you need to allow the devices to connect first so that OnDeviceJoin and OnDeviceLeft can work.

  • cjbruce You surely are doing something wrong , does the Pong example work for you ? I recommend that you go from there and examine the event sheet, remember that you need to allow the devices to connect first so that OnDeviceJoin and OnDeviceLeft can work.

    X3M

    The pong example works fine, but it does not include an example of sending a message to the controllers other than a handshake.

    I'm porting an existing project that has been working for months now, and trying to remake the controllers in C2, instead of by hand.

  • cjbruce

    Just use the send message from your game to the desired controller. Invent your own format for your state changes, quick dirty exemple:

    Listen for the message on your controller

    airConsole.onMessage = function(deviceId, data) {
    		if (data.handshake) {
    			sendHandshake();
    		}
    		else if (data == 'displayState1') {
    			do your controller changes
    [/code:e6ihv45e]
    
    As for the nickname, you surely won't tell the controller to ask the screen to get the controller's nickname and make it send it back to the controller....
    
    You have an AirConsole object on your controller, so just get the nickname with it...
    
    [code:e6ihv45e]airConsole = new AirConsole({"orientation": "landscape"});
    	var nickname = airConsole.getNickname();[/code:e6ihv45e]
    
    As for the controllers not receiving, not getting dunno what, I cannot help sorry. I do not know this plugin and what it generates. I know that the official controller generator does work so I let you solve that with 

    X3M[/p] [/p] This is the behavior: [url=https://puu.sh/tDCKO.png]https://puu.sh/tDCKO.png[/url][/p] Image is too big, this forum does not even resize when using [img][/p] [/p] [img="https://puu.sh/tDCKO.png"]

  • Psychokiller1888 Ok thanks for the code, I'll implement a OnMessageReceived == "text" in the Controller.

    Edit: Ok now you can consider the plugin fully finished, I've added all the remaining features to it such as :

    • Controller->Accelerometer&Gyroscope
    • Controller->DeviceNickname/Id/PlayerNumber

    -Edit profile

    -OnMessage "message" Receiver

    • Controller->ProfilePictureURL

    -Controller->ReceivedMessage

Jump to:
Active Users
There are 2 visitors browsing this topic (0 users and 2 guests)