How to determine the Console and Controller from a script.

GPC2 script programming for Titan Two. Code examples, questions, requests.

How to determine the Console and Controller from a script.

Postby MaxRat08 » Wed Oct 05, 2016 2:28 am

Does anyone have any ideas on how to do this?
I have tried the port_status function, but I have had now luck getting it to tell me anything other than if a controller is connected or not.
This is what I have discovered so far:

Input:
0= no controller/unsupported device
64=controller connected

Output:
0=no connection
128=connected to console
129= connected to console with controller and console being the same type.

Changing the protocol from anything other than 0 or PROTOCOL_AUTO will cause a compile error. This includes a variable with this value as well.
Changing the device argument from anything other than 0 will also cause a compiler warning.
User avatar
MaxRat08
Sergeant Major
Sergeant Major
 
Posts: 71
Joined: Thu Jan 07, 2016 9:18 pm

Re: How to determine the Console and Controller from a scrip

Postby J2Kbr » Wed Oct 05, 2016 10:15 am

you are on the right track, the way to determine that is using port_status. Please note there was an bug with this function that was fixed with the latest software/firmware releases.

Here is an example to determine the controller:

Code: Select all
init {
    uint8 status, protocol, device;
    status = port_status(PORT_USB_A, &protocol, &device);
    if(status & DIR_INPUT) { // Check if the port is input (controller)
        switch(protocol) {
            case PROTOCOL_PS3: printf("PS3 Controller: %d", device); break;
            case PROTOCOL_PS4: printf("PS4 Controller: %d", device); break;
            case PROTOCOL_XB360: printf("XB360 Controller: %d", device); break;
            case PROTOCOL_XB1: printf("XB1 Controller: %d", device); break;
        }
    }
}


if status == 0 there is no controller connected (or port error)
status with DIR_INPUT or DIR_OUTPUT to determine the data flow direction (controller / console).
status with PASSTHRU_NONE, PASSTHRU_FULL, PASSTHRU_PARTIAL to determine the passthru mode the port is working.

use 'protocol' to check the protocol in use on the port, this checking is the same for controller or console.

'device' can be used to determine more specifically the controller in use, 0 means the default/official controller for that protocol. For PS4 and XB1 protocols, device == 1 means a third-party controller. For XB1 device == 2 means Elite controller.
ConsoleTuner Support Team
User avatar
J2Kbr
General of the Army
General of the Army
 
Posts: 20323
Joined: Tue Mar 18, 2014 1:39 pm

Re: How to determine the Console and Controller from a scrip

Postby MaxRat08 » Wed Oct 05, 2016 3:30 pm

Awesome, thanks for the quick reply.
User avatar
MaxRat08
Sergeant Major
Sergeant Major
 
Posts: 71
Joined: Thu Jan 07, 2016 9:18 pm

Re: How to determine the Console and Controller from a scrip

Postby J2Kbr » Thu Oct 06, 2016 4:59 pm

I downloaded you script!! Great job!!:)
ConsoleTuner Support Team
User avatar
J2Kbr
General of the Army
General of the Army
 
Posts: 20323
Joined: Tue Mar 18, 2014 1:39 pm

Re: How to determine the Console and Controller from a scrip

Postby pablosscripts » Thu Oct 06, 2016 10:44 pm

Wait wait wait.

I can have an XB1 controller and a PS4 controller connected simultaneously, and then the T2 connected to both consoles with a hub (not a switch), and have it just work automatically regardless of which console I'm on? Am I understanding this right?
Setup: XIM Apex, T2, K780 keyboard, G Pro Wireless mouse, SteelSeries 4HD pad, DXRacer armrest, LucidSound LS30 headset, Netduma router, Ubiquiti UniFi AP LR

My R6 script: https://youtu.be/x-9NtxyySVM
User avatar
pablosscripts
Brigadier General
Brigadier General
 
Posts: 1976
Joined: Tue Nov 24, 2015 6:27 am

Re: How to determine the Console and Controller from a scrip

Postby J2Kbr » Fri Oct 07, 2016 6:08 pm

lol ... no, this is not possible ... the Titan Two has only one output despite the multiple inputs capability.
ConsoleTuner Support Team
User avatar
J2Kbr
General of the Army
General of the Army
 
Posts: 20323
Joined: Tue Mar 18, 2014 1:39 pm

Re: How to determine the Console and Controller from a scrip

Postby Prototype » Fri Oct 07, 2016 6:55 pm

Yes but like he said, by having the Titan Two plugged in a hub connected to both consoles? Of course it will be a problem if both consoles are powered in the same time :)
Console tuner since my 1st controller.
Scripting, a game in the game.
Believe or dare, It's Titanic! :smile0517:
User avatar
Prototype
Major General
Major General
 
Posts: 3251
Joined: Sun Dec 16, 2012 1:43 pm

Re: How to determine the Console and Controller from a scrip

Postby J2Kbr » Fri Oct 07, 2016 7:05 pm

This is possible with a USB Switch (not a hub).
ConsoleTuner Support Team
User avatar
J2Kbr
General of the Army
General of the Army
 
Posts: 20323
Joined: Tue Mar 18, 2014 1:39 pm

Re: How to determine the Console and Controller from a scrip

Postby Prototype » Fri Oct 07, 2016 7:08 pm

Yes of course, i understand.
Console tuner since my 1st controller.
Scripting, a game in the game.
Believe or dare, It's Titanic! :smile0517:
User avatar
Prototype
Major General
Major General
 
Posts: 3251
Joined: Sun Dec 16, 2012 1:43 pm


Return to GPC2 Script Programming

Who is online

Users browsing this forum: Majestic-12 [Bot] and 118 guests