[PATCH RFC 00/28] ui/input: Decouple internal and QAPI input events

Akihiko Odaki posted 28 patches 2 weeks, 2 days ago
Failed in applying to current master (apply log)
There is a newer version of this series
include/qemu/typedefs.h      |   1 +
include/system/replay.h      |   2 +-
include/ui/console.h         |   3 +-
include/ui/input.h           |  92 ++++++++------
include/ui/kbd-state.h       |   8 +-
replay/replay-internal.h     |   6 +-
ui/x_keymap.h                |   3 +-
chardev/msmouse.c            |  12 +-
chardev/wctablet.c           |  10 +-
hw/arm/musicpal.c            |  31 +++--
hw/char/escc.c               |  45 +++----
hw/display/xenfb.c           |  51 +++-----
hw/input/adb-kbd.c           | 246 ++++++++++++++++++-------------------
hw/input/adb-mouse.c         |  22 ++--
hw/input/hid.c               |  41 +++----
hw/input/ps2.c               | 116 +++++++++--------
hw/input/stellaris_gamepad.c |  11 +-
hw/input/virtio-input-hid.c  |  89 +++++++-------
hw/m68k/next-kbd.c           | 128 +++++++++----------
qemu-keymap.c                |  41 +++----
replay/replay-events.c       |   6 +-
replay/replay-input.c        | 117 ++++++------------
replay/replay.c              |   2 +-
replay/stubs-system.c        |   2 +-
ui/console.c                 |  62 ++++++----
ui/dbus-console.c            |   8 +-
ui/gtk.c                     |  49 ++++----
ui/input-barrier.c           |  26 ++--
ui/input-keymap.c            |  74 +++++------
ui/input-legacy.c            |  47 +++----
ui/input-linux.c             |   3 +-
ui/input.c                   | 229 ++++++++++++++--------------------
ui/kbd-state.c               |  55 +++++----
ui/keymaps.c                 |   4 +-
ui/sdl2-input.c              |  17 +--
ui/spice-input.c             |   3 +-
ui/vdagent.c                 |  20 ++-
ui/vnc.c                     |  25 ++--
ui/x_keymap.c                |  24 ++--
hw/input/trace-events        |   2 +-
ui/cocoa.m                   | 287 ++++++++++++++++++++++---------------------
ui/meson.build               |  29 +++--
ui/trace-events              |   3 +-
43 files changed, 962 insertions(+), 1090 deletions(-)
[PATCH RFC 00/28] ui/input: Decouple internal and QAPI input events
Posted by Akihiko Odaki 2 weeks, 2 days ago
The internal input event representation has different requirements from
the QAPI representation. Using QAPI types directly spreads QAPI-specific
constraints throughout the internal input code. Keep that impact
localized by decoupling the two representations with a dedicated
conversion layer. The decoupled internal representation has the
following benefits:

- It avoids wrapper structs and pointer indirections required by QAPI.
  They are useful at the QMP boundary, but unnecessary for internal
  input events and make handlers more verbose.

