Author Topic: adding key controles  (Read 1878 times)

0 Members and 1 Guest are viewing this topic.

Offline Bobboau

  • Just a MODern kinda guy
    Just MODerately cool
    And MODest too
  • 213
as I am copying my work I figured I'd document all the things you have to do to get a new key controle in game

so, you have a new key controle that you want to have bindable
first thing you have to do is add a define for it in controlsconfig.h there is a long list of them ending around line 444, in the origonal code there is 106 keys defined, in the SCP version there is going to be about 111 (after I put in my stuff)
you must add to this list like this
#define TOGGLE_HUD         107
that's RT's hud togleing thing for exterior veiw
at the botom of the list is this
#define CCFG_MAX "enter number + 1 of last key define here"

then you need to set up were it is to be found in the controles config, and it's default binding in a table called config_item Control_config ( ControlsConfigCommon.cpp )
seeing as I used it once allready here is RT's entry into this table
Code: [Select]
{  KEY_SHIFTED | KEY_O, -1, COMPUTER_TAB, "Toggle HUD"},

(KEY_O) this sets the default binding to the o key, (KEY_SHIFTED ) further it requires the shift key to be down, the -1 is an index to the joystick button, (COMPUTER_TAB) it is in the targeting panel, and has the description "Toggle HUD". if you look at other entrys you will also see that you can have alt key things.
this table is in order of the defines in controlsconfig.h if you add something to there you must add an entry to the botom of this list. [edit]also if you are going to use the time down check functions you must tack on ", CC_TYPE_CONTINUOUS" after the description[/edit]

there, now you have the new controle setup, now you just need to use it, most likely you will want to use check_control_timef(), it will return how long the controle has been in use, or just the fact that it has been in use.
another good one is check_control(), wich will mearly tell you if the controle is active
if you just want to quickly hack in a controle you may use key_down_timef() as a replacement, were you just have to put in a hard coded non-changeable key binding (for example KEY_D)
almost all key conrole stuff is found in PlayerControl.cpp

also adding a new bindable key will require you make a new pilot, make sure to tell anyone about this up front
« Last Edit: October 19, 2002, 01:04:51 pm by 57 »
Bobboau, bringing you products that work... in theory
learn to use PCS
creator of the ProXimus Procedural Texture and Effect Generator
My latest build of PCS2, get it while it's hot!
PCS 2.0.3


DEUTERONOMY 22:11
Thou shalt not wear a garment of diverse sorts, [as] of woollen and linen together

 

Offline RandomTiger

  • Senior Member
  • 211
Quote
Originally posted by Bobboau
also adding a new bindable key will require you make a new pilot, make sure to tell anyone about this up front


What happens if you dont?
I have had the problem that the key is not bound the first time you run it and you have to bind it yourself, is that because I didnt create a new pilot?

We should put this on a site as a tutorial.

 

Offline Bobboau

  • Just a MODern kinda guy
    Just MODerately cool
    And MODest too
  • 213
well key bindings are stored in the pilot file, if you don't make a new one, there may be problems, and it's just plain a better idea to make sure you don't have any conflicts
Bobboau, bringing you products that work... in theory
learn to use PCS
creator of the ProXimus Procedural Texture and Effect Generator
My latest build of PCS2, get it while it's hot!
PCS 2.0.3


DEUTERONOMY 22:11
Thou shalt not wear a garment of diverse sorts, [as] of woollen and linen together

 

Offline Bobboau

  • Just a MODern kinda guy
    Just MODerately cool
    And MODest too
  • 213
I forgot about the CC_TYPE_CONTINUOUS flag you have to tack on to the end of that little table thing if you are going to be useing the time down functions
Bobboau, bringing you products that work... in theory
learn to use PCS
creator of the ProXimus Procedural Texture and Effect Generator
My latest build of PCS2, get it while it's hot!
PCS 2.0.3


DEUTERONOMY 22:11
Thou shalt not wear a garment of diverse sorts, [as] of woollen and linen together