Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
orbclient
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
8
Issues
8
List
Boards
Labels
Service Desk
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
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
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
redox-os
orbclient
Commits
ca3ef993
Commit
ca3ef993
authored
Aug 15, 2020
by
Florian Blasius
🤘
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
workaround to get right key event characters
parent
4538af1a
Pipeline
#8325
passed with stage
in 1 minute and 34 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
11 deletions
+43
-11
src/event.rs
src/event.rs
+1
-2
src/sys/sdl2.rs
src/sys/sdl2.rs
+42
-9
No files found.
src/event.rs
View file @
ca3ef993
...
...
@@ -110,7 +110,6 @@ impl DerefMut for Event {
}
}
pub
const
K_A
:
u8
=
0x1E
;
pub
const
K_B
:
u8
=
0x30
;
pub
const
K_C
:
u8
=
0x2E
;
...
...
@@ -250,7 +249,7 @@ pub const K_F12: u8 = 0x58;
/// A key event (such as a pressed key)
#[derive(Copy,
Clone,
Debug)]
pub
struct
KeyEvent
{
/// The char
e
cter of the key
/// The char
a
cter of the key
pub
character
:
char
,
/// The scancode of the key
pub
scancode
:
u8
,
...
...
src/sys/sdl2.rs
View file @
ca3ef993
...
...
@@ -59,6 +59,10 @@ pub struct Window {
mouse_relative
:
bool
,
/// Content of the last drop (file | text) operation
drop_content
:
RefCell
<
Option
<
String
>>
,
/// This is used to correct the character of the key down event depending on the correct text input
key_event_correction
:
Cell
<
Option
<
KeyEvent
>>
,
/// This is used to correct the character of the key up event depending on the correct text input
last_text_input
:
Cell
<
Option
<
char
>>
,
}
impl
Renderer
for
Window
{
...
...
@@ -180,6 +184,8 @@ impl Window {
inner
:
window
.into_canvas
()
.software
()
.build
()
.unwrap
(),
mouse_relative
:
false
,
drop_content
:
RefCell
::
new
(
None
),
key_event_correction
:
Cell
::
new
(
None
),
last_text_input
:
Cell
::
new
(
None
),
}),
Err
(
_
)
=>
None
,
}
...
...
@@ -432,16 +438,33 @@ impl Window {
sdl2
::
event
::
Event
::
MouseWheel
{
x
,
y
,
..
}
=>
{
events
.push
(
ScrollEvent
{
x
:
x
,
y
:
y
}
.to_event
())
}
sdl2
::
event
::
Event
::
TextInput
{
text
,
..
}
=>
{
// workaround to get right character dependent on keyboard language settings (should be removed after keycode and keymap implementation is finished)
if
let
Some
(
mut
key_event
)
=
self
.key_event_correction
.get
()
{
for
c
in
text
.chars
()
{
key_event
.character
=
c
;
break
;
}
self
.last_text_input
.set
(
Some
(
key_event
.character
));
events
.push
(
key_event
.to_event
());
self
.key_event_correction
.set
(
None
);
}
}
sdl2
::
event
::
Event
::
KeyDown
{
scancode
,
..
}
=>
{
if
let
Some
(
code
)
=
self
.convert_scancode
(
scancode
,
shift
)
{
events
.push
(
KeyEvent
{
character
:
code
.0
,
scancode
:
code
.1
,
pressed
:
true
,
}
.to_event
(),
);
let
key_event
=
KeyEvent
{
character
:
code
.0
,
scancode
:
code
.1
,
pressed
:
true
,
};
// workaround to get right character dependent on keyboard language settings (should be removed after keycode and keymap implementation is finished)
if
key_event
.character
==
'\0'
{
events
.push
(
key_event
.to_event
());
}
else
{
self
.key_event_correction
.set
(
Some
(
key_event
));
}
}
}
sdl2
::
event
::
Event
::
DropFile
{
filename
,
..
}
=>
{
...
...
@@ -454,9 +477,19 @@ impl Window {
}
sdl2
::
event
::
Event
::
KeyUp
{
scancode
,
..
}
=>
{
if
let
Some
(
code
)
=
self
.convert_scancode
(
scancode
,
shift
)
{
let
mut
character
=
code
.0
;
// workaround to get right character dependent on keyboard language settings (should be removed after keycode and keymap implementation is finished)
if
character
!=
'\0'
{
if
let
Some
(
last
)
=
self
.last_text_input
.get
()
{
character
=
last
;
self
.last_text_input
.set
(
None
);
}
}
events
.push
(
KeyEvent
{
character
:
code
.0
,
character
,
scancode
:
code
.1
,
pressed
:
false
,
}
...
...
Frans Klaver
@fransklaver
mentioned in issue
#44
·
Aug 23, 2020
mentioned in issue
#44
mentioned in issue #44
Toggle commit list
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