Received: from eggs.gnu.org ([208.118.235.92]:60659) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UcxQz-0005gJ-O9 for qemu-devel@nongnu.org; Thu, 16 May 2013 08:37:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UcxQx-0003XS-Vt for qemu-devel@nongnu.org; Thu, 16 May 2013 08:37:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58627) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UcxQx-0003XO-Nz for qemu-devel@nongnu.org; Thu, 16 May 2013 08:37:23 -0400 Date: Fri, 17 May 2013 04:37:03 +0800 From: Amos Kong Message-ID: <20130516203703.GB3045@t430s.nay.redhat.com> References: <1368678651-3561-1-git-send-email-akong@redhat.com> <51948969.5050604@linux.vnet.ibm.com> <20130516073521.GE3785@t430s.nay.redhat.com> <5194A2DF.9010608@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <5194A2DF.9010608@linux.vnet.ibm.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] ps2: add support of auto-repeat List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Lei Li Cc: aliguori@us.ibm.com, lcapitulino@redhat.com, lersek@redhat.com, qemu-devel@nongnu.org, kraxel@redhat.com On Thu, May 16, 2013 at 05:11:59PM +0800, Lei Li wrote: > On 05/16/2013 03:35 PM, Amos Kong wrote: > >On Thu, May 16, 2013 at 03:23:21PM +0800, Lei Li wrote: > >>On 05/16/2013 12:30 PM, Amos Kong wrote: > >>>Guest driver sets repeat rate and delay time by KBD_CMD_SET_RATE, > >>>but ps2 backend doesn't process it and no auto-repeat implementation. > >>>This patch adds support of auto-repeat feature. > >>> > >>>Guest ps2 driver sets autorepeat to fastest possible in reset, > >>>period: 250ms, delay: 33ms > >>> > >>>Tested by 'sendkey' monitor command. > >>> > >>>referenced: http://www.computer-engineering.org/ps2keyboard/ > >>> > >>>Signed-off-by: Amos Kong > > > >>> /* > >>> keycode is expressed as follow: > >>> bit 7 - 0 key pressed, 1 =3D key released > >>>@@ -167,7 +186,17 @@ static void ps2_put_keycode(void *opaque, int k= eycode) > >>> keycode =3D ps2_raw_keycode_set3[keycode & 0x7f]; > >>> } > >>> } > >>>+ > >>>+ /* only auto-repeat press event */ > >>>+ auto_repeat =3D ~keycode & 0x80; > >Hi Lei, > > > >>Does this check allow to distinguish the difference between auto-repe= at and > >>actual repeated entry by the user? > >Actual repeat by user: > > press event > > release event > > press event > > release event > > press event > > release event > > > >Auto-repeat example: > > press event > > press event > > press event > > release event Hi Lei, =20 > On what platform? Fedora 18 @ thinkpad t430s [root@t430s amos]# showkey (hold 'a') akeycode 30 press aaaaaaaaaaakeycode 30 press keycode 30 press keycode 30 press keycode 30 press keycode 30 press keycode 30 press keycode 30 press keycode 30 press keycode 30 press keycode 30 press keycode 30 press keycode 30 press keycode 30 press aakeycode 30 press keycode 30 press keycode 30 release <----(one release event in the end) Qemu VM (rhel6, using vnc/ SDL) can get same result. =20 > AFAIK, the Auto-repeat event is like below on some GTK-based > ||||||||||||environments,|||||||||||| >=20 > keydown > keypress > keyup > keydown > keypress > keyup||||||||||||| > ... > as reference link: >=20 > https://developer.mozilla.org/zh-CN/docs/DOM/KeyboardEvent =3D=3D=3D=3D=3D Auto-repeat handling (it's also mentioned in mozilla pag= e) When a key is pressed and held down, it begins to auto-repeat. This results in a sequence of events similar to the following being dispatched: keydown keypress keydown keypress <> keyup <----(only one up event in the end) =20 > And on Xwindows: >=20 > keypress > keyrelease > keypress > keyrelease > ... > as reference link: >=20 > http://www.ypass.net/blog/2009/06/detecting-xlibs-keyboard-auto-repeat-= functionality-and-how-to-fix-it/ """Just what we=E2=80=99d expect, a bunch of KeyPress Events and one KeyR= elease event. But that=E2=80=99s not how it works in X.""" So pppppppR is expected. From: http://www.computer-engineering.org/ps2keyboard/ When you press and hold down a key, that key becomes typematic, which means the keyboard will _keep_ sending that key's _make code_ until the key is released or another key is pressed. (repeatedly send the make code, only one break code in the end) > This would cause it's hard to distinguish them. But looks like the link= s above is > a little out of time, and I am not sure if the auto-repeat behaviour on= such platforms > has been changed. :) > ||||||||||||| Both of them works, but the repeated release events are redundant (no ris= k). --=20 Amos.