Subject: Re: kern/36762: Locking alternative layouts for wskbd
To: None <kern-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: Mike M. Volokhov <mishka@NetBSD.org>
List: netbsd-bugs
Date: 08/10/2007 09:15:05
The following reply was made to PR kern/36762; it has been noted by GNATS.

From: "Mike M. Volokhov" <mishka@NetBSD.org>
To: gnats-bugs@NetBSD.org
Cc: netbsd-bugs@NetBSD.org
Subject: Re: kern/36762: Locking alternative layouts for wskbd
Date: Fri, 10 Aug 2007 12:11:40 +0300

 Grrr, copy-pasting... Original patch is:
 
 Index: wskbd.c
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/wscons/wskbd.c,v
 retrieving revision 1.105
 diff -u -r1.105 wskbd.c
 --- wskbd.c	6 Aug 2007 03:07:52 -0000	1.105
 +++ wskbd.c	10 Aug 2007 07:41:17 -0000
 @@ -1406,16 +1406,22 @@
  }
  
  static inline void
 -update_modifier(struct wskbd_internal *id, u_int type, int toggle, int mask)
 +update_modifier(struct wskbd_internal *id, u_int type, int togglemode, int mask)
  {
 -	if (toggle) {
 -		if (type == WSCONS_EVENT_KEY_DOWN)
 -			id->t_modifiers ^= mask;
 -	} else {
 +	switch (togglemode) {
 +	case 0:	/* down - on, up - off */
  		if (type == WSCONS_EVENT_KEY_DOWN)
  			id->t_modifiers |= mask;
  		else
  			id->t_modifiers &= ~mask;
 +		break;
 +	case 1: /* down - invert */
 +		if (type == WSCONS_EVENT_KEY_DOWN)
 +			id->t_modifiers ^= mask;
 +		break;
 +	case 2: /* either down or up - invert */
 +		id->t_modifiers ^= mask;
 +		break;
  	}
  }
  
 @@ -1503,6 +1509,17 @@
  	case KS_Cmd2:
  		update_modifier(sc->id, *type, 0, MOD_COMMAND2);
  		break;
 +
 +	case KS_Cmd_ModeToggle:
 +		if (*type == WSCONS_EVENT_KEY_DOWN) {
 +		    if (MOD_ONESET(sc->id, MOD_COMMAND1 | MOD_COMMAND2)) {
 +			update_modifier(sc->id, *type, 1, MOD_MODESHIFT);
 +			return (1);
 +		    } else {
 +			return (0);
 +		    }
 +		}
 +		break;
  	}
  
  	if (*type != WSCONS_EVENT_KEY_DOWN ||
 @@ -1648,7 +1665,11 @@
  		break;
  
  	case KS_Mode_switch:
 -		update_modifier(id, type, 0, MOD_MODESHIFT);
 +		update_modifier(id, type, 2, MOD_MODESHIFT);
 +		break;
 +
 +	case KS_Mode_toggle:
 +		update_modifier(id, type, 1, MOD_MODESHIFT);
  		break;
  
  	case KS_Num_Lock:
 Index: wsksymdef.h
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/wscons/wsksymdef.h,v
 retrieving revision 1.58
 diff -u -r1.58 wsksymdef.h
 --- wsksymdef.h	4 Apr 2007 14:50:21 -0000	1.58
 +++ wsksymdef.h	10 Aug 2007 07:41:17 -0000
 @@ -377,6 +377,7 @@
  #define KS_Henkan_Mode		0xf114	/* Start/Stop Conversion */
  #define KS_Henkan		0xf115	/* Alias for Henkan_Mode */
  #define KS_Muhenkan		0xf116	/* Cancel Conversion */
 +#define KS_Mode_toggle		0xf117
  
  /*
   * Group 2 (keypad) character in low byte
 @@ -524,6 +525,7 @@
  #define KS_Cmd_ScrollFastDown	0xf42d
  #define KS_Cmd_ScrollSlowUp	0xf42e
  #define KS_Cmd_ScrollSlowDown	0xf42f
 +#define KS_Cmd_ModeToggle	0xf430
  
  /*
   * Group 5 (internal)