Multi-key bind with modifier keys function?

Discuss anything ZDoom-related that doesn't fall into one of the other categories.

Multi-key bind with modifier keys function?

Postby Blackgrowl » Tue Aug 03, 2021 3:54 am

Hey there.

I was wondering if it's possible to make a "multi-key bind" in GZDoom using Windows' modifier keys (Control, Alt, Shift).
So, I have the whole Numpad set from 1 to 9 to spawn specific Doom monsters.
Now, I want to make it so Shift+Numpad from 1 to 9 also spawns different kinds of specific doom monsters.

Is it possible to do so? If so, what is the console command for such?
User avatar
Blackgrowl
I'm getting too old for everything but Doom
 
Joined: 06 Oct 2019
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: Multi-key bind with modifier keys function?

Postby Graf Zahl » Tue Aug 03, 2021 12:51 pm

No. To the input system the modifier keys are just normal keys that are actually all used by default.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Multi-key bind with modifier keys function?

Postby m8f » Wed Aug 04, 2021 8:16 am

You can kind of emulate this behavior with a cvar and a few aliases:
shift-key.pk3

CVARINFO:
Code: Select allExpand view
user bool shift_pressed = false;

KEYCONF:
Code: Select allExpand view
alias +shift_modifier "shift_pressed true"
alias -shift_modifier "shift_pressed false"

alias summon_zombie "summon zombieman"
alias summon_imp    "summon doomimp"
alias summon_zombie_or_imp "test $shift_pressed summon_zombie summon_imp"


How to use:
1. Bind Shift to +shift_modifier command (type bind shift +shift_modifier in console).
2. Bind any key to summon_zombie_or_imp.
3. Now pressing your key with shift summons a zombie, without shift it summons an imp.

Basically, you define a boolean cvar, and set shift to switch this cvar on and off. Then you test this cvar in an alias and select one of two different actions. See CCMDs for more info.

This solution has a couple of drawbacks:
1. You cannot use Shift for anything else.
2. You have to add new aliases to KEYCONF by hand.
You do not have the required permissions to view the files attached to this post.
User avatar
m8f
dreamer
 
 
 
Joined: 29 Dec 2017
Location: Siberia (UTC+7)
Discord: m8f#0629
Github ID: mmaulwurff
Operating System: Other Linux 64-bit

Re: Multi-key bind with modifier keys function?

Postby Blackgrowl » Wed Aug 04, 2021 10:43 am

Thanks, I'll try it when I can
I suppose if I want it to be alt instead, I simply change the "bind shift", to "bind alt", right?
User avatar
Blackgrowl
I'm getting too old for everything but Doom
 
Joined: 06 Oct 2019
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: Multi-key bind with modifier keys function?

Postby m8f » Wed Aug 04, 2021 10:47 am

Yes. You can also rename the cvar and commands to alt_... for clarity, but it will work either way.
User avatar
m8f
dreamer
 
 
 
Joined: 29 Dec 2017
Location: Siberia (UTC+7)
Discord: m8f#0629
Github ID: mmaulwurff
Operating System: Other Linux 64-bit


Return to General

Who is online

Users browsing this forum: No registered users and 3 guests