7 /* keyboard/mouse support */
9 #define MOUSE_EVENT_LBUTTON 0x01
10 #define MOUSE_EVENT_RBUTTON 0x02
11 #define MOUSE_EVENT_MBUTTON 0x04
13 /* identical to the ps/2 keyboard bits */
14 #define QEMU_SCROLL_LOCK_LED (1 << 0)
15 #define QEMU_NUM_LOCK_LED (1 << 1)
16 #define QEMU_CAPS_LOCK_LED (1 << 2)
19 #define GUI_REFRESH_INTERVAL 30
21 typedef void QEMUPutKBDEvent(void *opaque
, int keycode
);
22 typedef void QEMUPutLEDEvent(void *opaque
, int ledstate
);
23 typedef void QEMUPutMouseEvent(void *opaque
, int dx
, int dy
, int dz
, int buttons_state
);
25 typedef struct QEMUPutMouseEntry
{
26 QEMUPutMouseEvent
*qemu_put_mouse_event
;
27 void *qemu_put_mouse_event_opaque
;
28 int qemu_put_mouse_event_absolute
;
29 char *qemu_put_mouse_event_name
;
33 /* used internally by qemu for handling mice */
34 QTAILQ_ENTRY(QEMUPutMouseEntry
) node
;
37 typedef struct QEMUPutLEDEntry
{
38 QEMUPutLEDEvent
*put_led
;
40 QTAILQ_ENTRY(QEMUPutLEDEntry
) next
;
43 void qemu_add_kbd_event_handler(QEMUPutKBDEvent
*func
, void *opaque
);
44 QEMUPutMouseEntry
*qemu_add_mouse_event_handler(QEMUPutMouseEvent
*func
,
45 void *opaque
, int absolute
,
47 void qemu_remove_mouse_event_handler(QEMUPutMouseEntry
*entry
);
48 void qemu_activate_mouse_event_handler(QEMUPutMouseEntry
*entry
);
50 QEMUPutLEDEntry
*qemu_add_led_event_handler(QEMUPutLEDEvent
*func
, void *opaque
);
51 void qemu_remove_led_event_handler(QEMUPutLEDEntry
*entry
);
53 void kbd_put_keycode(int keycode
);
54 void kbd_put_ledstate(int ledstate
);
55 void kbd_mouse_event(int dx
, int dy
, int dz
, int buttons_state
);
56 int kbd_mouse_is_absolute(void);
58 struct MouseTransformInfo
{
59 /* Touchscreen resolution */
62 /* Calibration values as used/generated by tslib */
66 void do_info_mice_print(Monitor
*mon
, const QObject
*data
);
67 void do_info_mice(Monitor
*mon
, QObject
**ret_data
);
68 void do_mouse_set(Monitor
*mon
, const QDict
*qdict
);
70 /* keysym is a unicode code except for special keys (see QEMU_KEY_xxx
72 #define QEMU_KEY_ESC1(c) ((c) | 0xe100)
73 #define QEMU_KEY_BACKSPACE 0x007f
74 #define QEMU_KEY_UP QEMU_KEY_ESC1('A')
75 #define QEMU_KEY_DOWN QEMU_KEY_ESC1('B')
76 #define QEMU_KEY_RIGHT QEMU_KEY_ESC1('C')
77 #define QEMU_KEY_LEFT QEMU_KEY_ESC1('D')
78 #define QEMU_KEY_HOME QEMU_KEY_ESC1(1)
79 #define QEMU_KEY_END QEMU_KEY_ESC1(4)
80 #define QEMU_KEY_PAGEUP QEMU_KEY_ESC1(5)
81 #define QEMU_KEY_PAGEDOWN QEMU_KEY_ESC1(6)
82 #define QEMU_KEY_DELETE QEMU_KEY_ESC1(3)
84 #define QEMU_KEY_CTRL_UP 0xe400
85 #define QEMU_KEY_CTRL_DOWN 0xe401
86 #define QEMU_KEY_CTRL_LEFT 0xe402
87 #define QEMU_KEY_CTRL_RIGHT 0xe403
88 #define QEMU_KEY_CTRL_HOME 0xe404
89 #define QEMU_KEY_CTRL_END 0xe405
90 #define QEMU_KEY_CTRL_PAGEUP 0xe406
91 #define QEMU_KEY_CTRL_PAGEDOWN 0xe407
93 void kbd_put_keysym(int keysym
);
97 #define QEMU_BIG_ENDIAN_FLAG 0x01
98 #define QEMU_ALLOCATED_FLAG 0x02
99 #define QEMU_REALPIXELS_FLAG 0x04
102 uint8_t bits_per_pixel
;
103 uint8_t bytes_per_pixel
;
104 uint8_t depth
; /* color depth in bits */
105 uint32_t rmask
, gmask
, bmask
, amask
;
106 uint8_t rshift
, gshift
, bshift
, ashift
;
107 uint8_t rmax
, gmax
, bmax
, amax
;
108 uint8_t rbits
, gbits
, bbits
, abits
;
111 struct DisplaySurface
{
115 int linesize
; /* bytes per line */
118 struct PixelFormat pf
;
121 struct DisplayChangeListener
{
123 uint64_t gui_timer_interval
;
125 void (*dpy_update
)(struct DisplayState
*s
, int x
, int y
, int w
, int h
);
126 void (*dpy_resize
)(struct DisplayState
*s
);
127 void (*dpy_setdata
)(struct DisplayState
*s
);
128 void (*dpy_refresh
)(struct DisplayState
*s
);
129 void (*dpy_copy
)(struct DisplayState
*s
, int src_x
, int src_y
,
130 int dst_x
, int dst_y
, int w
, int h
);
131 void (*dpy_fill
)(struct DisplayState
*s
, int x
, int y
,
132 int w
, int h
, uint32_t c
);
133 void (*dpy_text_cursor
)(struct DisplayState
*s
, int x
, int y
);
135 struct DisplayChangeListener
*next
;
138 struct DisplayAllocator
{
139 DisplaySurface
* (*create_displaysurface
)(int width
, int height
);
140 DisplaySurface
* (*resize_displaysurface
)(DisplaySurface
*surface
, int width
, int height
);
141 void (*free_displaysurface
)(DisplaySurface
*surface
);
144 struct DisplayState
{
145 struct DisplaySurface
*surface
;
147 struct QEMUTimer
*gui_timer
;
149 struct DisplayAllocator
* allocator
;
150 struct DisplayChangeListener
* listeners
;
152 void (*mouse_set
)(int x
, int y
, int on
);
153 void (*cursor_define
)(int width
, int height
, int bpp
, int hot_x
, int hot_y
,
154 uint8_t *image
, uint8_t *mask
);
156 struct DisplayState
*next
;
159 void register_displaystate(DisplayState
*ds
);
160 DisplayState
*get_displaystate(void);
161 DisplaySurface
* qemu_create_displaysurface_from(int width
, int height
, int bpp
,
162 int linesize
, uint8_t *data
);
163 PixelFormat
qemu_different_endianness_pixelformat(int bpp
);
164 PixelFormat
qemu_default_pixelformat(int bpp
);
166 DisplayAllocator
*register_displayallocator(DisplayState
*ds
, DisplayAllocator
*da
);
168 static inline DisplaySurface
* qemu_create_displaysurface(DisplayState
*ds
, int width
, int height
)
170 return ds
->allocator
->create_displaysurface(width
, height
);
173 static inline DisplaySurface
* qemu_resize_displaysurface(DisplayState
*ds
, int width
, int height
)
175 return ds
->allocator
->resize_displaysurface(ds
->surface
, width
, height
);
178 static inline void qemu_free_displaysurface(DisplayState
*ds
)
180 ds
->allocator
->free_displaysurface(ds
->surface
);
183 static inline int is_surface_bgr(DisplaySurface
*surface
)
185 if (surface
->pf
.bits_per_pixel
== 32 && surface
->pf
.rshift
== 0)
191 static inline int is_buffer_shared(DisplaySurface
*surface
)
193 return (!(surface
->flags
& QEMU_ALLOCATED_FLAG
) &&
194 !(surface
->flags
& QEMU_REALPIXELS_FLAG
));
197 static inline void register_displaychangelistener(DisplayState
*ds
, DisplayChangeListener
*dcl
)
199 dcl
->next
= ds
->listeners
;
203 static inline void dpy_update(DisplayState
*s
, int x
, int y
, int w
, int h
)
205 struct DisplayChangeListener
*dcl
= s
->listeners
;
206 while (dcl
!= NULL
) {
207 dcl
->dpy_update(s
, x
, y
, w
, h
);
212 static inline void dpy_resize(DisplayState
*s
)
214 struct DisplayChangeListener
*dcl
= s
->listeners
;
215 while (dcl
!= NULL
) {
221 static inline void dpy_setdata(DisplayState
*s
)
223 struct DisplayChangeListener
*dcl
= s
->listeners
;
224 while (dcl
!= NULL
) {
225 if (dcl
->dpy_setdata
) dcl
->dpy_setdata(s
);
230 static inline void dpy_refresh(DisplayState
*s
)
232 struct DisplayChangeListener
*dcl
= s
->listeners
;
233 while (dcl
!= NULL
) {
234 if (dcl
->dpy_refresh
) dcl
->dpy_refresh(s
);
239 static inline void dpy_copy(struct DisplayState
*s
, int src_x
, int src_y
,
240 int dst_x
, int dst_y
, int w
, int h
) {
241 struct DisplayChangeListener
*dcl
= s
->listeners
;
242 while (dcl
!= NULL
) {
244 dcl
->dpy_copy(s
, src_x
, src_y
, dst_x
, dst_y
, w
, h
);
246 dcl
->dpy_update(s
, dst_x
, dst_y
, w
, h
);
251 static inline void dpy_fill(struct DisplayState
*s
, int x
, int y
,
252 int w
, int h
, uint32_t c
) {
253 struct DisplayChangeListener
*dcl
= s
->listeners
;
254 while (dcl
!= NULL
) {
255 if (dcl
->dpy_fill
) dcl
->dpy_fill(s
, x
, y
, w
, h
, c
);
260 static inline void dpy_cursor(struct DisplayState
*s
, int x
, int y
) {
261 struct DisplayChangeListener
*dcl
= s
->listeners
;
262 while (dcl
!= NULL
) {
263 if (dcl
->dpy_text_cursor
) dcl
->dpy_text_cursor(s
, x
, y
);
268 static inline int ds_get_linesize(DisplayState
*ds
)
270 return ds
->surface
->linesize
;
273 static inline uint8_t* ds_get_data(DisplayState
*ds
)
275 return ds
->surface
->data
;
278 static inline int ds_get_width(DisplayState
*ds
)
280 return ds
->surface
->width
;
283 static inline int ds_get_height(DisplayState
*ds
)
285 return ds
->surface
->height
;
288 static inline int ds_get_bits_per_pixel(DisplayState
*ds
)
290 return ds
->surface
->pf
.bits_per_pixel
;
293 static inline int ds_get_bytes_per_pixel(DisplayState
*ds
)
295 return ds
->surface
->pf
.bytes_per_pixel
;
298 typedef unsigned long console_ch_t
;
299 static inline void console_write_ch(console_ch_t
*dest
, uint32_t ch
)
301 cpu_to_le32wu((uint32_t *) dest
, ch
);
304 typedef void (*vga_hw_update_ptr
)(void *);
305 typedef void (*vga_hw_invalidate_ptr
)(void *);
306 typedef void (*vga_hw_screen_dump_ptr
)(void *, const char *);
307 typedef void (*vga_hw_text_update_ptr
)(void *, console_ch_t
*);
309 DisplayState
*graphic_console_init(vga_hw_update_ptr update
,
310 vga_hw_invalidate_ptr invalidate
,
311 vga_hw_screen_dump_ptr screen_dump
,
312 vga_hw_text_update_ptr text_update
,
315 void vga_hw_update(void);
316 void vga_hw_invalidate(void);
317 void vga_hw_screen_dump(const char *filename
);
318 void vga_hw_text_update(console_ch_t
*chardata
);
320 int is_graphic_console(void);
321 int is_fixedsize_console(void);
322 CharDriverState
*text_console_init(QemuOpts
*opts
);
323 void text_consoles_set_display(DisplayState
*ds
);
324 void console_select(unsigned int index
);
325 void console_color_init(DisplayState
*ds
);
326 void qemu_console_resize(DisplayState
*ds
, int width
, int height
);
327 void qemu_console_copy(DisplayState
*ds
, int src_x
, int src_y
,
328 int dst_x
, int dst_y
, int w
, int h
);
331 void sdl_display_init(DisplayState
*ds
, int full_screen
, int no_frame
);
334 void cocoa_display_init(DisplayState
*ds
, int full_screen
);
337 void vnc_display_init(DisplayState
*ds
);
338 void vnc_display_close(DisplayState
*ds
);
339 int vnc_display_open(DisplayState
*ds
, const char *display
);
340 int vnc_display_password(DisplayState
*ds
, const char *password
);
341 void do_info_vnc_print(Monitor
*mon
, const QObject
*data
);
342 void do_info_vnc(Monitor
*mon
, QObject
**ret_data
);
343 char *vnc_display_local_addr(DisplayState
*ds
);
346 void curses_display_init(DisplayState
*ds
, int full_screen
);