Commit bb0a18e11056c3b8c32e65b97340ca8ae84ba855
Committed by
Anthony Liguori
1 parent
5c5dafdc
vnc: improve numpad support for qemu console.
Reorganize qemu console emulation code. Make it look at the numlock state and interpret numpad keys as arrow+friends (numlock off) or digits (numlock on). While being at it also wind up the other numpad keys. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Showing
1 changed file
with
52 additions
and
9 deletions
vnc.c
... | ... | @@ -1361,6 +1361,7 @@ static void do_key_event(VncState *vs, int down, int keycode, int sym) |
1361 | 1361 | } else { |
1362 | 1362 | /* QEMU console emulation */ |
1363 | 1363 | if (down) { |
1364 | + int numlock = vs->modifiers_state[0x45]; | |
1364 | 1365 | switch (keycode) { |
1365 | 1366 | case 0x2a: /* Left Shift */ |
1366 | 1367 | case 0x36: /* Right Shift */ |
... | ... | @@ -1370,41 +1371,83 @@ static void do_key_event(VncState *vs, int down, int keycode, int sym) |
1370 | 1371 | case 0xb8: /* Right ALT */ |
1371 | 1372 | break; |
1372 | 1373 | case 0xc8: |
1373 | - case 0x48: | |
1374 | 1374 | kbd_put_keysym(QEMU_KEY_UP); |
1375 | 1375 | break; |
1376 | 1376 | case 0xd0: |
1377 | - case 0x50: | |
1378 | 1377 | kbd_put_keysym(QEMU_KEY_DOWN); |
1379 | 1378 | break; |
1380 | 1379 | case 0xcb: |
1381 | - case 0x4b: | |
1382 | 1380 | kbd_put_keysym(QEMU_KEY_LEFT); |
1383 | 1381 | break; |
1384 | 1382 | case 0xcd: |
1385 | - case 0x4d: | |
1386 | 1383 | kbd_put_keysym(QEMU_KEY_RIGHT); |
1387 | 1384 | break; |
1388 | 1385 | case 0xd3: |
1389 | - case 0x53: | |
1390 | 1386 | kbd_put_keysym(QEMU_KEY_DELETE); |
1391 | 1387 | break; |
1392 | 1388 | case 0xc7: |
1393 | - case 0x47: | |
1394 | 1389 | kbd_put_keysym(QEMU_KEY_HOME); |
1395 | 1390 | break; |
1396 | 1391 | case 0xcf: |
1397 | - case 0x4f: | |
1398 | 1392 | kbd_put_keysym(QEMU_KEY_END); |
1399 | 1393 | break; |
1400 | 1394 | case 0xc9: |
1401 | - case 0x49: | |
1402 | 1395 | kbd_put_keysym(QEMU_KEY_PAGEUP); |
1403 | 1396 | break; |
1404 | 1397 | case 0xd1: |
1405 | - case 0x51: | |
1406 | 1398 | kbd_put_keysym(QEMU_KEY_PAGEDOWN); |
1407 | 1399 | break; |
1400 | + | |
1401 | + case 0x47: | |
1402 | + kbd_put_keysym(numlock ? '7' : QEMU_KEY_HOME); | |
1403 | + break; | |
1404 | + case 0x48: | |
1405 | + kbd_put_keysym(numlock ? '8' : QEMU_KEY_UP); | |
1406 | + break; | |
1407 | + case 0x49: | |
1408 | + kbd_put_keysym(numlock ? '9' : QEMU_KEY_PAGEUP); | |
1409 | + break; | |
1410 | + case 0x4b: | |
1411 | + kbd_put_keysym(numlock ? '4' : QEMU_KEY_LEFT); | |
1412 | + break; | |
1413 | + case 0x4c: | |
1414 | + kbd_put_keysym('5'); | |
1415 | + break; | |
1416 | + case 0x4d: | |
1417 | + kbd_put_keysym(numlock ? '6' : QEMU_KEY_RIGHT); | |
1418 | + break; | |
1419 | + case 0x4f: | |
1420 | + kbd_put_keysym(numlock ? '1' : QEMU_KEY_END); | |
1421 | + break; | |
1422 | + case 0x50: | |
1423 | + kbd_put_keysym(numlock ? '2' : QEMU_KEY_DOWN); | |
1424 | + break; | |
1425 | + case 0x51: | |
1426 | + kbd_put_keysym(numlock ? '3' : QEMU_KEY_PAGEDOWN); | |
1427 | + break; | |
1428 | + case 0x52: | |
1429 | + kbd_put_keysym('0'); | |
1430 | + break; | |
1431 | + case 0x53: | |
1432 | + kbd_put_keysym(numlock ? '.' : QEMU_KEY_DELETE); | |
1433 | + break; | |
1434 | + | |
1435 | + case 0xb5: | |
1436 | + kbd_put_keysym('/'); | |
1437 | + break; | |
1438 | + case 0x37: | |
1439 | + kbd_put_keysym('*'); | |
1440 | + break; | |
1441 | + case 0x4a: | |
1442 | + kbd_put_keysym('-'); | |
1443 | + break; | |
1444 | + case 0x4e: | |
1445 | + kbd_put_keysym('+'); | |
1446 | + break; | |
1447 | + case 0x9c: | |
1448 | + kbd_put_keysym('\n'); | |
1449 | + break; | |
1450 | + | |
1408 | 1451 | default: |
1409 | 1452 | kbd_put_keysym(sym); |
1410 | 1453 | break; | ... | ... |