Thread View: borland.public.cppbuilder.multimedia
2 messages
2 total messages
Started by Michele Santucci
Tue, 28 Jun 2005 08:47
DInput
Author: 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
===================
Re: DInput
Author: DILIP K
Date: Fri, 04 Nov 2005 19:18
Date: Fri, 04 Nov 2005 19:18
12 lines
1724 bytes
1724 bytes
hello michelle,
b4 beginning let me say i am not used to writing directx files..
still from the code let me give a suggestion.
once that pressing take place try to break/stop the code.
'believe one press is much much very much slower compared to cpu proceesing speed.a single press from user ,however fast, is enough to complete the increment/decrement beyond the max. limit.
so each press should be detected single by single..and for that u have to break inbetween that is for each increment/decrement/jump statements , hav 2 use some sort of toggle variables to stop further changes unless another press is given withth peripheral device.
now u might have got some way....if i am wrong with my approach i appologize.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads