Revision e78c48ec

b/console.h
44 44
    int a[7];
45 45
};
46 46

  
47
void do_info_mice(Monitor *mon);
47
void do_info_mice_print(Monitor *mon, const QObject *data);
48
void do_info_mice(Monitor *mon, QObject **ret_data);
48 49
void do_mouse_set(Monitor *mon, const QDict *qdict);
49 50

  
50 51
/* keysym is a unicode code except for special keys (see QEMU_KEY_xxx
b/monitor.c
2518 2518
        .args_type  = "",
2519 2519
        .params     = "",
2520 2520
        .help       = "show which guest mouse is receiving events",
2521
        .mhandler.info = do_info_mice,
2521
        .user_print = do_info_mice_print,
2522
        .mhandler.info_new = do_info_mice,
2522 2523
    },
2523 2524
    {
2524 2525
        .name       = "vnc",
b/vl.c
156 156
#include "balloon.h"
157 157
#include "qemu-option.h"
158 158
#include "qemu-config.h"
159
#include "qemu-objects.h"
159 160

  
160 161
#include "disas.h"
161 162

  
......
490 491
    return qemu_put_mouse_event_current->qemu_put_mouse_event_absolute;
491 492
}
492 493

  
493
void do_info_mice(Monitor *mon)
494
static void info_mice_iter(QObject *data, void *opaque)
495
{
496
    QDict *mouse;
497
    Monitor *mon = opaque;
498

  
499
    mouse = qobject_to_qdict(data);
500
    monitor_printf(mon, "%c Mouse #%" PRId64 ": %s\n",
501
                  (qdict_get_bool(mouse, "current") ? '*' : ' '),
502
                  qdict_get_int(mouse, "index"), qdict_get_str(mouse, "name"));
503
}
504

  
505
void do_info_mice_print(Monitor *mon, const QObject *data)
506
{
507
    QList *mice_list;
508

  
509
    mice_list = qobject_to_qlist(data);
510
    if (qlist_empty(mice_list)) {
511
        monitor_printf(mon, "No mouse devices connected\n");
512
        return;
513
    }
514

  
515
    qlist_iter(mice_list, info_mice_iter, mon);
516
}
517

  
518
/**
519
 * do_info_mice(): Show VM mice information
520
 *
521
 * Each mouse is represented by a QDict, the returned QObject is a QList of
522
 * all mice.
523
 *
524
 * The mouse QDict contains the following:
525
 *
526
 * - "name": mouse's name
527
 * - "index": mouse's index
528
 * - "current": true if this mouse is receiving events, false otherwise
529
 *
530
 * Example:
531
 *
532
 * [ { "name": "QEMU Microsoft Mouse", "index": 0, "current": false },
533
 *   { "name": "QEMU PS/2 Mouse", "index": 1, "current": true } ]
534
 */
535
void do_info_mice(Monitor *mon, QObject **ret_data)
494 536
{
495 537
    QEMUPutMouseEntry *cursor;
538
    QList *mice_list;
496 539
    int index = 0;
497 540

  
541
    mice_list = qlist_new();
542

  
498 543
    if (!qemu_put_mouse_event_head) {
499
        monitor_printf(mon, "No mouse devices connected\n");
500
        return;
544
        goto out;
501 545
    }
502 546

  
503
    monitor_printf(mon, "Mouse devices available:\n");
504 547
    cursor = qemu_put_mouse_event_head;
505 548
    while (cursor != NULL) {
506
        monitor_printf(mon, "%c Mouse #%d: %s\n",
507
                       (cursor == qemu_put_mouse_event_current ? '*' : ' '),
508
                       index, cursor->qemu_put_mouse_event_name);
549
        QObject *obj;
550
        obj = qobject_from_jsonf("{ 'name': %s, 'index': %d, 'current': %i }",
551
                                 cursor->qemu_put_mouse_event_name,
552
                                 index, cursor == qemu_put_mouse_event_current);
553
        qlist_append_obj(mice_list, obj);
509 554
        index++;
510 555
        cursor = cursor->next;
511 556
    }
557

  
558
out:
559
    *ret_data = QOBJECT(mice_list);
512 560
}
513 561

  
514 562
void do_mouse_set(Monitor *mon, const QDict *qdict)

Also available in: Unified diff