I Created A Mod/software To Directly Control In Game Trains Using A Joystick (no Raildriver)

Discussion in 'TSW General Discussion' started by liam#5302, Apr 3, 2025.

  1. liam#5302

    liam#5302 Member

    Joined:
    Jan 11, 2025
    Messages:
    36
    Likes Received:
    22
    Yes that's what I tend to do as well because it can be hard to feel without a physical detent; it should be as simple as changing your direct_control/api_control/sync_control input value to have a different minimum value; let's say emergency brake is 0.0 and maximum brake is 0.1 then you can set the following input value constraints:

    "input_value": {
    "min": 0.1,
    "max": 1.0
    }

    That way it will never drop to emergency
     
  2. themkall#6732

    themkall#6732 New Member

    Joined:
    Nov 17, 2024
    Messages:
    8
    Likes Received:
    0
    you can set the min value if you are using direct control with a joystick to 0.09. that stops it from going into the emergency brake detent
     
  3. themkall#6732

    themkall#6732 New Member

    Joined:
    Nov 17, 2024
    Messages:
    8
    Likes Received:
    0
    perfect! both worked flawlessly, and thank you for making me understand the logic of the steps! this makes it easier for future profiles. last question. is there any way to for the app to automatically detect each train or do i have to to switch profiles everytime?
     
  4. themkall#6732

    themkall#6732 New Member

    Joined:
    Nov 17, 2024
    Messages:
    8
    Likes Received:
    0
    i will ask for your help once more unfortunatly.... I dont know if you are familliar with the br612 diesel locomotive throttle, which has four steps, idle, decrease, hold and increase. unfortunatly on the last step the increase which requires you to hold the throttle there, even if you max out the joystick the throttle jumps momenteraly on the increase step and then it goes back to hold. do you have any idea how to make this work?
     
  5. themkall#6732

    themkall#6732 New Member

    Joined:
    Nov 17, 2024
    Messages:
    8
    Likes Received:
    0
    found it! for anyone wondering, you put max value +0.5 and min value -0.5.
     
  6. liam#5302

    liam#5302 Member

    Joined:
    Jan 11, 2025
    Messages:
    36
    Likes Received:
    22
    Just replying; yes you can enable auto selection by adding the following properties to your profile
    ```
    "auto_select": true,
    "rail_class_information": [
    {
    "class_name": "{CLASSNAME}"
    }
    ```
    You can find the actual class name from the cab debugger at the top where it says Currently Driving; you can just copy that value - then you can keep the profile selector on "Auto-Detect" and it will just switch profiles as needed

    As for the hold thing you might need multiple conditional assignments to make this fully work;

    ```
    {
    "assignments": [
    {
    "conditions": [{"control": "MyControl", "operator": "lte", "value": 0.9}],
    "type": "direct_control",
    "controls": "Throttle",
    "input_value": {
    "min": 0,
    "max": 0.9
    }
    },
    {
    "conditions": [{"control": "MyControl", "operator": "gt", "value": 0.9}],
    "type": "momentary",
    "threshold": 0.91,
    "action_activate": {
    "controls": "Throttle",
    "value": 1.0,
    "hold": true
    },
    "action_deactivate": {
    "controls": "Throttle",
    "value": 0.9
    }
    }
    ]
    }
    ```
    In the above example we want the normal direct control to apply from 0-0.9 for the throttle; for the second assignment which applies above 0.9 we have a momentary action which holds the direct control value (the hold here means the program will essentially keep sending the value to hold it down) until you deactivate in which case it will re-set back to 0.9 and the normal direct control will take over again. This is getting into some more complex profiles.
     
  7. Emmy_MAN

    Emmy_MAN Well-Known Member

    Joined:
    Apr 9, 2022
    Messages:
    423
    Likes Received:
    835
    Hi liam#5302

    I have a question for you.

    Do you happen to have the TSC-X controller too?
    Because if you use it yourself, you could create profiles for, let's say, German locomotives and trains, and then add them to your programme or offer them as separate downloads.

    This would make it easier for many users who have the TSC-X controller to use your programme.
     
  8. liam#5302

    liam#5302 Member

    Joined:
    Jan 11, 2025
    Messages:
    36
    Likes Received:
    22
    Sadly; I don't - that's why in the explore tab all the profiles are for the TCA Quadrant because that's the only controller I have; I'm happy to take contributions though!
     
  9. LCYCowboy

    LCYCowboy Active Member

    Joined:
    Aug 23, 2021
    Messages:
    134
    Likes Received:
    150
    Hi Liam,

    Just moved across to your fantastic software after not being able to drive certain trains using my TSC-X using CobraOne's equally fantastic software (certain Locos aren't coded for Rail Driver is seems).

    I have been playing all afternoon and have managed to code the Class 802 with the correct notches. Brilliant.

    A quick question. I am trying to code the train brakes which use the [ and ] keys, but can't work out what the text for these is. I tried "LeftSquareBracket" and "LeftAngleBracke" but neither seem to work. Do you have a list of the keyboard commands?
     
  10. liam#5302

    liam#5302 Member

    Joined:
    Jan 11, 2025
    Messages:
    36
    Likes Received:
    22
    Glad it works well for you! For normal characters you should just be able to enter the actual character; so `"keys": "]"`
     
  11. LCYCowboy

    LCYCowboy Active Member

    Joined:
    Aug 23, 2021
    Messages:
    134
    Likes Received:
    150
    Fantastic. That works. Thanks so much for the quick answer. Now I just need to work out how to program the German brakes. I have managed to put all the notches in, but they have a setting where you push forward from "running" which also overpressures the brake reservoir.
     
  12. LCYCowboy

    LCYCowboy Active Member

    Joined:
    Aug 23, 2021
    Messages:
    134
    Likes Received:
    150
    I seem to have run into a problem. With your mod installed, when I press CTR-R to arm the AFB (cruise control) I get a crash to desktop.

    This is the error code:

    Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0x00007fffe24c3ac8

    UE4SS
    UE4SS
    TrainSimWorld
    TrainSimWorld
    TrainSimWorld
    TrainSimWorld
    TrainSimWorld
    TrainSimWorld
    TrainSimWorld
    TrainSimWorld
    TrainSimWorld
    TrainSimWorld
    TrainSimWorld
    TrainSimWorld
    TrainSimWorld
    TrainSimWorld
    TrainSimWorld
    TrainSimWorld
    TrainSimWorld
    kernel32
    ntdll

    I removed the ue4ss_tsw_controller_mod folder and it fixed it.

    Is the dwmapi.dll also part of the mod (I didn't remove this and it didn't seem to cause any issues)

    Seems I can't use your mod and use AFB
     
  13. liam#5302

    liam#5302 Member

    Joined:
    Jan 11, 2025
    Messages:
    36
    Likes Received:
    22
    Hm ; I've never ran into any issues - which loco is this?
     
  14. LCYCowboy

    LCYCowboy Active Member

    Joined:
    Aug 23, 2021
    Messages:
    134
    Likes Received:
    150
    I have done some more testing. It is the standard BR101 (not the expert one).

    If I turn on/off the AFB using the switch in the cab, it all works fine. It is only when I actually press CTR-R on the keyboard that it crashes???
     
  15. LCYCowboy

    LCYCowboy Active Member

    Joined:
    Aug 23, 2021
    Messages:
    134
    Likes Received:
    150
    More testing, CTR-R causes a CTD in all trains (not just German ones). If I remove your app it works. If I select the cruise control in cab using the virtual switch it works. How strange

    I programmed a button to mimic CTR-R and it also causes a CTD
     
    Last edited: Feb 19, 2026
  16. liam#5302

    liam#5302 Member

    Joined:
    Jan 11, 2025
    Messages:
    36
    Likes Received:
    22
    hm alright I will need to check why those shortcuts create problems - I usually turn AFB on from the display so I guess that's why I haven't ran into it.. very odd though
     
    • Like Like x 1
  17. liam#5302

    liam#5302 Member

    Joined:
    Jan 11, 2025
    Messages:
    36
    Likes Received:
    22
    It looks like it's because of a UE4SS setting; you can open the ue4ss_tsw_controller_mod/UE4SS-Settings.ini file and set the EnableHotReloadSystem value to 0 instead of 1;

    I'll disable it by default in the next release since it's not actually necessary to be shipped with hot reload enabled
     
    • Like Like x 2
  18. LCYCowboy

    LCYCowboy Active Member

    Joined:
    Aug 23, 2021
    Messages:
    134
    Likes Received:
    150
    Thanks for the info. Do you put a post out when you have updated your software?
     
  19. liam#5302

    liam#5302 Member

    Joined:
    Jan 11, 2025
    Messages:
    36
    Likes Received:
    22
    it was already updated - when you open the application you should get a banner saying there is an update
     
  20. LCYCowboy

    LCYCowboy Active Member

    Joined:
    Aug 23, 2021
    Messages:
    134
    Likes Received:
    150
    Thanks Liam,

    Just spotted that. All fixed now. Just one more question (Promise). I am trying to use the hat switch on my T1600 joystick to increase and decrease the cruise control. The hat appears as just one button in the calibration settings and gives values of 1 to 8 depending on which direction it is moved. How do I code this. Is it using the threshold value?

    Thanks again,

    Neil
     
  21. liam#5302

    liam#5302 Member

    Joined:
    Jan 11, 2025
    Messages:
    36
    Likes Received:
    22
    Hmm I think it's a little clunky right now; you can do it with a momentary threshold of whatever value your hat is and adding 2 conditions where it's like gte 1 and lte 1; so yea very clunky (posted an example below)

    I'll have to look at making hats better supported; probably by changing the momentary and toggle actions to allow the threshold to be an exact value as opposed to a greater than or equal to value - i'll keep you posted


    Example here:
    https://tsw-controller-app.vercel.a...gICBdCiAgICAgICAgfQogICAgICBdCiAgICB9CiAgXQp9
     
  22. liam#5302

    liam#5302 Member

    Joined:
    Jan 11, 2025
    Messages:
    36
    Likes Received:
    22
    I added a new option for momentary and toggle called match which defaults to exceeds but can be set to equals so that the threshold has to be an equal match; this should work with your hat switch because then you can just have 8 different assignments each with an equals matching threshold of 1,2,3,4...8 and a corresponding action

    little example:
    https://tsw-controller-app.vercel.a...zIgogICAgICAgIH0KICAgICAgXQogICAgfQogIF0KfQ==
     
  23. LCYCowboy

    LCYCowboy Active Member

    Joined:
    Aug 23, 2021
    Messages:
    134
    Likes Received:
    150
    I just tried and can't seem to get it to work.

    upload_2026-2-27_13-8-14.png

    The top assignment with a value of 1 works, the bottom with a value of 4 (which is what pulling the hat down in the calibration window shows) does nothing.
     

    Attached Files:

    Last edited: Feb 27, 2026 at 1:08 PM
  24. liam#5302

    liam#5302 Member

    Joined:
    Jan 11, 2025
    Messages:
    36
    Likes Received:
    22
    You need to combine the assignment lists; you can't define the same control twice since it will override each other (reduced example below)

    {
    "name": "Hat",
    "assignments": [
    { "type": "momentary", "threhsold": 1 },
    { "type": "momentary", "threhsold": 4 }
    ]
    }
     
  25. LCYCowboy

    LCYCowboy Active Member

    Joined:
    Aug 23, 2021
    Messages:
    134
    Likes Received:
    150
    Thanks so much, works perfectly now. Never done any coding in my life, so thanks for all the help and for such an amazing program.
     
  26. liam#5302

    liam#5302 Member

    Joined:
    Jan 11, 2025
    Messages:
    36
    Likes Received:
    22
    No worries at all! There is also the online profile builder you can use (https://tsw-controller-app.vercel.app/profile-builder) [but I find the code easier to reason about personally]
     
  27. Tigert1966

    Tigert1966 Well-Known Member

    Joined:
    Aug 18, 2020
    Messages:
    2,327
    Likes Received:
    4,017
    Hi Liam, just dropped into the thread to say thanks for the mod.

    I have a pretty nice TS Controllers setup, but I don't have a PBC, So I got a Boeing Throttle Quadrant and set up your mod and had everything I needed working within 15 minutes.

    Just need to modify the config a bit for a few controls and my setup will be exactly as I want it.
     
  28. liam#5302

    liam#5302 Member

    Joined:
    Jan 11, 2025
    Messages:
    36
    Likes Received:
    22
    That's good to hear!
     

Share This Page