1=============================
2Windows Display/Inputs driver
3=============================
4
5Overview
6********
7
8The **Windows** display/input `driver <https://github.com/lvgl/lvgl/src/drivers/windows>`__ offers support for simulating the LVGL display and keyboard/mouse inputs in a Windows Win32 window.
9
10The main purpose for this driver is for testing/debugging the LVGL application in a **Windows** simulation window via **simulator mode**, or developing a standard **Windows** desktop application with LVGL via **application mode**.
11
12These are the **similarities** between simulator mode and application mode.
13
14- Support LVGL pointer, keypad and encoder devices integration.
15- Support Windows touch input.
16- Support Windows input method integration input.
17- Support Per-monitor DPI Aware (both V1 and V2).
18- Provide HWND-based interoperability for other Windows UI infrastructures.
19
20These are the **differences** between simulator mode and application mode.
21
22Simulator Mode
23--------------
24
25- Designed for LVGL device-simulation scenario --- simulates LVGL rendering to a hardware display panel.
26- Keeps LVGL display resolution constant in order to best simulate UI layout which will will be seen in production devices.
27- When Windows DPI scaling setting is changed, Windows backend will stretch display content.
28
29Application Mode
30----------------
31
32- Designed for Windows desktop application-development scenario.
33- Has Window resizing support and LVGL display resolution is changed dynamically.
34- When Windows DPI scaling setting is changed, LVGL display DPI value is also changed.
35- The resolution you set for lv_windows_create_display is the window size instead of window client size for following the convention of other Windows desktop UI infrastructures.
36- The applications based on this mode should adapt the LVGL display resolution changing for supporting window resizing properly.
37
38Prerequisites
39*************
40
41The minimum Windows OS requirement for this driver is Windows Vista RTM.
42
43If you use Windows API shim libraries like `YY-Thunks
44<https://github.com/Chuyu-Team/YY-Thunks>`__, the tested minimum Windows OS
45requirement for this driver is Windows XP RTM.
46
47According to the Windows GDI API this driver used, it is possible the minimum Windows OS
48requirement limitation for this driver is Windows 2000 RTM.
49
50Configure Windows Driver
51************************
52
53Enable the Windows driver support in lv_conf.h, by cmake compiler define or by KConfig
54
55.. code-block:: c
56
57    #define LV_USE_WINDOWS  1
58
59Usage
60*****
61
62.. code-block:: c
63
64    #include <Windows.h>
65    #include "lvgl/lvgl.h"
66    #include "lvgl/examples/lv_examples.h"
67    #include "lvgl/demos/lv_demos.h"
68
69    int main()
70    {
71        lv_init();
72
73        int32_t zoom_level = 100;
74        bool allow_dpi_override = false;
75        bool simulator_mode = false;
76        lv_display_t* display = lv_windows_create_display(
77            L"LVGL Display Window",
78            800,
79            480,
80            zoom_level,
81            allow_dpi_override,
82            simulator_mode);
83        if (!display)
84        {
85            return -1;
86        }
87
88        lv_lock();
89
90        lv_indev_t* pointer_device = lv_windows_acquire_pointer_indev(display);
91        if (!pointer_device)
92        {
93            return -1;
94        }
95
96        lv_indev_t* keypad_device = lv_windows_acquire_keypad_indev(display);
97        if (!keypad_device)
98        {
99            return -1;
100        }
101
102        lv_indev_t* encoder_device = lv_windows_acquire_encoder_indev(display);
103        if (!encoder_device)
104        {
105            return -1;
106        }
107
108        lv_demo_widgets();
109
110        lv_unlock();
111
112        while (1)
113        {
114            uint32_t time_till_next = lv_timer_handler();
115            lv_delay_ms(time_till_next);
116        }
117
118        return 0;
119    }
120