Commit 79f9c623 authored by chili's avatar chili
Browse files

imgui input capture/stifle

parent dbee5401
...@@ -183,6 +183,7 @@ LRESULT Window::HandleMsg( HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam ) noex ...@@ -183,6 +183,7 @@ LRESULT Window::HandleMsg( HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam ) noex
{ {
return true; return true;
} }
const auto imio = ImGui::GetIO();
switch( msg ) switch( msg )
{ {
...@@ -200,6 +201,11 @@ LRESULT Window::HandleMsg( HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam ) noex ...@@ -200,6 +201,11 @@ LRESULT Window::HandleMsg( HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam ) noex
case WM_KEYDOWN: case WM_KEYDOWN:
// syskey commands need to be handled to track ALT key (VK_MENU) and F10 // syskey commands need to be handled to track ALT key (VK_MENU) and F10
case WM_SYSKEYDOWN: case WM_SYSKEYDOWN:
// stifle this keyboard message if imgui wants to capture
if( imio.WantCaptureKeyboard )
{
break;
}
if( !(lParam & 0x40000000) || kbd.AutorepeatIsEnabled() ) // filter autorepeat if( !(lParam & 0x40000000) || kbd.AutorepeatIsEnabled() ) // filter autorepeat
{ {
kbd.OnKeyPressed( static_cast<unsigned char>(wParam) ); kbd.OnKeyPressed( static_cast<unsigned char>(wParam) );
...@@ -207,9 +213,19 @@ LRESULT Window::HandleMsg( HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam ) noex ...@@ -207,9 +213,19 @@ LRESULT Window::HandleMsg( HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam ) noex
break; break;
case WM_KEYUP: case WM_KEYUP:
case WM_SYSKEYUP: case WM_SYSKEYUP:
// stifle this keyboard message if imgui wants to capture
if( imio.WantCaptureKeyboard )
{
break;
}
kbd.OnKeyReleased( static_cast<unsigned char>(wParam) ); kbd.OnKeyReleased( static_cast<unsigned char>(wParam) );
break; break;
case WM_CHAR: case WM_CHAR:
// stifle this keyboard message if imgui wants to capture
if( imio.WantCaptureKeyboard )
{
break;
}
kbd.OnChar( static_cast<unsigned char>(wParam) ); kbd.OnChar( static_cast<unsigned char>(wParam) );
break; break;
/*********** END KEYBOARD MESSAGES ***********/ /*********** END KEYBOARD MESSAGES ***********/
...@@ -217,6 +233,11 @@ LRESULT Window::HandleMsg( HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam ) noex ...@@ -217,6 +233,11 @@ LRESULT Window::HandleMsg( HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam ) noex
/************* MOUSE MESSAGES ****************/ /************* MOUSE MESSAGES ****************/
case WM_MOUSEMOVE: case WM_MOUSEMOVE:
{ {
// stifle this mouse message if imgui wants to capture
if( imio.WantCaptureMouse )
{
break;
}
const POINTS pt = MAKEPOINTS( lParam ); const POINTS pt = MAKEPOINTS( lParam );
// in client region -> log move, and log enter + capture mouse (if not previously in window) // in client region -> log move, and log enter + capture mouse (if not previously in window)
if( pt.x >= 0 && pt.x < width && pt.y >= 0 && pt.y < height ) if( pt.x >= 0 && pt.x < width && pt.y >= 0 && pt.y < height )
...@@ -246,19 +267,34 @@ LRESULT Window::HandleMsg( HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam ) noex ...@@ -246,19 +267,34 @@ LRESULT Window::HandleMsg( HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam ) noex
} }
case WM_LBUTTONDOWN: case WM_LBUTTONDOWN:
{ {
SetForegroundWindow( hWnd );
// stifle this mouse message if imgui wants to capture
if( imio.WantCaptureMouse )
{
break;
}
const POINTS pt = MAKEPOINTS( lParam ); const POINTS pt = MAKEPOINTS( lParam );
mouse.OnLeftPressed( pt.x,pt.y ); mouse.OnLeftPressed( pt.x,pt.y );
SetForegroundWindow( hWnd );
break; break;
} }
case WM_RBUTTONDOWN: case WM_RBUTTONDOWN:
{ {
// stifle this mouse message if imgui wants to capture
if( imio.WantCaptureMouse )
{
break;
}
const POINTS pt = MAKEPOINTS( lParam ); const POINTS pt = MAKEPOINTS( lParam );
mouse.OnRightPressed( pt.x,pt.y ); mouse.OnRightPressed( pt.x,pt.y );
break; break;
} }
case WM_LBUTTONUP: case WM_LBUTTONUP:
{ {
// stifle this mouse message if imgui wants to capture
if( imio.WantCaptureMouse )
{
break;
}
const POINTS pt = MAKEPOINTS( lParam ); const POINTS pt = MAKEPOINTS( lParam );
mouse.OnLeftReleased( pt.x,pt.y ); mouse.OnLeftReleased( pt.x,pt.y );
// release mouse if outside of window // release mouse if outside of window
...@@ -271,6 +307,11 @@ LRESULT Window::HandleMsg( HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam ) noex ...@@ -271,6 +307,11 @@ LRESULT Window::HandleMsg( HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam ) noex
} }
case WM_RBUTTONUP: case WM_RBUTTONUP:
{ {
// stifle this mouse message if imgui wants to capture
if( imio.WantCaptureMouse )
{
break;
}
const POINTS pt = MAKEPOINTS( lParam ); const POINTS pt = MAKEPOINTS( lParam );
mouse.OnRightReleased( pt.x,pt.y ); mouse.OnRightReleased( pt.x,pt.y );
// release mouse if outside of window // release mouse if outside of window
...@@ -283,6 +324,11 @@ LRESULT Window::HandleMsg( HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam ) noex ...@@ -283,6 +324,11 @@ LRESULT Window::HandleMsg( HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam ) noex
} }
case WM_MOUSEWHEEL: case WM_MOUSEWHEEL:
{ {
// stifle this mouse message if imgui wants to capture
if( imio.WantCaptureMouse )
{
break;
}
const POINTS pt = MAKEPOINTS( lParam ); const POINTS pt = MAKEPOINTS( lParam );
const int delta = GET_WHEEL_DELTA_WPARAM( wParam ); const int delta = GET_WHEEL_DELTA_WPARAM( wParam );
mouse.OnWheelDelta( pt.x,pt.y,delta ); mouse.OnWheelDelta( pt.x,pt.y,delta );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment