Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
GameDevWeek
Dependencies
Cpp
mirrage
Commits
14568d74
Commit
14568d74
authored
Mar 27, 2019
by
Florian Oetke
Browse files
fixed ignoring clicks on UI elements and partial fix for keys
parent
d6ddd6cc
Pipeline
#2802
passed with stage
in 9 minutes and 58 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/mirrage/gui/src/gui.cpp
View file @
14568d74
#include <sf2/sf2.hpp>
#include <mirrage/gui/gui.hpp>
#include <sf2/sf2.hpp>
#include <mirrage/asset/asset_manager.hpp>
#include <mirrage/input/events.hpp>
...
...
@@ -373,6 +373,7 @@ namespace mirrage::gui {
handle_key
(
evt
.
type
==
SDL_KEYDOWN
,
evt
.
key
.
keysym
.
scancode
);
return
evt
.
key
.
keysym
.
sym
==
SDLK_ESCAPE
||
!
io
.
WantCaptureKeyboard
;
case
SDL_MOUSEBUTTONUP
:
return
!
io
.
WantCaptureMouse
;
case
SDL_MOUSEBUTTONDOWN
:
if
(
evt
.
button
.
button
>
0
&&
evt
.
button
.
button
<
4
)
{
_mouse_pressed
[
evt
.
button
.
button
-
1
]
=
true
;
...
...
src/mirrage/input/include/mirrage/input/input_manager.hpp
View file @
14568d74
...
...
@@ -102,7 +102,7 @@ namespace mirrage::input {
void
_on_mouse_motion
(
const
SDL_MouseMotionEvent
&
motion
);
void
_poll_events
();
void
_handle_event
(
SDL_Event
&
event
);
void
_handle_event
(
SDL_Event
&
event
,
bool
filtered
);
private:
class
Gamepad
;
...
...
src/mirrage/input/src/input_manager.cpp
View file @
14568d74
...
...
@@ -201,9 +201,7 @@ namespace mirrage::input {
[
&
](
auto
f
)
{
return
!
f
->
propagate
(
event
);
})
!=
_event_filter
.
end
();
if
(
!
filtered
)
{
_handle_event
(
event
);
}
_handle_event
(
event
,
filtered
);
}
for
(
auto
&
f
:
_event_filter
)
{
...
...
@@ -212,8 +210,11 @@ namespace mirrage::input {
}
void
Input_manager
::
_handle_event
(
SDL_Event
&
event
)
void
Input_manager
::
_handle_event
(
SDL_Event
&
event
,
bool
filtered
)
{
if
(
filtered
)
return
;
// TODO: don't filter key/button-up events if the down event has already been send
switch
(
event
.
type
)
{
case
SDL_TEXTINPUT
:
_mailbox
.
send
<
Char_input
>
(
event
.
text
.
text
);
break
;
...
...
@@ -339,7 +340,8 @@ namespace mirrage::input {
if
(
SDL_IsGameController
(
joystick_id
))
{
SDL_GameController
*
controller
=
SDL_GameControllerOpen
(
joystick_id
);
if
(
controller
)
{
_gamepads
.
emplace_back
(
std
::
make_unique
<
Gamepad
>
(
gsl
::
narrow
<
Input_source
>
(
_gamepads
.
size
()
+
1
),
controller
,
*
_mapper
));
_gamepads
.
emplace_back
(
std
::
make_unique
<
Gamepad
>
(
gsl
::
narrow
<
Input_source
>
(
_gamepads
.
size
()
+
1
),
controller
,
*
_mapper
));
_mailbox
.
send
<
Source_added
>
(
Input_source
(
_gamepads
.
size
()));
}
else
{
std
::
cerr
<<
"Could not open gamecontroller "
<<
joystick_id
<<
": "
<<
SDL_GetError
()
...
...
Write
Preview
Supports
Markdown
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