Hi all,
I am currently porting an existing Linux application, so far everything seems to work well, X11, ALSA etc... I have one problem, I can't seem to access the nubs as joystick devices... I can see /dev/input/js0 and /dev/input/js1 exist, and open but I dont get any data. I have found that I need to switch the joysticks into absolute mode first, yet its not producing any data. Here are the two main functions I am using to access the hardware, any help would be very welcome...
	
	
	
		
				
			I am currently porting an existing Linux application, so far everything seems to work well, X11, ALSA etc... I have one problem, I can't seem to access the nubs as joystick devices... I can see /dev/input/js0 and /dev/input/js1 exist, and open but I dont get any data. I have found that I need to switch the joysticks into absolute mode first, yet its not producing any data. Here are the two main functions I am using to access the hardware, any help would be very welcome...
		Code:
	
	int open_joystick( INT_S16 stick_number )
{
        int fd;
        FILE *f;
        INT_S8 buffer[50];
        // make sure nub is in game mode
        sprintf( buffer, "/proc/pandora/nub%d/mode", stick_number-1 );
        f = fopen( buffer, "w+" );
        if( f )
        {
                // make the request
                fputs( "absolute", f );
                fclose( f );
        }
        // try to open this file
        sprintf( buffer, "/dev/input/js%d", stick_number-1 );
        fd = open( buffer, O_RDONLY|O_NONBLOCK );
        // did it open?
        return fd;
}
IBOOL JOYSTICK::read_joystick( void )
{
        int fd=-1;
        struct js_event event;
        <<snip, fd set to result of open_joystick()>>
        // loop through events (when no events left -1 returned and errno==EAGAIN)
        while( read( fd, &event, sizeof(event) ) > 0 )
        {
                // button changed?
                if( (event.type & ~JS_EVENT_INIT) == JS_EVENT_BUTTON )
                {
                        // set button flag
                        if( event.value )
                                button_flags |= (1 << event.number);
                        else
                                button_flags &= ~(1 << event.number);
                }
                // button changed?
                if( (event.type & ~JS_EVENT_INIT) == JS_EVENT_AXIS )
                {
                        // set axis
                        switch( event.number )
                        {
                                case 0: x = event.value; break;
                                case 1: y = event.value; break;
                                case 2: z = event.value; break;
                                case 3: axis_4 = event.value; break;
                                case 4: axis_5 = event.value; break;
                                case 5: axis_6 = event.value; break;
                        }
                }
        }
        // clear down pov
        pov_angle = 0;
        // all done
        return TRUE;
} // read_joystick()
	
	