maping multitouch to mouse osx
Posted: 21 May 2008 08:50 PM   [ Ignore ]
New Member
Rank
Total Posts:  11
Joined  2008-05-06

hi, im working on a kind of mouse driver to osx. ive found the way to move the mouse and send events to quartz api from within c++. but nou need to write the funcs that read the touches and send the apropiate systems evens. as move an click on the first blob. release when the blob disappear. double taping and secondary button when two blobs appear toguether.
any help?

Profile
 
 
Posted: 23 May 2008 11:06 AM   [ Ignore ]   [ # 1 ]
New Member
Rank
Total Posts:  8
Joined  2008-05-22
lseba - 21 May 2008 08:50 PM

hi, im working on a kind of mouse driver to osx. ive found the way to move the mouse and send events to quartz api from within c++. but nou need to write the funcs that read the touches and send the apropiate systems evens. as move an click on the first blob. release when the blob disappear. double taping and secondary button when two blobs appear toguether.
any help?

wow you seem like a brainy person i cant even edit the config.xml file properly :D

Profile
 
 
Posted: 23 May 2008 12:30 PM   [ Ignore ]   [ # 2 ]
New Member
Rank
Total Posts:  11
Joined  2008-05-06

anyone interested in helpin with this?
i ve some progress. ive managed to send events to sistem. move the cursos and press and release button. but when i exit the app i get this error code that worries me:
“openFrameworks(1283,0xa0695fa0) malloc: *** error for object 0xbffff0e0: Non-aligned pointer being freed (2)
*** set a breakpoint in malloc_error_break to debug

The Debugger has exited with status 0.”

here is my code

#include "testApp.h"



void testApp::setup() {
    ofSetFrameRate
60 );
    
cwidth 320;
    
cheight 240;
    
threshold 60;
    
mouseon=false;
    
bLearnBakground true;  
    
      
TUIOSocket.setupHOSTPORT ); // Set in Header  

    
vidGrabber.initGrabbercwidthcheight );
    
colorImg.allocatecwidthcheight );
    
grayImg.allocatecwidthcheight );
    
bgImg.allocatecwidthcheight );
    
    
blobTracker.setListenerthis );
    
alivecounter=0;
}



void testApp
::update() {
    ofBackground
100100100 );
    
vidGrabber.grabFrame();
    
    if( 
vidGrabber.isFrameNew() ) {
        colorImg 
vidGrabber.getPixels();
        
colorImg.mirrorfalsetrue );
        
grayImg colorImg;
     
        if( 
bLearnBakground {
            bgImg 
grayImg;
            
bLearnBakground false;
        
}    

        grayImg
.absDiffbgImg );
        
grayImg.blur11 );
        
grayImg.thresholdthreshold );

        
//findContures( img, minSize, maxSize, nMax, inner contours yes/no )
        
contourFinder.findContoursgrayImg10,2000010false );
        
blobTracker.trackBlobscontourFinder.blobs );
    
}
    
}



void testApp
::draw() {
    ofSetColor
0xffffff );
    
    
colorImg.draw20,20 );
  
//  grayImg.draw( 360,200 );
    
    
blobTracker.draw20,20 );
    
string strhelp="[space] to learn background\n[+]/[-] to adjust threshold: "ofToString(threshold2)+"\n[m] to toggle system mouse events:"+ofToString(mouseon);
    
ofDrawBitmapStringstrhelp20,300 );   
       
    
ofxOscMessage m2;
    
m2.setAddress"/tuio/2Dcur" );        
    
m2.addStringArg"alive" );
    for (
int i 0blobTracker.blobs.size() ; i++){
  
//  ofCvTrackedBlob blob = blobTracker.getById( id );
        
ofxOscMessage m1;
            
m1.setAddress"/tuio/2Dcur" );
            
m1.addStringArg"set" );
            
m1.addIntArgblobTracker.blobs[i].id ); //id (id can't be == 0)
            
m1.addFloatArgblobTracker.blobs[i].center.x/360 ); //  x/camWidth
            
m1.addFloatArg(  blobTracker.blobs[i].center.y/240 ); // y/camHeight 
            
m1.addFloatArg(   blobTracker.blobs[i].deltaLoc.); //X
            
m1.addFloatArg(  blobTracker.blobs[i].deltaLoc.y  ); //Y
            
m1.addFloatArg(  blobTracker.blobs[i].area ); //m    
            
m1.addFloatArg(blobTracker.blobs[i].box.width ); //  wd
            
m1.addFloatArgblobTracker.blobs[i].box.height );// ht
            
TUIOSocket.sendMessagem1 );
        
        
m2.addIntArgblobTracker.blobs[i].id  ); //Get list of ALL active IDs        
        
    
}
    TUIOSocket
.sendMessagem2 );//send them
    
alivecounterblobTracker.blobs.size();
}





void testApp
::keyPressedint key {
    
if( key == ' ' {
        bLearnBakground 
true;
    
else if( key == '-' {
        threshold 
MAX0threshold-);
    
else if( key == '+' || key == '=' {
        threshold 
MIN255threshold+);
    
}else if( key == 'm' && !mouseon {
       mouseon 
true;
    
}else{
    mouseon
=false;
    
}
}
void testApp
::mouseMovedint xint y {}    
void testApp
::mouseDraggedint xint yint button {}
void testApp
::mousePressedint xint yint button {}
void testApp
::mouseReleased() {}

//--------------------------------------------------------------
void testApp::setmouse(float xfloat y,int event ){
    CGPoint pt
;
    
pt.=x;
    
pt.y;

    switch(
event){
        
case 1://move
 
        
CGPostMouseEventpt11);
        break;
        case 
2://press
 
        
CGPostMouseEventpt11);
        break;
        case 
3://release
 
        
CGPostMouseEventpt11);
        break;
    
};
    
    
    
    
}
void testApp
::blobOnint xint yint idint order {
    
if(mouseon && alivecounter==&& order==){
    blobmouse
=id;
    
setmouse(blobTracker.blobs[order].center.xblobTracker.blobs[order].center.y,);
     
cout << "blobOn() - id:" << id << " order:" << order << endl;

    
}

       


}    
void testApp
::blobMovedint xint yint idint order{
  
//  cout << "blobMoved() - id:" << id << " order:" << order << endl;
    
   
}
void testApp
::blobOffint xint yint idint order {
  
//  
  
if( blobmouse==id){
    
    setmouse
(blobTracker.blobs[order].center.xblobTracker.blobs[order].center.y,);
    
cout << "blobOff() - id:" << id << " order:" << order << endl;

    
}

}


void testApp
::blobAlivevector <int{

}

Profile