Skip to main content
gamedev.net
🔒 Locked

Direct INput problems

Started by cxi2 8 replies 200+ views
Original Post
cxi2
cxi2
Man I have had so many problems with this... which mode ( exclusive/nonexclusive) should I be in to capture whether or not the user has pressed the enter key? I want the program to stop and wait until the user hits that buttom, how do I do that in direct INput??? to Code, or Not To Code
to Code, or Not To Code
furby100
furby100
In answer to your first question, either will work. In answer to your second question:
  
lpdikeyboard->GetDeviceState(....); // blah

while(!keys[VK_RETURN] & 0x80])
{
lpdikeyboard->GetDeviceState(....); // blah

}




Please state the nature of the debugging emergency.


sharewaregames.20m.com

cxi2
cxi2
MAYBE I should explain what i am doing...

in my main I have this:

InitDirectDraw();
InitDirectInput(hwnd);
Example();
WaitForKB();
MessageBox(hwnd, "You Pressed a key", "Event", 1);


My example shows a bitmap. the WaitForKB uses the code you gave me ( plus the variable declarations). I am basically thinking that if the messagebox shows, then the enter button was pressed.

I tried it like this:

while(!keyState[VK_RETURN] & 0x80)

and

while(keyState[VK_RETURN] & 0x80)

the message box came up both times when i was NOT touching the keyboard.... ACK what to do???




to Code, or Not To Code

Edited by - cxi2 on November 12, 2000 3:16:37 PM
to Code, or Not To Code
cxi2
cxi2
anyone know???

to Code, or Not To Code
to Code, or Not To Code
Doddler
Doddler
I had a problem similar to this just a few days ago. No matter what I did, it would still respond to the button being down, even if it wasnt. The solution I had was quite simple, really. Before you check the keyboard, or at some point in time, you have to call lpdiKeyboard->Acquire();. For me, I did this each time right before I checked the keyboard state with lpdiKeyboard->GetDeviceState(sizeof(diks),&diks); (I''m assuming this is DX7). Hopefully, this will work for you.

-Doddler
cxi2
cxi2
I think I am doing that, but it still doesnt enter the loop....



here is the code


void WaitForKB(void)
{

g_pKeyboard->Acquire();
unsigned char keystate[256];

g_pKeyboard->Acquire();
g_pKeyboard->GetDeviceState(256, &keystate); // blah

while(!keystate[DIK_RETURN] & 0x80 )
{
g_pKeyboard->Acquire();
g_pKeyboard->GetDeviceState(256, &keystate);
MessageBox(hwnd, "you have not pressed a button", "event", 1);
}

}

the message box here never comes up regardless of the keyboard

to Code, or Not To Code
to Code, or Not To Code
cxi2
cxi2
Are you supposed to use the windows procedure ( lresult callback wndProc(etc....)

with direct INput ???????????? I cant even get the GetAsyncKeyState(VK_LEFT) & 0x8000) to register a keypress.... Am I setting something up incorrectly???

to Code, or Not To Code
to Code, or Not To Code
cxi2
cxi2
I dont get it, is this some kind of impossible task??? It just doesnt work.. does anyone have a real working setup?????????? with CODE??

I am ripping my hair out. its enough to make one not want to make games >

to Code, or Not To Code
to Code, or Not To Code
cxi2
cxi2
Does any one have a small app that jsut runs in a loop until a person hits the enter key using direct input that they can show me the source code to?????

I am D E S P E R A T E please help

to Code, or Not To Code
to Code, or Not To Code
wazoo69
wazoo69
Stop the desperation!!

Seriously, just calm down and I HAVE done it (albeit in windows code)..my interpretation of the DirectInput stuff is like it''s a giant lookup table and/or state machine...it just sets itself according to the input given..

ALL you have to do in your main game loop is have a check for the key..you don''t need to lock your program into an infinite loop like you''ve done..

ie..main_loop is called during the idle times of the message queue (which I''ll post if you NEED it, but it''s everywhere)

TCHAR keystate[256];

main_loop() {

g_pKeyboard->Acquire();
g_pKeyboard->getDeviceState(sizeof(keystate), &keystate);

//if we hit escape then exit
if(g_pKeyboard->isHit(DIK_ESCAPE)){
PostMessage(g_hWnd, WM_CLOSE, 0, 0);
return(-1);
}

//otherwise do your code..
//display HUGE bitmap of Algore''s ego here

}

that should be enough to get the point..if you need further help, no problem I''ll help ya out (hopefully)

Famous Last Words #141: "Phew glad that''s over. I''ll take my armour off now."

Wazoo





Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.