linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* detecting when keys are being pressed on a keyboard
@ 2007-09-21  8:33 Oliver Neukum
  2007-09-21 12:47 ` Jiri Kosina
  0 siblings, 1 reply; 8+ messages in thread
From: Oliver Neukum @ 2007-09-21  8:33 UTC (permalink / raw)
  To: Jiri Kosina, linux-input, linux-usb-devel

Hi,

I got the strange case of a keyboard going into autosuspend while a key
was being pressed. The key release never arrived and I had to unplug
the keyboard to get the key unstuck. Is there a clean way to learn from
hid-core.c if a keyboard has keys pressed?

	Regards
		Oliver

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: detecting when keys are being pressed on a keyboard
  2007-09-21  8:33 detecting when keys are being pressed on a keyboard Oliver Neukum
@ 2007-09-21 12:47 ` Jiri Kosina
  2007-09-24 10:56   ` Oliver Neukum
  0 siblings, 1 reply; 8+ messages in thread
From: Jiri Kosina @ 2007-09-21 12:47 UTC (permalink / raw)
  To: Oliver Neukum; +Cc: linux-input, linux-usb-devel

On Fri, 21 Sep 2007, Oliver Neukum wrote:

> I got the strange case of a keyboard going into autosuspend while a key 
> was being pressed. The key release never arrived and I had to unplug the 
> keyboard to get the key unstuck. Is there a clean way to learn from 
> hid-core.c if a keyboard has keys pressed?

Hi Oliver,

HID doesn't keep any permanent state by itself. If you want to know 
whether a given key is currently pressed or not, you'd have to inspect the 
bitfields inside input_dev*, I am afraid.

-- 
Jiri Kosina

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: detecting when keys are being pressed on a keyboard
  2007-09-21 12:47 ` Jiri Kosina
@ 2007-09-24 10:56   ` Oliver Neukum
  2007-09-24 12:50     ` [linux-usb-devel] " Dmitry Torokhov
  2007-09-24 13:45     ` Jiri Kosina
  0 siblings, 2 replies; 8+ messages in thread
From: Oliver Neukum @ 2007-09-24 10:56 UTC (permalink / raw)
  To: linux-usb-devel; +Cc: linux-input

Am Freitag 21 September 2007 schrieb Jiri Kosina:
> On Fri, 21 Sep 2007, Oliver Neukum wrote:
> 
> > I got the strange case of a keyboard going into autosuspend while a key 
> > was being pressed. The key release never arrived and I had to unplug the 
> > keyboard to get the key unstuck. Is there a clean way to learn from 
> > hid-core.c if a keyboard has keys pressed?
> 
> Hi Oliver,
> 
> HID doesn't keep any permanent state by itself. If you want to know 
> whether a given key is currently pressed or not, you'd have to inspect the 
> bitfields inside input_dev*, I am afraid.

I see no way to do this without a race condition. The field isn't locked
as far as I can tell.
Secondly, what is to happen in case of a system wide suspend? Will
the system wake up thinking that the key is still pressed?

	Regards
		Oliver

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [linux-usb-devel] detecting when keys are being pressed on a keyboard
  2007-09-24 10:56   ` Oliver Neukum
@ 2007-09-24 12:50     ` Dmitry Torokhov
  2007-09-24 13:39       ` Oliver Neukum
  2007-09-24 13:45     ` Jiri Kosina
  1 sibling, 1 reply; 8+ messages in thread
From: Dmitry Torokhov @ 2007-09-24 12:50 UTC (permalink / raw)
  To: Oliver Neukum; +Cc: linux-usb-devel, linux-input

Hi Oliver,

On 9/24/07, Oliver Neukum <oliver@neukum.org> wrote:
> Am Freitag 21 September 2007 schrieb Jiri Kosina:
> > On Fri, 21 Sep 2007, Oliver Neukum wrote:
> >
> > > I got the strange case of a keyboard going into autosuspend while a key
> > > was being pressed. The key release never arrived and I had to unplug the
> > > keyboard to get the key unstuck. Is there a clean way to learn from
> > > hid-core.c if a keyboard has keys pressed?
> >
> > Hi Oliver,
> >
> > HID doesn't keep any permanent state by itself. If you want to know
> > whether a given key is currently pressed or not, you'd have to inspect the
> > bitfields inside input_dev*, I am afraid.
>
> I see no way to do this without a race condition. The field isn't locked
> as far as I can tell.

You can take input_dev->event_lock to stop event from propagating
through input core while you are evaluating the bits. Input lcoking
changes are im -mm and will be merged into 2.6.24.

> Secondly, what is to happen in case of a system wide suspend? Will
> the system wake up thinking that the key is still pressed?
>

For now it will but it is about to change. Input device will send
'release' events for all pressed keys from their suspend method.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [linux-usb-devel] detecting when keys are being pressed on a keyboard
  2007-09-24 12:50     ` [linux-usb-devel] " Dmitry Torokhov
@ 2007-09-24 13:39       ` Oliver Neukum
  2007-09-24 13:45         ` Dmitry Torokhov
  0 siblings, 1 reply; 8+ messages in thread
From: Oliver Neukum @ 2007-09-24 13:39 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: linux-usb-devel, linux-input

Am Montag 24 September 2007 schrieb Dmitry Torokhov:
> Hi Oliver,
> 
> On 9/24/07, Oliver Neukum <oliver@neukum.org> wrote:
> > Am Freitag 21 September 2007 schrieb Jiri Kosina:

> > > Hi Oliver,
> > >
> > > HID doesn't keep any permanent state by itself. If you want to know
> > > whether a given key is currently pressed or not, you'd have to inspect the
> > > bitfields inside input_dev*, I am afraid.
> >
> > I see no way to do this without a race condition. The field isn't locked
> > as far as I can tell.
> 
> You can take input_dev->event_lock to stop event from propagating
> through input core while you are evaluating the bits. Input lcoking
> changes are im -mm and will be merged into 2.6.24.

Hi Dmitry,

I was thinking about a second approach. As all keypresses run through
the interrupt handlers of the hid driver, how about checking the bit field
in the interrupt handler after calling hid_input_report() ?

	Regards
		Oliver

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [linux-usb-devel] detecting when keys are being pressed on a keyboard
  2007-09-24 13:39       ` Oliver Neukum
@ 2007-09-24 13:45         ` Dmitry Torokhov
  2007-09-24 13:54           ` Oliver Neukum
  0 siblings, 1 reply; 8+ messages in thread
From: Dmitry Torokhov @ 2007-09-24 13:45 UTC (permalink / raw)
  To: Oliver Neukum; +Cc: linux-usb-devel, linux-input

On 9/24/07, Oliver Neukum <oliver@neukum.org> wrote:
> Am Montag 24 September 2007 schrieb Dmitry Torokhov:
> > Hi Oliver,
> >
> > On 9/24/07, Oliver Neukum <oliver@neukum.org> wrote:
> > > Am Freitag 21 September 2007 schrieb Jiri Kosina:
>
> > > > Hi Oliver,
> > > >
> > > > HID doesn't keep any permanent state by itself. If you want to know
> > > > whether a given key is currently pressed or not, you'd have to inspect the
> > > > bitfields inside input_dev*, I am afraid.
> > >
> > > I see no way to do this without a race condition. The field isn't locked
> > > as far as I can tell.
> >
> > You can take input_dev->event_lock to stop event from propagating
> > through input core while you are evaluating the bits. Input lcoking
> > changes are im -mm and will be merged into 2.6.24.
>
> Hi Dmitry,
>
> I was thinking about a second approach. As all keypresses run through
> the interrupt handlers of the hid driver, how about checking the bit field
> in the interrupt handler after calling hid_input_report() ?
>

That should work as well I think.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: detecting when keys are being pressed on a keyboard
  2007-09-24 10:56   ` Oliver Neukum
  2007-09-24 12:50     ` [linux-usb-devel] " Dmitry Torokhov
@ 2007-09-24 13:45     ` Jiri Kosina
  1 sibling, 0 replies; 8+ messages in thread
From: Jiri Kosina @ 2007-09-24 13:45 UTC (permalink / raw)
  To: Oliver Neukum; +Cc: linux-input, Dmitry Torokhov, linux-usb-devel

On Mon, 24 Sep 2007, Oliver Neukum wrote:

> > HID doesn't keep any permanent state by itself. If you want to know 
> > whether a given key is currently pressed or not, you'd have to inspect 
> > the bitfields inside input_dev*, I am afraid.
> I see no way to do this without a race condition. The field isn't locked
> as far as I can tell.

Hi Oliver,

Dmitry (CC added) has been doing a lot of rework of locking in input as 
far as I know. He would know this better.

> Secondly, what is to happen in case of a system wide suspend? Will
> the system wake up thinking that the key is still pressed?

If the release event didn't happen before the machine went to suspend, I'd 
say so.

-- 
Jiri Kosina

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [linux-usb-devel] detecting when keys are being pressed on a keyboard
  2007-09-24 13:45         ` Dmitry Torokhov
@ 2007-09-24 13:54           ` Oliver Neukum
  0 siblings, 0 replies; 8+ messages in thread
From: Oliver Neukum @ 2007-09-24 13:54 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: linux-usb-devel, linux-input

Am Montag 24 September 2007 schrieb Dmitry Torokhov:
> > I was thinking about a second approach. As all keypresses run through
> > the interrupt handlers of the hid driver, how about checking the bit field
> > in the interrupt handler after calling hid_input_report() ?
> >
> 
> That should work as well I think.
> 

Thanks, I'll try that.

	Regards
		Oliver

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2007-09-24 13:54 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-21  8:33 detecting when keys are being pressed on a keyboard Oliver Neukum
2007-09-21 12:47 ` Jiri Kosina
2007-09-24 10:56   ` Oliver Neukum
2007-09-24 12:50     ` [linux-usb-devel] " Dmitry Torokhov
2007-09-24 13:39       ` Oliver Neukum
2007-09-24 13:45         ` Dmitry Torokhov
2007-09-24 13:54           ` Oliver Neukum
2007-09-24 13:45     ` Jiri Kosina

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).