aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hw/input/hid.c1
-rw-r--r--hw/input/ps2.c28
-rw-r--r--include/hw/input/ps2.h4
-rw-r--r--include/qemu/typedefs.h1
-rw-r--r--ui/cocoa.m56
-rw-r--r--ui/input.c1
-rw-r--r--ui/keymaps.c33
-rw-r--r--ui/sdl2.c1
-rw-r--r--ui/trace-events5
9 files changed, 101 insertions, 29 deletions
diff --git a/hw/input/hid.c b/hw/input/hid.c
index 93887ec..0d049ff 100644
--- a/hw/input/hid.c
+++ b/hw/input/hid.c
@@ -487,6 +487,7 @@ void hid_reset(HIDState *hs)
memset(hs->kbd.keycodes, 0, sizeof(hs->kbd.keycodes));
memset(hs->kbd.key, 0, sizeof(hs->kbd.key));
hs->kbd.keys = 0;
+ hs->kbd.modifiers = 0;
break;
case HID_MOUSE:
case HID_TABLET:
diff --git a/hw/input/ps2.c b/hw/input/ps2.c
index 1d3a440..3ba05ef 100644
--- a/hw/input/ps2.c
+++ b/hw/input/ps2.c
@@ -85,12 +85,12 @@ typedef struct {
int rptr, wptr, count;
} PS2Queue;
-typedef struct {
+struct PS2State {
PS2Queue queue;
int32_t write_cmd;
void (*update_irq)(void *, int);
void *update_arg;
-} PS2State;
+};
typedef struct {
PS2State common;
@@ -551,9 +551,17 @@ static uint8_t translate_table[256] = {
0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
};
-void ps2_queue(void *opaque, int b)
+static void ps2_reset_queue(PS2State *s)
+{
+ PS2Queue *q = &s->queue;
+
+ q->rptr = 0;
+ q->wptr = 0;
+ q->count = 0;
+}
+
+void ps2_queue(PS2State *s, int b)
{
- PS2State *s = (PS2State *)opaque;
PS2Queue *q = &s->queue;
if (q->count >= PS2_QUEUE_SIZE - 1)
@@ -692,13 +700,12 @@ static void ps2_keyboard_event(DeviceState *dev, QemuConsole *src,
}
}
-uint32_t ps2_read_data(void *opaque)
+uint32_t ps2_read_data(PS2State *s)
{
- PS2State *s = (PS2State *)opaque;
PS2Queue *q;
int val, index;
- trace_ps2_read_data(opaque);
+ trace_ps2_read_data(s);
q = &s->queue;
if (q->count == 0) {
/* NOTE: if no data left, we return the last keyboard one
@@ -733,6 +740,7 @@ static void ps2_reset_keyboard(PS2KbdState *s)
trace_ps2_reset_keyboard(s);
s->scan_enabled = 1;
s->scancode_set = 2;
+ ps2_reset_queue(&s->common);
ps2_set_ledstate(s, 0);
}
@@ -1081,12 +1089,8 @@ void ps2_write_mouse(void *opaque, int val)
static void ps2_common_reset(PS2State *s)
{
- PS2Queue *q;
s->write_cmd = -1;
- q = &s->queue;
- q->rptr = 0;
- q->wptr = 0;
- q->count = 0;
+ ps2_reset_queue(s);
s->update_irq(s->update_arg, 0);
}
diff --git a/include/hw/input/ps2.h b/include/hw/input/ps2.h
index 7f0a80a..94709b8 100644
--- a/include/hw/input/ps2.h
+++ b/include/hw/input/ps2.h
@@ -36,8 +36,8 @@ void *ps2_kbd_init(void (*update_irq)(void *, int), void *update_arg);
void *ps2_mouse_init(void (*update_irq)(void *, int), void *update_arg);
void ps2_write_mouse(void *, int val);
void ps2_write_keyboard(void *, int val);
-uint32_t ps2_read_data(void *);
-void ps2_queue(void *, int b);
+uint32_t ps2_read_data(PS2State *s);
+void ps2_queue(PS2State *s, int b);
void ps2_keyboard_set_translation(void *opaque, int mode);
void ps2_mouse_fake_event(void *opaque);
diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h
index f745d5f..2706aab 100644
--- a/include/qemu/typedefs.h
+++ b/include/qemu/typedefs.h
@@ -76,6 +76,7 @@ typedef struct PixelFormat PixelFormat;
typedef struct PostcopyDiscardState PostcopyDiscardState;
typedef struct Property Property;
typedef struct PropertyInfo PropertyInfo;
+typedef struct PS2State PS2State;
typedef struct QEMUBH QEMUBH;
typedef struct QemuConsole QemuConsole;
typedef struct QEMUFile QEMUFile;
diff --git a/ui/cocoa.m b/ui/cocoa.m
index 1f010d3..9e81285 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -35,6 +35,7 @@
#include "sysemu/blockdev.h"
#include "qemu-version.h"
#include <Carbon/Carbon.h>
+#include "qom/cpu.h"
#ifndef MAC_OS_X_VERSION_10_5
#define MAC_OS_X_VERSION_10_5 1050
@@ -893,6 +894,7 @@ QemuCocoaView *cocoaView;
- (void)openDocumentation:(NSString *)filename;
- (IBAction) do_about_menu_item: (id) sender;
- (void)make_about_window;
+- (void)adjustSpeed:(id)sender;
@end
@implementation QemuCocoaAppController
@@ -1299,6 +1301,34 @@ QemuCocoaView *cocoaView;
[superView addSubview: copyright_label];
}
+/* Used by the Speed menu items */
+- (void)adjustSpeed:(id)sender
+{
+ int throttle_pct; /* throttle percentage */
+ NSMenu *menu;
+
+ menu = [sender menu];
+ if (menu != nil)
+ {
+ /* Unselect the currently selected item */
+ for (NSMenuItem *item in [menu itemArray]) {
+ if (item.state == NSOnState) {
+ [item setState: NSOffState];
+ break;
+ }
+ }
+ }
+
+ // check the menu item
+ [sender setState: NSOnState];
+
+ // get the throttle percentage
+ throttle_pct = [sender tag];
+
+ cpu_throttle_set(throttle_pct);
+ COCOA_DEBUG("cpu throttling at %d%c\n", cpu_throttle_get_percentage(), '%');
+}
+
@end
@@ -1381,6 +1411,32 @@ int main (int argc, const char * argv[]) {
[menuItem setSubmenu:menu];
[[NSApp mainMenu] addItem:menuItem];
+ // Speed menu
+ menu = [[NSMenu alloc] initWithTitle:@"Speed"];
+
+ // Add the rest of the Speed menu items
+ int p, percentage, throttle_pct;
+ for (p = 10; p >= 0; p--)
+ {
+ percentage = p * 10 > 1 ? p * 10 : 1; // prevent a 0% menu item
+
+ menuItem = [[[NSMenuItem alloc]
+ initWithTitle: [NSString stringWithFormat: @"%d%%", percentage] action:@selector(adjustSpeed:) keyEquivalent:@""] autorelease];
+
+ if (percentage == 100) {
+ [menuItem setState: NSOnState];
+ }
+
+ /* Calculate the throttle percentage */
+ throttle_pct = -1 * percentage + 100;
+
+ [menuItem setTag: throttle_pct];
+ [menu addItem: menuItem];
+ }
+ menuItem = [[[NSMenuItem alloc] initWithTitle:@"Speed" action:nil keyEquivalent:@""] autorelease];
+ [menuItem setSubmenu:menu];
+ [[NSApp mainMenu] addItem:menuItem];
+
// Window menu
menu = [[NSMenu alloc] initWithTitle:@"Window"];
[menu addItem: [[[NSMenuItem alloc] initWithTitle:@"Minimize" action:@selector(performMiniaturize:) keyEquivalent:@"m"] autorelease]]; // Miniaturize
diff --git a/ui/input.c b/ui/input.c
index 2abd46d..af05f06 100644
--- a/ui/input.c
+++ b/ui/input.c
@@ -256,6 +256,7 @@ static void qemu_input_queue_process(void *opaque)
item = QTAILQ_FIRST(queue);
g_assert(item->type == QEMU_INPUT_QUEUE_DELAY);
QTAILQ_REMOVE(queue, item, node);
+ queue_count--;
g_free(item);
while (!QTAILQ_EMPTY(queue)) {
diff --git a/ui/keymaps.c b/ui/keymaps.c
index 8899a0b..fa00b82 100644
--- a/ui/keymaps.c
+++ b/ui/keymaps.c
@@ -25,6 +25,7 @@
#include "qemu/osdep.h"
#include "keymaps.h"
#include "sysemu/sysemu.h"
+#include "trace.h"
static int get_keysym(const name2keysym_t *table,
const char *name)
@@ -71,18 +72,14 @@ static void add_to_key_range(struct key_range **krp, int code) {
static void add_keysym(char *line, int keysym, int keycode, kbd_layout_t *k) {
if (keysym < MAX_NORMAL_KEYCODE) {
- /* fprintf(stderr,"Setting keysym %s (%d) to %d\n",
- line, keysym, keycode); */
+ trace_keymap_add("normal", keysym, keycode, line);
k->keysym2keycode[keysym] = keycode;
} else {
if (k->extra_count >= MAX_EXTRA_COUNT) {
fprintf(stderr, "Warning: Could not assign keysym %s (0x%x)"
" because of memory constraints.\n", line, keysym);
} else {
-#if 0
- fprintf(stderr, "Setting %d: %d,%d\n",
- k->extra_count, keysym, keycode);
-#endif
+ trace_keymap_add("extra", keysym, keycode, line);
k->keysym2keycode_extra[k->extra_count].
keysym = keysym;
k->keysym2keycode_extra[k->extra_count].
@@ -99,9 +96,11 @@ static kbd_layout_t *parse_keyboard_layout(const name2keysym_t *table,
FILE *f;
char * filename;
char line[1024];
+ char keyname[64];
int len;
filename = qemu_find_file(QEMU_FILE_TYPE_KEYMAP, language);
+ trace_keymap_parse(filename);
f = filename ? fopen(filename, "r") : NULL;
g_free(filename);
if (!f) {
@@ -130,18 +129,21 @@ static kbd_layout_t *parse_keyboard_layout(const name2keysym_t *table,
if (!strncmp(line, "include ", 8)) {
parse_keyboard_layout(table, line + 8, k);
} else {
- char *end_of_keysym = line;
- while (*end_of_keysym != 0 && *end_of_keysym != ' ') {
- end_of_keysym++;
+ int offset = 0;
+ while (line[offset] != 0 &&
+ line[offset] != ' ' &&
+ offset < sizeof(keyname) - 1) {
+ keyname[offset] = line[offset];
+ offset++;
}
- if (*end_of_keysym) {
+ keyname[offset] = 0;
+ if (strlen(keyname)) {
int keysym;
- *end_of_keysym = 0;
- keysym = get_keysym(table, line);
+ keysym = get_keysym(table, keyname);
if (keysym == 0) {
/* fprintf(stderr, "Warning: unknown keysym %s\n", line);*/
} else {
- const char *rest = end_of_keysym + 1;
+ const char *rest = line + offset + 1;
int keycode = strtol(rest, NULL, 0);
if (strstr(rest, "numlock")) {
@@ -165,10 +167,10 @@ static kbd_layout_t *parse_keyboard_layout(const name2keysym_t *table,
if (strstr(rest, "addupper")) {
char *c;
- for (c = line; *c; c++) {
+ for (c = keyname; *c; c++) {
*c = qemu_toupper(*c);
}
- keysym = get_keysym(table, line);
+ keysym = get_keysym(table, keyname);
if (keysym) {
add_keysym(line, keysym,
keycode | SCANCODE_SHIFT, k);
@@ -194,6 +196,7 @@ int keysym2scancode(void *kbd_layout, int keysym)
kbd_layout_t *k = kbd_layout;
if (keysym < MAX_NORMAL_KEYCODE) {
if (k->keysym2keycode[keysym] == 0) {
+ trace_keymap_unmapped(keysym);
fprintf(stderr, "Warning: no scancode found for keysym %d\n",
keysym);
}
diff --git a/ui/sdl2.c b/ui/sdl2.c
index f76ee10..53dd447 100644
--- a/ui/sdl2.c
+++ b/ui/sdl2.c
@@ -804,6 +804,7 @@ void sdl_display_init(DisplayState *ds, int full_screen, int no_frame)
sdl2_console = g_new0(struct sdl2_console, sdl2_num_outputs);
for (i = 0; i < sdl2_num_outputs; i++) {
QemuConsole *con = qemu_console_lookup_by_index(i);
+ assert(con != NULL);
if (!qemu_console_is_graphic(con)) {
sdl2_console[i].hidden = true;
}
diff --git a/ui/trace-events b/ui/trace-events
index 93fe548..19ce5f8 100644
--- a/ui/trace-events
+++ b/ui/trace-events
@@ -46,3 +46,8 @@ qemu_spice_create_primary_surface(int qid, uint32_t sid, void *surface, int asyn
qemu_spice_destroy_primary_surface(int qid, uint32_t sid, int async) "%d sid=%u async=%d"
qemu_spice_wakeup(uint32_t qid) "%d"
qemu_spice_create_update(uint32_t left, uint32_t right, uint32_t top, uint32_t bottom) "lr %d -> %d, tb -> %d -> %d"
+
+# ui/keymaps.c
+keymap_parse(const char *file) "file %s"
+keymap_add(const char *type, int sym, int code, const char *line) "%-6s sym=0x%04x code=0x%04x (line: %s)"
+keymap_unmapped(int sym) "sym=0x%04x"