Add a key-release signal in addition to key-press

Bug #390552 reported by ekilfoil
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
GtkHotkey
Confirmed
Wishlist
Mikkel Kamstrup Erlandsen
0.3
New
Undecided
Unassigned

Bug Description

When the hotkey is pressed, an event is sent as expected, however, there is no way to track a release event. The keypress release seems to happen instantly.

We're trying to implement a GPL version of voice chat software. The software uses a keypress to turn on the mic and send sound.

Instead of an "activated" event, I would expect a "pressed" and "released" event just like a GTK button.

Revision history for this message
Mikkel Kamstrup Erlandsen (kamstrup) wrote :

It is a good idea and I will look into it

Changed in gtkhotkey:
status: New → Confirmed
importance: Undecided → Wishlist
assignee: nobody → Mikkel Kamstrup Erlandsen (kamstrup)
Revision history for this message
Mikkel Kamstrup Erlandsen (kamstrup) wrote :

Ok, I think this can be done, fairly easily. Targetting 0.3.0

summary: - keypress release is premature
+ Add a key-release signal in addition to key-press
Changed in gtkhotkey:
milestone: none → 0.3.0
Revision history for this message
Mikkel Kamstrup Erlandsen (kamstrup) wrote :

I am mostly concerned about Win32 support here. The X11 part is definitely feasible. I talked to *** a bit about this and looked at the docs myself: http://msdn.microsoft.com/en-us/library/ms646309%28VS.85%29.aspx

As far as I can tell, Win32 can not support key-release events out of the box. It might be possible if one wants to go closer to the core Win32 API, but I am not sure anyone has time or skills to do that.

Unless we can get a 100% affirmative that this is portable and indeed feasible without jumping through hoops I am going to have to reject it.

Watch this space for updates.

Revision history for this message
ekilfoil (ekilfoil) wrote : Re: [Bug 390552] Re: Add a key-release signal in addition to key-press

It's been a while since I submitted this so I'm not sure exactly what the
situation is, but I can say that Windows supports key-release events *WAY*
better than X11. X11 pushes a fake key-release event into the X event queue
for autorepeat. Windows only issues a key-release event when the physical
key is actually released.
In windows, it is easy to detect an actual key release event. In X11, it is
much, much harder.

-eric

On Sat, Sep 12, 2009 at 7:11 AM, Mikkel Kamstrup Erlandsen <
<email address hidden>> wrote:

> I am mostly concerned about Win32 support here. The X11 part is
> definitely feasible. I talked to *** a bit about this and looked at the
> docs myself: http://msdn.microsoft.com/en-
> us/library/ms646309%28VS.85%29.aspx
>
> As far as I can tell, Win32 can not support key-release events out of
> the box. It might be possible if one wants to go closer to the core
> Win32 API, but I am not sure anyone has time or skills to do that.
>
> Unless we can get a 100% affirmative that this is portable and indeed
> feasible without jumping through hoops I am going to have to reject it.
>
> Watch this space for updates.
>
> --
> Add a key-release signal in addition to key-press
> https://bugs.launchpad.net/bugs/390552
> You received this bug notification because you are a direct subscriber
> of the bug.
>
> Status in Gtk Hotkey Library: Confirmed
> Status in GtkHotkey 0.3 series: New
>
> Bug description:
> When the hotkey is pressed, an event is sent as expected, however, there is
> no way to track a release event. The keypress release seems to happen
> instantly.
>
> We're trying to implement a GPL version of voice chat software. The
> software uses a keypress to turn on the mic and send sound.
>
> Instead of an "activated" event, I would expect a "pressed" and "released"
> event just like a GTK button.
>

Revision history for this message
Mikkel Kamstrup Erlandsen (kamstrup) wrote :

My biggest concern is that the native Win32 Hotkey API doesn't expose key-release events as far as I can see, and I, for one, don't have the faintest clue on how to work with the underlying windowing system of Win32.

So the question is simple: Is it realistic that we can have an implementation of GtkHotkeyListener, with a key-released signal add to to the interface, implemented on top of Win32?

