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,6 +1361,7 @@ static void do_key_event(VncState *vs, int down, int keycode, int sym) | ||
1361 | } else { | 1361 | } else { |
1362 | /* QEMU console emulation */ | 1362 | /* QEMU console emulation */ |
1363 | if (down) { | 1363 | if (down) { |
1364 | + int numlock = vs->modifiers_state[0x45]; | ||
1364 | switch (keycode) { | 1365 | switch (keycode) { |
1365 | case 0x2a: /* Left Shift */ | 1366 | case 0x2a: /* Left Shift */ |
1366 | case 0x36: /* Right Shift */ | 1367 | case 0x36: /* Right Shift */ |
@@ -1370,41 +1371,83 @@ static void do_key_event(VncState *vs, int down, int keycode, int sym) | @@ -1370,41 +1371,83 @@ static void do_key_event(VncState *vs, int down, int keycode, int sym) | ||
1370 | case 0xb8: /* Right ALT */ | 1371 | case 0xb8: /* Right ALT */ |
1371 | break; | 1372 | break; |
1372 | case 0xc8: | 1373 | case 0xc8: |
1373 | - case 0x48: | ||
1374 | kbd_put_keysym(QEMU_KEY_UP); | 1374 | kbd_put_keysym(QEMU_KEY_UP); |
1375 | break; | 1375 | break; |
1376 | case 0xd0: | 1376 | case 0xd0: |
1377 | - case 0x50: | ||
1378 | kbd_put_keysym(QEMU_KEY_DOWN); | 1377 | kbd_put_keysym(QEMU_KEY_DOWN); |
1379 | break; | 1378 | break; |
1380 | case 0xcb: | 1379 | case 0xcb: |
1381 | - case 0x4b: | ||
1382 | kbd_put_keysym(QEMU_KEY_LEFT); | 1380 | kbd_put_keysym(QEMU_KEY_LEFT); |
1383 | break; | 1381 | break; |
1384 | case 0xcd: | 1382 | case 0xcd: |
1385 | - case 0x4d: | ||
1386 | kbd_put_keysym(QEMU_KEY_RIGHT); | 1383 | kbd_put_keysym(QEMU_KEY_RIGHT); |
1387 | break; | 1384 | break; |
1388 | case 0xd3: | 1385 | case 0xd3: |
1389 | - case 0x53: | ||
1390 | kbd_put_keysym(QEMU_KEY_DELETE); | 1386 | kbd_put_keysym(QEMU_KEY_DELETE); |
1391 | break; | 1387 | break; |
1392 | case 0xc7: | 1388 | case 0xc7: |
1393 | - case 0x47: | ||
1394 | kbd_put_keysym(QEMU_KEY_HOME); | 1389 | kbd_put_keysym(QEMU_KEY_HOME); |
1395 | break; | 1390 | break; |
1396 | case 0xcf: | 1391 | case 0xcf: |
1397 | - case 0x4f: | ||
1398 | kbd_put_keysym(QEMU_KEY_END); | 1392 | kbd_put_keysym(QEMU_KEY_END); |
1399 | break; | 1393 | break; |
1400 | case 0xc9: | 1394 | case 0xc9: |
1401 | - case 0x49: | ||
1402 | kbd_put_keysym(QEMU_KEY_PAGEUP); | 1395 | kbd_put_keysym(QEMU_KEY_PAGEUP); |
1403 | break; | 1396 | break; |
1404 | case 0xd1: | 1397 | case 0xd1: |
1405 | - case 0x51: | ||
1406 | kbd_put_keysym(QEMU_KEY_PAGEDOWN); | 1398 | kbd_put_keysym(QEMU_KEY_PAGEDOWN); |
1407 | break; | 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 | default: | 1451 | default: |
1409 | kbd_put_keysym(sym); | 1452 | kbd_put_keysym(sym); |
1410 | break; | 1453 | break; |