F10 in Windows

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
raven_coda
Posts: 89
Joined: Thu Aug 17, 2006 8:11 pm
Location: Salt Lake City, UT, USA
Contact:

F10 in Windows

Post by raven_coda »

I've seen a few posts about this and tried to implement them but none of them seem to allow my eventreciever to catch when F10 is pressed. Seen this post but wasn't sure where in the file to add the code http://irrlicht.sourceforge.net/phpBB2/ ... hlight=f10

I just want to be able to tell when F10 is Pressed! :x

Using irrlicht 1.3.1
Windows Vista
Definition of an Upgrade: Take old bugs out, put new ones in.
Lonesome Ducky
Competition winner
Posts: 1123
Joined: Sun Jun 10, 2007 11:14 pm

Post by Lonesome Ducky »

Well you could use virtual keycode like so:
if(GetAsyncKeyState(VK_F10)<0) {
//do stuff here
}
That will do just fine
raven_coda
Posts: 89
Joined: Thu Aug 17, 2006 8:11 pm
Location: Salt Lake City, UT, USA
Contact:

Post by raven_coda »

That's Great!!!!! :D

between that and this post I have put this together to fix the prob. Maybe they can be built into the next release?

in CIrrDeviceWin32.cpp
add

Code: Select all

|| wParam == SC_KEYMENU
to the enf of line

Code: Select all

if ((wParam & 0xFFF0) == SC_SCREENSAVE ||
			(wParam & 0xFFF0) == SC_MONITORPOWER)
then in your main loop i added

Code: Select all

if(GetAsyncKeyState(VK_F10)!=f10)
			{
				f10=GetAsyncKeyState(VK_F10);
				SEvent ev;
				ev.EventType= irr::EET_KEY_INPUT_EVENT;
				ev.KeyInput.Char=0;
				ev.KeyInput.PressedDown=(f10<0);
				ev.KeyInput.Key=irr::KEY_F10;
				device->getEventReceiver()->OnEvent(ev);
			}
with this just before the main loop

Code: Select all

short f10=GetAsyncKeyState(VK_F10);
for this to work you must include windows.h
Definition of an Upgrade: Take old bugs out, put new ones in.
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

What you'd need to do to get it to work like you'd expect would be to add support for WM_SYSKEYUP and WM_SYSKEYDOWN messages. That will also get the left and right ALT keys to work as expected. Unfortunately if you fix this, ALT+F4 stops working because Irrlicht will intercept all keyboard input before the default window handler gets a chance. Of course you can overcome that by providing your own way for the program to exit.

Code: Select all

  // in CIrrDeviceWin32.cpp
  case WM_SYSKEYDOWN: // added
  case WM_KEYDOWN:
  {
    // snip...

    return 0;
  }

  case WM_SYSKEYUP: // added
  case WM_KEYUP:
  {
    // snip...

    return 0;
  }

  // snip...

  case WM_SYSCOMMAND:
    // prevent screensaver or monitor powersave mode from starting
    if ((wParam & 0xFFF0) == SC_SCREENSAVE ||
        (wParam & 0xFFF0) == SC_MONITORPOWER)
    {
      return 0;
    }
    else if ((wParam & 0xFFF0) == SC_KEYMENU) // added
    {
      return 0;
    }
    break;
Travis
Lonesome Ducky
Competition winner
Posts: 1123
Joined: Sun Jun 10, 2007 11:14 pm

Post by Lonesome Ducky »

For the problem with alt+f4 can't you just write code to see if alt+f4 are down then use PostQuitMessage(0);?
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

Absolutely. The only thing I'm saying is that you have to handle the message yourself where Irrlicht used to do it for you. If you have a program that uses the FPS camera and run it using a 'fixed' Irrlicht.dll, you'll have a hard time getting out of the program. You'll probably end up getting the task manager and killing it that way.

Travis
Post Reply