Lines Matching refs:joy

227 void fgPlatformJoystickRawRead( SFG_Joystick* joy, int* buttons, float* axes )  in fgPlatformJoystickRawRead()  argument
234 if ( joy->pJoystick.os->is_analog ) in fgPlatformJoystickRawRead()
236 …int status = read ( joy->pJoystick.os->fd, &joy->pJoystick.os->ajs, sizeof(joy->pJoystick.os->ajs)… in fgPlatformJoystickRawRead()
237 if ( status != sizeof(joy->pJoystick.os->ajs) ) { in fgPlatformJoystickRawRead()
238 perror ( joy->pJoystick.os->fname ); in fgPlatformJoystickRawRead()
239 joy->error = GL_TRUE; in fgPlatformJoystickRawRead()
243 … *buttons = ( joy->pJoystick.os->ajs.b1 ? 1 : 0 ) | ( joy->pJoystick.os->ajs.b2 ? 2 : 0 ); in fgPlatformJoystickRawRead()
247 axes[0] = (float) joy->pJoystick.os->ajs.x; in fgPlatformJoystickRawRead()
248 axes[1] = (float) joy->pJoystick.os->ajs.y; in fgPlatformJoystickRawRead()
255 …while ( ( len = read ( joy->pJoystick.os->fd, joy->pJoystick.os->hid_data_buf, joy->pJoystick.os->… in fgPlatformJoystickRawRead()
259 for ( h = joy->pJoystick.os->hids; h; h = h->next ) in fgPlatformJoystickRawRead()
261 int d = hid_get_data ( joy->pJoystick.os->hid_data_buf, h ); in fgPlatformJoystickRawRead()
269 for ( i = 0; i < joy->num_axes; i++ ) in fgPlatformJoystickRawRead()
270 if (joy->pJoystick.os->axes_usage[i] == usage) in fgPlatformJoystickRawRead()
276 joy->pJoystick.os->cache_axes[i] = (float)hatmap_x[d]; in fgPlatformJoystickRawRead()
277 joy->pJoystick.os->cache_axes[i + 1] = (float)hatmap_y[d]; in fgPlatformJoystickRawRead()
281 joy->pJoystick.os->cache_axes[i] = (float)d; in fgPlatformJoystickRawRead()
291 joy->pJoystick.os->cache_buttons |= (1 << ( usage - 1 )); in fgPlatformJoystickRawRead()
293 joy->pJoystick.os->cache_buttons &= ~(1 << ( usage - 1 )); in fgPlatformJoystickRawRead()
300 perror( joy->pJoystick.os->fname ); in fgPlatformJoystickRawRead()
301 joy->error = 1; in fgPlatformJoystickRawRead()
303 if ( buttons != NULL ) *buttons = joy->pJoystick.os->cache_buttons; in fgPlatformJoystickRawRead()
305 memcpy ( axes, joy->pJoystick.os->cache_axes, sizeof(float) * joy->num_axes ); in fgPlatformJoystickRawRead()
313 status = read ( joy->pJoystick.fd, &joy->pJoystick.js, sizeof(struct js_event) ); in fgPlatformJoystickRawRead()
321 *buttons = joy->pJoystick.tmp_buttons; in fgPlatformJoystickRawRead()
323 memcpy( axes, joy->pJoystick.tmp_axes, in fgPlatformJoystickRawRead()
324 sizeof( float ) * joy->num_axes ); in fgPlatformJoystickRawRead()
328 fgWarning ( "%s", joy->pJoystick.fname ); in fgPlatformJoystickRawRead()
329 joy->error = GL_TRUE; in fgPlatformJoystickRawRead()
333 switch ( joy->pJoystick.js.type & ~JS_EVENT_INIT ) in fgPlatformJoystickRawRead()
336 if( joy->pJoystick.js.value == 0 ) /* clear the flag */ in fgPlatformJoystickRawRead()
337 joy->pJoystick.tmp_buttons &= ~( 1 << joy->pJoystick.js.number ); in fgPlatformJoystickRawRead()
339 joy->pJoystick.tmp_buttons |= ( 1 << joy->pJoystick.js.number ); in fgPlatformJoystickRawRead()
343 if ( joy->pJoystick.js.number < joy->num_axes ) in fgPlatformJoystickRawRead()
345joy->pJoystick.tmp_axes[ joy->pJoystick.js.number ] = ( float )joy->pJoystick.js.value; in fgPlatformJoystickRawRead()
348 memcpy( axes, joy->pJoystick.tmp_axes, sizeof(float) * joy->num_axes ); in fgPlatformJoystickRawRead()
357 if ( buttons != NULL ) *buttons = joy->pJoystick.tmp_buttons; in fgPlatformJoystickRawRead()
359 memcpy ( axes, joy->pJoystick.tmp_axes, sizeof(float) * joy->num_axes ); in fgPlatformJoystickRawRead()
365 *buttons = joy->pJoystick.tmp_buttons; in fgPlatformJoystickRawRead()
369 status = read( joy->pJoystick.fd, &joy->pJoystick.js, JS_RETURN ); in fgPlatformJoystickRawRead()
373 fgWarning( "%s", joy->pJoystick.fname ); in fgPlatformJoystickRawRead()
374 joy->error = GL_TRUE; in fgPlatformJoystickRawRead()
380 …*buttons = ( joy->pJoystick.js.b1 ? 1 : 0 ) | ( joy->pJoystick.js.b2 ? 2 : 0 ); /* XXX Should not… in fgPlatformJoystickRawRead()
382 *buttons = joy->pJoystick.js.buttons; in fgPlatformJoystickRawRead()
387 axes[ 0 ] = (float) joy->pJoystick.js.x; in fgPlatformJoystickRawRead()
388 axes[ 1 ] = (float) joy->pJoystick.js.y; in fgPlatformJoystickRawRead()
394 void fgPlatformJoystickOpen( SFG_Joystick* joy ) in fgPlatformJoystickOpen() argument
412 joy->pJoystick.os->cache_axes[ i ] = 0.0f; in fgPlatformJoystickOpen()
414 joy->pJoystick.os->cache_buttons = 0; in fgPlatformJoystickOpen()
416 joy->pJoystick.os->fd = open( joy->pJoystick.os->fname, O_RDONLY | O_NONBLOCK); in fgPlatformJoystickOpen()
418 if( joy->pJoystick.os->fd < 0 && errno == EACCES ) in fgPlatformJoystickOpen()
419 fgWarning ( "%s exists but is not readable by you", joy->pJoystick.os->fname ); in fgPlatformJoystickOpen()
421 joy->error =( joy->pJoystick.os->fd < 0 ); in fgPlatformJoystickOpen()
423 if( joy->error ) in fgPlatformJoystickOpen()
426 joy->num_axes = 0; in fgPlatformJoystickOpen()
427 joy->num_buttons = 0; in fgPlatformJoystickOpen()
428 if( joy->pJoystick.os->is_analog ) in fgPlatformJoystickOpen()
437 joy->num_axes = 2; in fgPlatformJoystickOpen()
438 joy->num_buttons = 32; in fgPlatformJoystickOpen()
440 fgJoystickRawRead( joy, buttons, axes ); in fgPlatformJoystickOpen()
441 joy->error = axes[ 0 ] < -1000000000.0f; in fgPlatformJoystickOpen()
442 if( joy->error ) in fgPlatformJoystickOpen()
445 snprintf( joyfname, sizeof(joyfname), "%s/.joy%drc", getenv( "HOME" ), joy->id ); in fgPlatformJoystickOpen()
448 joy->error =( joyfile == NULL ); in fgPlatformJoystickOpen()
449 if( joy->error ) in fgPlatformJoystickOpen()
453 &joy->min[ 0 ], &joy->center[ 0 ], &joy->max[ 0 ], in fgPlatformJoystickOpen()
454 &joy->min[ 1 ], &joy->center[ 1 ], &joy->max[ 1 ] ); in fgPlatformJoystickOpen()
455 joy->error = noargs != 7 || in_no_axes != _JS_MAX_AXES; in fgPlatformJoystickOpen()
457 if( joy->error ) in fgPlatformJoystickOpen()
462 joy->dead_band[ i ] = 0.0f; in fgPlatformJoystickOpen()
463 joy->saturate [ i ] = 1.0f; in fgPlatformJoystickOpen()
470 if( ! fghJoystickInitializeHID( joy->pJoystick.os, &joy->num_axes, in fgPlatformJoystickOpen()
471 &joy->num_buttons ) ) in fgPlatformJoystickOpen()
473 close( joy->pJoystick.os->fd ); in fgPlatformJoystickOpen()
474 joy->error = GL_TRUE; in fgPlatformJoystickOpen()
478 cp = strrchr( joy->pJoystick.os->fname, '/' ); in fgPlatformJoystickOpen()
481 if( fghJoystickFindUSBdev( &cp[1], joy->name, sizeof( joy->name ) ) == in fgPlatformJoystickOpen()
483 strcpy( joy->name, &cp[1] ); in fgPlatformJoystickOpen()
486 if( joy->num_axes > _JS_MAX_AXES ) in fgPlatformJoystickOpen()
487 joy->num_axes = _JS_MAX_AXES; in fgPlatformJoystickOpen()
495 if( joy->pJoystick.os->axes_usage[ i ] == HUG_HAT_SWITCH ) in fgPlatformJoystickOpen()
497 joy->max [ i ] = 1.0f; in fgPlatformJoystickOpen()
498 joy->center[ i ] = 0.0f; in fgPlatformJoystickOpen()
499 joy->min [ i ] = -1.0f; in fgPlatformJoystickOpen()
503 joy->max [ i ] = 255.0f; in fgPlatformJoystickOpen()
504 joy->center[ i ] = 127.0f; in fgPlatformJoystickOpen()
505 joy->min [ i ] = 0.0f; in fgPlatformJoystickOpen()
508 joy->dead_band[ i ] = 0.0f; in fgPlatformJoystickOpen()
509 joy->saturate[ i ] = 1.0f; in fgPlatformJoystickOpen()
516 joy->num_axes = 2; in fgPlatformJoystickOpen()
517 joy->num_buttons = 32; in fgPlatformJoystickOpen()
521 joy->pJoystick.tmp_axes[ i ] = 0.0f; in fgPlatformJoystickOpen()
523 joy->pJoystick.tmp_buttons = 0; in fgPlatformJoystickOpen()
526 joy->pJoystick.fd = open( joy->pJoystick.fname, O_RDONLY ); in fgPlatformJoystickOpen()
528 joy->error =( joy->pJoystick.fd < 0 ); in fgPlatformJoystickOpen()
530 if( joy->error ) in fgPlatformJoystickOpen()
539 if(ioctl(joy->pJoystick.fd, JSIOCGAXES, &u) != -1) in fgPlatformJoystickOpen()
540 joy->num_axes = u; in fgPlatformJoystickOpen()
541 if(ioctl(joy->pJoystick.fd, JSIOCGBUTTONS, &u) != -1) in fgPlatformJoystickOpen()
542 joy->num_buttons = u; in fgPlatformJoystickOpen()
543 ioctl( joy->pJoystick.fd, JSIOCGNAME( sizeof( joy->name ) ), joy->name ); in fgPlatformJoystickOpen()
544 fcntl(joy->pJoystick.fd, F_SETFL, fcntl(joy->pJoystick.fd, F_GETFL) | O_NONBLOCK); in fgPlatformJoystickOpen()
560 fgJoystickRawRead( joy, NULL, joy->center ); in fgPlatformJoystickOpen()
562 } while( !joy->error && in fgPlatformJoystickOpen()
564 joy->center[ 0 ] == 512.0f && in fgPlatformJoystickOpen()
565 joy->center[ 1 ] == 512.0f ); in fgPlatformJoystickOpen()
568 joy->error = GL_TRUE; in fgPlatformJoystickOpen()
574 joy->max [ i ] = 32767.0f; in fgPlatformJoystickOpen()
575 joy->center[ i ] = 0.0f; in fgPlatformJoystickOpen()
576 joy->min [ i ] = -32767.0f; in fgPlatformJoystickOpen()
578 joy->max[ i ] = joy->center[ i ] * 2.0f; in fgPlatformJoystickOpen()
579 joy->min[ i ] = 0.0f; in fgPlatformJoystickOpen()
581 joy->dead_band[ i ] = 0.0f; in fgPlatformJoystickOpen()
582 joy->saturate [ i ] = 1.0f; in fgPlatformJoystickOpen()
587 void fgJoystickRawRead( SFG_Joystick* joy, int* buttons, float* axes ) in fgJoystickRawRead() argument
596 for( i = 0; i < joy->num_axes; i++ ) in fgJoystickRawRead()
599 if( joy->error ) in fgJoystickRawRead()
602 fgPlatformJoystickRawRead ( joy, buttons, axes ); in fgJoystickRawRead()