April 8, 200323 yr From the DX9 SDK, DInput Tut 1: Using the keyboard: [font color="blue"]//[/font] [font color="green"]HINSTANCE g_hinst;[/font] [font color="blue"]//[/font] [font color="green"]initialized earlier[/font][font color="black"]HRESULT hr; LPDIRECTINPUT8 g_lpDI; hr = DirectInput8Create(g_hinst, DIRECTINPUT_VERSION, IID_IDirectInput8, (void**)&g_lpDI, NULL); if FAILED(hr) { [/font] [font color="blue"]//[/font] [font color="green"]DirectInput not available; take appropriate action [/font][font color="black"]}[/font] How to adapt that very first initialization code for use in gauges? Why should I have initialized g_hinst earlier? I am always getting errors with DirectInput8Create.Etienne :-wave
April 8, 200323 yr This is from a DInput access to joystick made by me, more or less an unchanged example codeStoreInstanceHandle is just an "outsorced" g_hinst=(HINSTANCE)extra_data ReadJoystick is DIJOYSTATE joystick = UpdateInputState(fswnd); with extra stuff. void FSAPI gauge_cb( PGAUGEHDR pgauge, int service_id, UINT32 extra_data ){ static HWND fswnd=NULL; switch(service_id) { case PANEL_SERVICE_PRE_INSTALL : fswnd = FindWindow("FS98MAIN",NULL); StoreInstanceHandle((HINSTANCE)extra_data); InitDirectInput(fswnd); SetAcquire(fswnd); break;... case PANEL_SERVICE_PRE_UPDATE: ReadJoystick(fswnd); .. break;... case PANEL_SERVICE_PRE_KILL : FreeDirectInput(); break; }} The keybord acces can't be much different.Arne Bartels
April 8, 200323 yr Oh. So actually no CreateBlaBlaBla req'd at all?But "FS98MAIN"?? Is that up to date? :-)
April 9, 200323 yr InitDirectTinput is copied from the joystick sample and it contains a DirectInputCreate.FS98MAIN does work and would work from FS98 CFS FS2000 CFS2 to FS2002.Arne Bartels
March 28, 200719 yr >StoreInstanceHandle is just an "outsorced"> g_hinst=(HINSTANCE)extra_data Do not see anything like this in the current sample code. Also, not sure what the "extra data" is.... is this the handle of the gauge's window, vs. the FS window?>ReadJoystick is DIJOYSTATE>joystick = UpdateInputState(fswnd); This I understand. =)> >void FSAPI gauge_cb( PGAUGEHDR pgauge, int service_id, UINT32>extra_data )>{> static HWND fswnd=NULL;> switch(service_id)> {> case PANEL_SERVICE_PRE_INSTALL :> fswnd = FindWindow("FS98MAIN",NULL);> StoreInstanceHandle((HINSTANCE)extra_data);> InitDirectInput(fswnd);> SetAcquire(fswnd);> break;>...> case PANEL_SERVICE_PRE_UPDATE:> ReadJoystick(fswnd);> ..> break;>...> case PANEL_SERVICE_PRE_KILL :> FreeDirectInput();> break;> }>}Just wondering if this init and cleanup code can go in one gauge of a multi-gauge, or even in module_init / deinit.
March 28, 200719 yr Just wondering if this init and cleanup code can go in one gauge of a multi-gauge, or even in module_init / deinit.I like the module_init route; can't see why it wouldn't work. Problem with the PRE-INITIALIZE/PRE-KILL routine is that every time the user toggles a panel window or hits , DirectInput will be killed and restarted.Doug
March 28, 200719 yr Yes, exactly, which is why I do DirectSound stuff there... I have a feeling that Arne wrote this before FSX, and so it worked then.What a pain to have to take the two samples they give and integrate it to be able to do both keyboard and joystick.I just got done learning DirectSound so I could implement XACT, and I really don't feel like having to learn DirectInput too :(It seems I have no choice as I have to be able to push this button from the joystick, and have it stay down while the joystick button is pressed.If someone wants to trade working DirectInput keyboard and joystick stuff for working XACT stuff, I"m all ears :)XACT is very cool, as you can easily compose sounds into tracks and tracks into cues that are triggered by the game easily. You can loop, and trail sounds, and adjust volume and envelopes dynamically etc. Very cool stuff if you haven't looked at it.
Create an account or sign in to comment