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)
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
.
Control
=
((
allKeys
[
VK_CONTROL
]
&
0x80
)
!=
0
);
// Handle unicode and deadkeys in a way that works since Windows 95 and nt4.0
// Using ToUnicode instead would be shorter, but would to my knowledge not run on 95 and 98.
WORD
keyChars
[
2
];
UINT
scanCode
=
HIWORD
(
lParam
);
int
conversionResult
=
ToAsciiEx
(
wParam
,
scanCode
,
allKeys
,
keyChars
,
0
,
KEYBOARD_INPUT_HKL
);
if
(
conversionResult
==
1
)
// Translate to Unicode using the active keyboard layout.
// We intentionally don't emit characters on key-up events.
if
(
event
.
KeyInput
.
PressedDown
)
{
// ToAsciiEx writes translated ANSI chars into WORDs. Convert only the
// produced byte(s) instead of interpreting the whole WORD array as a byte buffer.
char
bytes
[
2
];
bytes
[
0
]
=
static_cast
<
char
>
(
keyChars
[
0
]
&
0xFF
);
bytes
[
1
]
=
static_cast
<
char
>
(
keyChars
[
1
]
&
0xFF
);
WORD
unicodeChar
=
0
;
MultiByteToWideChar
(
KEYBOARD_INPUT_CODEPAGE
,
MB_PRECOMPOSED
,
// default
bytes
,
1
,
(
WCHAR
*
)
&
unicodeChar
,
1
);
event
.
KeyInput
.
Char
=
unicodeChar
;
WCHAR
unicodeBuf
[
8
];
unicodeBuf
[
0
]
=
0
;
UINT
scanCode
=
(
UINT
)((
lParam
>>
16
)
&
0xFF
);
int
conversionResult
=
ToUnicodeEx
((
UINT
)
wParam
,
scanCode
,
allKeys
,
unicodeBuf
,
(
int
)(
sizeof
(
unicodeBuf
)
/
sizeof
(
unicodeBuf
[
0
])),
0
,
KEYBOARD_INPUT_HKL
);
if
(
conversionResult
==
-
1
)
{
// Dead-key: clear the keyboard layout state and do not emit a character.
ToUnicodeEx
((
UINT
)
wParam
,
scanCode
,
allKeys
,
unicodeBuf
,
(
int
)(
sizeof
(
unicodeBuf
)
/
sizeof
(
unicodeBuf
[
0
])),
0
,
KEYBOARD_INPUT_HKL
);
event
.
KeyInput
.
Char
=
0
;
}
else
if
(
conversionResult
>
0
)
{
event
.
KeyInput
.
Char
=
unicodeBuf
[
0
];
}
else
{
event
.
KeyInput
.
Char
=
0
;
}
}
else
{
event
.
KeyInput
.
Char
=
0
;
}
// allow composing characters like '@' with Alt Gr on non-US keyboards
if
((
allKeys
[
VK_MENU
]
&
0x80
)
!=
0
)
...
...
@@ -984,8 +999,8 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
delete
[]
buffer
;
}
ImmReleaseContext
(
hWnd
,
hIMC
);
// Remove GCS_RESULTSTR to prevent DefWindowProc from generating WM_IME_CHAR
lParam
&=
~
GCS_RESULTSTR
;
// Remove GCS_RESULTSTR to prevent DefWindowProc from generating WM_IME_CHAR
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