Browse Source

Add gamepad example initial src files

master
Krisjanis Rijnieks 8 years ago
parent
commit
73abf8fca4
  1. 24
      example-gamepad/src/main.cpp
  2. 34
      example-gamepad/src/ofApp.cpp
  3. 20
      example-gamepad/src/ofApp.h

24
example-gamepad/src/main.cpp

@ -0,0 +1,24 @@
#include "ofMain.h"
#include "ofApp.h"
#include <string>
#include <vector>
int main(int argc, char * argv[]){
bool fullscreen = false;
vector<string> arguments = vector<string>(argv, argv + argc);
for(int i = 0; i < arguments.size(); ++i){
if(arguments.at(i) == "-f"){
fullscreen = true;
break;
}
}
if(fullscreen){
ofSetupOpenGL(800, 450, OF_FULLSCREEN);
}else{
ofSetupOpenGL(800, 450, OF_WINDOW);
}
ofRunApp(new ofApp());
}

34
example-gamepad/src/ofApp.cpp

@ -0,0 +1,34 @@
#include "ofApp.h"
void ofApp::setup(){
ofBackground(0);
mapper.setup();
}
void ofApp::update(){
mapper.update();
}
void ofApp::draw(){
mapper.draw();
}
void ofApp::keyPressed(int key){
mapper.keyPressed(key);
}
void ofApp::keyReleased(int key){
mapper.keyReleased(key);
}
void ofApp::mousePressed(int x, int y, int button){
mapper.mousePressed(x, y, button);
}
void ofApp::mouseDragged(int x, int y, int button){
mapper.mouseDragged(x, y, button);
}
void ofApp::mouseReleased(int x, int y, int button){
piMapper.mouseReleased(x, y, button);
}

20
example-gamepad/src/ofApp.h

@ -0,0 +1,20 @@
#pragma once
#include "ofMain.h"
#include "ofxPiMapper.h"
class ofApp : public ofBaseApp {
public:
void setup();
void update();
void draw();
void keyPressed(int key);
void keyReleased(int key);
void mousePressed(int x, int y, int button);
void mouseDragged(int x, int y, int button);
void mouseReleased(int x, int y, int button);
ofxPiMapper mapper;
};
Loading…
Cancel
Save