But you seem to know the insides of Win32 way better than me... *hint* *hint* ;-)

Revision history for this message
ekilfoil (ekilfoil) wrote :

Actually... that was pretty much the extent of my Windows keyboard
processing knowledge :).
I don't know anything about the Win32 Hotkey API (or Win32 anything really),
but some googling led me to this:

http://msdn.microsoft.com/en-us/library/dd458624(VS.85).aspx

I guess what you're using now is the builtin hotkey register/notification
process that shows there, and you're right, it doesn't seem to be able to
deal with it. You'd have to actually look for the KEYDOWN and KEYUP
notifications in order to implement this.

-eric

On Mon, Sep 14, 2009 at 2:30 AM, Mikkel Kamstrup Erlandsen <
<email address hidden>> wrote:

> My biggest concern is that the native Win32 Hotkey API doesn't expose
> key-release events as far as I can see, and I, for one, don't have the
> faintest clue on how to work with the underlying windowing system of
> Win32.
>
> So the question is simple: Is it realistic that we can have an
> implementation of GtkHotkeyListener, with a key-released signal add to
> to the interface, implemented on top of Win32?
>
> But you seem to know the insides of Win32 way better than me... *hint*
> *hint* ;-)
>
> --
> Add a key-release signal in addition to key-press
> https://bugs.launchpad.net/bugs/390552
> You received this bug notification because you are a direct subscriber
> of the bug.
>
> Status in Gtk Hotkey Library: Confirmed
> Status in GtkHotkey 0.3 series: New
>
> Bug description:
> When the hotkey is pressed, an event is sent as expected, however, there is
> no way to track a release event. The keypress release seems to happen
> instantly.
>
> We're trying to implement a GPL version of voice chat software. The
> software uses a keypress to turn on the mic and send sound.
>
> Instead of an "activated" event, I would expect a "pressed" and "released"
> event just like a GTK button.
>

Revision history for this message
Mikkel Kamstrup Erlandsen (kamstrup) wrote :

The Win32 docs for KEY{UP,DOWN} specifically say that they are added to the message queue of the window with the focus. We an equivalent of XGrabKey: http://tronche.com/gui/x/xlib/input/XGrabKey.html

Revision history for this message
ekilfoil (ekilfoil) wrote :

I think this may be what you're looking for:

http://msdn.microsoft.com/en-us/library/ms644990(VS.85).aspx
and some more info here:

http://www.codeproject.com/KB/cs/globalhook.aspx

You have to be careful with XGrabKey as well. XGrabKey will steal focus and
you also lose the ability to *not* steal the key from the XEvent queue. In
fact, I think this is harder to do in X than it is in Windows. I ended up
having to code a GTK timeout to poll the state of the keyboard every 250msec
in order to implement this, and I think that's a horrible, horrible
solution.

The EVIE library may have a solution for it in X though. But I know in
Windows that this can be done, because I've seen apps that do this. They're
all just closed source.

-eric

On Mon, Sep 14, 2009 at 1:06 PM, Mikkel Kamstrup Erlandsen <
<email address hidden>> wrote:

> The Win32 docs for KEY{UP,DOWN} specifically say that they are added to
> the message queue of the window with the focus. We an equivalent of
> XGrabKey: http://tronche.com/gui/x/xlib/input/XGrabKey.html
>
> --
> Add a key-release signal in addition to key-press
> https://bugs.launchpad.net/bugs/390552
> You received this bug notification because you are a direct subscriber
> of the bug.
>
> Status in Gtk Hotkey Library: Confirmed
> Status in GtkHotkey 0.3 series: New
>
> Bug description:
> When the hotkey is pressed, an event is sent as expected, however, there is
> no way to track a release event. The keypress release seems to happen
> instantly.
>
> We're trying to implement a GPL version of voice chat software. The
> software uses a keypress to turn on the mic and send sound.
>
> Instead of an "activated" event, I would expect a "pressed" and "released"
> event just like a GTK button.
>

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.