hw/char/pl011: fix receiving multiple chars
PATCH 1/1 hw/char/pl011: fix receiving multiple chars
When using the GTK UI with libvte, multicharacter keystrokes are not sent correctly (such as arrow keys). This is not an issue for e.g. the SDL UI because qemu_chr_be_write is called with len=1 for each character (SDL sends more than once keystroke).
--- hw/char/pl011.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
hw/char/pl011.c +3 -1
@@ -300,7 +300,9 @@ static void pl011_put_fifo(void *opaque, uint32_t value)static void pl011_receive (void *opaque,const uint8_t *buf,int size) { -pl011_put_fifo (opaque, *buf); +for (int i =0 ; i < size; i++) { +pl011_put_fifo (opaque, buf[i]); + } }static void pl011_event (void *opaque,QEMUChrEvent event)
Signature · 1 line
2.20.1
Quoted 11 lines · Zack Marvel
When using the GTK UI with libvte, multicharacter keystrokes are not sent correctly (such as arrow keys). This is not an issue for e.g. the SDL UI because
qemu_chr_be_writeis called with len=1 for each character (SDL sends more than once keystroke).Signed-off-by Zack Marvel <[email protected]>
hw/char/pl011.c static void pl011_put_fifo(void *opaque, uint32_t value) · line 306
Quoted 8 lines
hw/char/pl011.c +3
-1@@ -300,7 +300,9 @@ static void pl011_put_fifo(void *opaque, uint32_t value)static void pl011_receive (void *opaque,const uint8_t *buf,int size) { -pl011_put_fifo (opaque, *buf); +for (int i =0 ; i < size; i++) { +pl011_put_fifo (opaque, buf[i]); + } }
I think this is a bug in whatever is on the other end of the chardev connection. The pl011 can_receive routine only ever returns 0 or 1, so it is an error for the code calling its receive function to ever pass a size that is greater than 1.
thanks
-- PMM
Peter,
Thanks for the quick review. You're right, I misunderstood the API and the bug is in ui/gtk.c.
Thanks,
Zack M
Quoted 30 lines · Peter Maydell
Quoted 11 lines · Zack Marvel
When using the GTK UI with libvte, multicharacter keystrokes are not sent correctly (such as arrow keys). This is not an issue for e.g. the SDL UI because
qemu_chr_be_writeis called with len=1 for each character (SDL sends more than once keystroke).Signed-off-by Zack Marvel <[email protected]>hw/char/pl011.c static void pl011_put_fifo(void *opaque, uint32_t value) · line 306
Quoted 8 lines
hw/char/pl011.c +3
-1@@ -300,7 +300,9 @@ static void pl011_put_fifo(void *opaque, uint32_t value)static void pl011_receive (void *opaque,const uint8_t *buf,int size) { -pl011_put_fifo (opaque, *buf); +for (int i =0 ; i < size; i++) { +pl011_put_fifo (opaque, buf[i]); + } }I think this is a bug in whatever is on the other end of the chardev connection. The pl011
can_receiveroutine only ever returns 0 or 1, so it is an error for the code calling its receive function to ever pass a size that is greater than 1.thanks
-- PMM