VBoxFB.cpp revision 273209ddea06daeb89a8dcc9c45e19ba14c89b8d
/** @file
*
* VBox frontends: Framebuffer (FB, DirectFB):
* main() routine.
*
* NOTE: this code has not been tested, so expect bugs. It is not part
* of a regular VirtualBox build.
*/
/*
* Copyright (C) 2006-2010 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
#include "VBoxFB.h"
#include "Framebuffer.h"
#include <getopt.h>
/**
* Globals
*/
int scaleGuest = 0;
videoMode fixedVideoMode = {0};
void showusage()
{
printf("\nThe following parameters are supported:\n"
"--startvm uuid start VM with UUID 'uuid'\n"
"--fixedres WxHxBPP always use fixed host resolution\n"
"--listhostmodes display list of supported host display modes and exit\n"
"--scale scale guest video mode to host video mode\n"
"--nodirectblit disable direct blitting, use intermediate framebuffer\n"
"--showlabel show VM name on top of the VM display\n");
}
/** entry point */
{
int c;
int listHostModes = 0;
int quit = 0;
{
};
printf("VirtualBox DirectFB GUI built %s %s\n"
for (;;)
{
if (c == -1)
break;
switch (c)
{
case 'h':
{
showusage();
exit(0);
break;
}
case 's':
{
// UUID as string, parse it
{
printf("Error, invalid UUID format given!\n");
showusage();
exit(-1);
}
break;
}
case 'f':
{
{
printf("Error, invalid resolution argument!\n");
showusage();
exit(-1);
}
useFixedVideoMode = 1;
break;
}
case 'l':
{
listHostModes = 1;
break;
}
case 'c':
{
scaleGuest = 1;
break;
}
default:
break;
}
}
// check if we got a UUID
if (!uuid)
{
printf("Error, no UUID given!\n");
showusage();
exit(-1);
}
/**
* XPCOM setup
*/
/*
* Note that we scope all nsCOMPtr variables in order to have all XPCOM
* objects automatically released before we call NS_ShutdownXPCOM at the
* end. This is an XPCOM requirement.
*/
{
{
exit(-1);
}
// register our component
if (!registrar)
{
printf("Error: could not query nsIComponentRegistrar interface!\n");
exit(-1);
}
/*
* Make sure the main event queue is created. This event queue is
* responsible for dispatching incoming XPCOM IPC messages. The main
* thread should run this event queue's loop during lengthy non-XPCOM
* operations to ensure messages from the VirtualBox server and other
* XPCOM IPC clients are processed. This use case doesn't perform such
* operations so it doesn't run the event loop.
*/
{
return -1;
}
/*
* Now XPCOM is ready and we can start to do real work.
* IVirtualBox is the root interface of VirtualBox and will be
* retrieved from the XPCOM component manager. We use the
* XPCOM provided smart pointer nsCOMPtr for all objects because
* that's very convenient and removes the need deal with reference
* counting and freeing.
*/
{
exit(-1);
}
{
exit(-1);
}
{
exit(-1);
}
// open session for this VM
{
printf("Error: given machine not found!\n");
exit(-1);
}
if (!machine)
{
printf("Error: given machine not found!\n");
exit(-1);
}
if (!console)
{
printf("Error: cannot get console!\n");
exit(-1);
}
if (!display)
{
printf("Error: could not get display object!\n");
exit(-1);
}
/**
* Init DirectFB
*/
int screen_width, screen_height;
// populate our structure of supported video modes
if (listHostModes)
{
printf("*****************************************************\n");
for (uint32_t i = 0; i < numVideoModes; i++)
{
printf("Mode %u: xres = %u, yres = %u, bpp = %u\n", i,
}
printf("Note: display modes with bpp < have been filtered out\n");
printf("*****************************************************\n");
goto Leave;
}
if (useFixedVideoMode)
{
// validate the fixed mode
if ((bestVideoMode == -1) ||
{
printf("Error: the specified fixed video mode is not available!\n");
exit(-1);
}
} else
{
if (initialVideoMode == -1)
{
printf("Error: initial video mode 640x480x16 is not available!\n");
exit(-1);
}
}
if (useFixedVideoMode)
{
} else
{
printf("Information: starting with default video mode %ux%ux%u\n",
}
// register our framebuffer
/**
* Start the VM execution thread
*/
/**
* Main event loop
*/
#define MAX_KEYEVENTS 10
int numKeyEvents;
while (!quit)
{
numKeyEvents = 0;
{
int mouseXDelta = 0;
int mouseYDelta = 0;
int mouseZDelta = 0;
{
#define QUEUEKEY(scan) keyEvents[numKeyEvents++] = scan | (event.type == DIET_KEYRELEASE ? 0x80 : 0x00)
case DIET_KEYPRESS:
case DIET_KEYRELEASE:
{
// @@@AH development hack to get out of it!
quit = 1;
if (numKeyEvents < MAX_KEYEVENTS)
{
//printf("%s: key_code: 0x%x\n", event.type == DIET_KEYPRESS ? "DIET_KEYPRESS" : "DIET_KEYRELEASE", event.key_code);
{
case DIKI_CONTROL_R:
QUEUEEXT();
QUEUEKEY(0x1d);
break;
case DIKI_INSERT:
QUEUEEXT();
QUEUEKEY(0x52);
break;
case DIKI_DELETE:
QUEUEEXT();
QUEUEKEY(0x53);
break;
case DIKI_HOME:
QUEUEEXT();
QUEUEKEY(0x47);
break;
case DIKI_END:
QUEUEEXT();
QUEUEKEY(0x4f);
break;
case DIKI_PAGE_UP:
QUEUEEXT();
QUEUEKEY(0x49);
break;
case DIKI_PAGE_DOWN:
QUEUEEXT();
QUEUEKEY(0x51);
break;
case DIKI_LEFT:
QUEUEEXT();
QUEUEKEY(0x4b);
break;
case DIKI_RIGHT:
QUEUEEXT();
QUEUEKEY(0x4d);
break;
case DIKI_UP:
QUEUEEXT();
QUEUEKEY(0x48);
break;
case DIKI_DOWN:
QUEUEEXT();
QUEUEKEY(0x50);
break;
case DIKI_KP_DIV:
QUEUEEXT();
QUEUEKEY(0x35);
break;
case DIKI_KP_ENTER:
QUEUEEXT();
QUEUEKEY(0x1c);
break;
case DIKI_PRINT:
// the break code is inverted!
{
QUEUEEXT();
QUEUEKEY(0x2a);
QUEUEEXT();
QUEUEKEY(0x37);
} else
{
QUEUEEXT();
QUEUEKEY(0x37);
QUEUEEXT();
QUEUEKEY(0x2a);
}
break;
case DIKI_PAUSE:
// This is a super weird key. No break code and a 6 byte
// combination.
{
QUEUEKEY(0xe1);
QUEUEKEY(0x1d);
QUEUEKEY(0x45);
QUEUEKEY(0xe1);
QUEUEKEY(0x9d);
QUEUEKEY(0xc5);
}
break;
case DIKI_META_L:
// the left Windows logo is a bit different
{
QUEUEEXT();
QUEUEKEYRAW(0x1f);
} else
{
QUEUEEXT();
QUEUEKEYRAW(0xf0);
QUEUEKEYRAW(0x1f);
}
break;
case DIKI_META_R:
// the right Windows logo is a bit different
{
QUEUEEXT();
QUEUEKEYRAW(0x27);
} else
{
QUEUEEXT();
QUEUEKEYRAW(0xf0);
QUEUEKEYRAW(0x27);
}
break;
case DIKI_SUPER_R:
// the popup menu is a bit different
{
QUEUEEXT();
QUEUEKEYRAW(0x2f);
} else
{
QUEUEEXT();
QUEUEKEYRAW(0xf0);
QUEUEKEYRAW(0x2f);
}
break;
default:
// check if we got a hardware scancode
{
// take the scancode from DirectFB as is
} else
{
// XXX need extra handling!
}
}
}
break;
}
case DIET_AXISMOTION:
{
{
case DIAI_X:
break;
case DIAI_Y:
break;
case DIAI_Z:
break;
default:
break;
}
// fall through
}
case DIET_BUTTONPRESS:
// fall through;
case DIET_BUTTONRELEASE:
{
int buttonState = 0;
break;
}
default:
break;
}
}
// did we get any keyboard events?
if (numKeyEvents > 0)
{
if (numKeyEvents > 1)
{
&codesStored);
} else
{
}
}
}
{
}
}
/*
* Perform the standard XPCOM shutdown procedure.
*/
return 0;
}