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:
    30
    Likes Received:
    19
    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:
    30
    Likes Received:
    19
    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:
    413
    Likes Received:
    817
    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:
    30
    Likes Received:
    19
    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:
    127
    Likes Received:
    148
    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:
    30
    Likes Received:
    19
    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:
    127
    Likes Received:
    148
    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:
    127
    Likes Received:
    148
    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:
    30
    Likes Received:
    19
    Hm ; I've never ran into any issues - which loco is this?
     
  14. LCYCowboy

    LCYCowboy Active Member

    Joined:
    Aug 23, 2021
    Messages:
    127
    Likes Received:
    148
    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:
    127
    Likes Received:
    148
    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 at 7:37 PM
  16. liam#5302

    liam#5302 Member

    Joined:
    Jan 11, 2025
    Messages:
    30
    Likes Received:
    19
    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
     
  17. liam#5302

    liam#5302 Member

    Joined:
    Jan 11, 2025
    Messages:
    30
    Likes Received:
    19
    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 1

Share This Page