mirror of
https://gitlab.com/qemu-project/qemu
synced 2024-11-05 20:35:44 +00:00
Add an ncurses UI.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3976 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
parent
c0be16d39f
commit
4d3b6f6e12
21 changed files with 1238 additions and 34 deletions
6
Makefile
6
Makefile
|
@ -99,6 +99,9 @@ OBJS+=$(addprefix audio/, $(AUDIO_OBJS))
|
|||
ifdef CONFIG_SDL
|
||||
OBJS+=sdl.o x_keymap.o
|
||||
endif
|
||||
ifdef CONFIG_CURSES
|
||||
OBJS+=curses.o
|
||||
endif
|
||||
OBJS+=vnc.o d3des.o
|
||||
|
||||
ifdef CONFIG_COCOA
|
||||
|
@ -122,6 +125,9 @@ sdl.o: sdl.c keymaps.c sdl_keysym.h
|
|||
vnc.o: vnc.c keymaps.c sdl_keysym.h vnchextile.h d3des.c d3des.h
|
||||
$(CC) $(CFLAGS) $(CPPFLAGS) $(CONFIG_VNC_TLS_CFLAGS) -c -o $@ $<
|
||||
|
||||
curses.o: curses.c keymaps.c curses_keys.h
|
||||
$(CC) $(CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) -c -o $@ $<
|
||||
|
||||
audio/sdlaudio.o: audio/sdlaudio.c
|
||||
$(CC) $(CFLAGS) $(CPPFLAGS) $(SDL_CFLAGS) -c -o $@ $<
|
||||
|
||||
|
|
|
@ -647,7 +647,7 @@ main.o: CFLAGS+=-p
|
|||
endif
|
||||
|
||||
$(QEMU_PROG): $(OBJS) ../libqemu_common.a libqemu.a
|
||||
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) $(COCOA_LIBS)
|
||||
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) $(COCOA_LIBS) $(CURSES_LIBS)
|
||||
|
||||
endif # !CONFIG_USER_ONLY
|
||||
|
||||
|
|
30
configure
vendored
30
configure
vendored
|
@ -108,6 +108,7 @@ linux_user="no"
|
|||
darwin_user="no"
|
||||
build_docs="no"
|
||||
uname_release=""
|
||||
curses="yes"
|
||||
|
||||
# OS specific
|
||||
targetos=`uname -s`
|
||||
|
@ -323,6 +324,8 @@ for opt do
|
|||
;;
|
||||
--disable-werror) werror="no"
|
||||
;;
|
||||
--disable-curses) curses="no"
|
||||
;;
|
||||
*) echo "ERROR: unknown option $opt"; show_help="yes"
|
||||
;;
|
||||
esac
|
||||
|
@ -669,6 +672,20 @@ EOF
|
|||
fi
|
||||
fi
|
||||
|
||||
##########################################
|
||||
# curses probe
|
||||
|
||||
if test "$curses" = "yes" ; then
|
||||
curses=no
|
||||
cat > $TMPC << EOF
|
||||
#include <curses.h>
|
||||
int main(void) { return curses_version(); }
|
||||
EOF
|
||||
if $cc -o $TMPE $TMPC -lcurses 2> /dev/null ; then
|
||||
curses=yes
|
||||
fi
|
||||
fi # test "$curses"
|
||||
|
||||
# Check if tools are available to build documentation.
|
||||
if [ -x "`which texi2html 2>/dev/null`" ] && \
|
||||
[ -x "`which pod2man 2>/dev/null`" ]; then
|
||||
|
@ -720,6 +737,7 @@ echo "SDL support $sdl"
|
|||
if test "$sdl" != "no" ; then
|
||||
echo "SDL static link $sdl_static"
|
||||
fi
|
||||
echo "curses support $curses"
|
||||
echo "mingw32 support $mingw32"
|
||||
echo "Adlib support $adlib"
|
||||
echo "AC97 support $ac97"
|
||||
|
@ -974,8 +992,13 @@ if test "$sdl1" = "yes" ; then
|
|||
fi
|
||||
fi
|
||||
if test "$cocoa" = "yes" ; then
|
||||
echo "#define CONFIG_COCOA 1" >> $config_h
|
||||
echo "CONFIG_COCOA=yes" >> $config_mak
|
||||
echo "#define CONFIG_COCOA 1" >> $config_h
|
||||
echo "CONFIG_COCOA=yes" >> $config_mak
|
||||
fi
|
||||
if test "$curses" = "yes" ; then
|
||||
echo "#define CONFIG_CURSES 1" >> $config_h
|
||||
echo "CONFIG_CURSES=yes" >> $config_mak
|
||||
echo "CURSES_LIBS=-lcurses" >> $config_mak
|
||||
fi
|
||||
|
||||
# XXX: suppress that
|
||||
|
@ -1040,7 +1063,8 @@ if test "$target_user_only" = "no" -a "$check_gfx" = "yes" \
|
|||
-a "$sdl" = "no" -a "$cocoa" = "no" ; then
|
||||
echo "ERROR: QEMU requires SDL or Cocoa for graphical output"
|
||||
echo "To build QEMU without graphical output configure with --disable-gfx-check"
|
||||
echo "Note that this will disable all output from the virtual graphics card."
|
||||
echo "Note that this will disable all output from the virtual graphics card"
|
||||
echo "except through VNC or curses."
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
|
|
113
console.c
113
console.c
|
@ -121,6 +121,7 @@ struct TextConsole {
|
|||
vga_hw_update_ptr hw_update;
|
||||
vga_hw_invalidate_ptr hw_invalidate;
|
||||
vga_hw_screen_dump_ptr hw_screen_dump;
|
||||
vga_hw_text_update_ptr hw_text_update;
|
||||
void *hw;
|
||||
|
||||
int g_width, g_height;
|
||||
|
@ -135,6 +136,7 @@ struct TextConsole {
|
|||
TextAttributes t_attrib_default; /* default text attributes */
|
||||
TextAttributes t_attrib; /* currently active text attributes */
|
||||
TextCell *cells;
|
||||
int text_x[2], text_y[2], cursor_invalidate;
|
||||
|
||||
enum TTYState state;
|
||||
int esc_params[MAX_ESC_PARAMS];
|
||||
|
@ -171,6 +173,12 @@ void vga_hw_screen_dump(const char *filename)
|
|||
consoles[0]->hw_screen_dump(consoles[0]->hw, filename);
|
||||
}
|
||||
|
||||
void vga_hw_text_update(console_ch_t *chardata)
|
||||
{
|
||||
if (active_console && active_console->hw_text_update)
|
||||
active_console->hw_text_update(active_console->hw, chardata);
|
||||
}
|
||||
|
||||
/* convert a RGBA color to a color index usable in graphic primitives */
|
||||
static unsigned int vga_get_color(DisplayState *ds, unsigned int rgba)
|
||||
{
|
||||
|
@ -515,12 +523,25 @@ static void text_console_resize(TextConsole *s)
|
|||
s->cells = cells;
|
||||
}
|
||||
|
||||
static inline void text_update_xy(TextConsole *s, int x, int y)
|
||||
{
|
||||
s->text_x[0] = MIN(s->text_x[0], x);
|
||||
s->text_x[1] = MAX(s->text_x[1], x);
|
||||
s->text_y[0] = MIN(s->text_y[0], y);
|
||||
s->text_y[1] = MAX(s->text_y[1], y);
|
||||
}
|
||||
|
||||
static void update_xy(TextConsole *s, int x, int y)
|
||||
{
|
||||
TextCell *c;
|
||||
int y1, y2;
|
||||
|
||||
if (s == active_console) {
|
||||
if (!s->ds->depth) {
|
||||
text_update_xy(s, x, y);
|
||||
return;
|
||||
}
|
||||
|
||||
y1 = (s->y_base + y) % s->total_height;
|
||||
y2 = y1 - s->y_displayed;
|
||||
if (y2 < 0)
|
||||
|
@ -542,6 +563,12 @@ static void console_show_cursor(TextConsole *s, int show)
|
|||
|
||||
if (s == active_console) {
|
||||
int x = s->x;
|
||||
|
||||
if (!s->ds->depth) {
|
||||
s->cursor_invalidate = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
if (x >= s->width) {
|
||||
x = s->width - 1;
|
||||
}
|
||||
|
@ -571,6 +598,14 @@ static void console_refresh(TextConsole *s)
|
|||
|
||||
if (s != active_console)
|
||||
return;
|
||||
if (!s->ds->depth) {
|
||||
s->text_x[0] = 0;
|
||||
s->text_y[0] = 0;
|
||||
s->text_x[1] = s->width - 1;
|
||||
s->text_y[1] = s->height - 1;
|
||||
s->cursor_invalidate = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
vga_fill_rect(s->ds, 0, 0, s->ds->width, s->ds->height,
|
||||
color_table[0][COLOR_BLACK]);
|
||||
|
@ -648,6 +683,14 @@ static void console_put_lf(TextConsole *s)
|
|||
c++;
|
||||
}
|
||||
if (s == active_console && s->y_displayed == s->y_base) {
|
||||
if (!s->ds->depth) {
|
||||
s->text_x[0] = 0;
|
||||
s->text_y[0] = 0;
|
||||
s->text_x[1] = s->width - 1;
|
||||
s->text_y[1] = s->height - 1;
|
||||
return;
|
||||
}
|
||||
|
||||
vga_bitblt(s->ds, 0, FONT_HEIGHT, 0, 0,
|
||||
s->width * FONT_WIDTH,
|
||||
(s->height - 1) * FONT_HEIGHT);
|
||||
|
@ -998,21 +1041,7 @@ void console_select(unsigned int index)
|
|||
s = consoles[index];
|
||||
if (s) {
|
||||
active_console = s;
|
||||
if (s->console_type != GRAPHIC_CONSOLE) {
|
||||
if (s->g_width != s->ds->width ||
|
||||
s->g_height != s->ds->height) {
|
||||
if (s->console_type == TEXT_CONSOLE_FIXED_SIZE) {
|
||||
dpy_resize(s->ds, s->g_width, s->g_height);
|
||||
} else {
|
||||
s->g_width = s->ds->width;
|
||||
s->g_height = s->ds->height;
|
||||
text_console_resize(s);
|
||||
}
|
||||
}
|
||||
console_refresh(s);
|
||||
} else {
|
||||
vga_hw_invalidate();
|
||||
}
|
||||
vga_hw_invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1116,6 +1145,52 @@ void kbd_put_keysym(int keysym)
|
|||
}
|
||||
}
|
||||
|
||||
static void text_console_invalidate(void *opaque)
|
||||
{
|
||||
TextConsole *s = (TextConsole *) opaque;
|
||||
|
||||
if (s->console_type != GRAPHIC_CONSOLE) {
|
||||
if (s->g_width != s->ds->width ||
|
||||
s->g_height != s->ds->height) {
|
||||
if (s->console_type == TEXT_CONSOLE_FIXED_SIZE)
|
||||
dpy_resize(s->ds, s->g_width, s->g_height);
|
||||
else {
|
||||
s->g_width = s->ds->width;
|
||||
s->g_height = s->ds->height;
|
||||
text_console_resize(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
console_refresh(s);
|
||||
}
|
||||
|
||||
static void text_console_update(void *opaque, console_ch_t *chardata)
|
||||
{
|
||||
TextConsole *s = (TextConsole *) opaque;
|
||||
int i, j, src;
|
||||
|
||||
if (s->text_x[0] <= s->text_x[1]) {
|
||||
src = (s->y_base + s->text_y[0]) * s->width;
|
||||
chardata += s->text_y[0] * s->width;
|
||||
for (i = s->text_y[0]; i <= s->text_y[1]; i ++)
|
||||
for (j = 0; j < s->width; j ++, src ++)
|
||||
console_write_ch(chardata ++, s->cells[src].ch |
|
||||
(s->cells[src].t_attrib.fgcol << 12) |
|
||||
(s->cells[src].t_attrib.bgcol << 8) |
|
||||
(s->cells[src].t_attrib.bold << 21));
|
||||
dpy_update(s->ds, s->text_x[0], s->text_y[0],
|
||||
s->text_x[1] - s->text_x[0], i - s->text_y[0]);
|
||||
s->text_x[0] = s->width;
|
||||
s->text_y[0] = s->height;
|
||||
s->text_x[1] = 0;
|
||||
s->text_y[1] = 0;
|
||||
}
|
||||
if (s->cursor_invalidate) {
|
||||
dpy_cursor(s->ds, s->x, s->y);
|
||||
s->cursor_invalidate = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static TextConsole *new_console(DisplayState *ds, console_type_t console_type)
|
||||
{
|
||||
TextConsole *s;
|
||||
|
@ -1150,6 +1225,7 @@ static TextConsole *new_console(DisplayState *ds, console_type_t console_type)
|
|||
TextConsole *graphic_console_init(DisplayState *ds, vga_hw_update_ptr update,
|
||||
vga_hw_invalidate_ptr invalidate,
|
||||
vga_hw_screen_dump_ptr screen_dump,
|
||||
vga_hw_text_update_ptr text_update,
|
||||
void *opaque)
|
||||
{
|
||||
TextConsole *s;
|
||||
|
@ -1160,13 +1236,14 @@ TextConsole *graphic_console_init(DisplayState *ds, vga_hw_update_ptr update,
|
|||
s->hw_update = update;
|
||||
s->hw_invalidate = invalidate;
|
||||
s->hw_screen_dump = screen_dump;
|
||||
s->hw_text_update = text_update;
|
||||
s->hw = opaque;
|
||||
return s;
|
||||
}
|
||||
|
||||
int is_graphic_console(void)
|
||||
{
|
||||
return active_console->console_type == GRAPHIC_CONSOLE;
|
||||
return active_console && active_console->console_type == GRAPHIC_CONSOLE;
|
||||
}
|
||||
|
||||
void console_color_init(DisplayState *ds)
|
||||
|
@ -1234,6 +1311,10 @@ CharDriverState *text_console_init(DisplayState *ds, const char *p)
|
|||
s->g_width = width;
|
||||
s->g_height = height;
|
||||
|
||||
s->hw_invalidate = text_console_invalidate;
|
||||
s->hw_text_update = text_console_update;
|
||||
s->hw = s;
|
||||
|
||||
/* Set text attribute defaults */
|
||||
s->t_attrib_default.bold = 0;
|
||||
s->t_attrib_default.uline = 0;
|
||||
|
|
19
console.h
19
console.h
|
@ -79,6 +79,7 @@ struct DisplayState {
|
|||
int dst_x, int dst_y, int w, int h);
|
||||
void (*dpy_fill)(struct DisplayState *s, int x, int y,
|
||||
int w, int h, uint32_t c);
|
||||
void (*dpy_text_cursor)(struct DisplayState *s, int x, int y);
|
||||
void (*mouse_set)(int x, int y, int on);
|
||||
void (*cursor_define)(int width, int height, int bpp, int hot_x, int hot_y,
|
||||
uint8_t *image, uint8_t *mask);
|
||||
|
@ -94,17 +95,32 @@ static inline void dpy_resize(DisplayState *s, int w, int h)
|
|||
s->dpy_resize(s, w, h);
|
||||
}
|
||||
|
||||
static inline void dpy_cursor(DisplayState *s, int x, int y)
|
||||
{
|
||||
if (s->dpy_text_cursor)
|
||||
s->dpy_text_cursor(s, x, y);
|
||||
}
|
||||
|
||||
typedef unsigned long console_ch_t;
|
||||
static inline void console_write_ch(console_ch_t *dest, uint32_t ch)
|
||||
{
|
||||
cpu_to_le32wu((uint32_t *) dest, ch);
|
||||
}
|
||||
|
||||
typedef void (*vga_hw_update_ptr)(void *);
|
||||
typedef void (*vga_hw_invalidate_ptr)(void *);
|
||||
typedef void (*vga_hw_screen_dump_ptr)(void *, const char *);
|
||||
typedef void (*vga_hw_text_update_ptr)(void *, console_ch_t *);
|
||||
|
||||
TextConsole *graphic_console_init(DisplayState *ds, vga_hw_update_ptr update,
|
||||
vga_hw_invalidate_ptr invalidate,
|
||||
vga_hw_screen_dump_ptr screen_dump,
|
||||
vga_hw_text_update_ptr text_update,
|
||||
void *opaque);
|
||||
void vga_hw_update(void);
|
||||
void vga_hw_invalidate(void);
|
||||
void vga_hw_screen_dump(const char *filename);
|
||||
void vga_hw_text_update(console_ch_t *chardata);
|
||||
|
||||
int is_graphic_console(void);
|
||||
CharDriverState *text_console_init(DisplayState *ds, const char *p);
|
||||
|
@ -124,6 +140,9 @@ int vnc_display_open(DisplayState *ds, const char *display);
|
|||
int vnc_display_password(DisplayState *ds, const char *password);
|
||||
void do_info_vnc(void);
|
||||
|
||||
/* curses.c */
|
||||
void curses_display_init(DisplayState *ds, int full_screen);
|
||||
|
||||
/* x_keymap.c */
|
||||
extern uint8_t _translate_keycode(const int key);
|
||||
|
||||
|
|
370
curses.c
Normal file
370
curses.c
Normal file
|
@ -0,0 +1,370 @@
|
|||
/*
|
||||
* QEMU curses/ncurses display driver
|
||||
*
|
||||
* Copyright (c) 2005 Andrzej Zaborowski <balrog@zabor.org>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "qemu-common.h"
|
||||
#include "console.h"
|
||||
#include "sysemu.h"
|
||||
|
||||
#include <curses.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <signal.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <termios.h>
|
||||
#endif
|
||||
|
||||
#define FONT_HEIGHT 16
|
||||
#define FONT_WIDTH 8
|
||||
|
||||
static console_ch_t screen[160 * 100];
|
||||
static WINDOW *screenpad = NULL;
|
||||
static int width, height, gwidth, gheight, invalidate;
|
||||
static int px, py, sminx, sminy, smaxx, smaxy;
|
||||
|
||||
static void curses_update(DisplayState *ds, int x, int y, int w, int h)
|
||||
{
|
||||
chtype *line;
|
||||
|
||||
line = ((chtype *) screen) + y * width;
|
||||
for (h += y; y < h; y ++, line += width)
|
||||
mvwaddchnstr(screenpad, y, 0, line, width);
|
||||
|
||||
pnoutrefresh(screenpad, py, px, sminy, sminx, smaxy - 1, smaxx - 1);
|
||||
refresh();
|
||||
}
|
||||
|
||||
static void curses_calc_pad(void)
|
||||
{
|
||||
if (is_graphic_console()) {
|
||||
width = gwidth;
|
||||
height = gheight;
|
||||
} else {
|
||||
width = COLS;
|
||||
height = LINES;
|
||||
}
|
||||
|
||||
if (screenpad)
|
||||
delwin(screenpad);
|
||||
|
||||
clear();
|
||||
refresh();
|
||||
|
||||
screenpad = newpad(height, width);
|
||||
|
||||
if (width > COLS) {
|
||||
px = (width - COLS) / 2;
|
||||
sminx = 0;
|
||||
smaxx = COLS;
|
||||
} else {
|
||||
px = 0;
|
||||
sminx = (COLS - width) / 2;
|
||||
smaxx = sminx + width;
|
||||
}
|
||||
|
||||
if (height > LINES) {
|
||||
py = (height - LINES) / 2;
|
||||
sminy = 0;
|
||||
smaxy = LINES;
|
||||
} else {
|
||||
py = 0;
|
||||
sminy = (LINES - height) / 2;
|
||||
smaxy = sminy + height;
|
||||
}
|
||||
}
|
||||
|
||||
static void curses_resize(DisplayState *ds, int w, int h)
|
||||
{
|
||||
if (w == gwidth && h == gheight)
|
||||
return;
|
||||
|
||||
gwidth = w;
|
||||
gheight = h;
|
||||
|
||||
curses_calc_pad();
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
#ifdef SIGWINCH
|
||||
static void curses_winch_handler(int signum)
|
||||
{
|
||||
struct winsize {
|
||||
unsigned short ws_row;
|
||||
unsigned short ws_col;
|
||||
unsigned short ws_xpixel; /* unused */
|
||||
unsigned short ws_ypixel; /* unused */
|
||||
} ws;
|
||||
|
||||
/* terminal size changed */
|
||||
if (ioctl(1, TIOCGWINSZ, &ws) == -1)
|
||||
return;
|
||||
|
||||
resize_term(ws.ws_row, ws.ws_col);
|
||||
curses_calc_pad();
|
||||
invalidate = 1;
|
||||
|
||||
/* some systems require this */
|
||||
signal(SIGWINCH, curses_winch_handler);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static void curses_cursor_position(DisplayState *ds, int x, int y)
|
||||
{
|
||||
if (x >= 0) {
|
||||
x = sminx + x - px;
|
||||
y = sminy + y - py;
|
||||
|
||||
if (x >= 0 && y >= 0 && x < COLS && y < LINES) {
|
||||
move(y, x);
|
||||
curs_set(1);
|
||||
/* it seems that curs_set(1) must always be called before
|
||||
* curs_set(2) for the latter to have effect */
|
||||
if (!is_graphic_console())
|
||||
curs_set(2);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
curs_set(0);
|
||||
}
|
||||
|
||||
/* generic keyboard conversion */
|
||||
|
||||
#include "curses_keys.h"
|
||||
#include "keymaps.c"
|
||||
|
||||
static kbd_layout_t *kbd_layout = 0;
|
||||
static int keycode2keysym[CURSES_KEYS];
|
||||
|
||||
static void curses_refresh(DisplayState *ds)
|
||||
{
|
||||
int chr, nextchr, keysym, keycode;
|
||||
|
||||
if (invalidate) {
|
||||
clear();
|
||||
refresh();
|
||||
curses_calc_pad();
|
||||
ds->width = FONT_WIDTH * width;
|
||||
ds->height = FONT_HEIGHT * height;
|
||||
vga_hw_invalidate();
|
||||
invalidate = 0;
|
||||
}
|
||||
|
||||
vga_hw_text_update(screen);
|
||||
|
||||
nextchr = ERR;
|
||||
while (1) {
|
||||
/* while there are any pending key strokes to process */
|
||||
if (nextchr == ERR)
|
||||
chr = getch();
|
||||
else {
|
||||
chr = nextchr;
|
||||
nextchr = ERR;
|
||||
}
|
||||
|
||||
if (chr == ERR)
|
||||
break;
|
||||
|
||||
/* this shouldn't occur when we use a custom SIGWINCH handler */
|
||||
if (chr == KEY_RESIZE) {
|
||||
clear();
|
||||
refresh();
|
||||
curses_calc_pad();
|
||||
curses_update(ds, 0, 0, width, height);
|
||||
ds->width = FONT_WIDTH * width;
|
||||
ds->height = FONT_HEIGHT * height;
|
||||
continue;
|
||||
}
|
||||
|
||||
keycode = curses2keycode[chr];
|
||||
if (keycode == -1)
|
||||
continue;
|
||||
|
||||
/* alt key */
|
||||
if (keycode == 1) {
|
||||
nextchr = getch();
|
||||
|
||||
if (nextchr != ERR) {
|
||||
keycode = curses2keycode[nextchr];
|
||||
nextchr = ERR;
|
||||
if (keycode == -1)
|
||||
continue;
|
||||
|
||||
keycode |= ALT;
|
||||
|
||||
/* process keys reserved for qemu */
|
||||
if (keycode >= QEMU_KEY_CONSOLE0 &&
|
||||
keycode < QEMU_KEY_CONSOLE0 + 9) {
|
||||
erase();
|
||||
wnoutrefresh(stdscr);
|
||||
console_select(keycode - QEMU_KEY_CONSOLE0);
|
||||
|
||||
invalidate = 1;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (kbd_layout && !(keycode & GREY)) {
|
||||
keysym = keycode2keysym[keycode & KEY_MASK];
|
||||
if (keysym == -1)
|
||||
keysym = chr;
|
||||
|
||||
keycode &= ~KEY_MASK;
|
||||
keycode |= keysym2scancode(kbd_layout, keysym);
|
||||
}
|
||||
|
||||
if (is_graphic_console()) {
|
||||
/* since terminals don't know about key press and release
|
||||
* events, we need to emit both for each key received */
|
||||
if (keycode & SHIFT)
|
||||
kbd_put_keycode(SHIFT_CODE);
|
||||
if (keycode & CNTRL)
|
||||
kbd_put_keycode(CNTRL_CODE);
|
||||
if (keycode & ALT)
|
||||
kbd_put_keycode(ALT_CODE);
|
||||
if (keycode & GREY)
|
||||
kbd_put_keycode(GREY_CODE);
|
||||
kbd_put_keycode(keycode & KEY_MASK);
|
||||
if (keycode & GREY)
|
||||
kbd_put_keycode(GREY_CODE);
|
||||
kbd_put_keycode((keycode & KEY_MASK) | KEY_RELEASE);
|
||||
if (keycode & ALT)
|
||||
kbd_put_keycode(ALT_CODE | KEY_RELEASE);
|
||||
if (keycode & CNTRL)
|
||||
kbd_put_keycode(CNTRL_CODE | KEY_RELEASE);
|
||||
if (keycode & SHIFT)
|
||||
kbd_put_keycode(SHIFT_CODE | KEY_RELEASE);
|
||||
} else {
|
||||
keysym = curses2keysym[chr];
|
||||
if (keysym == -1)
|
||||
keysym = chr;
|
||||
|
||||
kbd_put_keysym(keysym);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void curses_cleanup(void *opaque)
|
||||
{
|
||||
endwin();
|
||||
}
|
||||
|
||||
static void curses_atexit(void)
|
||||
{
|
||||
curses_cleanup(NULL);
|
||||
}
|
||||
|
||||
static void curses_setup(void)
|
||||
{
|
||||
int i, colour_default[8] = {
|
||||
COLOR_BLACK, COLOR_BLUE, COLOR_GREEN, COLOR_CYAN,
|
||||
COLOR_RED, COLOR_MAGENTA, COLOR_YELLOW, COLOR_WHITE,
|
||||
};
|
||||
|
||||
/* input as raw as possible, let everything be interpreted
|
||||
* by the guest system */
|
||||
initscr(); noecho(); intrflush(stdscr, FALSE);
|
||||
nodelay(stdscr, TRUE); nonl(); keypad(stdscr, TRUE);
|
||||
start_color(); raw(); scrollok(stdscr, FALSE);
|
||||
|
||||
for (i = 0; i < 64; i ++)
|
||||
init_pair(i, colour_default[i & 7], colour_default[i >> 3]);
|
||||
}
|
||||
|
||||
static void curses_keyboard_setup(void)
|
||||
{
|
||||
int i, keycode, keysym;
|
||||
|
||||
#if defined(__APPLE__)
|
||||
/* always use generic keymaps */
|
||||
if (!keyboard_layout)
|
||||
keyboard_layout = "en-us";
|
||||
#endif
|
||||
if(keyboard_layout) {
|
||||
kbd_layout = init_keyboard_layout(keyboard_layout);
|
||||
if (!kbd_layout)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
for (i = 0; i < CURSES_KEYS; i ++)
|
||||
keycode2keysym[i] = -1;
|
||||
|
||||
for (i = 0; i < CURSES_KEYS; i ++) {
|
||||
if (curses2keycode[i] == -1)
|
||||
continue;
|
||||
|
||||
keycode = curses2keycode[i] & KEY_MASK;
|
||||
if (keycode2keysym[keycode] >= 0)
|
||||
continue;
|
||||
|
||||
for (keysym = 0; keysym < CURSES_KEYS; keysym ++)
|
||||
if (curses2keycode[keysym] == keycode) {
|
||||
keycode2keysym[keycode] = keysym;
|
||||
break;
|
||||
}
|
||||
|
||||
if (keysym >= CURSES_KEYS)
|
||||
keycode2keysym[keycode] = i;
|
||||
}
|
||||
}
|
||||
|
||||
void curses_display_init(DisplayState *ds, int full_screen)
|
||||
{
|
||||
#ifndef _WIN32
|
||||
if (!isatty(1)) {
|
||||
fprintf(stderr, "We need a terminal output\n");
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
curses_setup();
|
||||
curses_keyboard_setup();
|
||||
atexit(curses_atexit);
|
||||
|
||||
#ifndef _WIN32
|
||||
signal(SIGINT, SIG_DFL);
|
||||
signal(SIGQUIT, SIG_DFL);
|
||||
#ifdef SIGWINCH
|
||||
/* some curses implementations provide a handler, but we
|
||||
* want to be sure this is handled regardless of the library */
|
||||
signal(SIGWINCH, curses_winch_handler);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
ds->data = (void *) screen;
|
||||
ds->linesize = 0;
|
||||
ds->depth = 0;
|
||||
ds->width = 640;
|
||||
ds->height = 400;
|
||||
ds->dpy_update = curses_update;
|
||||
ds->dpy_resize = curses_resize;
|
||||
ds->dpy_refresh = curses_refresh;
|
||||
ds->dpy_text_cursor = curses_cursor_position;
|
||||
|
||||
invalidate = 1;
|
||||
|
||||
/* Standard VGA initial text mode dimensions */
|
||||
curses_resize(ds, 80, 25);
|
||||
}
|
484
curses_keys.h
Normal file
484
curses_keys.h
Normal file
|
@ -0,0 +1,484 @@
|
|||
/*
|
||||
* Keycode and keysyms conversion tables for curses
|
||||
*
|
||||
* Copyright (c) 2005 Andrzej Zaborowski <balrog@zabor.org>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
#define KEY_RELEASE 0x80
|
||||
#define KEY_MASK 0x7f
|
||||
#define SHIFT_CODE 0x2a
|
||||
#define SHIFT 0x0080
|
||||
#define GREY_CODE 0xe0
|
||||
#define GREY 0x0100
|
||||
#define CNTRL_CODE 0x1d
|
||||
#define CNTRL 0x0200
|
||||
#define ALT_CODE 0x38
|
||||
#define ALT 0x0400
|
||||
|
||||
/* curses won't detect a Control + Alt + 1, so use Alt + 1 */
|
||||
#define QEMU_KEY_CONSOLE0 (2 | ALT) /* (curses2keycode['1'] | ALT) */
|
||||
|
||||
#define CURSES_KEYS KEY_MAX /* KEY_MAX defined in <curses.h> */
|
||||
|
||||
int curses2keycode[CURSES_KEYS] = {
|
||||
[0 ... (CURSES_KEYS - 1)] = -1,
|
||||
|
||||
[0x01b] = 1, /* Escape */
|
||||
['1'] = 2,
|
||||
['2'] = 3,
|
||||
['3'] = 4,
|
||||
['4'] = 5,
|
||||
['5'] = 6,
|
||||
['6'] = 7,
|
||||
['7'] = 8,
|
||||
['8'] = 9,
|
||||
['9'] = 10,
|
||||
['0'] = 11,
|
||||
['-'] = 12,
|
||||
['='] = 13,
|
||||
[0x07f] = 14, /* Backspace */
|
||||
[0x107] = 14, /* Backspace */
|
||||
|
||||
['\t'] = 15, /* Tab */
|
||||
['q'] = 16,
|
||||
['w'] = 17,
|
||||
['e'] = 18,
|
||||
['r'] = 19,
|
||||
['t'] = 20,
|
||||
['y'] = 21,
|
||||
['u'] = 22,
|
||||
['i'] = 23,
|
||||
['o'] = 24,
|
||||
['p'] = 25,
|
||||
['['] = 26,
|
||||
[']'] = 27,
|
||||
['\n'] = 28, /* Return */
|
||||
['\r'] = 28, /* Return */
|
||||
[0x157] = 28, /* Return */
|
||||
|
||||
['a'] = 30,
|
||||
['s'] = 31,
|
||||
['d'] = 32,
|
||||
['f'] = 33,
|
||||
['g'] = 34,
|
||||
['h'] = 35,
|
||||
['j'] = 36,
|
||||
['k'] = 37,
|
||||
['l'] = 38,
|
||||
[';'] = 39,
|
||||
['\''] = 40, /* Single quote */
|
||||
['`'] = 41,
|
||||
['\\'] = 43, /* Backslash */
|
||||
|
||||
['z'] = 44,
|
||||
['x'] = 45,
|
||||
['c'] = 46,
|
||||
['v'] = 47,
|
||||
['b'] = 48,
|
||||
['n'] = 49,
|
||||
['m'] = 50,
|
||||
[','] = 51,
|
||||
['.'] = 52,
|
||||
['/'] = 53,
|
||||
|
||||
[' '] = 57,
|
||||
|
||||
[0x109] = 59, /* Function Key 1 */
|
||||
[0x10a] = 60, /* Function Key 2 */
|
||||
[0x10b] = 61, /* Function Key 3 */
|
||||
[0x10c] = 62, /* Function Key 4 */
|
||||
[0x10d] = 63, /* Function Key 5 */
|
||||
[0x10e] = 64, /* Function Key 6 */
|
||||
[0x10f] = 65, /* Function Key 7 */
|
||||
[0x110] = 66, /* Function Key 8 */
|
||||
[0x111] = 67, /* Function Key 9 */
|
||||
[0x112] = 68, /* Function Key 10 */
|
||||
[0x113] = 87, /* Function Key 11 */
|
||||
[0x114] = 88, /* Function Key 12 */
|
||||
|
||||
[0x106] = 71 | GREY, /* Home */
|
||||
[0x103] = 72 | GREY, /* Up Arrow */
|
||||
[0x153] = 73 | GREY, /* Page Up */
|
||||
[0x104] = 75 | GREY, /* Left Arrow */
|
||||
[0x105] = 77 | GREY, /* Right Arrow */
|
||||
[0x168] = 79 | GREY, /* End */
|
||||
[0x102] = 80 | GREY, /* Down Arrow */
|
||||
[0x152] = 81 | GREY, /* Page Down */
|
||||
[0x14b] = 82 | GREY, /* Insert */
|
||||
[0x14a] = 83 | GREY, /* Delete */
|
||||
|
||||
['!'] = 2 | SHIFT,
|
||||
['@'] = 3 | SHIFT,
|
||||
['#'] = 4 | SHIFT,
|
||||
['$'] = 5 | SHIFT,
|
||||
['%'] = 6 | SHIFT,
|
||||
['^'] = 7 | SHIFT,
|
||||
['&'] = 8 | SHIFT,
|
||||
['*'] = 9 | SHIFT,
|
||||
['('] = 10 | SHIFT,
|
||||
[')'] = 11 | SHIFT,
|
||||
['_'] = 12 | SHIFT,
|
||||
['+'] = 13 | SHIFT,
|
||||
|
||||
[0x161] = 15 | SHIFT, /* Shift + Tab */
|
||||
['Q'] = 16 | SHIFT,
|
||||
['W'] = 17 | SHIFT,
|
||||
['E'] = 18 | SHIFT,
|
||||
['R'] = 19 | SHIFT,
|
||||
['T'] = 20 | SHIFT,
|
||||
['Y'] = 21 | SHIFT,
|
||||
['U'] = 22 | SHIFT,
|
||||
['I'] = 23 | SHIFT,
|
||||
['O'] = 24 | SHIFT,
|
||||
['P'] = 25 | SHIFT,
|
||||
['{'] = 26 | SHIFT,
|
||||
['}'] = 27 | SHIFT,
|
||||
|
||||
['A'] = 30 | SHIFT,
|
||||
['S'] = 31 | SHIFT,
|
||||
['D'] = 32 | SHIFT,
|
||||
['F'] = 33 | SHIFT,
|
||||
['G'] = 34 | SHIFT,
|
||||
['H'] = 35 | SHIFT,
|
||||
['J'] = 36 | SHIFT,
|
||||
['K'] = 37 | SHIFT,
|
||||
['L'] = 38 | SHIFT,
|
||||
[':'] = 39 | SHIFT,
|
||||
['"'] = 40 | SHIFT,
|
||||
['~'] = 41 | SHIFT,
|
||||
['|'] = 43 | SHIFT,
|
||||
|
||||
['Z'] = 44 | SHIFT,
|
||||
['X'] = 45 | SHIFT,
|
||||
['C'] = 46 | SHIFT,
|
||||
['V'] = 47 | SHIFT,
|
||||
['B'] = 48 | SHIFT,
|
||||
['N'] = 49 | SHIFT,
|
||||
['M'] = 50 | SHIFT,
|
||||
['<'] = 51 | SHIFT,
|
||||
['>'] = 52 | SHIFT,
|
||||
['?'] = 53 | SHIFT,
|
||||
|
||||
[0x115] = 59 | SHIFT, /* Shift + Function Key 1 */
|
||||
[0x116] = 60 | SHIFT, /* Shift + Function Key 2 */
|
||||
[0x117] = 61 | SHIFT, /* Shift + Function Key 3 */
|
||||
[0x118] = 62 | SHIFT, /* Shift + Function Key 4 */
|
||||
[0x119] = 63 | SHIFT, /* Shift + Function Key 5 */
|
||||
[0x11a] = 64 | SHIFT, /* Shift + Function Key 6 */
|
||||
[0x11b] = 65 | SHIFT, /* Shift + Function Key 7 */
|
||||
[0x11c] = 66 | SHIFT, /* Shift + Function Key 8 */
|
||||
|
||||
[0x011] = 16 | CNTRL, /* Control + q */
|
||||
[0x017] = 17 | CNTRL, /* Control + w */
|
||||
[0x005] = 18 | CNTRL, /* Control + e */
|
||||
[0x012] = 19 | CNTRL, /* Control + r */
|
||||
[0x014] = 20 | CNTRL, /* Control + t */
|
||||
[0x019] = 21 | CNTRL, /* Control + y */
|
||||
[0x015] = 22 | CNTRL, /* Control + u */
|
||||
[0x009] = 23 | CNTRL, /* Control + i */
|
||||
[0x00f] = 24 | CNTRL, /* Control + o */
|
||||
[0x010] = 25 | CNTRL, /* Control + p */
|
||||
|
||||
[0x001] = 30 | CNTRL, /* Control + a */
|
||||
[0x013] = 31 | CNTRL, /* Control + s */
|
||||
[0x014] = 32 | CNTRL, /* Control + d */
|
||||
[0x006] = 33 | CNTRL, /* Control + f */
|
||||
[0x007] = 34 | CNTRL, /* Control + g */
|
||||
[0x008] = 35 | CNTRL, /* Control + h */
|
||||
[0x00a] = 36 | CNTRL, /* Control + j */
|
||||
[0x00b] = 37 | CNTRL, /* Control + k */
|
||||
[0x00c] = 38 | CNTRL, /* Control + l */
|
||||
|
||||
[0x01a] = 44 | CNTRL, /* Control + z */
|
||||
[0x018] = 45 | CNTRL, /* Control + x */
|
||||
[0x003] = 46 | CNTRL, /* Control + c */
|
||||
[0x016] = 47 | CNTRL, /* Control + v */
|
||||
[0x002] = 48 | CNTRL, /* Control + b */
|
||||
[0x00e] = 49 | CNTRL, /* Control + n */
|
||||
/* Control + m collides with the keycode for Enter */
|
||||
|
||||
};
|
||||
|
||||
int curses2keysym[CURSES_KEYS] = {
|
||||
[0 ... (CURSES_KEYS - 1)] = -1,
|
||||
|
||||
['\n'] = '\n',
|
||||
['\r'] = '\n',
|
||||
|
||||
[0x07f] = QEMU_KEY_BACKSPACE,
|
||||
|
||||
[0x102] = QEMU_KEY_DOWN,
|
||||
[0x103] = QEMU_KEY_UP,
|
||||
[0x104] = QEMU_KEY_LEFT,
|
||||
[0x105] = QEMU_KEY_RIGHT,
|
||||
[0x106] = QEMU_KEY_HOME,
|
||||
[0x107] = QEMU_KEY_BACKSPACE,
|
||||
|
||||
[0x14a] = QEMU_KEY_DELETE,
|
||||
[0x152] = QEMU_KEY_PAGEDOWN,
|
||||
[0x153] = QEMU_KEY_PAGEUP,
|
||||
[0x157] = '\n',
|
||||
[0x168] = QEMU_KEY_END,
|
||||
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
const char* name;
|
||||
int keysym;
|
||||
} name2keysym_t;
|
||||
|
||||
static name2keysym_t name2keysym[] = {
|
||||
/* Plain ASCII */
|
||||
{ "space", 0x020 },
|
||||
{ "exclam", 0x021 },
|
||||
{ "quotedbl", 0x022 },
|
||||
{ "numbersign", 0x023 },
|
||||
{ "dollar", 0x024 },
|
||||
{ "percent", 0x025 },
|
||||
{ "ampersand", 0x026 },
|
||||
{ "apostrophe", 0x027 },
|
||||
{ "parenleft", 0x028 },
|
||||
{ "parenright", 0x029 },
|
||||
{ "asterisk", 0x02a },
|
||||
{ "plus", 0x02b },
|
||||
{ "comma", 0x02c },
|
||||
{ "minus", 0x02d },
|
||||
{ "period", 0x02e },
|
||||
{ "slash", 0x02f },
|
||||
{ "0", 0x030 },
|
||||
{ "1", 0x031 },
|
||||
{ "2", 0x032 },
|
||||
{ "3", 0x033 },
|
||||
{ "4", 0x034 },
|
||||
{ "5", 0x035 },
|
||||
{ "6", 0x036 },
|
||||
{ "7", 0x037 },
|
||||
{ "8", 0x038 },
|
||||
{ "9", 0x039 },
|
||||
{ "colon", 0x03a },
|
||||
{ "semicolon", 0x03b },
|
||||
{ "less", 0x03c },
|
||||
{ "equal", 0x03d },
|
||||
{ "greater", 0x03e },
|
||||
{ "question", 0x03f },
|
||||
{ "at", 0x040 },
|
||||
{ "A", 0x041 },
|
||||
{ "B", 0x042 },
|
||||
{ "C", 0x043 },
|
||||
{ "D", 0x044 },
|
||||
{ "E", 0x045 },
|
||||
{ "F", 0x046 },
|
||||
{ "G", 0x047 },
|
||||
{ "H", 0x048 },
|
||||
{ "I", 0x049 },
|
||||
{ "J", 0x04a },
|
||||
{ "K", 0x04b },
|
||||
{ "L", 0x04c },
|
||||
{ "M", 0x04d },
|
||||
{ "N", 0x04e },
|
||||
{ "O", 0x04f },
|
||||
{ "P", 0x050 },
|
||||
{ "Q", 0x051 },
|
||||
{ "R", 0x052 },
|
||||
{ "S", 0x053 },
|
||||
{ "T", 0x054 },
|
||||
{ "U", 0x055 },
|
||||
{ "V", 0x056 },
|
||||
{ "W", 0x057 },
|
||||
{ "X", 0x058 },
|
||||
{ "Y", 0x059 },
|
||||
{ "Z", 0x05a },
|
||||
{ "bracketleft", 0x05b },
|
||||
{ "backslash", 0x05c },
|
||||
{ "bracketright", 0x05d },
|
||||
{ "asciicircum", 0x05e },
|
||||
{ "underscore", 0x05f },
|
||||
{ "grave", 0x060 },
|
||||
{ "a", 0x061 },
|
||||
{ "b", 0x062 },
|
||||
{ "c", 0x063 },
|
||||
{ "d", 0x064 },
|
||||
{ "e", 0x065 },
|
||||
{ "f", 0x066 },
|
||||
{ "g", 0x067 },
|
||||
{ "h", 0x068 },
|
||||
{ "i", 0x069 },
|
||||
{ "j", 0x06a },
|
||||
{ "k", 0x06b },
|
||||
{ "l", 0x06c },
|
||||
{ "m", 0x06d },
|
||||
{ "n", 0x06e },
|
||||
{ "o", 0x06f },
|
||||
{ "p", 0x070 },
|
||||
{ "q", 0x071 },
|
||||
{ "r", 0x072 },
|
||||
{ "s", 0x073 },
|
||||
{ "t", 0x074 },
|
||||
{ "u", 0x075 },
|
||||
{ "v", 0x076 },
|
||||
{ "w", 0x077 },
|
||||
{ "x", 0x078 },
|
||||
{ "y", 0x079 },
|
||||
{ "z", 0x07a },
|
||||
{ "braceleft", 0x07b },
|
||||
{ "bar", 0x07c },
|
||||
{ "braceright", 0x07d },
|
||||
{ "asciitilde", 0x07e },
|
||||
|
||||
/* Latin-1 extensions */
|
||||
{ "nobreakspace", 0x0a0 },
|
||||
{ "exclamdown", 0x0a1 },
|
||||
{ "cent", 0x0a2 },
|
||||
{ "sterling", 0x0a3 },
|
||||
{ "currency", 0x0a4 },
|
||||
{ "yen", 0x0a5 },
|
||||
{ "brokenbar", 0x0a6 },
|
||||
{ "section", 0x0a7 },
|
||||
{ "diaeresis", 0x0a8 },
|
||||
{ "copyright", 0x0a9 },
|
||||
{ "ordfeminine", 0x0aa },
|
||||
{ "guillemotleft", 0x0ab },
|
||||
{ "notsign", 0x0ac },
|
||||
{ "hyphen", 0x0ad },
|
||||
{ "registered", 0x0ae },
|
||||
{ "macron", 0x0af },
|
||||
{ "degree", 0x0b0 },
|
||||
{ "plusminus", 0x0b1 },
|
||||
{ "twosuperior", 0x0b2 },
|
||||
{ "threesuperior", 0x0b3 },
|
||||
{ "acute", 0x0b4 },
|
||||
{ "mu", 0x0b5 },
|
||||
{ "paragraph", 0x0b6 },
|
||||
{ "periodcentered", 0x0b7 },
|
||||
{ "cedilla", 0x0b8 },
|
||||
{ "onesuperior", 0x0b9 },
|
||||
{ "masculine", 0x0ba },
|
||||
{ "guillemotright", 0x0bb },
|
||||
{ "onequarter", 0x0bc },
|
||||
{ "onehalf", 0x0bd },
|
||||
{ "threequarters", 0x0be },
|
||||
{ "questiondown", 0x0bf },
|
||||
{ "Agrave", 0x0c0 },
|
||||
{ "Aacute", 0x0c1 },
|
||||
{ "Acircumflex", 0x0c2 },
|
||||
{ "Atilde", 0x0c3 },
|
||||
{ "Adiaeresis", 0x0c4 },
|
||||
{ "Aring", 0x0c5 },
|
||||
{ "AE", 0x0c6 },
|
||||
{ "Ccedilla", 0x0c7 },
|
||||
{ "Egrave", 0x0c8 },
|
||||
{ "Eacute", 0x0c9 },
|
||||
{ "Ecircumflex", 0x0ca },
|
||||
{ "Ediaeresis", 0x0cb },
|
||||
{ "Igrave", 0x0cc },
|
||||
{ "Iacute", 0x0cd },
|
||||
{ "Icircumflex", 0x0ce },
|
||||
{ "Idiaeresis", 0x0cf },
|
||||
{ "ETH", 0x0d0 },
|
||||
{ "Eth", 0x0d0 },
|
||||
{ "Ntilde", 0x0d1 },
|
||||
{ "Ograve", 0x0d2 },
|
||||
{ "Oacute", 0x0d3 },
|
||||
{ "Ocircumflex", 0x0d4 },
|
||||
{ "Otilde", 0x0d5 },
|
||||
{ "Odiaeresis", 0x0d6 },
|
||||
{ "multiply", 0x0d7 },
|
||||
{ "Ooblique", 0x0d8 },
|
||||
{ "Oslash", 0x0d8 },
|
||||
{ "Ugrave", 0x0d9 },
|
||||
{ "Uacute", 0x0da },
|
||||
{ "Ucircumflex", 0x0db },
|
||||
{ "Udiaeresis", 0x0dc },
|
||||
{ "Yacute", 0x0dd },
|
||||
{ "THORN", 0x0de },
|
||||
{ "Thorn", 0x0de },
|
||||
{ "ssharp", 0x0df },
|
||||
{ "agrave", 0x0e0 },
|
||||
{ "aacute", 0x0e1 },
|
||||
{ "acircumflex", 0x0e2 },
|
||||
{ "atilde", 0x0e3 },
|
||||
{ "adiaeresis", 0x0e4 },
|
||||
{ "aring", 0x0e5 },
|
||||
{ "ae", 0x0e6 },
|
||||
{ "ccedilla", 0x0e7 },
|
||||
{ "egrave", 0x0e8 },
|
||||
{ "eacute", 0x0e9 },
|
||||
{ "ecircumflex", 0x0ea },
|
||||
{ "ediaeresis", 0x0eb },
|
||||
{ "igrave", 0x0ec },
|
||||
{ "iacute", 0x0ed },
|
||||
{ "icircumflex", 0x0ee },
|
||||
{ "idiaeresis", 0x0ef },
|
||||
{ "eth", 0x0f0 },
|
||||
{ "ntilde", 0x0f1 },
|
||||
{ "ograve", 0x0f2 },
|
||||
{ "oacute", 0x0f3 },
|
||||
{ "ocircumflex", 0x0f4 },
|
||||
{ "otilde", 0x0f5 },
|
||||
{ "odiaeresis", 0x0f6 },
|
||||
{ "division", 0x0f7 },
|
||||
{ "oslash", 0x0f8 },
|
||||
{ "ooblique", 0x0f8 },
|
||||
{ "ugrave", 0x0f9 },
|
||||
{ "uacute", 0x0fa },
|
||||
{ "ucircumflex", 0x0fb },
|
||||
{ "udiaeresis", 0x0fc },
|
||||
{ "yacute", 0x0fd },
|
||||
{ "thorn", 0x0fe },
|
||||
{ "ydiaeresis", 0x0ff },
|
||||
|
||||
/* Special keys */
|
||||
{ "BackSpace", 0x07f },
|
||||
{ "Tab", '\t' },
|
||||
{ "Return", '\r' },
|
||||
{ "Right", 0x105 },
|
||||
{ "Left", 0x104 },
|
||||
{ "Up", 0x103 },
|
||||
{ "Down", 0x102 },
|
||||
{ "Page_Down", 0x152 },
|
||||
{ "Page_Up", 0x153 },
|
||||
{ "Insert", 0x14b },
|
||||
{ "Delete", 0x14a },
|
||||
{ "Home", 0x106 },
|
||||
{ "End", 0x168 },
|
||||
{ "F1", 0x109 },
|
||||
{ "F2", 0x10a },
|
||||
{ "F3", 0x10b },
|
||||
{ "F4", 0x10c },
|
||||
{ "F5", 0x10d },
|
||||
{ "F6", 0x10e },
|
||||
{ "F7", 0x10f },
|
||||
{ "F8", 0x110 },
|
||||
{ "F9", 0x111 },
|
||||
{ "F10", 0x112 },
|
||||
{ "F11", 0x113 },
|
||||
{ "F12", 0x114 },
|
||||
{ "F13", 0x115 },
|
||||
{ "F14", 0x116 },
|
||||
{ "F15", 0x117 },
|
||||
{ "F16", 0x118 },
|
||||
{ "F17", 0x119 },
|
||||
{ "F18", 0x11a },
|
||||
{ "F19", 0x11b },
|
||||
{ "F20", 0x11c },
|
||||
{ "Escape", 27 },
|
||||
|
||||
{ 0, 0 },
|
||||
};
|
|
@ -3257,7 +3257,8 @@ void pci_cirrus_vga_init(PCIBus *bus, DisplayState *ds, uint8_t *vga_ram_base,
|
|||
ds, vga_ram_base, vga_ram_offset, vga_ram_size);
|
||||
cirrus_init_common(s, device_id, 1);
|
||||
|
||||
graphic_console_init(s->ds, s->update, s->invalidate, s->screen_dump, s);
|
||||
graphic_console_init(s->ds, s->update, s->invalidate, s->screen_dump,
|
||||
s->text_update, s);
|
||||
|
||||
s->pci_dev = (PCIDevice *)d;
|
||||
|
||||
|
|
|
@ -285,6 +285,22 @@ static void jazz_led_screen_dump(void *opaque, const char *filename)
|
|||
printf("jazz_led_screen_dump() not implemented\n");
|
||||
}
|
||||
|
||||
static void jazz_led_text_update(void *opaque, console_ch_t *chardata)
|
||||
{
|
||||
LedState *s = opaque;
|
||||
char buf[2];
|
||||
|
||||
dpy_cursor(s->ds, -1, -1);
|
||||
dpy_resize(s->ds, 2, 1);
|
||||
|
||||
/* TODO: draw the segments */
|
||||
snprintf(buf, 2, "%02hhx\n", s->segments);
|
||||
console_write_ch(chardata++, 0x00200100 | buf[0]);
|
||||
console_write_ch(chardata++, 0x00200100 | buf[1]);
|
||||
|
||||
dpy_update(s->ds, 0, 0, 2, 1);
|
||||
}
|
||||
|
||||
void jazz_led_init(DisplayState *ds, target_phys_addr_t base)
|
||||
{
|
||||
LedState *s;
|
||||
|
@ -301,5 +317,7 @@ void jazz_led_init(DisplayState *ds, target_phys_addr_t base)
|
|||
io = cpu_register_io_memory(0, led_read, led_write, s);
|
||||
cpu_register_physical_memory(s->base, 1, io);
|
||||
|
||||
graphic_console_init(ds, jazz_led_update_display, jazz_led_invalidate_display, jazz_led_screen_dump, s);
|
||||
graphic_console_init(ds, jazz_led_update_display,
|
||||
jazz_led_invalidate_display, jazz_led_screen_dump,
|
||||
jazz_led_text_update, s);
|
||||
}
|
||||
|
|
|
@ -495,7 +495,7 @@ struct omap_lcd_panel_s *omap_lcdc_init(target_phys_addr_t base, qemu_irq irq,
|
|||
cpu_register_physical_memory(s->base, 0x100, iomemtype);
|
||||
|
||||
graphic_console_init(ds, omap_update_display,
|
||||
omap_invalidate_display, omap_screen_dump, s);
|
||||
omap_invalidate_display, omap_screen_dump, NULL, s);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
|
|
@ -426,7 +426,7 @@ void *pl110_init(DisplayState *ds, uint32_t base, qemu_irq irq,
|
|||
s->versatile = versatile;
|
||||
s->irq = irq;
|
||||
graphic_console_init(ds, pl110_update_display, pl110_invalidate_display,
|
||||
NULL, s);
|
||||
NULL, NULL, s);
|
||||
/* ??? Save/restore. */
|
||||
return s;
|
||||
}
|
||||
|
|
|
@ -1002,7 +1002,7 @@ struct pxa2xx_lcdc_s *pxa2xx_lcdc_init(target_phys_addr_t base, qemu_irq irq,
|
|||
cpu_register_physical_memory(base, 0x00100000, iomemtype);
|
||||
|
||||
graphic_console_init(ds, pxa2xx_update_display,
|
||||
pxa2xx_invalidate_display, pxa2xx_screen_dump, s);
|
||||
pxa2xx_invalidate_display, pxa2xx_screen_dump, NULL, s);
|
||||
|
||||
switch (s->ds->depth) {
|
||||
case 0:
|
||||
|
|
|
@ -270,6 +270,6 @@ void ssd0303_init(DisplayState *ds, i2c_bus *bus, int address)
|
|||
s->i2c.recv = ssd0303_recv;
|
||||
s->i2c.send = ssd0303_send;
|
||||
graphic_console_init(ds, ssd0303_update_display, ssd0303_invalidate_display,
|
||||
NULL, s);
|
||||
NULL, NULL, s);
|
||||
dpy_resize(s->ds, 96 * MAGNIFY, 16 * MAGNIFY);
|
||||
}
|
||||
|
|
|
@ -280,7 +280,7 @@ void *ssd0323_init(DisplayState *ds, qemu_irq *cmd_p)
|
|||
s = (ssd0323_state *)qemu_mallocz(sizeof(ssd0323_state));
|
||||
s->ds = ds;
|
||||
graphic_console_init(ds, ssd0323_update_display, ssd0323_invalidate_display,
|
||||
NULL, s);
|
||||
NULL, NULL, s);
|
||||
dpy_resize(s->ds, 128 * MAGNIFY, 64 * MAGNIFY);
|
||||
s->col_end = 63;
|
||||
s->row_end = 79;
|
||||
|
|
5
hw/tcx.c
5
hw/tcx.c
|
@ -537,12 +537,13 @@ void tcx_init(DisplayState *ds, target_phys_addr_t addr, uint8_t *vram_base,
|
|||
s->cplane_offset = vram_offset;
|
||||
cpu_register_physical_memory(addr + 0x0a000000ULL, size, vram_offset);
|
||||
graphic_console_init(s->ds, tcx24_update_display,
|
||||
tcx24_invalidate_display, tcx24_screen_dump, s);
|
||||
tcx24_invalidate_display,
|
||||
tcx24_screen_dump, NULL, s);
|
||||
} else {
|
||||
cpu_register_physical_memory(addr + 0x00300000ULL, TCX_THC_NREGS_8,
|
||||
dummy_memory);
|
||||
graphic_console_init(s->ds, tcx_update_display, tcx_invalidate_display,
|
||||
tcx_screen_dump, s);
|
||||
tcx_screen_dump, NULL, s);
|
||||
}
|
||||
// NetBSD writes here even with 8-bit display
|
||||
cpu_register_physical_memory(addr + 0x00301000ULL, TCX_THC_NREGS_24,
|
||||
|
|
169
hw/vga.c
169
hw/vga.c
|
@ -1660,6 +1660,165 @@ static void vga_reset(VGAState *s)
|
|||
s->graphic_mode = -1; /* force full update */
|
||||
}
|
||||
|
||||
#define TEXTMODE_X(x) ((x) % width)
|
||||
#define TEXTMODE_Y(x) ((x) / width)
|
||||
#define VMEM2CHTYPE(v) ((v & 0xff0007ff) | \
|
||||
((v & 0x00000800) << 10) | ((v & 0x00007000) >> 1))
|
||||
/* relay text rendering to the display driver
|
||||
* instead of doing a full vga_update_display() */
|
||||
static void vga_update_text(void *opaque, console_ch_t *chardata)
|
||||
{
|
||||
VGAState *s = (VGAState *) opaque;
|
||||
int graphic_mode, i, cursor_offset, cursor_visible;
|
||||
int cw, cheight, width, height, size, c_min, c_max;
|
||||
uint32_t *src;
|
||||
console_ch_t *dst, val;
|
||||
char msg_buffer[80];
|
||||
int full_update;
|
||||
full_update = 0;
|
||||
|
||||
if (!(s->ar_index & 0x20)) {
|
||||
graphic_mode = GMODE_BLANK;
|
||||
} else {
|
||||
graphic_mode = s->gr[6] & 1;
|
||||
}
|
||||
if (graphic_mode != s->graphic_mode) {
|
||||
s->graphic_mode = graphic_mode;
|
||||
full_update = 1;
|
||||
}
|
||||
if (s->last_width == -1) {
|
||||
s->last_width = 0;
|
||||
full_update = 1;
|
||||
}
|
||||
|
||||
switch (graphic_mode) {
|
||||
case GMODE_TEXT:
|
||||
/* TODO: update palette */
|
||||
full_update |= update_basic_params(s);
|
||||
|
||||
/* total width & height */
|
||||
cheight = (s->cr[9] & 0x1f) + 1;
|
||||
cw = 8;
|
||||
if (!(s->sr[1] & 0x01))
|
||||
cw = 9;
|
||||
if (s->sr[1] & 0x08)
|
||||
cw = 16; /* NOTE: no 18 pixel wide */
|
||||
width = (s->cr[0x01] + 1);
|
||||
if (s->cr[0x06] == 100) {
|
||||
/* ugly hack for CGA 160x100x16 - explain me the logic */
|
||||
height = 100;
|
||||
} else {
|
||||
height = s->cr[0x12] |
|
||||
((s->cr[0x07] & 0x02) << 7) |
|
||||
((s->cr[0x07] & 0x40) << 3);
|
||||
height = (height + 1) / cheight;
|
||||
}
|
||||
|
||||
size = (height * width);
|
||||
if (size > CH_ATTR_SIZE) {
|
||||
if (!full_update)
|
||||
return;
|
||||
|
||||
sprintf(msg_buffer, "%i x %i Text mode", width, height);
|
||||
break;
|
||||
}
|
||||
|
||||
if (width != s->last_width || height != s->last_height ||
|
||||
cw != s->last_cw || cheight != s->last_ch) {
|
||||
s->last_scr_width = width * cw;
|
||||
s->last_scr_height = height * cheight;
|
||||
dpy_resize(s->ds, width, height);
|
||||
s->last_width = width;
|
||||
s->last_height = height;
|
||||
s->last_ch = cheight;
|
||||
s->last_cw = cw;
|
||||
full_update = 1;
|
||||
}
|
||||
|
||||
/* Update "hardware" cursor */
|
||||
cursor_offset = ((s->cr[0x0e] << 8) | s->cr[0x0f]) - s->start_addr;
|
||||
if (cursor_offset != s->cursor_offset ||
|
||||
s->cr[0xa] != s->cursor_start ||
|
||||
s->cr[0xb] != s->cursor_end || full_update) {
|
||||
cursor_visible = !(s->cr[0xa] & 0x20);
|
||||
if (cursor_visible && cursor_offset < size && cursor_offset >= 0)
|
||||
dpy_cursor(s->ds,
|
||||
TEXTMODE_X(cursor_offset),
|
||||
TEXTMODE_Y(cursor_offset));
|
||||
else
|
||||
dpy_cursor(s->ds, -1, -1);
|
||||
s->cursor_offset = cursor_offset;
|
||||
s->cursor_start = s->cr[0xa];
|
||||
s->cursor_end = s->cr[0xb];
|
||||
}
|
||||
|
||||
src = (uint32_t *) s->vram_ptr + s->start_addr;
|
||||
dst = chardata;
|
||||
|
||||
if (full_update) {
|
||||
for (i = 0; i < size; src ++, dst ++, i ++)
|
||||
console_write_ch(dst, VMEM2CHTYPE(*src));
|
||||
|
||||
dpy_update(s->ds, 0, 0, width, height);
|
||||
} else {
|
||||
c_max = 0;
|
||||
|
||||
for (i = 0; i < size; src ++, dst ++, i ++) {
|
||||
console_write_ch(&val, VMEM2CHTYPE(*src));
|
||||
if (*dst != val) {
|
||||
*dst = val;
|
||||
c_max = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
c_min = i;
|
||||
for (; i < size; src ++, dst ++, i ++) {
|
||||
console_write_ch(&val, VMEM2CHTYPE(*src));
|
||||
if (*dst != val) {
|
||||
*dst = val;
|
||||
c_max = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (c_min <= c_max) {
|
||||
i = TEXTMODE_Y(c_min);
|
||||
dpy_update(s->ds, 0, i, width, TEXTMODE_Y(c_max) - i + 1);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
case GMODE_GRAPH:
|
||||
if (!full_update)
|
||||
return;
|
||||
|
||||
s->get_resolution(s, &width, &height);
|
||||
sprintf(msg_buffer, "%i x %i Graphic mode", width, height);
|
||||
break;
|
||||
case GMODE_BLANK:
|
||||
default:
|
||||
if (!full_update)
|
||||
return;
|
||||
|
||||
sprintf(msg_buffer, "VGA Blank mode");
|
||||
break;
|
||||
}
|
||||
|
||||
/* Display a message */
|
||||
dpy_cursor(s->ds, -1, -1);
|
||||
dpy_resize(s->ds, 60, 3);
|
||||
|
||||
for (dst = chardata, i = 0; i < 60 * 3; i ++)
|
||||
console_write_ch(dst ++, ' ');
|
||||
|
||||
size = strlen(msg_buffer);
|
||||
width = (60 - size) / 2;
|
||||
dst = chardata + 60 + width;
|
||||
for (i = 0; i < size; i ++)
|
||||
console_write_ch(dst ++, 0x00200100 | msg_buffer[i]);
|
||||
|
||||
dpy_update(s->ds, 0, 0, 60, 3);
|
||||
}
|
||||
|
||||
static CPUReadMemoryFunc *vga_mem_read[3] = {
|
||||
vga_mem_readb,
|
||||
vga_mem_readw,
|
||||
|
@ -1830,6 +1989,7 @@ void vga_common_init(VGAState *s, DisplayState *ds, uint8_t *vga_ram_base,
|
|||
s->update = vga_update_display;
|
||||
s->invalidate = vga_invalidate_display;
|
||||
s->screen_dump = vga_screen_dump;
|
||||
s->text_update = vga_update_text;
|
||||
}
|
||||
|
||||
/* used by both ISA and PCI */
|
||||
|
@ -1971,7 +2131,8 @@ int isa_vga_init(DisplayState *ds, uint8_t *vga_ram_base,
|
|||
vga_common_init(s, ds, vga_ram_base, vga_ram_offset, vga_ram_size);
|
||||
vga_init(s);
|
||||
|
||||
graphic_console_init(s->ds, s->update, s->invalidate, s->screen_dump, s);
|
||||
graphic_console_init(s->ds, s->update, s->invalidate, s->screen_dump,
|
||||
s->text_update, s);
|
||||
|
||||
#ifdef CONFIG_BOCHS_VBE
|
||||
/* XXX: use optimized standard vga accesses */
|
||||
|
@ -1995,7 +2156,8 @@ int isa_vga_mm_init(DisplayState *ds, uint8_t *vga_ram_base,
|
|||
vga_common_init(s, ds, vga_ram_base, vga_ram_offset, vga_ram_size);
|
||||
vga_mm_init(s, vram_base, ctrl_base, it_shift);
|
||||
|
||||
graphic_console_init(s->ds, s->update, s->invalidate, s->screen_dump, s);
|
||||
graphic_console_init(s->ds, s->update, s->invalidate, s->screen_dump,
|
||||
s->text_update, s);
|
||||
|
||||
#ifdef CONFIG_BOCHS_VBE
|
||||
/* XXX: use optimized standard vga accesses */
|
||||
|
@ -2023,7 +2185,8 @@ int pci_vga_init(PCIBus *bus, DisplayState *ds, uint8_t *vga_ram_base,
|
|||
vga_common_init(s, ds, vga_ram_base, vga_ram_offset, vga_ram_size);
|
||||
vga_init(s);
|
||||
|
||||
graphic_console_init(s->ds, s->update, s->invalidate, s->screen_dump, s);
|
||||
graphic_console_init(s->ds, s->update, s->invalidate, s->screen_dump,
|
||||
s->text_update, s);
|
||||
|
||||
s->pci_dev = &d->dev;
|
||||
|
||||
|
|
|
@ -139,6 +139,7 @@
|
|||
vga_hw_update_ptr update; \
|
||||
vga_hw_invalidate_ptr invalidate; \
|
||||
vga_hw_screen_dump_ptr screen_dump; \
|
||||
vga_hw_text_update_ptr text_update; \
|
||||
/* hardware mouse cursor support */ \
|
||||
uint32_t invalidated_y_table[VGA_MAX_HEIGHT / 32]; \
|
||||
void (*cursor_invalidate)(struct VGAState *s); \
|
||||
|
|
|
@ -949,6 +949,14 @@ static void vmsvga_screen_dump(void *opaque, const char *filename)
|
|||
}
|
||||
}
|
||||
|
||||
static void vmsvga_text_update(void *opaque, console_ch_t *chardata)
|
||||
{
|
||||
struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque;
|
||||
|
||||
if (s->text_update)
|
||||
s->text_update(opaque, chardata);
|
||||
}
|
||||
|
||||
#ifdef DIRECT_VRAM
|
||||
static uint32_t vmsvga_vram_readb(void *opaque, target_phys_addr_t addr)
|
||||
{
|
||||
|
@ -1101,7 +1109,8 @@ static void vmsvga_init(struct vmsvga_state_s *s, DisplayState *ds,
|
|||
iomemtype);
|
||||
|
||||
graphic_console_init(ds, vmsvga_update_display,
|
||||
vmsvga_invalidate_display, vmsvga_screen_dump, s);
|
||||
vmsvga_invalidate_display, vmsvga_screen_dump,
|
||||
vmsvga_text_update, s);
|
||||
|
||||
#ifdef EMBED_STDVGA
|
||||
vga_common_init((VGAState *) s, ds,
|
||||
|
|
|
@ -824,6 +824,8 @@ static const KeyDef key_defs[] = {
|
|||
{ 0x31, "n" },
|
||||
{ 0x32, "m" },
|
||||
|
||||
{ 0x37, "asterisk" },
|
||||
|
||||
{ 0x39, "spc" },
|
||||
{ 0x3a, "caps_lock" },
|
||||
{ 0x3b, "f1" },
|
||||
|
|
26
vl.c
26
vl.c
|
@ -172,6 +172,7 @@ BlockDriverState *bs_snapshots;
|
|||
int vga_ram_size;
|
||||
static DisplayState display_state;
|
||||
int nographic;
|
||||
int curses;
|
||||
const char* keyboard_layout = NULL;
|
||||
int64_t ticks_per_sec;
|
||||
int ram_size;
|
||||
|
@ -7651,6 +7652,9 @@ static void help(int exitcode)
|
|||
"-std-vga simulate a standard VGA card with VESA Bochs Extensions\n"
|
||||
" (default is CL-GD5446 PCI VGA)\n"
|
||||
"-no-acpi disable ACPI\n"
|
||||
#endif
|
||||
#ifdef CONFIG_CURSES
|
||||
"-curses use a curses/ncurses interface instead of SDL\n"
|
||||
#endif
|
||||
"-no-reboot exit instead of rebooting\n"
|
||||
"-loadvm file start right away with a saved state (loadvm in monitor)\n"
|
||||
|
@ -7757,6 +7761,7 @@ enum {
|
|||
QEMU_OPTION_smp,
|
||||
QEMU_OPTION_vnc,
|
||||
QEMU_OPTION_no_acpi,
|
||||
QEMU_OPTION_curses,
|
||||
QEMU_OPTION_no_reboot,
|
||||
QEMU_OPTION_show_cursor,
|
||||
QEMU_OPTION_daemonize,
|
||||
|
@ -7853,6 +7858,9 @@ const QEMUOption qemu_options[] = {
|
|||
{ "usbdevice", HAS_ARG, QEMU_OPTION_usbdevice },
|
||||
{ "smp", HAS_ARG, QEMU_OPTION_smp },
|
||||
{ "vnc", HAS_ARG, QEMU_OPTION_vnc },
|
||||
#ifdef CONFIG_CURSES
|
||||
{ "curses", 0, QEMU_OPTION_curses },
|
||||
#endif
|
||||
|
||||
/* temporary options */
|
||||
{ "usb", 0, QEMU_OPTION_usb },
|
||||
|
@ -8189,6 +8197,7 @@ int main(int argc, char **argv)
|
|||
#endif
|
||||
snapshot = 0;
|
||||
nographic = 0;
|
||||
curses = 0;
|
||||
kernel_filename = NULL;
|
||||
kernel_cmdline = "";
|
||||
cyls = heads = secs = 0;
|
||||
|
@ -8363,6 +8372,11 @@ int main(int argc, char **argv)
|
|||
pstrcpy(monitor_device, sizeof(monitor_device), "stdio");
|
||||
nographic = 1;
|
||||
break;
|
||||
#ifdef CONFIG_CURSES
|
||||
case QEMU_OPTION_curses:
|
||||
curses = 1;
|
||||
break;
|
||||
#endif
|
||||
case QEMU_OPTION_portrait:
|
||||
graphic_rotate = 1;
|
||||
break;
|
||||
|
@ -8903,13 +8917,23 @@ int main(int argc, char **argv)
|
|||
/* terminal init */
|
||||
memset(&display_state, 0, sizeof(display_state));
|
||||
if (nographic) {
|
||||
if (curses) {
|
||||
fprintf(stderr, "fatal: -nographic can't be used with -curses\n");
|
||||
exit(1);
|
||||
}
|
||||
/* nearly nothing to do */
|
||||
dumb_display_init(ds);
|
||||
} else if (vnc_display != NULL) {
|
||||
vnc_display_init(ds);
|
||||
if (vnc_display_open(ds, vnc_display) < 0)
|
||||
exit(1);
|
||||
} else {
|
||||
} else
|
||||
#if defined(CONFIG_CURSES)
|
||||
if (curses) {
|
||||
curses_display_init(ds, full_screen);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
#if defined(CONFIG_SDL)
|
||||
sdl_display_init(ds, full_screen, no_frame);
|
||||
#elif defined(CONFIG_COCOA)
|
||||
|
|
1
vnc.c
1
vnc.c
|
@ -945,6 +945,7 @@ static void do_key_event(VncState *vs, int down, uint32_t sym)
|
|||
return;
|
||||
}
|
||||
break;
|
||||
case 0x3a: /* CapsLock */
|
||||
case 0x45: /* NumLock */
|
||||
if (!down)
|
||||
vs->modifiers_state[keycode] ^= 1;
|
||||
|
|
Loading…
Reference in a new issue