int main( int argc, char *argv[] ) { DFBResult ret; /* Initialize DirectFB including command line parsing. */ ret = DirectFBInit( &argc, &argv ); if (ret) { DirectFBError( "DirectFBInit() failed", ret ); return -1; } /* Parse the command line. */ if (!parse_command_line( argc, argv )) return -2; DirectFBSetOption( "bg-none", NULL ); DirectFBSetOption( "no-cursor", NULL ); /* Create the super interface. */ ret = DirectFBCreate( &dfb ); if (ret) { DirectFBError( "DirectFBCreate() failed", ret ); return -3; } printf( "\n" ); enum_screens(); enum_input_devices(); enum_graphics(); /* Release the super interface. */ dfb->Release( dfb ); return EXIT_SUCCESS; }
int main( int argc, char *argv[] ) { DFBResult err; DFBSurfaceDescription sdsc; DFBFontDescription fdsc; const char *fontfile = FONTDIR"/decker.ttf"; int n; DeviceInfo *devices = NULL; DFBCHECK(DirectFBInit( &argc, &argv )); DirectFBSetOption ("bg-none", NULL); /* create the super interface */ DFBCHECK(DirectFBCreate( &dfb )); /* create a list of input devices */ dfb->EnumInputDevices( dfb, enum_input_device, &devices ); /* create an event buffer for all devices */ DFBCHECK(dfb->CreateInputEventBuffer( dfb, DICAPS_ALL, DFB_FALSE, &events )); /* set our cooperative level to DFSCL_FULLSCREEN for exclusive access to the primary layer */ dfb->SetCooperativeLevel( dfb, DFSCL_FULLSCREEN ); /* get the primary surface, i.e. the surface of the primary layer we have exclusive access to */ sdsc.flags = DSDESC_CAPS; sdsc.caps = DSCAPS_PRIMARY | DSCAPS_DOUBLE; DFBCHECK(dfb->CreateSurface( dfb, &sdsc, &primary )); primary->GetSize( primary, &screen_width, &screen_height ); mouse_x = screen_width / 2; mouse_y = screen_height / 2; fdsc.flags = DFDESC_HEIGHT; fdsc.height = screen_width / 30; DFBCHECK(dfb->CreateFont( dfb, fontfile, &fdsc, &font_small )); fdsc.height = screen_width / 20; DFBCHECK(dfb->CreateFont( dfb, fontfile, &fdsc, &font_normal )); fdsc.height = screen_width / 10; DFBCHECK(dfb->CreateFont( dfb, fontfile, &fdsc, &font_large )); primary->Clear( primary, 0, 0, 0, 0 ); primary->SetFont( primary, font_normal ); primary->SetColor( primary, 0x60, 0x60, 0x60, 0xFF ); primary->DrawString( primary, "Press any key to continue.", -1, screen_width/2, screen_height/2, DSTF_CENTER ); primary->Flip( primary, NULL, 0 ); keys_image = load_image( IMGDIR "/gnu-keys.png" ); mouse_image = load_image( IMGDIR "/gnome-mouse.png" ); if (events->WaitForEventWithTimeout( events, 10, 0 ) == DFB_TIMEOUT) { primary->Clear( primary, 0, 0, 0, 0 ); primary->DrawString( primary, "Timed out.", -1, screen_width/2, screen_height/2, DSTF_CENTER ); primary->Flip( primary, NULL, 0 ); primary->Clear( primary, 0, 0, 0, 0 ); sleep( 1 ); } else { DFBInputDeviceKeySymbol last_symbol = DIKS_NULL; while (1) { DFBInputEvent evt; while (events->GetEvent( events, DFB_EVENT(&evt) ) == DFB_OK) { const char *device_name; DFBInputDeviceTypeFlags device_type; primary->Clear( primary, 0, 0, 0, 0 ); device_name = get_device_name( devices, evt.device_id ); device_type = get_device_type( devices, evt.device_id ); show_event( device_name, device_type, &evt ); primary->Flip( primary, NULL, 0 ); } if (evt.type == DIET_KEYRELEASE) { if ((last_symbol == DIKS_ESCAPE || last_symbol == DIKS_EXIT) && (evt.key_symbol == DIKS_ESCAPE || evt.key_symbol == DIKS_EXIT)) break; last_symbol = evt.key_symbol; } events->WaitForEvent( events ); } } while (devices) { DeviceInfo *next = devices->next; free( devices ); devices = next; } /* release our interfaces to shutdown DirectFB */ if (keys_image) keys_image->Release( keys_image ); if (mouse_image) mouse_image->Release( mouse_image ); font_small->Release( font_small ); font_normal->Release( font_normal ); font_large->Release( font_large ); primary->Release( primary ); events->Release( events ); dfb->Release( dfb ); return 0; }
static void stHelper_setDirectFBMode(int width, int height) { char mode[MAX_GRAPHICS_MODE_STRING]; snprintf(mode, sizeof(mode), "%dx%d", width, height); DirectFBSetOption("mode", mode); }
void DirectFBVid_InitAndCreateSurface(DirectFBVidCtx *ctx, u32 window_mode) { DFBResult err; DFBSurfaceDescription dsc; DFBSurfacePixelFormat dfbpf; DeviceInfo *devices = NULL; //fake arguments and DirectFBInit() { int i, argc=2, argc_ro=2; char **argv = malloc(argc*sizeof(char*)); char *argv_ro[2]; //http://directfb.org/wiki/index.php/Configuring_DirectFB argv_ro[0]=argv[0]=strdup("gpac"); // graphis system used is X11 if (window_mode == WINDOW_SDL) { argv_ro[1]=argv[1]=strdup("--dfb:system=sdl"); } else { argv_ro[1]=argv[1]=strdup("--dfb:system=x11"); } // screen resolution 640x480 //~ argv_ro[2]=argv[2]=strdup("--dfb:mode=640x480"); //~ argv_ro[2]=argv[2]=strdup(""); /* create the super interface */ DFBCHECK(DirectFBInit(&argc, &argv)); for (i=0; i<argc_ro; i++) free(argv_ro[i]); free(argv); } // disable background handling DFBCHECK(DirectFBSetOption ("bg-none", NULL)); // disable layers DFBCHECK(DirectFBSetOption ("no-init-layer", NULL)); /* create the surface */ DFBCHECK(DirectFBCreate( &(ctx->dfb) )); /* create a list of input devices */ ctx->dfb->EnumInputDevices(ctx->dfb, enum_input_device, &devices ); if (devices->desc.type & DIDTF_JOYSTICK) { // for mouse DFBCHECK(ctx->dfb->GetInputDevice(ctx->dfb, devices->device_id, &(ctx->mouse))); } /* create an event buffer for all devices */ DFBCHECK(ctx->dfb->CreateInputEventBuffer(ctx->dfb, DICAPS_KEYS, DFB_FALSE, &(ctx->events) )); /* Set the cooperative level */ DFBCHECK(ctx->dfb->SetCooperativeLevel( ctx->dfb, DFSCL_FULLSCREEN )); /* Get the primary surface, i.e. the surface of the primary layer. */ // capabilities field is valid dsc.flags = DSDESC_CAPS; // primary, double-buffered surface dsc.caps = DSCAPS_PRIMARY | DSCAPS_DOUBLE; // if using system memory, data is permanently stored in this memory (no video memory allocation) if (ctx->use_systems_memory) dsc.caps |= DSCAPS_SYSTEMONLY; DFBCHECK(ctx->dfb->CreateSurface( ctx->dfb, &dsc, &(ctx->primary) )); // fetch pixel format ctx->primary->GetPixelFormat( ctx->primary, &dfbpf ); // translate DirectFB pixel format to GPAC ctx->pixel_format = DirectFBVid_TranslatePixelFormatToGPAC(dfbpf); // surface width and height in pixel ctx->primary->GetSize( ctx->primary, &(ctx->width), &(ctx->height) ); ctx->primary->Clear( ctx->primary, 0, 0, 0, 0xFF); }
static int DirectFB_VideoInit(_THIS) { IDirectFB *dfb = NULL; DFB_DeviceData *devdata = NULL; char *stemp; DFBResult ret; SDL_DFB_CALLOC(devdata, 1, sizeof(*devdata)); SDL_DFB_CHECKERR(DirectFBInit(NULL, NULL)); /* avoid switching to the framebuffer when we * are running X11 */ stemp = SDL_getenv(DFBENV_USE_X11_CHECK); if (stemp) ret = atoi(stemp); else ret = 1; if (ret) { if (SDL_getenv("DISPLAY")) DirectFBSetOption("system", "x11"); else DirectFBSetOption("disable-module", "x11input"); } devdata->use_linux_input = 1; /* default: on */ stemp = SDL_getenv(DFBENV_USE_LINUX_INPUT); if (stemp) devdata->use_linux_input = atoi(stemp); if (!devdata->use_linux_input) DirectFBSetOption("disable-module", "linux_input"); SDL_DFB_CHECKERR(DirectFBCreate(&dfb)); DirectFB_DeviceInformation(dfb); devdata->use_yuv_underlays = 0; /* default: off */ stemp = SDL_getenv(DFBENV_USE_YUV_UNDERLAY); if (stemp) devdata->use_yuv_underlays = atoi(stemp); /* Create global Eventbuffer for axis events */ if (devdata->use_linux_input) { SDL_DFB_CHECKERR(dfb->CreateInputEventBuffer(dfb, DICAPS_ALL, DFB_TRUE, &devdata->events)); } else { SDL_DFB_CHECKERR(dfb->CreateInputEventBuffer(dfb, DICAPS_AXES /*DICAPS_ALL */ , DFB_TRUE, &devdata->events)); } devdata->initialized = 1; /* simple window manager support */ stemp = SDL_getenv(DFBENV_USE_WM); if (stemp) devdata->has_own_wm = atoi(stemp); else devdata->has_own_wm = 0; devdata->dfb = dfb; devdata->firstwin = NULL; _this->driverdata = devdata; DirectFB_InitModes(_this); #if SDL_DIRECTFB_OPENGL DirectFB_GL_Initialize(_this); #endif DirectFB_AddRenderDriver(_this); DirectFB_InitMouse(_this); DirectFB_InitKeyboard(_this); return 0; error: SDL_DFB_FREE(devdata); SDL_DFB_RELEASE(dfb); return -1; }
static int DirectFB_VideoInit(_THIS) { IDirectFB *dfb = NULL; DFB_DeviceData *devdata = NULL; DFBResult ret; SDL_DFB_ALLOC_CLEAR(devdata, sizeof(*devdata)); SDL_DFB_CHECKERR(DirectFBInit(NULL, NULL)); /* avoid switching to the framebuffer when we * are running X11 */ ret = readBoolEnv(DFBENV_USE_X11_CHECK , 1); if (ret) { if (SDL_getenv("DISPLAY")) DirectFBSetOption("system", "x11"); else DirectFBSetOption("disable-module", "x11input"); } /* FIXME: Reenable as default once multi kbd/mouse interface is sorted out */ devdata->use_linux_input = readBoolEnv(DFBENV_USE_LINUX_INPUT, 0); /* default: on */ if (!devdata->use_linux_input) { SDL_DFB_LOG("Disabling linux input\n"); DirectFBSetOption("disable-module", "linux_input"); } SDL_DFB_CHECKERR(DirectFBCreate(&dfb)); DirectFB_DeviceInformation(dfb); devdata->use_yuv_underlays = readBoolEnv(DFBENV_USE_YUV_UNDERLAY, 0); /* default: off */ devdata->use_yuv_direct = readBoolEnv(DFBENV_USE_YUV_DIRECT, 0); /* default is off! */ /* Create global Eventbuffer for axis events */ if (devdata->use_linux_input) { SDL_DFB_CHECKERR(dfb->CreateInputEventBuffer(dfb, DICAPS_ALL, DFB_TRUE, &devdata->events)); } else { SDL_DFB_CHECKERR(dfb->CreateInputEventBuffer(dfb, DICAPS_AXES /* DICAPS_ALL */ , DFB_TRUE, &devdata->events)); } /* simple window manager support */ devdata->has_own_wm = readBoolEnv(DFBENV_USE_WM, 0); devdata->initialized = 1; devdata->dfb = dfb; devdata->firstwin = NULL; devdata->grabbed_window = NULL; _this->driverdata = devdata; DirectFB_InitModes(_this); #if SDL_DIRECTFB_OPENGL DirectFB_GL_Initialize(_this); #endif DirectFB_InitMouse(_this); DirectFB_InitKeyboard(_this); return 0; error: SDL_DFB_FREE(devdata); SDL_DFB_RELEASE(dfb); return -1; }
void Renderer::setVideoMode(int videoMode) { int full_width; int full_height; char dfb_mode[32]; char * dtv_signal = NULL; char * dtv_tv_standard = NULL; char * dtv_connector = NULL; char * component_signal = NULL; char * component_tv_standard = NULL; char * component_connector = NULL; char * analog_signal = NULL; char * analog_tv_standard = NULL; char * analog_connector = NULL; debug("Set video mode: %d\n", videoMode); switch (videoMode) { #if 0 case (0): { debug("Mode: Auto\n"); //! \todo How should this be implemented? } break; #endif case (1): { debug("Mode: Composite NTSC\n"); full_width = 720; full_height = 480; analog_signal = "ntsc"; analog_tv_standard = "ntsc"; analog_connector = "yc"; // or scart ? } break; case (2): { debug("Mode: Composite PAL\n"); full_width = 720; full_height = 576; analog_signal = "pal"; analog_tv_standard = "pal"; analog_connector = "yc"; // or scart ? } break; case (3): { debug("Mode: Component NTSC 480i 60Hz\n"); full_width = 720; full_height = 480; component_signal = "edtv"; // is 480 ntsc / 576 pal component_tv_standard = "hdtv60"; component_connector = "ycrcb"; } break; case (4): { debug("Mode: Component PAL 576i 50Hz\n"); full_width = 720; full_height = 576; component_signal = "edtv"; // is 480 ntsc / 576 pal component_tv_standard = "hdtv50"; component_connector = "ycrcb"; } break; case (5): { debug("Mode: Component 480p 60Hz\n"); full_width = 720; full_height = 480; //! \todo How to force 480p? component_signal = "edtv"; component_tv_standard = "hdtv60"; component_connector = "ycrcb"; } break; case (6): { debug("Mode: Component 720p 60Hz\n"); full_width = 1280; full_height = 720; component_signal = "720p"; component_tv_standard = "hdtv60"; component_connector = "ycrcb"; } break; case (7): { debug("Mode: Component 1080p 60Hz\n"); full_width = 1920; full_height = 1080; component_signal = "1080p"; component_tv_standard = "hdtv60"; component_connector = "ycrcb"; } break; case (8): { debug("Mode: Component 1080i 60Hz\n"); full_width = 1920; full_height = 1080; component_signal = "1080i"; component_tv_standard = "hdtv60"; component_connector = "ycrcb"; } break; #if 0 case (9): { debug("Mode: HDMI 480p 60Hz\n"); //! \todo Illegal mode?!? Not supported by DFB? full_width = 720; full_height = 480; } break; #endif case (10): { debug("Mode: HDMI 720p 60Hz\n"); full_width = 1280; full_height = 720; dtv_signal = "720p"; dtv_tv_standard = "hdtv60"; dtv_connector = "hdmi"; } break; case (11): { debug("Mode: Component 1080p 24Hz\n"); full_width = 1920; full_height = 1080; dtv_signal = "1080p24"; dtv_tv_standard = "hdtv60"; // should this also be set? dtv_connector = "hdmi"; } break; case (13): { debug("Mode: Component 720p 50Hz\n"); full_width = 1280; full_height = 720; component_signal = "720p"; component_tv_standard = "hdtv50"; component_connector = "ycrcb"; } break; case (14): { debug("Mode: Component 1080p 50Hz\n"); full_width = 1920; full_height = 1080; component_signal = "1080p"; component_tv_standard = "hdtv50"; component_connector = "ycrcb"; } break; case (15): { debug("Mode: Component 1080i 50Hz\n"); full_width = 1920; full_height = 1080; component_signal = "1080i"; component_tv_standard = "hdtv50"; component_connector = "ycrcb"; } break; case (16): { debug("Mode: HDMI 720p 50Hz\n"); full_width = 1280; full_height = 720; dtv_signal = "720p"; dtv_tv_standard = "hdtv50"; dtv_connector = "hdmi"; } break; case (18): { debug("Mode: HDMI 1080p 50Hz\n"); full_width = 1920; full_height = 1080; dtv_signal = "1080p"; dtv_tv_standard = "hdtv50"; dtv_connector = "hdmi"; } break; case (29): { debug("Mode: HDMI 1080p 60Hz\n"); full_width = 1920; full_height = 1080; dtv_signal = "1080p"; dtv_tv_standard = "hdtv60"; dtv_connector = "hdmi"; } break; case (30): { debug("Mode: Component 576p 50Hz\n"); full_width = 720; full_height = 576; //! \todo How to force 576p? component_signal = "edtv"; component_tv_standard = "hdtv50"; component_connector = "ycrcb"; } break; case (31): { debug("Mode: HDMI 576p 50Hz\n"); full_width = 720; full_height = 576; //! \todo Should EDID be used to configure special resolutions? dtv_signal = "edid"; dtv_tv_standard = "hdtv50"; dtv_connector = "hdmi"; } break; case (32): { debug("Mode: HDMI 1080i 60Hz\n"); full_width = 1920; full_height = 1080; dtv_signal = "1080i"; dtv_tv_standard = "hdtv60"; dtv_connector = "hdmi"; } break; default: { fprintf(stderr, "Unsupported video mode: %d!\n", videoMode); return; } break; } // Set resolution (mode) snprintf(dfb_mode, sizeof(dfb_mode), "%dx%d", full_width, full_height); if (DirectFBSetOption("mode", dfb_mode) != DFB_OK) { fprintf(stderr, "Error setting mode: %s\n", dfb_mode); return; } // Set which signals should be enabled // dtv if (dtv_signal) { if (DirectFBSetOption ("dtv-signal", dtv_signal) != DFB_OK) { fprintf(stderr, "Error setting dtv-signal: %s\n", dtv_signal); return; } if (DirectFBSetOption ("dtv-tv-standard", dtv_tv_standard) != DFB_OK) { fprintf(stderr, "Error setting dtv-tv-standard: %s\n", dtv_tv_standard); return; } if (DirectFBSetOption ("dtv-connector", dtv_connector) != DFB_OK) { fprintf(stderr, "Error setting dtv-connector: %s\n", dtv_connector); return; } } else { // Disable dtv signal if (DirectFBSetOption ("dtv-signal", "none") != DFB_OK) { fprintf(stderr, "Error disabling dtv-signal\n"); return; } } // component if (component_signal) { if (DirectFBSetOption ("component-signal", component_signal) != DFB_OK) { fprintf(stderr, "Error setting component-signal: %s\n", component_signal); return; } if (DirectFBSetOption ("component-tv-standard", component_tv_standard) != DFB_OK) { fprintf(stderr, "Error setting component-tv-standard: %s\n", component_tv_standard); return; } if (DirectFBSetOption ("component-connector", component_connector) != DFB_OK) { fprintf(stderr, "Error setting component-connector: %s\n", component_connector); return; } } else { // Disable component signal if (DirectFBSetOption ("component-signal", "none") != DFB_OK) { fprintf(stderr, "Error disabling component-signal\n"); return; } } // analog if (analog_signal) { if (DirectFBSetOption ("analog-signal", analog_signal) != DFB_OK) { fprintf(stderr, "Error setting analog-signal: %s\n", analog_signal); return; } if (DirectFBSetOption ("analog-tv-standard", analog_tv_standard) != DFB_OK) { fprintf(stderr, "Error setting analog-tv-standard: %s\n", analog_tv_standard); return; } if (DirectFBSetOption ("analog-connector", analog_connector) != DFB_OK) { fprintf(stderr, "Error setting analog-connector: %s\n", analog_connector); return; } } else { // Disable component signal if (DirectFBSetOption ("analog-signal", "none") != DFB_OK) { fprintf(stderr, "Error disabling analog-signal\n"); return; } } }