PC Ts World Raildriver And Joystick Interface

Discussion in 'TSW General Discussion' started by CobraOne, Nov 8, 2022.

  1. SGTDRE

    SGTDRE Well-Known Member

    Joined:
    Sep 6, 2022
    Messages:
    1,546
    Likes Received:
    803
    Okay, this I understand now, then, yes the program that CobraOne has made is what you need and are trying to get working, not the native RailDriver in-game support for the device made by P.I. Engineering, or the Macroworks software. My apologies, I misunderstood, hope you can get it working.
     
    Last edited: Nov 17, 2023
  2. fizzbin14

    fizzbin14 Member

    Joined:
    Jan 22, 2022
    Messages:
    35
    Likes Received:
    3
    Has anyone got the RD working with the class 142? Works fine with the 47 on the same route.
     
  3. atpyatt

    atpyatt Well-Known Member

    Joined:
    Nov 28, 2020
    Messages:
    118
    Likes Received:
    314
    • Helpful Helpful x 1
  4. fizzbin14

    fizzbin14 Member

    Joined:
    Jan 22, 2022
    Messages:
    35
    Likes Received:
    3
    Thank you very much sir.
     
  5. SGTDRE

    SGTDRE Well-Known Member

    Joined:
    Sep 6, 2022
    Messages:
    1,546
    Likes Received:
    803
  6. atpyatt

    atpyatt Well-Known Member

    Joined:
    Nov 28, 2020
    Messages:
    118
    Likes Received:
    314
    No, you don't need to do anything with the in game calibration tool. I just meant that I haven't spent any time customising the 142 setup in the files because I use the Raildriver And Joystick Interface to set notch values etc.

    Just drop the pak file into your DLC and use this tool to set the controls up to your liking (I'm using the Raildriver loco brake for the 142 throttle)
     
    • Helpful Helpful x 1
  7. CobraOne

    CobraOne Active Member

    Joined:
    Jun 3, 2022
    Messages:
    254
    Likes Received:
    190
    I have just run the 395 using a saitek throttle quadrant and my program worked fine.
    Can I suggest you try calibrating the "TWCS USB Throttle Controller" in TSW and in my program to see if that helps.
    One thing I did notice is that the brake range went from 10 - 3 then straight to 0 without a 2 or 1 position.
    I also noticed it does this if you use the keyboard and not my program.
    Chris
     
  8. SGTDRE

    SGTDRE Well-Known Member

    Joined:
    Sep 6, 2022
    Messages:
    1,546
    Likes Received:
    803
    Have not had time to do much, "shared PC" but anyway I just dropped your RD mod into the DLC folder and everything is working just as it should, with the exception of the RD buttons for the bell and the toggle switches, the LED lights up no flickering, the lights, wipers, brake key, reverser, work just fine, the throttle is just that for me as well as the brake lever, the d-pad opens and closes the doors.

    This may be TMI here but I'm just putting this info here to let you know how it's working for me, the only program installed that I don't really need is Macroworks 3.1 but that is something I'm trying to get working with something else. Also, I do not have the program from CobraOne installed. With just the native in-game support for RD and your mod, it works well, it's spot on.
    I thank you for taking the time to make this mod and for sharing it with us, I do appreciate it very much, and If I misunderstood you, my apologies.
     
  9. atpyatt

    atpyatt Well-Known Member

    Joined:
    Nov 28, 2020
    Messages:
    118
    Likes Received:
    314
    Great, sounds like it works better by default than I thought it would, you're welcome :)
     
  10. Hsing

    Hsing New Member

    Joined:
    Dec 3, 2023
    Messages:
    17
    Likes Received:
    3
    Hi Chris, I bought my RailDriver a few days ago and got unsatisfied with its accuracy :( And yeah, I'll likely dive into a joystick-mapping solution. I have roughly browsed both yours and Drakoz's solutions, and believed both works are very creative and beneficial to hard-core train sim players, a big thanks ! (though you use quite different methods). I'm wondering (honestly curious about) how you can interpret PieHid64.dll file and modify it accordingly. Does P.I. Eng. or DTG provide any documentation for it? If not, I'm really curious about how you make your program work. Of course, if you don't mind these "open-source" questions, could you give some info on your program from a developer's perspective? I may want to try to customize the program as needed, and will share any findings/suggestions/bug report I could get with you and the community for sure. Thanks!
     
  11. darkman222

    darkman222 Member

    Joined:
    Nov 8, 2020
    Messages:
    57
    Likes Received:
    66
    Very good software. I calibrated it in TSW4 with the Raildriver Setup. But I cant get rid of the percentage input jumps the axis is doing. Even if its in percent, it just jumps. Any idea how to have some kind of a finer "resolution"?
    Thats what I am talking about:
    https://youtube.com/shorts/PP-heXIXQU4
     
    Last edited: Dec 18, 2023
  12. CobraOne

    CobraOne Active Member

    Joined:
    Jun 3, 2022
    Messages:
    254
    Likes Received:
    190
    Hi Hsing
    I used the information from these links to ascertain how the PieHid64.dll works and how to communicate between two processes (my program and the dll) using named pipes.
    PI Engineering SDK
    https://github.com/piengineering/PI-Engineering-SDK

    Named Pipe Server C++
    https://learn.microsoft.com/en-us/windows/win32/ipc/named-pipe-server-using-overlapped-i-o

    Named Pipe Client C++
    https://learn.microsoft.com/en-us/windows/win32/ipc/named-pipe-client

    I have also uploaded the code for the two dll's I wrote, Piehid64.dll and WriteToPipe.dll here
    https://www.dropbox.com/s/5fwdom79vmzo3zr/TSW New Dll's.zip?dl=1

    I won't share the main program code, as I want to keep full control over it to restrict as much as possible, the possibility of a virus.
    Basically my program uses the PI engineering example to read the Raildriver and SharpDx to read the joysticks. It then writes this data to the PieHid64.dll as a 15 byte array. See the documentation on the link to the PI Engineering SDK.

    You are free to use the code in the two dll's in any program you create, but due to health problems, I won't be doing any more development myself.

    Chris
     
    Last edited: Dec 21, 2023
    • Like Like x 1
  13. CobraOne

    CobraOne Active Member

    Joined:
    Jun 3, 2022
    Messages:
    254
    Likes Received:
    190
    Hi darkman
    Have you calibrated your joystick in TSW, any levers you don't use, simply click past them and they will be ignored.
    Also can you make sure that "Use Notches" is set to No in the lever map and see if that makes a difference.
    If your loco has a throttle and separate brake, try using the ThrottleFullRange lever map.

    Chris
     
  14. SGTDRE

    SGTDRE Well-Known Member

    Joined:
    Sep 6, 2022
    Messages:
    1,546
    Likes Received:
    803
    @atpyatt Have a question for you, I don't know of any other modders who are creating mods like this, that are active on the TSC mod pages, I was wondering if you would be able to make one for Train Sim World® 2: Peninsula Corridor: San Francisco - San Jose Route Add-On so the Raildriver could be used with it, I just noticed it today, that there is NO calibration setting for it in game that is.

    Also In the event you have not seen, in the one update for TSW4 the Raildriver is now working with the 142 except for the reverser, it can't be put into reverse with the Railldriver off-neutral-forward yes. Just thought I would let y'all know if you have not seen it.
     
    Last edited: Dec 25, 2023
  15. Expressdriver

    Expressdriver Member

    Joined:
    Sep 29, 2021
    Messages:
    16
    Likes Received:
    25
    I'm struggling to work out how to set up the 150 using the Flight hotas throttle. The throttle itself has a centre indent. I select 150 in the raildriver and interface program, when I go the pull off, the brake handle doesn't move and the throttle moves through all 7 notices, any idea how to make it so the brake handle is in one part of the throttle and the power handle the next?
     
  16. CobraOne

    CobraOne Active Member

    Joined:
    Jun 3, 2022
    Messages:
    254
    Likes Received:
    190
    Hi Ben
    I did receive your message and am working on a solution, but after catching COVID in October, my brain isn't firing on all cylinders at the moment.
    My software is designed to have one joystick lever per train lever unless the train has a combined lever like the class 377 etc. I will reply to your message when I have a solution for you to test for me but it may be a few days before I think of a solution.
    Chris
     
    Last edited: Dec 29, 2023
  17. CobraOne

    CobraOne Active Member

    Joined:
    Jun 3, 2022
    Messages:
    254
    Likes Received:
    190
    TSW Raildriver & Joystick Interface V2.0.0.3 Released

    Main Full Program

    https://www.dropbox.com/scl/fi/687y....0.3.zip?rlkey=tafs3nnk9sahm1vkdp40ftzz4&dl=1

    Quick Start Guide v2.0.0.0
    https://www.dropbox.com/scl/fi/usv1....0.0.pdf?rlkey=r9up8ze24xtp49yyj5g4bcg5k&dl=1

    Directx
    https://www.microsoft.com/en-gb/download/details.aspx?id=8109

    At the request of Expressdriver I have now added the option to control the trains in TSW using a single joystick lever.
    This will allow you to set the lever as the ThrottleAndBrake, Throttle and TrainBrake, Throttle and LocoBrake and ThrottleAndBrake with Trainbrake.
    In the Manuals folder is a three page pdf file called "Single Lever Joystick" showing how to setup the three new lever maps that are required and the master lever map.

    This version is the same as V2.0.0.2 but with the single lever option added, if you use more than one lever then there will be no difference to you between the two versions.
    Chris

    If you downloaded this version before 15:30hrs GMT on 13/01/24 then can you download the software again as I uploaded a beta version by mistake.
     
    Last edited: Mar 24, 2024
    • Like Like x 4
  18. danbaz100

    danbaz100 New Member

    Joined:
    Dec 30, 2021
    Messages:
    12
    Likes Received:
    3
    Dear CobraOne (Chris), thank you very much for having created this wonderful program!

    I have come over from TSW2 Controller app. Yours has the benefit that you are not depending on screen reads.
    The other program also has a few really nice options, that I just would like to throw out here and maybe this is something that you can implement in your app, if you like it.

    What I would like to do is to use the joystick (springloaded) from my HOTAS to be able to walk around on foot.
    Currently the app can split axes, but could it be further split in four, so that ultimately we have the option to move forward and backward, but also turn left and turn right while moving forward/backward (joystick I mean, not the mouse for turns)?

    Further when you think about the forward movement of the joystick, let's say 0 to 100. Could you implement the option to assign e.g. 20-70 to walking forward and 71-100 to running. The idea is to be able to walk and run by moving the joystick lesser or further forward.

    These are just some ideas and I am greatful for what you alrewady have done!

    My last question is about the turning left or right by using a key press (not the mouse). I was hoping for Ctrl+left or A or Shift+left or D, however this does not seem to exist. Do you or anybody know this key combination? This would be needed to be able to walk around on foot solely using the joystick. Thanks!

    Regards,
     
  19. CobraOne

    CobraOne Active Member

    Joined:
    Jun 3, 2022
    Messages:
    254
    Likes Received:
    190
    Hi danbaz100
    I have so far managed to implement move forward/backward, move left/right and turn left/right (by emulating the mouse, there are no keyboard keys for mouse movement). Do you also require look up/down? which again has to be implemented by emulating the mouse as there are no keyboard keys. If so, how are you going to implement it on your joystick, i.e. which axis?
    Chris
     
  20. danbaz100

    danbaz100 New Member

    Joined:
    Dec 30, 2021
    Messages:
    12
    Likes Received:
    3
    Hi Chris,
    Nice to hear you are able to make turning left/right work!
    I maybe would like looking up/down indeed once walking around with joystick only. Not a big one for me now though. Maybe for other users..
    I can imagine I would want to use the hat switch up/down for looking up/down. So that would then be button to mouse emulation...?

    Kind regards,
     
  21. CobraOne

    CobraOne Active Member

    Joined:
    Jun 3, 2022
    Messages:
    254
    Likes Received:
    190
    TSW Raildriver & Joystick Interface V2.0.0.4 Released

    Main Full Program
    https://www.dropbox.com/scl/fi/wwpu....0.4.zip?rlkey=xz6nwjyxobcaculnhxqw4o4lo&dl=1

    Quick Start Guide v2.0.0.0
    https://www.dropbox.com/scl/fi/usv1....0.0.pdf?rlkey=r9up8ze24xtp49yyj5g4bcg5k&dl=1

    Directx
    https://www.microsoft.com/en-gb/download/details.aspx?id=8109

    At the request of danbaz100, the program will now allow you to assign a joystick axis to:
    Walk/run forwards/backwards.
    Walk/run left/right.
    Turn Left/right.
    Look up/down.

    You can also assign buttons to:
    Turn Left/right.
    Look up/down.
    Act as the left/right mouse buttons.
    Assigning these in your button map to a hat switch will allow you to look around without using the mouse.

    Full instructiions are provided in the "Walking and looking in TSW using a joystick.pdf" file located in the Manuals folder.

    The program will now automatically create the three lever maps needed in the last version, so you no longer need to do this manually.

    Also note that if you are updating from an earlier version, the program will automatically update your master lever and button maps to enabled the above options. Once the update is done, you will receive a message asking you to restart the program for the changes to be applied.

    Chris
     
    Last edited: Mar 24, 2024
    • Like Like x 4
    • Helpful Helpful x 1
  22. danbaz100

    danbaz100 New Member

    Joined:
    Dec 30, 2021
    Messages:
    12
    Likes Received:
    3
    Thank you very much Chris!

    Really happy with this!
     
    • Like Like x 1
  23. danbaz100

    danbaz100 New Member

    Joined:
    Dec 30, 2021
    Messages:
    12
    Likes Received:
    3
    Hi Chris,

    The first version of this program that I downloaded was version V2.0.0.3. I had unpacked and placed it somewhere on my compter and then just started to use it.
    Now there is version V2.0.0.4. I have downloaded it and unpacked it.
    Should I overwrite this to where I had the previous version placed?
    Will this then overwrite my Default_ButtonMapper file to which I had added some missing buttons?
    If I save it first somewhere else and then add it back, does that mean I am missing some crucial things?
    In short: How to go about the update process of this wonderful gem program?
    Sorry if this has been discussed before. I had tried to find it, but not find it.

    Kind regards,
     
  24. CobraOne

    CobraOne Active Member

    Joined:
    Jun 3, 2022
    Messages:
    254
    Likes Received:
    190
    Yes
    No
    Yes

    I have designed the program so that if you have changed or created your own lever maps, button maps and master lever maps, they will never be replaced. What this version does, is read your button maps and master lever maps, and if they do not contain the necessary commands I have created for the mouse control, then they will be added to your files, leaving everything else in the file alone.
    The only files that get updated when you copy over a new version are those in the DefaultSetttings folder, the Manuals folder and the root folder, i.e. the dll's and the program exe file. Nothing in the KeyMaps or Settings folder will be overwritten, only updated by the program itself if needed. That's why, when you first run 2.0.0.4, it will update your files and ask you to restart the program.

    So in short, simply copy over the new version onto your older version and answer Yes when asked to overwrite any files.

    Chris
     
    Last edited: Jan 25, 2024
    • Like Like x 2
  25. jamster47

    jamster47 Well-Known Member

    Joined:
    Jul 26, 2020
    Messages:
    220
    Likes Received:
    422
    Sorry but quick question is this for any joystick or only certain types? Not familiar with the process. I have the airbus throttle and flight stick. thanks for any assistance.
     
  26. CobraOne

    CobraOne Active Member

    Joined:
    Jun 3, 2022
    Messages:
    254
    Likes Received:
    190
    This can be used with any joystick even ones you create yourself using a Arduino board that emulates a joystick.
    It also can be used to enhance the Raildriver Cab Controller from PI Engineering.
    You can use your flight stick to walkaround and the levers for the throttles as the levers in the cab of the trains in TSW2 onwards.

    Chris
     
  27. jamster47

    jamster47 Well-Known Member

    Joined:
    Jul 26, 2020
    Messages:
    220
    Likes Received:
    422
    Amazing thank you. I will have a play. Sounds awesome.
     
  28. danbaz100

    danbaz100 New Member

    Joined:
    Dec 30, 2021
    Messages:
    12
    Likes Received:
    3
    Thank you very much for the explanation.
    Maybe you can add something about it in the manual (sorry if it is there and I have overlooked).
     
  29. lawn.chairs

    lawn.chairs Member

    Joined:
    Aug 8, 2021
    Messages:
    39
    Likes Received:
    40
    Works great with the Zuiki Densha De Go controller. Will try to fine tune it over time, but definitely best suited to recent combined-power-handle locos (UK class 801, OBB 4024).
     
    • Like Like x 1
  30. chippiearnold

    chippiearnold Member

    Joined:
    Oct 24, 2017
    Messages:
    32
    Likes Received:
    59
    Just discovered this today, and just wanted to say how great this is - finally I can use my Honeycomb Bravo throttle unit to drive trains! Massive thanks to CobraOne for producing and updating this genius piece of software. Bravo sir! Literally :)
     
    • Like Like x 1
  31. Fields

    Fields New Member

    Joined:
    Mar 3, 2022
    Messages:
    12
    Likes Received:
    11
    Hi there CobraOne,

    I'm using your awesome program since you released the first version here, thank you so much for your effort and for making this available! I never had any issues, but now there is some strange behavior with my custom train controller, although I don't remember changing anything:
    I have separate levers for throttle and dynamic break, so I'm using "ThrottleAndDynamic". Since a few days, the lever for my dynamic break isn't recognised at all. When looking at "Data Sent To TSW", I noticed that it displays "Dynamic Break" with value 0.5. When I move my throttle lever to the middle, it switches to "Throttle", starting from 0.5 as well and then all the way up to 1. No matter what I'm doing, the value for "Dynamic Break" is not changing.
    I already tried to recalibrate my controller in Windows, all axes are displayed fine there. Redownloading your program and verifying game files of TSW via Steam did also not help. Do you have any idea what might cause the issue?

    Thank you!
     
  32. CobraOne

    CobraOne Active Member

    Joined:
    Jun 3, 2022
    Messages:
    254
    Likes Received:
    190
    • Like Like x 2
  33. Fields

    Fields New Member

    Joined:
    Mar 3, 2022
    Messages:
    12
    Likes Received:
    11
    Ohhhh, that makes sense! Didn't come to my mind that I could try an older version. Works perfectly again with 2.0.0.2! Thank you so much, Chris, really appreciate your work!
     
    • Like Like x 1
  34. cpavit

    cpavit Member

    Joined:
    Jan 13, 2024
    Messages:
    38
    Likes Received:
    41
    Thanks for this software. Can you please add support for the Siemens Vectron train?
     
  35. CobraOne

    CobraOne Active Member

    Joined:
    Jun 3, 2022
    Messages:
    254
    Likes Received:
    190
    Hi cpavit
    You can use the ThrottleAndBrake lever map to control the Siemens Vector but there are a couple of problems with the train that require a fix by DTG, I can't fix them through my software.
    1. The Ind Brake (LocoBrake) lever on the Raildriver Controller is supposed to be assigned to the AFB but it isn't.
    2. The Ind Brake (LocoBrake) lever on the Raildriver Controller is not assigned to the Direct Brake (LocoBrake) in the train either.

    Therefore, the only controls that work are the Reverser, ThrottleAndBrake and the Auto (Train) Brake.

    I have tested this with a Raildriver and the original Dll that comes with the game and the problems exist then too.

    Chris
     
  36. SGTDRE

    SGTDRE Well-Known Member

    Joined:
    Sep 6, 2022
    Messages:
    1,546
    Likes Received:
    803
  37. CobraOne

    CobraOne Active Member

    Joined:
    Jun 3, 2022
    Messages:
    254
    Likes Received:
    190
    SGTDRE That worked a treat, thank you for the link.
    cpavit Download the file from the link and place it where stated and the AFB and Direct Brake will work. The AFB is controlled by your locobrake lever and the Direct Brake by the reverser lever.

    Chris
     
    Last edited: Feb 10, 2024
  38. SGTDRE

    SGTDRE Well-Known Member

    Joined:
    Sep 6, 2022
    Messages:
    1,546
    Likes Received:
    803
    you're welcome.
     
  39. xie

    xie New Member

    Joined:
    Feb 27, 2024
    Messages:
    1
    Likes Received:
    0
    Thank you
     
  40. CobraOne

    CobraOne Active Member

    Joined:
    Jun 3, 2022
    Messages:
    254
    Likes Received:
    190
    TSW Raildriver & Joystick Interface V2.0.0.5 Released

    Main Full Program
    https://www.dropbox.com/scl/fi/os02....0.5.zip?rlkey=v5bx0ryqhtol1gvxt3d91nk2a&dl=1

    Quick Start Guide v2.0.0.0 English
    https://www.dropbox.com/scl/fi/usv1....0.0.pdf?rlkey=r9up8ze24xtp49yyj5g4bcg5k&dl=1

    Quick Start Guide V2.0.0.0 French
    https://www.dropbox.com/scl/fi/qm7n...e-FR.pdf?rlkey=pnrq2jjzawjxzu05wx779v2rm&dl=1

    Directx
    https://www.microsoft.com/en-gb/download/details.aspx?id=8109

    If you are updating from an earlier version, simply extract the zip file into your current folder, otherwise extract the zip file into a folder of your choice.

    1. Fixes the bug that crept in in V2.0.0.3 regarding the dynamic brake no longer working.
    2. Fixed an issue where buttons in TSW would not be released on some loco's.
    3. French versions of the Quick Start guide and TSW Raildriver and Joystick Interface Manual inluded in the Manuals folder, thanks to
    lactic#5649 for providing them.https://www.univers-simu.com/guides...oysticks-pour-conduire-vos-locomotives-26220/
    4. I have also updated the notches settings so that it is now possible to fine tune the notch values,
    see the Advanced Notches section of the Using Notches.pdf in the Manuals folder.
    This is mostly intended for those that have a Zuiki Mascon controller that has indents at each notch position for precise positioning of the joystick, but others may also find it helpful.
    When using the original method, using the Reverser as an example (Off, Forward, Neutral, Reverse) you would enter 0, 0.33, 0.66, 1, this means that whenever your joystick is between 0.0 and 1.0, the following would be sent to TSW.
    J upload_2024-2-28_8-11-37.png
    You can now enter something like this (note the change in Value sent to TSW too).
    upload_2024-2-28_8-12-50.png

    This will allow you to fine tune your notches.
    With the example above, when the joystick is between 0.04 and 0.29, 0.37 and 0.62, and 0.70 and 0.96 nothing will be sent to TSW.

    It is advisable that once you have setup your notches, do not calibrate your Raildriver or joysticks again as it may throw the notch values off.

    Chris
     
    Last edited: Mar 24, 2024
    • Like Like x 1
  41. jaapjan#1769

    jaapjan#1769 New Member

    Joined:
    Feb 28, 2024
    Messages:
    3
    Likes Received:
    0
    I am curious, the link you provided for the code of the two DLL's doesn't actually contain the code for making the DLL's, just the DLL's themselves. Am I looking in the wrong spot for the sourcecode for these two DLL's?
     
  42. CobraOne

    CobraOne Active Member

    Joined:
    Jun 3, 2022
    Messages:
    254
    Likes Received:
    190
  43. jaapjan#1769

    jaapjan#1769 New Member

    Joined:
    Feb 28, 2024
    Messages:
    3
    Likes Received:
    0
  44. liam.mitchell2698

    liam.mitchell2698 New Member

    Joined:
    Feb 25, 2024
    Messages:
    2
    Likes Received:
    0
    Hi,

    When using the program in TSW 4 i keep getting “unable to create Raildriver” at the bottom left hand corner of the interface when i click start callback. Anyone any ideas as to what is happening and why i cant get it to connect?
     
  45. CobraOne

    CobraOne Active Member

    Joined:
    Jun 3, 2022
    Messages:
    254
    Likes Received:
    190
    Hi Liam
    The “unable to create Raildriver” error means my program cannot talk to TSW, can you try running my program as an Administrator and see if that fixes it for you.
    To do that, right click on the TSW Raildriver And Joystick Interface.exe and select Run as administrator.
    Chris
     
    • Helpful Helpful x 1
  46. liam.mitchell2698

    liam.mitchell2698 New Member

    Joined:
    Feb 25, 2024
    Messages:
    2
    Likes Received:
    0
    Hi Chris

    This fixed the issue! Thanks!

    Liam
     
  47. Hsing

    Hsing New Member

    Joined:
    Dec 3, 2023
    Messages:
    17
    Likes Received:
    3
    Hi Chris CobraOne ,

    I've previously asked you for some information on development of your program. Thanks a lot for providing those!

    I'm wondering if you are able to make a small addendum these days to the main program, doing the following:
    - making the RailDriver calibration settings available when joystick mappings are used instead of a real RD. That basically means, you can calibrate you imitated RD with the your physical joystick's levers.

    This would be helpful as it is in many flight sim games, which allows you to match the "important nodes" of your joystick's lever axis to those of aircraft's quadrant (e.g., AirBus' REV, IDLE, CLB, FLX/MCB & TO/GA). Some joysticks feature several notches/detents at these nodes and make your sim really immersive. If we can match these nodes with train's neutral, minimum break, EB, manual release of independent break, dynamic break setup, etc., we are doing something really amazing. (I think your Assign Notches does a very good job, but it's now limited by a linear correspondance to axis input. It may fail if a physical notch is far from its in-game position).

    I will try to do this myself if you, unfortunately, couldn't for any reason. B/c you keep your main exe's source private for security concern (makes sense of course), it may take me quite a while. I'm happy to try it anyhow.

    Let me know what you think and we appreciate your great work!

    - Hsing
     
  48. Hsing

    Hsing New Member

    Joined:
    Dec 3, 2023
    Messages:
    17
    Likes Received:
    3
    Just want let you know that I hvae hegun to look at Chris' code and work on it. If I'm right, he created a new dll that wraps the PIE's original one, with the same function prototypes but now being able to respond to any sharpDX joysticks. Though I got some problems while getting started, fortunately, I think I catched the idea of it now.

    I'm looking at how Chris reproduces the RD calibration functionality. I'm still not quite there to understand how it works without the source of main program's code, but I hope I can find it.

    I put this update here for the purpose that if Chris or anyone has comments/suggestions!

    - Hsing
     
  49. CobraOne

    CobraOne Active Member

    Joined:
    Jun 3, 2022
    Messages:
    254
    Likes Received:
    190
    Hi Hsing
    I have seen your last two posts and I am working on a solution to allow you to calibrate your joystick(s), but due to family circumstances, my spare time is very limited. As I see it, there are two options:
    1. Get the user to calibrate their Raildriver or Joystick in TSW and then use the calibration file created that is stored in
    Users\YOUR_USER_NAME\Documents\My Games\TrainSimWorld4\Saved\Config\WindowsNoEditor\Raildriver.ini.
    Advantage: - This would also negate the need to also calibrate the Raildriver in my program.
    Disadvantage: - Whenever a new version of TSW is released, you would have to either, recalibrate your controls in TSW or, remember to copy the Raildriver.ini file to the new game location in the My Games folder.

    2. Create new code in my program to allow the user to calibrate their joystick(s) and save the settings in a file stored in my program folder.
    Advantage: - You won't need to recalibrate your Raildriver or joystick(s) in my program once done for the first time.
    Disadvantage: - You will still have to recalibrate or move the Raildriver.ini when a new version of TSW is released. You will also need to check that the two calibrations files are in sync.

    I am working on code for both versions at the moment, but finding option 2 requires far more code so may still go for option 1 and try and automate the copying of the file when a new version is released. If DTG stick to the same folder layout as they have done since release, then it won't be a problem.

    I assume you are aware, that as I am emulating a Raildriver, the only calibration point are a shown here?

    Raildriver - full.png

    You are correct, the new PieHid64.dll uses the same functions as the original, but instead of only talking to the Raildriver, it now can talk to joysticks too. It does this using Named Pipes which is a way for two or more Processes on a PC to talk to each other using a piece of the PC's memory to exchange the data. The ReadWriteToPipe.dll is the other end of the Pipe which allows my program to talk to the PieHid64.dll. This means, all my main program has to do to control TSW is sent a 15 byte array
    upload_2024-3-10_11-20-54.png

    For more info, download and install the SDK from PI Engineering https://xkeys.com/software/developer/developerwindowssdk.html

    Not to scare you off your project but my program consists of 35 files with a total of 19,000 lines of code, the file that deals with the input from the Raildriver and joysticks is 2000 lines.

    I am willing to send you the 3 files I created to setup the Raildrivers and joysticks and calibrate the raildriver on the understanding that
    1. The files are not commented.
    2. You will be on your own in working out what they do, I don't have the time to try and explain the code.
    3. I wont be sharing any other code with you.

    If you (or anyone else who wishes to use it) agree to the above, then you can download the files from here
    https://www.dropbox.com/scl/fi/s118...tion.zip?rlkey=3n90k1b6z5csvy0ujvpotbi5g&dl=1

    Chris
     
    Last edited: Mar 10, 2024
    • Like Like x 1
  50. Hsing

    Hsing New Member

    Joined:
    Dec 3, 2023
    Messages:
    17
    Likes Received:
    3
    Pretty happy to see your reply.

    For calibration: after looking through the piehid64.cpp and readwritetopipe.cpp you shared, as well as the PIE's SDK, I think the calibration process is done by TSW game originally, whereas peihid64.dll only plays as an interface to the hardware. Due to this, the Option 1, for sure, shoud work well and re-calibrating the device as new TSW released makes sense to me. I agree that Option 2 requires more coding, so maybe just focusing on Option 1 at this moment is a good idea, as you said.

    For the source code you just shared: firstly a big thanks to you! Actually, I have gone through the NewDll and ReadWriteToPipe projects, and been very clear on the general idea and programing details of those part. The rest of dozens of code lines, are of course useful as a reference, but can be hard to follow as you mentioned. You made a easy-to-use GUI, automated input detecting, profile saving, and many other sophisticated functions, which I believe require bunch of coding.

    For me, I have looked at PIE's SDK, and planned to develop a new program using emulated piehid64.dll and Microsoft's latest GameInput API (a superset of DirectInput, XInput, etc.), as an alternative to out-of-maintained SharpDX (though I believe it still works well for our purpose). I do this primarily for fun and for a more customizable experience, and as a backup in case DTG made significant changes to how these currently work or lack of your maintenance on the project due to time reason or any other. Since I'm now a professioinal developer on Windows and I also get busy from time to time, I won't make a GUI or make it widely compatible and highly automated. Basically I might only keep it at a command-line level and only working for a certain set of devices I'll be using. Once I completed, I will share it through the forum, and if possible, I'll try to make it somehow "easy to adjust a little and use" or make a documentation for it. I'm still happy to see it can be helpful among the community. Let's look forward to it together! (no guarantee that I won't give up at a point XD)

    Thanks again for your support. It's yours and Drakoz's TARGET project that inspire me to start to do these. Both of you did a extraordinarily nice work and unfortunately to the players, couldn't make frequent updates to the projects now. Yet you are still responsive at the forum and kindly keeping providing support. I agree to your "terms", and will download them as a backup archive for possible reference.

    - Hsing
     

Share This Page