• 12
• 27
• 9
• 20
• 33

# DInput, XInput & WM_CHAR

This topic is 2616 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi all,

I can mix DInput & WM_CHAR and XInput?
In fact, i want to use dinput for managing mouse and joystick (with xinput), but keyboard in dinput isn't a great idea because you have to translate the scancode to ascii...
Someone have some suggestions?

##### Share on other sites
You shouldn't use DInput for either mouse or keyboard. Just use Raw Input http://msdn.microsoft.com/en-us/library/ms645543(v=vs.85).aspx

##### Share on other sites

Hi all,

I can mix DInput & WM_CHAR and XInput?
In fact, i want to use dinput for managing mouse and joystick (with xinput), but keyboard in dinput isn't a great idea because you have to translate the scancode to ascii...
Someone have some suggestions?

I don't know about XInput, but you can mix DirectInput and WM_CHAR, at least as long as your cooperative level isn't set to exclusive (I think).

In your main windows message procedure, just add a case for WM_CHAR. wParam will equal whatever key was pressed. Its pretty simple really, if you want to see if SHIFT + F was pressed you just check:
if (wParam == 'F') //switch to fullscreen or whatever

I don't know how you're using DInput for keyboard input, but in my programs I just use the DIK_* defines to check for keydowns. Checking for SHIFT + F might look like this:
 if ((keys[DIK_LSHIFT] & 0x80) && (keys[DIK_F] & 0x80)) //do whatever 

Hope that helps.