Hello,
I'm working on updating an app that allows users to set up and save
custom key binds for use in a game. The user can assign those keys by
clicking a button that makes a popup dialog showing buttons arranged
like a keyboard. A user would normally have to click on these virtual
keyboard keys to assign them, but I want to make it so the user can
hit the corresponding keys on their real keyboard to activate the same
virtual keyboard buttons.

Most keys will activate fine, but CTRL, ALT, SHIFT don't if I'm trying
to capture L or R, which I need to for key binds using the modifier
alone. Del won't work in my actual file (but works in a test code),
and F10 prevents me from using some of the other keys until I press it
again.

If modifier keys are used, I know how to get which ones (using
MODKEYSTATE), but if a user presses SHIFT+CTRL+E, how do I get the
"E"? Trying to use "iup.KeyCodeToName(c)" gives me an error.

Is there a simple way to make K_ANY case insensitive to letters so if
a user has caps lock on (for some reason), they can still activate the
same letter buttons in the dialog with their real keyboard?

Is there any way to distinguish the Num Lock key pad numbers from
regular numbers?

Is there any way to fix these things? Here is a sample Lua code
demonstrating some things I'm talking about:

require'iuplua'

local placeholder = iup.label{title = "Press Key"}

local dlg = iup.dialog{title = "a dialog", iup.vbox{placeholder},
size="QUARTERxQUARTER"}

function dlg:k_any(c)
--  local mks = iup.GetGlobal("MODKEYSTATE")
--  iup.Message("Mod Key State",tostring(mks)) --prints one or more
letters for modifiers: A,C,S,Y
    local name = iup.KeyCodeToName(c)
    iup.Message("Key",tostring(name)) --Error

    if c == iup.K_F10 then placeholder.title = "You pressed \"F10\"" end
    if c == iup.K_DEL then placeholder.title = "You pressed \"Del\""
end --works here, but not in original script I need it in
    if c == iup.K_a then placeholder.title = "You pressed \"a\"" end
--how can I make letters case insensitive?
    if c == iup.K_BS then placeholder.title = "You pressed \"Backspace\"" end
    if iup.isShiftXkey(c) then
        if c == iup.K_LSHIFT then placeholder.title = "You pressed
\"LShift\"" --doesn't work
        else placeholder.title = "You pressed \"Shift\" and "..c
--works but how do I convert the code number into a key name?
        end
    end
    iup.Refresh(dlg)
end

dlg:popup(iup.CENTER,iup.CENTER)

if (iup.MainLoopLevel()==0) then
    iup.MainLoop()
    dlg:destroy()
    iup.Close()
end


_______________________________________________
Iup-users mailing list
Iup-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/iup-users

Reply via email to