Start re-organizing demos so the physics setup can be shared easier (explicit create graphics objects, init/exit physics etc)

Add B3G_RETURN key code, only implemented in Windows so far (todo: Mac, Linux)
Fix Windows key management (use WM_CHAR event instead of WM_KEYUP
Add Return (OnKeyReturn) key support TreeNode, so we can select an item using the return key.
This commit is contained in:
Erwin Coumans
2014-06-24 10:14:06 -07:00
parent 28f19f1bab
commit 68f798a2da
29 changed files with 746 additions and 655 deletions

View File

@@ -55,8 +55,21 @@ void Win32Window::pumpMessage()
int getAsciiCodeFromVirtualKeycode(int virtualKeyCode)
{
int keycode = 0xffffffff;
if (virtualKeyCode >= '0' && virtualKeyCode <= '9')
{
return virtualKeyCode;
}
if (virtualKeyCode >= 'a' && virtualKeyCode <= 'z')
{
return virtualKeyCode;
}
if (virtualKeyCode >= 'A' && virtualKeyCode <= 'Z')
{
return virtualKeyCode;
}
switch (virtualKeyCode)
{
case VK_RETURN: {keycode = B3G_RETURN; break; };
case VK_F1: {keycode = B3G_F1; break;}
case VK_F2: {keycode = B3G_F2; break;}
case VK_F3: {keycode = B3G_F3; break;}
@@ -126,7 +139,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
case WM_SYSKEYUP:
case WM_KEYUP:
{
{
int keycode = getAsciiCodeFromVirtualKeycode(wParam);
@@ -140,12 +153,15 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
}
case WM_CHAR:
{
int keycode = wParam;
if (sData && sData->m_keyboardCallback && ((HIWORD(lParam) & KF_REPEAT) == 0))
//skip 'enter' key, it is processed in WM_KEYUP/WM_KEYDOWN
int keycode = getAsciiCodeFromVirtualKeycode(wParam);
if (keycode < 0)
{
int state = 1;
(*sData->m_keyboardCallback)(keycode,state);
if (sData && sData->m_keyboardCallback && ((HIWORD(lParam) & KF_REPEAT) == 0))
{
int state = 1;
(*sData->m_keyboardCallback)(wParam, state);
}
}
return 0;
}
@@ -322,6 +338,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
break;
default:{
}
};