Forum

Direct input/Have more buttons than 3?

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

Direct input/Have more buttons than 3?

Postby daemonicky » Wed Apr 27, 2011 8:44 am

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. :)
User avatar
daemonicky
 
Posts: 185
Joined: Wed Apr 13, 2011 1:34 pm

Postby behind_you » Wed Apr 27, 2011 9:16 am

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
User avatar
behind_you
 
Posts: 237
Joined: Sat Feb 05, 2011 6:57 am
Location: Tripoli, Libya

Postby Jukki » Wed Apr 27, 2011 4:15 pm

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

Postby Spike » Wed Apr 27, 2011 5:21 pm

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).
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Postby behind_you » Thu Apr 28, 2011 7:51 am

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.
User avatar
behind_you
 
Posts: 237
Joined: Sat Feb 05, 2011 6:57 am
Location: Tripoli, Libya

Postby Jukki » Thu Apr 28, 2011 11:07 am

Well not realy, cause of psp there is not many buttons etc so i havent realy seen any problems
Jukki
 
Posts: 214
Joined: Wed Apr 07, 2010 4:59 am


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest