Page 6 of 29
Re: TrainSim Helper (Joystick/Overlay) release thread
Posted: Sat Oct 11, 2014 11:04 am
by Havner
LionelMarco wrote:But ( as there's always a but...) I'm using a French keyboard (Azerty), and the overlay seems linked to a Qwerty one. So the control are "wrongly" placed (an easy one: Decrease speed-Q- is A on my keyboard and so on). In the end, it's quite dificult to translate the command in my head... Is there's a way to adapt your script to "different" keyboards?
Sorry, I'm not sure I follow. The script is not related to the keyboard shortcuts in any way. That's the game itself. By default it uses A/D for throttle/regulator and this will be the case whenever you use my helper or not.
I take it you used the default HUD before, not the shortcuts?
There is a way to change the shortcuts, but it's not the easiest. You'd have to change them for almost every loco one by one:
http://forums.uktrainsim.com/viewtopic. ... 1&t=139086
PS: If you still need a few bin file from steam locomotive or class 101 , I can send you a few ones.
Thanks, I think I'm good for now

I'll contact you if I need more.
davep wrote:My apologies Havner. It seems I missed YOUR post

Sure, get in touch with me when I release 0.3. I'll tell you what you need to do to achieve what you want.
Re: TrainSim Helper (Joystick/Overlay) release thread
Posted: Sat Oct 11, 2014 2:15 pm
by CobraOne
LionelMarco wrote:Hi!
Same problem with the Xbox360 controller which is completely off too: trying to add break in fact open the throttle. May it be related to the keyboard problem?
Lionel Marco.
If you look in the 'trainsim-helper-joystick.lua' file which should be in your plugins folder, at the top there is the section
-- To disable an invert set it to 0 or comment out
ReverserInvert = 1
CombinedThrottleInvert = 1
ThrottleInvert = 1
--TrainBrakeInvert = 1
--LocoBrakeInvert = 1
--DynamicBrakeInvert = 1
AFBInvert = 1
If I understand you correctly then try setting
CombinedThrottleInvert = 0
ThrottleInvert = 0
see if that helps.
Chris
Re: TrainSim Helper (Joystick/Overlay) release thread
Posted: Sat Oct 11, 2014 2:37 pm
by Havner
CobraOne wrote:LionelMarco wrote:Hi!
Same problem with the Xbox360 controller which is completely off too: trying to add break in fact open the throttle. May it be related to the keyboard problem?
Lionel Marco.
If you look in the 'trainsim-helper-joystick.lua' file which should be in your plugins folder, at the top there is the section
Nope, this won't help you. XBox360 controller is not DirectInput compatible. It's XInput. You can't use it with my helper.
Besides:
- The game grabs it anyway
- It doesn't have any "persistent" axes, like axes that keep their value
So it would be useless anyway.
All the assignments to the XBox360 controller are done directly by Train Simulator and they don't appear to be configurable, even by editing files.
Re: TrainSim Helper (Joystick/Overlay) release thread
Posted: Sat Oct 11, 2014 2:40 pm
by Havner
Version 0.3 released
http://vega.livecd.pl/~havner/trainsim-helper/
Code: Select all
0.3
- WARNING: the script has been split into 3 files, you need all
- Overlay configuration is in the trainsim-helper-overlay.lua
- Joystick configuration is in the trainsim-helper-joystick.lua
- Detections for locos are in the trainsim-helper.lua
- WARNING: ALL ControlRanges are detected before Locos detections
- This allows for less code in the detection routines
- GearControl axis added (Gear Lever)
- Gear in the Overlay moved to the controls group (blue)
- WARNING: Because of this shortcuts got shifted by 1 (F1-F9, F11-F12)
- Vacuum Pipe added to the Overlay (red), Vacuum Chamber ignored (seems irrelevant)
- Moved the clock to align better with long scenario names and F5 UI
- Overlay GradientUK format option (1:XXX) (mostly autodetected for UK)
- Fixed gigantic speed limits for SpeedLimitType == 3 (now it's '??')
- Add units to acceleration, recalculate from m/s^2 (Kph/m, Mph/m)
- Moved most of the calculations to C++ for performance and greater control
- Readme updated (TOC and section on how to receive help)
- Detections and notches configurations for more locos
- Source code from now is on github:
- https://github.com/Havner/trainsim-helper
Re: TrainSim Helper (Joystick/Overlay) release thread
Posted: Sat Oct 11, 2014 3:11 pm
by Havner
CobraOne wrote:@Havner Have a look at the program and if you feel it may help others then maybe consider including it in your next update too.
I had a quick look at few locos with notches and nice work. Definitely useful.
You want me to link it somewhere? Or include the complete binary?
One thing that might be nice to handle is a case where the game is using equal notches. Like throttle in most of the US locos.
Code: Select all
<ControlName d:type="cDeltaString">Regulator</ControlName>
(...)
<NumberOfNotches d:type="sFloat32" d:alt_encoding="0000000000002240" d:precision="string">9</NumberOfNotches>
BTW, how's your work on the remapper?
Re: TrainSim Helper (Joystick/Overlay) release thread
Posted: Sat Oct 11, 2014 7:26 pm
by CobraOne
Havner wrote:
I had a quick look at few locos with notches and nice work. Definitely useful.
You want me to link it somewhere? Or include the complete binary??
It would probably be easier for you to include the complete binary, it's free to be used by anyone so no licence worries.
Havner wrote:One thing that might be nice to handle is a case where the game is using equal notches. Like throttle in most of the US locos.
Code: Select all
<ControlName d:type="cDeltaString">Regulator</ControlName>
(...)
<NumberOfNotches d:type="sFloat32" d:alt_encoding="0000000000002240" d:precision="string">9</NumberOfNotches>
Done and new files uploaded
https://www.dropbox.com/sh/svyifuyxtice ... Un8Ia?dl=0
Havner wrote: BTW, how's your work on the remapper?
I managed to find the problem with getting the class 365 working. I had used
Code: Select all
if OnControlValueChange then
OnControlValueChange(t[1], 0, t[2])
else
Call( "*:SetControlValue", t[1], 0, t[2])
end
Instead of
Code: Select all
if OnControlValueChange then
OnControlValueChange(t[1], 0, tonumber(t[2]))
else
Call( "*:SetControlValue", t[1], 0, tonumber(t[2]))
end
Took me a while to find it. I am also now working on adding something similar to your overlay as I am sure people who wish to use the Raildriver, will, on seeing your overlay, want one too! but rather than incorporate your helper_script into mine and maybe cause confusion I thought I should keep it separate.
Chris
Re: TrainSim Helper (Joystick/Overlay) release thread
Posted: Sat Oct 11, 2014 7:38 pm
by Havner
Thank you
I managed to find the problem with getting the class 365 working. I had used
Yeah, what I would give for a working lua debugger within the TrainSimulator after having written so much code...
I am also now working on adding something similar to your overlay as I am sure people who wish to use the Raildriver, will, on seeing your overlay, want one too! but rather than incorporate your helper_script into mine and maybe cause confusion I thought I should keep it separate.
As you prefer
BTW, how does Raildriver work? Can it be used as is with my helper at all? I mean, does windows see it as a regular joystick or not?
I know they have some SDK, so in theory one could make it work as he wishes. But out of the box, is it of any use in things not specifically written for it?
EDIT: oh, and by the remapper I meant your tool to change keyboard shortcuts, not the RailDriver stuff. You've posted a screenshot of it in the other thread. I thought those were separate.
Re: TrainSim Helper (Joystick/Overlay) release thread
Posted: Sat Oct 11, 2014 10:48 pm
by CobraOne
Havner wrote:
BTW, how does Raildriver work? Can it be used as is with my helper at all? I mean, does windows see it as a regular joystick or not?
I know they have some SDK, so in theory one could make it work as he wishes. But out of the box, is it of any use in things not specifically written for it?
EDIT: oh, and by the remapper I meant your tool to change keyboard shortcuts, not the RailDriver stuff. You've posted a screenshot of it in the other thread. I thought those were separate.
The Raildriver does not show up in windows as a joystick, just a usb hid device. I am using PIEHidDotNet.dll as supplied in the SDK to read the controller. The remapper is part of the software I have written for the raildriver, so not a separate entity yet. I was looking to convert my software to be used with a joystick but as you have done such a great job, I will probably shelve that idea and start playing trains again.
Re: TrainSim Helper (Joystick/Overlay) release thread
Posted: Sun Oct 12, 2014 4:38 pm
by Havner
Introducing distance indicator
Havner had an idea. And as usual implemented it faster then he managed to think it through.
We don't have a distance to target. Checked. But we do have time and speed. This gives us something. So I implemented a distance passed. It's not taken from the game, it's calculated using the momentary speed and momentary time I have inside the C++ code. It's not 100% precise but it's precise enough.
We start at a station. We see next distance to destination (F1/F3/F4) view. Look down, there is a new Distance meter in the overlay:
http://vega.livecd.pl/~havner/trainsim- ... ance-1.jpg
It's 0, but as I move it starts to accumulate. After 3+ miles we can see it's still in a good shape (this will vary, on how often you change speeds and by how much, I did a 10+ miles run with speed changes as the signs told me and got it precise up to 0.01 mile):
http://vega.livecd.pl/~havner/trainsim- ... ance-2.jpg
We reached our destination and we're right on the spot with the distance telling us 7.00 miles:
http://vega.livecd.pl/~havner/trainsim- ... ance-3.jpg
We can now either reset the distance with a shortcut:
http://vega.livecd.pl/~havner/trainsim- ... ance-4.jpg
OR,

put the distance manually (with shortcuts) and switch it to the countdown mode, see in the middle of the screen where I put the distance:
http://vega.livecd.pl/~havner/trainsim- ... ance-5.jpg
Now it's being set the overlay switched to the countdown mode (again, lower left of the screen):
http://vega.livecd.pl/~havner/trainsim- ... ance-6.jpg
And off we go! As we travel it decreases:
http://vega.livecd.pl/~havner/trainsim- ... ance-7.jpg
When we are below 1 mile it goes yellow:
http://vega.livecd.pl/~havner/trainsim- ... ance-8.jpg
And if we passed the target it goes red:
http://vega.livecd.pl/~havner/trainsim- ... ance-9.jpg
The last screenshot is cheated a little (the number should've been higher, but the red didn't work initially and I had to fix and restart the helper).
Not ideal, but I'd say pretty damn usable. We usually have enough time at the train stop to look at the F1, see our next stop, see its arrival time AND set the distance. Now (At least for me) there is nothing I need from the F1 view during the travel between the stations
I'll try to release ASAP, but it might take few days. I spent too much time this weekend coding instead of driving and I need to refine this a little as well.
Re: TrainSim Helper (Joystick/Overlay) release thread
Posted: Sun Oct 12, 2014 7:05 pm
by CobraOne
Havner your a Genius, can't wait to see the code and if it's OK incorporate the idea into my version.

Re: TrainSim Helper (Joystick/Overlay) release thread
Posted: Sun Oct 12, 2014 8:19 pm
by Havner
CobraOne wrote:Havner your a Genius, can't wait to see the code and if it's OK incorporate the idea into my version.

Thank you, I must say I'm pretty proud of it

such a simple thing and I seriously could've thought about it sooner. And it helps tremendously. I'm just driving with it happy like a child I don't have to glance at the F1.
Of course It's OK, do whatever you wish with it.
The code is actually pretty simple. We have a current speed and simulation time (both from LUA). Every cycle (I do around 120/s in my main loop) I do something like:
Code: Select all
DeltaTime = CurrentSimTime - PreviousSimTime
DeltaDistance = CurrentSpeed * DeltaTime
AccumulatedDistance += DeltaDistance
PreviousSimTime = CurrentSimTime
Of course there is a lot of code around it for the Countdown, to set it, to handle shortcuts, display (whether it's Distance or Countdown) but that's pretty much it in terms of Distance calculations.
EDIT: oh, and do calculations on doubles. To increase precision. I also removed the numbers formatting for Speed and SimulationTime from the LUA getter to get as precise numbers as possible.
Re: TrainSim Helper (Joystick/Overlay) release thread
Posted: Sun Oct 12, 2014 9:21 pm
by Natvander
So in essence you've created an odometer? That is cool

. If it can be reset at any time, and you know the length of your train you could use it when passing speed limit boards etc. Especially useful for multi-km long US intermodals.
Re: TrainSim Helper (Joystick/Overlay) release thread
Posted: Sun Oct 12, 2014 9:25 pm
by Havner
Natvander wrote:So in essence you've created an odometer? That is cool

. If it can be reset at any time, and you know the length of your train you could use it when passing speed limit boards etc. Especially useful for multi-km long US intermodals.
Yes sir. You can reset it at any time. And you can use it as you wish. Even as a remainder to take a leak in 5 miles

I didn't think about using in that way but it's definitely possible.
It can count up and down (from a set value).
Re: TrainSim Helper (Joystick/Overlay) release thread
Posted: Mon Oct 13, 2014 5:08 pm
by Havner
I've pushed the latest code changes to the github. I might not have a lot of time this weekend so no promises for the release. If you feel like you can compile that yourself for now.
0.3 seems to be stable with no major bugs (there are some with the patcher but ONLY for custom installations outside of steam, fixes in github as well).
EDIT: CobraOne, I've used you data extractor in live cases to prepare more locos. Makes things much easier. Nice work, thanks again. I'd just remove the "**" in output file to see the subsections more easily.
Also I've found a curious case.
FP59PH. It has regulator (0,1) with 17 equal notches and dynamic brake (0,1) with 19 equal notches. But in the game they are combined. And the resulting notches are combined as well. 10 (half) notches for (0, 0.5) and 9 (half) notches for (0.5,1). Making them unequal for the whole range.
Re: TrainSim Helper (Joystick/Overlay) release thread
Posted: Mon Oct 13, 2014 8:20 pm
by CobraOne
Havner wrote:
EDIT: CobraOne, I've used you data extractor in live cases to prepare more locos. Makes things much easier. Nice work, thanks again. I'd just remove the "**" in output file to see the subsections more easily.
"**" removed and re uploaded
Havner wrote:
Also I've found a curious case.
FP59PH. It has regulator (0,1) with 17 equal notches and dynamic brake (0,1) with 19 equal notches. But in the game they are combined. And the resulting notches are combined as well. 10 (half) notches for (0, 0.5) and 9 (half) notches for (0.5,1). Making them unequal for the whole range.
I'm not surprised, not much in the engine files has remained consistent throughout Train Simulators life.
