Skip to content

Commit

Permalink
Merge pull request #122 from mattfelsen/no-touch-support
Browse files Browse the repository at this point in the history
Wrap Touch-related in `#ifndef NOTOUCH` to support faster builds
  • Loading branch information
benjaminbojko authored Aug 17, 2018
2 parents 78a0196 + a4d1697 commit 366bf90
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/bluecadet/core/BaseApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,20 @@
#include "ScreenLayout.h"
#include "ScreenCamera.h"

// Needed for SetForegroundWindow
#if defined(CINDER_MSW)
#include <Windows.h>
#endif

using namespace ci;
using namespace ci::app;
using namespace std;
using namespace bluecadet::views;

#ifndef NO_TOUCH
using namespace bluecadet::touch;
using namespace bluecadet::touch::drivers;
#endif

namespace bluecadet {
namespace core {
Expand Down Expand Up @@ -66,6 +74,7 @@ void BaseApp::setup() {
gl::enableVerticalSync(settings->mVerticalSync);
gl::enableAlphaBlending();

#ifndef NO_TOUCH
// Set up touches
if (settings->mMouseEnabled) {
mMouseDriver.connect();
Expand All @@ -79,6 +88,7 @@ void BaseApp::setup() {
}

mSimulatedTouchDriver.setup(Rectf(vec2(0), getWindowSize()), 60);
#endif

// Debugging
mStats->setBackgroundColor(ColorA(0, 0, 0, 0.1f));
Expand All @@ -99,7 +109,9 @@ void BaseApp::update() {
// touch events to convert touches from window into app space
const auto appTransform = glm::inverse(ScreenCamera::getInstance()->getTransform());
const auto appSize = ScreenLayout::getInstance()->getAppSize();
#ifndef NO_TOUCH
touch::TouchManager::getInstance()->update(mRootView, appSize, appTransform);
#endif
mRootView->updateScene(deltaTime);

mStats->addValue("FPS", 1.0f / (float)deltaTime);
Expand All @@ -118,10 +130,12 @@ void BaseApp::draw(const bool clear) {
gl::multModelMatrix(ScreenCamera::getInstance()->getTransform());
mRootView->drawScene();

#ifndef NO_TOUCH
// draw debug touches in app coordinate space
if (settings->mDebugEnabled && settings->mShowTouches) {
touch::TouchManager::getInstance()->debugDrawTouches();
}
#endif
}

if (settings->mDebugEnabled) {
Expand Down Expand Up @@ -199,6 +213,7 @@ void BaseApp::handleViewportChange(const ci::Area & viewport) {
SettingsManager::getInstance()->getParams()->setPosition(vec2(mDebugUiPadding));
}

#ifndef NO_TOUCH
void BaseApp::addTouchSimulatorParams(float touchesPerSecond) {

mSimulatedTouchDriver.setTouchesPerSecond(touchesPerSecond);
Expand Down Expand Up @@ -254,6 +269,7 @@ void BaseApp::addTouchSimulatorParams(float touchesPerSecond) {
params->setOptions(groupName, "opened=false");
}
}
#endif

}
}
8 changes: 8 additions & 0 deletions src/bluecadet/core/BaseApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@
#include "../views/BaseView.h"
#include "../views/MiniMapView.h"
#include "../views/GraphView.h"

#ifndef NO_TOUCH
#include "../touch/TouchManager.h"
#include "../touch/drivers/MouseDriver.h"
#include "../touch/drivers/NativeTouchDriver.h"
#include "../touch/drivers/TuioDriver.h"
#include "../touch/drivers/SimulatedTouchDriver.h"
#endif

namespace bluecadet {
namespace core {
Expand Down Expand Up @@ -51,6 +54,7 @@ class BaseApp : public ci::app::App {
//! Debug view to render stats like fps in a graph.
views::GraphViewRef getStats() const { return mStats; };

#ifndef NO_TOUCH
//! The main touch driver running on TUIO. Automatically connected at app launch.
touch::drivers::TuioDriver & getTouchDriver() { return mTuioDriver; }

Expand All @@ -65,6 +69,7 @@ class BaseApp : public ci::app::App {

//! Adds a set of params to control the touch simulator
void addTouchSimulatorParams(float touchesPerSecond = 50.f);
#endif

private:
views::BaseViewRef mRootView;
Expand All @@ -74,10 +79,13 @@ class BaseApp : public ci::app::App {
float mDebugUiPadding;
bool mIsLateSetupCompleted;

#ifndef NO_TOUCH
touch::drivers::TuioDriver mTuioDriver;
touch::drivers::MouseDriver mMouseDriver;
touch::drivers::NativeTouchDriver mNativeTouchDriver;
touch::drivers::SimulatedTouchDriver mSimulatedTouchDriver;
#endif

};

}
Expand Down
3 changes: 3 additions & 0 deletions src/bluecadet/views/TouchView.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#ifndef NO_TOUCH

#include "TouchView.h"
#include "../touch/TouchManager.h"
Expand Down Expand Up @@ -246,3 +247,5 @@ void TouchView::setTouchPath(const float radius, const ci::vec2& offset, const i

}
}

#endif
4 changes: 4 additions & 0 deletions src/bluecadet/views/TouchView.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#pragma once
#ifndef NO_TOUCH

#include "cinder/app/App.h"
#include "cinder/Timeline.h"
#include "cinder/Shape2d.h"
Expand Down Expand Up @@ -201,3 +203,5 @@ class TouchView : public BaseView {

}
}

#endif

0 comments on commit 366bf90

Please sign in to comment.