Commit 2a6d9115 authored by chili's avatar chili
Browse files

enable / disable raw input

parent 704f5322
......@@ -32,15 +32,15 @@ void App::DoFrame()
{
if( e->IsPress() && e->GetCode() == VK_INSERT )
{
if( cursorEnabled )
if( wnd.CursorEnabled() )
{
wnd.DisableCursor();
cursorEnabled = false;
wnd.mouse.EnableRaw();
}
else
{
wnd.EnableCursor();
cursorEnabled = true;
wnd.mouse.DisableRaw();
}
}
}
......@@ -75,7 +75,7 @@ void App::ShowRawInputWindow()
if( ImGui::Begin( "Raw Input" ) )
{
ImGui::Text( "Tally: (%d,%d)",x,y );
ImGui::Text( "Cursor: %s",cursorEnabled?"enabled":"disabled" );
ImGui::Text( "Cursor: %s",wnd.CursorEnabled()?"enabled":"disabled" );
}
ImGui::End();
}
......
......@@ -19,7 +19,6 @@ private:
void ShowImguiDemoWindow();
void ShowRawInputWindow();
private:
bool cursorEnabled = true;
int x = 0,y = 0;
ImguiManager imgui;
Window wnd;
......
......@@ -79,6 +79,21 @@ void Mouse::Flush() noexcept
buffer = std::queue<Event>();
}
void Mouse::EnableRaw() noexcept
{
rawEnabled = true;
}
void Mouse::DisableRaw() noexcept
{
rawEnabled = false;
}
bool Mouse::RawEnabled() const noexcept
{
return rawEnabled;
}
void Mouse::OnMouseMove( int newx,int newy ) noexcept
{
x = newx;
......
......@@ -102,6 +102,9 @@ public:
return buffer.empty();
}
void Flush() noexcept;
void EnableRaw() noexcept;
void DisableRaw() noexcept;
bool RawEnabled() const noexcept;
private:
void OnMouseMove( int x,int y ) noexcept;
void OnMouseLeave() noexcept;
......@@ -124,6 +127,7 @@ private:
bool rightIsPressed = false;
bool isInWindow = false;
int wheelDeltaCarry = 0;
bool rawEnabled = false;
std::queue<Event> buffer;
std::queue<RawDelta> rawDeltaBuffer;
};
\ No newline at end of file
......@@ -145,6 +145,11 @@ void Window::DisableCursor() noexcept
ConfineCursor();
}
bool Window::CursorEnabled() const noexcept
{
return cursorEnabled;
}
std::optional<int> Window::ProcessMessages() noexcept
{
MSG msg;
......@@ -430,6 +435,10 @@ LRESULT Window::HandleMsg( HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam ) noex
/************** RAW MOUSE MESSAGES **************/
case WM_INPUT:
{
if( !mouse.RawEnabled() )
{
break;
}
UINT size;
// first get the size of the input data
if( GetRawInputData(
......
......@@ -77,6 +77,7 @@ public:
void SetTitle( const std::string& title );
void EnableCursor() noexcept;
void DisableCursor() noexcept;
bool CursorEnabled() const noexcept;
static std::optional<int> ProcessMessages() noexcept;
Graphics& Gfx();
private:
......
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