]> git.proxmox.com Git - qemu.git/blame - console.h
Ask password when encrypted disk image is used (Laurent Vivier)
[qemu.git] / console.h
CommitLineData
87ecb68b
PB
1#ifndef CONSOLE_H
2#define CONSOLE_H
3
4#include "qemu-char.h"
5
6/* keyboard/mouse support */
7
8#define MOUSE_EVENT_LBUTTON 0x01
9#define MOUSE_EVENT_RBUTTON 0x02
10#define MOUSE_EVENT_MBUTTON 0x04
11
12typedef void QEMUPutKBDEvent(void *opaque, int keycode);
13typedef void QEMUPutMouseEvent(void *opaque, int dx, int dy, int dz, int buttons_state);
14
15typedef struct QEMUPutMouseEntry {
16 QEMUPutMouseEvent *qemu_put_mouse_event;
17 void *qemu_put_mouse_event_opaque;
18 int qemu_put_mouse_event_absolute;
19 char *qemu_put_mouse_event_name;
20
21 /* used internally by qemu for handling mice */
22 struct QEMUPutMouseEntry *next;
23} QEMUPutMouseEntry;
24
25void qemu_add_kbd_event_handler(QEMUPutKBDEvent *func, void *opaque);
26QEMUPutMouseEntry *qemu_add_mouse_event_handler(QEMUPutMouseEvent *func,
27 void *opaque, int absolute,
28 const char *name);
29void qemu_remove_mouse_event_handler(QEMUPutMouseEntry *entry);
30
31void kbd_put_keycode(int keycode);
32void kbd_mouse_event(int dx, int dy, int dz, int buttons_state);
33int kbd_mouse_is_absolute(void);
34
a5d7eb65
AZ
35struct mouse_transform_info_s {
36 /* Touchscreen resolution */
37 int x;
38 int y;
39 /* Calibration values as used/generated by tslib */
40 int a[7];
41};
42
87ecb68b
PB
43void do_info_mice(void);
44void do_mouse_set(int index);
45
46/* keysym is a unicode code except for special keys (see QEMU_KEY_xxx
47 constants) */
48#define QEMU_KEY_ESC1(c) ((c) | 0xe100)
49#define QEMU_KEY_BACKSPACE 0x007f
50#define QEMU_KEY_UP QEMU_KEY_ESC1('A')
51#define QEMU_KEY_DOWN QEMU_KEY_ESC1('B')
52#define QEMU_KEY_RIGHT QEMU_KEY_ESC1('C')
53#define QEMU_KEY_LEFT QEMU_KEY_ESC1('D')
54#define QEMU_KEY_HOME QEMU_KEY_ESC1(1)
55#define QEMU_KEY_END QEMU_KEY_ESC1(4)
56#define QEMU_KEY_PAGEUP QEMU_KEY_ESC1(5)
57#define QEMU_KEY_PAGEDOWN QEMU_KEY_ESC1(6)
58#define QEMU_KEY_DELETE QEMU_KEY_ESC1(3)
59
60#define QEMU_KEY_CTRL_UP 0xe400
61#define QEMU_KEY_CTRL_DOWN 0xe401
62#define QEMU_KEY_CTRL_LEFT 0xe402
63#define QEMU_KEY_CTRL_RIGHT 0xe403
64#define QEMU_KEY_CTRL_HOME 0xe404
65#define QEMU_KEY_CTRL_END 0xe405
66#define QEMU_KEY_CTRL_PAGEUP 0xe406
67#define QEMU_KEY_CTRL_PAGEDOWN 0xe407
68
69void kbd_put_keysym(int keysym);
70
71/* consoles */
72
73struct DisplayState {
74 uint8_t *data;
75 int linesize;
76 int depth;
77 int bgr; /* BGR color order instead of RGB. Only valid for depth == 32 */
78 int width;
79 int height;
80 void *opaque;
81 struct QEMUTimer *gui_timer;
f442e08b 82 uint64_t gui_timer_interval;
87ecb68b
PB
83
84 void (*dpy_update)(struct DisplayState *s, int x, int y, int w, int h);
85 void (*dpy_resize)(struct DisplayState *s, int w, int h);
86 void (*dpy_refresh)(struct DisplayState *s);
87 void (*dpy_copy)(struct DisplayState *s, int src_x, int src_y,
88 int dst_x, int dst_y, int w, int h);
89 void (*dpy_fill)(struct DisplayState *s, int x, int y,
90 int w, int h, uint32_t c);
4d3b6f6e 91 void (*dpy_text_cursor)(struct DisplayState *s, int x, int y);
87ecb68b
PB
92 void (*mouse_set)(int x, int y, int on);
93 void (*cursor_define)(int width, int height, int bpp, int hot_x, int hot_y,
94 uint8_t *image, uint8_t *mask);
95};
96
97static inline void dpy_update(DisplayState *s, int x, int y, int w, int h)
98{
99 s->dpy_update(s, x, y, w, h);
100}
101
102static inline void dpy_resize(DisplayState *s, int w, int h)
103{
104 s->dpy_resize(s, w, h);
105}
106
4d3b6f6e
AZ
107static inline void dpy_cursor(DisplayState *s, int x, int y)
108{
109 if (s->dpy_text_cursor)
110 s->dpy_text_cursor(s, x, y);
111}
112
113typedef unsigned long console_ch_t;
114static inline void console_write_ch(console_ch_t *dest, uint32_t ch)
115{
116 cpu_to_le32wu((uint32_t *) dest, ch);
117}
118
87ecb68b
PB
119typedef void (*vga_hw_update_ptr)(void *);
120typedef void (*vga_hw_invalidate_ptr)(void *);
121typedef void (*vga_hw_screen_dump_ptr)(void *, const char *);
4d3b6f6e 122typedef void (*vga_hw_text_update_ptr)(void *, console_ch_t *);
87ecb68b
PB
123
124TextConsole *graphic_console_init(DisplayState *ds, vga_hw_update_ptr update,
125 vga_hw_invalidate_ptr invalidate,
126 vga_hw_screen_dump_ptr screen_dump,
4d3b6f6e 127 vga_hw_text_update_ptr text_update,
87ecb68b
PB
128 void *opaque);
129void vga_hw_update(void);
130void vga_hw_invalidate(void);
131void vga_hw_screen_dump(const char *filename);
4d3b6f6e 132void vga_hw_text_update(console_ch_t *chardata);
87ecb68b
PB
133
134int is_graphic_console(void);
135CharDriverState *text_console_init(DisplayState *ds, const char *p);
136void console_select(unsigned int index);
137void console_color_init(DisplayState *ds);
c60e08d9 138void qemu_console_resize(QEMUConsole *console, int width, int height);
87ecb68b
PB
139
140/* sdl.c */
141void sdl_display_init(DisplayState *ds, int full_screen, int no_frame);
142
143/* cocoa.m */
144void cocoa_display_init(DisplayState *ds, int full_screen);
145
146/* vnc.c */
147void vnc_display_init(DisplayState *ds);
148void vnc_display_close(DisplayState *ds);
149int vnc_display_open(DisplayState *ds, const char *display);
150int vnc_display_password(DisplayState *ds, const char *password);
151void do_info_vnc(void);
152
4d3b6f6e
AZ
153/* curses.c */
154void curses_display_init(DisplayState *ds, int full_screen);
155
87ecb68b
PB
156/* x_keymap.c */
157extern uint8_t _translate_keycode(const int key);
158
159/* FIXME: term_printf et al should probably go elsewhere so everything
160 does not need to include console.h */
161/* monitor.c */
162void monitor_init(CharDriverState *hd, int show_banner);
396f9297 163void monitor_start_input(void);
87ecb68b
PB
164void term_puts(const char *str);
165void term_vprintf(const char *fmt, va_list ap);
166void term_printf(const char *fmt, ...) __attribute__ ((__format__ (__printf__, 1, 2)));
167void term_print_filename(const char *filename);
168void term_flush(void);
169void term_print_help(void);
170void monitor_readline(const char *prompt, int is_password,
171 char *buf, int buf_size);
172
173/* readline.c */
174typedef void ReadLineFunc(void *opaque, const char *str);
175
176extern int completion_index;
177void add_completion(const char *str);
178void readline_handle_byte(int ch);
179void readline_find_completion(const char *cmdline);
180const char *readline_get_history(unsigned int index);
181void readline_start(const char *prompt, int is_password,
182 ReadLineFunc *readline_func, void *opaque);
183
184#endif