The online racing simulator
#1 - PoVo
.NET C# - Send key input into LFS
Hello,

I'm currently writing a little joystick-to-shifter program for LFS.

I got it to read X, Y values from the joystick using DirectInput and determine the gear.

I'm trying to use SendKeys.SendWait() to send a key to LFS for use with the gears.

For example:
Process proc = Process.GetProcessesByName("LFS")[0];
SetForegroundWindow(proc.MainWindowHandle);
SendKeys.SendWait("5");

My issue is that it doesn't seem to work when mapping the shifter buttons in LFS, however it DOES work when I press "T" in LFS to enter text it the chat because I see a "5" being written into the box.

What would be the best way to get around this and make LFS treat the keys from my program as keyboard keys?

Another idea would be to override the physical controller keys and emulate them being pressed whenever I need them to be (if that's even possible).

Any tips or ideas?

Cheers.

EDIT: Figured it out myself. I needed to import the native function:
Quote :[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
public static extern void keybd_event(byte bVk, byte bScan, int dwFlags, int dwExtraInfo);


FGED GREDG RDFGDR GSFDG