Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
I
Irrlicht New
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
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
MyCard
Irrlicht New
Commits
e899f77f
Commit
e899f77f
authored
Dec 24, 2025
by
mercury233
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use ToUnicodeEx instead of ToAsciiEx
parent
f07e86dd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
22 deletions
+37
-22
source/Irrlicht/CIrrDeviceWin32.cpp
source/Irrlicht/CIrrDeviceWin32.cpp
+37
-22
No files found.
source/Irrlicht/CIrrDeviceWin32.cpp
View file @
e899f77f
...
@@ -833,33 +833,48 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
...
@@ -833,33 +833,48 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
GetKeyboardState
(
allKeys
);
GetKeyboardState
(
allKeys
);
// Ensure current key state reflects this message.
if
(
wParam
<
256
)
{
if
(
event
.
KeyInput
.
PressedDown
)
allKeys
[
wParam
]
|=
0x80
;
else
allKeys
[
wParam
]
&=
~
0x80
;
}
event
.
KeyInput
.
Shift
=
((
allKeys
[
VK_SHIFT
]
&
0x80
)
!=
0
);
event
.
KeyInput
.
Shift
=
((
allKeys
[
VK_SHIFT
]
&
0x80
)
!=
0
);
event
.
KeyInput
.
Control
=
((
allKeys
[
VK_CONTROL
]
&
0x80
)
!=
0
);
event
.
KeyInput
.
Control
=
((
allKeys
[
VK_CONTROL
]
&
0x80
)
!=
0
);
// Handle unicode and deadkeys in a way that works since Windows 95 and nt4.0
// Translate to Unicode using the active keyboard layout.
// Using ToUnicode instead would be shorter, but would to my knowledge not run on 95 and 98.
// We intentionally don't emit characters on key-up events.
WORD
keyChars
[
2
];
if
(
event
.
KeyInput
.
PressedDown
)
UINT
scanCode
=
HIWORD
(
lParam
);
int
conversionResult
=
ToAsciiEx
(
wParam
,
scanCode
,
allKeys
,
keyChars
,
0
,
KEYBOARD_INPUT_HKL
);
if
(
conversionResult
==
1
)
{
{
// ToAsciiEx writes translated ANSI chars into WORDs. Convert only the
WCHAR
unicodeBuf
[
8
];
// produced byte(s) instead of interpreting the whole WORD array as a byte buffer.
unicodeBuf
[
0
]
=
0
;
char
bytes
[
2
];
UINT
scanCode
=
(
UINT
)((
lParam
>>
16
)
&
0xFF
);
bytes
[
0
]
=
static_cast
<
char
>
(
keyChars
[
0
]
&
0xFF
);
int
conversionResult
=
ToUnicodeEx
((
UINT
)
wParam
,
scanCode
,
allKeys
,
unicodeBuf
,
bytes
[
1
]
=
static_cast
<
char
>
(
keyChars
[
1
]
&
0xFF
);
(
int
)(
sizeof
(
unicodeBuf
)
/
sizeof
(
unicodeBuf
[
0
])),
0
,
KEYBOARD_INPUT_HKL
);
WORD
unicodeChar
=
0
;
MultiByteToWideChar
(
if
(
conversionResult
==
-
1
)
KEYBOARD_INPUT_CODEPAGE
,
{
MB_PRECOMPOSED
,
// default
// Dead-key: clear the keyboard layout state and do not emit a character.
bytes
,
ToUnicodeEx
((
UINT
)
wParam
,
scanCode
,
allKeys
,
unicodeBuf
,
1
,
(
int
)(
sizeof
(
unicodeBuf
)
/
sizeof
(
unicodeBuf
[
0
])),
0
,
KEYBOARD_INPUT_HKL
);
(
WCHAR
*
)
&
unicodeChar
,
event
.
KeyInput
.
Char
=
0
;
1
);
}
event
.
KeyInput
.
Char
=
unicodeChar
;
else
if
(
conversionResult
>
0
)
{
event
.
KeyInput
.
Char
=
unicodeBuf
[
0
];
}
else
{
event
.
KeyInput
.
Char
=
0
;
}
}
}
else
else
{
event
.
KeyInput
.
Char
=
0
;
event
.
KeyInput
.
Char
=
0
;
}
// allow composing characters like '@' with Alt Gr on non-US keyboards
// allow composing characters like '@' with Alt Gr on non-US keyboards
if
((
allKeys
[
VK_MENU
]
&
0x80
)
!=
0
)
if
((
allKeys
[
VK_MENU
]
&
0x80
)
!=
0
)
...
@@ -984,8 +999,8 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
...
@@ -984,8 +999,8 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
delete
[]
buffer
;
delete
[]
buffer
;
}
}
ImmReleaseContext
(
hWnd
,
hIMC
);
ImmReleaseContext
(
hWnd
,
hIMC
);
// Remove GCS_RESULTSTR to prevent DefWindowProc from generating WM_IME_CHAR
// Remove GCS_RESULTSTR to prevent DefWindowProc from generating WM_IME_CHAR
lParam
&=
~
GCS_RESULTSTR
;
lParam
&=
~
GCS_RESULTSTR
;
}
}
}
}
}
}
...
...
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