The online racing simulator
Sending keypresses for keys bound to driving controls
I've been trying something for the past two days and I've exhausted every means I can think of, so maybe someone here has come across this as well.

Basically I want to selectively let my paddle shifters control up/down shift or control my insim app. Both LFS and my app capture the DirectInput device, but I have no way to tell LFS to not listen to the shifters when I don't want it to. My solution was to bind upshift/downshift to keys, let my app exclusively handle the paddle shifters and send key presses to LFS when I want them to mean upshift/downshift.

I figured, i'd use SCH packets to send the keypresses. But apparently no such luck.. While I can send keys for things like changing view, the key presses for controls don't seem to get processed. Don't know if it's a bug, or just not an intended use for SCH... So I tried the win32 API for sendkeys to the active app. Again nothing.

Googling around I thought i found the answer: LFS is using directinput, so it doesn't listen to external keypresses. Using some code I found at gamedev, i created a program that would inject key presses into DirectInput. Worked fine with the sample windows directinput app. But when I tried it with LFS, it never acquired the device to inject.

Anyone have any suggestions? Any pointers to code for creating a virtual device driver so i can pretend to be my own DirectInput device?

cheers,
sdether
#2 - bal00
Quote from sdether :Basically I want to selectively let my paddle shifters control up/down shift or control my insim app. Both LFS and my app capture the DirectInput device, but I have no way to tell LFS to not listen to the shifters when I don't want it to. My solution was to bind upshift/downshift to keys, let my app exclusively handle the paddle shifters and send key presses to LFS when I want them to mean upshift/downshift.

I'm actually using AutoHotkey (www.autohotkey.com) to do that (selectively send key presses to LFS when using the joystick buttons). Unfortunately I'm not sure which method AHK uses to send the key presses. It's free, so if you don't have a problem with running an extra executable (you can convert the scripts into standalone exes), you could let AHK handle the button presses and selectively send them to either your Insim app or LFS.

Or you could check out PPJoy (http://www.geocities.com/deonvdw/Docs/PPJoyIntro.htm). It's a virtual joystick driver than can take inputs from other apps.
You can do it by sending WM_KEYDOWN and WM_KEYUP messages to the LFS window.
Quote from Kegetys :You can do it by sending WM_KEYDOWN and WM_KEYUP messages to the LFS window.

Thanks. I'll give that a try. I figured SendKeys was doing that behind the scenes, but I'll try WM_KEYDOWN & WM_KEYUP explicitly through P/Invoke.
Quote from bal00 :Or you could check out PPJoy (http://www.geocities.com/deonvdw/Docs/PPJoyIntro.htm). It's a virtual joystick driver than can take inputs from other apps.

I looked at that briefly yesterday. Since it was talking about emulating a gameport device, i didn't know if it would be a valid device for DirectInput, so i put that approach on the back-burner
Quote from Kegetys :You can do it by sending WM_KEYDOWN and WM_KEYUP messages to the LFS window.

Well, that's what I get for assuming that the native function uses the p/invoke behind the scenes and writing off that solution without trying. Switched my code to using SendMessage with WM_KEYDOWN and WM_KEYUP and that works like a charm. Thanks again!
Do you need the source code how to bind a gaming device with direct input and use it ? i will give you my source code of JBindX and you can extend the keybind function to control more than one key. this app was only made for push to talk in comm apps
Quote from JogDive :Do you need the source code how to bind a gaming device with direct input and use it ? i will give you my source code of JBindX and you can extend the keybind function to control more than one key. this app was only made for push to talk in comm apps

Unfortunately i'm doing the opposite. I can easily consume any directinput device. However what would be nice if I could write an App that shows up to Windows as a Human Interface Device inside of the Game Controllers control panel and pretends to be a joystick, so i can proxy a real joystick through my app and then have other apps consume my proxy joystick, allowing me to un/re-map controls on the fly.

The SendMessage approach does the trick for now, but it means i can't use any axis for my UI.

FGED GREDG RDFGDR GSFDG