Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
mirrage
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
GameDevWeek
D
Dependencies
Cpp
mirrage
Commits
1bf4f023
Commit
1bf4f023
authored
Mar 27, 2019
by
Florian Oetke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed hanging keys caused by ui-filtered events
parent
9b89d53e
Pipeline
#2812
passed with stage
in 15 minutes and 48 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
14 deletions
+34
-14
src/mirrage/input/include/mirrage/input/input_mapping.hpp
src/mirrage/input/include/mirrage/input/input_mapping.hpp
+6
-2
src/mirrage/input/src/input_manager.cpp
src/mirrage/input/src/input_manager.cpp
+9
-7
src/mirrage/input/src/input_mapping.cpp
src/mirrage/input/src/input_mapping.cpp
+19
-5
No files found.
src/mirrage/input/include/mirrage/input/input_mapping.hpp
View file @
1bf4f023
...
...
@@ -18,6 +18,7 @@
#include <glm/vec2.hpp>
#include <memory>
#include <unordered_map>
#include <unordered_set>
namespace
mirrage
::
asset
{
...
...
@@ -51,7 +52,7 @@ namespace mirrage::input {
void
enable_context
(
Context_id
id
);
void
on_key_pressed
(
Key
);
void
on_key_released
(
Key
);
void
on_key_released
(
Key
,
bool
filtered
);
void
on_mouse_pos_change
(
glm
::
vec2
rel
,
glm
::
vec2
abs
);
...
...
@@ -62,7 +63,7 @@ namespace mirrage::input {
void
on_pad_button_released
(
Input_source
src
,
Pad_button
);
void
on_mouse_button_pressed
(
Mouse_button
,
float
pressure
=
1.
f
);
void
on_mouse_button_released
(
Mouse_button
,
int8_t
clicks
);
void
on_mouse_button_released
(
Mouse_button
,
int8_t
clicks
,
bool
filtered
);
void
on_pad_stick_change
(
Input_source
src
,
Pad_stick
,
glm
::
vec2
rel
,
glm
::
vec2
abs
);
...
...
@@ -74,6 +75,9 @@ namespace mirrage::input {
Context_id
_active_context_id
;
Context
*
_active_context
;
std
::
unordered_set
<
Key
>
_cont_pressed_keys
;
std
::
unordered_set
<
Mouse_button
>
_cont_pressed_mouse
;
bool
_primary_mouse_button_down
=
false
;
bool
_is_mouse_drag
=
false
;
};
...
...
src/mirrage/input/src/input_manager.cpp
View file @
1bf4f023
...
...
@@ -212,8 +212,9 @@ namespace mirrage::input {
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
if
(
filtered
&&
event
.
type
!=
SDL_KEYUP
&&
event
.
type
!=
SDL_MOUSEBUTTONUP
)
{
return
;
}
switch
(
event
.
type
)
{
case
SDL_TEXTINPUT
:
_mailbox
.
send
<
Char_input
>
(
event
.
text
.
text
);
break
;
...
...
@@ -224,8 +225,9 @@ namespace mirrage::input {
break
;
case
SDL_KEYUP
:
if
(
event
.
key
.
repeat
==
0
)
_mapper
->
on_key_released
(
from_sdl_keycode
(
event
.
key
.
keysym
.
sym
));
if
(
event
.
key
.
repeat
==
0
)
{
_mapper
->
on_key_released
(
from_sdl_keycode
(
event
.
key
.
keysym
.
sym
),
filtered
);
}
break
;
case
SDL_MOUSEMOTION
:
_on_mouse_motion
(
event
.
motion
);
break
;
...
...
@@ -236,8 +238,8 @@ namespace mirrage::input {
break
;
case
SDL_MOUSEBUTTONUP
:
_mapper
->
on_mouse_button_released
(
event
.
button
.
button
,
static_cast
<
int8_t
>
(
event
.
button
.
clicks
)
);
_mapper
->
on_mouse_button_released
(
event
.
button
.
button
,
static_cast
<
int8_t
>
(
event
.
button
.
clicks
),
filtered
);
_pointer_active
[
0
]
=
false
;
break
;
...
...
@@ -282,7 +284,7 @@ namespace mirrage::input {
if
(
event
.
tfinger
.
type
==
SDL_FINGERDOWN
)
_mapper
->
on_mouse_button_pressed
(
1
,
event
.
tfinger
.
pressure
);
else
if
(
event
.
tfinger
.
type
==
SDL_FINGERUP
)
_mapper
->
on_mouse_button_released
(
1
,
1
);
_mapper
->
on_mouse_button_released
(
1
,
1
,
filtered
);
}
}
break
;
...
...
src/mirrage/input/src/input_mapping.cpp
View file @
1bf4f023
...
...
@@ -153,12 +153,21 @@ namespace mirrage::input {
void
Input_mapper
::
on_key_pressed
(
Key
k
)
{
_cont_pressed_keys
.
emplace
(
k
);
find_maybe
(
_active_context
->
keys
,
k
).
process
([
&
](
auto
&
action
)
{
process_pressed
(
_bus
,
action
);
});
}
void
Input_mapper
::
on_key_released
(
Key
k
)
void
Input_mapper
::
on_key_released
(
Key
k
,
bool
filtered
)
{
find_maybe
(
_active_context
->
keys
,
k
).
process
([
&
](
auto
&
action
)
{
process_release
(
_bus
,
action
);
});
auto
pressed
=
_cont_pressed_keys
.
count
(
k
);
_cont_pressed_keys
.
erase
(
k
);
find_maybe
(
_active_context
->
keys
,
k
).
process
([
&
](
auto
&
action
)
{
if
(
!
filtered
||
action
.
type
==
Reaction_type
::
continuous
)
{
if
(
pressed
||
action
.
type
!=
Reaction_type
::
continuous
)
process_release
(
_bus
,
action
);
}
});
}
void
Input_mapper
::
on_mouse_pos_change
(
glm
::
vec2
rel
,
glm
::
vec2
abs
)
...
...
@@ -213,6 +222,8 @@ namespace mirrage::input {
void
Input_mapper
::
on_mouse_button_pressed
(
Mouse_button
b
,
float
pressure
)
{
_cont_pressed_mouse
.
emplace
(
b
);
find_maybe
(
_active_context
->
mouse_buttons
,
{
b
,
0
}).
process
([
&
](
auto
&
action
)
{
process_pressed
(
_bus
,
action
,
Input_source
{
0
},
pressure
);
});
...
...
@@ -221,9 +232,9 @@ namespace mirrage::input {
_primary_mouse_button_down
=
true
;
}
void
Input_mapper
::
on_mouse_button_released
(
Mouse_button
b
,
int8_t
clicks
)
void
Input_mapper
::
on_mouse_button_released
(
Mouse_button
b
,
int8_t
clicks
,
bool
filtered
)
{
if
(
b
!=
1
||
!
_is_mouse_drag
)
{
if
(
(
b
!=
1
||
!
_is_mouse_drag
)
&&
!
filtered
)
{
find_maybe
(
_active_context
->
mouse_buttons
,
{
b
,
clicks
}).
process
([
&
](
auto
&
action
)
{
process_release
(
_bus
,
action
);
});
...
...
@@ -236,13 +247,16 @@ namespace mirrage::input {
// call end listerners for continue_click_handlers (clicks==0)
find_maybe
(
_active_context
->
mouse_buttons
,
{
b
,
0
}).
process
([
&
](
auto
&
action
)
{
process_release
(
_bus
,
action
);
if
(
!
filtered
||
(
action
.
type
==
Reaction_type
::
continuous
&&
_cont_pressed_mouse
.
count
(
b
)
>
0
))
process_release
(
_bus
,
action
);
});
if
(
b
==
1
)
{
_primary_mouse_button_down
=
false
;
_is_mouse_drag
=
false
;
}
_cont_pressed_mouse
.
erase
(
b
);
}
void
Input_mapper
::
on_pad_stick_change
(
Input_source
src
,
Pad_stick
s
,
glm
::
vec2
rel
,
glm
::
vec2
abs
)
...
...
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