comparison src/msdos.c @ 24559:7e59f6e590da

(struct kbd_translate): New struct, for key translation tables private to certain national keyboard layouts. (struct dos_keyboard_map): Add a pointer to a private translation table. (jp_kbd_translate_table): Private table for the Japanese keyboard. (jp_keyboard): Japanese keyboard layout. (it_kbd_translate_table): Private table for the Italian keyboard. (it_keyboard): Use it_kbd_translate_table. (keyboard_layout_list): Add the Japanese keyboard. (dos_rawgetc): Use the keyboard-private translation table, if available. (abort) [__DJGPP_MINOR__ >= 2]: Raise SIGABRT.
author Eli Zaretskii <eliz@gnu.org>
date Sun, 04 Apr 1999 11:43:57 +0000
parents fce0e760c4ab
children bb608cd1af6e
comparison
equal deleted inserted replaced
24558:ea8a9509b52f 24559:7e59f6e590da
376 regs.x.cx = count; 376 regs.x.cx = count;
377 __dpmi_int (0x10, &regs); 377 __dpmi_int (0x10, &regs);
378 } 378 }
379 #endif 379 #endif
380 380
381 static 381 static void
382 dos_direct_output (y, x, buf, len) 382 dos_direct_output (y, x, buf, len)
383 int y; 383 int y;
384 int x; 384 int x;
385 char *buf; 385 char *buf;
386 int len; 386 int len;
950 new_pos_Y = y; 950 new_pos_Y = y;
951 } 951 }
952 952
953 static int cursor_cleared; 953 static int cursor_cleared;
954 954
955 static 955 static void
956 IT_display_cursor (int on) 956 IT_display_cursor (int on)
957 { 957 {
958 if (on && cursor_cleared) 958 if (on && cursor_cleared)
959 { 959 {
960 ScreenSetCursor (current_pos_Y, current_pos_X); 960 ScreenSetCursor (current_pos_Y, current_pos_X);
1150 regs.x.es = ScreenMode () == 7 ? 0xb000 : 0xb800; 1150 regs.x.es = ScreenMode () == 7 ? 0xb000 : 0xb800;
1151 regs.x.di = 0; 1151 regs.x.di = 0;
1152 es_value = regs.x.es; 1152 es_value = regs.x.es;
1153 __dpmi_int (0x10, &regs); 1153 __dpmi_int (0x10, &regs);
1154 1154
1155 if (regs.x.es != es_value && regs.x.es != (ScreenPrimary >> 4) & 0xffff) 1155 if (regs.x.es != es_value)
1156 { 1156 {
1157 screen_old_address = ScreenPrimary; 1157 /* screen_old_address is only set if ScreenPrimary does NOT
1158 already point to the relocated buffer address returned by
1159 the Int 10h/AX=FEh call above. DJGPP v2.02 and later sets
1160 ScreenPrimary to that address at startup under DOS/V. */
1161 if (regs.x.es != (ScreenPrimary >> 4) & 0xffff)
1162 screen_old_address = ScreenPrimary;
1158 screen_virtual_segment = regs.x.es; 1163 screen_virtual_segment = regs.x.es;
1159 screen_virtual_offset = regs.x.di; 1164 screen_virtual_offset = regs.x.di;
1160 ScreenPrimary = (screen_virtual_segment << 4) + screen_virtual_offset; 1165 ScreenPrimary = (screen_virtual_segment << 4) + screen_virtual_offset;
1161 } 1166 }
1162 } 1167 }
1471 * CLOK 30 31 32 33 34 35 36 37 38 39 40 (41) RET 1476 * CLOK 30 31 32 33 34 35 36 37 38 39 40 (41) RET
1472 * SH () 45 46 47 48 49 50 51 52 53 54 SHIFT 1477 * SH () 45 46 47 48 49 50 51 52 53 54 SHIFT
1473 * SPACE 1478 * SPACE
1474 */ 1479 */
1475 1480
1481 #define Ignore 0x0000
1482 #define Normal 0x0000 /* normal key - alt changes scan-code */
1483 #define FctKey 0x1000 /* func key if c == 0, else c */
1484 #define Special 0x2000 /* func key even if c != 0 */
1485 #define ModFct 0x3000 /* special if mod-keys, else 'c' */
1486 #define Map 0x4000 /* alt scan-code, map to unshift/shift key */
1487 #define KeyPad 0x5000 /* map to insert/kp-0 depending on c == 0xe0 */
1488 #define Grey 0x6000 /* Grey keypad key */
1489
1490 #define Alt 0x0100 /* alt scan-code */
1491 #define Ctrl 0x0200 /* ctrl scan-code */
1492 #define Shift 0x0400 /* shift scan-code */
1493
1476 static int extended_kbd; /* 101 (102) keyboard present. */ 1494 static int extended_kbd; /* 101 (102) keyboard present. */
1495
1496 struct kbd_translate {
1497 unsigned char sc;
1498 unsigned char ch;
1499 unsigned short code;
1500 };
1477 1501
1478 struct dos_keyboard_map 1502 struct dos_keyboard_map
1479 { 1503 {
1480 char *unshifted; 1504 char *unshifted;
1481 char *shifted; 1505 char *shifted;
1482 char *alt_gr; 1506 char *alt_gr;
1507 struct kbd_translate *translate_table;
1483 }; 1508 };
1484 1509
1485 1510
1486 static struct dos_keyboard_map us_keyboard = { 1511 static struct dos_keyboard_map us_keyboard = {
1487 /* 0 1 2 3 4 5 */ 1512 /* 0 1 2 3 4 5 */
1488 /* 01234567890123456789012345678901234567890 12345678901234 */ 1513 /* 01234567890123456789012345678901234567890 12345678901234 */
1489 "`1234567890-= qwertyuiop[] asdfghjkl;'\\ zxcvbnm,./ ", 1514 "`1234567890-= qwertyuiop[] asdfghjkl;'\\ zxcvbnm,./ ",
1490 /* 0123456789012345678901234567890123456789 012345678901234 */ 1515 /* 0123456789012345678901234567890123456789 012345678901234 */
1491 "~!@#$%^&*()_+ QWERTYUIOP{} ASDFGHJKL:\"| ZXCVBNM<>? ", 1516 "~!@#$%^&*()_+ QWERTYUIOP{} ASDFGHJKL:\"| ZXCVBNM<>? ",
1492 0 /* no Alt-Gr key */ 1517 0, /* no Alt-Gr key */
1518 0 /* no translate table */
1493 }; 1519 };
1494 1520
1495 static struct dos_keyboard_map fr_keyboard = { 1521 static struct dos_keyboard_map fr_keyboard = {
1496 /* 0 1 2 3 4 5 */ 1522 /* 0 1 2 3 4 5 */
1497 /* 012 3456789012345678901234567890123456789012345678901234 */ 1523 /* 012 3456789012345678901234567890123456789012345678901234 */
1498 "&\",(-_)= azertyuiop^$ qsdfghjklm* wxcvbnm;:! ", 1524 "&\",(-_)= azertyuiop^$ qsdfghjklm* wxcvbnm;:! ",
1499 /* 0123456789012345678901234567890123456789012345678901234 */ 1525 /* 0123456789012345678901234567890123456789012345678901234 */
1500 " 1234567890+ AZERTYUIOP QSDFGHJKLM% WXCVBN?./ ", 1526 " 1234567890+ AZERTYUIOP QSDFGHJKLM% WXCVBN?./ ",
1501 /* 01234567 89012345678901234567890123456789012345678901234 */ 1527 /* 01234567 89012345678901234567890123456789012345678901234 */
1502 " ~#{[|`\\^@]} " 1528 " ~#{[|`\\^@]} ",
1529 0 /* no translate table */
1503 }; 1530 };
1504 1531
1505 /* 1532 /*
1506 * Italian keyboard support, country code 39. 1533 * Italian keyboard support, country code 39.
1507 * '<' 56:3c*0000 1534 * '<' 56:3c*0000
1508 * '>' 56:3e*0000 1535 * '>' 56:3e*0000
1509 * added also {,},` as, respectively, AltGr-8, AltGr-9, AltGr-' 1536 * added also {,},` as, respectively, AltGr-8, AltGr-9, AltGr-'
1510 * Donated by Stefano Brozzi <brozzis@mag00.cedi.unipr.it> 1537 * Donated by Stefano Brozzi <brozzis@mag00.cedi.unipr.it>
1511 */ 1538 */
1539
1540 static struct kbd_translate it_kbd_translate_table[] = {
1541 { 0x56, 0x3c, Map | 13 },
1542 { 0x56, 0x3e, Map | 13 },
1543 { 0, 0, 0 }
1544 };
1512 static struct dos_keyboard_map it_keyboard = { 1545 static struct dos_keyboard_map it_keyboard = {
1513 /* 0 1 2 3 4 5 */ 1546 /* 0 1 2 3 4 5 */
1514 /* 0 123456789012345678901234567890123456789012345678901234 */ 1547 /* 0 123456789012345678901234567890123456789012345678901234 */
1515 "\\1234567890' qwertyuiop+ asdfghjkl zxcvbnm,.- ", 1548 "\\1234567890'< qwertyuiop+ asdfghjkl zxcvbnm,.- ",
1516 /* 01 23456789012345678901234567890123456789012345678901234 */ 1549 /* 01 23456789012345678901234567890123456789012345678901234 */
1517 "|!\"$%&/()=?^ QWERTYUIOP* ASDFGHJKL ZXCVBNM;:_ ", 1550 "|!\"$%&/()=?^> QWERTYUIOP* ASDFGHJKL ZXCVBNM;:_ ",
1518 /* 0123456789012345678901234567890123456789012345678901234 */ 1551 /* 0123456789012345678901234567890123456789012345678901234 */
1519 " {}~` [] @# " 1552 " {}~` [] @# ",
1553 it_kbd_translate_table
1520 }; 1554 };
1521 1555
1522 static struct dos_keyboard_map dk_keyboard = { 1556 static struct dos_keyboard_map dk_keyboard = {
1523 /* 0 1 2 3 4 5 */ 1557 /* 0 1 2 3 4 5 */
1524 /* 0123456789012345678901234567890123456789012345678901234 */ 1558 /* 0123456789012345678901234567890123456789012345678901234 */
1525 "1234567890+| qwertyuiop~ asdfghjkl' zxcvbnm,.- ", 1559 "1234567890+| qwertyuiop~ asdfghjkl' zxcvbnm,.- ",
1526 /* 01 23456789012345678901234567890123456789012345678901234 */ 1560 /* 01 23456789012345678901234567890123456789012345678901234 */
1527 "!\"#$%&/()=?` QWERTYUIOP^ ASDFGHJKL* ZXCVBNM;:_ ", 1561 "!\"#$%&/()=?` QWERTYUIOP^ ASDFGHJKL* ZXCVBNM;:_ ",
1528 /* 0123456789012345678901234567890123456789012345678901234 */ 1562 /* 0123456789012345678901234567890123456789012345678901234 */
1529 " @$ {[]} | " 1563 " @$ {[]} | ",
1564 0 /* no translate table */
1565 };
1566
1567 static struct kbd_translate jp_kbd_translate_table[] = {
1568 { 0x73, 0x5c, Map | 0 },
1569 { 0x7d, 0x5c, Map | 13 },
1570 { 0, 0, 0 }
1571 };
1572 static struct dos_keyboard_map jp_keyboard = {
1573 /* 0 1 2 3 4 5 */
1574 /* 0123456789012 345678901234567890123456789012345678901234 */
1575 "\\1234567890-^\\ qwertyuiop@[ asdfghjkl;:] zxcvbnm,./ ",
1576 /* 01 23456789012345678901234567890123456789012345678901234 */
1577 "_!\"#$%&'()~=~| QWERTYUIOP`{ ASDFGHJKL+*} ZXCVBNM<>? ",
1578 0, /* no Alt-Gr key */
1579 jp_kbd_translate_table
1530 }; 1580 };
1531 1581
1532 static struct keyboard_layout_list 1582 static struct keyboard_layout_list
1533 { 1583 {
1534 int country_code; 1584 int country_code;
1536 } keyboard_layout_list[] = 1586 } keyboard_layout_list[] =
1537 { 1587 {
1538 1, &us_keyboard, 1588 1, &us_keyboard,
1539 33, &fr_keyboard, 1589 33, &fr_keyboard,
1540 39, &it_keyboard, 1590 39, &it_keyboard,
1541 45, &dk_keyboard 1591 45, &dk_keyboard,
1592 81, &jp_keyboard
1542 }; 1593 };
1543 1594
1544 static struct dos_keyboard_map *keyboard; 1595 static struct dos_keyboard_map *keyboard;
1545 static int keyboard_map_all; 1596 static int keyboard_map_all;
1546 static int international_keyboard; 1597 static int international_keyboard;
1576 return 1; 1627 return 1;
1577 } 1628 }
1578 return 0; 1629 return 0;
1579 } 1630 }
1580 1631
1581 #define Ignore 0x0000
1582 #define Normal 0x0000 /* normal key - alt changes scan-code */
1583 #define FctKey 0x1000 /* func key if c == 0, else c */
1584 #define Special 0x2000 /* func key even if c != 0 */
1585 #define ModFct 0x3000 /* special if mod-keys, else 'c' */
1586 #define Map 0x4000 /* alt scan-code, map to unshift/shift key */
1587 #define KeyPad 0x5000 /* map to insert/kp-0 depending on c == 0xe0 */
1588 #define Grey 0x6000 /* Grey keypad key */
1589
1590 #define Alt 0x0100 /* alt scan-code */
1591 #define Ctrl 0x0200 /* ctrl scan-code */
1592 #define Shift 0x0400 /* shift scan-code */
1593
1594 static struct 1632 static struct
1595 { 1633 {
1596 unsigned char char_code; /* normal code */ 1634 unsigned char char_code; /* normal code */
1597 unsigned char meta_code; /* M- code */ 1635 unsigned char meta_code; /* M- code */
1598 unsigned char keypad_code; /* keypad code */ 1636 unsigned char keypad_code; /* keypad code */
1688 Map | 53, /* '.' */ 1726 Map | 53, /* '.' */
1689 Map | 54, /* '/' */ 1727 Map | 54, /* '/' */
1690 Ignore, /* Right shift */ 1728 Ignore, /* Right shift */
1691 Grey | 1, /* Grey * */ 1729 Grey | 1, /* Grey * */
1692 Ignore, /* Alt */ 1730 Ignore, /* Alt */
1693 Normal | ' ', /* ' ' */ 1731 Normal | 55, /* ' ' */
1694 Ignore, /* Caps Lock */ 1732 Ignore, /* Caps Lock */
1695 FctKey | 0xbe, /* F1 */ 1733 FctKey | 0xbe, /* F1 */
1696 FctKey | 0xbf, /* F2 */ 1734 FctKey | 0xbf, /* F2 */
1697 FctKey | 0xc0, /* F3 */ 1735 FctKey | 0xc0, /* F3 */
1698 FctKey | 0xc1, /* F4 */ 1736 FctKey | 0xc1, /* F4 */
1960 int86 (0x16, &regs, &regs), 1998 int86 (0x16, &regs, &regs),
1961 (regs.x.flags & 0x40) == 0) 1999 (regs.x.flags & 0x40) == 0)
1962 { 2000 {
1963 union REGS regs; 2001 union REGS regs;
1964 register unsigned char c; 2002 register unsigned char c;
1965 int sc, code, mask, kp_mode; 2003 int sc, code = -1, mask, kp_mode;
1966 int modifiers; 2004 int modifiers;
1967 2005
1968 regs.h.ah = extended_kbd ? 0x10 : 0x00; 2006 regs.h.ah = extended_kbd ? 0x10 : 0x00;
1969 int86 (0x16, &regs, &regs); 2007 int86 (0x16, &regs, &regs);
1970 c = regs.h.al; 2008 c = regs.h.al;
2010 }; 2048 };
2011 c = 0; 2049 c = 0;
2012 } 2050 }
2013 else 2051 else
2014 { 2052 {
2015 if (sc >= (sizeof (ibmpc_translate_map) / sizeof (short))) 2053 /* Try the keyboard-private translation table first. */
2016 continue; 2054 if (keyboard->translate_table)
2017 if ((code = ibmpc_translate_map[sc]) == Ignore) 2055 {
2018 continue; 2056 struct kbd_translate *p = keyboard->translate_table;
2057
2058 while (p->sc)
2059 {
2060 if (p->sc == sc && p->ch == c)
2061 {
2062 code = p->code;
2063 break;
2064 }
2065 p++;
2066 }
2067 }
2068 /* If the private table didn't translate it, use the general
2069 one. */
2070 if (code == -1)
2071 {
2072 if (sc >= (sizeof (ibmpc_translate_map) / sizeof (short)))
2073 continue;
2074 if ((code = ibmpc_translate_map[sc]) == Ignore)
2075 continue;
2076 }
2019 } 2077 }
2020 2078
2021 if (c == 0) 2079 if (c == 0)
2022 { 2080 {
2023 /* We only look at the keyboard Ctrl/Shift/Alt keys when 2081 /* We only look at the keyboard Ctrl/Shift/Alt keys when
2069 code = c; 2127 code = c;
2070 break; 2128 break;
2071 } 2129 }
2072 2130
2073 case Map: 2131 case Map:
2132 if (keyboard->translate_table)
2133 c = 0; /* so key gets mapped through country-specific kbd */
2074 if (c && !(mask & ALT_P) && !((mask & SHIFT_P) && (mask & CTRL_P))) 2134 if (c && !(mask & ALT_P) && !((mask & SHIFT_P) && (mask & CTRL_P)))
2075 if (!keyboard_map_all) 2135 if (!keyboard_map_all)
2076 return c; 2136 return c;
2077 2137
2078 code &= 0xff; 2138 code &= 0xff;
3906 cputs ("\r\n\nEmacs aborted!\r\n"); 3966 cputs ("\r\n\nEmacs aborted!\r\n");
3907 #if __DJGPP__ > 1 3967 #if __DJGPP__ > 1
3908 #if __DJGPP__ == 2 && __DJGPP_MINOR__ < 2 3968 #if __DJGPP__ == 2 && __DJGPP_MINOR__ < 2
3909 if (screen_virtual_segment) 3969 if (screen_virtual_segment)
3910 dosv_refresh_virtual_screen (2 * 10 * screen_size_X, 4 * screen_size_X); 3970 dosv_refresh_virtual_screen (2 * 10 * screen_size_X, 4 * screen_size_X);
3911 #endif /* __DJGPP_MINOR__ < 2 */
3912 /* Generate traceback, so we could tell whodunit. */ 3971 /* Generate traceback, so we could tell whodunit. */
3913 signal (SIGINT, SIG_DFL); 3972 signal (SIGINT, SIG_DFL);
3914 __asm__ __volatile__ ("movb $0x1b,%al;call ___djgpp_hw_exception"); 3973 __asm__ __volatile__ ("movb $0x1b,%al;call ___djgpp_hw_exception");
3974 #else /* __DJGPP_MINOR__ >= 2 */
3975 raise (SIGABRT);
3976 #endif /* __DJGPP_MINOR__ >= 2 */
3915 #endif 3977 #endif
3916 exit (2); 3978 exit (2);
3917 } 3979 }
3918 #endif 3980 #endif
3919 3981