From e7424d492ecd732fc85a775106cefab9a238ee83 Mon Sep 17 00:00:00 2001 From: Krisjanis Rijnieks Date: Tue, 10 Jan 2017 19:25:56 +0100 Subject: [PATCH] Add passing key events instead of registering to them --- src/Application/Application.cpp | 2 ++ src/ofxPiMapper.cpp | 12 ++++++++++++ src/ofxPiMapper.h | 3 +++ 3 files changed, 17 insertions(+) diff --git a/src/Application/Application.cpp b/src/Application/Application.cpp index 3e6fc7f..09e3018 100644 --- a/src/Application/Application.cpp +++ b/src/Application/Application.cpp @@ -14,8 +14,10 @@ Application::Application(){ ofHideCursor(); // TODO: Get rid of listeners, pipe application events from the example app + /* ofAddListener(ofEvents().keyPressed, this, &Application::onKeyPressed); ofAddListener(ofEvents().keyReleased, this, &Application::onKeyReleased); + */ /* ofAddListener(ofEvents().mousePressed, this, &Application::onMousePressed); diff --git a/src/ofxPiMapper.cpp b/src/ofxPiMapper.cpp index e6e81ca..aa2a3c7 100644 --- a/src/ofxPiMapper.cpp +++ b/src/ofxPiMapper.cpp @@ -14,6 +14,18 @@ void ofxPiMapper::draw(){ _application.draw(); } +void ofxPiMapper::keyPressed(int key){ + ofKeyEventArgs args; + args.key = key; + _application.onKeyPressed(args); +} + +void ofxPiMapper::keyReleased(int key){ + ofKeyEventArgs args; + args.key = key; + _application.onKeyReleased(args); +} + void ofxPiMapper::mousePressed(int x, int y, int button){ ofMouseEventArgs args; args.x = x; diff --git a/src/ofxPiMapper.h b/src/ofxPiMapper.h index c5f61ac..2c5411b 100644 --- a/src/ofxPiMapper.h +++ b/src/ofxPiMapper.h @@ -39,6 +39,9 @@ class ofxPiMapper { void update(); void draw(); + void keyPressed(int key); + void keyReleased(int key); + void mousePressed(int x, int y, int button); void mouseReleased(int x, int y, int button); void mouseDragged(int x, int y, int button);