root / include / ui / console.h @ 380cd056
History | View | Annotate | Download (10.5 kB)
1 |
#ifndef CONSOLE_H
|
---|---|
2 |
#define CONSOLE_H
|
3 |
|
4 |
#include "ui/qemu-pixman.h" |
5 |
#include "qapi/qmp/qdict.h" |
6 |
#include "qemu/notify.h" |
7 |
#include "monitor/monitor.h" |
8 |
#include "trace.h" |
9 |
#include "qapi-types.h" |
10 |
#include "qapi/error.h" |
11 |
|
12 |
/* keyboard/mouse support */
|
13 |
|
14 |
#define MOUSE_EVENT_LBUTTON 0x01 |
15 |
#define MOUSE_EVENT_RBUTTON 0x02 |
16 |
#define MOUSE_EVENT_MBUTTON 0x04 |
17 |
|
18 |
/* identical to the ps/2 keyboard bits */
|
19 |
#define QEMU_SCROLL_LOCK_LED (1 << 0) |
20 |
#define QEMU_NUM_LOCK_LED (1 << 1) |
21 |
#define QEMU_CAPS_LOCK_LED (1 << 2) |
22 |
|
23 |
/* in ms */
|
24 |
#define GUI_REFRESH_INTERVAL 30 |
25 |
|
26 |
typedef void QEMUPutKBDEvent(void *opaque, int keycode); |
27 |
typedef void QEMUPutLEDEvent(void *opaque, int ledstate); |
28 |
typedef void QEMUPutMouseEvent(void *opaque, int dx, int dy, int dz, int buttons_state); |
29 |
|
30 |
typedef struct QEMUPutMouseEntry { |
31 |
QEMUPutMouseEvent *qemu_put_mouse_event; |
32 |
void *qemu_put_mouse_event_opaque;
|
33 |
int qemu_put_mouse_event_absolute;
|
34 |
char *qemu_put_mouse_event_name;
|
35 |
|
36 |
int index;
|
37 |
|
38 |
/* used internally by qemu for handling mice */
|
39 |
QTAILQ_ENTRY(QEMUPutMouseEntry) node; |
40 |
} QEMUPutMouseEntry; |
41 |
|
42 |
typedef struct QEMUPutLEDEntry { |
43 |
QEMUPutLEDEvent *put_led; |
44 |
void *opaque;
|
45 |
QTAILQ_ENTRY(QEMUPutLEDEntry) next; |
46 |
} QEMUPutLEDEntry; |
47 |
|
48 |
void qemu_add_kbd_event_handler(QEMUPutKBDEvent *func, void *opaque); |
49 |
void qemu_remove_kbd_event_handler(void); |
50 |
QEMUPutMouseEntry *qemu_add_mouse_event_handler(QEMUPutMouseEvent *func, |
51 |
void *opaque, int absolute, |
52 |
const char *name); |
53 |
void qemu_remove_mouse_event_handler(QEMUPutMouseEntry *entry);
|
54 |
void qemu_activate_mouse_event_handler(QEMUPutMouseEntry *entry);
|
55 |
|
56 |
QEMUPutLEDEntry *qemu_add_led_event_handler(QEMUPutLEDEvent *func, void *opaque);
|
57 |
void qemu_remove_led_event_handler(QEMUPutLEDEntry *entry);
|
58 |
|
59 |
void kbd_put_keycode(int keycode); |
60 |
void kbd_put_ledstate(int ledstate); |
61 |
void kbd_mouse_event(int dx, int dy, int dz, int buttons_state); |
62 |
|
63 |
/* Does the current mouse generate absolute events */
|
64 |
int kbd_mouse_is_absolute(void); |
65 |
void qemu_add_mouse_mode_change_notifier(Notifier *notify);
|
66 |
void qemu_remove_mouse_mode_change_notifier(Notifier *notify);
|
67 |
|
68 |
/* Of all the mice, is there one that generates absolute events */
|
69 |
int kbd_mouse_has_absolute(void); |
70 |
|
71 |
struct MouseTransformInfo {
|
72 |
/* Touchscreen resolution */
|
73 |
int x;
|
74 |
int y;
|
75 |
/* Calibration values as used/generated by tslib */
|
76 |
int a[7]; |
77 |
}; |
78 |
|
79 |
void do_mouse_set(Monitor *mon, const QDict *qdict); |
80 |
|
81 |
/* keysym is a unicode code except for special keys (see QEMU_KEY_xxx
|
82 |
constants) */
|
83 |
#define QEMU_KEY_ESC1(c) ((c) | 0xe100) |
84 |
#define QEMU_KEY_BACKSPACE 0x007f |
85 |
#define QEMU_KEY_UP QEMU_KEY_ESC1('A') |
86 |
#define QEMU_KEY_DOWN QEMU_KEY_ESC1('B') |
87 |
#define QEMU_KEY_RIGHT QEMU_KEY_ESC1('C') |
88 |
#define QEMU_KEY_LEFT QEMU_KEY_ESC1('D') |
89 |
#define QEMU_KEY_HOME QEMU_KEY_ESC1(1) |
90 |
#define QEMU_KEY_END QEMU_KEY_ESC1(4) |
91 |
#define QEMU_KEY_PAGEUP QEMU_KEY_ESC1(5) |
92 |
#define QEMU_KEY_PAGEDOWN QEMU_KEY_ESC1(6) |
93 |
#define QEMU_KEY_DELETE QEMU_KEY_ESC1(3) |
94 |
|
95 |
#define QEMU_KEY_CTRL_UP 0xe400 |
96 |
#define QEMU_KEY_CTRL_DOWN 0xe401 |
97 |
#define QEMU_KEY_CTRL_LEFT 0xe402 |
98 |
#define QEMU_KEY_CTRL_RIGHT 0xe403 |
99 |
#define QEMU_KEY_CTRL_HOME 0xe404 |
100 |
#define QEMU_KEY_CTRL_END 0xe405 |
101 |
#define QEMU_KEY_CTRL_PAGEUP 0xe406 |
102 |
#define QEMU_KEY_CTRL_PAGEDOWN 0xe407 |
103 |
|
104 |
void kbd_put_keysym(int keysym); |
105 |
|
106 |
/* consoles */
|
107 |
|
108 |
#define QEMU_BIG_ENDIAN_FLAG 0x01 |
109 |
#define QEMU_ALLOCATED_FLAG 0x02 |
110 |
|
111 |
struct PixelFormat {
|
112 |
uint8_t bits_per_pixel; |
113 |
uint8_t bytes_per_pixel; |
114 |
uint8_t depth; /* color depth in bits */
|
115 |
uint32_t rmask, gmask, bmask, amask; |
116 |
uint8_t rshift, gshift, bshift, ashift; |
117 |
uint8_t rmax, gmax, bmax, amax; |
118 |
uint8_t rbits, gbits, bbits, abits; |
119 |
}; |
120 |
|
121 |
struct DisplaySurface {
|
122 |
pixman_format_code_t format; |
123 |
pixman_image_t *image; |
124 |
uint8_t flags; |
125 |
|
126 |
struct PixelFormat pf;
|
127 |
}; |
128 |
|
129 |
/* cursor data format is 32bit RGBA */
|
130 |
typedef struct QEMUCursor { |
131 |
int width, height;
|
132 |
int hot_x, hot_y;
|
133 |
int refcount;
|
134 |
uint32_t data[]; |
135 |
} QEMUCursor; |
136 |
|
137 |
QEMUCursor *cursor_alloc(int width, int height); |
138 |
void cursor_get(QEMUCursor *c);
|
139 |
void cursor_put(QEMUCursor *c);
|
140 |
QEMUCursor *cursor_builtin_hidden(void);
|
141 |
QEMUCursor *cursor_builtin_left_ptr(void);
|
142 |
void cursor_print_ascii_art(QEMUCursor *c, const char *prefix); |
143 |
int cursor_get_mono_bpl(QEMUCursor *c);
|
144 |
void cursor_set_mono(QEMUCursor *c,
|
145 |
uint32_t foreground, uint32_t background, uint8_t *image, |
146 |
int transparent, uint8_t *mask);
|
147 |
void cursor_get_mono_image(QEMUCursor *c, int foreground, uint8_t *mask); |
148 |
void cursor_get_mono_mask(QEMUCursor *c, int transparent, uint8_t *mask); |
149 |
|
150 |
typedef struct DisplayChangeListenerOps { |
151 |
const char *dpy_name; |
152 |
|
153 |
void (*dpy_refresh)(DisplayChangeListener *dcl);
|
154 |
|
155 |
void (*dpy_gfx_update)(DisplayChangeListener *dcl,
|
156 |
int x, int y, int w, int h); |
157 |
void (*dpy_gfx_switch)(DisplayChangeListener *dcl,
|
158 |
struct DisplaySurface *new_surface);
|
159 |
void (*dpy_gfx_copy)(DisplayChangeListener *dcl,
|
160 |
int src_x, int src_y, |
161 |
int dst_x, int dst_y, int w, int h); |
162 |
|
163 |
void (*dpy_text_cursor)(DisplayChangeListener *dcl,
|
164 |
int x, int y); |
165 |
void (*dpy_text_resize)(DisplayChangeListener *dcl,
|
166 |
int w, int h); |
167 |
void (*dpy_text_update)(DisplayChangeListener *dcl,
|
168 |
int x, int y, int w, int h); |
169 |
|
170 |
void (*dpy_mouse_set)(DisplayChangeListener *dcl,
|
171 |
int x, int y, int on); |
172 |
void (*dpy_cursor_define)(DisplayChangeListener *dcl,
|
173 |
QEMUCursor *cursor); |
174 |
} DisplayChangeListenerOps; |
175 |
|
176 |
struct DisplayChangeListener {
|
177 |
int idle;
|
178 |
uint64_t gui_timer_interval; |
179 |
const DisplayChangeListenerOps *ops;
|
180 |
DisplayState *ds; |
181 |
|
182 |
QLIST_ENTRY(DisplayChangeListener) next; |
183 |
}; |
184 |
|
185 |
DisplayState *init_displaystate(void);
|
186 |
DisplaySurface* qemu_create_displaysurface_from(int width, int height, int bpp, |
187 |
int linesize, uint8_t *data,
|
188 |
bool byteswap);
|
189 |
PixelFormat qemu_different_endianness_pixelformat(int bpp);
|
190 |
PixelFormat qemu_default_pixelformat(int bpp);
|
191 |
|
192 |
DisplaySurface *qemu_create_displaysurface(int width, int height); |
193 |
void qemu_free_displaysurface(DisplaySurface *surface);
|
194 |
|
195 |
static inline int is_surface_bgr(DisplaySurface *surface) |
196 |
{ |
197 |
if (surface->pf.bits_per_pixel == 32 && surface->pf.rshift == 0) |
198 |
return 1; |
199 |
else
|
200 |
return 0; |
201 |
} |
202 |
|
203 |
static inline int is_buffer_shared(DisplaySurface *surface) |
204 |
{ |
205 |
return !(surface->flags & QEMU_ALLOCATED_FLAG);
|
206 |
} |
207 |
|
208 |
void register_displaychangelistener(DisplayState *ds,
|
209 |
DisplayChangeListener *dcl); |
210 |
void unregister_displaychangelistener(DisplayChangeListener *dcl);
|
211 |
|
212 |
void dpy_gfx_update(QemuConsole *con, int x, int y, int w, int h); |
213 |
void dpy_gfx_replace_surface(QemuConsole *con,
|
214 |
DisplaySurface *surface); |
215 |
void dpy_refresh(DisplayState *s);
|
216 |
void dpy_gfx_copy(QemuConsole *con, int src_x, int src_y, |
217 |
int dst_x, int dst_y, int w, int h); |
218 |
void dpy_text_cursor(QemuConsole *con, int x, int y); |
219 |
void dpy_text_update(QemuConsole *con, int x, int y, int w, int h); |
220 |
void dpy_text_resize(QemuConsole *con, int w, int h); |
221 |
void dpy_mouse_set(QemuConsole *con, int x, int y, int on); |
222 |
void dpy_cursor_define(QemuConsole *con, QEMUCursor *cursor);
|
223 |
bool dpy_cursor_define_supported(QemuConsole *con);
|
224 |
|
225 |
static inline int surface_stride(DisplaySurface *s) |
226 |
{ |
227 |
return pixman_image_get_stride(s->image);
|
228 |
} |
229 |
|
230 |
static inline void *surface_data(DisplaySurface *s) |
231 |
{ |
232 |
return pixman_image_get_data(s->image);
|
233 |
} |
234 |
|
235 |
static inline int surface_width(DisplaySurface *s) |
236 |
{ |
237 |
return pixman_image_get_width(s->image);
|
238 |
} |
239 |
|
240 |
static inline int surface_height(DisplaySurface *s) |
241 |
{ |
242 |
return pixman_image_get_height(s->image);
|
243 |
} |
244 |
|
245 |
static inline int surface_bits_per_pixel(DisplaySurface *s) |
246 |
{ |
247 |
int bits = PIXMAN_FORMAT_BPP(s->format);
|
248 |
return bits;
|
249 |
} |
250 |
|
251 |
static inline int surface_bytes_per_pixel(DisplaySurface *s) |
252 |
{ |
253 |
int bits = PIXMAN_FORMAT_BPP(s->format);
|
254 |
return (bits + 7) / 8; |
255 |
} |
256 |
|
257 |
#ifdef CONFIG_CURSES
|
258 |
#include <curses.h> |
259 |
typedef chtype console_ch_t;
|
260 |
#else
|
261 |
typedef unsigned long console_ch_t; |
262 |
#endif
|
263 |
static inline void console_write_ch(console_ch_t *dest, uint32_t ch) |
264 |
{ |
265 |
if (!(ch & 0xff)) |
266 |
ch |= ' ';
|
267 |
*dest = ch; |
268 |
} |
269 |
|
270 |
typedef struct GraphicHwOps { |
271 |
void (*invalidate)(void *opaque); |
272 |
void (*gfx_update)(void *opaque); |
273 |
void (*text_update)(void *opaque, console_ch_t *text); |
274 |
} GraphicHwOps; |
275 |
|
276 |
QemuConsole *graphic_console_init(const GraphicHwOps *ops,
|
277 |
void *opaque);
|
278 |
|
279 |
void graphic_hw_update(QemuConsole *con);
|
280 |
void graphic_hw_invalidate(QemuConsole *con);
|
281 |
void graphic_hw_text_update(QemuConsole *con, console_ch_t *chardata);
|
282 |
|
283 |
int is_graphic_console(void); |
284 |
int is_fixedsize_console(void); |
285 |
void text_consoles_set_display(DisplayState *ds);
|
286 |
void console_select(unsigned int index); |
287 |
void console_color_init(DisplayState *ds);
|
288 |
void qemu_console_resize(QemuConsole *con, int width, int height); |
289 |
void qemu_console_copy(QemuConsole *con, int src_x, int src_y, |
290 |
int dst_x, int dst_y, int w, int h); |
291 |
DisplaySurface *qemu_console_surface(QemuConsole *con); |
292 |
DisplayState *qemu_console_displaystate(QemuConsole *console); |
293 |
|
294 |
typedef CharDriverState *(VcHandler)(ChardevVC *vc);
|
295 |
|
296 |
CharDriverState *vc_init(ChardevVC *vc); |
297 |
void register_vc_handler(VcHandler *handler);
|
298 |
|
299 |
/* sdl.c */
|
300 |
void sdl_display_init(DisplayState *ds, int full_screen, int no_frame); |
301 |
|
302 |
/* cocoa.m */
|
303 |
void cocoa_display_init(DisplayState *ds, int full_screen); |
304 |
|
305 |
/* vnc.c */
|
306 |
void vnc_display_init(DisplayState *ds);
|
307 |
void vnc_display_open(DisplayState *ds, const char *display, Error **errp); |
308 |
void vnc_display_add_client(DisplayState *ds, int csock, int skipauth); |
309 |
char *vnc_display_local_addr(DisplayState *ds);
|
310 |
#ifdef CONFIG_VNC
|
311 |
int vnc_display_password(DisplayState *ds, const char *password); |
312 |
int vnc_display_pw_expire(DisplayState *ds, time_t expires);
|
313 |
#else
|
314 |
static inline int vnc_display_password(DisplayState *ds, const char *password) |
315 |
{ |
316 |
return -ENODEV;
|
317 |
} |
318 |
static inline int vnc_display_pw_expire(DisplayState *ds, time_t expires) |
319 |
{ |
320 |
return -ENODEV;
|
321 |
}; |
322 |
#endif
|
323 |
|
324 |
/* curses.c */
|
325 |
void curses_display_init(DisplayState *ds, int full_screen); |
326 |
|
327 |
/* input.c */
|
328 |
int index_from_key(const char *key); |
329 |
int index_from_keycode(int code); |
330 |
|
331 |
/* gtk.c */
|
332 |
void early_gtk_display_init(void); |
333 |
void gtk_display_init(DisplayState *ds);
|
334 |
|
335 |
#endif
|