Sign in to follow this  
Sync Views

direct input

Recommended Posts

When useing the keyboard direct input fills an array of 256 unsigned chars. I know that the 8th bit of each element is if they key is pressed or not but what is direct input doing with the other 7bits? I looked around but everywhere just uses the last bit and ignors the rest...

Share this post


Link to post
Share on other sites
It may not be doing anything at all with the other 7 bits. An 8 bit unsigned char is the smallest primitive type you can work with in C or C++, which means for anything more granular you would have to use bitwise operations to extract the characters. Personally I don't think saving the extra 224 bytes would have been worth it.

On a side note, you really don't want to use DirectInput for keyboard input anyway.

Share this post


Link to post
Share on other sites
Ok how should I do it?


Also for the mouse ive got this so I can see if a button is currently pressed and if it was pressed/releashed since the last game step (at the end of each step [x][1] and [x][2] are set to false)

case WM_LBUTTONDOWN: mouse[0][0] = true; mouse[0][1] = true; break;
case WM_LBUTTONUP: mouse[0][0] = false; mouse[0][2] = true; break;

case WM_MBUTTONDOWN: mouse[1][0] = true; mouse[1][1] = true; break;
case WM_MBUTTONUP: mouse[1][0] = false; mouse[1][2] = true; break;

case WM_RBUTTONDOWN: mouse[2][0] = true; mouse[2][1] = true; break;
case WM_RBUTTONUP: mouse[2][0] = false; mouse[2][2] = true; break;


But how can I get the current x/y cords.

I searched ont the net but only found stuff for the buttons (above) everything else was with direct input...

Share this post


Link to post
Share on other sites
Quote:
Original post by Sync Views
Ok how should I do it?


Also for the mouse ive got this so I can see if a button is currently pressed and if it was pressed/releashed since the last game step (at the end of each step [x][1] and [x][2] are set to false)
*** Source Snippet Removed ***
But how can I get the current x/y cords.

I searched ont the net but only found stuff for the buttons (above) everything else was with direct input...
WM_MOUSEMOVE

Or GetCursorPos (But then you'll have to use ScreenToClient to convert that into client area coordinates)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this