From: Lionel Sambuc Date: Wed, 4 Jun 2014 14:04:36 +0000 (+0200) Subject: FKEY_EVENTS cleanups X-Git-Tag: v3.3.0~198 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/rndc.conf.html?a=commitdiff_plain;h=e2e57d387f8766ea47122a3318729cd2c5f0de52;p=minix.git FKEY_EVENTS cleanups - Fix a bug where an FKEY_EVENT request would always return EINVAL - Replace two manual usage of FKEY_EVENT messages by a call to fkey_events which is mapped to fkey_ctl. Change-Id: I7bc54cade45a29f14c89313b3ec4c28d81a4ec93 --- diff --git a/drivers/orinoco/orinoco.c b/drivers/orinoco/orinoco.c index 0c053eb7e..b6632f080 100644 --- a/drivers/orinoco/orinoco.c +++ b/drivers/orinoco/orinoco.c @@ -389,7 +389,8 @@ static void or_reset() { static void or_dump (message *m) { t_or *orp; - + int sfkeys; + orp = &or_state; if(orp->or_mode == OR_M_DISABLED) { @@ -399,12 +400,11 @@ static void or_dump (message *m) if(orp->or_mode != OR_M_ENABLED) return; - m->m_type = TTY_FKEY_CONTROL; - m->FKEY_REQUEST = FKEY_EVENTS; - if(OK!=(ipc_sendrec(TTY_PROC_NR,m)) ) + if(OK != fkey_events(NULL, &sfkeys)) { printf("Contacting the TTY failed\n"); + } - if(bit_isset(m->FKEY_SFKEYS, 11)) { + if(bit_isset(sfkeys, 11)) { print_linkstatus(orp, orp->last_linkstatus); } } diff --git a/drivers/tty/arch/i386/keyboard.c b/drivers/tty/arch/i386/keyboard.c index 0e8a9fc59..bd74859bd 100644 --- a/drivers/tty/arch/i386/keyboard.c +++ b/drivers/tty/arch/i386/keyboard.c @@ -501,6 +501,7 @@ message *m_ptr; /* pointer to the request message */ } break; case FKEY_EVENTS: + result = OK; /* everything will be ok*/ m_ptr->FKEY_FKEYS = m_ptr->FKEY_SFKEYS = 0; for (i=0; i < 12; i++) { /* check (Shift+) F1-F12 keys */ if (fkey_obs[i].proc_nr == m_ptr->m_source) { diff --git a/servers/is/dmp.c b/servers/is/dmp.c index 819d4532b..64e08b99e 100644 --- a/servers/is/dmp.c +++ b/servers/is/dmp.c @@ -67,25 +67,31 @@ int map; /*===========================================================================* * handle_fkey * *===========================================================================*/ -#define pressed(k) ((F1<=(k)&&(k)<=F12 && bit_isset(m->FKEY_FKEYS,((k)-F1+1)))\ - || (SF1<=(k) && (k)<=SF12 && bit_isset(m->FKEY_SFKEYS, ((k)-SF1+1)))) +#define pressed(start, end, bitfield, key) \ + (((start) <= (key)) && ((end) >= (key)) && \ + bit_isset((bitfield), ((key) - (start) + 1))) int do_fkey_pressed(m) message *m; /* notification message */ { int s, h; + int fkeys, sfkeys; /* The notification message does not convey any information, other * than that some function keys have been pressed. Ask TTY for details. */ - m->m_type = TTY_FKEY_CONTROL; - m->FKEY_REQUEST = FKEY_EVENTS; - if (OK != (s=ipc_sendrec(TTY_PROC_NR, m))) - printf("IS: warning, ipc_sendrec to TTY failed: %d\n", s); + s = fkey_events(&fkeys, &sfkeys); + if (s < 0) { + printf("IS: warning, fkey_events failed: %d\n", s); + } /* Now check which keys were pressed: F1-F12, SF1-SF12. */ - for(h=0; h < NHOOKS; h++) - if(pressed(hooks[h].key)) - hooks[h].function(); + for(h=0; h < NHOOKS; h++) { + if (pressed(F1, F12, fkeys, hooks[h].key)) { + hooks[h].function(); + } else if (pressed(SF1, SF12, sfkeys, hooks[h].key)) { + hooks[h].function(); + } + } /* Don't send a reply message. */ return(EDONTREPLY);