b1s
Member
|
change buttons.
We would like to create changeable controls..
anyone have any idea how this should be done?
|
|
07-07-2010 08:18 AM |
|
menajev
Member
|
RE: change buttons.
enum KeyFunc{kfForward,kfBack,kfLeft,kfRight,(...) kfAmount,};
class cInput
{
Memb<int> key;
Memb<Bool> keyMs; //if it's mouse button
Memb<Str> funcName;
public:
cInput(){Load();}
void Load(Bool default=false);
void Save();
Bool KB(KeyFunc); //press and hold
Bool KBP(KeyFunc); //pressed
Bool KBR(KeyFunc); //released
};
You change size of 'key' and 'keyMs' to equal kfAmount.
In key you keep KB_... enum value or no of mouse button.
In KB(KeyFunc kf) just return Kb.b(key[kf]) (you must cast here) or if keyMs[kf]==true return Ms.b(key[kf])
|
|
07-07-2010 08:30 AM |
|
Esenthel
Administrator
|
RE: change buttons.
actually for this purpose there are InputButton and Input classes, but I never made a tutorial about them.
struct InputButton // universal Input Button, may be a button from Keyboard, Mouse, Joypad
struct Input // Action Input (for example walk_forward), may be defined by maximum 3 custom buttons
{
UInt group; // custom input group (for example Movement, Interaction, Combat, ...)
CChar *name ; // action name
InputButton b[3] ; // 3 custom buttons
|
|
07-07-2010 03:23 PM |
|
b1s
Member
|
RE: change buttons.
how about detecting the button pressed?
|
|
07-07-2010 04:21 PM |
|
b1s
Member
|
RE: change buttons.
tutorial about this would be great.
|
|
07-08-2010 12:52 PM |
|
Esenthel
Administrator
|
RE: change buttons.
struct InputButton // universal Input Button, may be a button from Keyboard, Mouse, Joypad
{
INPUT_TYPE type ; // input type
Byte button, // button index
device; // device index
Bool operator==(InputButton &b); // if input buttons are equal
Bool on (); // if button on
Bool pd (); // if button pushed
Bool rs (); // if button released
Bool db (); // if button double clicked
CChar16* text(); // text describing the key
InputButton(INPUT_TYPE type=INPUT_NONE, Byte button=0, Byte device=0) {T.type=type; T.button=button; T.device=device;}
};
you set INPUT_KB, KB_A, 0
then call 'on' method to check if that button is on
|
|
07-08-2010 01:17 PM |
|
b1s
Member
|
RE: change buttons.
okay thanks.
|
|
07-08-2010 05:40 PM |
|