VBoxSDL.cpp revision 12e26793b1ea6a986b1c0cc3d573b9f1900b6372
c64777b77514bdc924249d2f9900be25079b0d84vboxsync * VBox frontends: VBoxSDL (simple frontend based on SDL):
c64777b77514bdc924249d2f9900be25079b0d84vboxsync * Main code
c626bd8465f241db74519c3c8dbe59ea620a9e34vboxsync * Copyright (C) 2006-2007 Sun Microsystems, Inc.
c64777b77514bdc924249d2f9900be25079b0d84vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
c64777b77514bdc924249d2f9900be25079b0d84vboxsync * available from http://www.virtualbox.org. This file is free software;
c64777b77514bdc924249d2f9900be25079b0d84vboxsync * you can redistribute it and/or modify it under the terms of the GNU
c64777b77514bdc924249d2f9900be25079b0d84vboxsync * General Public License (GPL) as published by the Free Software
c64777b77514bdc924249d2f9900be25079b0d84vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
c64777b77514bdc924249d2f9900be25079b0d84vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
c64777b77514bdc924249d2f9900be25079b0d84vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
c64777b77514bdc924249d2f9900be25079b0d84vboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
c64777b77514bdc924249d2f9900be25079b0d84vboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
c64777b77514bdc924249d2f9900be25079b0d84vboxsync * additional information or have any questions.
c64777b77514bdc924249d2f9900be25079b0d84vboxsync/*******************************************************************************
c64777b77514bdc924249d2f9900be25079b0d84vboxsync* Header Files *
c64777b77514bdc924249d2f9900be25079b0d84vboxsync*******************************************************************************/
c64777b77514bdc924249d2f9900be25079b0d84vboxsyncusing namespace com;
c64777b77514bdc924249d2f9900be25079b0d84vboxsync/* Xlib would re-define our enums */
c64777b77514bdc924249d2f9900be25079b0d84vboxsync/*******************************************************************************
c64777b77514bdc924249d2f9900be25079b0d84vboxsync* Defined Constants And Macros *
c64777b77514bdc924249d2f9900be25079b0d84vboxsync*******************************************************************************/
c64777b77514bdc924249d2f9900be25079b0d84vboxsync/** extra data key for the secure label */
c64777b77514bdc924249d2f9900be25079b0d84vboxsync#define VBOXSDL_SECURELABEL_EXTRADATA "VBoxSDL/SecureLabel"
c64777b77514bdc924249d2f9900be25079b0d84vboxsync/** label area height in pixels */
c64777b77514bdc924249d2f9900be25079b0d84vboxsync/** Enables the rawr[0|3], patm, and casm options. */
c64777b77514bdc924249d2f9900be25079b0d84vboxsync/*******************************************************************************
3942acfaf590eaef4740d7b8a5311bb91e2bed0dvboxsync* Structures and Typedefs *
c64777b77514bdc924249d2f9900be25079b0d84vboxsync*******************************************************************************/
9b828870d7acf28326746e3850098e579c590a44vboxsync/** Pointer shape change event data strucure */
6cac05f856d982151579a9d445a109960c2c07d2vboxsync PointerShapeChangeData (BOOL aVisible, BOOL aAlpha, ULONG aXHot, ULONG aYHot,
6cac05f856d982151579a9d445a109960c2c07d2vboxsync ULONG aWidth, ULONG aHeight, const uint8_t *aShape)
6cac05f856d982151579a9d445a109960c2c07d2vboxsync : visible (aVisible), alpha (aAlpha), xHot (aXHot), yHot (aYHot),
6cac05f856d982151579a9d445a109960c2c07d2vboxsync // make a copy of the shape
6cac05f856d982151579a9d445a109960c2c07d2vboxsync uint32_t shapeSize = ((((aWidth + 7) / 8) * aHeight + 3) & ~3) + aWidth * 4 * aHeight;
9b828870d7acf28326746e3850098e579c590a44vboxsync memcpy ((void *) shape, (void *) aShape, shapeSize);
6cac05f856d982151579a9d445a109960c2c07d2vboxsync/*******************************************************************************
6cac05f856d982151579a9d445a109960c2c07d2vboxsync* Internal Functions *
6cac05f856d982151579a9d445a109960c2c07d2vboxsync*******************************************************************************/
6cac05f856d982151579a9d445a109960c2c07d2vboxsyncstatic bool UseAbsoluteMouse(void);
6cac05f856d982151579a9d445a109960c2c07d2vboxsyncstatic void ResetKeys(void);
6cac05f856d982151579a9d445a109960c2c07d2vboxsyncstatic void InputGrabStart(void);
6cac05f856d982151579a9d445a109960c2c07d2vboxsyncstatic void InputGrabEnd(void);
6cac05f856d982151579a9d445a109960c2c07d2vboxsyncstatic void SendMouseEvent(int dz, int button, int down);
6cac05f856d982151579a9d445a109960c2c07d2vboxsyncstatic void UpdateTitlebar(TitlebarMode mode, uint32_t u32User = 0);
6cac05f856d982151579a9d445a109960c2c07d2vboxsyncstatic void SetPointerShape(const PointerShapeChangeData *data);
6cac05f856d982151579a9d445a109960c2c07d2vboxsyncstatic void HandleGuestCapsChanged(void);
6cac05f856d982151579a9d445a109960c2c07d2vboxsyncstatic int HandleHostKey(const SDL_KeyboardEvent *pEv);
6cac05f856d982151579a9d445a109960c2c07d2vboxsyncstatic Uint32 StartupTimer(Uint32 interval, void *param);
6cac05f856d982151579a9d445a109960c2c07d2vboxsyncstatic Uint32 ResizeTimer(Uint32 interval, void *param);
6cac05f856d982151579a9d445a109960c2c07d2vboxsyncstatic Uint32 QuitTimer(Uint32 interval, void *param);
6cac05f856d982151579a9d445a109960c2c07d2vboxsync/*******************************************************************************
6cac05f856d982151579a9d445a109960c2c07d2vboxsync* Global Variables *
6cac05f856d982151579a9d445a109960c2c07d2vboxsync*******************************************************************************/
6cac05f856d982151579a9d445a109960c2c07d2vboxsync// my mini kbd doesn't have RCTRL...
c64777b77514bdc924249d2f9900be25079b0d84vboxsyncstatic const char *gHostKeyDisabledCombinations = "";
c64777b77514bdc924249d2f9900be25079b0d84vboxsyncstatic const char *gpszPidFile;
c64777b77514bdc924249d2f9900be25079b0d84vboxsync/** modifier keypress status (scancode as index) */
9b828870d7acf28326746e3850098e579c590a44vboxsyncstatic volatile int32_t g_cNotifyUpdateEventsPending;
9b828870d7acf28326746e3850098e579c590a44vboxsync * Callback handler for VirtualBox events
c64777b77514bdc924249d2f9900be25079b0d84vboxsync delete this;
c64777b77514bdc924249d2f9900be25079b0d84vboxsync STDMETHOD(QueryInterface)(REFIID riid , void **ppObj)
c64777b77514bdc924249d2f9900be25079b0d84vboxsync STDMETHOD(OnMachineStateChange)(IN_GUID machineId, MachineState_T state)
c64777b77514bdc924249d2f9900be25079b0d84vboxsync STDMETHOD(OnExtraDataCanChange)(IN_GUID machineId, IN_BSTR key, IN_BSTR value,
c64777b77514bdc924249d2f9900be25079b0d84vboxsync /* we never disagree */
c64777b77514bdc924249d2f9900be25079b0d84vboxsync STDMETHOD(OnExtraDataChange)(IN_GUID machineId, IN_BSTR key, IN_BSTR value)
c64777b77514bdc924249d2f9900be25079b0d84vboxsync * check if we're interested in the message
c64777b77514bdc924249d2f9900be25079b0d84vboxsync if (keyString && keyString == VBOXSDL_SECURELABEL_EXTRADATA)
c64777b77514bdc924249d2f9900be25079b0d84vboxsync * Notify SDL thread of the string update
6cac05f856d982151579a9d445a109960c2c07d2vboxsync event.user.type = SDL_USER_EVENT_SECURELABEL_UPDATE;
6cac05f856d982151579a9d445a109960c2c07d2vboxsync#endif /* VBOX_SECURELABEL */
4ad0e04fb2a93fb4980de2644f7ccca9e8869083vboxsync STDMETHOD(OnMediaRegistered) (IN_GUID mediaId, DeviceType_T mediaType,
4ad0e04fb2a93fb4980de2644f7ccca9e8869083vboxsync STDMETHOD(OnMachineRegistered)(IN_GUID machineId, BOOL registered)
4ad0e04fb2a93fb4980de2644f7ccca9e8869083vboxsync STDMETHOD(OnSessionStateChange)(IN_GUID machineId, SessionState_T state)
4ad0e04fb2a93fb4980de2644f7ccca9e8869083vboxsync STDMETHOD(OnSnapshotTaken) (IN_GUID aMachineId, IN_GUID aSnapshotId)
4ad0e04fb2a93fb4980de2644f7ccca9e8869083vboxsync STDMETHOD(OnSnapshotDiscarded) (IN_GUID aMachineId, IN_GUID aSnapshotId)
4ad0e04fb2a93fb4980de2644f7ccca9e8869083vboxsync STDMETHOD(OnSnapshotChange) (IN_GUID aMachineId, IN_GUID aSnapshotId)
4ad0e04fb2a93fb4980de2644f7ccca9e8869083vboxsync STDMETHOD(OnGuestPropertyChange)(IN_GUID machineId, IN_BSTR key, IN_BSTR value, IN_BSTR flags)
6cac05f856d982151579a9d445a109960c2c07d2vboxsync * Callback handler for machine events
6cac05f856d982151579a9d445a109960c2c07d2vboxsync VBoxSDLConsoleCallback() : m_fIgnorePowerOffEvents(false)
6cac05f856d982151579a9d445a109960c2c07d2vboxsync delete this;
6cac05f856d982151579a9d445a109960c2c07d2vboxsync STDMETHOD(QueryInterface)(REFIID riid , void **ppObj)
6cac05f856d982151579a9d445a109960c2c07d2vboxsync STDMETHOD(OnMousePointerShapeChange) (BOOL visible, BOOL alpha, ULONG xHot, ULONG yHot,
c64777b77514bdc924249d2f9900be25079b0d84vboxsync data = new PointerShapeChangeData (visible, alpha, xHot, yHot, width, height,
c64777b77514bdc924249d2f9900be25079b0d84vboxsync STDMETHOD(OnMouseCapabilityChange)(BOOL supportsAbsolute, BOOL needsHostCursor)
c64777b77514bdc924249d2f9900be25079b0d84vboxsync LogFlow(("OnMouseCapabilityChange: supportsAbsolute = %d\n", supportsAbsolute));
c64777b77514bdc924249d2f9900be25079b0d84vboxsync event.user.type = SDL_USER_EVENT_GUEST_CAP_CHANGED;
c64777b77514bdc924249d2f9900be25079b0d84vboxsync STDMETHOD(OnKeyboardLedsChange)(BOOL fNumLock, BOOL fCapsLock, BOOL fScrollLock)
c64777b77514bdc924249d2f9900be25079b0d84vboxsync /* Don't bother the guest with NumLock scancodes if he doesn't set the NumLock LED */
c64777b77514bdc924249d2f9900be25079b0d84vboxsync STDMETHOD(OnStateChange)(MachineState_T machineState)
c64777b77514bdc924249d2f9900be25079b0d84vboxsync LogFlow(("OnStateChange: machineState = %d (%s)\n", machineState, GetStateName(machineState)));
c64777b77514bdc924249d2f9900be25079b0d84vboxsync || (machineState == MachineState_Saved && !m_fIgnorePowerOffEvents)
c64777b77514bdc924249d2f9900be25079b0d84vboxsync || (machineState == MachineState_PoweredOff && !m_fIgnorePowerOffEvents))
c64777b77514bdc924249d2f9900be25079b0d84vboxsync * We have to inform the SDL thread that the application has be terminated
c64777b77514bdc924249d2f9900be25079b0d84vboxsync event.user.code = machineState == MachineState_Aborted
c64777b77514bdc924249d2f9900be25079b0d84vboxsync * Inform the SDL thread to refresh the titlebar
c64777b77514bdc924249d2f9900be25079b0d84vboxsync STDMETHOD(OnNetworkAdapterChange) (INetworkAdapter *aNetworkAdapter)
c64777b77514bdc924249d2f9900be25079b0d84vboxsync STDMETHOD(OnSerialPortChange) (ISerialPort *aSerialPort)
c64777b77514bdc924249d2f9900be25079b0d84vboxsync STDMETHOD(OnParallelPortChange) (IParallelPort *aParallelPort)
c64777b77514bdc924249d2f9900be25079b0d84vboxsync STDMETHOD(OnUSBDeviceStateChange) (IUSBDevice *aDevice, BOOL aAttached,
3942acfaf590eaef4740d7b8a5311bb91e2bed0dvboxsync STDMETHOD(OnRuntimeError)(BOOL fFatal, IN_BSTR id, IN_BSTR message)
c64777b77514bdc924249d2f9900be25079b0d84vboxsync const char *pszType;
c64777b77514bdc924249d2f9900be25079b0d84vboxsync bool fPaused = machineState == MachineState_Paused;
ee2aeb0cd5535f38ee098713a9cebb74dc1c2e30vboxsync RTPrintf("\n%s: ** %lS **\n%lS\n%s\n", pszType, id, message,
c64777b77514bdc924249d2f9900be25079b0d84vboxsync fPaused ? "The VM was paused. Continue with HostKey + P after you solved the problem.\n" : "");
c64777b77514bdc924249d2f9900be25079b0d84vboxsync /* SDL feature not available on Quartz */
c64777b77514bdc924249d2f9900be25079b0d84vboxsync#endif /* !RT_OS_DARWIN */
c64777b77514bdc924249d2f9900be25079b0d84vboxsync static const char *GetStateName(MachineState_T machineState)
c64777b77514bdc924249d2f9900be25079b0d84vboxsync default: return "no idea";
c64777b77514bdc924249d2f9900be25079b0d84vboxsyncNS_IMPL_ISUPPORTS1_CI(VBoxSDLCallback, IVirtualBoxCallback)
3942acfaf590eaef4740d7b8a5311bb91e2bed0dvboxsyncNS_IMPL_ISUPPORTS1_CI(VBoxSDLConsoleCallback, IConsoleCallback)
c64777b77514bdc924249d2f9900be25079b0d84vboxsync#endif /* VBOX_WITH_XPCOM */
c64777b77514bdc924249d2f9900be25079b0d84vboxsync " -vm <id|name> Virtual machine to start, either UUID or name\n"
c64777b77514bdc924249d2f9900be25079b0d84vboxsync " -hda <file> Set temporary first hard disk to file\n"
37fb67be7d1d328213aeda3f56ab5aacd37416d1vboxsync " -fda <file> Set temporary first floppy disk to file\n"
3942acfaf590eaef4740d7b8a5311bb91e2bed0dvboxsync " -cdrom <file> Set temporary CDROM/DVD to file/device ('none' to unmount)\n"
c64777b77514bdc924249d2f9900be25079b0d84vboxsync " -boot <a|c|d|n> Set temporary boot device (a = floppy, c = 1st HD, d = DVD, n = network)\n"
3942acfaf590eaef4740d7b8a5311bb91e2bed0dvboxsync " -m <size> Set temporary memory size in megabytes\n"
42c1972c22e09797b4b24afbd0ec114ed076c37cvboxsync " -vram <size> Set temporary size of video memory in megabytes\n"
c64777b77514bdc924249d2f9900be25079b0d84vboxsync " -fullscreen Start VM in fullscreen mode\n"
c64777b77514bdc924249d2f9900be25079b0d84vboxsync " -fullscreenresize Resize the guest on fullscreen\n"
c1980cd3f410c88b8f92f464c56ed987a15f44c1vboxsync " -fixedmode <w> <h> <bpp> Use a fixed SDL video mode with given width, height and bits per pixel\n"
3942acfaf590eaef4740d7b8a5311bb91e2bed0dvboxsync " -nofstoggle Forbid switching to/from fullscreen mode\n"
3942acfaf590eaef4740d7b8a5311bb91e2bed0dvboxsync " -noresize Make the SDL frame non resizable\n"
3942acfaf590eaef4740d7b8a5311bb91e2bed0dvboxsync " -nohostkey Disable all hostkey combinations\n"
c64777b77514bdc924249d2f9900be25079b0d84vboxsync " -nohostkeys ... Disable specific hostkey combinations, see below for valid keys\n"
3942acfaf590eaef4740d7b8a5311bb91e2bed0dvboxsync " -nograbonclick Disable mouse/keyboard grabbing on mouse click w/o additions\n"
3942acfaf590eaef4740d7b8a5311bb91e2bed0dvboxsync " -detecthostkey Get the hostkey identifier and modifier state\n"
42c1972c22e09797b4b24afbd0ec114ed076c37cvboxsync " -hostkey <key> {<key2>} <mod> Set the host key to the values obtained using -detecthostkey\n"
3942acfaf590eaef4740d7b8a5311bb91e2bed0dvboxsync " -termacpi Send an ACPI power button event when closing the window\n"
42c1972c22e09797b4b24afbd0ec114ed076c37cvboxsync#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) /** @todo UNIXISH_TAP stuff out of main and up to Config.kmk! */
42c1972c22e09797b4b24afbd0ec114ed076c37cvboxsync " -evdevkeymap Use evdev keycode map\n"
c64777b77514bdc924249d2f9900be25079b0d84vboxsync " -vrdp <port> Listen for VRDP connections on port (default if not specified)\n"
c64777b77514bdc924249d2f9900be25079b0d84vboxsync " -discardstate Discard saved state (if present) and revert to last snapshot (if present)\n"
c64777b77514bdc924249d2f9900be25079b0d84vboxsync " -securelabel Display a secure VM label at the top of the screen\n"
3942acfaf590eaef4740d7b8a5311bb91e2bed0dvboxsync " -seclabelfnt TrueType (.ttf) font file for secure session label\n"
af0b37c347057e87a85cfbc869b9e68432de1baevboxsync " -seclabelsiz Font point size for secure session label (default 12)\n"
af0b37c347057e87a85cfbc869b9e68432de1baevboxsync " -seclabelofs Font offset within the secure label (default 0)\n"
3942acfaf590eaef4740d7b8a5311bb91e2bed0dvboxsync " -seclabelfgcol <rgb> Secure label text color RGB value in 6 digit hexadecimal (eg: FFFF00)\n"
3942acfaf590eaef4740d7b8a5311bb91e2bed0dvboxsync " -seclabelbgcol <rgb> Secure label background color RGB value in 6 digit hexadecimal (eg: FF0000)\n"
3942acfaf590eaef4740d7b8a5311bb91e2bed0dvboxsync " -[no]rawr0 Enable or disable raw ring 3\n"
3942acfaf590eaef4740d7b8a5311bb91e2bed0dvboxsync " -[no]rawr3 Enable or disable raw ring 0\n"
c64777b77514bdc924249d2f9900be25079b0d84vboxsync " -[no]patm Enable or disable PATM\n"
3942acfaf590eaef4740d7b8a5311bb91e2bed0dvboxsync " -[no]csam Enable or disable CSAM\n"
c64777b77514bdc924249d2f9900be25079b0d84vboxsync " -[no]hwvirtex Permit or deny the usage of VMX/SVN\n"
3942acfaf590eaef4740d7b8a5311bb91e2bed0dvboxsync " -convertSettings Allow to auto-convert settings files\n"
c64777b77514bdc924249d2f9900be25079b0d84vboxsync " -convertSettingsBackup Allow to auto-convert settings files\n"
3942acfaf590eaef4740d7b8a5311bb91e2bed0dvboxsync " but create backup copies before\n"
3942acfaf590eaef4740d7b8a5311bb91e2bed0dvboxsync " -convertSettingsIgnore Allow to auto-convert settings files\n"
3942acfaf590eaef4740d7b8a5311bb91e2bed0dvboxsync " but don't explicitly save the results\n"
3942acfaf590eaef4740d7b8a5311bb91e2bed0dvboxsync "Key bindings:\n"
af0b37c347057e87a85cfbc869b9e68432de1baevboxsync " <hostkey> + f Switch to full screen / restore to previous view\n"
c64777b77514bdc924249d2f9900be25079b0d84vboxsync " h Press ACPI power button\n"
c64777b77514bdc924249d2f9900be25079b0d84vboxsync " n Take a snapshot and continue execution\n"
c64777b77514bdc924249d2f9900be25079b0d84vboxsync " p Pause / resume execution\n"
c64777b77514bdc924249d2f9900be25079b0d84vboxsync " q Power off\n"
c64777b77514bdc924249d2f9900be25079b0d84vboxsync " r VM reset\n"
c64777b77514bdc924249d2f9900be25079b0d84vboxsync " s Save state and power off\n"
c64777b77514bdc924249d2f9900be25079b0d84vboxsync " <del> Send <ctrl><alt><del>\n"
c64777b77514bdc924249d2f9900be25079b0d84vboxsync " <F1>...<F12> Send <ctrl><alt><Fx>\n"
c64777b77514bdc924249d2f9900be25079b0d84vboxsync "Further key bindings useful for debugging:\n"
42c1972c22e09797b4b24afbd0ec114ed076c37cvboxsync " LCtrl + Alt + F12 Reset statistics counter\n"
c64777b77514bdc924249d2f9900be25079b0d84vboxsync " LCtrl + Alt + F11 Dump statistics to logfile\n"
42c1972c22e09797b4b24afbd0ec114ed076c37cvboxsync " Alt + F12 Toggle R0 recompiler\n"
c64777b77514bdc924249d2f9900be25079b0d84vboxsync " Alt + F11 Toggle R3 recompiler\n"
42c1972c22e09797b4b24afbd0ec114ed076c37cvboxsync " Alt + F10 Toggle PATM\n"
c64777b77514bdc924249d2f9900be25079b0d84vboxsync " Alt + F9 Toggle CSAM\n"
c1980cd3f410c88b8f92f464c56ed987a15f44c1vboxsync " Alt + F8 Toggle single step mode\n"
c64777b77514bdc924249d2f9900be25079b0d84vboxsync " LCtrl/RCtrl + F12 Toggle logger\n"
42c1972c22e09797b4b24afbd0ec114ed076c37cvboxsync " F12 Write log marker to logfile\n"
3942acfaf590eaef4740d7b8a5311bb91e2bed0dvboxsyncstatic void PrintError(const char *pszName, CBSTR pwszDescr, CBSTR pwszComponent=NULL)
c64777b77514bdc924249d2f9900be25079b0d84vboxsync RTStrPrintf(pszBuffer, sizeof(pszBuffer), "%lS", pwszDescr);
c64777b77514bdc924249d2f9900be25079b0d84vboxsync && (pszStat = strstr(pszBuffer, "VBox status code: ")))
c64777b77514bdc924249d2f9900be25079b0d84vboxsync * Custom signal handler. Currently it is only used to release modifier
c64777b77514bdc924249d2f9900be25079b0d84vboxsync * keys when receiving the USR1 signal. When switching VTs, we might not
c64777b77514bdc924249d2f9900be25079b0d84vboxsync * get release events for Ctrl-Alt and in case a savestate is performed
3942acfaf590eaef4740d7b8a5311bb91e2bed0dvboxsync * on the new VT, the VM will be saved with modifier keys stuck. This is
c64777b77514bdc924249d2f9900be25079b0d84vboxsync * annoying enough for introducing this hack.
c64777b77514bdc924249d2f9900be25079b0d84vboxsyncvoid signal_handler_SIGUSR1(int sig, siginfo_t *info, void *secret)
3942acfaf590eaef4740d7b8a5311bb91e2bed0dvboxsync /* only SIGUSR1 is interesting */
3942acfaf590eaef4740d7b8a5311bb91e2bed0dvboxsync /* just release the modifiers */
c64777b77514bdc924249d2f9900be25079b0d84vboxsync * Custom signal handler for catching exit events.
c64777b77514bdc924249d2f9900be25079b0d84vboxsync#endif /* VBOXSDL_WITH_X11 */
3942acfaf590eaef4740d7b8a5311bb91e2bed0dvboxsync * Checks if any of the settings files were auto-converted and informs the
3942acfaf590eaef4740d7b8a5311bb91e2bed0dvboxsync * user if so.
3942acfaf590eaef4740d7b8a5311bb91e2bed0dvboxsync * @return @false if the program should terminate and @true otherwise.
3942acfaf590eaef4740d7b8a5311bb91e2bed0dvboxsync * @note The function is taken from VBoxManage.cpp almost unchanged (except the
3942acfaf590eaef4740d7b8a5311bb91e2bed0dvboxsync * help text).
3942acfaf590eaef4740d7b8a5311bb91e2bed0dvboxsyncstatic bool checkForAutoConvertedSettings (ComPtr<IVirtualBox> virtualBox,
3942acfaf590eaef4740d7b8a5311bb91e2bed0dvboxsync /* return early if nothing to do */
3942acfaf590eaef4740d7b8a5311bb91e2bed0dvboxsync return true;
3942acfaf590eaef4740d7b8a5311bb91e2bed0dvboxsync CHECK_ERROR_BREAK(virtualBox, COMGETTER(SettingsFormatVersion) (formatVersion.asOutParam()));
c64777b77514bdc924249d2f9900be25079b0d84vboxsync CHECK_ERROR_BREAK(virtualBox, COMGETTER(Machines2) (ComSafeArrayAsOutParam (machines)));
3942acfaf590eaef4740d7b8a5311bb91e2bed0dvboxsync CHECK_ERROR_BREAK(machines[i], COMGETTER(Accessible) (&accessible));
3942acfaf590eaef4740d7b8a5311bb91e2bed0dvboxsync CHECK_ERROR_BREAK(machines[i], COMGETTER(SettingsFileVersion) (version.asOutParam()));
3942acfaf590eaef4740d7b8a5311bb91e2bed0dvboxsync CHECK_ERROR_BREAK(machines[i], COMGETTER(SettingsFilePath) (filePath.asOutParam()));
3942acfaf590eaef4740d7b8a5311bb91e2bed0dvboxsync fileList.push_back (Utf8StrFmt ("%ls (%ls)", filePath.raw(),
c64777b77514bdc924249d2f9900be25079b0d84vboxsync CHECK_ERROR_BREAK(virtualBox, COMGETTER(SettingsFileVersion) (version.asOutParam()));
c64777b77514bdc924249d2f9900be25079b0d84vboxsync CHECK_ERROR_BREAK(virtualBox, COMGETTER(SettingsFilePath) (filePath.asOutParam()));
c64777b77514bdc924249d2f9900be25079b0d84vboxsync fileList.push_back (Utf8StrFmt ("%ls (%ls)", filePath.raw(),
3942acfaf590eaef4740d7b8a5311bb91e2bed0dvboxsync"WARNING! The following VirtualBox settings files have been automatically\n"
42c1972c22e09797b4b24afbd0ec114ed076c37cvboxsync"converted to the new settings file format version '%ls':\n"
3942acfaf590eaef4740d7b8a5311bb91e2bed0dvboxsync for (std::list <Utf8Str>::const_iterator f = fileList.begin();
c64777b77514bdc924249d2f9900be25079b0d84vboxsync"The current command was aborted to prevent overwriting the above settings\n"
3942acfaf590eaef4740d7b8a5311bb91e2bed0dvboxsync"files with the results of the auto-conversion without your permission.\n"
c64777b77514bdc924249d2f9900be25079b0d84vboxsync"Please add one of the following command line switches to the VBoxSDL command\n"
c64777b77514bdc924249d2f9900be25079b0d84vboxsync"line and repeat the command:\n"
c64777b77514bdc924249d2f9900be25079b0d84vboxsync" -convertSettings - to save all auto-converted files (it will not\n"
c64777b77514bdc924249d2f9900be25079b0d84vboxsync" be possible to use these settings files with an\n"
c64777b77514bdc924249d2f9900be25079b0d84vboxsync" older version of VirtualBox in the future);\n"
c64777b77514bdc924249d2f9900be25079b0d84vboxsync" -convertSettingsBackup - to create backup copies of the settings files in\n"
c64777b77514bdc924249d2f9900be25079b0d84vboxsync" the old format before saving them in the new format;\n"
c64777b77514bdc924249d2f9900be25079b0d84vboxsync" -convertSettingsIgnore - to not save the auto-converted settings files.\n"
4a1a50ee161eb0a0f907d9d1585581f3bb43bed2vboxsync"Note that if you use -convertSettingsIgnore, the auto-converted settings files\n"
42c1972c22e09797b4b24afbd0ec114ed076c37cvboxsync"will be implicitly saved in the new format anyway once you change a setting or\n"
37fb67be7d1d328213aeda3f56ab5aacd37416d1vboxsync"start a virtual machine, but NO backup copies will be created in this case.\n");
c64777b77514bdc924249d2f9900be25079b0d84vboxsync return false;
c64777b77514bdc924249d2f9900be25079b0d84vboxsync for (std::list <ComPtr <IMachine> >::const_iterator m = cvtMachines.begin();
c64777b77514bdc924249d2f9900be25079b0d84vboxsync CHECK_ERROR_BREAK((*m), COMGETTER(Id) (id.asOutParam()));
c64777b77514bdc924249d2f9900be25079b0d84vboxsync /* open a session for the VM */
c64777b77514bdc924249d2f9900be25079b0d84vboxsync CHECK_ERROR_BREAK (virtualBox, OpenSession (session, id));
c64777b77514bdc924249d2f9900be25079b0d84vboxsync CHECK_ERROR_BREAK(session, COMGETTER(Machine) (sm.asOutParam()));
c64777b77514bdc924249d2f9900be25079b0d84vboxsync CHECK_ERROR (sm, SaveSettingsWithBackup (bakFileName.asOutParam()));
c64777b77514bdc924249d2f9900be25079b0d84vboxsync CHECK_ERROR (virtualBox, SaveSettingsWithBackup (bakFileName.asOutParam()));
c64777b77514bdc924249d2f9900be25079b0d84vboxsync/** entry point */
c64777b77514bdc924249d2f9900be25079b0d84vboxsyncDECLEXPORT(int) TrustedMain(int argc, char **argv, char **envp)
c64777b77514bdc924249d2f9900be25079b0d84vboxsync * Lock keys on SDL behave different from normal keys: A KeyPress event is generated
c64777b77514bdc924249d2f9900be25079b0d84vboxsync * if the lock mode gets active and a keyRelease event is genereated if the lock mode
c64777b77514bdc924249d2f9900be25079b0d84vboxsync * gets inactive, that is KeyPress and KeyRelease are sent when pressing the lock key
c64777b77514bdc924249d2f9900be25079b0d84vboxsync * to change the mode. The current lock mode is reflected in SDL_GetModState().
ad27e1d5e48ca41245120c331cc88b50464813cevboxsync * Debian patched libSDL to make the lock keys behave like normal keys generating a
c64777b77514bdc924249d2f9900be25079b0d84vboxsync * KeyPress/KeyRelease event if the lock key was pressed/released. But the lock status
c64777b77514bdc924249d2f9900be25079b0d84vboxsync * is not reflected in the mod status anymore. We disable the Debian-specific extension
c64777b77514bdc924249d2f9900be25079b0d84vboxsync * to ensure a defined environment and work around the missing KeyPress/KeyRelease
c64777b77514bdc924249d2f9900be25079b0d84vboxsync * events in ProcessKeys().
c64777b77514bdc924249d2f9900be25079b0d84vboxsync * the hostkey detection mode is unrelated to VM processing, so handle it before
c64777b77514bdc924249d2f9900be25079b0d84vboxsync * we initialize anything COM related
c64777b77514bdc924249d2f9900be25079b0d84vboxsync if (argc == 2 && !strcmp(argv[1], "-detecthostkey"))
c64777b77514bdc924249d2f9900be25079b0d84vboxsync int rc = SDL_InitSubSystem(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_NOPARACHUTE);
c64777b77514bdc924249d2f9900be25079b0d84vboxsync RTPrintf("Error: SDL_InitSubSystem failed with message '%s'\n", SDL_GetError());
c64777b77514bdc924249d2f9900be25079b0d84vboxsync /* we need a video window for the keyboard stuff to work */
c64777b77514bdc924249d2f9900be25079b0d84vboxsync if (!SDL_SetVideoMode(640, 480, 16, SDL_SWSURFACE))
c64777b77514bdc924249d2f9900be25079b0d84vboxsync RTPrintf("Please hit one or two function key(s) to get the -hostkey value...\n");
42c1972c22e09797b4b24afbd0ec114ed076c37cvboxsync unsigned mod = SDL_GetModState() & ~(KMOD_MODE | KMOD_NUM | KMOD_RESERVED);
c64777b77514bdc924249d2f9900be25079b0d84vboxsync if (event2.type == SDL_KEYDOWN || event2.type == SDL_KEYUP)
c64777b77514bdc924249d2f9900be25079b0d84vboxsync /* pressed additional host key */
ccd08a3ae2b154ad27cd2bb21a9360bc33aeb552vboxsync RTPrintf(" %d\n", SDL_GetModState() & ~(KMOD_MODE | KMOD_NUM | KMOD_RESERVED));
c64777b77514bdc924249d2f9900be25079b0d84vboxsync /* we're done */
c64777b77514bdc924249d2f9900be25079b0d84vboxsync /* we're down */
c64777b77514bdc924249d2f9900be25079b0d84vboxsync bool fFullscreen = false;
4a25fdc1810f28c7813f2fd13ab04ce25b60f30bvboxsync unsigned fRawR0 = ~0U;
c64777b77514bdc924249d2f9900be25079b0d84vboxsync unsigned fRawR3 = ~0U;
c64777b77514bdc924249d2f9900be25079b0d84vboxsync unsigned fPATM = ~0U;
c64777b77514bdc924249d2f9900be25079b0d84vboxsync unsigned fCSAM = ~0U;
c64777b77514bdc924249d2f9900be25079b0d84vboxsync bool fWin32UI = true;
c64777b77514bdc924249d2f9900be25079b0d84vboxsync /* The damned GOTOs forces this to be up here - totally out of place. */
23795b52925e0506e39a546334af089b8f93c50avboxsync * Host key handling.
c64777b77514bdc924249d2f9900be25079b0d84vboxsync * The golden rule is that host-key combinations should not be seen
c64777b77514bdc924249d2f9900be25079b0d84vboxsync * by the guest. For instance a CAD should not have any extra RCtrl down
c64777b77514bdc924249d2f9900be25079b0d84vboxsync * and RCtrl up around itself. Nor should a resume be followed by a Ctrl-P
c64777b77514bdc924249d2f9900be25079b0d84vboxsync * that could encourage applications to start printing.
ad27e1d5e48ca41245120c331cc88b50464813cevboxsync * We must not confuse the hostkey processing into any release sequences
c64777b77514bdc924249d2f9900be25079b0d84vboxsync * either, the host key is supposed to be explicitly pressing one key.
4a64ab8cc32b5b6d329a51b36b23fa50c6ada410vboxsync * Quick state diagram:
4a64ab8cc32b5b6d329a51b36b23fa50c6ada410vboxsync * host key down alone
4a64ab8cc32b5b6d329a51b36b23fa50c6ada410vboxsync * (Normal) ---------------
4a64ab8cc32b5b6d329a51b36b23fa50c6ada410vboxsync * | | v host combination key down
4a64ab8cc32b5b6d329a51b36b23fa50c6ada410vboxsync * | | (Host key down) ----------------
4a64ab8cc32b5b6d329a51b36b23fa50c6ada410vboxsync * | | host key up v | |
4a64ab8cc32b5b6d329a51b36b23fa50c6ada410vboxsync * | |-------------- | other key down v host combination key down
4a64ab8cc32b5b6d329a51b36b23fa50c6ada410vboxsync * | | (host key used) -------------
c64777b77514bdc924249d2f9900be25079b0d84vboxsync * | | | ^ |
4a64ab8cc32b5b6d329a51b36b23fa50c6ada410vboxsync * | (not host key)-- | |---------------
c64777b77514bdc924249d2f9900be25079b0d84vboxsync * | | | | |
c64777b77514bdc924249d2f9900be25079b0d84vboxsync * | | ---- other |
c64777b77514bdc924249d2f9900be25079b0d84vboxsync * | modifiers = 0 v v
c64777b77514bdc924249d2f9900be25079b0d84vboxsync * -----------------------------------------------
c64777b77514bdc924249d2f9900be25079b0d84vboxsync /** The initial and most common state, pass keystrokes to the guest.
c64777b77514bdc924249d2f9900be25079b0d84vboxsync * Next state: HKEYSTATE_DOWN
c64777b77514bdc924249d2f9900be25079b0d84vboxsync * Prev state: Any */
c64777b77514bdc924249d2f9900be25079b0d84vboxsync /** The first host key was pressed down
c64777b77514bdc924249d2f9900be25079b0d84vboxsync /** The second host key was pressed down (if gHostKeySym2 != SDLK_UNKNOWN)
c64777b77514bdc924249d2f9900be25079b0d84vboxsync /** The host key has been pressed down.
c64777b77514bdc924249d2f9900be25079b0d84vboxsync * Prev state: HKEYSTATE_NORMAL
c64777b77514bdc924249d2f9900be25079b0d84vboxsync * Next state: HKEYSTATE_NORMAL - host key up, capture toggle.
c64777b77514bdc924249d2f9900be25079b0d84vboxsync * Next state: HKEYSTATE_USED - host key combination down.
c1980cd3f410c88b8f92f464c56ed987a15f44c1vboxsync * Next state: HKEYSTATE_NOT_IT - non-host key combination down.
c1980cd3f410c88b8f92f464c56ed987a15f44c1vboxsync /** A host key combination was pressed.
d08565193a56acd57fd770cf3eb8c3fcbe3af70bvboxsync * Prev state: HKEYSTATE_DOWN
c1980cd3f410c88b8f92f464c56ed987a15f44c1vboxsync * Next state: HKEYSTATE_NORMAL - when modifiers are all 0
c64777b77514bdc924249d2f9900be25079b0d84vboxsync /** A non-host key combination was attempted. Send hostkey down to the
c64777b77514bdc924249d2f9900be25079b0d84vboxsync * guest and continue until all modifiers have been released.
c64777b77514bdc924249d2f9900be25079b0d84vboxsync * Prev state: HKEYSTATE_DOWN
c64777b77514bdc924249d2f9900be25079b0d84vboxsync * Next state: HKEYSTATE_NORMAL - when modifiers are all 0
c64777b77514bdc924249d2f9900be25079b0d84vboxsync /** The host key down event which we have been hiding from the guest.
c64777b77514bdc924249d2f9900be25079b0d84vboxsync * Used when going from HKEYSTATE_DOWN to HKEYSTATE_NOT_IT. */
c64777b77514bdc924249d2f9900be25079b0d84vboxsync "(C) 2005-2009 Sun Microsystems, Inc.\n"
c64777b77514bdc924249d2f9900be25079b0d84vboxsync "All rights reserved.\n\n",
c64777b77514bdc924249d2f9900be25079b0d84vboxsync // less than one parameter is not possible
c64777b77514bdc924249d2f9900be25079b0d84vboxsync RTPrintf("Error: COM initialization failed, rc = 0x%x!\n", rc);
c1980cd3f410c88b8f92f464c56ed987a15f44c1vboxsync // scopes all the stuff till shutdown
c1980cd3f410c88b8f92f464c56ed987a15f44c1vboxsync ////////////////////////////////////////////////////////////////////////////
c1980cd3f410c88b8f92f464c56ed987a15f44c1vboxsync rc = virtualBox.createLocalObject (CLSID_VirtualBox);
c64777b77514bdc924249d2f9900be25079b0d84vboxsync RTPrintf("Failed to create VirtualBox object! No error information available (rc = 0x%x).\n", rc);
c64777b77514bdc924249d2f9900be25079b0d84vboxsync RTPrintf("Failed to create session object, rc = 0x%x!\n", rc);
c64777b77514bdc924249d2f9900be25079b0d84vboxsync // create the event queue
3942acfaf590eaef4740d7b8a5311bb91e2bed0dvboxsync // (here it is necessary only to process remaining XPCOM/IPC events
c64777b77514bdc924249d2f9900be25079b0d84vboxsync // after the session is closed)
c64777b77514bdc924249d2f9900be25079b0d84vboxsync// EventQueue eventQ;
c64777b77514bdc924249d2f9900be25079b0d84vboxsync#endif /* USE_XPCOM_QUEUE_THREAD */
c64777b77514bdc924249d2f9900be25079b0d84vboxsync /* Get the number of network adapters */
c64777b77514bdc924249d2f9900be25079b0d84vboxsync virtualBox->COMGETTER(SystemProperties) (sysInfo.asOutParam());
c64777b77514bdc924249d2f9900be25079b0d84vboxsync sysInfo->COMGETTER (NetworkAdapterCount) (&NetworkAdapterCount);
c64777b77514bdc924249d2f9900be25079b0d84vboxsync ConvertSettings fConvertSettings = ConvertSettings_No;
c64777b77514bdc924249d2f9900be25079b0d84vboxsync // command line argument parsing stuff
c64777b77514bdc924249d2f9900be25079b0d84vboxsync RTPrintf("Error: VM not specified (UUID or name)!\n");
c64777b77514bdc924249d2f9900be25079b0d84vboxsync // first check if a UUID was supplied
3942acfaf590eaef4740d7b8a5311bb91e2bed0dvboxsync if (RT_FAILURE(RTUuidFromStr(uuid.ptr(), argv[curArg])))
3942acfaf590eaef4740d7b8a5311bb91e2bed0dvboxsync LogFlow(("invalid UUID format, assuming it's a VM name\n"));
c64777b77514bdc924249d2f9900be25079b0d84vboxsync RTPrintf("Error: missing argument for boot drive!\n");
fFullscreen = true;
gfFullscreenResize = true;
#ifdef VBOXSDL_WITH_X11
fResizable = false;
gHostKeyMod = 0;
gHostKeySym1 = 0;
for (i=0; i<cStr; i++)
i = cStr;
if (!hdaFile)
RTPrintf("Error: The path to the specified harddisk, '%s', could not be resolved.\n", argv[curArg]);
if (!fdaFile)
RTPrintf("Error: The path to the specified floppy disk, '%s', could not be resolved.\n", argv[curArg]);
if (!cdromFile)
#ifdef RT_OS_LINUX
#ifdef VBOX_WITH_VRDP
portVRDP = 0;
if (port > 0)
curArg++;
fDiscardState = true;
#ifdef VBOX_SECURELABEL
fSecureLabel = true;
#ifdef VBOXSDL_ADVANCED_OPTIONS
fRawR0 = true;
fRawR0 = false;
fRawR3 = true;
fRawR3 = false;
fPATM = true;
fPATM = false;
fCSAM = true;
fCSAM = false;
#ifdef VBOX_WIN32_UI
fWin32UI = true;
fShowSDLConfig = true;
show_usage();
goto leave;
goto leave;
goto leave;
if (!session)
goto leave;
sessionOpened = true;
if (!gMachine)
goto leave;
if (!gConsole)
goto leave;
if (hdaFile)
if (!hardDisk)
if (hardDisk)
goto leave;
if (fdaFile)
bool done = false;
done = true;
if (!done)
goto leave;
if (cdromFile)
bool done = false;
done = true;
if (!done)
goto leave;
if (fDiscardState)
if (cSnapshots)
if (gMachineDebugger)
if (!gDisplay)
goto leave;
if (memorySize)
if (vramSize)
#ifdef VBOX_WIN32_UI
if (fWin32UI)
if (!gpFrameBuffer)
goto leave;
#ifdef VBOX_WIN32_UI
goto leave;
if (fFullscreen)
SetFullscreen(true);
#ifdef VBOX_SECURELABEL
if (fSecureLabel)
if (!secureLabelFontFile)
goto leave;
int rcVBox;
rcVBox = RTLdrGetSymbol(gLibrarySDL_ttf, "TTF_RenderUTF8_Blended", (void**)&pTTF_RenderUTF8_Blended);
rcVBox = gpFrameBuffer->initSecureLabel(SECURE_LABEL_HEIGHT, secureLabelFontFile, secureLabelPointSize, secureLabelFontOffs);
goto leave;
#ifdef VBOXSDL_WITH_X11
goto leave;
#ifdef VBOX_WITH_VRDP
if (portVRDP != ~0)
if (gVrdpServer)
if (portVRDP > 0)
goto leave;
goto leave;
#ifdef VBOXSDL_ADVANCED_OPTIONS
if (fRawR0 != ~0U)
if (!gMachineDebugger)
goto leave;
if (fRawR3 != ~0U)
if (!gMachineDebugger)
goto leave;
if (fPATM != ~0U)
if (!gMachineDebugger)
goto leave;
if (fCSAM != ~0U)
if (!gMachineDebugger)
goto leave;
if (u32WarpDrive != 0)
if (!gMachineDebugger)
goto leave;
#ifdef VBOXSDL_WITH_X11
goto leave;
# if !defined(VBOX_WITHOUT_XCURSOR)
#ifdef VBOXSDL_WITH_X11
goto leave;
#ifdef USE_XPCOM_QUEUE_THREAD
bool fTerminateDuringStartup;
fTerminateDuringStartup = false;
#ifdef USE_XPCOM_QUEUE_THREAD
fXPCOMEventThreadSignaled = true;
case SDL_USER_EVENT_TIMER:
case SDL_USER_EVENT_RESIZE:
#ifdef USE_XPCOM_QUEUE_THREAD
case SDL_USER_EVENT_TERMINATE:
fTerminateDuringStartup = true;
sdlTimer = 0;
goto leave;
RTPrintf("Error: failed to power up VM! No error text available (rc = 0x%x state = %d)\n", rc, machineState);
goto leave;
if (!gKeyboard)
goto leave;
if (!gMouse)
goto leave;
if (gpszPidFile)
#ifdef USE_XPCOM_QUEUE_THREAD
case SDL_VIDEOEXPOSE:
case SDL_KEYDOWN:
case SDL_KEYUP:
switch (enmHKeyState)
case HKEYSTATE_NORMAL:
case HKEYSTATE_DOWN_1ST:
case HKEYSTATE_DOWN_2ND:
case HKEYSTATE_DOWN:
goto leave;
if (!gfGrabbed)
InputGrabEnd();
ResetKeys();
case HKEYSTATE_USED:
goto leave;
case HKEYSTATE_NOT_IT:
case SDL_QUIT:
goto leave;
if (gConsole)
case SDL_MOUSEMOTION:
SendMouseEvent(0, 0, 0);
case SDL_MOUSEBUTTONDOWN:
case SDL_MOUSEBUTTONUP:
switch (enmHKeyState)
case HKEYSTATE_DOWN_1ST:
case HKEYSTATE_DOWN_2ND:
case HKEYSTATE_DOWN:
case SDL_ACTIVEEVENT:
InputGrabEnd();
case SDL_VIDEORESIZE:
if (gDisplay)
if (gfIgnoreNextResize)
#ifdef VBOX_SECURELABEL
if (fSecureLabel)
if (gSdlResizeTimer)
case SDL_USER_EVENT_RESIZE:
#ifdef USE_XPCOM_QUEUE_THREAD
case SDL_USER_EVENT_TERMINATE:
goto leave;
#ifdef VBOX_SECURELABEL
delete data;
if (gpszPidFile)
#ifdef VBOX_WITH_VRDP
if (gVrdpServer)
if (gMachine)
if ( gConsole
RTPrintf("Failed to power down virtual machine! No error information available (rc = 0x%x).\n", rc);
if ( gMachine
if (sessionOpened)
if (gpDefaultCursor)
#ifdef VBOXSDL_WITH_X11
if (gpCustomCursor)
if (pCustomTempWMCursor)
#if defined (RT_OS_WINDOWS)
if (gDisplay)
if (gpFrameBuffer)
#ifdef VBOX_SECURELABEL
if (gLibrarySDL_ttf)
if (callback)
if (consoleCallback)
#ifndef VBOX_WITH_HARDENING
static bool UseAbsoluteMouse(void)
switch (sym)
case SDLK_EXCLAIM:
case SDLK_AT:
case SDLK_HASH:
case SDLK_DOLLAR:
case SDLK_CARET:
case SDLK_AMPERSAND:
case SDLK_ASTERISK:
case SDLK_LEFTPAREN:
case SDLK_RIGHTPAREN:
case SDLK_UNDERSCORE:
case SDLK_EQUALS:
case SDLK_COLON:
case SDLK_QUOTEDBL:
case SDLK_LESS:
case SDLK_GREATER:
case SDLK_QUESTION:
case SDLK_KP_MULTIPLY:
case SDLK_LMETA:
case SDLK_RMETA:
case SDLK_CLEAR: return 0x;
case SDLK_KP_EQUALS: return 0x;
case SDLK_COMPOSE: return 0x;
case SDLK_HELP: return 0x;
case SDLK_BREAK: return 0x;
case SDLK_POWER: return 0x;
case SDLK_EURO: return 0x;
case SDLK_UNDO: return 0x;
#ifdef VBOXSDL_WITH_X11
keycode = 0;
// Japanese backslash/underscore and Brazilian backslash/question mark
keycode = 0;
/* This is derived partially from SDL_QuartzKeys.h and partially from testing. */
/* set-1 SDL_QuartzKeys.h */
if (keycode == 0)
case SDLK_RMETA:
case SDLK_LMETA:
keycode = 0;
if (!keycode)
#ifdef DEBUG_bird
#ifdef DEBUG_bird
return keycode;
static void ResetKeys(void)
if (!gKeyboard)
if (gaModifiersState[i])
gaModifiersState[i] = 0;
case SDLK_F12:
case SDLK_F11:
case SDLK_F12:
case SDLK_F11:
case SDLK_F10:
case SDLK_F9:
case SDLK_F8:
#ifdef DEBUG_bird
switch(keycode)
ResetKeys();
#ifdef RT_OS_DARWIN
typedef int CGSConnection;
extern CGError CGSGetGlobalHotKeyOperatingMode(CGSConnection Connection, CGSGlobalHotKeyOperatingMode *enmMode);
extern CGError CGSSetGlobalHotKeyOperatingMode(CGSConnection Connection, CGSGlobalHotKeyOperatingMode enmMode);
static bool g_fHotKeysDisabled = false;
static bool g_fConnectedToCGS = false;
if (!g_fConnectedToCGS)
g_fConnectedToCGS = true;
if (fDisable)
static void InputGrabStart(void)
#ifdef RT_OS_DARWIN
DisableGlobalHotKeys(true);
if (!gfGuestNeedsHostCursor)
static void InputGrabEnd(void)
if (!gfGuestNeedsHostCursor)
#ifdef RT_OS_DARWIN
DisableGlobalHotKeys(false);
bool abs;
buttons = 0;
if (abs)
button = 0;
if (!gpOffCursor)
if (gpOffCursor)
int tmp_button = 0;
switch (button)
if (abs)
if (abs)
void ResetVM(void)
if (gConsole)
void SaveState(void)
ResetKeys();
if (gfGrabbed)
InputGrabEnd();
case SDL_USER_EVENT_TIMER:
#ifdef USE_XPCOM_QUEUE_THREAD
case SDL_USER_EVENT_RESIZE:
case SDL_USER_EVENT_TERMINATE:
sdlTimer = 0;
lrc = ~0;
if (!lrc)
if (name)
switch (mode)
case TITLEBAR_NORMAL:
if (gfGrabbed)
if (gMachineDebugger)
case TITLEBAR_STARTUP:
case TITLEBAR_SAVE:
case TITLEBAR_SNAPSHOT:
#ifdef VBOX_WIN32_UI
static void vbox_show_shape (unsigned short w, unsigned short h,
size_t x, y;
unsigned short pitch;
if (c == bg)
if (gpOffCursor)
bool ok = false;
uint32_t shapeSize = ((((data->width + 7) / 8) * data->height + 3) & ~3) + data->width * 4 * data->height;
#if defined (RT_OS_WINDOWS)
void *lpBits;
if (hAlphaCursor)
// see SDL12/src/video/wincommon/SDL_sysmouse.c
if (pCustomTempWMCursor)
ok = true;
if (hMonoBitmap)
if (hBitmap)
if (img)
if (cur)
// see SDL12/src/video/x11/SDL_x11mouse.c
if (pCustomTempWMCursor)
ok = true;
if (!ok)
else if (gfAbsoluteMouseGuest)
static void HandleGuestCapsChanged(void)
if (!gfAbsoluteMouseGuest)
if (gfGrabbed)
InputGrabEnd();
return VERR_NOT_SUPPORTED;
case SDLK_DELETE:
case SDLK_f:
return VERR_NOT_SUPPORTED;
case SDLK_p:
return VERR_NOT_SUPPORTED;
if (gfGrabbed)
InputGrabEnd();
case SDLK_r:
return VERR_NOT_SUPPORTED;
ResetVM();
case SDLK_q:
return VERR_NOT_SUPPORTED;
return VINF_EM_TERMINATE;
case SDLK_s:
return VERR_NOT_SUPPORTED;
SaveState();
return VINF_EM_TERMINATE;
case SDLK_h:
return VERR_NOT_SUPPORTED;
if (gConsole)
case SDLK_n:
return VERR_NOT_SUPPORTED;
return VINF_SUCCESS;
return VINF_SUCCESS;
return VINF_SUCCESS;
return VERR_NOT_SUPPORTED;
return VINF_SUCCESS;
return interval;
if (gConsole)
#ifdef USE_XPCOM_QUEUE_THREAD
if (rc == 0)
#ifdef VBOXSDL_WITH_X11
if (!rc)
if (!gfFullscreenResize)
if (enable)