input.c (57b93c0f8ea3901661990de74aef15b44aea5556) input.c (0337e4123e62721bd0bcb4d5645fee2a31e8906d)
1#include "qemu/osdep.h"
2#include "sysemu/sysemu.h"
3#include "qapi/error.h"
4#include "qapi/qapi-commands-ui.h"
5#include "trace.h"
6#include "ui/input.h"
7#include "ui/console.h"
8#include "sysemu/replay.h"

--- 42 unchanged lines hidden (view full) ---

51 QemuInputHandlerState *s = g_new0(QemuInputHandlerState, 1);
52 static int id = 1;
53
54 s->dev = dev;
55 s->handler = handler;
56 s->id = id++;
57 QTAILQ_INSERT_TAIL(&handlers, s, node);
58
1#include "qemu/osdep.h"
2#include "sysemu/sysemu.h"
3#include "qapi/error.h"
4#include "qapi/qapi-commands-ui.h"
5#include "trace.h"
6#include "ui/input.h"
7#include "ui/console.h"
8#include "sysemu/replay.h"

--- 42 unchanged lines hidden (view full) ---

51 QemuInputHandlerState *s = g_new0(QemuInputHandlerState, 1);
52 static int id = 1;
53
54 s->dev = dev;
55 s->handler = handler;
56 s->id = id++;
57 QTAILQ_INSERT_TAIL(&handlers, s, node);
58
59 qemu_input_check_mode_change();
59 notifier_list_notify(&mouse_mode_notifiers, NULL);
60 return s;
61}
62
63void qemu_input_handler_activate(QemuInputHandlerState *s)
64{
65 QTAILQ_REMOVE(&handlers, s, node);
66 QTAILQ_INSERT_HEAD(&handlers, s, node);
60 return s;
61}
62
63void qemu_input_handler_activate(QemuInputHandlerState *s)
64{
65 QTAILQ_REMOVE(&handlers, s, node);
66 QTAILQ_INSERT_HEAD(&handlers, s, node);
67 qemu_input_check_mode_change();
67 notifier_list_notify(&mouse_mode_notifiers, NULL);
68}
69
70void qemu_input_handler_deactivate(QemuInputHandlerState *s)
71{
72 QTAILQ_REMOVE(&handlers, s, node);
73 QTAILQ_INSERT_TAIL(&handlers, s, node);
68}
69
70void qemu_input_handler_deactivate(QemuInputHandlerState *s)
71{
72 QTAILQ_REMOVE(&handlers, s, node);
73 QTAILQ_INSERT_TAIL(&handlers, s, node);
74 qemu_input_check_mode_change();
74 notifier_list_notify(&mouse_mode_notifiers, NULL);
75}
76
77void qemu_input_handler_unregister(QemuInputHandlerState *s)
78{
79 QTAILQ_REMOVE(&handlers, s, node);
80 g_free(s);
75}
76
77void qemu_input_handler_unregister(QemuInputHandlerState *s)
78{
79 QTAILQ_REMOVE(&handlers, s, node);
80 g_free(s);
81 qemu_input_check_mode_change();
81 notifier_list_notify(&mouse_mode_notifiers, NULL);
82}
83
84void qemu_input_handler_bind(QemuInputHandlerState *s,
85 const char *device_id, int head,
86 Error **errp)
87{
88 QemuConsole *con;
89 Error *err = NULL;

--- 399 unchanged lines hidden (view full) ---

489 mask = button_map[btn];
490 if ((button_old & mask) == (button_new & mask)) {
491 continue;
492 }
493 qemu_input_queue_btn(src, btn, button_new & mask);
494 }
495}
496
82}
83
84void qemu_input_handler_bind(QemuInputHandlerState *s,
85 const char *device_id, int head,
86 Error **errp)
87{
88 QemuConsole *con;
89 Error *err = NULL;

--- 399 unchanged lines hidden (view full) ---

489 mask = button_map[btn];
490 if ((button_old & mask) == (button_new & mask)) {
491 continue;
492 }
493 qemu_input_queue_btn(src, btn, button_new & mask);
494 }
495}
496
497bool qemu_input_is_absolute(void)
497bool qemu_input_is_absolute(QemuConsole *con)
498{
499 QemuInputHandlerState *s;
500
501 s = qemu_input_find_handler(INPUT_EVENT_MASK_REL | INPUT_EVENT_MASK_ABS,
498{
499 QemuInputHandlerState *s;
500
501 s = qemu_input_find_handler(INPUT_EVENT_MASK_REL | INPUT_EVENT_MASK_ABS,
502 NULL);
502 con);
503 return (s != NULL) && (s->handler->mask & INPUT_EVENT_MASK_ABS);
504}
505
506int qemu_input_scale_axis(int value,
507 int min_in, int max_in,
508 int min_out, int max_out)
509{
510 int64_t range_in = (int64_t)max_in - min_in;

--- 67 unchanged lines hidden (view full) ---

578 InputEvent evt = {
579 .type = INPUT_EVENT_KIND_MTT,
580 .u.mtt.data = &mtt,
581 };
582
583 qemu_input_event_send(src, &evt);
584}
585
503 return (s != NULL) && (s->handler->mask & INPUT_EVENT_MASK_ABS);
504}
505
506int qemu_input_scale_axis(int value,
507 int min_in, int max_in,
508 int min_out, int max_out)
509{
510 int64_t range_in = (int64_t)max_in - min_in;

--- 67 unchanged lines hidden (view full) ---

578 InputEvent evt = {
579 .type = INPUT_EVENT_KIND_MTT,
580 .u.mtt.data = &mtt,
581 };
582
583 qemu_input_event_send(src, &evt);
584}
585
586void qemu_input_check_mode_change(void)
587{
588 static int current_is_absolute;
589 int is_absolute;
590
591 is_absolute = qemu_input_is_absolute();
592
593 if (is_absolute != current_is_absolute) {
594 trace_input_mouse_mode(is_absolute);
595 notifier_list_notify(&mouse_mode_notifiers, NULL);
596 }
597
598 current_is_absolute = is_absolute;
599}
600
601void qemu_add_mouse_mode_change_notifier(Notifier *notify)
602{
603 notifier_list_add(&mouse_mode_notifiers, notify);
604}
605
606void qemu_remove_mouse_mode_change_notifier(Notifier *notify)
607{
608 notifier_remove(notify);

--- 43 unchanged lines hidden (view full) ---

652 if (!(s->handler->mask & (INPUT_EVENT_MASK_REL |
653 INPUT_EVENT_MASK_ABS))) {
654 error_setg(errp, "Input device '%s' is not a mouse",
655 s->handler->name);
656 return false;
657 }
658
659 qemu_input_handler_activate(s);
586void qemu_add_mouse_mode_change_notifier(Notifier *notify)
587{
588 notifier_list_add(&mouse_mode_notifiers, notify);
589}
590
591void qemu_remove_mouse_mode_change_notifier(Notifier *notify)
592{
593 notifier_remove(notify);

--- 43 unchanged lines hidden (view full) ---

637 if (!(s->handler->mask & (INPUT_EVENT_MASK_REL |
638 INPUT_EVENT_MASK_ABS))) {
639 error_setg(errp, "Input device '%s' is not a mouse",
640 s->handler->name);
641 return false;
642 }
643
644 qemu_input_handler_activate(s);
660 qemu_input_check_mode_change();
645 notifier_list_notify(&mouse_mode_notifiers, NULL);
661 return true;
662}
646 return true;
647}