#### Archived

This topic is now archived and is closed to further replies.

# Jim's Book. Core Input Problem.

## Recommended Posts

Dear Jim, I am trying to integrate your core input code with my own network code and it seems that creating a non-modal dialog box will prevent the core input from detecting key presses. For example, the following code in Winmain() doesn''t work:
	// Display the LoginDialog

// Initialize input and input devices
m_Input.Init(hWnd_Application, hInst);
m_Keyboard.Create(&m_Input, KEYBOARD);

// Start the Windows Message Loop
while(msg.message != WM_QUIT)
{
if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}

// Get local input every frame
m_Keyboard.Acquire(TRUE);

if(m_Keyboard.GetKeyState(KEY_A) == TRUE)
{
MessageBox(NULL, "test", "test", MB_OK);
}
}

However, if I just remove:
// Display the LoginDialog


...it will work perfectly fine. And if I put the core input initialization code before the creation of the login dialog:
// Initialize input and input devices
m_Input.Init(hWnd_Application, hInst);
m_Keyboard.Create(&m_Input, KEYBOARD);


...it will act weird and keep detecting the keypress although I am not pressing any keys. I am pretty sure it is the creation of the non-modal dialog that is causing the error but is there a way around it if I simply must create that non-modal dialog? Thank you ^_^. _________________ Best regards, Sherman Chin www.Sherman3D.com

##### Share on other sites
Ok, it is fixed - apparently I need to change the DirectInput
cooperative level flag in core_input.cpp to DISCL_BACKGROUND.
Now, another problem crops up - DirectInput detects everything
except the arrow keys.

So, for the time being, I have to compromise with the numpad
arrow keys:

MoveAction |= 1;
MoveAction |= 4;
MoveAction |= 16;
MoveAction |= 32;

Anybody knows how I can rectify this problem and get DirectInput
to detect the arrow keys again?

Thanks ^_^

_________________
Best regards,
Sherman Chin
www.Sherman3D.com

##### Share on other sites
isn''t it DIK_UP, DIK_DOWN, DIK_LEFT, DIK_RIGHT?

##### Share on other sites
AP - those are just macros that redefine to DIK_*.

Sherman: I haven''t really tried mixing dialog boxes in that way, but Windows is probably removing all system and related keys (arrows, ALT, etc). You might want to try reading the keyboard before Get/PeekMessage or inside the WM_KEYDOWN function of the dialog box procedure.

• ### Forum Statistics

• Total Topics
628395
• Total Posts
2982436

• 10
• 9
• 19
• 24
• 10