Hi Thomas,

This is a snippet of code from the BGT engine, with some specifics taken out so that you get a bare bones example that still works. Just be sure to always call uninstall_keyhook from your cleanup procedure.


HHOOK g_hKeyboardHook=NULL;
bool hooked=false;

LRESULT CALLBACK LowLevelKeyboardProc( int nCode, WPARAM wParam, LPARAM lParam )
{
       return CallNextHookEx( g_hKeyboardHook, nCode, wParam, lParam);
}

bool install_keyhook()
{
if(hooked==true)
{
return false;
}
g_hKeyboardHook = SetWindowsHookEx( WH_KEYBOARD_LL, LowLevelKeyboardProc, GetModuleHandle(NULL), 0 );
if(g_hKeyboardHook==NULL)
{
return false;
}
hooked=true;
return true;
}

bool uninstall_keyhook()
{
if(hooked==false)
{
return false;
}
UnhookWindowsHookEx( g_hKeyboardHook );
g_hKeyboardHook=NULL;
hooked=false;
return true;
}

Kind regards,

Philip Bennefall
----- Original Message ----- From: "Thomas Ward" <thomasward1...@gmail.com>
To: <phi...@blastbay.com>; "Gamers Discussion list" <gamers@audyssey.org>
Sent: Thursday, November 03, 2011 2:36 PM
Subject: Re: [Audyssey] Keyboard hooks Was Re: USA Games News


Hi Philip,

Would you mind sending me some example source code how to do this. I'm
clueless on how to set a low-level key hook, and it might save me time
and frustration researching this if you could just send me some source
code examples of how to do this.

As for the win32 keyboard events I know. They are slow and they suck
in any kind of fast action game so that would definitely not be my
first choice.  Fixing the problem with JFW and DirectInput is
definitely my goal here.

Thanks.

On 11/1/11, Philip Bennefall <phi...@blastbay.com> wrote:
Hi Thomas,

There is an easy solution to fix this problem. I use it in BGT with no
difficulties. You want to install a low level keyhook in the process using
SetWindowsHookEx, and inside the hook callback you simply let all the
keyboard events through. What happens then is that, since Jaws installs a
low level keyhook as well, my own takes priority which means that I get
control before Jaws does, and I can thus make the decision whether the key
is supposed to be allowed through or not rather than leaving that choice up
toJaws.

Hope this helps you. And please do not! use the keyboard events from Win32, they are sluggish in comparison to Direct X and they have other issues like the automatic repeats and lack of certain keys without special work arounds
etc.

Kind regards

Philip Bennefall

----- Original Message -----
From: "Thomas Ward" <thomasward1...@gmail.com>
To: "Gamers Discussion list" <gamers@audyssey.org>
Sent: Tuesday, November 01, 2011 3:41 AM
Subject: Re: [Audyssey] USA Games News


Hi,

Ah, that's still one of the issues I'm working on. When using Jaws for
speech output there is a keyboard trapping issue I've not found a good
way around yet. I did put the JFW demo to sleep and that seemed to
work, but even though it frees up the keyboard its not as responsive
as using say NVDA, because I think Jaws still tries to capture or trap
the keyboard in the background. It is pretty problematic right now. I
may have to switch over to standard keyboard events rather than using
DirectX to fix that issue.

However, as for ESpeak and Eloquence I don't think they fit well into
a game environment, but its whatever works. With newer versions of
Jaws like Jaws 12 there is plenty of RealSpeak Direct voices like Tom,
Karen, Jennifer, Daniel, etc so all the user has to do is download and
install a RealSpeak direct voice, set Jaws up to use that, and the
game will use the RealSpeak voices instead of Eloquence. So hopefully
it is things like that which will provide a better solution than just
ESpeak or Eloquence.

Cheers!




On 10/31/11, pitermach <piterm...@gmail.com> wrote:
This news article made me curious about something.
Have you been able to work around the jaws keyboard trap issue? I guess
you understand what I mean. Even then I'm not sure how well you could
play a game like MOTA with it running, since it does make the keyboard
sort of sluggish in some parts (scraping in a sound editor for instance)
Over all though i'm glad things are progressing. Being a NVDA user
myself I really like using it as speech output in games. You could argue
how Espeak/eloquence fits into a mood of a game, but hey. What ever
works for someone just works.


---
Gamers mailing list __ Gamers@audyssey.org
If you want to leave the list, send E-mail to
gamers-unsubscr...@audyssey.org.
You can make changes or update your subscription via the web, at
http://mail.audyssey.org/mailman/listinfo/gamers_audyssey.org.
All messages are archived and can be searched and read at
http://www.mail-archive.com/gamers@audyssey.org.
If you have any questions or concerns regarding the management of the
list,
please send E-mail to gamers-ow...@audyssey.org.


---
Gamers mailing list __ Gamers@audyssey.org
If you want to leave the list, send E-mail to
gamers-unsubscr...@audyssey.org.
You can make changes or update your subscription via the web, at
http://mail.audyssey.org/mailman/listinfo/gamers_audyssey.org.
All messages are archived and can be searched and read at
http://www.mail-archive.com/gamers@audyssey.org.
If you have any questions or concerns regarding the management of the list,
please send E-mail to gamers-ow...@audyssey.org.


---
Gamers mailing list __ Gamers@audyssey.org
If you want to leave the list, send E-mail to
gamers-unsubscr...@audyssey.org.
You can make changes or update your subscription via the web, at
http://mail.audyssey.org/mailman/listinfo/gamers_audyssey.org.
All messages are archived and can be searched and read at
http://www.mail-archive.com/gamers@audyssey.org.
If you have any questions or concerns regarding the management of the list,
please send E-mail to gamers-ow...@audyssey.org.



---
Gamers mailing list __ Gamers@audyssey.org
If you want to leave the list, send E-mail to gamers-unsubscr...@audyssey.org.
You can make changes or update your subscription via the web, at
http://mail.audyssey.org/mailman/listinfo/gamers_audyssey.org.
All messages are archived and can be searched and read at
http://www.mail-archive.com/gamers@audyssey.org.
If you have any questions or concerns regarding the management of the list,
please send E-mail to gamers-ow...@audyssey.org.

Reply via email to