How to bind Shift+C for example?

Request help for teeworlds-related subjects (mapping, servers, ..).
For client issues, see our repositories (https://github.com/ddnet/ddnet/issues).
Post Reply
Wonder
Posts: 10
Joined: Sat May 28, 2016 9:07 pm

How to bind Shift+C for example?

Post 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? :oops:

Or is it possible only by hard coding in sources? :roll:

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.
User avatar
deen
TECHNICAL Team
Posts: 3576
Joined: Mon May 05, 2014 2:30 pm
Player profile: https://ddnet.org/players/deen/
Discord: deen#5910

Re: How to bind Shift+C for example?

Post by deen »

Not supported.
Wonder
Posts: 10
Joined: Sat May 28, 2016 9:07 pm

Re: How to bind Shift+C for example?

Post 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? :roll:
User avatar
deen
TECHNICAL Team
Posts: 3576
Joined: Mon May 05, 2014 2:30 pm
Player profile: https://ddnet.org/players/deen/
Discord: deen#5910

Re: How to bind Shift+C for example?

Post 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.
Wonder
Posts: 10
Joined: Sat May 28, 2016 9:07 pm

Re: How to bind Shift+C for example?

Post 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. :oops:
User avatar
deen
TECHNICAL Team
Posts: 3576
Joined: Mon May 05, 2014 2:30 pm
Player profile: https://ddnet.org/players/deen/
Discord: deen#5910

Re: How to bind Shift+C for example?

Post 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.
Wonder
Posts: 10
Joined: Sat May 28, 2016 9:07 pm

Re: How to bind Shift+C for example?

Post by Wonder »

Godbless you, deen. :mrgreen:
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. 8-)

Wow, just that simple!

Thanks, deen. :D
Wonder
Posts: 10
Joined: Sat May 28, 2016 9:07 pm

Re: How to bind Shift+C for example?

Post 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? :roll:
User avatar
deen
TECHNICAL Team
Posts: 3576
Joined: Mon May 05, 2014 2:30 pm
Player profile: https://ddnet.org/players/deen/
Discord: deen#5910

Re: How to bind Shift+C for example?

Post 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.
Wonder
Posts: 10
Joined: Sat May 28, 2016 9:07 pm

Re: How to bind Shift+C for example?

Post 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 :D).
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. :)
Post Reply

Who is online

Users browsing this forum: No registered users and 42 guests