For those of you whom refuse to use Direct Input for some reason or another, simple system like the one I'm using will probably suit your needs.
Important variables
Code:
typedef enum KEY_STATE { KS_UP, KS_DOWN, KS_IGNORE };
typedef struct {
KEY_STATE state;
long time;
} sKey;
typedef struct {
int x,y; // position
int wheelDelta; // wheel change
int prevx, prevy, prevdelta;
int button;
} sMouse;
sKey keys[256];
sMouse mouse;
using variables
Code:
case WM_KEYDOWN:
{
keys[wParam].state = KS_DOWN; // key is in down state
keys[wParam].time = GetTickCount(); // keypress happend when?
return 0;
}
case WM_KEYUP: // Has A Key Been Released?
{
keys[wParam].state = KS_UP; // key is in up state
keys[wParam].time = GetTickCount(); // keyup happend when?
return 0;
}
case WM_SIZE: // Resize The OpenGL Window
{
g_winWidth = LOWORD(lParam);
g_winHeight = HIWORD(lParam);
ReSizeGLScene(LOWORD(lParam),HIWORD(lParam)); // LoWord=Width, HiWord=Height
return 0; // Jump Back
}
case WM_LBUTTONDOWN:
case WM_LBUTTONUP:
case WM_RBUTTONDOWN:
case WM_RBUTTONUP:
case WM_MBUTTONDOWN:
case WM_MBUTTONUP:
case WM_MOUSEMOVE:
{
/*
MK_CONTROL
The CTRL key is down.
MK_LBUTTON
The left mouse button is down.
MK_MBUTTON
The middle mouse button is down.
MK_RBUTTON
The right mouse button is down.
MK_SHIFT
The SHIFT key is down.
*/
mouse.prevx = mouse.x;
mouse.prevy = mouse.y;
mouse.x = GET_X_LPARAM(lParam);
mouse.y = GET_Y_LPARAM(lParam);
mouse.button = wParam;
return 0;
}
case WM_MOUSEWHEEL:
{
mouse.wheelDelta = HIWORD( wParam ); // wheel rotation
//xPos = LOWORD(lParam); // horizontal position of pointer
//yPos = HIWORD(lParam); // vertical position of pointer
return 0;
}
With those variables, you can impliment a lot of functionality. The skys the limmit.