ofxPiMapper fixed for C++17 & oF 12.0
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

64 lines
2.7 KiB

#include "Keyboard.h"
namespace ofx {
namespace piMapper {
Keyboard::Keyboard(ofxPiMapper * opm) {
_ofxPiMapper = opm;
ofLogNotice("Keyboard event handler");
ofAddListener(ofEvents().keyPressed, this, &Keyboard::onKeyPressed);
}
Keyboard::~Keyboard() {
_ofxPiMapper = 0;
ofRemoveListener(ofEvents().keyPressed, this, &Keyboard::onKeyPressed);
}
void Keyboard::onKeyPressed(ofKeyEventArgs & args) {
ofLogNotice("Keyboard::onKeyPressed");
ofLog() << args.keycode;
// Choose what command to create here
// depending on the key pressed
switch (args.key) {
case '1':
ofLogNotice("Keyboard::onKeyPressed") << "1";
if (_ofxPiMapper->getGui().getMode() != ofx::piMapper::GuiMode::NONE) {
_ofxPiMapper->getCmdManager().exec(
new ofx::piMapper::SetGuiModeCmd(&_ofxPiMapper->getGui(),
ofx::piMapper::GuiMode::NONE));
}
break;
case '2':
ofLogNotice("Keyboard::onKeyPressed") << "2";
if (_ofxPiMapper->getGui().getMode() != ofx::piMapper::GuiMode::PROJECTION_MAPPING) {
_ofxPiMapper->getCmdManager().exec(new ofx::piMapper::SetGuiModeCmd(
&_ofxPiMapper->getGui(),
ofx::piMapper::GuiMode::PROJECTION_MAPPING));
}
break;
case '3':
ofLogNotice("Keyboard::onKeyPressed") << "3";
if (_ofxPiMapper->getGui().getMode() != ofx::piMapper::GuiMode::SOURCE_SELECTION) {
_ofxPiMapper->getCmdManager().exec(new ofx::piMapper::SetGuiModeCmd(
&_ofxPiMapper->getGui(),
ofx::piMapper::GuiMode::SOURCE_SELECTION));
}
break;
case '4':
ofLogNotice("Keyboard::onKeyPressed") << "4";
if (_ofxPiMapper->getGui().getMode() != ofx::piMapper::GuiMode::TEXTURE_MAPPING) {
_ofxPiMapper->getCmdManager().exec(new ofx::piMapper::SetGuiModeCmd(
&_ofxPiMapper->getGui(),
ofx::piMapper::GuiMode::TEXTURE_MAPPING));
}
break;
default:
// TODO: Forward it to the application state for it to decide.
ofLogNotice("Keyboard::onKeyPressed") << "default case";
break;
}
}
}
}