Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libsimple_interactive
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
We are moving to Forgejo!
You are on a read-only GitLab instance.
Show more breadcrumbs
namark
libsimple_interactive
Commits
ddf063d8
Commit
ddf063d8
authored
4 years ago
by
namark
Browse files
Options
Downloads
Patches
Plain Diff
Text input and pointer events.
parent
c3f64f0b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
source/simple/interactive/event.cpp
+56
-0
56 additions, 0 deletions
source/simple/interactive/event.cpp
source/simple/interactive/event.h
+32
-1
32 additions, 1 deletion
source/simple/interactive/event.h
with
88 additions
and
1 deletion
source/simple/interactive/event.cpp
+
56
−
0
View file @
ddf063d8
...
...
@@ -5,6 +5,17 @@ using simple::geom::vector;
namespace
simple
::
interactive
{
template
<
typename
T
,
size_t
N
,
size_t
...
I
>
constexpr
auto
copy_array_n
(
T
(
&
arr
)[
N
],
std
::
index_sequence
<
I
...
>
)
{
return
std
::
array
{
arr
[
I
]...};
}
template
<
typename
T
,
size_t
N
>
constexpr
auto
to_array
(
T
(
&
arr
)[
N
])
{
return
copy_array_n
(
arr
,
std
::
make_index_sequence
<
N
>
{});
}
template
<
typename
WindowEvent
>
auto
make_window_event
(
const
SDL_Event
&
event
)
...
...
@@ -99,6 +110,51 @@ namespace simple::interactive
static_cast
<
wheel_direction
>
(
event
.
wheel
.
direction
),
#endif
};
case
SDL_TEXTINPUT
:
return
text_input
{
std
::
chrono
::
milliseconds
(
event
.
text
.
timestamp
),
event
.
text
.
windowID
,
to_array
(
event
.
text
.
text
)
};
case
SDL_TEXTEDITING
:
return
text_edit
{
std
::
chrono
::
milliseconds
(
event
.
edit
.
timestamp
),
event
.
edit
.
windowID
,
to_array
(
event
.
edit
.
text
),
{
event
.
edit
.
start
,
event
.
edit
.
start
+
event
.
edit
.
length
}
};
case
SDL_FINGERMOTION
:
return
pointer_motion
{
std
::
chrono
::
milliseconds
(
event
.
tfinger
.
timestamp
),
event
.
tfinger
.
touchId
,
event
.
tfinger
.
fingerId
,
{
event
.
tfinger
.
x
,
event
.
tfinger
.
y
},
{
event
.
tfinger
.
dx
,
event
.
tfinger
.
dy
},
event
.
tfinger
.
pressure
};
case
SDL_FINGERDOWN
:
return
pointer_down
{
std
::
chrono
::
milliseconds
(
event
.
tfinger
.
timestamp
),
event
.
tfinger
.
touchId
,
event
.
tfinger
.
fingerId
,
{
event
.
tfinger
.
x
,
event
.
tfinger
.
y
},
{
event
.
tfinger
.
dx
,
event
.
tfinger
.
dy
},
event
.
tfinger
.
pressure
};
case
SDL_FINGERUP
:
return
pointer_up
{
std
::
chrono
::
milliseconds
(
event
.
tfinger
.
timestamp
),
event
.
tfinger
.
touchId
,
event
.
tfinger
.
fingerId
,
{
event
.
tfinger
.
x
,
event
.
tfinger
.
y
},
{
event
.
tfinger
.
dx
,
event
.
tfinger
.
dy
},
event
.
tfinger
.
pressure
};
case
SDL_WINDOWEVENT
:
switch
(
event
.
window
.
event
)
{
...
...
This diff is collapsed.
Click to expand it.
source/simple/interactive/event.h
+
32
−
1
View file @
ddf063d8
...
...
@@ -68,7 +68,7 @@ namespace simple::interactive
struct
mouse_data
:
public
window_event_data
{
uint32_t
mous
e_id
;
uint32_t
devic
e_id
;
int2
position
;
};
...
...
@@ -94,6 +94,25 @@ namespace simple::interactive
#endif
};
struct
text_input_data
:
public
window_event_data
{
std
::
array
<
char
,
32
>
text
;
};
struct
text_edit_data
:
public
text_input_data
{
simple
::
support
::
range
<
int
>
edit_range
;
};
struct
pointer_data
:
public
event_data
{
int64_t
device_id
;
int64_t
pointer_id
;
float2
position
;
float2
motion
;
float
pressure
;
};
struct
key_event
{
const
key_data
data
;
...
...
@@ -142,6 +161,13 @@ namespace simple::interactive
struct
mouse_up
:
public
mouse_button_event
{};
struct
text_input
{
const
text_input_data
data
;
};
struct
text_edit
{
const
text_edit_data
data
;
};
struct
pointer_motion
{
const
pointer_data
data
;
};
struct
pointer_down
{
const
pointer_data
data
;
};
struct
pointer_up
{
const
pointer_data
data
;
};
struct
quit_request
{
const
event_data
data
;
};
// TODO: screen normalized position/size getters as with mouse?
...
...
@@ -173,6 +199,11 @@ namespace simple::interactive
,
mouse_up
,
mouse_motion
,
mouse_wheel
,
text_input
,
text_edit
,
pointer_motion
,
pointer_down
,
pointer_up
,
quit_request
,
window_shown
...
...
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