Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Clark Lin
hw3d
Commits
2a6d9115
Commit
2a6d9115
authored
Jul 02, 2019
by
chili
Browse files
enable / disable raw input
parent
704f5322
Changes
6
Hide whitespace changes
Inline
Side-by-side
hw3d/App.cpp
View file @
2a6d9115
...
...
@@ -32,15 +32,15 @@ void App::DoFrame()
{
if
(
e
->
IsPress
()
&&
e
->
GetCode
()
==
VK_INSERT
)
{
if
(
c
ursorEnabled
)
if
(
wnd
.
C
ursorEnabled
()
)
{
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"
,
c
ursorEnabled
?
"enabled"
:
"disabled"
);
ImGui
::
Text
(
"Cursor: %s"
,
wnd
.
C
ursorEnabled
()
?
"enabled"
:
"disabled"
);
}
ImGui
::
End
();
}
...
...
hw3d/App.h
View file @
2a6d9115
...
...
@@ -19,7 +19,6 @@ private:
void
ShowImguiDemoWindow
();
void
ShowRawInputWindow
();
private:
bool
cursorEnabled
=
true
;
int
x
=
0
,
y
=
0
;
ImguiManager
imgui
;
Window
wnd
;
...
...
hw3d/Mouse.cpp
View file @
2a6d9115
...
...
@@ -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
;
...
...
hw3d/Mouse.h
View file @
2a6d9115
...
...
@@ -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
hw3d/Window.cpp
View file @
2a6d9115
...
...
@@ -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
(
...
...
hw3d/Window.h
View file @
2a6d9115
...
...
@@ -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:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment