Article View: borland.public.cppbuilder.multimedia
Article #63DInput
From: Michele Santucci
Date: Tue, 28 Jun 2005 08:47
Date: Tue, 28 Jun 2005 08:47
78 lines
3193 bytes
3193 bytes
Hello NG,
I have some problem using DInput... I wrote this code following the example
from
Directx 9 SDK (December 2004/April 2005).
The problem is how to check the button status i.e. in this piece of code:
for( int i = 0; i < LAST_BTN; i++ )
{
if( js.rgbButtons[GEARUP_BTN] & 0x80 )
Gear++;
else if( js.rgbButtons[GEARDOWN_BTN] & 0x80 )
Gear--;
else if( js.rgbButtons[CHANGECAMERA_BTN] & 0x80 )
SWITCH_CAMERA( Camera );
else if( js.rgbButtons[ARM_BTN] & 0x80 )
SWITCH_ARM( ArmStatus );
}
after the first time I push one of the checked buttons the if statement is
executed correctly
but after that each other check of the same button returns true even if the
button have been
released. Why? How can I fix this?
// Full code
HRESULT TfrmJoyState::UpdateInputState()
{
HRESULT hr;
DIJOYSTATE2 js;
if( NULL == g_pJoystick )
return S_OK;
hr = g_pJoystick->Poll();
if( FAILED(hr) )
{
hr = g_pJoystick->Acquire();
while( hr == DIERR_INPUTLOST )
hr = g_pJoystick->Acquire();
return S_OK;
}
if( FAILED( hr = g_pJoystick->GetDeviceState( sizeof(DIJOYSTATE),
&js ) ) )
return hr;
FSteering = js.lX;
FTrust = js.lY;
for( int i = 0; i < LAST_BTN; i++ )
{
if( js.rgbButtons[GEARUP_BTN] & 0x80 )
Gear++;
else if( js.rgbButtons[GEARDOWN_BTN] & 0x80 )
Gear--;
else if( js.rgbButtons[CHANGECAMERA_BTN] & 0x80 )
SWITCH_CAMERA( Camera );
else if( js.rgbButtons[ARM_BTN] & 0x80 )
SWITCH_ARM( ArmStatus );
}
return S_OK;
}
--
Michele Santucci
===================
Celin Avio S.r.l.
Software Dev. Manager
--------------------------------------
tel. +390187564080
Via Fontevivo 21/M
19126 La Spezia
===================
Technical Details
Message-ID:
<42c10e97$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!news.moat.net!news-out.newsfeeds.com!propagator3-LAX.newsfeeds.com!news-in.spamkiller.net!news-in.superfeed.net!caladan.landsraad.net!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 10d0fc,a9f3a3aab4933a6c,start X-Google-Attributes: gid10d0fc,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Michele Santucci" <michele.santucci@celinavio.it> Newsgroups: borland.public.cppbuilder.multimedia Subject: DInput Date: Tue, 28 Jun 2005 10:47:22 +0200 Lines: 80 Organization: Celin Avio S.r.l. X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2527 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527 X-RFC2646: Format=Flowed; Original NNTP-Posting-Host: 80.86.50.144 Message-ID: <42c10e97$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1119948439 80.86.50.144 (28 Jun 2005 01:47:19 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!news.moat.net!news-out.newsfeeds.com!propagator3-LAX.newsfeeds.com!news-in.spamkiller.net!news-in.superfeed.net!caladan.landsraad.net!newsgroups.borland.com!not-for-mail