diff options
author | Kazutaka YOKOTA <yokota@FreeBSD.org> | 1998-01-07 08:40:34 +0000 |
---|---|---|
committer | Kazutaka YOKOTA <yokota@FreeBSD.org> | 1998-01-07 08:40:34 +0000 |
commit | a3bd3dac2575b690c4fa408b5156b15d8593a916 (patch) | |
tree | 0eb35c19d2305f35c815849ba74d361880570e10 /sys/isa/syscons.c | |
parent | 4493ca0bce0ca7568a3b4a552c8ca916913ea72c (diff) |
Added accent (dead) key support to syscons and kbdcontrol.
With a keymap with accent key definitions loaded to syscons, you press
an accent key followed by a regular letter key to produce an accented
letter. Press an accent key followed by the space bar to get the
accent letter itself.
Code is based on the ideas and work by jmrueda@diatel.upm.es and
totii@est.is.
PR: i386/4016
console.h
- Defined structures and constants for accent (dead) keys.
syscons.c, kbdtables.h
- When an accent key is pressed, set the corresponding index to
`accents'. If the next key is the space key, produce the accent char
itself. Otherwise search the accent key map entry, indexed by
`accents', for a matching pair of a regular char and an accented char.
- Added ioctl functions to set and get the accent key map (PIO_DEADKEYMAP
and GIO_DEADKEYMAP).
Notes
Notes:
svn path=/head/; revision=32315
Diffstat (limited to 'sys/isa/syscons.c')
-rw-r--r-- | sys/isa/syscons.c | 62 |
1 files changed, 58 insertions, 4 deletions
diff --git a/sys/isa/syscons.c b/sys/isa/syscons.c index 56feb74653b1..85dbdc95acb3 100644 --- a/sys/isa/syscons.c +++ b/sys/isa/syscons.c @@ -25,7 +25,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: syscons.c,v 1.241 1997/12/06 13:23:26 bde Exp $ + * $Id: syscons.c,v 1.242 1997/12/07 08:09:19 yokota Exp $ */ #include "sc.h" @@ -127,6 +127,7 @@ static int blinkrate = 0; char crtc_type = KD_MONO; char crtc_vga = FALSE; static u_char shfts = 0, ctls = 0, alts = 0, agrs = 0, metas = 0; +static u_char accents = 0; static u_char nlkcnt = 0, clkcnt = 0, slkcnt = 0, alkcnt = 0; static const u_int n_fkey_tab = sizeof(fkey_tab) / sizeof(*fkey_tab); static int delayed_next_scr = FALSE; @@ -635,7 +636,7 @@ fail: static int scresume(void *dummy) { - shfts = ctls = alts = agrs = metas = 0; + shfts = ctls = alts = agrs = metas = accents = 0; return 0; } #endif @@ -1767,7 +1768,7 @@ scioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) case K_XLATE: /* switch to XLT ascii mode */ if (scp == cur_console && scp->status & KBD_RAW_MODE) - shfts = ctls = alts = agrs = metas = 0; + shfts = ctls = alts = agrs = metas = accents = 0; scp->status &= ~(KBD_RAW_MODE | KBD_CODE_MODE); return 0; default: @@ -1867,9 +1868,20 @@ scioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) return 0; case PIO_KEYMAP: /* set keyboard translation table */ + accents = 0; + bzero(&accent_map, sizeof(accent_map)); bcopy(data, &key_map, sizeof(key_map)); return 0; + case GIO_DEADKEYMAP: /* get accent key translation table */ + bcopy(&accent_map, data, sizeof(accent_map)); + return 0; + + case PIO_DEADKEYMAP: /* set accent key translation table */ + accents = 0; + bcopy(data, &accent_map, sizeof(accent_map)); + return 0; + case PIO_FONT8x8: /* set 8x8 dot font */ if (!crtc_vga) return ENXIO; @@ -2349,7 +2361,7 @@ exchange_scr(void) load_palette(palette); if (old_scp->status & KBD_RAW_MODE || new_scp->status & KBD_RAW_MODE || old_scp->status & KBD_CODE_MODE || new_scp->status & KBD_CODE_MODE) - shfts = ctls = alts = agrs = metas = 0; + shfts = ctls = alts = agrs = metas = accents = 0; set_border(new_scp->border); update_leds(new_scp->status); delayed_next_scr = FALSE; @@ -3695,20 +3707,24 @@ next_code: break; case SPSC: #ifdef SC_SPLASH_SCREEN + accents = 0; toggle_splash_screen(cur_console); #endif break; case RBT: + accents = 0; shutdown_nice(); break; case SUSP: #if NAPM > 0 + accents = 0; apm_suspend(); #endif break; case DBG: #ifdef DDB /* try to switch to console 0 */ + accents = 0; if (cur_console->smode.mode == VT_AUTO && console[0]->smode.mode == VT_AUTO) switch_scr(cur_console, 0); @@ -3754,8 +3770,21 @@ next_code: } break; case BTAB: + accents = 0; return(BKEY); default: + if (action >= F_ACC && action <= L_ACC) { + accents = action - F_ACC + 1; + if (accent_map.acc[accents - 1].accchar == 0) { + accents = 0; + do_bell(cur_console, BELL_PITCH, BELL_DURATION); + } + break; + } + if (accents > 0) { + accents = 0; + do_bell(cur_console, BELL_PITCH, BELL_DURATION); + } if (action >= F_SCR && action <= L_SCR) { switch_scr(cur_console, action - F_SCR); break; @@ -3766,6 +3795,31 @@ next_code: } } else { + if (accents) { + struct acc_t *acc; + int i; + + acc = &accent_map.acc[accents - 1]; + accents = 0; + if (action == ' ') { + action = acc->accchar; + if (metas) + action |= MKEY; + return (action); + } + for (i = 0; i < NUM_ACCENTCHARS; ++i) { + if (acc->map[i][0] == 0) + break; + if (acc->map[i][0] == action) { + action = acc->map[i][1]; + if (metas) + action |= MKEY; + return (action); + } + } + do_bell(cur_console, BELL_PITCH, BELL_DURATION); + goto next_code; + } if (metas) action |= MKEY; return(action); |