Well I get my keystrokes via the WM_KEYDOWN and WM_KEYUP messages. Inside my application framework is this MsgProc function.
- Code:
LRESULT TApplication::MsgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg)
{
case WM_KEYDOWN:
//
// disable repeating keypresses
if (!(lParam & 0x40000000))
{
ButtonDown(wParam);
}
return 0;
case WM_KEYUP:
ButtonUp(wParam);
return 0;
}
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
And then inside my ButtonDown/Up calls you can do this:
- Code:
void TApp::ButtonDown(int nButton)
{
if (nButton == VK_TUP)
{
// button up code
}
if (nButton == VK_TDOWN)
{
// button down
}
if (nButton == VK_TRIGHT)
{
}
if (nButton == VK_TLEFT)
{
}
if (nButton == VK_SOFT1)
{
// left soft key usually
}
if (nButton == VK_ACTION)
{
// middle action/thumb button
}
}
That seems to work well on the many many phones I've tried. The VK_ defines are defined in wmuser.h if I recall correctly. Best bet is to move your cursor over VK_ACTION and hit F12 (if your running Visual Studio) and that will bring up the defines. There are defines there for the CALL and END button and a bunch of others.