How to determine the Console and Controller from a script.
9 posts
• Page 1 of 1
How to determine the Console and Controller from a script.
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.
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.
-
MaxRat08 - Sergeant Major
- Posts: 71
- Joined: Thu Jan 07, 2016 9:18 pm
Re: How to determine the Console and Controller from a scrip
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:
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.
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
-
J2Kbr - 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
Awesome, thanks for the quick reply.
-
MaxRat08 - Sergeant Major
- Posts: 71
- Joined: Thu Jan 07, 2016 9:18 pm
Re: How to determine the Console and Controller from a scrip
I downloaded you script!! Great job!!:)
ConsoleTuner Support Team
-
J2Kbr - 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
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?
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
My R6 script: https://youtu.be/x-9NtxyySVM
-
pablosscripts - Brigadier General
- Posts: 1976
- Joined: Tue Nov 24, 2015 6:27 am
Re: How to determine the Console and Controller from a scrip
lol ... no, this is not possible ... the Titan Two has only one output despite the multiple inputs capability.
ConsoleTuner Support Team
-
J2Kbr - 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
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!
Scripting, a game in the game.
Believe or dare, It's Titanic!
-
Prototype - Major General
- Posts: 3251
- Joined: Sun Dec 16, 2012 1:43 pm
Re: How to determine the Console and Controller from a scrip
This is possible with a USB Switch (not a hub).
ConsoleTuner Support Team
-
J2Kbr - 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
Yes of course, i understand.
Console tuner since my 1st controller.
Scripting, a game in the game.
Believe or dare, It's Titanic!
Scripting, a game in the game.
Believe or dare, It's Titanic!
-
Prototype - Major General
- Posts: 3251
- Joined: Sun Dec 16, 2012 1:43 pm
9 posts
• Page 1 of 1
Return to GPC2 Script Programming
Who is online
Users browsing this forum: Majestic-12 [Bot] and 118 guests