4
4
5
5
#include " flutter/shell/platform/windows/keyboard_key_embedder_handler.h"
6
6
7
- #include < assert.h>
8
7
#include < windows.h>
9
8
10
9
#include < chrono>
11
10
#include < iostream>
12
11
#include < string>
13
12
13
+ #include " flutter/fml/logging.h"
14
14
#include " flutter/shell/platform/windows/keyboard_utils.h"
15
15
16
16
namespace flutter {
@@ -38,7 +38,7 @@ char _GetBit(char32_t ch, size_t start, size_t end) {
38
38
39
39
std::string ConvertChar32ToUtf8 (char32_t ch) {
40
40
std::string result;
41
- assert (0 <= ch && ch <= 0x10FFFF );
41
+ FML_DCHECK (0 <= ch && ch <= 0x10FFFF ) << " Character out of range " ;
42
42
if (ch <= 0x007F ) {
43
43
result.push_back (ch);
44
44
} else if (ch <= 0x07FF ) {
@@ -160,8 +160,8 @@ void KeyboardKeyEmbedderHandler::KeyboardHookImpl(
160
160
std::function<void (bool )> callback) {
161
161
const uint64_t physical_key = GetPhysicalKey (scancode, extended);
162
162
const uint64_t logical_key = GetLogicalKey (key, extended, scancode);
163
- assert (action == WM_KEYDOWN || action == WM_KEYUP ||
164
- action == WM_SYSKEYDOWN || action == WM_SYSKEYUP);
163
+ FML_DCHECK (action == WM_KEYDOWN || action == WM_KEYUP ||
164
+ action == WM_SYSKEYDOWN || action == WM_SYSKEYUP);
165
165
166
166
auto last_logical_record_iter = pressingRecords_.find (physical_key);
167
167
bool had_record = last_logical_record_iter != pressingRecords_.end ();
@@ -230,7 +230,7 @@ void KeyboardKeyEmbedderHandler::KeyboardHookImpl(
230
230
if (was_down) {
231
231
// A normal repeated key.
232
232
type = kFlutterKeyEventTypeRepeat ;
233
- assert (had_record);
233
+ FML_DCHECK (had_record);
234
234
ConvertUtf32ToUtf8_ (character_bytes, character);
235
235
eventual_logical_record = last_logical_record;
236
236
result_logical_key = last_logical_record;
@@ -245,7 +245,7 @@ void KeyboardKeyEmbedderHandler::KeyboardHookImpl(
245
245
} else {
246
246
// A normal down event (whether the system event is a repeat or not).
247
247
type = kFlutterKeyEventTypeDown ;
248
- assert (!had_record);
248
+ FML_DCHECK (!had_record);
249
249
ConvertUtf32ToUtf8_ (character_bytes, character);
250
250
eventual_logical_record = logical_key;
251
251
result_logical_key = logical_key;
@@ -260,7 +260,7 @@ void KeyboardKeyEmbedderHandler::KeyboardHookImpl(
260
260
} else {
261
261
// A normal up event.
262
262
type = kFlutterKeyEventTypeUp ;
263
- assert (had_record);
263
+ FML_DCHECK (had_record);
264
264
// Up events never have character.
265
265
character_bytes[0 ] = ' \0 ' ;
266
266
eventual_logical_record = 0 ;
@@ -278,7 +278,7 @@ void KeyboardKeyEmbedderHandler::KeyboardHookImpl(
278
278
if (record_iter != pressingRecords_.end ()) {
279
279
pressingRecords_.erase (record_iter);
280
280
} else {
281
- assert (false );
281
+ FML_DCHECK (false );
282
282
}
283
283
}
284
284
@@ -375,7 +375,7 @@ void KeyboardKeyEmbedderHandler::SynchronizeCriticalToggledStates(
375
375
// Never seen this key.
376
376
continue ;
377
377
}
378
- assert (key_info.logical_key != 0 );
378
+ FML_DCHECK (key_info.logical_key != 0 );
379
379
380
380
// Check toggling state first, because it might alter pressing state.
381
381
if (key_info.check_toggled ) {
@@ -440,7 +440,7 @@ void KeyboardKeyEmbedderHandler::SynchronizeCriticalPressedStates(
440
440
// Never seen this key.
441
441
continue ;
442
442
}
443
- assert (key_info.logical_key != 0 );
443
+ FML_DCHECK (key_info.logical_key != 0 );
444
444
if (key_info.check_pressed ) {
445
445
SHORT true_pressed = get_key_state_ (virtual_key) & kStateMaskPressed ;
446
446
auto pressing_record_iter = pressingRecords_.find (key_info.physical_key );
0 commit comments