Skip to content
View in the app

A better way to browse. Learn more.

The AVSIM Community

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

DirectInput initialization in gauges

Featured Replies

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

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

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

  • 3 years later...

>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.

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

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.

Lucky DirectInput is soo much easier than DirectSound.Got it all working now :)

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.