diff mbox series

[RFC,v2,3/7] sdl2: use only QKeyCode in sdl2_process_key()

Message ID 20181219120904.17643-4-kraxel@redhat.com
State New
Headers show
Series ui: add generic keyboard state tracker, fix keymap | expand

Commit Message

Gerd Hoffmann Dec. 19, 2018, 12:09 p.m. UTC
Small cleanup.  Also drop the special backspace handling,
kbd_put_qcode_console() learned to handle that meanwhile.
And sdl2_process_key is never called with scon == NULL.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 ui/sdl2-input.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

Comments

Daniel P. Berrangé Dec. 21, 2018, 11:06 a.m. UTC | #1
On Wed, Dec 19, 2018 at 01:09:00PM +0100, Gerd Hoffmann wrote:
> Small cleanup.  Also drop the special backspace handling,
> kbd_put_qcode_console() learned to handle that meanwhile.

I'm not seeing what backspace handlking is changed in this
patch - i guess this comment is left over from a previous
version of the patch.

> And sdl2_process_key is never called with scon == NULL.
> 
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
>  ui/sdl2-input.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/ui/sdl2-input.c b/ui/sdl2-input.c
> index ae52d548f6..78241c2a98 100644
> --- a/ui/sdl2-input.c
> +++ b/ui/sdl2-input.c
> @@ -39,20 +39,19 @@ void sdl2_process_key(struct sdl2_console *scon,
>                        SDL_KeyboardEvent *ev)
>  {
>      int qcode;
> -    QemuConsole *con = scon ? scon->dcl.con : NULL;
> +    QemuConsole *con = scon->dcl.con;
>  
>      if (ev->keysym.scancode >= qemu_input_map_usb_to_qcode_len) {
>          return;
>      }
> -
>      qcode = qemu_input_map_usb_to_qcode[ev->keysym.scancode];
>      kbd_state_key_event(scon->kbd, qcode, ev->type == SDL_KEYDOWN);
>  
>      if (!qemu_console_is_graphic(con)) {
>          bool ctrl = kbd_state_modifier_get(scon->kbd, KBD_MOD_CTRL);
>          if (ev->type == SDL_KEYDOWN) {
> -            switch (ev->keysym.scancode) {
> -            case SDL_SCANCODE_RETURN:
> +            switch (qcode) {
> +            case Q_KEY_CODE_RET:
>                  kbd_put_keysym_console(con, '\n');
>                  break;
>              default:

With fixed commit message

  Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


Regards,
Daniel
diff mbox series

Patch

diff --git a/ui/sdl2-input.c b/ui/sdl2-input.c
index ae52d548f6..78241c2a98 100644
--- a/ui/sdl2-input.c
+++ b/ui/sdl2-input.c
@@ -39,20 +39,19 @@  void sdl2_process_key(struct sdl2_console *scon,
                       SDL_KeyboardEvent *ev)
 {
     int qcode;
-    QemuConsole *con = scon ? scon->dcl.con : NULL;
+    QemuConsole *con = scon->dcl.con;
 
     if (ev->keysym.scancode >= qemu_input_map_usb_to_qcode_len) {
         return;
     }
-
     qcode = qemu_input_map_usb_to_qcode[ev->keysym.scancode];
     kbd_state_key_event(scon->kbd, qcode, ev->type == SDL_KEYDOWN);
 
     if (!qemu_console_is_graphic(con)) {
         bool ctrl = kbd_state_modifier_get(scon->kbd, KBD_MOD_CTRL);
         if (ev->type == SDL_KEYDOWN) {
-            switch (ev->keysym.scancode) {
-            case SDL_SCANCODE_RETURN:
+            switch (qcode) {
+            case Q_KEY_CODE_RET:
                 kbd_put_keysym_console(con, '\n');
                 break;
             default: