The Gaming Universe

The Archives => Open Zelda => Archived Projects => OZ Help => Topic started by: Khatuni on May 16, 2011, 05:58:07 PM

Title: Disable Alt Key Pause
Post by: Khatuni on May 16, 2011, 05:58:07 PM
Usually in Windows, when you press Alt in a program, it calls the menu bar and pauses the program. Now I removed the menu bar in OZ, but Alt still pauses the game, even in fullscreen mode. How would I disable this, so that I can use Alt as a regular control key?
Title: Re: Disable Alt Key Pause
Post by: KingOfHumans on May 16, 2011, 08:24:39 PM
There's no Alt anywhere in the OpenZelda.rc file, right?
Title: Re: Disable Alt Key Pause
Post by: Aliem on May 17, 2011, 03:01:27 AM
This might be presumptuous of me, but why not use another key?
Title: Re: Disable Alt Key Pause
Post by: Khatuni on May 17, 2011, 05:53:02 AM
This might be presumptuous of me, but why not use another key?

It's not that I need Alt for a certain thing, but I want all keyboard keys to be available for the player, just like in Snes9x and Project64.

There's no Alt anywhere in the OpenZelda.rc file, right?

Nope, the only "alt" in my source is in amx.c.

Edit: Luke sent me this code, to use in MainWndProc:

   case WM_SYSKEYDOWN:
      return 0;
      break;

But it disables the other keyboard keys, so that won't work.
Title: Re: Disable Alt Key Pause
Post by: KingOfHumans on May 17, 2011, 10:41:03 AM
What does it to in the amx.c? (I'll look it up)
Maybe what Luke suggested will help narrow down the problem.

edit: I believe Luke's idea will work. Try placing his code after the keys check.
I'm not 100% sure yet but I think the alt key is being sent here.

return DefWindowProc(hWnd, msg, wParam, lParam);

So I'm looking up the .h file to see if this is true. So like I said, try it after the keys function.
Title: Re: Disable Alt Key Pause
Post by: Khatuni on May 17, 2011, 02:03:24 PM
amx.c handles the Small scripts, so that's not the problem.
You mean after the key check, like this?:
Code: [Select]
case WM_KEYUP:
g_pGame->m_fKeys[wParam] = false;
g_pGame->m_fkey = 0;
break;
case WM_KEYDOWN:
g_pGame->m_fKeys[wParam] = true;
g_pGame->m_fkey = wParam;
break;
        case WM_SYSKEYDOWN:
                return 0;
                break;

Doesn't matter where I put the WM_SYSKEYDOWN, it can't be used in combo with other keys.

I don't think the solution should be in MainWndProc. It's not a key check issue, it's the function of Alt/F10 that runs after the key has been checked. That function call needs to be disabled.

Edit: After reading through some articles on the internet, I think this is really a standard Windows thing. There are ways to work around it, but I wanted to be able to still use Alt as a regular key, not disabling it completely. Well...  whatever.
Title: Re: Disable Alt Key Pause
Post by: KingOfHumans on May 17, 2011, 02:27:24 PM
I did a little more searching and found two pages that may help.
http://cboard.cprogramming.com/windows-programming/61896-disabling-alt-key.html

http://www.codeproject.com/KB/winsdk/AntonioWinLock.aspx

It most likely has to do with windows.h as most programs use it.

btw 0x20000000 is how you write hex, works for OZ to.
I don't get it completely in this case since it converts to 536870912.
You can use my "native ToHex(val, out[]);" to understand hex a bit more. Especially that & symbol.
Title: Re: Disable Alt Key Pause
Post by: Khatuni on May 17, 2011, 04:51:32 PM
I'm not going to change windows.h... One mistake and it might screw up my whole computer.  :p
Title: Re: Disable Alt Key Pause
Post by: Aliem on May 17, 2011, 10:56:08 PM
Quote
lukex> Can some inform Khatuni that WM_KEYDOWN/WM_KEYUP in the switch can be copied for WM_SYSKEYDOWN/WM_SYSKEYUP so alt key can be used. Thanks.
Title: Re: Disable Alt Key Pause
Post by: Khatuni on May 18, 2011, 07:28:06 AM
I get it now. Give him my thanks if you speak him. Hotmail blocks his account for me.

Code: [Select]
case WM_KEYUP:
g_pGame->m_fKeys[wParam] = false;
g_pGame->m_fkey = 0;
break;
case WM_KEYDOWN:
g_pGame->m_fKeys[wParam] = true;
g_pGame->m_fkey = wParam;
break;
case WM_SYSKEYUP:
g_pGame->m_fKeys[wParam] = false;
g_pGame->m_fkey = 0;
break;
case WM_SYSKEYDOWN:
g_pGame->m_fKeys[wParam] = true;
g_pGame->m_fkey = wParam;
return 0;
break;
Title: Re: Disable Alt Key Pause
Post by: KingOfHumans on May 18, 2011, 10:14:39 AM
So you also removed the function CheckKeysDown/Up I see.
Anyways, glad you got it working.
Title: Re: Disable Alt Key Pause
Post by: Khatuni on May 18, 2011, 12:31:26 PM
Those functions are useless since they are only returned there (in the CV).