- It enforces a single key code set while QAPI input events allow key
  codes to be stored either as qnum or qcode. Having two code sets is
  useful for QMP compatibility, but complicates internal input handling.
  Commit af07e5ff02ae ("ui: convert key events to QKeyCodes
  immediately") made qcode the only key code set used internally, but
  the QAPI type does not enforce that and accessing the key code is
  still tedious.

- It uses Linux key codes. They cover all keys represented by qcodes,
  include additional keys, and allow QEMU to pass codes through from
  Linux hosts to Linux guests. This also simplifies the code by avoiding
  qcode aliases and matches the approach used by virtio and Xen. Since
  this is an internal representation, QEMU can extend the key code set
  if a QEMU-specific need arises.

Only the switch to Linux key codes is intended to change functional
behavior. The interfaces that require QKeyCode are still preserved and
QKeyCode_str() is still used to query key names. Changing QAPI to accept
Linux key codes is possible, but out of scope for this series.

This series is organized as follows:
Patches 1-6 convert the internal interfaces.
Patches 7-26 convert their users.
Patches 27-28 remove the old internal interfaces.

Signed-off-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>

---
Akihiko Odaki (28):
      ui/input: Introduce QemuInputEvent typedef
      ui/input: Remove QAPI wrappers from QemuInputEvent
      ui/input: Store QKeyCode directly in QemuInputKeyEvent
      ui/input: Use Linux key codes for internal key events
      ui/console: Add qemu_text_console_put_linux()
      ui/kbd-state: Use Linux key codes
      hw/arm/musicpal: Use Linux key codes
      hw/char/escc: Use Linux key codes
      hw/display/xenfb: Use Linux key codes
      hw/input/adb-kbd: Use Linux key codes
      hw/input/hid: Use Linux key codes
      hw/input/ps2: Use Linux key codes
      hw/input/virtio-input: Use Linux key codes
      hw/m68k/next-kbd: Use Linux key codes
      replay: Use Linux key codes
      ui/cocoa: Use Linux key codes
      ui/dbus: Use Linux key codes
      ui/gtk: Use Linux key codes
      ui/input-barrier: Use Linux key codes
      ui/input-legacy: Use Linux key codes
      ui/input-linux: Use Linux key codes
      ui/keymaps: Use Linux key codes
      ui/sdl2: Use Linux key codes
      ui/spice: Use Linux key codes
      ui/vnc: Use Linux key codes
      qemu-keymap: Use Linux key codes
      ui/console: Remove qemu_text_console_put_qcode()
      ui/input: Remove unused QKeyCode helpers and keymaps

 include/qemu/typedefs.h      |   1 +
 include/system/replay.h      |   2 +-
 include/ui/console.h         |   3 +-
 include/ui/input.h           |  92 ++++++++------
 include/ui/kbd-state.h       |   8 +-
 replay/replay-internal.h     |   6 +-
 ui/x_keymap.h                |   3 +-
 chardev/msmouse.c            |  12 +-
 chardev/wctablet.c           |  10 +-
 hw/arm/musicpal.c            |  31 +++--
 hw/char/escc.c               |  45 +++----
 hw/display/xenfb.c           |  51 +++-----
 hw/input/adb-kbd.c           | 246 ++++++++++++++++++-------------------
 hw/input/adb-mouse.c         |  22 ++--
 hw/input/hid.c               |  41 +++----
 hw/input/ps2.c               | 116 +++++++++--------
 hw/input/stellaris_gamepad.c |  11 +-
 hw/input/virtio-input-hid.c  |  89 +++++++-------
 hw/m68k/next-kbd.c           | 128 +++++++++----------
 qemu-keymap.c                |  41 +++----
 replay/replay-events.c       |   6 +-
 replay/replay-input.c        | 117 ++++++------------
 replay/replay.c              |   2 +-
 replay/stubs-system.c        |   2 +-
 ui/console.c                 |  62 ++++++----
 ui/dbus-console.c            |   8 +-
 ui/gtk.c                     |  49 ++++----
 ui/input-barrier.c           |  26 ++--
 ui/input-keymap.c            |  74 +++++------
 ui/input-legacy.c            |  47 +++----
 ui/input-linux.c             |   3 +-
 ui/input.c                   | 229 ++++++++++++++--------------------
 ui/kbd-state.c               |  55 +++++----
 ui/keymaps.c                 |   4 +-
 ui/sdl2-input.c              |  17 +--
 ui/spice-input.c             |   3 +-
 ui/vdagent.c                 |  20 ++-
 ui/vnc.c                     |  25 ++--
 ui/x_keymap.c                |  24 ++--
 hw/input/trace-events        |   2 +-
 ui/cocoa.m                   | 287 ++++++++++++++++++++++---------------------
 ui/meson.build               |  29 +++--
 ui/trace-events              |   3 +-
 43 files changed, 962 insertions(+), 1090 deletions(-)
---
base-commit: 759c456b1d22fe4083c8b384da27d3f56fd53f82
change-id: 20260428-input-9b94f389ea55

Best regards,
--  
Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>