Lfs Rev Limiter v0.1
====================
Its only a test program - the idea was cool but the outcome isn't...
What you need
=============
.Net framework 2.0 at least
Intall guide
============
1) LFS
- Open your cfg.txt file located in main LiveForSpeed folder
- Somwhere at the bottom you will find:
(...)
OutGauge Mode ?
OutGauge Delay ?
OutGauge IP ?.?.?.?
OutGauge Port ?
OutGauge ID ?
(...)
Where ? stands for a number
- Change it to:
OutGauge Mode 2
OutGauge Delay 5
OutGauge IP 127.0.0.1
OutGauge Port 11222
OutGauge ID 2
*Note that "Outgage Delay" has some impact on program response - experiment with it (values between 1 - 50 or more)
2)Files
- Copy "LfsRevLimiter.exe" and "LFS_External.dll" anywhere on your disk, but DO NOT SEPARATE THOSE FILES. LfsRevLimiter.exe uses LFS_External.dll to catch outgage packets and it must be in the same dir.
3)Start up lfs, then lfs revlimiter.
4)Change the trackbars value at the bottom of program to suit you - its the delay in ms between each "I" key press_and_depress cycle.
(cycle is: Press I, wait trackbar_value ms, depress I, wait 10ms, see if the cycle needs to be done again - for example revs have dropped under rev limit)
NOTES
=====
- Program works best if rev limiter is set quite high - close to real rev limiter.
BUGS
====
- lfsrevlimiter going out of sync with cars engine state
Its the main problem why I have gave up working on this program.
Problem is that there is no possibility to read if the cars engine is on or off. Assuming that its "on" while program starts, every time "I" is pressed, it changes engines ignition. Problem is that when key is pressed for shorter time then 17ms (at least on my computer) it sometimes isnt recognised by lfs, so it goes out of sync while emulating oldschool revlimiter - pressing "I" manually puts it back in sync again for short time.
Workaround? I could read if user is pressing gas pedal and asume that if revs are dropping that it has gone out of sync... but what if your in the middle of climbing a hill etc.
- nullpointer exception caused by lfs_external library... didn't have time to properly debug it, but turning lfs and lfsrevlimiter off and on again does the job
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
public static extern void mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
public static extern void keybd_event(byte bVk, byte bScan, int dwFlags, int dwExtraInfo);
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
public static extern byte VkKeyScan(char ch);
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true, CallingConvention = CallingConvention.Winapi)]
public static extern short GetKeyState(int keyCode);
public const int KEYEVENTF_EXTENDEDKEY = 0x01;
public const int KEYEVENTF_KEYUP = 0x02;
private byte BreakCode(char ch)
{
switch (Char.ToUpper(ch))
{
(...)
case 'I': return 0x97; break;
(...)
}
return 0x00;
}
private void KeyPress(char ch)
{
keybd_event(VkKeyScan(ch), BreakCode(ch), 0, 0);
keybd_event(VkKeyScan(ch), BreakCode(ch), KEYEVENTF_KEYUP, 0);
//backspace key to not interfere with chat
keybd_event(0x08, 0x8E, 0, 0);
keybd_event(0x08, 0x8E, KEYEVENTF_KEYUP, 0);
}
private void KeyDown(char ch)//keeps it in pressed state
{
keybd_event(VkKeyScan(ch), BreakCode(ch), 0, 0);
//backspace key to not interfere with chat
keybd_event(0x08, 0x8E, 0, 0);
keybd_event(0x08, 0x8E, KEYEVENTF_KEYUP, 0);
}
private void KeyUp(char ch)//cancel above
{
keybd_event(VkKeyScan(ch), BreakCode(ch), KEYEVENTF_KEYUP, 0);
}