I’m trying to get a basic cinder animation onto an iOS app. At a later stage I wish to switch a boolean in the code based on input from a wired ipad remote. As a first step, I was trying to switch this boolean with a bluetooth keyboard. The keyDown function works as long as I create an OSX app but fails to switch the boolean in the iOS app. How can I do this?
In case it helps, here’s the code (I’m trying to use a keyDown event to change the boolean trigger to true):
class LoomStimulusApp : public AppNative {
public:
void setup();
void keyDown( KeyEvent event );
void update();
void draw();
Vec2f centre;
float r_h;
float r_v;
float ar;
float size;
float dist;
float speed;
float transparency;
float timestep;
bool trigger;
};
void LoomStimulusApp::setup()
{
gl::disableVerticalSync();
gl::enableAlphaBlending();
centre = Vec2f(getWindowCenter().x, getWindowCenter().y);
ar = 1.0f;
size = 10000.0f;
dist = 10000.0f;
speed = 80.0f;
transparency = 1.0f;
timestep = 0.0f;
trigger = true;
}
void LoomStimulusApp::keyDown( KeyEvent event )
{
if ( event.getChar() == ‘w’ ) trigger = true;
std::cout << event.getCode() << " ";
}
void LoomStimulusApp::update()
{
if (trigger)
{
if (dist > FLT_EPSILON)
{
dist -= speed;
if (dist <= FLT_EPSILON) dist = FLT_EPSILON;
}
if (dist <= FLT_EPSILON)
{
dist = 10000.0f;
trigger = false;
}
if (ar <= 1.0f)
{
r_h = size / dist;
r_v = r_h * ar;
}
else
{
r_v = size / dist;
r_h = r_v / ar;
}
++timestep;
}
}
void LoomStimulusApp::draw()
{
// clear out the window with black
gl::clear( Color( 1.0f, 1.0f, 1.0f ) );
// draw circle in centre of screen
gl::color( ColorA( 0.0f, 0.0f, 0.0f, transparency ) );
if (trigger)
{
if (ar != 1.0f) gl::drawSolidEllipse(centre, r_h, r_v);
else gl::drawSolidCircle(centre, r_h);
}
}
Thanks a lot for your help.
Vivek