static void joystick_handle_event( JoystickData *data, struct js_event jse ) { DFBInputEvent event; switch (jse.type) { case JS_EVENT_BUTTON: event.type = (jse.value ? DIET_BUTTONPRESS : DIET_BUTTONRELEASE); event.flags = DIEF_NONE; /* button is always valid */ event.button = jse.number; break; case JS_EVENT_AXIS: event.type = DIET_AXISMOTION; event.flags = DIEF_AXISABS; event.axis = jse.number; event.axisabs = jse.value; break; case JS_EVENT_INIT: case JS_EVENT_INIT | JS_EVENT_BUTTON: case JS_EVENT_INIT | JS_EVENT_AXIS: D_ONCE( "Joystick sends JS_EVENT_INIT events, " \ "make sure it has been calibrated using 'jscal -c'\n"); return; break; default: D_PERROR ("unknown joystick event type\n"); return; } dfb_input_dispatch( data->device, &event ); }
static inline void savage3D_validate_color( Savage3DDriverData *sdrv, Savage3DDeviceData *sdev, CardState *state ) { if (sdev->v_color) return; savage3D_waitfifo( sdrv, sdev, 2 ); BCI_SEND( BCI_CMD_NOP | BCI_CMD_SEND_COLOR ); switch (state->destination->config.format) { case DSPF_A8: BCI_SEND( state->color.a ); break; case DSPF_ARGB1555: BCI_SEND( PIXEL_ARGB1555(state->color.a, state->color.r, state->color.g, state->color.b) ); break; case DSPF_RGB16: BCI_SEND( PIXEL_RGB16(state->color.r, state->color.g, state->color.b) ); break; case DSPF_RGB32: BCI_SEND( PIXEL_RGB32(state->color.r, state->color.g, state->color.b) ); break; case DSPF_ARGB: BCI_SEND( PIXEL_ARGB(state->color.a, state->color.r, state->color.g, state->color.b) ); break; default: D_ONCE( "unsupported destination format" ); break; } sdev->v_color = 1; }
static ReactionResult foo_channel_listener( const void *msg_data, void *ctx ) { const UniqueInputEvent *event = msg_data; UniqueContext *context = ctx; (void) context; D_ASSERT( event != NULL ); D_MAGIC_ASSERT( context, UniqueContext ); D_DEBUG_AT( UniQuE_TestFoo, "foo_channel_listener( %p, %p )\n", event, context ); switch (event->type) { case UIET_MOTION: //dispatch_motion( window, event ); break; case UIET_BUTTON: //dispatch_button( window, event ); break; case UIET_WHEEL: //dispatch_wheel( window, event ); break; case UIET_KEY: //dispatch_key( window, event ); break; case UIET_CHANNEL: //dispatch_channel( window, event ); break; default: D_ONCE( "unknown event type" ); break; } return RS_OK; }
DFBResult dfb_core_destroy( CoreDFB *core, bool emergency ) { D_MAGIC_ASSERT( core, CoreDFB ); D_ASSERT( core->refs > 0 ); D_ASSERT( core == core_dfb ); D_DEBUG_AT( DirectFB_Core, "%s...\n", __FUNCTION__ ); if (!emergency) { pthread_mutex_lock( &core_dfb_lock ); if (--core->refs) { pthread_mutex_unlock( &core_dfb_lock ); return DFB_OK; } } dfb_font_manager_destroy( core->font_manager ); if (core->signal_handler) direct_signal_handler_remove( core->signal_handler ); if (core->cleanup_handler) direct_cleanup_handler_remove( core->cleanup_handler ); if (core->master) { if (emergency) { fusion_kill( core->world, 0, SIGKILL, 1000 ); } else { fusion_kill( core->world, 0, SIGTERM, 5000 ); fusion_kill( core->world, 0, SIGKILL, 2000 ); } } dfb_core_process_cleanups( core, emergency ); while (fusion_arena_exit( core->arena, dfb_core_arena_shutdown, core->master ? NULL : dfb_core_arena_leave, core, emergency, NULL ) == DR_BUSY) { D_ONCE( "waiting for DirectFB slaves to terminate" ); direct_thread_sleep( 100000 ); } fusion_exit( core->world, emergency ); if (!emergency) direct_thread_remove_init_handler( core->init_handler ); D_MAGIC_CLEAR( core ); D_FREE( core ); core_dfb = NULL; if (!emergency) { pthread_mutex_unlock( &core_dfb_lock ); direct_shutdown(); } return DFB_OK; }
static DFBResult update_screen( DFBX11 *x11, const DFBRectangle *clip, CoreSurfaceBufferLock *lock, XWindow *xw ) { void *dst; void *src; unsigned int offset = 0; XImage *ximage; CoreSurface *surface; CoreSurfaceAllocation *allocation; DFBX11Shared *shared; DFBRectangle rect; bool direct = false; D_ASSERT( x11 != NULL ); DFB_RECTANGLE_ASSERT( clip ); D_DEBUG_AT( X11_Update, "%s( %4d,%4d-%4dx%4d )\n", __FUNCTION__, DFB_RECTANGLE_VALS( clip ) ); CORE_SURFACE_BUFFER_LOCK_ASSERT( lock ); shared = x11->shared; D_ASSERT( shared != NULL ); XLockDisplay( x11->display ); if (!xw) { XUnlockDisplay( x11->display ); return DFB_OK; } allocation = lock->allocation; CORE_SURFACE_ALLOCATION_ASSERT( allocation ); surface = allocation->surface; D_ASSERT( surface != NULL ); rect.x = rect.y = 0; rect.w = xw->width; rect.h = xw->height; if (!dfb_rectangle_intersect( &rect, clip )) { XUnlockDisplay( x11->display ); return DFB_OK; } D_DEBUG_AT( X11_Update, " -> %4d,%4d-%4dx%4d\n", DFB_RECTANGLE_VALS( &rect ) ); #ifdef USE_GLX /* Check for GLX allocation... */ if (allocation->pool == shared->glx_pool && lock->handle) { LocalPixmap *pixmap = lock->handle; D_MAGIC_ASSERT( pixmap, LocalPixmap ); /* ...and just call SwapBuffers... */ //D_DEBUG_AT( X11_Update, " -> Calling glXSwapBuffers( 0x%lx )...\n", alloc->drawable ); //glXSwapBuffers( x11->display, alloc->drawable ); D_DEBUG_AT( X11_Update, " -> Copying from GLXPixmap...\n" ); glXWaitGL(); XCopyArea( x11->display, pixmap->pixmap, xw->window, xw->gc, rect.x, rect.y, rect.w, rect.h, rect.x, rect.y ); glXWaitX(); XUnlockDisplay( x11->display ); return DFB_OK; } #endif /* Check for our special native allocation... */ if (allocation->pool == shared->x11image_pool && lock->handle) { x11Image *image = lock->handle; D_MAGIC_ASSERT( image, x11Image ); /* ...and directly XShmPutImage from that. */ ximage = image->ximage; direct = true; } else { /* ...or copy or convert into XShmImage or XImage allocated with the XWindow. */ ximage = xw->ximage; offset = xw->ximage_offset; xw->ximage_offset = (offset ? 0 : ximage->height / 2); /* make sure the 16-bit input formats are properly 2-pixel-clipped */ switch (surface->config.format) { case DSPF_I420: case DSPF_YV12: case DSPF_NV12: case DSPF_NV21: if (rect.y & 1) { rect.y--; rect.h++; } /* fall through */ case DSPF_YUY2: case DSPF_UYVY: case DSPF_NV16: if (rect.x & 1) { rect.x--; rect.w++; } default: /* no action */ break; } dst = xw->virtualscreen + rect.x * xw->bpp + (rect.y + offset) * ximage->bytes_per_line; src = lock->addr + DFB_BYTES_PER_LINE( surface->config.format, rect.x ) + rect.y * lock->pitch; switch (xw->depth) { case 32: dfb_convert_to_argb( surface->config.format, src, lock->pitch, surface->config.size.h, dst, ximage->bytes_per_line, rect.w, rect.h ); break; case 24: dfb_convert_to_rgb32( surface->config.format, src, lock->pitch, surface->config.size.h, dst, ximage->bytes_per_line, rect.w, rect.h ); break; case 16: if (surface->config.format == DSPF_LUT8) { int width = rect.w; int height = rect.h; const u8 *src8 = src; u16 *dst16 = dst; CorePalette *palette = surface->palette; int x; while (height--) { for (x=0; x<width; x++) { DFBColor color = palette->entries[src8[x]]; dst16[x] = PIXEL_RGB16( color.r, color.g, color.b ); } src8 += lock->pitch; dst16 += ximage->bytes_per_line / 2; } } else { dfb_convert_to_rgb16( surface->config.format, src, lock->pitch, surface->config.size.h, dst, ximage->bytes_per_line, rect.w, rect.h ); } break; case 15: dfb_convert_to_rgb555( surface->config.format, src, lock->pitch, surface->config.size.h, dst, ximage->bytes_per_line, rect.w, rect.h ); break; default: D_ONCE( "unsupported depth %d", xw->depth ); } } D_ASSERT( ximage != NULL ); /* Wait for previous data to be processed... */ XSync( x11->display, False ); /* ...and immediately queue or send the next! */ if (x11->use_shm) { /* Just queue the command, it's XShm :) */ XShmPutImage( xw->display, xw->window, xw->gc, ximage, rect.x, rect.y + offset, rect.x, rect.y, rect.w, rect.h, False ); /* Make sure the queue has really happened! */ XFlush( x11->display ); } else /* Initiate transfer of buffer... */ XPutImage( xw->display, xw->window, xw->gc, ximage, rect.x, rect.y + offset, rect.x, rect.y, rect.w, rect.h ); /* Wait for display if single buffered and not converted... */ if (direct && !(surface->config.caps & DSCAPS_FLIPPING)) XSync( x11->display, False ); XUnlockDisplay( x11->display ); return DFB_OK; }
static ReactionResult foo_channel_listener( const void *msg_data, void *ctx ) { const UniqueInputEvent *event = msg_data; UniqueContext *context = ctx; CoreLayerRegion *region; StretRegion *stret; WMShared *shared; static UniqueWindow *window; (void) context; D_ASSERT( event != NULL ); D_MAGIC_ASSERT( context, UniqueContext ); D_DEBUG_AT( UniQuE_TestFoo, "foo_channel_listener( %p, %p )\n", event, context ); region = context->region; D_ASSERT( region != NULL ); D_ASSERT( region->context != NULL ); shared = context->shared; D_MAGIC_ASSERT( shared, WMShared ); dfb_layer_context_lock( region->context ); switch (event->type) { case UIET_MOTION: case UIET_BUTTON: /* FIXME: This is a workaround because of the global input channel used for all windows. */ stret = stret_region_at( context->root, event->pointer.x, event->pointer.y, SRF_INPUT, shared->region_classes[URCI_FOO] ); if (stret) window = stret->data; else if (event->type == UIET_BUTTON && !event->pointer.buttons) window = NULL; if (window) { D_MAGIC_ASSERT( window, UniqueWindow ); if (event->type == UIET_MOTION) dispatch_motion( window, &event->pointer ); else dispatch_button( window, &event->pointer ); } break; case UIET_WHEEL: break; case UIET_KEY: break; case UIET_CHANNEL: break; default: D_ONCE( "unknown event type" ); break; } dfb_layer_context_unlock( region->context ); return RS_OK; }