diff --git a/LvglWindowsSimulator/win32drv.c b/LvglWindowsSimulator/win32drv.c index 3aa9c28..b64fcf7 100644 --- a/LvglWindowsSimulator/win32drv.c +++ b/LvglWindowsSimulator/win32drv.c @@ -178,17 +178,12 @@ static void lv_win32_push_key_to_keyboard_queue( uint32_t key, lv_indev_state_t state) { - lv_win32_keypad_queue_item_t* current = - (lv_win32_keypad_queue_item_t*)(_aligned_malloc( - sizeof(lv_win32_keypad_queue_item_t), - MEMORY_ALLOCATION_ALIGNMENT)); + lv_win32_keypad_queue_item_t* current = (lv_win32_keypad_queue_item_t*)( + _lv_ll_ins_tail(&context->keypad.queue)); if (current) { current->key = key; current->state = state; - InterlockedPushEntrySList( - context->keypad.queue, - ¤t->ItemEntry); } } @@ -679,15 +674,15 @@ static void lv_win32_keypad_driver_read_callback( EnterCriticalSection(&context->keypad.mutex); - lv_win32_keypad_queue_item_t* current = - (lv_win32_keypad_queue_item_t*)(InterlockedPopEntrySList( - context->keypad.queue)); + lv_win32_keypad_queue_item_t* current = (lv_win32_keypad_queue_item_t*)( + _lv_ll_get_head(&context->keypad.queue)); if (current) { data->key = current->key; data->state = current->state; - _aligned_free(current); + _lv_ll_remove(&context->keypad.queue, current); + lv_free(current); data->continue_reading = true; } @@ -831,14 +826,9 @@ static LRESULT CALLBACK lv_win32_window_message_callback( context->display_device_object); InitializeCriticalSection(&context->keypad.mutex); - context->keypad.queue = _aligned_malloc( - sizeof(SLIST_HEADER), - MEMORY_ALLOCATION_ALIGNMENT); - if (!context->keypad.queue) - { - return -1; - } - InitializeSListHead(context->keypad.queue); + _lv_ll_init( + &context->keypad.queue, + sizeof(lv_win32_keypad_queue_item_t)); context->keypad.utf16_high_surrogate = 0; context->keypad.utf16_low_surrogate = 0; context->keyboard_device_object = lv_indev_create(); @@ -1353,20 +1343,7 @@ static LRESULT CALLBACK lv_win32_window_message_callback( context->keyboard_device_object; context->keyboard_device_object = NULL; lv_indev_delete(keyboard_device_object); - do - { - PSLIST_ENTRY current = InterlockedPopEntrySList( - context->keypad.queue); - if (!current) - { - _aligned_free(context->keypad.queue); - context->keypad.queue = NULL; - break; - } - - _aligned_free(current); - - } while (true); + _lv_ll_clear(&context->keypad.queue); DeleteCriticalSection(&context->keypad.mutex); free(context); diff --git a/LvglWindowsSimulator/win32drv.h b/LvglWindowsSimulator/win32drv.h index db06ca7..f81a2cc 100644 --- a/LvglWindowsSimulator/win32drv.h +++ b/LvglWindowsSimulator/win32drv.h @@ -60,7 +60,6 @@ typedef struct _lv_windows_pointer_device_context_t typedef struct _lv_win32_keypad_queue_item_t { - SLIST_ENTRY ItemEntry; uint32_t key; lv_indev_state_t state; } lv_win32_keypad_queue_item_t; @@ -68,7 +67,7 @@ typedef struct _lv_win32_keypad_queue_item_t typedef struct _lv_windows_keypad_device_context_t { CRITICAL_SECTION mutex; - PSLIST_HEADER queue; + lv_ll_t queue; uint16_t utf16_high_surrogate; uint16_t utf16_low_surrogate; } lv_windows_keypad_device_context_t;