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
9413bde0
Commit
9413bde0
authored
Dec 24, 2018
by
chili
Browse files
proper wheel delta
parent
524925dd
Changes
3
Show whitespace changes
Inline
Side-by-side
hw3d/Mouse.cpp
View file @
9413bde0
...
...
@@ -19,7 +19,7 @@
* along with The Chili DirectX Framework. If not, see <http://www.gnu.org/licenses/>. *
******************************************************************************************/
#include "Mouse.h"
#include <Windows.h>
std
::
pair
<
int
,
int
>
Mouse
::
GetPos
()
const
noexcept
{
...
...
@@ -144,3 +144,19 @@ void Mouse::TrimBuffer() noexcept
buffer
.
pop
();
}
}
void
Mouse
::
OnWheelDelta
(
int
x
,
int
y
,
int
delta
)
noexcept
{
wheelDeltaCarry
+=
delta
;
// generate events for every 120
while
(
wheelDeltaCarry
>=
WHEEL_DELTA
)
{
wheelDeltaCarry
-=
WHEEL_DELTA
;
OnWheelUp
(
x
,
y
);
}
while
(
wheelDeltaCarry
<=
-
WHEEL_DELTA
)
{
wheelDeltaCarry
+=
WHEEL_DELTA
;
OnWheelDown
(
x
,
y
);
}
}
hw3d/Mouse.h
View file @
9413bde0
...
...
@@ -120,6 +120,7 @@ private:
void
OnWheelUp
(
int
x
,
int
y
)
noexcept
;
void
OnWheelDown
(
int
x
,
int
y
)
noexcept
;
void
TrimBuffer
()
noexcept
;
void
OnWheelDelta
(
int
x
,
int
y
,
int
delta
)
noexcept
;
private:
static
constexpr
unsigned
int
bufferSize
=
16u
;
int
x
;
...
...
@@ -127,5 +128,6 @@ private:
bool
leftIsPressed
=
false
;
bool
rightIsPressed
=
false
;
bool
isInWindow
=
false
;
int
wheelDeltaCarry
=
0
;
std
::
queue
<
Event
>
buffer
;
};
\ No newline at end of file
hw3d/Window.cpp
View file @
9413bde0
...
...
@@ -240,14 +240,8 @@ LRESULT Window::HandleMsg( HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam ) noex
case
WM_MOUSEWHEEL
:
{
const
POINTS
pt
=
MAKEPOINTS
(
lParam
);
if
(
GET_WHEEL_DELTA_WPARAM
(
wParam
)
>
0
)
{
mouse
.
OnWheelUp
(
pt
.
x
,
pt
.
y
);
}
else
if
(
GET_WHEEL_DELTA_WPARAM
(
wParam
)
<
0
)
{
mouse
.
OnWheelDown
(
pt
.
x
,
pt
.
y
);
}
const
int
delta
=
GET_WHEEL_DELTA_WPARAM
(
wParam
);
mouse
.
OnWheelDelta
(
pt
.
x
,
pt
.
y
,
delta
);
break
;
}
/************** END MOUSE MESSAGES **************/
...
...
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