Direct input/Have more buttons than 3?
Moderator: InsideQC Admins
6 posts
• Page 1 of 1
Direct input/Have more buttons than 3?
I want to detect when player press keys on keyboard, clicks mouse buttons from Quake C. I dont want to touch engine C because it would make it less portable.
There are three variables - button0 to button3. They work, but it is only for mouse buttons.
Is there a way to detect another input, like keyboard from vannila Quake C ?
Thanks.
There are three variables - button0 to button3. They work, but it is only for mouse buttons.
Is there a way to detect another input, like keyboard from vannila Quake C ?
Thanks.
-

daemonicky - Posts: 185
- Joined: Wed Apr 13, 2011 1:34 pm
if using DP, you can use button4 - button8 as well
without dp and without editing the source, the only way i can think of is binding the keys you want to use to impulses and then writing an if(self.impulse == number)
ie
config.cfg
bind f "impulse 44"
in impulsecommands
if (self.impulse == 44) // if you hit the f key on the keyboard
dowhatyouwant();
for holding buttons and detecting release, im pretty sure the only valid option is to use .buttons
in conclusion, satisfactory results will only come thru using dp or editing source
without dp and without editing the source, the only way i can think of is binding the keys you want to use to impulses and then writing an if(self.impulse == number)
ie
config.cfg
bind f "impulse 44"
in impulsecommands
if (self.impulse == 44) // if you hit the f key on the keyboard
dowhatyouwant();
for holding buttons and detecting release, im pretty sure the only valid option is to use .buttons
in conclusion, satisfactory results will only come thru using dp or editing source
-

behind_you - Posts: 237
- Joined: Sat Feb 05, 2011 6:57 am
- Location: Tripoli, Libya
Actualy i have a nice litle piece of code done in qc wich uses aliases and impulses to check holding and key press and key releases. I also made it support doble tapping. So in my game i have hand grenades when you press the throw it starts throwing. If a value HOLDING Is true (set true when key down impulse [+alias] is pressed and false when key up [-alias]) it will hold the nade and if you release the button it throws it. If you quickly double tap it. It will chabge grenade type then. I would give the code but i dont have acces to computer atm. I hope i still gved you basic idea how to do it.
- Jukki
- Posts: 214
- Joined: Wed Apr 07, 2010 4:59 am
alias +foo "impulse 20"
alias -foo "impulse 21"
bind f foo
press f, you get impulse 20, release it and you get impulse 21.
impulses can be lost, and can be overwritten by other impulses.
buttons are more reliable, so should be used in preference if there are no other downsides (like limited engine support).
alias -foo "impulse 21"
bind f foo
press f, you get impulse 20, release it and you get impulse 21.
impulses can be lost, and can be overwritten by other impulses.
buttons are more reliable, so should be used in preference if there are no other downsides (like limited engine support).
- Spike
- Posts: 2892
- Joined: Fri Nov 05, 2004 3:12 am
- Location: UK
Jukki wrote:Actualy i have a nice litle piece of code done in qc wich uses aliases and impulses to check holding and key press and key releases. I also made it support doble tapping. So in my game i have hand grenades when you press the throw it starts throwing. If a value HOLDING Is true (set true when key down impulse [+alias] is pressed and false when key up [-alias]) it will hold the nade and if you release the button it throws it. If you quickly double tap it. It will chabge grenade type then. I would give the code but i dont have acces to computer atm. I hope i still gved you basic idea how to do it.
nice. but does your code have the problem that spike described:
Spike wrote:impulses can be lost, and can be overwritten by other impulses.
-

behind_you - Posts: 237
- Joined: Sat Feb 05, 2011 6:57 am
- Location: Tripoli, Libya
6 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest