SDLConsole.cpp revision 332d68e9666b04a5aa788a586d9f4c6b1f19c700
/** @file
*
* VBox frontends: Basic Frontend (BFE):
* Implementation of SDLConsole class
*/
/*
* Copyright (C) 2006-2009 Sun Microsystems, Inc.
*
* 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.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#define LOG_GROUP LOG_GROUP_GUI
#define __STDC_LIMIT_MACROS
#define __STDC_CONSTANT_MACROS
#ifdef RT_OS_DARWIN
#endif
#ifdef VBOXBFE_WITHOUT_COM
# include "COMDefs.h"
#else
#endif
#include <iprt/initterm.h>
#include <iprt/semaphore.h>
#ifdef VBOXBFE_WITH_X11
# ifndef VBOXBFE_WITHOUT_XCURSOR
# endif
#endif
#include "VBoxBFE.h"
#include <vector>
#include "DisplayImpl.h"
#include "MouseImpl.h"
#include "KeyboardImpl.h"
#include "VMMDevInterface.h"
#include "Framebuffer.h"
#include "MachineDebuggerImpl.h"
#include "VMControl.h"
#include "ConsoleImpl.h"
#include "SDLConsole.h"
#include "Ico64x01.h"
/*******************************************************************************
* Internal Functions *
*******************************************************************************/
{
int rc;
mfInputGrab = false;
/** Custom window manager cursor? */
mfInitialized = false;
if (rc != 0)
{
return;
}
/* memorize the default cursor */
/* create a fake empty cursor */
{
}
#ifdef VBOXBFE_WITH_X11
/* get Window Manager info */
if (!SDL_GetWMInfo(&gSdlInfo))
{
/** @todo: Is this fatal? */
AssertMsgFailed(("Error: could not get SDL Window Manager info!\n"));
}
#endif
if (12320 == g_cbIco64x01)
{
/** @todo make it as simple as possible. No PNM interpreter here... */
if (mWMIcon)
{
}
}
/*
* Enable keyboard repeats
*/
mfInitialized = true;
}
SDLConsole::~SDLConsole()
{
if (mfInputGrab)
inputGrabEnd();
if (mWMIcon)
{
}
}
{
return CONEVENT_QUIT;
{
/*
* The screen needs to be repainted.
*/
case SDL_VIDEOEXPOSE:
{
return CONEVENT_SCREENUPDATE;
}
/*
* Keyboard events.
*/
case SDL_KEYDOWN:
case SDL_KEYUP:
{
switch (enmHKeyState)
{
case HKEYSTATE_NORMAL:
{
{
EvHKeyDown = *ev;
break;
}
break;
}
case HKEYSTATE_DOWN:
{
{
/* potential host key combination, try execute it */
if (rc == VINF_SUCCESS)
{
break;
}
if (RT_SUCCESS(rc))
{
return CONEVENT_QUIT;
}
}
else /* SDL_KEYUP */
{
{
/* toggle grabbing state */
if (!mfInputGrab)
else
inputGrabEnd();
/* SDL doesn't always reset the keystates, correct it */
resetKeys();
break;
}
}
/* not host key */
break;
}
case HKEYSTATE_USED:
{
{
}
{
{
return CONEVENT_QUIT;
}
}
break;
}
default:
/* fall thru */
case HKEYSTATE_NOT_IT:
{
{
}
break;
}
} /* state switch */
break;
}
/*
* The window was closed.
*/
case SDL_QUIT:
{
return CONEVENT_QUIT;
}
/*
* The mouse has moved
*/
case SDL_MOUSEMOTION:
{
mouseSendEvent(0);
break;
}
/*
* A mouse button has been clicked or released.
*/
case SDL_MOUSEBUTTONDOWN:
case SDL_MOUSEBUTTONUP:
{
{
{
/* start grabbing all events */
}
}
else
{
int dz = 0;
{
dz = -1;
}
{
dz = 1;
}
}
break;
}
/*
* The window has gained or lost focus.
*/
case SDL_ACTIVEEVENT:
{
{
inputGrabEnd();
}
break;
}
/*
* User specific update event.
*/
/** @todo use a common user event handler so that SDL_PeepEvents() won't
* possibly remove other events in the queue!
*/
{
/*
* Decode event parameters.
*/
LogFlow(("SDL_USER_EVENT_UPDATERECT: x = %d, y = %d, w = %d, h = %d\n",
x, y, w, h));
/*
* Lock the framebuffer, perform the update and lock again
*/
gFramebuffer->Lock();
gFramebuffer->update(x, y, w, h);
gFramebuffer->Unlock();
break;
}
/*
* User specific resize event.
*/
case SDL_USER_EVENT_RESIZE:
return CONEVENT_USR_SCREENRESIZE;
/*
* User specific update title bar notification event
*/
return CONEVENT_USR_TITLEBARUPDATE;
/*
* User specific termination event
*/
case SDL_USER_EVENT_TERMINATE:
{
RTPrintf("Error: VM terminated abnormally!\n");
return CONEVENT_USR_QUIT;
}
#ifdef VBOX_SECURELABEL
/*
* User specific secure label update event
*/
return CONEVENT_USR_SECURELABELUPDATE;
#endif /* VBOX_SECURELABEL */
/*
* User specific pointer shape change event
*/
{
delete data;
break;
}
case SDL_VIDEORESIZE:
{
/* ignore this */
break;
}
default:
{
break;
}
}
return CONEVENT_NONE;
}
/**
* Push the exit event forcing the main event loop to terminate.
*/
void SDLConsole::doEventQuit()
{
}
void SDLConsole::eventQuit()
{
doEventQuit();
}
/**
* Fallback keycode conversion using SDL symbols.
*
* This is used to catch keycodes that's missing from the translation table.
*
* @returns XT scancode
* @param ev SDL scancode
*/
{
Log(("SDL key event: sym=%d scancode=%#x unicode=%#x\n",
switch (sym)
{ /* set 1 scan code */
case SDLK_ESCAPE: return 0x01;
case SDLK_EXCLAIM:
case SDLK_1: return 0x02;
case SDLK_AT:
case SDLK_2: return 0x03;
case SDLK_HASH:
case SDLK_3: return 0x04;
case SDLK_DOLLAR:
case SDLK_4: return 0x05;
/* % */
case SDLK_5: return 0x06;
case SDLK_CARET:
case SDLK_6: return 0x07;
case SDLK_AMPERSAND:
case SDLK_7: return 0x08;
case SDLK_ASTERISK:
case SDLK_8: return 0x09;
case SDLK_LEFTPAREN:
case SDLK_9: return 0x0a;
case SDLK_RIGHTPAREN:
case SDLK_0: return 0x0b;
case SDLK_UNDERSCORE:
case SDLK_MINUS: return 0x0c;
case SDLK_EQUALS:
case SDLK_PLUS: return 0x0d;
case SDLK_BACKSPACE: return 0x0e;
case SDLK_TAB: return 0x0f;
case SDLK_q: return 0x10;
case SDLK_w: return 0x11;
case SDLK_e: return 0x12;
case SDLK_r: return 0x13;
case SDLK_t: return 0x14;
case SDLK_y: return 0x15;
case SDLK_u: return 0x16;
case SDLK_i: return 0x17;
case SDLK_o: return 0x18;
case SDLK_p: return 0x19;
case SDLK_LEFTBRACKET: return 0x1a;
case SDLK_RIGHTBRACKET: return 0x1b;
case SDLK_RETURN: return 0x1c;
case SDLK_LCTRL: return 0x1d;
case SDLK_a: return 0x1e;
case SDLK_s: return 0x1f;
case SDLK_d: return 0x20;
case SDLK_f: return 0x21;
case SDLK_g: return 0x22;
case SDLK_h: return 0x23;
case SDLK_j: return 0x24;
case SDLK_k: return 0x25;
case SDLK_l: return 0x26;
case SDLK_COLON:
case SDLK_SEMICOLON: return 0x27;
case SDLK_QUOTEDBL:
case SDLK_QUOTE: return 0x28;
case SDLK_BACKQUOTE: return 0x29;
case SDLK_LSHIFT: return 0x2a;
case SDLK_BACKSLASH: return 0x2b;
case SDLK_z: return 0x2c;
case SDLK_x: return 0x2d;
case SDLK_c: return 0x2e;
case SDLK_v: return 0x2f;
case SDLK_b: return 0x30;
case SDLK_n: return 0x31;
case SDLK_m: return 0x32;
case SDLK_LESS:
case SDLK_COMMA: return 0x33;
case SDLK_GREATER:
case SDLK_PERIOD: return 0x34;
case SDLK_KP_DIVIDE: /*??*/
case SDLK_QUESTION:
case SDLK_SLASH: return 0x35;
case SDLK_RSHIFT: return 0x36;
case SDLK_KP_MULTIPLY:
case SDLK_LALT: return 0x38;
case SDLK_MODE: /* alt gr*/
case SDLK_SPACE: return 0x39;
case SDLK_CAPSLOCK: return 0x3a;
case SDLK_F1: return 0x3b;
case SDLK_F2: return 0x3c;
case SDLK_F3: return 0x3d;
case SDLK_F4: return 0x3e;
case SDLK_F5: return 0x3f;
case SDLK_F6: return 0x40;
case SDLK_F7: return 0x41;
case SDLK_F8: return 0x42;
case SDLK_F9: return 0x43;
case SDLK_F10: return 0x44;
case SDLK_NUMLOCK: return 0x45;
case SDLK_SCROLLOCK: return 0x46;
case SDLK_KP7: return 0x47;
case SDLK_KP8: return 0x48;
case SDLK_KP9: return 0x49;
case SDLK_KP_MINUS: return 0x4a;
case SDLK_KP4: return 0x4b;
case SDLK_KP5: return 0x4c;
case SDLK_KP6: return 0x4d;
case SDLK_KP_PLUS: return 0x4e;
case SDLK_KP1: return 0x4f;
case SDLK_KP2: return 0x50;
case SDLK_KP3: return 0x51;
case SDLK_KP0: return 0x52;
case SDLK_KP_PERIOD: return 0x53;
case SDLK_SYSREQ: return 0x54;
case SDLK_F11: return 0x57;
case SDLK_F12: return 0x58;
case SDLK_F13: return 0x5b;
case SDLK_LMETA:
case SDLK_F14: return 0x5c;
case SDLK_RMETA:
case SDLK_F15: return 0x5d;
#if 0
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;
#endif
default:
Log(("Unhandled sdl key event: sym=%d scancode=%#x unicode=%#x\n",
return 0;
}
}
#endif /* RT_OS_DARWIN */
/**
* Converts an SDL keyboard eventcode to a XT scancode.
*
* @returns XT scancode
* @param ev SDL scancode
*/
{
int keycode;
// start with the scancode determined by SDL
#if defined(RT_OS_LINUX)
// workaround for SDL keyboard translation issues on Linux
// keycodes > 0x100 are sent as 0xe0 keycode
// servers on a Linux host, and will almost certainly not
// work on other hosts or on other servers on Linux hosts.
// For a more general approach, see the Wine code in the GUI.
{
0xc7, /* 97 Home */
0xc8, /* 98 Up */
0xc9, /* 99 PgUp */
0xcb, /* 100 Left */
0x4c, /* 101 KP-5 */
0xcd, /* 102 Right */
0xcf, /* 103 End */
0xd0, /* 104 Down */
0xd1, /* 105 PgDn */
0xd2, /* 106 Ins */
0xd3, /* 107 Del */
0x9c, /* 108 Enter */
0x9d, /* 109 Ctrl-R */
0x0, /* 110 Pause */
0xb7, /* 111 Print */
0xb5, /* 112 Divide */
0xb8, /* 113 Alt-R */
0xc6, /* 114 Break */
0x0, /* 115 */
0x0, /* 116 */
0x0, /* 117 */
0x0, /* 118 */
0x0, /* 119 */
0x70, /* 120 Hiragana_Katakana */
0x0, /* 121 */
0x0, /* 122 */
0x73, /* 123 backslash */
0x0, /* 124 */
0x0, /* 125 */
0x0, /* 126 */
0x0, /* 127 */
0x0, /* 128 */
0x79, /* 129 Henkan */
0x0, /* 130 */
0x7b, /* 131 Muhenkan */
0x0, /* 132 */
0x7d, /* 133 Yen */
0x0, /* 134 */
0x0, /* 135 */
0x47, /* 136 KP_7 */
0x48, /* 137 KP_8 */
0x49, /* 138 KP_9 */
0x4b, /* 139 KP_4 */
0x4c, /* 140 KP_5 */
0x4d, /* 141 KP_6 */
0x4f, /* 142 KP_1 */
0x50, /* 143 KP_2 */
0x51, /* 144 KP_3 */
0x52, /* 145 KP_0 */
0x53, /* 146 KP_. */
0x47, /* 147 KP_HOME */
0x48, /* 148 KP_UP */
0x49, /* 149 KP_PgUp */
0x4b, /* 150 KP_Left */
0x4c, /* 151 KP_ */
0x4d, /* 152 KP_Right */
0x4f, /* 153 KP_End */
0x50, /* 154 KP_Down */
0x51, /* 155 KP_PgDn */
0x52, /* 156 KP_Ins */
0x53, /* 157 KP_Del */
};
if (keycode < 9)
{
keycode = 0;
}
else if (keycode < 97)
{
// just an offset
keycode -= 8;
}
else if (keycode < 158)
{
// apply conversion table
}
else
{
keycode = 0;
}
#elif defined(RT_OS_DARWIN)
/* This is derived partially from SDL_QuartzKeys.h and partially from testing. */
static const uint8_t s_aMacToSet1[] =
{
/* set-1 SDL_QuartzKeys.h */
0x1e, /* QZ_a 0x00 */
0x1f, /* QZ_s 0x01 */
0x20, /* QZ_d 0x02 */
0x21, /* QZ_f 0x03 */
0x23, /* QZ_h 0x04 */
0x22, /* QZ_g 0x05 */
0x2c, /* QZ_z 0x06 */
0x2d, /* QZ_x 0x07 */
0x2e, /* QZ_c 0x08 */
0x2f, /* QZ_v 0x09 */
0x56, /* between lshift and z. 'INT 1'? */
0x30, /* QZ_b 0x0B */
0x10, /* QZ_q 0x0C */
0x11, /* QZ_w 0x0D */
0x12, /* QZ_e 0x0E */
0x13, /* QZ_r 0x0F */
0x15, /* QZ_y 0x10 */
0x14, /* QZ_t 0x11 */
0x02, /* QZ_1 0x12 */
0x03, /* QZ_2 0x13 */
0x04, /* QZ_3 0x14 */
0x05, /* QZ_4 0x15 */
0x07, /* QZ_6 0x16 */
0x06, /* QZ_5 0x17 */
0x0d, /* QZ_EQUALS 0x18 */
0x0a, /* QZ_9 0x19 */
0x08, /* QZ_7 0x1A */
0x0c, /* QZ_MINUS 0x1B */
0x09, /* QZ_8 0x1C */
0x0b, /* QZ_0 0x1D */
0x1b, /* QZ_RIGHTBRACKET 0x1E */
0x18, /* QZ_o 0x1F */
0x16, /* QZ_u 0x20 */
0x1a, /* QZ_LEFTBRACKET 0x21 */
0x17, /* QZ_i 0x22 */
0x19, /* QZ_p 0x23 */
0x1c, /* QZ_RETURN 0x24 */
0x26, /* QZ_l 0x25 */
0x24, /* QZ_j 0x26 */
0x28, /* QZ_QUOTE 0x27 */
0x25, /* QZ_k 0x28 */
0x27, /* QZ_SEMICOLON 0x29 */
0x2b, /* QZ_BACKSLASH 0x2A */
0x33, /* QZ_COMMA 0x2B */
0x35, /* QZ_SLASH 0x2C */
0x31, /* QZ_n 0x2D */
0x32, /* QZ_m 0x2E */
0x34, /* QZ_PERIOD 0x2F */
0x0f, /* QZ_TAB 0x30 */
0x39, /* QZ_SPACE 0x31 */
0x29, /* QZ_BACKQUOTE 0x32 */
0x0e, /* QZ_BACKSPACE 0x33 */
0x9c, /* QZ_IBOOK_ENTER 0x34 */
0x01, /* QZ_ESCAPE 0x35 */
0x5c|0x80, /* QZ_RMETA 0x36 */
0x5b|0x80, /* QZ_LMETA 0x37 */
0x2a, /* QZ_LSHIFT 0x38 */
0x3a, /* QZ_CAPSLOCK 0x39 */
0x38, /* QZ_LALT 0x3A */
0x1d, /* QZ_LCTRL 0x3B */
0x36, /* QZ_RSHIFT 0x3C */
0x38|0x80, /* QZ_RALT 0x3D */
0x1d|0x80, /* QZ_RCTRL 0x3E */
0, /* */
0, /* */
0x53, /* QZ_KP_PERIOD 0x41 */
0, /* */
0x37, /* QZ_KP_MULTIPLY 0x43 */
0, /* */
0x4e, /* QZ_KP_PLUS 0x45 */
0, /* */
0x45, /* QZ_NUMLOCK 0x47 */
0, /* */
0, /* */
0, /* */
0x35|0x80, /* QZ_KP_DIVIDE 0x4B */
0x1c|0x80, /* QZ_KP_ENTER 0x4C */
0, /* */
0x4a, /* QZ_KP_MINUS 0x4E */
0, /* */
0, /* */
0x0d/*?*/, /* QZ_KP_EQUALS 0x51 */
0x52, /* QZ_KP0 0x52 */
0x4f, /* QZ_KP1 0x53 */
0x50, /* QZ_KP2 0x54 */
0x51, /* QZ_KP3 0x55 */
0x4b, /* QZ_KP4 0x56 */
0x4c, /* QZ_KP5 0x57 */
0x4d, /* QZ_KP6 0x58 */
0x47, /* QZ_KP7 0x59 */
0, /* */
0x48, /* QZ_KP8 0x5B */
0x49, /* QZ_KP9 0x5C */
0, /* */
0, /* */
0, /* */
0x3f, /* QZ_F5 0x60 */
0x40, /* QZ_F6 0x61 */
0x41, /* QZ_F7 0x62 */
0x3d, /* QZ_F3 0x63 */
0x42, /* QZ_F8 0x64 */
0x43, /* QZ_F9 0x65 */
0, /* */
0x57, /* QZ_F11 0x67 */
0, /* */
0x37|0x80, /* QZ_PRINT / F13 0x69 */
0x63, /* QZ_F16 0x6A */
0x46, /* QZ_SCROLLOCK 0x6B */
0, /* */
0x44, /* QZ_F10 0x6D */
0x5d|0x80, /* */
0x58, /* QZ_F12 0x6F */
0, /* */
0/* 0xe1,0x1d,0x45*/, /* QZ_PAUSE 0x71 */
0x52|0x80, /* QZ_INSERT / HELP 0x72 */
0x47|0x80, /* QZ_HOME 0x73 */
0x49|0x80, /* QZ_PAGEUP 0x74 */
0x53|0x80, /* QZ_DELETE 0x75 */
0x3e, /* QZ_F4 0x76 */
0x4f|0x80, /* QZ_END 0x77 */
0x3c, /* QZ_F2 0x78 */
0x51|0x80, /* QZ_PAGEDOWN 0x79 */
0x3b, /* QZ_F1 0x7A */
0x4b|0x80, /* QZ_LEFT 0x7B */
0x4d|0x80, /* QZ_RIGHT 0x7C */
0x50|0x80, /* QZ_DOWN 0x7D */
0x48|0x80, /* QZ_UP 0x7E */
0x5e|0x80, /* QZ_POWER 0x7F */ /* have different break key! */
};
if (keycode == 0)
{
/* This could be a modifier or it could be 'a'. */
{
case SDLK_MODE: /* alt gr */
case SDLK_RMETA:
case SDLK_LMETA:
/* Sssumes normal key. */
}
}
else
{
else
keycode = 0;
if (!keycode)
{
#ifdef DEBUG_bird
#endif
}
}
#ifdef DEBUG_bird
#endif
/*
* For now, just use the fallback code.
*/
#endif
return keycode;
}
/**
* Releases any modifier keys that are currently in pressed state.
*/
void SDLConsole::resetKeys(void)
{
int i;
for(i = 0; i < 256; i++)
{
if (gaModifiersState[i])
{
if (i & 0x80)
gaModifiersState[i] = 0;
}
}
}
/**
* Keyboard event handler.
*
* @param ev SDL keyboard event.
*/
{
int keycode, v;
#if defined(VBOXSDL_ADVANCED_OPTIONS) && defined(DEBUG) && 0
// first handle the debugger hotkeys
{
{
// pressing Alt-F12 toggles the supervisor recompiler
case SDLK_F12:
{
if (gMachineDebugger)
{
}
break;
}
// pressing Alt-F11 toggles the user recompiler
case SDLK_F11:
{
if (gMachineDebugger)
{
}
break;
}
// pressing Alt-F10 toggles the patch manager
case SDLK_F10:
{
if (gMachineDebugger)
{
}
break;
}
// pressing Alt-F9 toggles CSAM
case SDLK_F9:
{
if (gMachineDebugger)
{
}
break;
}
// pressing Alt-F8 toggles singlestepping mode
case SDLK_F8:
{
if (gMachineDebugger)
{
}
break;
}
default:
break;
}
}
// pressing Ctrl-F12 toggles the logger
{
if (fEnabled)
{
}
else
{
}
}
// pressing F12 sets a logmark
{
RTLogPrintf("****** LOGGING MARK ******\n");
}
// now update the titlebar flags
#endif
// the pause key is the weirdest, needs special handling
{
v = 0;
v |= 0x80;
return;
}
/*
* Perform SDL key event to scancode conversion
*/
switch(keycode)
{
case 0x00:
{
/* sent when leaving window: reset the modifiers state */
resetKeys();
return;
}
case 0x2a: /* Left Shift */
case 0x36: /* Right Shift */
case 0x1d: /* Left CTRL */
case 0x9d: /* Right CTRL */
case 0x38: /* Left ALT */
case 0xb8: /* Right ALT */
{
gaModifiersState[keycode] = 0;
else
break;
}
case 0x45: /* num lock */
case 0x3a: /* caps lock */
{
/* SDL does not send the key up event, so we generate it */
return;
}
}
/*
* Now we send the event. Apply extended and release prefixes.
*/
if (keycode & 0x80)
else
}
#ifdef RT_OS_DARWIN
/* Private interface in 10.3 and later. */
typedef int CGSConnection;
typedef enum
{
extern CGSConnection _CGSDefaultConnection(void);
extern CGError CGSGetGlobalHotKeyOperatingMode(CGSConnection Connection, CGSGlobalHotKeyOperatingMode *enmMode);
extern CGError CGSSetGlobalHotKeyOperatingMode(CGSConnection Connection, CGSGlobalHotKeyOperatingMode enmMode);
/** Keeping track of whether we disabled the hotkeys or not. */
static bool g_fHotKeysDisabled = false;
/** Whether we've connected or not. */
static bool g_fConnectedToCGS = false;
/** Cached connection. */
static CGSConnection g_CGSConnection;
/**
* Disables or enabled global hot keys.
*/
static void DisableGlobalHotKeys(bool fDisable)
{
if (!g_fConnectedToCGS)
{
g_fConnectedToCGS = true;
}
/* get current mode. */
/* calc new mode. */
if (fDisable)
{
if (enmMode != kCGSGlobalHotKeyEnable)
return;
}
else
{
if ( enmMode != kCGSGlobalHotKeyDisable
/*|| !g_fHotKeysDisabled*/)
return;
}
/* try set it and check the actual result. */
if (enmNewMode == enmMode)
}
#endif /* RT_OS_DARWIN */
/**
* Start grabbing the mouse.
*/
void SDLConsole::inputGrabStart()
{
#ifdef RT_OS_DARWIN
DisableGlobalHotKeys(true);
#endif
if (!gMouse->getNeedsHostCursor())
// dummy read to avoid moving the mouse
mfInputGrab = true;
}
/**
* End mouse grabbing.
*/
void SDLConsole::inputGrabEnd()
{
if (!gMouse->getNeedsHostCursor())
#ifdef RT_OS_DARWIN
DisableGlobalHotKeys(false);
#endif
mfInputGrab = false;
}
/**
* Query mouse position and button state from SDL and send to the VM
*
* @param dz Relative mouse wheel movement
*/
extern int GetRelativeMouseState(int *, int*);
extern int GetMouseState(int *, int*);
{
bool abs;
// process buttons
buttons = 0;
// now send the mouse event
if (abs)
{
/**
* @todo
* PutMouseEventAbsolute() expects x and y starting from 1,1.
* should we do the increment internally in PutMouseEventAbsolute()
* or state it in PutMouseEventAbsolute() docs?
*/
/* only send if outside the extra offset area */
if (y >= gFramebuffer->getYOffset())
}
else
{
}
}
/**
* Update the pointer shape or visibility.
*
* This is called when the mouse pointer shape changes or pointer is
* hidden/displaying. The new shape is passed as a caller allocated
* buffer that will be freed after returning.
*
* @param fVisible Whether the pointer is visible or not.
* @param fAlpha Alpha channel information is present.
* @param xHot Horizontal coordinate of the pointer hot spot.
* @param yHot Vertical coordinate of the pointer hot spot.
* @param width Pointer width in pixels.
* @param height Pointer height in pixels.
* @param pShape The shape buffer. If NULL, then only
* pointer visibility is being changed
*/
{
if (!data)
return;
if (rc)
delete data;
}
{
if (uPercent != g_uProgressPercent)
{
}
}
/**
* Build the titlebar string
*/
void SDLConsole::updateTitlebar()
{
char pszTitle[1024];
"Sun VirtualBox%s%s",
if (g_uProgressPercent != ~0U)
#if defined(VBOXSDL_ADVANCED_OPTIONS) && defined(DEBUG)
// do we have a debugger interface
if (gMachineDebugger)
{
// query the machine state
" [STEP=%d CS=%d PAT=%d RR0=%d RR3=%d LOG=%d]",
}
#endif /* DEBUG */
}
/**
* Updates the title bar while saving the state.
* @param iPercent Percentage.
*/
{
char szTitle[256];
}
/**
* Sets the pointer shape according to parameters.
* Must be called only from the main SDL thread.
*/
{
/*
* don't do anything if there are no guest additions loaded (anymore)
*/
if (!gMouse->getAbsoluteCoordinates())
return;
{
bool ok = false;
#if defined (RT_OS_WINDOWS)
void *lpBits;
// specifiy a supported 32 BPP alpha format for Windows XP
else
bi.bV5AlphaMask = 0;
// create the DIB section with an alpha channel
{
// create an empty mask bitmap
}
else
{
// for now, we assert if width is not multiple of 16. the
// alternative is to manually align the AND mask to 16 bits.
// create the AND mask bitmap
}
if (hBitmap && hMonoBitmap)
{
{
}
if (hAlphaCursor)
{
// here we do a dirty trick by substituting a Window Manager's
// cursor handle with the handle we created
// see SDL12/src/video/wincommon/SDL_sysmouse.c
if (old_wm_cursor)
{
}
ok = true;
}
}
if (hMonoBitmap)
::DeleteObject (hMonoBitmap);
if (hBitmap)
::DeleteObject (hBitmap);
if (img)
{
{
{
// convert AND mask to the alpha channel
{
if (!(x % 8))
byte = *(srcAndMaskPtr ++);
else
byte <<= 1;
if (byte & 0x80)
{
// X11 doesn't support inverted pixels (XOR ops,
// to be exact) in cursor shapes, so we detect such
// pixels and always replace them with black ones to
// make them visible at least over light colors
if (dstShapePtr [x] & 0x00FFFFFF)
dstShapePtr [x] = 0xFF000000;
else
dstShapePtr [x] = 0x00000000;
}
else
dstShapePtr [x] |= 0xFF000000;
}
}
}
if (cur)
{
// here we do a dirty trick by substituting a Window Manager's
// cursor handle with the handle we created
// see SDL12/src/video/x11/SDL_x11mouse.c
if (old_wm_cursor)
{
}
ok = true;
}
}
#endif /* VBOXBFE_WITH_X11 */
if (!ok)
{
}
}
else
{
{
}
else
{
}
}
}
void SDLConsole::resetCursor(void)
{
}
/**
* Handles a host key down event
*/
{
/*
* Revalidate the host key modifier
*/
return VERR_NOT_SUPPORTED;
/*
* What was pressed?
*/
{
/* Control-Alt-Delete */
case SDLK_DELETE:
{
break;
}
/*
* Fullscreen / Windowed toggle.
*/
case SDLK_f:
{
break;
}
/*
* Pause / Resume toggle.
*/
case SDLK_p:
{
if (machineState == VMSTATE_RUNNING)
VMCtrlPause();
else
VMCtrlResume();
break;
}
/*
* Reset the VM
*/
case SDLK_r:
{
VMCtrlReset();
break;
}
/*
* Terminate the VM
*/
case SDLK_q:
{
return VINF_EM_TERMINATE;
break;
}
/*
* Send ACPI power button press event
*/
case SDLK_h:
{
break;
}
/*
* Save the machine's state and exit
*/
case SDLK_s:
{
break;
}
/*
* Not a host key combination.
* Indicate this by returning false.
*/
default:
return VERR_NOT_SUPPORTED;
}
return VINF_SUCCESS;
}