-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature request - key control ala ofxGameCamera #4
Comments
i think kyle tried implementing key controls last time. perhaps we could have an |
Yeah another approach could be to have an isKeyBoardEnabled option that allowed you to bind the keys. Maybe even broken out into a separate utility Class like ofxGrabCamKeyUtils. Something like that could load a config file to allow custom mappings |
yeah that'd be great perhaps syntax like: class ofBaseHasActions {
public:
virtual void doAction(int action) = 0; ///<override this function to perform your actions
};
class ofBaseHasHotkeys : public ofBaseHasActions {
public:
~ofBaseHasHotkeys(); ///<removes hotkeys from this instance from static dictionary
void addHotkey(int key, int action); ///<throws a warning if this key is already linked to any action globally
void removeHotkey(int key);
protected:
static std::map<int , pair<ofBaseHasHotkeys *, int> > hotkeyDictionary; ///< global map of [key, [instance, action] ]
}; I presume that the class ofNode : public ofBaseHasHotkeys {
public:
enum action { PITCH_UP, PITCH_DOWN, YAW_LEFT, YAW_RIGHT, ROLL_LEFT, ROLL_RIGHT, etc }
virtual void doAction(int action); ///<note that it's still virtual so child classes can add further hotkeys as long as they remember to call ofNode::doAction(action)
....
}; |
a couple of other notes: we could keep hotkeys seperate and have static std::map<int , pair<ofBaseHasHotkeys *, int> > hotkeyDictionary;
void ofAddHotkey(int key, int action, ofBaseHasActions * instance);
void ofRemoveHotkey(int key, ofBaseHasActions * instance = 0); ///<by default removes all hotkey associations then we'd also need class ofBaseHasActions {
public:
~ofBaseHasActions(); ///<removes any hotkeys linked to this instance from the dictionary
virtual void doAction(int action) = 0; ///<override this function to perform your actions
}; the above still requires the user to define the hotkeys at compile time (rather than in a file) and i can see this being a bit of a bugger to debug for new users if something goes wrong (it's not very safe) I'd suggest having a look at https://github.com/elliotwoods/ofxGrabCam/tree/interactive |
ah!!!!! yes of course! |
I was wondering what you meant about breaking convention but I thought maybe you were trying to get ofxGrabCam into core :) |
Because being able to move without a mouse would be awesome (nice for laptops)
https://github.com/Flightphase/ofxGameCamera/blob/master/src/ofxGameCamera.cpp
The text was updated successfully, but these errors were encountered: