GUIKeyEvent 1.2a

This bundle is marked as approved. It works and satisfies the submission rules.
Version 1.31 introduced the possibility to detect when ANY keyboard key is pressed or released, but this functionality is limited to JASS/Lua users only as Blizzard never implemented any GUI functionality for this new feature.

I've seen some requests and questions from GUI users wondering how they can implement this feature, but it's usually difficult as they're not used to work with code.
GUIKeyEvent changes that and now GUI users can detect whenever ANY key is pressed or released by any player.


# Features
- Detect when any keyboard key is pressed or released.
- Detect if a meta key was pressed with the key
--- Meta keys are Shift, Control, Alt and META (windows-key)
--- So you could, as an example, detect if a player presses "W", while holding the Shift-key.


# How to Use
- Use the event "Game - GUIKeyEvent becomes Equal to 1.00" as your trigger event to detect when a key is pressed or released.
- You can then use 5 variables in your trigger:
--- "_GUIKeyPlayer" = This is the player that pressed the keyboard key.

--- "_GUIKeyTrigger" = This is the keyboard key that was pressed.
----- Use an "Integer Comparison" in order to detect which key was pressed. Example: "_GUIKeyTrigger Equal to GUIKEY_W"

--- "_GUIKeyMeta" = This holds meta key data for the pressed key. Was Shift, Control, Alt or the Windows key pressed together with the key?
----- Use an "Integer Comparison" in order to detect which meta key was pressed. Example: "_GUIKeyMeta Equal to GUIMETAKEY_SHIFT". You may also check for multiple at once, like "_GUIKeyMeta Equal to GUIMETAKEY_SHIFT_CONTROL_ALT"

--- "_GUIKeyIsPressed" = Is the keyboard key pressed or released?
----- Use a "Boolean Comparison" in order to detect if the key is pressed or not. Example: "_GUIKeyIsPressed Equal to True"

--- "_GUIKeyIsReleased" = Is the keyboard key pressed or released?
----- Use a "Boolean Comparison" in order to detect if the key is pressed or not. Example: "_GUIKeyIsReleased Equal to True"

--- You can turn off the system at any time with the "Trigger - Turn off GUIKeyEvent_System" action and then turn it on with "Trigger - Turn on GUIKeyEvent_System".


# How to Install
- 1. It's recommended to delete any previous "GUIKeyEvent'' folder you may already have installed before installing a new version of GUIKeyEvent.
- 2. Copy the "GUIKeyEvent" folder.
- 3. Open your map and paste the folder into the Trigger Editor.
- 4. Adjust any GUIKeyEvent settings in the "GUIKeyEvent Settings" trigger.
- 5. (optional) Check the "GUIKeyEvent Demo(s)" folder for some examples of how to use GUIKeyEvent.
- 6. Done.


# Additional Notes
- Thanks to Tasyen for some information regarding oskey natives (https://www.hiveworkshop.com/threads/oskey-player-key-event.319903/)
- The number of players playing drastically increases the map loading time.
- The number of variables required is massive, due to enable easy variable comparisons.
- I barely know what half of the keys represent, so any questions regarding that may not be answered by me.
- 3 demos are included:
--- A very simple WASD-movement system.
--- A basic trigger to display any key that was pressed or released by a player.
--- A basic trigger to have the "Escape"-key open up the F10 Menu.



# 1.2a:
- Added a "Lightweight" version.
--- This version only detect the more common keys and uses 54 less variables.
--- The map loading time is improved as well.
- Added a new string array variable "GUIKEY_NAME" that can be used to get the name of the keys. Could be useful for debugging, etc.
- Fixed an issue that caused the OSKEY_OEM_CLEAR key to not be registered.

# 1.1a:
- The system is now initialized at RunInitializationTriggers in main (in order to not have GUIKeyEvent Settings overwritten by InitGlobals).
- Removed desync prone GetPlayerController/GetPlayerSlotState at map init and instead added GUIKeyEvent_S_EnablePlayer to the GUIKeyEvent Settings trigger that allows the user to manually set players to use.
- "GUIKeyEvent_S_BlockRepeat" setting set to true by default in the GUIKeyEvent Settings trigger.
- Renamed the variable "_GUIKeyIsDown" to "_GUIKeyIsPressed".
- Added a new boolean variable "_GUIKeyIsReleased", that can be used instead of "_GUIKeyIsPressed Equal to False"

# 1.0a:
- Release


JASS:
//===========================================================================
//
//  GUIKeyEvent 1.2a
//  Author: lolreported
//
//
//  Important Note:
//  Do not touch any of the code below, unless you
//  know what you're doing. I'll not help debug any errors
//  resulting from careless editing.
//
//===========================================================================

library GUIKeyEvent
    globals
        // If true, static if's causes certain code not to be compiled for Lightweight version.
        // Will cause errors if set to false in lightweight version as GUI variables is missing.
        private constant boolean IS_LIGHTWEIGHT_VERSION = false
   
        // For init
        private constant integer CONVERT_OS_KEY_TYPE_INDEX_START = $08
        private constant integer CONVERT_OS_KEY_TYPE_INDEX_END   = $FE
       
        // Value combined of all possible meta keys.
        // MetaKeys are "none"(0), "shift"(1), "control"(2), "alt"(4) and "META"(8) (windows key).
        private constant integer META_KEY_MAX                    = 15
        private integer currentKey
       
        // For settings
        private integer array playerPrevKey
        private boolean array playerKeyWasDown
    endglobals
   
    private function OnGUIKeyEvent takes nothing returns boolean
        local integer playerId
        // Set globals whenever a players press a key
        set udg__GUIKeyPlayer    = GetTriggerPlayer() // Set player that triggered the oskey event
        set udg__GUIKeyTrigger   = GetHandleId(BlzGetTriggerPlayerKey()) // Convert oskey to handle in order to be able to compare with GUI key variables
        set udg__GUIKeyIsPressed = BlzGetTriggerPlayerIsKeyDown() // Set boolean to if the key was pressed or released
       
        // Ignore new events if the key is held down and udg_GUIKeyEvent_S_BlockRepeat is set to true.
        if (udg_GUIKeyEvent_S_BlockRepeat) then
            set playerId = GetPlayerId(udg__GUIKeyPlayer)
            if (playerKeyWasDown[playerId] == udg__GUIKeyIsPressed and playerPrevKey[playerId] == udg__GUIKeyTrigger) then
                return false
            endif
            set playerPrevKey[playerId]    = udg__GUIKeyTrigger
            set playerKeyWasDown[playerId] = udg__GUIKeyIsPressed
        endif
       
        set udg__GUIKeyMeta       = BlzGetTriggerPlayerMetaKey() // Set meta key for pressed key
        set udg__GUIKeyIsReleased = not udg__GUIKeyIsPressed

        // Trigger events
        set udg_GUIKeyEvent = 0.0
        set udg_GUIKeyEvent = 1.0
        //set udg_GUIKeyEvent = 0.0
        return false
    endfunction
   
    private function LWKeyCheck takes integer currentKey returns boolean
        // Returns false if the key is not a lightweight key
        return not (currentKey == $15 or /*
            */ currentKey == $17 or /*
            */ currentKey == $18 or /*
            */ currentKey == $19 or /*
            */ currentKey == $1C or /*
            */ currentKey == $1D or /*
            */ currentKey == $1E or /*
            */ currentKey == $1F or /*
            */ currentKey == $92 or /*
            */ currentKey == $92 or /*
            */ currentKey == $93 or /*
            */ currentKey == $94 or /*
            */ currentKey == $95 or /*
            */ currentKey == $96 or /*
            */ currentKey == $A6 or /*
            */ currentKey == $A7 or /*
            */ currentKey == $A8 or /*
            */ currentKey == $A9 or /*
            */ currentKey == $AA or /*
            */ currentKey == $AB or /*
            */ currentKey == $AC or /*
            */ currentKey == $B4 or /*
            */ currentKey == $B5 or /*
            */ currentKey == $B6 or /*
            */ currentKey == $B7 or /*
            */ currentKey == $E3 or /*
            */ currentKey == $E4 or /*
            */ currentKey == $E5 or /*
            */ currentKey == $E6 or /*
            */ currentKey == $E7 or /*
            */ currentKey == $E9 or /*
            */ currentKey == $EA or /*
            */ currentKey == $EB or /*
            */ currentKey == $EC or /*
            */ currentKey == $ED or /*
            */ currentKey == $EE or /*
            */ currentKey == $EF or /*
            */ currentKey == $F0 or /*
            */ currentKey == $F1 or /*
            */ currentKey == $F2 or /*
            */ currentKey == $F3 or /*
            */ currentKey == $F4 or /*
            */ currentKey == $F5 or /*
            */ currentKey == $F6 or /*
            */ currentKey == $F7 or /*
            */ currentKey == $F8 or /*
            */ currentKey == $F9 or /*
            */ currentKey == $FA or /*
            */ currentKey == $FB or /*
            */ currentKey == $FC or /*
            */ currentKey == $FD or /*
            */ currentKey == $FE)
        return true
    endfunction
   
    private function RegisterKey takes nothing returns nothing
        local integer playerId
        local integer metaKey
        local oskeytype key
       
        //ConvertOsKeyType starts at index 8 and ends at index 254 ($08 to $FE)
        set currentKey = currentKey + 1
        if (currentKey > CONVERT_OS_KEY_TYPE_INDEX_END) then
          // No more keys to register, finish.
          call DestroyTrigger(GetTriggeringTrigger())
          return
        endif
       
        // If lightweight version, only register certain keys
        if (not IS_LIGHTWEIGHT_VERSION or LWKeyCheck(currentKey)) then
            // Get the current oskey and register player key events
            set key = ConvertOsKeyType(currentKey)
            set playerId = 0
            loop
                // Only register oskey events for players that are active
                // Registers both keyDown/keyUp and all metaKey combinations.
                if (udg_GUIKeyEvent_S_EnablePlayer[playerId + 1]) then
                    set metaKey = 0
                    loop
                        call BlzTriggerRegisterPlayerKeyEvent(udg_GUIKeyEvent_System, Player(playerId), key, metaKey, false)
                        call BlzTriggerRegisterPlayerKeyEvent(udg_GUIKeyEvent_System, Player(playerId), key, metaKey, true)
                        set metaKey = metaKey + 1
                        exitwhen(metaKey > META_KEY_MAX)
                    endloop
                endif
                set playerId = playerId + 1
                exitwhen(playerId >= bj_MAX_PLAYERS)
            endloop
            set key = null
        endif
       
        // Run this trigger again, until all keys have been registered
        call TriggerEvaluate(GetTriggeringTrigger())
    endfunction
   
    private function SetupGUIKeys takes nothing returns nothing
        call PauseTimer(GetExpiredTimer())
        call DestroyTimer(GetExpiredTimer())
       
        // "Lightweight" keys
        set udg_GUIKEY_BACKSPACE                      = GetHandleId(ConvertOsKeyType($08))
        set udg_GUIKEY_TAB                            = GetHandleId(ConvertOsKeyType($09))
        set udg_GUIKEY_CLEAR                          = GetHandleId(ConvertOsKeyType($0C))
        set udg_GUIKEY_RETURN                         = GetHandleId(ConvertOsKeyType($0D))
        set udg_GUIKEY_SHIFT                          = GetHandleId(ConvertOsKeyType($10))
        set udg_GUIKEY_CONTROL                        = GetHandleId(ConvertOsKeyType($11))
        set udg_GUIKEY_ALT                            = GetHandleId(ConvertOsKeyType($12))
        set udg_GUIKEY_PAUSE                          = GetHandleId(ConvertOsKeyType($13))
        set udg_GUIKEY_CAPSLOCK                       = GetHandleId(ConvertOsKeyType($14))
        set udg_GUIKEY_ESCAPE                         = GetHandleId(ConvertOsKeyType($1B))
        set udg_GUIKEY_SPACE                          = GetHandleId(ConvertOsKeyType($20))
        set udg_GUIKEY_PAGEUP                         = GetHandleId(ConvertOsKeyType($21))
        set udg_GUIKEY_PAGEDOWN                       = GetHandleId(ConvertOsKeyType($22))
        set udg_GUIKEY_END                            = GetHandleId(ConvertOsKeyType($23))
        set udg_GUIKEY_HOME                           = GetHandleId(ConvertOsKeyType($24))
        set udg_GUIKEY_LEFT                           = GetHandleId(ConvertOsKeyType($25))
        set udg_GUIKEY_UP                             = GetHandleId(ConvertOsKeyType($26))
        set udg_GUIKEY_RIGHT                          = GetHandleId(ConvertOsKeyType($27))
        set udg_GUIKEY_DOWN                           = GetHandleId(ConvertOsKeyType($28))
        set udg_GUIKEY_SELECT                         = GetHandleId(ConvertOsKeyType($29))
        set udg_GUIKEY_PRINT                          = GetHandleId(ConvertOsKeyType($2A))
        set udg_GUIKEY_EXECUTE                        = GetHandleId(ConvertOsKeyType($2B))
        set udg_GUIKEY_PRINTSCREEN                    = GetHandleId(ConvertOsKeyType($2C))
        set udg_GUIKEY_INSERT                         = GetHandleId(ConvertOsKeyType($2D))
        set udg_GUIKEY_DELETE                         = GetHandleId(ConvertOsKeyType($2E))
        set udg_GUIKEY_HELP                           = GetHandleId(ConvertOsKeyType($2F))
        set udg_GUIKEY_0                              = GetHandleId(ConvertOsKeyType($30))
        set udg_GUIKEY_1                              = GetHandleId(ConvertOsKeyType($31))
        set udg_GUIKEY_2                              = GetHandleId(ConvertOsKeyType($32))
        set udg_GUIKEY_3                              = GetHandleId(ConvertOsKeyType($33))
        set udg_GUIKEY_4                              = GetHandleId(ConvertOsKeyType($34))
        set udg_GUIKEY_5                              = GetHandleId(ConvertOsKeyType($35))
        set udg_GUIKEY_6                              = GetHandleId(ConvertOsKeyType($36))
        set udg_GUIKEY_7                              = GetHandleId(ConvertOsKeyType($37))
        set udg_GUIKEY_8                              = GetHandleId(ConvertOsKeyType($38))
        set udg_GUIKEY_9                              = GetHandleId(ConvertOsKeyType($39))
        set udg_GUIKEY_A                              = GetHandleId(ConvertOsKeyType($41))
        set udg_GUIKEY_B                              = GetHandleId(ConvertOsKeyType($42))
        set udg_GUIKEY_C                              = GetHandleId(ConvertOsKeyType($43))
        set udg_GUIKEY_D                              = GetHandleId(ConvertOsKeyType($44))
        set udg_GUIKEY_E                              = GetHandleId(ConvertOsKeyType($45))
        set udg_GUIKEY_F                              = GetHandleId(ConvertOsKeyType($46))
        set udg_GUIKEY_G                              = GetHandleId(ConvertOsKeyType($47))
        set udg_GUIKEY_H                              = GetHandleId(ConvertOsKeyType($48))
        set udg_GUIKEY_I                              = GetHandleId(ConvertOsKeyType($49))
        set udg_GUIKEY_J                              = GetHandleId(ConvertOsKeyType($4A))
        set udg_GUIKEY_K                              = GetHandleId(ConvertOsKeyType($4B))
        set udg_GUIKEY_L                              = GetHandleId(ConvertOsKeyType($4C))
        set udg_GUIKEY_M                              = GetHandleId(ConvertOsKeyType($4D))
        set udg_GUIKEY_N                              = GetHandleId(ConvertOsKeyType($4E))
        set udg_GUIKEY_O                              = GetHandleId(ConvertOsKeyType($4F))
        set udg_GUIKEY_P                              = GetHandleId(ConvertOsKeyType($50))
        set udg_GUIKEY_Q                              = GetHandleId(ConvertOsKeyType($51))
        set udg_GUIKEY_R                              = GetHandleId(ConvertOsKeyType($52))
        set udg_GUIKEY_S                              = GetHandleId(ConvertOsKeyType($53))
        set udg_GUIKEY_T                              = GetHandleId(ConvertOsKeyType($54))
        set udg_GUIKEY_U                              = GetHandleId(ConvertOsKeyType($55))
        set udg_GUIKEY_V                              = GetHandleId(ConvertOsKeyType($56))
        set udg_GUIKEY_W                              = GetHandleId(ConvertOsKeyType($57))
        set udg_GUIKEY_X                              = GetHandleId(ConvertOsKeyType($58))
        set udg_GUIKEY_Y                              = GetHandleId(ConvertOsKeyType($59))
        set udg_GUIKEY_Z                              = GetHandleId(ConvertOsKeyType($5A))
        set udg_GUIKEY_LMETA                          = GetHandleId(ConvertOsKeyType($5B))
        set udg_GUIKEY_RMETA                          = GetHandleId(ConvertOsKeyType($5C))
        set udg_GUIKEY_APPS                           = GetHandleId(ConvertOsKeyType($5D))
        set udg_GUIKEY_SLEEP                          = GetHandleId(ConvertOsKeyType($5F))
        set udg_GUIKEY_NUMPAD0                        = GetHandleId(ConvertOsKeyType($60))
        set udg_GUIKEY_NUMPAD1                        = GetHandleId(ConvertOsKeyType($61))
        set udg_GUIKEY_NUMPAD2                        = GetHandleId(ConvertOsKeyType($62))
        set udg_GUIKEY_NUMPAD3                        = GetHandleId(ConvertOsKeyType($63))
        set udg_GUIKEY_NUMPAD4                        = GetHandleId(ConvertOsKeyType($64))
        set udg_GUIKEY_NUMPAD5                        = GetHandleId(ConvertOsKeyType($65))
        set udg_GUIKEY_NUMPAD6                        = GetHandleId(ConvertOsKeyType($66))
        set udg_GUIKEY_NUMPAD7                        = GetHandleId(ConvertOsKeyType($67))
        set udg_GUIKEY_NUMPAD8                        = GetHandleId(ConvertOsKeyType($68))
        set udg_GUIKEY_NUMPAD9                        = GetHandleId(ConvertOsKeyType($69))
        set udg_GUIKEY_MULTIPLY                       = GetHandleId(ConvertOsKeyType($6A))
        set udg_GUIKEY_ADD                            = GetHandleId(ConvertOsKeyType($6B))
        set udg_GUIKEY_SEPARATOR                      = GetHandleId(ConvertOsKeyType($6C))
        set udg_GUIKEY_SUBTRACT                       = GetHandleId(ConvertOsKeyType($6D))
        set udg_GUIKEY_DECIMAL                        = GetHandleId(ConvertOsKeyType($6E))
        set udg_GUIKEY_DIVIDE                         = GetHandleId(ConvertOsKeyType($6F))
        set udg_GUIKEY_F1                             = GetHandleId(ConvertOsKeyType($70))
        set udg_GUIKEY_F2                             = GetHandleId(ConvertOsKeyType($71))
        set udg_GUIKEY_F3                             = GetHandleId(ConvertOsKeyType($72))
        set udg_GUIKEY_F4                             = GetHandleId(ConvertOsKeyType($73))
        set udg_GUIKEY_F5                             = GetHandleId(ConvertOsKeyType($74))
        set udg_GUIKEY_F6                             = GetHandleId(ConvertOsKeyType($75))
        set udg_GUIKEY_F7                             = GetHandleId(ConvertOsKeyType($76))
        set udg_GUIKEY_F8                             = GetHandleId(ConvertOsKeyType($77))
        set udg_GUIKEY_F9                             = GetHandleId(ConvertOsKeyType($78))
        set udg_GUIKEY_F10                            = GetHandleId(ConvertOsKeyType($79))
        set udg_GUIKEY_F11                            = GetHandleId(ConvertOsKeyType($7A))
        set udg_GUIKEY_F12                            = GetHandleId(ConvertOsKeyType($7B))
        set udg_GUIKEY_F13                            = GetHandleId(ConvertOsKeyType($7C))
        set udg_GUIKEY_F14                            = GetHandleId(ConvertOsKeyType($7D))
        set udg_GUIKEY_F15                            = GetHandleId(ConvertOsKeyType($7E))
        set udg_GUIKEY_F16                            = GetHandleId(ConvertOsKeyType($7F))
        set udg_GUIKEY_F17                            = GetHandleId(ConvertOsKeyType($80))
        set udg_GUIKEY_F18                            = GetHandleId(ConvertOsKeyType($81))
        set udg_GUIKEY_F19                            = GetHandleId(ConvertOsKeyType($82))
        set udg_GUIKEY_F20                            = GetHandleId(ConvertOsKeyType($83))
        set udg_GUIKEY_F21                            = GetHandleId(ConvertOsKeyType($84))
        set udg_GUIKEY_F22                            = GetHandleId(ConvertOsKeyType($85))
        set udg_GUIKEY_F23                            = GetHandleId(ConvertOsKeyType($86))
        set udg_GUIKEY_F24                            = GetHandleId(ConvertOsKeyType($87))
        set udg_GUIKEY_NUMLOCK                        = GetHandleId(ConvertOsKeyType($90))
        set udg_GUIKEY_SCROLLLOCK                     = GetHandleId(ConvertOsKeyType($91))
        set udg_GUIKEY_LSHIFT                         = GetHandleId(ConvertOsKeyType($A0))
        set udg_GUIKEY_RSHIFT                         = GetHandleId(ConvertOsKeyType($A1))
        set udg_GUIKEY_LCONTROL                       = GetHandleId(ConvertOsKeyType($A2))
        set udg_GUIKEY_RCONTROL                       = GetHandleId(ConvertOsKeyType($A3))
        set udg_GUIKEY_LALT                           = GetHandleId(ConvertOsKeyType($A4))
        set udg_GUIKEY_RALT                           = GetHandleId(ConvertOsKeyType($A5))
        set udg_GUIKEY_VOLUME_MUTE                    = GetHandleId(ConvertOsKeyType($AD))
        set udg_GUIKEY_VOLUME_DOWN                    = GetHandleId(ConvertOsKeyType($AE))
        set udg_GUIKEY_VOLUME_UP                      = GetHandleId(ConvertOsKeyType($AF))
        set udg_GUIKEY_MEDIA_NEXT_TRACK               = GetHandleId(ConvertOsKeyType($B0))
        set udg_GUIKEY_MEDIA_PREV_TRACK               = GetHandleId(ConvertOsKeyType($B1))
        set udg_GUIKEY_MEDIA_STOP                     = GetHandleId(ConvertOsKeyType($B2))
        set udg_GUIKEY_MEDIA_PLAY_PAUSE               = GetHandleId(ConvertOsKeyType($B3))
        set udg_GUIKEY_OEM_1                          = GetHandleId(ConvertOsKeyType($BA))
        set udg_GUIKEY_OEM_PLUS                       = GetHandleId(ConvertOsKeyType($BB))
        set udg_GUIKEY_OEM_COMMA                      = GetHandleId(ConvertOsKeyType($BC))
        set udg_GUIKEY_OEM_MINUS                      = GetHandleId(ConvertOsKeyType($BD))
        set udg_GUIKEY_OEM_PERIOD                     = GetHandleId(ConvertOsKeyType($BE))
        set udg_GUIKEY_OEM_2                          = GetHandleId(ConvertOsKeyType($BF))
        set udg_GUIKEY_OEM_3                          = GetHandleId(ConvertOsKeyType($C0))
        set udg_GUIKEY_OEM_4                          = GetHandleId(ConvertOsKeyType($DB))
        set udg_GUIKEY_OEM_5                          = GetHandleId(ConvertOsKeyType($DC))
        set udg_GUIKEY_OEM_6                          = GetHandleId(ConvertOsKeyType($DD))
        set udg_GUIKEY_OEM_7                          = GetHandleId(ConvertOsKeyType($DE))
        set udg_GUIKEY_OEM_8                          = GetHandleId(ConvertOsKeyType($DF))
        set udg_GUIKEY_OEM_AX                         = GetHandleId(ConvertOsKeyType($E1))
        set udg_GUIKEY_OEM_102                        = GetHandleId(ConvertOsKeyType($E2))
       
        // Non "Lightweight" keys
        static if not IS_LIGHTWEIGHT_VERSION then
            set udg_GUIKEY_KANA                           = GetHandleId(ConvertOsKeyType($15))
            set udg_GUIKEY_HANGUL                         = GetHandleId(ConvertOsKeyType($15))
            set udg_GUIKEY_JUNJA                          = GetHandleId(ConvertOsKeyType($17))
            set udg_GUIKEY_FINAL                          = GetHandleId(ConvertOsKeyType($18))
            set udg_GUIKEY_HANJA                          = GetHandleId(ConvertOsKeyType($19))
            set udg_GUIKEY_KANJI                          = GetHandleId(ConvertOsKeyType($19))
            set udg_GUIKEY_CONVERT                        = GetHandleId(ConvertOsKeyType($1C))
            set udg_GUIKEY_NONCONVERT                     = GetHandleId(ConvertOsKeyType($1D))
            set udg_GUIKEY_ACCEPT                         = GetHandleId(ConvertOsKeyType($1E))
            set udg_GUIKEY_MODECHANGE                     = GetHandleId(ConvertOsKeyType($1F))
            set udg_GUIKEY_OEM_NEC_EQUAL                  = GetHandleId(ConvertOsKeyType($92))
            set udg_GUIKEY_OEM_FJ_JISHO                   = GetHandleId(ConvertOsKeyType($92))
            set udg_GUIKEY_OEM_FJ_MASSHOU                 = GetHandleId(ConvertOsKeyType($93))
            set udg_GUIKEY_OEM_FJ_TOUROKU                 = GetHandleId(ConvertOsKeyType($94))
            set udg_GUIKEY_OEM_FJ_LOYA                    = GetHandleId(ConvertOsKeyType($95))
            set udg_GUIKEY_OEM_FJ_ROYA                    = GetHandleId(ConvertOsKeyType($96))
            set udg_GUIKEY_BROWSER_BACK                   = GetHandleId(ConvertOsKeyType($A6))
            set udg_GUIKEY_BROWSER_FORWARD                = GetHandleId(ConvertOsKeyType($A7))
            set udg_GUIKEY_BROWSER_REFRESH                = GetHandleId(ConvertOsKeyType($A8))
            set udg_GUIKEY_BROWSER_STOP                   = GetHandleId(ConvertOsKeyType($A9))
            set udg_GUIKEY_BROWSER_SEARCH                 = GetHandleId(ConvertOsKeyType($AA))
            set udg_GUIKEY_BROWSER_FAVORITES              = GetHandleId(ConvertOsKeyType($AB))
            set udg_GUIKEY_BROWSER_HOME                   = GetHandleId(ConvertOsKeyType($AC))
            set udg_GUIKEY_LAUNCH_MAIL                    = GetHandleId(ConvertOsKeyType($B4))
            set udg_GUIKEY_LAUNCH_MEDIA_SELECT            = GetHandleId(ConvertOsKeyType($B5))
            set udg_GUIKEY_LAUNCH_APP1                    = GetHandleId(ConvertOsKeyType($B6))
            set udg_GUIKEY_LAUNCH_APP2                    = GetHandleId(ConvertOsKeyType($B7))
            set udg_GUIKEY_ICO_HELP                       = GetHandleId(ConvertOsKeyType($E3))
            set udg_GUIKEY_ICO_00                         = GetHandleId(ConvertOsKeyType($E4))
            set udg_GUIKEY_PROCESSKEY                     = GetHandleId(ConvertOsKeyType($E5))
            set udg_GUIKEY_ICO_CLEAR                      = GetHandleId(ConvertOsKeyType($E6))
            set udg_GUIKEY_PACKET                         = GetHandleId(ConvertOsKeyType($E7))
            set udg_GUIKEY_OEM_RESET                      = GetHandleId(ConvertOsKeyType($E9))
            set udg_GUIKEY_OEM_JUMP                       = GetHandleId(ConvertOsKeyType($EA))
            set udg_GUIKEY_OEM_PA1                        = GetHandleId(ConvertOsKeyType($EB))
            set udg_GUIKEY_OEM_PA2                        = GetHandleId(ConvertOsKeyType($EC))
            set udg_GUIKEY_OEM_PA3                        = GetHandleId(ConvertOsKeyType($ED))
            set udg_GUIKEY_OEM_WSCTRL                     = GetHandleId(ConvertOsKeyType($EE))
            set udg_GUIKEY_OEM_CUSEL                      = GetHandleId(ConvertOsKeyType($EF))
            set udg_GUIKEY_OEM_ATTN                       = GetHandleId(ConvertOsKeyType($F0))
            set udg_GUIKEY_OEM_FINISH                     = GetHandleId(ConvertOsKeyType($F1))
            set udg_GUIKEY_OEM_COPY                       = GetHandleId(ConvertOsKeyType($F2))
            set udg_GUIKEY_OEM_AUTO                       = GetHandleId(ConvertOsKeyType($F3))
            set udg_GUIKEY_OEM_ENLW                       = GetHandleId(ConvertOsKeyType($F4))
            set udg_GUIKEY_OEM_BACKTAB                    = GetHandleId(ConvertOsKeyType($F5))
            set udg_GUIKEY_ATTN                           = GetHandleId(ConvertOsKeyType($F6))
            set udg_GUIKEY_CRSEL                          = GetHandleId(ConvertOsKeyType($F7))
            set udg_GUIKEY_EXSEL                          = GetHandleId(ConvertOsKeyType($F8))
            set udg_GUIKEY_EREOF                          = GetHandleId(ConvertOsKeyType($F9))
            set udg_GUIKEY_PLAY                           = GetHandleId(ConvertOsKeyType($FA))
            set udg_GUIKEY_ZOOM                           = GetHandleId(ConvertOsKeyType($FB))
            set udg_GUIKEY_NONAME                         = GetHandleId(ConvertOsKeyType($FC))
            set udg_GUIKEY_PA1                            = GetHandleId(ConvertOsKeyType($FD))
            set udg_GUIKEY_OEM_CLEAR                      = GetHandleId(ConvertOsKeyType($FE))
        endif
       
        // "Lightweight" Key names to string
        set  udg_GUIKEY_NAME[udg_GUIKEY_BACKSPACE]    = "BACKSPACE"
        set  udg_GUIKEY_NAME[udg_GUIKEY_TAB]          = "TAB"
        set  udg_GUIKEY_NAME[udg_GUIKEY_CLEAR]        = "CLEAR"
        set  udg_GUIKEY_NAME[udg_GUIKEY_RETURN]       = "RETURN"
        set  udg_GUIKEY_NAME[udg_GUIKEY_SHIFT]        = "SHIFT"
        set  udg_GUIKEY_NAME[udg_GUIKEY_CONTROL]      = "CONTROL"
        set  udg_GUIKEY_NAME[udg_GUIKEY_ALT]          = "ALT"
        set  udg_GUIKEY_NAME[udg_GUIKEY_PAUSE]        = "PAUSE"
        set  udg_GUIKEY_NAME[udg_GUIKEY_CAPSLOCK]     = "CAPSLOCK"
        set  udg_GUIKEY_NAME[udg_GUIKEY_ESCAPE]       = "ESCAPE"
        set  udg_GUIKEY_NAME[udg_GUIKEY_SPACE]        = "SPACE"
        set  udg_GUIKEY_NAME[udg_GUIKEY_PAGEUP]       = "PAGEUP"
        set  udg_GUIKEY_NAME[udg_GUIKEY_PAGEDOWN]     = "PAGEDOWN"
        set  udg_GUIKEY_NAME[udg_GUIKEY_END]          = "END"
        set  udg_GUIKEY_NAME[udg_GUIKEY_HOME]         = "HOME"
        set  udg_GUIKEY_NAME[udg_GUIKEY_LEFT]         = "LEFT"
        set  udg_GUIKEY_NAME[udg_GUIKEY_UP]           = "UP"
        set  udg_GUIKEY_NAME[udg_GUIKEY_RIGHT]        = "RIGHT"
        set  udg_GUIKEY_NAME[udg_GUIKEY_DOWN]         = "DOWN"
        set  udg_GUIKEY_NAME[udg_GUIKEY_SELECT]       = "SELECT"
        set  udg_GUIKEY_NAME[udg_GUIKEY_PRINT]        = "PRINT"
        set  udg_GUIKEY_NAME[udg_GUIKEY_EXECUTE]      = "EXECUTE"
        set  udg_GUIKEY_NAME[udg_GUIKEY_PRINTSCREEN]  = "PRINTSCREEN"
        set  udg_GUIKEY_NAME[udg_GUIKEY_INSERT]       = "INSERT"
        set  udg_GUIKEY_NAME[udg_GUIKEY_DELETE]       = "DELETE"
        set  udg_GUIKEY_NAME[udg_GUIKEY_HELP]         = "HELP"
        set  udg_GUIKEY_NAME[udg_GUIKEY_0]            = "0"
        set  udg_GUIKEY_NAME[udg_GUIKEY_1]            = "1"
        set  udg_GUIKEY_NAME[udg_GUIKEY_2]            = "2"
        set  udg_GUIKEY_NAME[udg_GUIKEY_3]            = "3"
        set  udg_GUIKEY_NAME[udg_GUIKEY_4]            = "4"
        set  udg_GUIKEY_NAME[udg_GUIKEY_5]            = "5"
        set  udg_GUIKEY_NAME[udg_GUIKEY_6]            = "6"
        set  udg_GUIKEY_NAME[udg_GUIKEY_7]            = "7"
        set  udg_GUIKEY_NAME[udg_GUIKEY_8]            = "8"
        set  udg_GUIKEY_NAME[udg_GUIKEY_9]            = "9"
        set  udg_GUIKEY_NAME[udg_GUIKEY_A]            = "A"
        set  udg_GUIKEY_NAME[udg_GUIKEY_B]            = "B"
        set  udg_GUIKEY_NAME[udg_GUIKEY_C]            = "C"
        set  udg_GUIKEY_NAME[udg_GUIKEY_D]            = "D"
        set  udg_GUIKEY_NAME[udg_GUIKEY_E]            = "E"
        set  udg_GUIKEY_NAME[udg_GUIKEY_F]            = "F"
        set  udg_GUIKEY_NAME[udg_GUIKEY_G]            = "G"
        set  udg_GUIKEY_NAME[udg_GUIKEY_H]            = "H"
        set  udg_GUIKEY_NAME[udg_GUIKEY_I]            = "I"
        set  udg_GUIKEY_NAME[udg_GUIKEY_J]            = "J"
        set  udg_GUIKEY_NAME[udg_GUIKEY_K]            = "K"
        set  udg_GUIKEY_NAME[udg_GUIKEY_L]            = "L"
        set  udg_GUIKEY_NAME[udg_GUIKEY_M]            = "M"
        set  udg_GUIKEY_NAME[udg_GUIKEY_N]            = "N"
        set  udg_GUIKEY_NAME[udg_GUIKEY_O]            = "O"
        set  udg_GUIKEY_NAME[udg_GUIKEY_P]            = "P"
        set  udg_GUIKEY_NAME[udg_GUIKEY_Q]            = "Q"
        set  udg_GUIKEY_NAME[udg_GUIKEY_R]            = "R"
        set  udg_GUIKEY_NAME[udg_GUIKEY_S]            = "S"
        set  udg_GUIKEY_NAME[udg_GUIKEY_T]            = "T"
        set  udg_GUIKEY_NAME[udg_GUIKEY_U]            = "U"
        set  udg_GUIKEY_NAME[udg_GUIKEY_V]            = "V"
        set  udg_GUIKEY_NAME[udg_GUIKEY_W]            = "W"
        set  udg_GUIKEY_NAME[udg_GUIKEY_X]            = "X"
        set  udg_GUIKEY_NAME[udg_GUIKEY_Y]            = "Y"
        set  udg_GUIKEY_NAME[udg_GUIKEY_Z]            = "Z"
        set  udg_GUIKEY_NAME[udg_GUIKEY_LMETA]        = "LMETA"
        set  udg_GUIKEY_NAME[udg_GUIKEY_RMETA]        = "RMETA"
        set  udg_GUIKEY_NAME[udg_GUIKEY_APPS]         = "APPS"
        set  udg_GUIKEY_NAME[udg_GUIKEY_SLEEP]        = "SLEEP"
        set  udg_GUIKEY_NAME[udg_GUIKEY_NUMPAD0]      = "NUMPAD0"
        set  udg_GUIKEY_NAME[udg_GUIKEY_NUMPAD1]      = "NUMPAD1"
        set  udg_GUIKEY_NAME[udg_GUIKEY_NUMPAD2]      = "NUMPAD2"
        set  udg_GUIKEY_NAME[udg_GUIKEY_NUMPAD3]      = "NUMPAD3"
        set  udg_GUIKEY_NAME[udg_GUIKEY_NUMPAD4]      = "NUMPAD4"
        set  udg_GUIKEY_NAME[udg_GUIKEY_NUMPAD5]      = "NUMPAD5"
        set  udg_GUIKEY_NAME[udg_GUIKEY_NUMPAD6]      = "NUMPAD6"
        set  udg_GUIKEY_NAME[udg_GUIKEY_NUMPAD7]      = "NUMPAD7"
        set  udg_GUIKEY_NAME[udg_GUIKEY_NUMPAD8]      = "NUMPAD8"
        set  udg_GUIKEY_NAME[udg_GUIKEY_NUMPAD9]      = "NUMPAD9"
        set  udg_GUIKEY_NAME[udg_GUIKEY_MULTIPLY]     = "MULTIPLY"
        set  udg_GUIKEY_NAME[udg_GUIKEY_ADD]          = "ADD"
        set  udg_GUIKEY_NAME[udg_GUIKEY_SEPARATOR]    = "SEPARATOR"
        set  udg_GUIKEY_NAME[udg_GUIKEY_SUBTRACT]     = "SUBTRACT"
        set  udg_GUIKEY_NAME[udg_GUIKEY_DECIMAL]      = "DECIMAL"
        set  udg_GUIKEY_NAME[udg_GUIKEY_DIVIDE]       = "DIVIDE"
        set  udg_GUIKEY_NAME[udg_GUIKEY_F1]           = "F1"
        set  udg_GUIKEY_NAME[udg_GUIKEY_F2]           = "F2"
        set  udg_GUIKEY_NAME[udg_GUIKEY_F3]           = "F3"
        set  udg_GUIKEY_NAME[udg_GUIKEY_F4]           = "F4"
        set  udg_GUIKEY_NAME[udg_GUIKEY_F5]           = "F5"
        set  udg_GUIKEY_NAME[udg_GUIKEY_F6]           = "F6"
        set  udg_GUIKEY_NAME[udg_GUIKEY_F7]           = "F7"
        set  udg_GUIKEY_NAME[udg_GUIKEY_F8]           = "F8"
        set  udg_GUIKEY_NAME[udg_GUIKEY_F9]           = "F9"
        set  udg_GUIKEY_NAME[udg_GUIKEY_F10]          = "F10"
        set  udg_GUIKEY_NAME[udg_GUIKEY_F11]          = "F11"
        set  udg_GUIKEY_NAME[udg_GUIKEY_F12]          = "F12"
        set  udg_GUIKEY_NAME[udg_GUIKEY_F13]          = "F13"
        set  udg_GUIKEY_NAME[udg_GUIKEY_F14]          = "F14"
        set  udg_GUIKEY_NAME[udg_GUIKEY_F15]          = "F15"
        set  udg_GUIKEY_NAME[udg_GUIKEY_F16]          = "F16"
        set  udg_GUIKEY_NAME[udg_GUIKEY_F17]          = "F17"
        set  udg_GUIKEY_NAME[udg_GUIKEY_F18]          = "F18"
        set  udg_GUIKEY_NAME[udg_GUIKEY_F19]          = "F19"
        set  udg_GUIKEY_NAME[udg_GUIKEY_F20]          = "F20"
        set  udg_GUIKEY_NAME[udg_GUIKEY_F21]          = "F21"
        set  udg_GUIKEY_NAME[udg_GUIKEY_F22]          = "F22"
        set  udg_GUIKEY_NAME[udg_GUIKEY_F23]          = "F23"
        set  udg_GUIKEY_NAME[udg_GUIKEY_F24]          = "F24"
        set  udg_GUIKEY_NAME[udg_GUIKEY_NUMLOCK]      = "NUMLOCK"
        set  udg_GUIKEY_NAME[udg_GUIKEY_SCROLLLOCK]   = "SCROLLLOCK"
        set  udg_GUIKEY_NAME[udg_GUIKEY_LSHIFT]       = "LSHIFT"
        set  udg_GUIKEY_NAME[udg_GUIKEY_RSHIFT]       = "RSHIFT"
        set  udg_GUIKEY_NAME[udg_GUIKEY_LCONTROL]     = "LCONTROL"
        set  udg_GUIKEY_NAME[udg_GUIKEY_RCONTROL]     = "RCONTROL"
        set  udg_GUIKEY_NAME[udg_GUIKEY_LALT]         = "LALT"
        set  udg_GUIKEY_NAME[udg_GUIKEY_RALT]         = "RALT"
        set  udg_GUIKEY_NAME[udg_GUIKEY_VOLUME_MUTE]  = "VOLUME_MUTE"
        set  udg_GUIKEY_NAME[udg_GUIKEY_VOLUME_DOWN]  = "VOLUME_DOWN"
        set  udg_GUIKEY_NAME[udg_GUIKEY_VOLUME_UP]    = "VOLUME_UP"
        set  udg_GUIKEY_NAME[udg_GUIKEY_MEDIA_NEXT_TRACK] = "MEDIA_NEXT_TRACK"
        set  udg_GUIKEY_NAME[udg_GUIKEY_MEDIA_PREV_TRACK] = "MEDIA_PREV_TRACK"
        set  udg_GUIKEY_NAME[udg_GUIKEY_MEDIA_STOP]   = "MEDIA_STOP"
        set  udg_GUIKEY_NAME[udg_GUIKEY_MEDIA_PLAY_PAUSE] = "MEDIA_PLAY_PAUSE"
        set  udg_GUIKEY_NAME[udg_GUIKEY_OEM_1]        = "OEM_1"
        set  udg_GUIKEY_NAME[udg_GUIKEY_OEM_PLUS]     = "OEM_PLUS"
        set  udg_GUIKEY_NAME[udg_GUIKEY_OEM_COMMA]    = "OEM_COMMA"
        set  udg_GUIKEY_NAME[udg_GUIKEY_OEM_MINUS]    = "OEM_MINUS"
        set  udg_GUIKEY_NAME[udg_GUIKEY_OEM_PERIOD]   = "OEM_PERIOD"
        set  udg_GUIKEY_NAME[udg_GUIKEY_OEM_2]        = "OEM_2"
        set  udg_GUIKEY_NAME[udg_GUIKEY_OEM_3]        = "OEM_3"
        set  udg_GUIKEY_NAME[udg_GUIKEY_OEM_4]        = "OEM_4"
        set  udg_GUIKEY_NAME[udg_GUIKEY_OEM_5]        = "OEM_5"
        set  udg_GUIKEY_NAME[udg_GUIKEY_OEM_6]        = "OEM_6"
        set  udg_GUIKEY_NAME[udg_GUIKEY_OEM_7]        = "OEM_7"
        set  udg_GUIKEY_NAME[udg_GUIKEY_OEM_8]        = "OEM_8"
        set  udg_GUIKEY_NAME[udg_GUIKEY_OEM_AX]       = "OEM_AX"
        set  udg_GUIKEY_NAME[udg_GUIKEY_OEM_102]      = "OEM_102"
       
        // Non "Lightweight" Key names to string
        static if not IS_LIGHTWEIGHT_VERSION then
            set  udg_GUIKEY_NAME[udg_GUIKEY_KANA]         = "KANA"
            set  udg_GUIKEY_NAME[udg_GUIKEY_HANGUL]       = "HANGUL"
            set  udg_GUIKEY_NAME[udg_GUIKEY_JUNJA]        = "JUNJA"
            set  udg_GUIKEY_NAME[udg_GUIKEY_FINAL]        = "FINAL"
            set  udg_GUIKEY_NAME[udg_GUIKEY_HANJA]        = "HANJA"
            set  udg_GUIKEY_NAME[udg_GUIKEY_KANJI]        = "KANJI"
            set  udg_GUIKEY_NAME[udg_GUIKEY_CONVERT]      = "CONVERT"
            set  udg_GUIKEY_NAME[udg_GUIKEY_NONCONVERT]   = "NONCONVERT"
            set  udg_GUIKEY_NAME[udg_GUIKEY_ACCEPT]       = "ACCEPT"
            set  udg_GUIKEY_NAME[udg_GUIKEY_MODECHANGE]   = "MODECHANGE"
            set  udg_GUIKEY_NAME[udg_GUIKEY_OEM_NEC_EQUAL]= "OEM_NEC_EQUAL"
            set  udg_GUIKEY_NAME[udg_GUIKEY_OEM_FJ_JISHO] = "OEM_FJ_JISHO"
            set  udg_GUIKEY_NAME[udg_GUIKEY_OEM_FJ_MASSHOU] = "OEM_FJ_MASSHOU"
            set  udg_GUIKEY_NAME[udg_GUIKEY_OEM_FJ_TOUROKU] = "OEM_FJ_TOUROKU"
            set  udg_GUIKEY_NAME[udg_GUIKEY_OEM_FJ_LOYA]  = "OEM_FJ_LOYA"
            set  udg_GUIKEY_NAME[udg_GUIKEY_OEM_FJ_ROYA]  = "OEM_FJ_ROYA"
            set  udg_GUIKEY_NAME[udg_GUIKEY_BROWSER_BACK] = "BROWSER_BACK"
            set  udg_GUIKEY_NAME[udg_GUIKEY_BROWSER_FORWARD] = "BROWSER_FORWARD"
            set  udg_GUIKEY_NAME[udg_GUIKEY_BROWSER_REFRESH] = "BROWSER_REFRESH"
            set  udg_GUIKEY_NAME[udg_GUIKEY_BROWSER_STOP] = "BROWSER_STOP"
            set  udg_GUIKEY_NAME[udg_GUIKEY_BROWSER_SEARCH] = "BROWSER_SEARCH"
            set  udg_GUIKEY_NAME[udg_GUIKEY_BROWSER_FAVORITES] = "BROWSER_FAVORITES"
            set  udg_GUIKEY_NAME[udg_GUIKEY_BROWSER_HOME] = "BROWSER_HOME"
            set  udg_GUIKEY_NAME[udg_GUIKEY_LAUNCH_MAIL]  = "LAUNCH_MAIL"
            set  udg_GUIKEY_NAME[udg_GUIKEY_LAUNCH_MEDIA_SELECT] = "LAUNCH_MEDIA_SELECT"
            set  udg_GUIKEY_NAME[udg_GUIKEY_LAUNCH_APP1]  = "LAUNCH_APP1"
            set  udg_GUIKEY_NAME[udg_GUIKEY_LAUNCH_APP2]  = "LAUNCH_APP2"
            set  udg_GUIKEY_NAME[udg_GUIKEY_ICO_HELP]     = "ICO_HELP"
            set  udg_GUIKEY_NAME[udg_GUIKEY_ICO_00]       = "ICO_00"
            set  udg_GUIKEY_NAME[udg_GUIKEY_PROCESSKEY]   = "PROCESSKEY"
            set  udg_GUIKEY_NAME[udg_GUIKEY_ICO_CLEAR]    = "ICO_CLEAR"
            set  udg_GUIKEY_NAME[udg_GUIKEY_PACKET]       = "PACKET"
            set  udg_GUIKEY_NAME[udg_GUIKEY_OEM_RESET]    = "OEM_RESET"
            set  udg_GUIKEY_NAME[udg_GUIKEY_OEM_JUMP]     = "OEM_JUMP"
            set  udg_GUIKEY_NAME[udg_GUIKEY_OEM_PA1]      = "OEM_PA1"
            set  udg_GUIKEY_NAME[udg_GUIKEY_OEM_PA2]      = "OEM_PA2"
            set  udg_GUIKEY_NAME[udg_GUIKEY_OEM_PA3]      = "OEM_PA3"
            set  udg_GUIKEY_NAME[udg_GUIKEY_OEM_WSCTRL]   = "OEM_WSCTRL"
            set  udg_GUIKEY_NAME[udg_GUIKEY_OEM_CUSEL]    = "OEM_CUSEL"
            set  udg_GUIKEY_NAME[udg_GUIKEY_OEM_ATTN]     = "OEM_ATTN"
            set  udg_GUIKEY_NAME[udg_GUIKEY_OEM_FINISH]   = "OEM_FINISH"
            set  udg_GUIKEY_NAME[udg_GUIKEY_OEM_COPY]     = "OEM_COPY"
            set  udg_GUIKEY_NAME[udg_GUIKEY_OEM_AUTO]     = "OEM_AUTO"
            set  udg_GUIKEY_NAME[udg_GUIKEY_OEM_ENLW]     = "OEM_ENLW"
            set  udg_GUIKEY_NAME[udg_GUIKEY_OEM_BACKTAB]  = "OEM_BACKTAB"
            set  udg_GUIKEY_NAME[udg_GUIKEY_ATTN]         = "ATTN"
            set  udg_GUIKEY_NAME[udg_GUIKEY_CRSEL]        = "CRSEL"
            set  udg_GUIKEY_NAME[udg_GUIKEY_EXSEL]        = "EXSEL"
            set  udg_GUIKEY_NAME[udg_GUIKEY_EREOF]        = "EREOF"
            set  udg_GUIKEY_NAME[udg_GUIKEY_PLAY]         = "PLAY"
            set  udg_GUIKEY_NAME[udg_GUIKEY_ZOOM]         = "ZOOM"
            set  udg_GUIKEY_NAME[udg_GUIKEY_NONAME]       = "NONAME"
            set  udg_GUIKEY_NAME[udg_GUIKEY_PA1]          = "PA1"
            set  udg_GUIKEY_NAME[udg_GUIKEY_OEM_CLEAR]    = "OEM_CLEAR"
        endif
    endfunction
   
    public function GUIKeyEventInit takes nothing returns nothing
        local trigger t
       
        // Create the trigger that handles oskey input
        set udg_GUIKeyEvent_System = CreateTrigger()
        call TriggerAddCondition(udg_GUIKeyEvent_System, Condition(function OnGUIKeyEvent))

        // Register oskey events for players
        // Run each key as a new thread to avoid op-limit (but shouldn't be an issue most likely anyway).
        // Results in ~100k operations for 24 players
        set currentKey = CONVERT_OS_KEY_TYPE_INDEX_START - 1
        set t = CreateTrigger()
        call TriggerAddCondition(t, Condition(function RegisterKey))
        call TriggerEvaluate(t)
        set t = null
       
        //Setup the GUI key variables after a short delay. If called at map init GetHandleId(ConvertOsKeyType(xx)) returns 0
        call TimerStart(CreateTimer(), .0, false, function SetupGUIKeys)
    endfunction
endlibrary
Contents

GUIKeyEvent 1.2a (Map)

GUIKeyEvent 1.2a Lightweight (Map)

Reviews
MyPad
Very interesting. Bridging the gap between GUI and vJASS is always an appreciated gesture for the users. The testmap plays out like a charm as well. There aren't many changes to be made here codewise and suggestions that have been made pertaining...
Level 19
Joined
Aug 16, 2007
Messages
871
JASS:
set playerIsActive[playerId] = (GetPlayerController(Player(playerId)) == MAP_CONTROL_USER and GetPlayerSlotState(Player(playerId)) == PLAYER_SLOT_STATE_PLAYING)

This is unsafe during initialization, it causes desyncs.
Thanks, I suspected so, but couldn't find any concrete answer.

I'll look for another approach. The downside to not have it at map init is due to the noticeable lag caused by the event creation.
 
Level 19
Joined
Aug 16, 2007
Messages
871
Updated to version 1.1a.

Changes:
  • The system is now initialized at RunInitializationTriggers in main (in order to not have GUIKeyEvent Settings overwritten by InitGlobals).
  • Removed desync prone GetPlayerController/GetPlayerSlotState at map init and instead added GUIKeyEvent_S_EnablePlayer to the GUIKeyEvent Settings trigger that allows the user to manually set players to use.
  • "GUIKeyEvent_S_BlockRepeat" setting set to true by default in the GUIKeyEvent Settings trigger.
  • Renamed the variable "_GUIKeyIsDown" to "_GUIKeyIsPressed".
  • Added a new boolean variable "_GUIKeyIsReleased", that can be used instead of "_GUIKeyIsPressed Equal to False"

I plan to release a "lightweight" version as well, which removes a lot of the keys I don't think most users will use.


2022-04-24 Edit:
Updated to version 1.2a.

Changes:
  • Added a "Lightweight" version.
    • This version only detect the more common keys and uses 54 less variables.
    • The map loading time is improved as well.
  • Added a new string array variable "GUIKEY_NAME" that can be used to get the name of the keys. Could be useful for debugging, etc.
  • Fixed an issue that caused the OSKEY_OEM_CLEAR key to not be registered.
The Lightweight version is a seperate map.
 
Last edited:

MyPad

Spell Reviewer
Level 23
Joined
May 9, 2014
Messages
1,711
Very interesting. Bridging the gap between GUI and vJASS is always an appreciated gesture for the users. The testmap plays out like a charm as well.

  • The LWKeyCheck function has an additional return statement just below the huge body of or-conditional statements. Perhaps this was supposed to be a placeholder?

    JASS:
    private function LWKeyCheck takes integer currentKey returns boolean        // Returns false if the key is not a lightweight key
        return not (currentKey == $15 or /*
            */ // huge body of conditions /*
            */ currentKey == $FE)
        return true
    endfunction

  • In the same function, I think it would be better if a boolean array variable would be used to hold the appropriate lightweight key indices (by setting the value at said indices to true), though it does come with a downside of having to initialize the array first. Still, since the LWKey values aren't expected to change, you may choose to implement the code changes.

    JASS:
    globals
        private boolean array isLWKey
    endglobals
    
    private function LWKeyInit takes nothing returns nothing
        set isLWKey[$15] = true
        // body
        set isLWKey[$FE] = true
    endfunction
    private function LWKeyCheck takes integer currentKey returns boolean
        return not isLWKey[currentKey]
    endfunction

There aren't many changes to be made here codewise and suggestions that have been made pertaining to the code are quite minor. Still, a 1.31 version of the same system would be nice, if feasibly compatible with the current Reforged version.

Status:

  • Approved
 
Top