Problem with the SDK

Post questions, comments and feedback to our 3Dconnexion UNIX/Linux Development Team.

Moderator: Moderators

Problem with the SDK

Postby vekni » Mon Jul 04, 2011 4:45 am

Hello,

I have a problem with my program which get the data of the 3Dmouse spacepilot pro. To run the program, I have to run the daemon. And then, there is a problem, the first time I build and the run the program : no problem, i have in the console in real time the coordinates of each axis of the mouse and when i rebuild it, it doesn't work anymore, i can't get the datas and I don't know why

I tried to reboot the daemon, build/run again bht it doesn't work at all, even in rebooting the computer. The only way to run again the program, is to create a new project and to copy/paste the program and to buil & run it.
If someone had an idea it would cool!

Thanks!

#include <stdlib>
#include <stdio>
#include <X11>
#include "xdrvlib.h"
//-------------------------------------------------------------------------------------------------------------------------------
int getCoord(double*);
//-------------------------------------------------------------------------------------------------------------------------------
double MagellanSensitivity = 1.0;
//-------------------------------------------------------------------------------------------------------------------------------
//-----------------------------------------------MAIN()--------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------------------------------------
int main( int argc, char *argv[] )
{
double coordonnees[6];
getCoord(coordonnees);
return 0;
}
//-------------------------------------------------------------------------------------------------------------------------------
//--------------------------------------FONCTION RECUPERATION DES COORDONNES-----------------------------------------------------
//-------------------------------------------------------------------------------------------------------------------------------
int getCoord(double* tab)
{
Display *display;
Window root, window;

int screennumber,width,height;
XSizeHints *sizehints;
XWMHints *wmhints;
XClassHint *classhints;


XEvent report;
MagellanFloatEvent MagellanEvent;

XComposeStatus compose;
KeySym keysym;

int MagellanDemoEnd = FALSE;
char MagellanBuffer[ 256 ];


/****************** Open a Window ******************************************/
sizehints = XAllocSizeHints();
wmhints = XAllocWMHints();
classhints = XAllocClassHint();
if ( (sizehints==NULL) || (wmhints==NULL) || (classhints==NULL) )
{
fprintf( stderr, "Can't allocate memory! Exit ... \n" );
exit( -1 );
};

display = XOpenDisplay( NULL );
if ( display == NULL )
{
fprintf( stderr, "Can't open display! Exit ... \n");
exit( -1 );
};

screennumber = DefaultScreen(display);
width = DisplayWidth(display,screennumber);
height = DisplayHeight(display,screennumber);
root = DefaultRootWindow(display);
window = XCreateSimpleWindow( display, root, 0,0, width/5*3,height/8, 20, BlackPixel(display,screennumber),WhitePixel(display,screennumber) );

/************************* Create 3D Event Types ***************************/
if ( !MagellanInit( display, window ) )
{
fprintf( stderr, "No driver is running. Exit ... \n" );
exit(-1);
};

/************************* Main Loop ***************************************/
XSelectInput( display, window, KeyPressMask | KeyReleaseMask );

while( MagellanDemoEnd == FALSE )
{
XNextEvent( display, &report );
switch( report.type )
{
case KeyRelease : /* ... */
break;

case KeyPress :
XLookupString( (XKeyEvent*)&report, MagellanBuffer,
sizeof(MagellanBuffer), &keysym, &compose );
MagellanDemoEnd = keysym == XK_Escape;
break;

case ClientMessage :
switch( MagellanTranslateEvent( display, &report, &MagellanEvent, 1.0, 1.0 ) )
{
case MagellanInputMotionEvent :
MagellanRemoveMotionEvents( display );

tab[0] = MagellanEvent.MagellanData[ MagellanX ];
tab[1] = MagellanEvent.MagellanData[ MagellanY ];
tab[2] = MagellanEvent.MagellanData[ MagellanZ ];
tab[3] = MagellanEvent.MagellanData[ MagellanA ];
tab[4] = MagellanEvent.MagellanData[ MagellanB ];
tab[5] = MagellanEvent.MagellanData[ MagellanC ];
printf("x=%+5.0lf y=%+5.0lf z=%+5.0lf a=%+5.0lf b=%+5.0lf c=%+5.0lf \n",tab[0] ,tab[1] , tab[2] , tab[3] , tab[4] , tab[5] );
};
break;
};
};
return TRUE;
}
vekni
 
Posts: 6
Joined: Mon Jun 06, 2011 2:59 am

Return to Developer's Forum for UNIX/Linux

Who is online

Users browsing this forum: No registered users and 1 guest