detect keyrelease events?

Need help with C, C++, perl, python, etc?

detect keyrelease events?

Postby jointhefree » 2015-03-30 19:21

Calling on brains faster or wiser than mine, because I've failed with the search engine to find the answer.
I'm trying to get a particular voice chat app (IHearYou, designed for lan) to do what it's not designed to do. It goes by voice activation, but I want key-presses. I don't use the Windows (Super_L) key for anything, so that will be my key. I know several ways of triggering events with a keypress. I want to raise my mic volume to some high level on Super_L keypress events, using alsamixer for the adjustment. Problem is, I need to reduce mic volume to 0 on key RELEASE. Detecting keyreleases must be possible, right? Preferrably in bash? Or if I can run some raw code, that'd probably be fine too.
The only thing I've found so far for monitoring global events is xev, but that creates a window in the front of everything, which would be annoying.

EDIT: I found a solution, but imperfect. Xbindkeys. xbindkeys-config was helpful too for speeding my progress up. So I'll be able to have a script that makes alsamixer adjust the mic volume to 0 when I release a designated key and another script to set it to 30 triggered when I press that key. For some reason, I'm having trouble getting xbindkeys to map a script to the the Windows Super_L key keyrelease, but other keys work, so I'm sure I can get something working here.

Another edit: I also found a xset r off was necessary, as auto-repeat simulates repeated keypresses and releases, causing the mic volume to go up and down many times in a second. Not good.

FINALLY: Here's what I ended up with. a script called toggle-mic-on:
#!/bin/bash
xset -r 78
amixer -q set Digital 60
exit

and a script called toggle-mic-off
#!/bin/bash
xset -r 78
amixer -q set Digital 0
exit

Using xbindkeys-config, I mapped toggle-mic-on to occur when I press the scroll_lock key and toggle-mic-off when I release the scroll_lock key The condition looks like: "Release + Scroll_Lock" . The "xset -r 78" line gets rid of key auto-repeat for just the scroll_lock key. Because I want to keep auto-repeat on the "normal" keys.

Yes, I'm adjusting just the digital. Whatever that means. It seems to be tied with the overall recording volume. Then I adjust my mic, micbst, and capture levels to get them right using audacity. I record (while holding the scroll-lock key) and watch to see if I'm getting a good volume but avoiding red levels.

I really would have preferred to map these events to hotkey triggers using openbox's rc.xml (or in my case, lxde-rc.xml), but I could find nothing in the docs about release events being possible. So, I was forced to use xbindkeys. It works, anyway.
Last edited by jointhefree on 2015-04-01 02:36, edited 10 times in total.
jointhefree
 
Posts: 30
Joined: 2014-01-04 14:14

Re: detect keyrelease events?

Postby dasein » 2015-03-30 20:32

jointhefree wrote:...I've failed with the search engine to find the answer.

Really??? I find myself wondering exactly what query terms you used. (And "I tried lots and lots and magically can't remember any of them" just means you that you need to take notes when you redo the searches.)
Last edited by dasein on 2015-03-30 20:45, edited 1 time in total.
User avatar
dasein
 
Posts: 7775
Joined: 2011-03-04 01:06
Location: Terra Incantationum

Re: detect keyrelease events?

Postby jointhefree » 2015-03-30 20:44

Well, I'm clearly lost. :o Thank you for your considerate helpfulness, you kind man, you. Really, though, am I in the wrong place? I may be. It sure does sound like it.
jointhefree
 
Posts: 30
Joined: 2014-01-04 14:14

Re: detect keyrelease events?

Postby dasein » 2015-03-30 20:48

Sharing query terms, rather than invoking the "magic amensia" defense, would have gone a long way toward validating your claim to exhaustive searching.

Maybe have "another" go. I found thousands of hits with a brain-dead obvious query.
User avatar
dasein
 
Posts: 7775
Joined: 2011-03-04 01:06
Location: Terra Incantationum

Re: detect keyrelease events?

Postby jointhefree » 2015-03-30 20:53

I wanted help, not google tips. I apologize for wasting your time.
jointhefree
 
Posts: 30
Joined: 2014-01-04 14:14

Re: detect keyrelease events?

Postby jointhefree » 2015-03-30 21:01

What really puzzles me is the anger I always encounter in here. Is it that certain people feel like a post REQUIRES them to help or respond, meaning that a post by someone far less experienced is therefore an intentional bid to waste their time and effort?
jointhefree
 
Posts: 30
Joined: 2014-01-04 14:14

Re: detect keyrelease events?

Postby jointhefree » 2015-03-31 01:46

Reading the thread, I realize now, it may have just been a misunderstanding. My mentioning that I failed in my search made it sound like I was seeking help searching the search engines I suppose. And that would be an oops on me. Sorry about that. It was me who was the angry one. :D I'll blame it on this rare headache I have today.
jointhefree
 
Posts: 30
Joined: 2014-01-04 14:14

Re: detect keyrelease events?

Postby Head_on_a_Stick » 2015-03-31 07:11

If you use xev that returns key release events ("KeyRelease") so you could grep the output from that.
dbruce wrote:Ubuntu forums try to be like a coffee shop in Seattle. Debian forums strive for the charm and ambience of a skinhead bar in Bacau. We intend to keep it that way.
User avatar
Head_on_a_Stick
 
Posts: 8324
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: detect keyrelease events?

Postby jointhefree » 2015-04-01 02:11

You mean, to get the key code for the Super_L key? Yeah, I know about xev. No, it seems to be some problem with xkeybind or something. It just doesn't want to map to the Super_L (windows key). Maybe I should try the right Windows key.. I probably already did, but not sure.
jointhefree
 
Posts: 30
Joined: 2014-01-04 14:14


Return to Programming

Who is online

Users browsing this forum: No registered users and 2 guests

fashionable