Page 1 of 1
How to bind Shift+C for example?
Posted: Mon May 30, 2016 2:30 pm
by Wonder
I see SDL support in the client but confused how to bind key modifiers + key.
Like CTRL + S, SHIFT + W, ALT + Z, etc.
May somebody explain please?
Or is it possible only by hard coding in sources?
I wanna bind dummy keys, zoom toggles, emotes, team switch, and so on via modifiers. Just all-in-one-hand like it works in another games.
Re: How to bind Shift+C for example?
Posted: Mon May 30, 2016 3:00 pm
by deen
Not supported.
Re: How to bind Shift+C for example?
Posted: Mon May 30, 2016 3:37 pm
by Wonder
May you give me a hint please. Which file do i need to modify to insert direct bindings like CTRL+SHIFT+D for debug?
If it impossible to do via console it must be possible to make it by source editing.
I'll do it similarly like it done with ALT+SHIFT+Q.
Or may be i could insert into key list words like "LALTQ" which will mean alt+q? Am i wrong?
How players do it without modifiers? Like "move right hand from mouse on the keyboard press grey minus for zoom out, then move hand to mouse, do a catch, then move right hand to the keyboard, press zoom in, then move right hand back to the mouse"?
Is it supposed to be like that anti-ergonomic gameplay?

Re: How to bind Shift+C for example?
Posted: Mon May 30, 2016 3:52 pm
by deen
The idea is that the keyboard is used as a big gamepad ingame, so modifier keys like ctrl or shift just act as a regular key without any special meaning. Check
https://github.com/ddnet/ddnet/blob/mas ... .cpp#L2730 for the implementation of ctrl-shift-q etc. You should be able to call
m_pConsole->ExecuteLine("foo bar");
there or call the functions you want directly.
Re: How to bind Shift+C for example?
Posted: Mon May 30, 2016 4:05 pm
by Wonder
Ok, i've got it.
Could you give a little example how to initialize Console command via this construction?
Is it correct?
Code: Select all
if(CtrlShiftKey(KEY_Z, LastZ))
m_pConsole->ExecuteLine("kill")
And for Ctrl+z i may use analogically:
Code: Select all
if(CtrlKey(KEY_Z, LastZ))
m_pConsole->ExecuteLine("kill")
Will these work?
I'm sorry i'm very new to programming. Just wanna do modifiers.

Re: How to bind Shift+C for example?
Posted: Mon May 30, 2016 4:10 pm
by deen
You will also need to add a line bool LastZ = false;
where the similar definitions are, a few lines before.
CtrlKey
is not implemented so you would have to implement it yourself, see how CtrlShiftKey is defined in client.cpp and client.h for inspiration.
Try compiling it, play around with it until you understand what's going on and how to get it working.
Re: How to bind Shift+C for example?
Posted: Mon May 30, 2016 4:35 pm
by Wonder
Godbless you, deen.
I added all right side of the keyboard into these lines.
Code: Select all
bool LastQ = false;
bool LastW = false;
bool LastE = false;
bool LastR = false;
bool LastA = false;
bool LastS = false;
bool LastD = false;
bool LastF = false;
bool LastZ = false;
bool LastX = false;
bool LastC = false;
bool LastV = false;
bool LastG = false;
Also added CtrlKey and AltKey function. Then did kill bind to CTRL+Z.
Tested it, and it works! Now i can customize my own source-config like i want.
Wow, just that simple!
Thanks, deen.

Re: How to bind Shift+C for example?
Posted: Mon May 30, 2016 7:07 pm
by Wonder
Oh, i've got a bug.
For instance, i made a zoomout bind to Alt+D. When i press Alt+D, D button also presses. And tee moves right.
I got 2 functions pressed at 1 time. And for my purposes i need all keys in combinations was free. Like Alt - do nothing. And E - do nothing. In that case i can use Alt-E, Ctrl-E, Ctrl-shift-E any way i want. But if i have at "free" E something, then it presses too.
Any suggestions how to fix that?

Re: How to bind Shift+C for example?
Posted: Mon May 30, 2016 10:23 pm
by deen
Well, that's gonna be difficult exactly because the system is set up as I described and not meant to be used as you want. You would have to change the input system to remove events after you handled them in your thingy. This would mean adding stuff to the CInput and IInput classes.
An alternative quick hack:
https://github.com/ddnet/ddnet/blob/mas ... #L174-L187
So if you want to use lctrl, lshift and lalt as special keys that are ignored by regular input system you can use F1,
inp_ignored_modifiers 321
.
Re: How to bind Shift+C for example?
Posted: Tue May 31, 2016 2:30 pm
by Wonder
Ok, i will try and check which way is better.
For that moment i binded free keys.
Like C - +Showhookcoll, but ALT+C - +toggle inp_mousesens 1 130. So by pressing C i've got collision lines but ALT-C results as collision lines + precise aiming with 1 sens. Very comfortable.

Or E - zoom-, but ALT+E "zoom; zoom+". Restore default (zoom+ because E presses too

).
Alt-R - team 30, Ctrl-R - lockteam, Shift-R - unlockteam. Ctrl+Shift-R - team 0.
Entities, text overlays, quads, etc on 1 key too.
And much more.
So now i play TW like with modern ergonomic game controls.
Thank you for attention.
