Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Project_Phoenix
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LuFG VR VIS
VR-Group
Project_Phoenix
Commits
0572b7d2
Commit
0572b7d2
authored
6 years ago
by
jwendt
Browse files
Options
Downloads
Patches
Plain Diff
Add mouse weel scroll signal
#463
parent
b33dff4c
No related branches found
No related tags found
1 merge request
!156
Feature/#463 mouse keyboard device
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
library/phx/input/mouse.cpp
+7
-0
7 additions, 0 deletions
library/phx/input/mouse.cpp
library/phx/input/mouse.hpp
+3
-1
3 additions, 1 deletion
library/phx/input/mouse.hpp
tests/src/test_mouse.cpp
+24
-0
24 additions, 0 deletions
tests/src/test_mouse.cpp
with
34 additions
and
1 deletion
library/phx/input/mouse.cpp
+
7
−
0
View file @
0572b7d2
...
@@ -36,6 +36,8 @@ void Mouse::OnSDLEvent(const SDL_Event& event) {
...
@@ -36,6 +36,8 @@ void Mouse::OnSDLEvent(const SDL_Event& event) {
if
(
event
.
type
==
SDL_MOUSEMOTION
)
{
if
(
event
.
type
==
SDL_MOUSEMOTION
)
{
move_signal_
(
static_cast
<
int
>
(
event
.
motion
.
xrel
),
move_signal_
(
static_cast
<
int
>
(
event
.
motion
.
xrel
),
static_cast
<
int
>
(
event
.
motion
.
yrel
));
static_cast
<
int
>
(
event
.
motion
.
yrel
));
}
else
if
(
event
.
type
==
SDL_MOUSEWHEEL
)
{
wheel_signal_
(
static_cast
<
int
>
(
event
.
wheel
.
y
));
}
else
if
(
event
.
type
==
SDL_MOUSEBUTTONDOWN
)
{
}
else
if
(
event
.
type
==
SDL_MOUSEBUTTONDOWN
)
{
event_type
=
BUTTON_PRESSED
;
event_type
=
BUTTON_PRESSED
;
}
else
if
(
event
.
type
==
SDL_MOUSEBUTTONUP
)
{
}
else
if
(
event
.
type
==
SDL_MOUSEBUTTONUP
)
{
...
@@ -75,4 +77,9 @@ boost::signals2::connection Mouse::RegisterMoveSignal(
...
@@ -75,4 +77,9 @@ boost::signals2::connection Mouse::RegisterMoveSignal(
return
move_signal_
.
connect
(
callback
);
return
move_signal_
.
connect
(
callback
);
}
}
boost
::
signals2
::
connection
Mouse
::
RegisterWheelSignal
(
const
std
::
function
<
void
(
int
)
>&
callback
)
{
return
wheel_signal_
.
connect
(
callback
);
}
}
// namespace phx
}
// namespace phx
This diff is collapsed.
Click to expand it.
library/phx/input/mouse.hpp
+
3
−
1
View file @
0572b7d2
...
@@ -31,7 +31,6 @@
...
@@ -31,7 +31,6 @@
#include
"boost/signals2/signal.hpp"
#include
"boost/signals2/signal.hpp"
#include
"phx/input/sdl_device.hpp"
#include
"phx/input/sdl_device.hpp"
#include
"phx/suppress_warnings.hpp"
#include
"phx/export.hpp"
#include
"phx/export.hpp"
...
@@ -57,10 +56,13 @@ class PHOENIX_EXPORT Mouse : public SDLDevice {
...
@@ -57,10 +56,13 @@ class PHOENIX_EXPORT Mouse : public SDLDevice {
const
std
::
function
<
void
(
ButtonId
,
ButtonEvent
)
>&
callback
);
const
std
::
function
<
void
(
ButtonId
,
ButtonEvent
)
>&
callback
);
boost
::
signals2
::
connection
RegisterMoveSignal
(
boost
::
signals2
::
connection
RegisterMoveSignal
(
const
std
::
function
<
void
(
int
,
int
)
>&
callback
);
const
std
::
function
<
void
(
int
,
int
)
>&
callback
);
boost
::
signals2
::
connection
RegisterWheelSignal
(
const
std
::
function
<
void
(
int
)
>&
callback
);
private
:
private
:
boost
::
signals2
::
signal
<
void
(
ButtonId
,
ButtonEvent
)
>
button_signal_
;
boost
::
signals2
::
signal
<
void
(
ButtonId
,
ButtonEvent
)
>
button_signal_
;
boost
::
signals2
::
signal
<
void
(
int
,
int
)
>
move_signal_
;
boost
::
signals2
::
signal
<
void
(
int
,
int
)
>
move_signal_
;
boost
::
signals2
::
signal
<
void
(
int
)
>
wheel_signal_
;
};
};
}
// namespace phx
}
// namespace phx
...
...
This diff is collapsed.
Click to expand it.
tests/src/test_mouse.cpp
+
24
−
0
View file @
0572b7d2
...
@@ -97,5 +97,29 @@ SCENARIO("Mouse signals received events.", "[phx][phx::Mouse]") {
...
@@ -97,5 +97,29 @@ SCENARIO("Mouse signals received events.", "[phx][phx::Mouse]") {
}
}
}
}
}
}
WHEN
(
"a mouse scroll signal is registered"
)
{
int
y_delta_received
=
0
;
mouse
.
RegisterWheelSignal
(
[
&
y_delta_received
](
int
y_delta
)
{
y_delta_received
=
y_delta
;
});
WHEN
(
"A mouse scroll event is fired by SDL."
)
{
SDL_Event
mouse_event
;
mouse_event
.
type
=
SDL_MOUSEWHEEL
;
mouse_event
.
wheel
.
y
=
3
;
auto
first_call
=
std
::
make_shared
<
bool
>
(
true
);
ALLOW_CALL
(
sdl_mock
.
Get
(),
SDL_PollEvent
(
_
))
.
SIDE_EFFECT
(
*
_1
=
mouse_event
)
.
SIDE_EFFECT
(
*
first_call
=
false
)
.
WITH
(
*
first_call
==
true
)
.
RETURN
(
true
);
ALLOW_CALL
(
sdl_mock
.
Get
(),
SDL_PollEvent
(
_
))
.
WITH
(
*
first_call
==
false
)
.
RETURN
(
false
);
THEN
(
"I should receive a signal."
)
{
mouse
.
Update
();
REQUIRE
(
y_delta_received
==
3
);
}
}
}
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment