Skip to content

Instantly share code, notes, and snippets.

@jsoltren
Created November 20, 2022 18:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsoltren/903dd5f24e3b31dbc602afeb8ff10b00 to your computer and use it in GitHub Desktop.
Save jsoltren/903dd5f24e3b31dbc602afeb8ff10b00 to your computer and use it in GitHub Desktop.
Use the Zuiki Densha-de-GO! controller for the Nintendo Switch on the PlayStation, using a ConsoleTuner Titan One.
// Zuiki Densha De Go! Nintendo Switch to PS4 Converter
// Jose Soltren <jsoltren@gmail.com>
// 2022-11-20
// Based heavily on Wes Alvaro's converter for Titan Two:
// https://gist.github.com/wesalvaro/a4a21fc3d1eebe58878b6516d9357245
// #pragma METAINFO("Zuiki Densha-de-GO! for PS4", 1, 0, "Wes Alvaro")
// (His version is better. The GPC language for Titan One is too restricting.)
// Converts NS Zuiki Densha-de-GO! controller mascon values for PS4.
// Mascon values need conversion or else mascon positions are skipped.
// No changes are needed for other controls (including EB),
// but I do call out EB explicitly.
// The mascon is controlled with the left analog stick's y-axis.
// Values are negative for braking, positive for powering, 0 when neutral.
define MASCON = HID_STICK_2_Y;
// The following values were from my controller and Titan One.
// It's possible that these values are not consistent across all controllers.
// To account for differences, an epsilon of 5 (which is equal to half of the
// smallest range 10) is added when making comparisons. Sadly, the input values
// can't be easily recognized by a function due to their curious value jumps.
// Power Corrections:
// Input values to Titan 2 from NS Zuiki:
int NS_BE = -100; // Emergency Brake
int NS_B8 = -96;
int NS_B7 = -85;
int NS_B6 = -74;
int NS_B5 = -63;
int NS_B4 = -52;
int NS_B3 = -42;
int NS_B2 = -31;
int NS_B1 = -20;
int NS_N = 0;
int NS_P1 = 24;
int NS_P2 = 43;
int NS_P3 = 61;
int NS_P4 = 80;
int NS_P5 = 100;
// Output values from Titan 2 to PS4:
// The following values are accepted by the PS4 for Standard + Direct controls.
// These values don't need any adjustment as they are unrelated to hardware.
// The positions map 1-to-1 with the NS_ values above.
int PS_BE = -100; // Emergency Brake
int PS_B8 = -100;
int PS_B7 = -90;
int PS_B6 = -75;
int PS_B5 = -65;
int PS_B4 = -60;
int PS_B3 = -50;
int PS_B2 = -40;
int PS_B1 = -30;
int PS_N = 0;
int PS_P1 = 40;
int PS_P2 = 50;
int PS_P3 = 60;
int PS_P4 = 80;
int PS_P5 = 100;
// Epsilon for NS input value differences between hardware:
int E = 5;
int pOut = 0;
main {
// Initialize the output to the current value of the mascon
pOut = get_val(MASCON);
// Translate mascon position value from NS to PS values
if (pOut < NS_BE + E) pOut = PS_BE;
else if (pOut < NS_B8 + E) pOut = PS_B8;
else if (pOut < NS_B7 + E) pOut = PS_B7;
else if (pOut < NS_B6 + E) pOut = PS_B6;
else if (pOut < NS_B5 + E) pOut = PS_B5;
else if (pOut < NS_B4 + E) pOut = PS_B4;
else if (pOut < NS_B3 + E) pOut = PS_B3;
else if (pOut < NS_B2 + E) pOut = PS_B2;
else if (pOut < NS_B1 + E) pOut = PS_B1;
else if (pOut < NS_N + E) pOut = PS_N;
else if (pOut < NS_P1 + E) pOut = PS_P1;
else if (pOut < NS_P2 + E) pOut = PS_P2;
else if (pOut < NS_P3 + E) pOut = PS_P3;
else if (pOut < NS_P4 + E) pOut = PS_P4;
else if (pOut < NS_P5 + E) pOut = PS_P5;
// Set adjusted mascon position value:
set_val(MASCON, pOut);
}
@ndoo
Copy link

ndoo commented Aug 27, 2023

Hi there, how do you avoid the 8-10min reauthentication disconnection when using the Titan One?

So far, I either enable crossover mode and deal with annoying disconnections while driving, or if I don't enable crossover mode, the controller won't authenticate.

@jsoltren
Copy link
Author

I have no clue. I wish I could help further. PS4 passthrough authentication would need to be handled by the Titan One. This change only remaps the left analog stick's y-axis value from the NS Zuiki's values to values that the PS4 version of the game expects (lines 74-91). I don't have anything further to offer beyond ConsoleTuner's support page (https://www.consoletuner.com/kbase/connecting_on_playstation_4.htm) and whatever you might find on forums.

My very limited testing involved plugging in the controller and making sure the mascon values mapped correctly. I don't think I hit the timeout in that time, the testing only took a few minutes.

It's ugly, but you could always try yet another console adapter (e.g. Mayflash or Brook) after the Titan One to deal with authentication.

@ndoo
Copy link

ndoo commented Aug 27, 2023

Hey, thanks for the reply. Yeah I can see how your testing wouldn't catch it, the script definitely works for the mapping of the masscon values, but for actual gameplay the Titan One should probably be avoided, as the game doesn't pause when the controller disconnect happens, leading to the train unintentionally coasting while trying to stop at a station, which could ruin the entire journey.

If I had known this would be a problem, I wouldn't have gotten the Titan One, instead just going directly for the Titan Two. Oh well. Hoping this comment helps anyone who may be considering purchasing the Titan One.

There isn't any workaround as the Titan One does not support USB hubs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment