About Store Forum Documentation Contact



Post Reply 
change buttons.
Author Message
b1s Offline
Member

Post: #1
change buttons.
We would like to create changeable controls..
anyone have any idea how this should be done?
07-07-2010 08:18 AM
Find all posts by this user Quote this message in a reply
menajev Offline
Member

Post: #2
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
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #3
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
Find all posts by this user Quote this message in a reply
b1s Offline
Member

Post: #4
RE: change buttons.
how about detecting the button pressed?
07-07-2010 04:21 PM
Find all posts by this user Quote this message in a reply
b1s Offline
Member

Post: #5
RE: change buttons.
tutorial about this would be great.
07-08-2010 12:52 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #6
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
Find all posts by this user Quote this message in a reply
b1s Offline
Member

Post: #7
RE: change buttons.
okay thanks.
07-08-2010 05:40 PM
Find all posts by this user Quote this message in a reply
Post Reply