diff --git a/src/Application/Application.cpp b/src/Application/Application.cpp index ebbcd93..7acba76 100644 --- a/src/Application/Application.cpp +++ b/src/Application/Application.cpp @@ -158,6 +158,10 @@ void Application::onKeyPressed(ofKeyEventArgs & args){ reboot(); break; + case 'c': + shutdown(); + break; + default: // All the other keypresses are handled by the application state onKeyPressed _state->onKeyPressed(this, args); @@ -308,6 +312,14 @@ void Application::reboot(){ #endif } +void Application::shutdown(){ + #ifdef TARGET_RASPBERRY_PI + system("sudo shutdown -h now"); + #else + ofLogNotice("Application::shutdown()", "Supported only on Raspberry Pi"); + #endif +} + bool Application::loadXmlSettings(string fileName){ if(!ofFile::doesFileExist(fileName)){ ofLogError("Application::loadXmlSettings()") << fileName << " does not exist"; diff --git a/src/Application/Application.h b/src/Application/Application.h index a18d04a..ab387a5 100644 --- a/src/Application/Application.h +++ b/src/Application/Application.h @@ -126,6 +126,7 @@ class Application : public KeyListener { // System commands void reboot(); + void shutdown(); protected: void setState(ApplicationBaseMode * st); diff --git a/src/ofxPiMapper.cpp b/src/ofxPiMapper.cpp index d847952..b7b10b9 100644 --- a/src/ofxPiMapper.cpp +++ b/src/ofxPiMapper.cpp @@ -154,6 +154,10 @@ void ofxPiMapper::reboot(){ _application.reboot(); } +void ofxPiMapper::shutdown(){ + _application.shutdown(); +} + void ofxPiMapper::saveProject(){ _application.saveProject(); } diff --git a/src/ofxPiMapper.h b/src/ofxPiMapper.h index 9be9859..47d9a33 100644 --- a/src/ofxPiMapper.h +++ b/src/ofxPiMapper.h @@ -68,6 +68,7 @@ class ofxPiMapper { // System commands void reboot(); + void shutdown(); private: ofx::piMapper::Application _application;