Remote triggering of iOS app

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

I don’t understand the part about the hardware. What do you mean with a “wired iPad remote” and a “BlueTooth keyboard”? I can’t recall seeing an iPad with a USB connector or Ethernet connection.

For what it’s worth: the keyDown() method just works if you use the built-in on-screen iPad keyboard.

Hey Paul,

I was off the app building and doing other things for a while. But here’s my problem explained in a bit more detail.

I’m a biologist and am trying to build an app to scare fish with. What I’d like is to have a white screen and trigger the stimulus whenever I choose to. However, I myself do not want to be part of the experimental setup and would like to be able to trigger the stimulus remotely. One solution I thought could work is using an external trigger. I was thinking of something like this:


where I could stand several meters away from the experimental setup and still be able to trigger the stimulus. I’ve seen such external remotes mostly used to trigger the photo app. I was wondering if there’s a way for me to be able to trigger events in my app using cinder with an external remote like this.

Thanks for your help again.

Cheers!
Vivek

Hi Vivek,

As you can see from the video the remote uses the headphone jack. I think it is sending some audio signal that you can detect by analysing the audio input from your cinder application.

-Gabor

@vivekhsridhar Depending on the stimulus, you could just use my Augmented Theatre App. It is controlled by osc. The description will point you to the set up instructions.

–8

You are right @gabor_papp. So I have the wired remote and I know it functions as the volume up button on the ipad. I just need to figure out how to use that button to switch a boolean in my app.

@eight_io, I’m nearly done with building the app. I’d like to try and finish it myself. I’ll still take a look at your app incase I don’t manage that though. Thanks.

Cheers!
Vivek

It’d be great to know if someone already has that part figured out… How I can use the ‘volume up’ button on the ipad to switch a boolean

Thanks again for the help.

Cheers!
Vivek

I have no experience with this, but this might help:
https://github.com/blladnar/RBVolumeButtons

Thanks everyone for the help. For your amusement, here’s a video of the fish freaking out at the sight of my app.

Cheers!
Vivek