2001-11-19 03:33:36 +03:00
|
|
|
#include "CMSWindowsPrimaryScreen.h"
|
2002-07-11 17:13:37 +04:00
|
|
|
#include "IScreenReceiver.h"
|
|
|
|
#include "IPrimaryScreenReceiver.h"
|
2002-06-11 02:06:45 +04:00
|
|
|
#include "CMSWindowsClipboard.h"
|
2002-06-24 01:53:31 +04:00
|
|
|
#include "CMSWindowsScreenSaver.h"
|
2002-06-09 01:48:00 +04:00
|
|
|
#include "CPlatform.h"
|
2002-07-11 17:13:37 +04:00
|
|
|
#include "CClipboard.h"
|
|
|
|
#include "ProtocolTypes.h"
|
2002-06-09 01:48:00 +04:00
|
|
|
#include "XScreen.h"
|
2001-11-25 21:32:41 +03:00
|
|
|
#include "XSynergy.h"
|
2002-06-09 01:48:00 +04:00
|
|
|
#include "CThread.h"
|
2002-06-11 02:06:45 +04:00
|
|
|
#include "CLog.h"
|
|
|
|
#include <cstring>
|
2001-11-19 03:33:36 +03:00
|
|
|
|
|
|
|
//
|
|
|
|
// CMSWindowsPrimaryScreen
|
|
|
|
//
|
|
|
|
|
2002-07-11 17:13:37 +04:00
|
|
|
CMSWindowsPrimaryScreen::CMSWindowsPrimaryScreen(
|
|
|
|
IScreenReceiver* receiver,
|
|
|
|
IPrimaryScreenReceiver* primaryReceiver) :
|
|
|
|
m_receiver(receiver),
|
|
|
|
m_primaryReceiver(primaryReceiver),
|
2002-06-11 02:06:45 +04:00
|
|
|
m_threadID(0),
|
|
|
|
m_desk(NULL),
|
|
|
|
m_deskName(),
|
|
|
|
m_window(NULL),
|
|
|
|
m_active(false),
|
|
|
|
m_mark(0),
|
|
|
|
m_markReceived(0),
|
|
|
|
m_nextClipboardWindow(NULL),
|
|
|
|
m_clipboardOwner(NULL)
|
2001-11-19 03:33:36 +03:00
|
|
|
{
|
2002-07-11 17:13:37 +04:00
|
|
|
assert(m_receiver != NULL);
|
|
|
|
assert(m_primaryReceiver != NULL);
|
|
|
|
|
2002-06-09 01:48:00 +04:00
|
|
|
// load the hook library
|
|
|
|
m_hookLibrary = LoadLibrary("synrgyhk");
|
|
|
|
if (m_hookLibrary == NULL) {
|
|
|
|
log((CLOG_ERR "failed to load hook library"));
|
|
|
|
throw XScreenOpenFailure();
|
|
|
|
}
|
2002-07-11 17:13:37 +04:00
|
|
|
m_setSides = (SetSidesFunc)GetProcAddress(m_hookLibrary, "setSides");
|
2002-06-09 01:48:00 +04:00
|
|
|
m_setZone = (SetZoneFunc)GetProcAddress(m_hookLibrary, "setZone");
|
|
|
|
m_setRelay = (SetRelayFunc)GetProcAddress(m_hookLibrary, "setRelay");
|
|
|
|
m_install = (InstallFunc)GetProcAddress(m_hookLibrary, "install");
|
|
|
|
m_uninstall = (UninstallFunc)GetProcAddress(m_hookLibrary, "uninstall");
|
2002-06-24 01:53:31 +04:00
|
|
|
m_init = (InitFunc)GetProcAddress(m_hookLibrary, "init");
|
|
|
|
m_cleanup = (CleanupFunc)GetProcAddress(m_hookLibrary, "cleanup");
|
2002-07-11 17:13:37 +04:00
|
|
|
if (m_setSides == NULL ||
|
|
|
|
m_setZone == NULL ||
|
2002-06-09 01:48:00 +04:00
|
|
|
m_setRelay == NULL ||
|
|
|
|
m_install == NULL ||
|
2002-06-24 01:53:31 +04:00
|
|
|
m_uninstall == NULL ||
|
|
|
|
m_init == NULL ||
|
|
|
|
m_cleanup == NULL) {
|
2002-06-09 01:48:00 +04:00
|
|
|
log((CLOG_ERR "invalid hook library"));
|
|
|
|
FreeLibrary(m_hookLibrary);
|
|
|
|
throw XScreenOpenFailure();
|
2002-06-01 23:26:11 +04:00
|
|
|
}
|
2002-06-09 01:48:00 +04:00
|
|
|
|
2002-06-24 01:53:31 +04:00
|
|
|
// get the screen saver functions
|
|
|
|
m_installScreenSaver = (InstallScreenSaverFunc)GetProcAddress(
|
|
|
|
m_hookLibrary, "installScreenSaver");
|
|
|
|
m_uninstallScreenSaver = (UninstallScreenSaverFunc)GetProcAddress(
|
|
|
|
m_hookLibrary, "uninstallScreenSaver");
|
|
|
|
if (m_installScreenSaver == NULL || m_uninstallScreenSaver == NULL) {
|
|
|
|
// disable uninstall if install is unavailable
|
|
|
|
m_uninstallScreenSaver = NULL;
|
|
|
|
}
|
|
|
|
|
2002-06-09 01:48:00 +04:00
|
|
|
// detect operating system
|
|
|
|
m_is95Family = CPlatform::isWindows95Family();
|
|
|
|
|
|
|
|
// make sure this thread has a message queue
|
|
|
|
MSG dummy;
|
|
|
|
PeekMessage(&dummy, NULL, WM_USER, WM_USER, PM_NOREMOVE);
|
2001-11-19 03:33:36 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
CMSWindowsPrimaryScreen::~CMSWindowsPrimaryScreen()
|
|
|
|
{
|
2002-06-09 01:48:00 +04:00
|
|
|
assert(m_hookLibrary != NULL);
|
2001-11-19 03:33:36 +03:00
|
|
|
assert(m_window == NULL);
|
2002-06-09 01:48:00 +04:00
|
|
|
|
2002-06-24 01:53:31 +04:00
|
|
|
// uninstall screen saver hook
|
|
|
|
if (m_uninstallScreenSaver != NULL) {
|
|
|
|
m_uninstallScreenSaver();
|
|
|
|
}
|
|
|
|
|
2002-06-09 01:48:00 +04:00
|
|
|
// done with hook library
|
|
|
|
FreeLibrary(m_hookLibrary);
|
2001-11-19 03:33:36 +03:00
|
|
|
}
|
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
void
|
|
|
|
CMSWindowsPrimaryScreen::run()
|
2001-11-19 03:33:36 +03:00
|
|
|
{
|
2002-06-09 01:48:00 +04:00
|
|
|
// must call run() from same thread as open()
|
|
|
|
assert(m_threadID == GetCurrentThreadId());
|
|
|
|
|
2002-05-22 21:01:17 +04:00
|
|
|
// change our priority
|
|
|
|
CThread::getCurrentThread().setPriority(-3);
|
|
|
|
|
2002-06-09 01:48:00 +04:00
|
|
|
// poll input desktop to see if it changes (preTranslateMessage()
|
|
|
|
// handles WM_TIMER)
|
|
|
|
UINT timer = 0;
|
|
|
|
if (!m_is95Family) {
|
|
|
|
SetTimer(NULL, 0, 200, NULL);
|
|
|
|
}
|
|
|
|
|
2002-05-22 21:01:17 +04:00
|
|
|
// run event loop
|
|
|
|
log((CLOG_INFO "entering event loop"));
|
2001-11-19 03:33:36 +03:00
|
|
|
doRun();
|
2002-05-22 21:01:17 +04:00
|
|
|
log((CLOG_INFO "exiting event loop"));
|
2002-06-09 01:48:00 +04:00
|
|
|
|
|
|
|
// remove timer
|
|
|
|
if (!m_is95Family) {
|
|
|
|
KillTimer(NULL, timer);
|
|
|
|
}
|
2001-11-19 03:33:36 +03:00
|
|
|
}
|
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
void
|
|
|
|
CMSWindowsPrimaryScreen::stop()
|
2001-11-19 03:33:36 +03:00
|
|
|
{
|
|
|
|
doStop();
|
|
|
|
}
|
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
void
|
2002-07-11 17:13:37 +04:00
|
|
|
CMSWindowsPrimaryScreen::open()
|
2001-11-19 03:33:36 +03:00
|
|
|
{
|
|
|
|
// open the display
|
|
|
|
openDisplay();
|
|
|
|
|
2002-06-09 01:48:00 +04:00
|
|
|
// initialize marks
|
|
|
|
m_mark = 0;
|
|
|
|
m_markReceived = 0;
|
|
|
|
nextMark();
|
2002-05-22 21:01:17 +04:00
|
|
|
|
2002-06-20 00:24:35 +04:00
|
|
|
// save cursor pos
|
|
|
|
POINT pos;
|
|
|
|
GetCursorPos(&pos);
|
|
|
|
m_x = pos.x;
|
|
|
|
m_y = pos.y;
|
|
|
|
|
2002-05-24 21:54:28 +04:00
|
|
|
// send screen info
|
2002-07-11 17:13:37 +04:00
|
|
|
CClientInfo info;
|
|
|
|
getScreenShape(info.m_x, info.m_y, info.m_w, info.m_h);
|
|
|
|
info.m_zoneSize = getJumpZoneSize();
|
|
|
|
info.m_mx = m_x;
|
|
|
|
info.m_my = m_y;
|
|
|
|
m_receiver->onInfoChanged(info);
|
2002-05-24 21:54:28 +04:00
|
|
|
|
2002-06-19 21:03:29 +04:00
|
|
|
// compute center pixel of primary screen
|
|
|
|
m_xCenter = GetSystemMetrics(SM_CXSCREEN) >> 1;
|
|
|
|
m_yCenter = GetSystemMetrics(SM_CYSCREEN) >> 1;
|
2002-06-09 01:48:00 +04:00
|
|
|
|
|
|
|
// get keyboard state
|
|
|
|
updateKeys();
|
|
|
|
|
2002-07-11 17:13:37 +04:00
|
|
|
// set jump zones
|
|
|
|
m_setZone(info.m_x, info.m_y, info.m_w, info.m_h, info.m_zoneSize);
|
|
|
|
|
2001-11-19 03:33:36 +03:00
|
|
|
// enter the screen
|
2002-06-09 01:48:00 +04:00
|
|
|
enterNoWarp();
|
2001-11-19 03:33:36 +03:00
|
|
|
}
|
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
void
|
|
|
|
CMSWindowsPrimaryScreen::close()
|
2001-11-19 03:33:36 +03:00
|
|
|
{
|
|
|
|
// close the display
|
|
|
|
closeDisplay();
|
|
|
|
}
|
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
void
|
2002-06-24 03:24:22 +04:00
|
|
|
CMSWindowsPrimaryScreen::enter(SInt32 x, SInt32 y, bool forScreenSaver)
|
2001-11-19 03:33:36 +03:00
|
|
|
{
|
|
|
|
log((CLOG_INFO "entering primary at %d,%d", x, y));
|
|
|
|
assert(m_active == true);
|
|
|
|
|
2002-06-09 01:48:00 +04:00
|
|
|
// enter the screen
|
|
|
|
enterNoWarp();
|
2001-11-19 03:33:36 +03:00
|
|
|
|
|
|
|
// warp to requested location
|
2002-06-24 03:24:22 +04:00
|
|
|
if (!forScreenSaver) {
|
|
|
|
warpCursor(x, y);
|
|
|
|
}
|
2001-11-19 03:33:36 +03:00
|
|
|
}
|
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
bool
|
|
|
|
CMSWindowsPrimaryScreen::leave()
|
2001-11-19 03:33:36 +03:00
|
|
|
{
|
|
|
|
log((CLOG_INFO "leaving primary"));
|
|
|
|
assert(m_active == false);
|
|
|
|
|
|
|
|
// all messages prior to now are invalid
|
|
|
|
nextMark();
|
|
|
|
|
2002-06-09 01:48:00 +04:00
|
|
|
// save active window, show ours, and grab mouse/keyboard
|
|
|
|
if (!onLeave()) {
|
|
|
|
return false;
|
2002-05-22 21:01:17 +04:00
|
|
|
}
|
2001-11-25 21:32:41 +03:00
|
|
|
|
2001-11-19 03:33:36 +03:00
|
|
|
// relay all mouse and keyboard events
|
2002-07-11 17:13:37 +04:00
|
|
|
m_setRelay(true);
|
2002-06-09 01:48:00 +04:00
|
|
|
|
|
|
|
// get state of keys as we leave
|
|
|
|
updateKeys();
|
|
|
|
|
|
|
|
// warp mouse to center of screen
|
2002-06-20 00:24:35 +04:00
|
|
|
warpCursorToCenter();
|
2002-06-09 01:48:00 +04:00
|
|
|
|
|
|
|
// ignore this many mouse motion events (not including the already
|
|
|
|
// queued events). on (at least) the win2k login desktop, one
|
|
|
|
// motion event is reported using a position from before the above
|
|
|
|
// warpCursor(). i don't know why it does that and other desktops
|
|
|
|
// don't have the same problem. anyway, simply ignoring that event
|
|
|
|
// works around it.
|
2002-06-20 00:24:35 +04:00
|
|
|
// FIXME -- is this true now that we're using mouse_event?
|
2002-06-09 01:48:00 +04:00
|
|
|
m_mouseMoveIgnore = 1;
|
|
|
|
|
|
|
|
// disable ctrl+alt+del, alt+tab, etc
|
2002-06-01 23:26:11 +04:00
|
|
|
if (m_is95Family) {
|
|
|
|
DWORD dummy = 0;
|
|
|
|
SystemParametersInfo(SPI_SETSCREENSAVERRUNNING, TRUE, &dummy, 0);
|
|
|
|
}
|
2001-11-19 03:33:36 +03:00
|
|
|
|
2002-05-22 21:01:17 +04:00
|
|
|
// discard messages until after the warp
|
2001-11-19 03:33:36 +03:00
|
|
|
nextMark();
|
|
|
|
|
|
|
|
// local client now active
|
|
|
|
m_active = true;
|
2001-11-25 21:32:41 +03:00
|
|
|
|
|
|
|
// if we think we own the clipboard but we don't then somebody
|
|
|
|
// grabbed the clipboard on this screen without us knowing.
|
|
|
|
// tell the server that this screen grabbed the clipboard.
|
|
|
|
//
|
|
|
|
// this works around bugs in the clipboard viewer chain.
|
|
|
|
// sometimes NT will simply never send WM_DRAWCLIPBOARD
|
|
|
|
// messages for no apparent reason and rebooting fixes the
|
|
|
|
// problem. since we don't want a broken clipboard until the
|
|
|
|
// next reboot we do this double check. clipboard ownership
|
|
|
|
// won't be reflected on other screens until we leave but at
|
|
|
|
// least the clipboard itself will work.
|
|
|
|
HWND clipboardOwner = GetClipboardOwner();
|
|
|
|
if (m_clipboardOwner != clipboardOwner) {
|
|
|
|
try {
|
|
|
|
m_clipboardOwner = clipboardOwner;
|
|
|
|
if (m_clipboardOwner != m_window) {
|
2002-07-11 17:13:37 +04:00
|
|
|
m_receiver->onGrabClipboard(kClipboardClipboard);
|
|
|
|
m_receiver->onGrabClipboard(kClipboardSelection);
|
2001-11-25 21:32:41 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (XBadClient&) {
|
|
|
|
// ignore
|
|
|
|
}
|
|
|
|
}
|
2002-06-03 22:53:18 +04:00
|
|
|
|
|
|
|
return true;
|
2001-11-19 03:33:36 +03:00
|
|
|
}
|
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
void
|
2002-07-11 17:13:37 +04:00
|
|
|
CMSWindowsPrimaryScreen::reconfigure(UInt32 activeSides)
|
2002-06-01 23:26:11 +04:00
|
|
|
{
|
2002-07-11 17:13:37 +04:00
|
|
|
m_setSides(activeSides);
|
2002-06-01 23:26:11 +04:00
|
|
|
}
|
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
void
|
2002-06-17 17:31:21 +04:00
|
|
|
CMSWindowsPrimaryScreen::warpCursor(SInt32 x, SInt32 y)
|
2001-11-19 03:33:36 +03:00
|
|
|
{
|
2002-05-22 21:01:17 +04:00
|
|
|
// set the cursor position without generating an event
|
|
|
|
SetCursorPos(x, y);
|
2002-06-20 00:24:35 +04:00
|
|
|
|
|
|
|
// save position as last position
|
|
|
|
m_x = x;
|
|
|
|
m_y = y;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CMSWindowsPrimaryScreen::warpCursorToCenter()
|
|
|
|
{
|
|
|
|
// warp to center. the extra info tells the hook DLL to send
|
|
|
|
// SYNERGY_MSG_POST_WARP instead of SYNERGY_MSG_MOUSE_MOVE.
|
|
|
|
SInt32 x, y, w, h;
|
|
|
|
getScreenShape(x, y, w, h);
|
|
|
|
mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE,
|
|
|
|
(DWORD)((65535.99 * (m_xCenter - x)) / (w - 1)),
|
|
|
|
(DWORD)((65535.99 * (m_yCenter - y)) / (h - 1)),
|
|
|
|
0,
|
|
|
|
0x12345678);
|
2001-11-19 03:33:36 +03:00
|
|
|
}
|
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
void
|
2002-06-17 17:31:21 +04:00
|
|
|
CMSWindowsPrimaryScreen::setClipboard(ClipboardID /*id*/,
|
|
|
|
const IClipboard* src)
|
2001-11-25 21:32:41 +03:00
|
|
|
{
|
|
|
|
assert(m_window != NULL);
|
|
|
|
|
|
|
|
CMSWindowsClipboard dst(m_window);
|
|
|
|
CClipboard::copy(&dst, src);
|
|
|
|
}
|
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
void
|
2002-06-17 17:31:21 +04:00
|
|
|
CMSWindowsPrimaryScreen::grabClipboard(ClipboardID /*id*/)
|
2001-11-19 03:33:36 +03:00
|
|
|
{
|
|
|
|
assert(m_window != NULL);
|
|
|
|
|
2001-11-25 21:32:41 +03:00
|
|
|
CMSWindowsClipboard clipboard(m_window);
|
2002-04-30 20:23:03 +04:00
|
|
|
if (clipboard.open(0)) {
|
2001-11-25 21:32:41 +03:00
|
|
|
clipboard.close();
|
2001-11-19 03:33:36 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
void
|
2002-06-17 17:31:21 +04:00
|
|
|
CMSWindowsPrimaryScreen::getClipboard(ClipboardID /*id*/,
|
|
|
|
IClipboard* dst) const
|
2001-11-19 03:33:36 +03:00
|
|
|
{
|
2001-11-25 21:32:41 +03:00
|
|
|
assert(m_window != NULL);
|
|
|
|
|
|
|
|
CMSWindowsClipboard src(m_window);
|
|
|
|
CClipboard::copy(dst, &src);
|
2001-11-19 03:33:36 +03:00
|
|
|
}
|
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
KeyModifierMask
|
|
|
|
CMSWindowsPrimaryScreen::getToggleMask() const
|
2002-04-30 21:48:11 +04:00
|
|
|
{
|
2002-05-22 21:01:17 +04:00
|
|
|
KeyModifierMask mask = 0;
|
2002-05-24 21:54:28 +04:00
|
|
|
if ((GetKeyState(VK_CAPITAL) & 0x01) != 0)
|
2002-04-30 21:48:11 +04:00
|
|
|
mask |= KeyModifierCapsLock;
|
2002-05-24 21:54:28 +04:00
|
|
|
if ((GetKeyState(VK_NUMLOCK) & 0x01) != 0)
|
2002-04-30 21:48:11 +04:00
|
|
|
mask |= KeyModifierNumLock;
|
2002-05-24 21:54:28 +04:00
|
|
|
if ((GetKeyState(VK_SCROLL) & 0x01) != 0)
|
2002-04-30 21:48:11 +04:00
|
|
|
mask |= KeyModifierScrollLock;
|
|
|
|
return mask;
|
|
|
|
}
|
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
bool
|
|
|
|
CMSWindowsPrimaryScreen::isLockedToScreen() const
|
2002-05-24 18:37:12 +04:00
|
|
|
{
|
2002-07-01 17:00:12 +04:00
|
|
|
// virtual key table. the table defines the virtual keys that are
|
|
|
|
// mapped to something (including mouse buttons, OEM and kanji keys
|
|
|
|
// but not unassigned or undefined keys).
|
|
|
|
static const UInt32 s_mappedKeys[] = {
|
|
|
|
0xfbff331e,
|
|
|
|
0x03ffffff,
|
|
|
|
0x3ffffffe,
|
|
|
|
0xffffffff,
|
|
|
|
0x000300ff,
|
|
|
|
0xfc000000,
|
|
|
|
0xf8000001,
|
|
|
|
0x7ffffe5f
|
|
|
|
};
|
|
|
|
|
|
|
|
// check each key. note that we cannot use GetKeyboardState() here
|
|
|
|
// since it reports the state of keys according to key messages
|
|
|
|
// that have been pulled off the queue. in general, we won't get
|
|
|
|
// these key messages because they're not for our window. if any
|
|
|
|
// key (or mouse button) is down then we're locked to the screen.
|
|
|
|
if (m_active) {
|
|
|
|
// use shadow keyboard state in m_keys
|
|
|
|
for (UInt32 i = 0; i < 256; ++i) {
|
|
|
|
if ((m_keys[i] & 0x80) != 0) {
|
2002-05-24 21:54:28 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2002-07-01 17:00:12 +04:00
|
|
|
else {
|
|
|
|
for (UInt32 i = 0; i < 256 / 32; ++i) {
|
|
|
|
for (UInt32 b = 1, j = 0; j < 32; b <<= 1, ++j) {
|
|
|
|
if ((s_mappedKeys[i] & b) != 0) {
|
|
|
|
if (GetAsyncKeyState(i * 32 + j) < 0) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2002-05-24 21:54:28 +04:00
|
|
|
|
|
|
|
// not locked
|
2002-05-24 18:37:12 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
void
|
|
|
|
CMSWindowsPrimaryScreen::onOpenDisplay()
|
2001-11-19 03:33:36 +03:00
|
|
|
{
|
|
|
|
assert(m_window == NULL);
|
|
|
|
|
2002-06-09 01:48:00 +04:00
|
|
|
// save thread id. we'll need to pass this to the hook library.
|
|
|
|
m_threadID = GetCurrentThreadId();
|
2001-11-19 03:33:36 +03:00
|
|
|
|
2002-06-24 01:53:31 +04:00
|
|
|
// initialize hook library
|
|
|
|
m_init(m_threadID);
|
|
|
|
|
2002-06-26 20:31:48 +04:00
|
|
|
try {
|
|
|
|
// install the screen saver hook
|
|
|
|
if (m_installScreenSaver != NULL) {
|
|
|
|
m_installScreenSaver();
|
|
|
|
}
|
2002-06-24 01:53:31 +04:00
|
|
|
|
2002-06-26 20:31:48 +04:00
|
|
|
// get the input desktop and switch to it
|
|
|
|
if (m_is95Family) {
|
|
|
|
if (!openDesktop()) {
|
|
|
|
throw XScreenOpenFailure();
|
|
|
|
}
|
2001-11-19 03:33:36 +03:00
|
|
|
}
|
2002-06-26 20:31:48 +04:00
|
|
|
else {
|
|
|
|
if (!switchDesktop(openInputDesktop())) {
|
|
|
|
throw XScreenOpenFailure();
|
|
|
|
}
|
2002-06-09 01:48:00 +04:00
|
|
|
}
|
2001-11-19 03:33:36 +03:00
|
|
|
}
|
2002-06-26 20:31:48 +04:00
|
|
|
catch (...) {
|
|
|
|
m_cleanup();
|
|
|
|
throw;
|
|
|
|
}
|
2001-11-19 03:33:36 +03:00
|
|
|
}
|
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
void
|
|
|
|
CMSWindowsPrimaryScreen::onCloseDisplay()
|
2001-11-19 03:33:36 +03:00
|
|
|
{
|
2002-06-09 01:48:00 +04:00
|
|
|
// disconnect from desktop
|
|
|
|
if (m_is95Family) {
|
|
|
|
closeDesktop();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
switchDesktop(NULL);
|
2001-11-19 03:33:36 +03:00
|
|
|
}
|
|
|
|
|
2002-06-24 01:53:31 +04:00
|
|
|
// uninstall the screen saver hook
|
|
|
|
if (m_uninstallScreenSaver != NULL) {
|
|
|
|
m_uninstallScreenSaver();
|
|
|
|
}
|
|
|
|
|
|
|
|
// cleanup hook library
|
|
|
|
m_cleanup();
|
|
|
|
|
2002-06-09 01:48:00 +04:00
|
|
|
// clear thread id
|
|
|
|
m_threadID = 0;
|
2001-11-25 21:32:41 +03:00
|
|
|
|
2002-06-09 01:48:00 +04:00
|
|
|
assert(m_window == NULL);
|
|
|
|
assert(m_desk == NULL);
|
2001-11-19 03:33:36 +03:00
|
|
|
}
|
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
bool
|
2002-06-17 17:31:21 +04:00
|
|
|
CMSWindowsPrimaryScreen::onPreTranslate(MSG* msg)
|
2001-11-19 03:33:36 +03:00
|
|
|
{
|
|
|
|
// handle event
|
|
|
|
switch (msg->message) {
|
2002-04-29 18:40:01 +04:00
|
|
|
case SYNERGY_MSG_MARK:
|
2001-11-19 03:33:36 +03:00
|
|
|
m_markReceived = msg->wParam;
|
|
|
|
return true;
|
|
|
|
|
2002-04-29 18:40:01 +04:00
|
|
|
case SYNERGY_MSG_KEY:
|
2002-06-09 01:48:00 +04:00
|
|
|
// ignore message if posted prior to last mark change
|
|
|
|
if (m_markReceived == m_mark) {
|
2001-11-25 21:32:41 +03:00
|
|
|
KeyModifierMask mask;
|
|
|
|
const KeyID key = mapKey(msg->wParam, msg->lParam, &mask);
|
|
|
|
if (key != kKeyNone) {
|
|
|
|
if ((msg->lParam & 0x80000000) == 0) {
|
|
|
|
// key press
|
|
|
|
const SInt32 repeat = (SInt32)(msg->lParam & 0xffff);
|
|
|
|
if (repeat >= 2) {
|
2002-04-30 20:23:03 +04:00
|
|
|
log((CLOG_DEBUG1 "event: key repeat key=%d mask=0x%04x count=%d", key, mask, repeat));
|
2002-07-11 17:13:37 +04:00
|
|
|
m_primaryReceiver->onKeyRepeat(key, mask, repeat);
|
2001-11-25 21:32:41 +03:00
|
|
|
}
|
|
|
|
else {
|
2002-04-30 20:23:03 +04:00
|
|
|
log((CLOG_DEBUG1 "event: key press key=%d mask=0x%04x", key, mask));
|
2002-07-11 17:13:37 +04:00
|
|
|
m_primaryReceiver->onKeyDown(key, mask);
|
2001-11-25 21:32:41 +03:00
|
|
|
}
|
2002-04-30 20:23:03 +04:00
|
|
|
|
|
|
|
// update key state
|
|
|
|
updateKey(msg->wParam, true);
|
2001-11-25 21:32:41 +03:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
// key release
|
2002-04-30 20:23:03 +04:00
|
|
|
log((CLOG_DEBUG1 "event: key release key=%d mask=0x%04x", key, mask));
|
2002-07-11 17:13:37 +04:00
|
|
|
m_primaryReceiver->onKeyUp(key, mask);
|
2002-04-30 20:23:03 +04:00
|
|
|
|
|
|
|
// update key state
|
|
|
|
updateKey(msg->wParam, false);
|
2001-11-25 21:32:41 +03:00
|
|
|
}
|
|
|
|
}
|
2002-05-22 21:01:17 +04:00
|
|
|
else {
|
|
|
|
log((CLOG_DEBUG2 "event: cannot map key wParam=%d lParam=0x%08x", msg->wParam, msg->lParam));
|
|
|
|
}
|
2001-11-19 03:33:36 +03:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
|
2002-04-29 18:40:01 +04:00
|
|
|
case SYNERGY_MSG_MOUSE_BUTTON:
|
2002-06-09 01:48:00 +04:00
|
|
|
// ignore message if posted prior to last mark change
|
|
|
|
if (m_markReceived == m_mark) {
|
2002-07-01 19:05:49 +04:00
|
|
|
static const int s_vkButton[] = {
|
|
|
|
0, // kButtonNone
|
|
|
|
VK_LBUTTON, // kButtonLeft, etc.
|
|
|
|
VK_MBUTTON,
|
|
|
|
VK_RBUTTON
|
|
|
|
};
|
|
|
|
|
2001-11-19 03:33:36 +03:00
|
|
|
const ButtonID button = mapButton(msg->wParam);
|
|
|
|
switch (msg->wParam) {
|
2002-04-29 18:40:01 +04:00
|
|
|
case WM_LBUTTONDOWN:
|
|
|
|
case WM_MBUTTONDOWN:
|
|
|
|
case WM_RBUTTONDOWN:
|
2002-04-30 20:23:03 +04:00
|
|
|
log((CLOG_DEBUG1 "event: button press button=%d", button));
|
2001-11-19 03:33:36 +03:00
|
|
|
if (button != kButtonNone) {
|
2002-07-11 17:13:37 +04:00
|
|
|
m_primaryReceiver->onMouseDown(button);
|
2002-07-01 19:05:49 +04:00
|
|
|
m_keys[s_vkButton[button]] |= 0x80;
|
2001-11-19 03:33:36 +03:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2002-04-29 18:40:01 +04:00
|
|
|
case WM_LBUTTONUP:
|
|
|
|
case WM_MBUTTONUP:
|
|
|
|
case WM_RBUTTONUP:
|
2002-04-30 20:23:03 +04:00
|
|
|
log((CLOG_DEBUG1 "event: button release button=%d", button));
|
2001-11-19 03:33:36 +03:00
|
|
|
if (button != kButtonNone) {
|
2002-07-11 17:13:37 +04:00
|
|
|
m_primaryReceiver->onMouseUp(button);
|
2002-07-01 19:05:49 +04:00
|
|
|
m_keys[s_vkButton[button]] &= ~0x80;
|
2001-11-19 03:33:36 +03:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
|
2002-05-23 22:35:08 +04:00
|
|
|
case SYNERGY_MSG_MOUSE_WHEEL:
|
2002-06-09 01:48:00 +04:00
|
|
|
// ignore message if posted prior to last mark change
|
|
|
|
if (m_markReceived == m_mark) {
|
2002-05-23 22:35:08 +04:00
|
|
|
log((CLOG_ERR "event: button wheel delta=%d %d", msg->wParam, msg->lParam));
|
2002-07-11 17:13:37 +04:00
|
|
|
m_primaryReceiver->onMouseWheel(msg->wParam);
|
2002-05-23 22:35:08 +04:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
|
2002-04-29 18:40:01 +04:00
|
|
|
case SYNERGY_MSG_MOUSE_MOVE:
|
2002-06-09 01:48:00 +04:00
|
|
|
// ignore message if posted prior to last mark change
|
|
|
|
if (m_markReceived == m_mark) {
|
|
|
|
SInt32 x = static_cast<SInt32>(msg->wParam);
|
|
|
|
SInt32 y = static_cast<SInt32>(msg->lParam);
|
2001-11-19 03:33:36 +03:00
|
|
|
if (!m_active) {
|
2002-07-11 17:13:37 +04:00
|
|
|
m_primaryReceiver->onMouseMovePrimary(x, y);
|
2001-11-19 03:33:36 +03:00
|
|
|
}
|
|
|
|
else {
|
2002-06-20 00:24:35 +04:00
|
|
|
// compute motion delta. this is relative to the
|
|
|
|
// last known mouse position.
|
|
|
|
x -= m_x;
|
|
|
|
y -= m_y;
|
|
|
|
|
|
|
|
// save position to compute delta of next motion
|
|
|
|
m_x = static_cast<SInt32>(msg->wParam);
|
|
|
|
m_y = static_cast<SInt32>(msg->lParam);
|
2001-11-19 03:33:36 +03:00
|
|
|
|
2002-06-09 01:48:00 +04:00
|
|
|
// ignore if the mouse didn't move or we're ignoring
|
|
|
|
// motion.
|
|
|
|
if (m_mouseMoveIgnore == 0) {
|
2002-06-20 00:24:35 +04:00
|
|
|
if (x != 0 || y != 0) {
|
|
|
|
// back to center
|
|
|
|
warpCursorToCenter();
|
2002-05-24 21:54:28 +04:00
|
|
|
|
2002-06-09 01:48:00 +04:00
|
|
|
// send motion
|
2002-07-11 17:13:37 +04:00
|
|
|
m_primaryReceiver->onMouseMoveSecondary(x, y);
|
2002-06-09 01:48:00 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// ignored one more motion event
|
|
|
|
--m_mouseMoveIgnore;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
2001-11-19 03:33:36 +03:00
|
|
|
|
2002-06-20 00:24:35 +04:00
|
|
|
case SYNERGY_MSG_POST_WARP:
|
|
|
|
m_x = static_cast<SInt32>(msg->wParam);
|
|
|
|
m_y = static_cast<SInt32>(msg->lParam);
|
|
|
|
return true;
|
|
|
|
|
2002-06-24 01:53:31 +04:00
|
|
|
case SYNERGY_MSG_SCREEN_SAVER:
|
|
|
|
if (msg->wParam != 0) {
|
|
|
|
if (getScreenSaver()->checkStarted(msg->message, FALSE, 0)) {
|
2002-07-11 17:13:37 +04:00
|
|
|
m_primaryReceiver->onScreenSaver(true);
|
2002-06-24 01:53:31 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2002-07-11 17:13:37 +04:00
|
|
|
m_primaryReceiver->onScreenSaver(false);
|
2002-06-24 01:53:31 +04:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
|
2002-06-09 01:48:00 +04:00
|
|
|
case WM_TIMER:
|
|
|
|
// if current desktop is not the input desktop then switch to it
|
|
|
|
if (!m_is95Family) {
|
|
|
|
HDESK desk = openInputDesktop();
|
|
|
|
if (desk != NULL) {
|
|
|
|
if (isCurrentDesktop(desk)) {
|
|
|
|
CloseDesktop(desk);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
switchDesktop(desk);
|
2002-05-24 21:54:28 +04:00
|
|
|
}
|
2001-11-19 03:33:36 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2001-11-25 21:32:41 +03:00
|
|
|
}
|
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
LRESULT
|
2002-06-17 17:31:21 +04:00
|
|
|
CMSWindowsPrimaryScreen::onEvent(HWND hwnd, UINT msg,
|
|
|
|
WPARAM wParam, LPARAM lParam)
|
2001-11-25 21:32:41 +03:00
|
|
|
{
|
|
|
|
switch (msg) {
|
2002-06-09 01:48:00 +04:00
|
|
|
case WM_QUERYENDSESSION:
|
|
|
|
if (m_is95Family) {
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_ENDSESSION:
|
|
|
|
if (m_is95Family) {
|
|
|
|
if (wParam == TRUE && lParam == 0) {
|
|
|
|
stop();
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
break;
|
2002-06-01 23:26:11 +04:00
|
|
|
|
2002-04-29 18:40:01 +04:00
|
|
|
case WM_PAINT:
|
2001-11-25 21:32:41 +03:00
|
|
|
ValidateRect(hwnd, NULL);
|
|
|
|
return 0;
|
2001-11-19 03:33:36 +03:00
|
|
|
|
2002-04-29 18:40:01 +04:00
|
|
|
case WM_DRAWCLIPBOARD:
|
2001-11-25 21:32:41 +03:00
|
|
|
log((CLOG_DEBUG "clipboard was taken"));
|
2001-11-19 03:33:36 +03:00
|
|
|
|
2001-11-25 21:32:41 +03:00
|
|
|
// first pass it on
|
2002-06-09 01:48:00 +04:00
|
|
|
if (m_nextClipboardWindow != NULL) {
|
|
|
|
SendMessage(m_nextClipboardWindow, msg, wParam, lParam);
|
|
|
|
}
|
2001-11-19 03:33:36 +03:00
|
|
|
|
2001-11-25 21:32:41 +03:00
|
|
|
// now notify server that somebody changed the clipboard.
|
|
|
|
// skip that if we're the new owner.
|
|
|
|
try {
|
|
|
|
m_clipboardOwner = GetClipboardOwner();
|
|
|
|
if (m_clipboardOwner != m_window) {
|
2002-07-11 17:13:37 +04:00
|
|
|
m_receiver->onGrabClipboard(kClipboardClipboard);
|
|
|
|
m_receiver->onGrabClipboard(kClipboardSelection);
|
2001-11-25 21:32:41 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (XBadClient&) {
|
|
|
|
// ignore. this can happen if we receive this event
|
|
|
|
// before we've fully started up.
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
|
2002-04-29 18:40:01 +04:00
|
|
|
case WM_CHANGECBCHAIN:
|
2002-06-09 01:48:00 +04:00
|
|
|
if (m_nextClipboardWindow == (HWND)wParam) {
|
2001-11-25 21:32:41 +03:00
|
|
|
m_nextClipboardWindow = (HWND)lParam;
|
2002-06-09 01:48:00 +04:00
|
|
|
}
|
|
|
|
else if (m_nextClipboardWindow != NULL) {
|
2001-11-25 21:32:41 +03:00
|
|
|
SendMessage(m_nextClipboardWindow, msg, wParam, lParam);
|
2002-06-09 01:48:00 +04:00
|
|
|
}
|
2001-11-25 21:32:41 +03:00
|
|
|
return 0;
|
2002-05-24 21:54:28 +04:00
|
|
|
|
2002-06-09 01:48:00 +04:00
|
|
|
case WM_DISPLAYCHANGE:
|
|
|
|
{
|
|
|
|
// screen resolution may have changed
|
2002-06-19 21:03:29 +04:00
|
|
|
SInt32 xOld, yOld, wOld, hOld;
|
|
|
|
getScreenShape(xOld, yOld, wOld, hOld);
|
|
|
|
updateScreenShape();
|
|
|
|
SInt32 x, y, w, h;
|
|
|
|
getScreenShape(x, y, w, h);
|
2002-06-09 01:48:00 +04:00
|
|
|
|
|
|
|
// do nothing if resolution hasn't changed
|
2002-06-19 21:03:29 +04:00
|
|
|
if (x != xOld || y != yOld || w != wOld || h != hOld) {
|
|
|
|
// recompute center pixel of primary screen
|
|
|
|
m_xCenter = GetSystemMetrics(SM_CXSCREEN) >> 1;
|
|
|
|
m_yCenter = GetSystemMetrics(SM_CYSCREEN) >> 1;
|
2002-06-09 01:48:00 +04:00
|
|
|
|
|
|
|
// warp mouse to center if active
|
|
|
|
if (m_active) {
|
2002-06-20 00:24:35 +04:00
|
|
|
warpCursorToCenter();
|
2002-06-09 01:48:00 +04:00
|
|
|
}
|
2002-05-24 21:54:28 +04:00
|
|
|
|
2002-06-09 01:48:00 +04:00
|
|
|
// tell hook about resize if not active
|
|
|
|
else {
|
2002-07-11 17:13:37 +04:00
|
|
|
m_setZone(x, y, w, h, getJumpZoneSize());
|
2002-06-09 01:48:00 +04:00
|
|
|
}
|
2002-05-24 21:54:28 +04:00
|
|
|
|
2002-06-09 01:48:00 +04:00
|
|
|
// send new screen info
|
|
|
|
POINT pos;
|
|
|
|
GetCursorPos(&pos);
|
2002-07-11 17:13:37 +04:00
|
|
|
CClientInfo info;
|
|
|
|
info.m_x = x;
|
|
|
|
info.m_y = y;
|
|
|
|
info.m_w = w;
|
|
|
|
info.m_h = h;
|
|
|
|
info.m_zoneSize = getJumpZoneSize();
|
|
|
|
info.m_mx = pos.x;
|
|
|
|
info.m_my = pos.y;
|
|
|
|
m_receiver->onInfoChanged(info);
|
2002-06-09 01:48:00 +04:00
|
|
|
}
|
2002-05-24 21:54:28 +04:00
|
|
|
|
2002-06-09 01:48:00 +04:00
|
|
|
return 0;
|
2002-05-24 21:54:28 +04:00
|
|
|
}
|
2002-06-09 01:48:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return DefWindowProc(hwnd, msg, wParam, lParam);
|
|
|
|
}
|
2002-05-24 21:54:28 +04:00
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
void
|
|
|
|
CMSWindowsPrimaryScreen::enterNoWarp()
|
2002-06-09 01:48:00 +04:00
|
|
|
{
|
|
|
|
// not active anymore
|
|
|
|
m_active = false;
|
2002-05-24 21:54:28 +04:00
|
|
|
|
2002-06-09 01:48:00 +04:00
|
|
|
// reset motion ignore count
|
|
|
|
m_mouseMoveIgnore = 0;
|
|
|
|
|
|
|
|
// enable ctrl+alt+del, alt+tab, etc
|
|
|
|
if (m_is95Family) {
|
|
|
|
DWORD dummy = 0;
|
|
|
|
SystemParametersInfo(SPI_SETSCREENSAVERRUNNING, FALSE, &dummy, 0);
|
|
|
|
}
|
|
|
|
|
2002-07-11 17:13:37 +04:00
|
|
|
// watch jump zones
|
|
|
|
m_setRelay(false);
|
2002-06-09 01:48:00 +04:00
|
|
|
|
|
|
|
// restore active window and hide our window
|
|
|
|
onEnter();
|
|
|
|
|
|
|
|
// all messages prior to now are invalid
|
|
|
|
nextMark();
|
|
|
|
}
|
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
void
|
|
|
|
CMSWindowsPrimaryScreen::onEnter()
|
2002-06-09 01:48:00 +04:00
|
|
|
{
|
|
|
|
// restore the active window and hide our window. we can only set
|
|
|
|
// the active window for another thread if we first attach our input
|
|
|
|
// to that thread.
|
|
|
|
ReleaseCapture();
|
|
|
|
if (m_lastActiveWindow != NULL) {
|
|
|
|
DWORD myThread = GetCurrentThreadId();
|
|
|
|
if (AttachThreadInput(myThread, m_lastActiveThread, TRUE)) {
|
|
|
|
// FIXME -- shouldn't raise window if X-Mouse is enabled
|
|
|
|
// but i have no idea how to do that or check if enabled.
|
|
|
|
SetActiveWindow(m_lastActiveWindow);
|
|
|
|
AttachThreadInput(myThread, m_lastActiveThread, FALSE);
|
|
|
|
}
|
2002-05-24 21:54:28 +04:00
|
|
|
}
|
2002-06-09 01:48:00 +04:00
|
|
|
ShowWindow(m_window, SW_HIDE);
|
|
|
|
}
|
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
bool
|
|
|
|
CMSWindowsPrimaryScreen::onLeave()
|
2002-06-09 01:48:00 +04:00
|
|
|
{
|
|
|
|
// remember the active window before we leave. GetActiveWindow()
|
|
|
|
// will only return the active window for the thread's queue (i.e.
|
|
|
|
// our app) but we need the globally active window. get that by
|
|
|
|
// attaching input to the foreground window's thread then calling
|
|
|
|
// GetActiveWindow() and then detaching our input.
|
|
|
|
m_lastActiveWindow = NULL;
|
|
|
|
m_lastForegroundWindow = GetForegroundWindow();
|
|
|
|
m_lastActiveThread = GetWindowThreadProcessId(
|
|
|
|
m_lastForegroundWindow, NULL);
|
|
|
|
if (m_lastActiveThread != 0) {
|
|
|
|
DWORD myThread = GetCurrentThreadId();
|
|
|
|
if (AttachThreadInput(myThread, m_lastActiveThread, TRUE)) {
|
|
|
|
m_lastActiveWindow = GetActiveWindow();
|
|
|
|
AttachThreadInput(myThread, m_lastActiveThread, FALSE);
|
|
|
|
}
|
2001-11-19 03:33:36 +03:00
|
|
|
}
|
2002-05-22 21:01:17 +04:00
|
|
|
|
2002-06-09 01:48:00 +04:00
|
|
|
// show our window
|
|
|
|
ShowWindow(m_window, SW_SHOW);
|
|
|
|
|
|
|
|
// get keyboard input and capture mouse
|
|
|
|
SetActiveWindow(m_window);
|
|
|
|
SetFocus(m_window);
|
|
|
|
SetCapture(m_window);
|
|
|
|
|
|
|
|
return true;
|
2001-11-19 03:33:36 +03:00
|
|
|
}
|
|
|
|
|
2002-07-11 17:13:37 +04:00
|
|
|
SInt32
|
|
|
|
CMSWindowsPrimaryScreen::getJumpZoneSize() const
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
void
|
|
|
|
CMSWindowsPrimaryScreen::nextMark()
|
2001-11-19 03:33:36 +03:00
|
|
|
{
|
2002-06-09 01:48:00 +04:00
|
|
|
// next mark
|
|
|
|
++m_mark;
|
|
|
|
|
|
|
|
// mark point in message queue where the mark was changed
|
|
|
|
PostThreadMessage(m_threadID, SYNERGY_MSG_MARK, m_mark, 0);
|
|
|
|
}
|
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
bool
|
|
|
|
CMSWindowsPrimaryScreen::openDesktop()
|
2002-06-09 01:48:00 +04:00
|
|
|
{
|
|
|
|
// install hooks
|
2002-06-24 01:53:31 +04:00
|
|
|
m_install();
|
2002-06-09 01:48:00 +04:00
|
|
|
|
|
|
|
// note -- we use a fullscreen window to grab input. it should
|
|
|
|
// be possible to use a 1x1 window but i've run into problems
|
|
|
|
// with losing keyboard input (focus?) in that case.
|
|
|
|
// unfortunately, hiding the full screen window (when entering
|
|
|
|
// the scren causes all other windows to redraw).
|
2002-06-19 21:03:29 +04:00
|
|
|
SInt32 x, y, w, h;
|
|
|
|
getScreenShape(x, y, w, h);
|
2001-11-19 03:33:36 +03:00
|
|
|
|
2002-06-09 01:48:00 +04:00
|
|
|
// create the window
|
|
|
|
m_window = CreateWindowEx(WS_EX_TOPMOST |
|
|
|
|
WS_EX_TRANSPARENT |
|
|
|
|
WS_EX_TOOLWINDOW,
|
|
|
|
(LPCTSTR)getClass(),
|
|
|
|
"Synergy",
|
|
|
|
WS_POPUP,
|
2002-06-19 21:03:29 +04:00
|
|
|
x, y, w, h, NULL, NULL,
|
2002-06-09 01:48:00 +04:00
|
|
|
getInstance(),
|
|
|
|
NULL);
|
|
|
|
if (m_window == NULL) {
|
|
|
|
log((CLOG_ERR "failed to create window: %d", GetLastError()));
|
|
|
|
m_uninstall();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// install our clipboard snooper
|
|
|
|
m_nextClipboardWindow = SetClipboardViewer(m_window);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
void
|
|
|
|
CMSWindowsPrimaryScreen::closeDesktop()
|
2002-06-09 01:48:00 +04:00
|
|
|
{
|
|
|
|
// destroy old window
|
|
|
|
if (m_window != NULL) {
|
|
|
|
// restore active window and hide ours
|
|
|
|
if (m_active) {
|
|
|
|
onEnter();
|
|
|
|
}
|
|
|
|
|
|
|
|
// first remove clipboard snooper
|
|
|
|
ChangeClipboardChain(m_window, m_nextClipboardWindow);
|
|
|
|
m_nextClipboardWindow = NULL;
|
|
|
|
|
|
|
|
// we no longer own the clipboard
|
|
|
|
if (m_clipboardOwner == m_window) {
|
|
|
|
m_clipboardOwner = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// now destroy window
|
|
|
|
DestroyWindow(m_window);
|
|
|
|
m_window = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// unhook
|
|
|
|
m_uninstall();
|
|
|
|
}
|
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
bool
|
2002-06-17 17:31:21 +04:00
|
|
|
CMSWindowsPrimaryScreen::switchDesktop(HDESK desk)
|
2002-06-09 01:48:00 +04:00
|
|
|
{
|
|
|
|
// did we own the clipboard?
|
|
|
|
bool ownClipboard = (m_clipboardOwner == m_window);
|
|
|
|
|
|
|
|
// destroy old window
|
|
|
|
if (m_window != NULL) {
|
|
|
|
// restore active window and hide ours
|
|
|
|
if (m_active) {
|
|
|
|
onEnter();
|
|
|
|
}
|
|
|
|
|
|
|
|
// first remove clipboard snooper
|
|
|
|
ChangeClipboardChain(m_window, m_nextClipboardWindow);
|
|
|
|
m_nextClipboardWindow = NULL;
|
|
|
|
|
|
|
|
// we no longer own the clipboard
|
|
|
|
if (ownClipboard) {
|
|
|
|
m_clipboardOwner = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// now destroy window
|
|
|
|
DestroyWindow(m_window);
|
|
|
|
m_window = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// unhook
|
|
|
|
if (m_desk != NULL) {
|
|
|
|
m_uninstall();
|
|
|
|
CloseDesktop(m_desk);
|
|
|
|
m_desk = NULL;
|
|
|
|
m_deskName = "";
|
|
|
|
}
|
|
|
|
|
|
|
|
// if no new desktop then we're done
|
|
|
|
if (desk == NULL) {
|
|
|
|
log((CLOG_INFO "disconnecting desktop"));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// set the desktop. can only do this when there are no windows
|
|
|
|
// and hooks on the current desktop owned by this thread.
|
|
|
|
if (SetThreadDesktop(desk) == 0) {
|
|
|
|
log((CLOG_ERR "failed to set desktop: %d", GetLastError()));
|
|
|
|
CloseDesktop(desk);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// install hooks
|
2002-06-24 01:53:31 +04:00
|
|
|
m_install();
|
2002-06-09 01:48:00 +04:00
|
|
|
|
|
|
|
// note -- we use a fullscreen window to grab input. it should
|
|
|
|
// be possible to use a 1x1 window but i've run into problems
|
|
|
|
// with losing keyboard input (focus?) in that case.
|
|
|
|
// unfortunately, hiding the full screen window (when entering
|
|
|
|
// the scren causes all other windows to redraw).
|
2002-06-19 21:03:29 +04:00
|
|
|
SInt32 x, y, w, h;
|
|
|
|
getScreenShape(x, y, w, h);
|
2002-06-09 01:48:00 +04:00
|
|
|
|
|
|
|
// create the window
|
|
|
|
m_window = CreateWindowEx(WS_EX_TOPMOST |
|
|
|
|
WS_EX_TRANSPARENT |
|
|
|
|
WS_EX_TOOLWINDOW,
|
|
|
|
(LPCTSTR)getClass(),
|
|
|
|
"Synergy",
|
|
|
|
WS_POPUP,
|
2002-06-19 21:03:29 +04:00
|
|
|
x, y, w, h, NULL, NULL,
|
2002-06-09 01:48:00 +04:00
|
|
|
getInstance(),
|
|
|
|
NULL);
|
|
|
|
if (m_window == NULL) {
|
|
|
|
log((CLOG_ERR "failed to create window: %d", GetLastError()));
|
|
|
|
m_uninstall();
|
|
|
|
CloseDesktop(desk);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// install our clipboard snooper
|
|
|
|
m_nextClipboardWindow = SetClipboardViewer(m_window);
|
|
|
|
|
|
|
|
// reassert clipboard ownership
|
|
|
|
if (ownClipboard) {
|
|
|
|
// FIXME
|
|
|
|
}
|
|
|
|
|
|
|
|
// save new desktop
|
|
|
|
m_desk = desk;
|
|
|
|
m_deskName = getDesktopName(m_desk);
|
|
|
|
log((CLOG_INFO "switched to desktop %s", m_deskName.c_str()));
|
|
|
|
|
|
|
|
// get active window and show ours
|
|
|
|
if (m_active) {
|
|
|
|
onLeave();
|
|
|
|
}
|
|
|
|
else {
|
2002-07-11 17:13:37 +04:00
|
|
|
// watch jump zones
|
|
|
|
m_setRelay(false);
|
2002-06-09 01:48:00 +04:00
|
|
|
|
|
|
|
// all messages prior to now are invalid
|
|
|
|
nextMark();
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
CString
|
|
|
|
CMSWindowsPrimaryScreen::getCurrentDesktopName() const
|
2002-06-09 01:48:00 +04:00
|
|
|
{
|
|
|
|
return m_deskName;
|
2001-11-19 03:33:36 +03:00
|
|
|
}
|
|
|
|
|
2001-11-25 21:32:41 +03:00
|
|
|
static const KeyID g_virtualKey[] =
|
2001-11-19 03:33:36 +03:00
|
|
|
{
|
2001-11-25 21:32:41 +03:00
|
|
|
/* 0x00 */ kKeyNone, // reserved
|
|
|
|
/* 0x01 */ kKeyNone, // VK_LBUTTON
|
|
|
|
/* 0x02 */ kKeyNone, // VK_RBUTTON
|
|
|
|
/* 0x03 */ 0xff6b, // VK_CANCEL XK_Break
|
|
|
|
/* 0x04 */ kKeyNone, // VK_MBUTTON
|
|
|
|
/* 0x05 */ kKeyNone, // undefined
|
|
|
|
/* 0x06 */ kKeyNone, // undefined
|
|
|
|
/* 0x07 */ kKeyNone, // undefined
|
|
|
|
/* 0x08 */ 0xff08, // VK_BACK XK_Backspace
|
|
|
|
/* 0x09 */ 0xff09, // VK_TAB VK_Tab
|
|
|
|
/* 0x0a */ kKeyNone, // undefined
|
|
|
|
/* 0x0b */ kKeyNone, // undefined
|
|
|
|
/* 0x0c */ 0xff0b, // VK_CLEAR XK_Clear
|
|
|
|
/* 0x0d */ 0xff0d, // VK_RETURN XK_Return
|
|
|
|
/* 0x0e */ kKeyNone, // undefined
|
|
|
|
/* 0x0f */ kKeyNone, // undefined
|
|
|
|
/* 0x10 */ 0xffe1, // VK_SHIFT XK_Shift_L
|
|
|
|
/* 0x11 */ 0xffe3, // VK_CONTROL XK_Control_L
|
|
|
|
/* 0x12 */ 0xffe9, // VK_MENU XK_Alt_L
|
|
|
|
/* 0x13 */ 0xff13, // VK_PAUSE XK_Pause
|
|
|
|
/* 0x14 */ 0xffe5, // VK_CAPITAL XK_Caps_Lock
|
|
|
|
/* 0x15 */ kKeyNone, // VK_KANA
|
|
|
|
/* 0x16 */ kKeyNone, // VK_HANGUL
|
|
|
|
/* 0x17 */ kKeyNone, // VK_JUNJA
|
|
|
|
/* 0x18 */ kKeyNone, // VK_FINAL
|
|
|
|
/* 0x19 */ kKeyNone, // VK_KANJI
|
|
|
|
/* 0x1a */ kKeyNone, // undefined
|
|
|
|
/* 0x1b */ 0xff1b, // VK_ESCAPE XK_Escape
|
|
|
|
/* 0x1c */ kKeyNone, // VK_CONVERT
|
|
|
|
/* 0x1d */ kKeyNone, // VK_NONCONVERT
|
|
|
|
/* 0x1e */ kKeyNone, // VK_ACCEPT
|
|
|
|
/* 0x1f */ kKeyNone, // VK_MODECHANGE
|
2002-04-30 20:23:03 +04:00
|
|
|
/* 0x20 */ 0x0020, // VK_SPACE XK_space
|
2001-11-25 21:32:41 +03:00
|
|
|
/* 0x21 */ 0xff55, // VK_PRIOR XK_Prior
|
|
|
|
/* 0x22 */ 0xff56, // VK_NEXT XK_Next
|
|
|
|
/* 0x23 */ 0xff57, // VK_END XK_End
|
|
|
|
/* 0x24 */ 0xff50, // VK_HOME XK_Home
|
|
|
|
/* 0x25 */ 0xff51, // VK_LEFT XK_Left
|
|
|
|
/* 0x26 */ 0xff52, // VK_UP XK_Up
|
|
|
|
/* 0x27 */ 0xff53, // VK_RIGHT XK_Right
|
|
|
|
/* 0x28 */ 0xff54, // VK_DOWN XK_Down
|
|
|
|
/* 0x29 */ 0xff60, // VK_SELECT XK_Select
|
|
|
|
/* 0x2a */ kKeyNone, // VK_PRINT
|
|
|
|
/* 0x2b */ 0xff62, // VK_EXECUTE XK_Execute
|
|
|
|
/* 0x2c */ 0xff61, // VK_SNAPSHOT XK_Print
|
|
|
|
/* 0x2d */ 0xff63, // VK_INSERT XK_Insert
|
|
|
|
/* 0x2e */ 0xffff, // VK_DELETE XK_Delete
|
|
|
|
/* 0x2f */ 0xff6a, // VK_HELP XK_Help
|
2002-04-30 20:23:03 +04:00
|
|
|
/* 0x30 */ kKeyNone, // VK_0 XK_0
|
|
|
|
/* 0x31 */ kKeyNone, // VK_1 XK_1
|
|
|
|
/* 0x32 */ kKeyNone, // VK_2 XK_2
|
|
|
|
/* 0x33 */ kKeyNone, // VK_3 XK_3
|
|
|
|
/* 0x34 */ kKeyNone, // VK_4 XK_4
|
|
|
|
/* 0x35 */ kKeyNone, // VK_5 XK_5
|
|
|
|
/* 0x36 */ kKeyNone, // VK_6 XK_6
|
|
|
|
/* 0x37 */ kKeyNone, // VK_7 XK_7
|
|
|
|
/* 0x38 */ kKeyNone, // VK_8 XK_8
|
|
|
|
/* 0x39 */ kKeyNone, // VK_9 XK_9
|
2001-11-25 21:32:41 +03:00
|
|
|
/* 0x3a */ kKeyNone, // undefined
|
|
|
|
/* 0x3b */ kKeyNone, // undefined
|
|
|
|
/* 0x3c */ kKeyNone, // undefined
|
|
|
|
/* 0x3d */ kKeyNone, // undefined
|
|
|
|
/* 0x3e */ kKeyNone, // undefined
|
|
|
|
/* 0x3f */ kKeyNone, // undefined
|
|
|
|
/* 0x40 */ kKeyNone, // undefined
|
2002-04-30 20:23:03 +04:00
|
|
|
/* 0x41 */ kKeyNone, // VK_A XK_A
|
|
|
|
/* 0x42 */ kKeyNone, // VK_B XK_B
|
|
|
|
/* 0x43 */ kKeyNone, // VK_C XK_C
|
|
|
|
/* 0x44 */ kKeyNone, // VK_D XK_D
|
|
|
|
/* 0x45 */ kKeyNone, // VK_E XK_E
|
|
|
|
/* 0x46 */ kKeyNone, // VK_F XK_F
|
|
|
|
/* 0x47 */ kKeyNone, // VK_G XK_G
|
|
|
|
/* 0x48 */ kKeyNone, // VK_H XK_H
|
|
|
|
/* 0x49 */ kKeyNone, // VK_I XK_I
|
|
|
|
/* 0x4a */ kKeyNone, // VK_J XK_J
|
|
|
|
/* 0x4b */ kKeyNone, // VK_K XK_K
|
|
|
|
/* 0x4c */ kKeyNone, // VK_L XK_L
|
|
|
|
/* 0x4d */ kKeyNone, // VK_M XK_M
|
|
|
|
/* 0x4e */ kKeyNone, // VK_N XK_N
|
|
|
|
/* 0x4f */ kKeyNone, // VK_O XK_O
|
|
|
|
/* 0x50 */ kKeyNone, // VK_P XK_P
|
|
|
|
/* 0x51 */ kKeyNone, // VK_Q XK_Q
|
|
|
|
/* 0x52 */ kKeyNone, // VK_R XK_R
|
|
|
|
/* 0x53 */ kKeyNone, // VK_S XK_S
|
|
|
|
/* 0x54 */ kKeyNone, // VK_T XK_T
|
|
|
|
/* 0x55 */ kKeyNone, // VK_U XK_U
|
|
|
|
/* 0x56 */ kKeyNone, // VK_V XK_V
|
|
|
|
/* 0x57 */ kKeyNone, // VK_W XK_W
|
|
|
|
/* 0x58 */ kKeyNone, // VK_X XK_X
|
|
|
|
/* 0x59 */ kKeyNone, // VK_Y XK_Y
|
|
|
|
/* 0x5a */ kKeyNone, // VK_Z XK_Z
|
2001-11-25 21:32:41 +03:00
|
|
|
/* 0x5b */ 0xffe7, // VK_LWIN XK_Meta_L
|
|
|
|
/* 0x5c */ 0xffe8, // VK_RWIN XK_Meta_R
|
|
|
|
/* 0x5d */ 0xff67, // VK_APPS XK_Menu
|
|
|
|
/* 0x5e */ kKeyNone, // undefined
|
|
|
|
/* 0x5f */ kKeyNone, // undefined
|
|
|
|
/* 0x60 */ 0xffb0, // VK_NUMPAD0 XK_KP_0
|
|
|
|
/* 0x61 */ 0xffb1, // VK_NUMPAD1 XK_KP_1
|
|
|
|
/* 0x62 */ 0xffb2, // VK_NUMPAD2 XK_KP_2
|
|
|
|
/* 0x63 */ 0xffb3, // VK_NUMPAD3 XK_KP_3
|
|
|
|
/* 0x64 */ 0xffb4, // VK_NUMPAD4 XK_KP_4
|
|
|
|
/* 0x65 */ 0xffb5, // VK_NUMPAD5 XK_KP_5
|
|
|
|
/* 0x66 */ 0xffb6, // VK_NUMPAD6 XK_KP_6
|
|
|
|
/* 0x67 */ 0xffb7, // VK_NUMPAD7 XK_KP_7
|
|
|
|
/* 0x68 */ 0xffb8, // VK_NUMPAD8 XK_KP_8
|
|
|
|
/* 0x69 */ 0xffb9, // VK_NUMPAD9 XK_KP_9
|
|
|
|
/* 0x6a */ 0xffaa, // VK_MULTIPLY XK_KP_Multiply
|
|
|
|
/* 0x6b */ 0xffab, // VK_ADD XK_KP_Add
|
|
|
|
/* 0x6c */ 0xffac, // VK_SEPARATOR XK_KP_Separator
|
|
|
|
/* 0x6d */ 0xffad, // VK_SUBTRACT XK_KP_Subtract
|
|
|
|
/* 0x6e */ 0xffae, // VK_DECIMAL XK_KP_Decimal
|
|
|
|
/* 0x6f */ 0xffaf, // VK_DIVIDE XK_KP_Divide
|
|
|
|
/* 0x70 */ 0xffbe, // VK_F1 XK_F1
|
|
|
|
/* 0x71 */ 0xffbf, // VK_F2 XK_F2
|
|
|
|
/* 0x72 */ 0xffc0, // VK_F3 XK_F3
|
|
|
|
/* 0x73 */ 0xffc1, // VK_F4 XK_F4
|
|
|
|
/* 0x74 */ 0xffc2, // VK_F5 XK_F5
|
|
|
|
/* 0x75 */ 0xffc3, // VK_F6 XK_F6
|
|
|
|
/* 0x76 */ 0xffc4, // VK_F7 XK_F7
|
|
|
|
/* 0x77 */ 0xffc5, // VK_F8 XK_F8
|
|
|
|
/* 0x78 */ 0xffc6, // VK_F9 XK_F9
|
|
|
|
/* 0x79 */ 0xffc7, // VK_F10 XK_F10
|
|
|
|
/* 0x7a */ 0xffc8, // VK_F11 XK_F11
|
|
|
|
/* 0x7b */ 0xffc9, // VK_F12 XK_F12
|
|
|
|
/* 0x7c */ 0xffca, // VK_F13 XK_F13
|
|
|
|
/* 0x7d */ 0xffcb, // VK_F14 XK_F14
|
|
|
|
/* 0x7e */ 0xffcc, // VK_F15 XK_F15
|
|
|
|
/* 0x7f */ 0xffcd, // VK_F16 XK_F16
|
|
|
|
/* 0x80 */ 0xffce, // VK_F17 XK_F17
|
|
|
|
/* 0x81 */ 0xffcf, // VK_F18 XK_F18
|
|
|
|
/* 0x82 */ 0xffd0, // VK_F19 XK_F19
|
|
|
|
/* 0x83 */ 0xffd1, // VK_F20 XK_F20
|
|
|
|
/* 0x84 */ 0xffd2, // VK_F21 XK_F21
|
|
|
|
/* 0x85 */ 0xffd3, // VK_F22 XK_F22
|
|
|
|
/* 0x86 */ 0xffd4, // VK_F23 XK_F23
|
|
|
|
/* 0x87 */ 0xffd5, // VK_F24 XK_F24
|
|
|
|
/* 0x88 */ kKeyNone, // unassigned
|
|
|
|
/* 0x89 */ kKeyNone, // unassigned
|
|
|
|
/* 0x8a */ kKeyNone, // unassigned
|
|
|
|
/* 0x8b */ kKeyNone, // unassigned
|
|
|
|
/* 0x8c */ kKeyNone, // unassigned
|
|
|
|
/* 0x8d */ kKeyNone, // unassigned
|
|
|
|
/* 0x8e */ kKeyNone, // unassigned
|
|
|
|
/* 0x8f */ kKeyNone, // unassigned
|
|
|
|
/* 0x90 */ 0xff7f, // VK_NUMLOCK XK_Num_Lock
|
|
|
|
/* 0x91 */ 0xff14, // VK_SCROLL XK_Scroll_Lock
|
|
|
|
/* 0x92 */ kKeyNone, // unassigned
|
|
|
|
/* 0x93 */ kKeyNone, // unassigned
|
|
|
|
/* 0x94 */ kKeyNone, // unassigned
|
|
|
|
/* 0x95 */ kKeyNone, // unassigned
|
|
|
|
/* 0x96 */ kKeyNone, // unassigned
|
|
|
|
/* 0x97 */ kKeyNone, // unassigned
|
|
|
|
/* 0x98 */ kKeyNone, // unassigned
|
|
|
|
/* 0x99 */ kKeyNone, // unassigned
|
|
|
|
/* 0x9a */ kKeyNone, // unassigned
|
|
|
|
/* 0x9b */ kKeyNone, // unassigned
|
|
|
|
/* 0x9c */ kKeyNone, // unassigned
|
|
|
|
/* 0x9d */ kKeyNone, // unassigned
|
|
|
|
/* 0x9e */ kKeyNone, // unassigned
|
|
|
|
/* 0x9f */ kKeyNone, // unassigned
|
2002-04-30 20:23:03 +04:00
|
|
|
/* 0xa0 */ 0xffe1, // VK_LSHIFT XK_Shift_L
|
|
|
|
/* 0xa1 */ 0xffe2, // VK_RSHIFT XK_Shift_R
|
|
|
|
/* 0xa2 */ 0xffe3, // VK_LCONTROL XK_Control_L
|
|
|
|
/* 0xa3 */ 0xffe4, // VK_RCONTROL XK_Control_R
|
|
|
|
/* 0xa4 */ 0xffe9, // VK_LMENU XK_Alt_L
|
|
|
|
/* 0xa5 */ 0xffea, // VK_RMENU XK_Alt_R
|
2001-11-25 21:32:41 +03:00
|
|
|
/* 0xa6 */ kKeyNone, // unassigned
|
|
|
|
/* 0xa7 */ kKeyNone, // unassigned
|
|
|
|
/* 0xa8 */ kKeyNone, // unassigned
|
|
|
|
/* 0xa9 */ kKeyNone, // unassigned
|
|
|
|
/* 0xaa */ kKeyNone, // unassigned
|
|
|
|
/* 0xab */ kKeyNone, // unassigned
|
|
|
|
/* 0xac */ kKeyNone, // unassigned
|
|
|
|
/* 0xad */ kKeyNone, // unassigned
|
|
|
|
/* 0xae */ kKeyNone, // unassigned
|
|
|
|
/* 0xaf */ kKeyNone, // unassigned
|
|
|
|
/* 0xb0 */ kKeyNone, // unassigned
|
|
|
|
/* 0xb1 */ kKeyNone, // unassigned
|
|
|
|
/* 0xb2 */ kKeyNone, // unassigned
|
|
|
|
/* 0xb3 */ kKeyNone, // unassigned
|
|
|
|
/* 0xb4 */ kKeyNone, // unassigned
|
|
|
|
/* 0xb5 */ kKeyNone, // unassigned
|
|
|
|
/* 0xb6 */ kKeyNone, // unassigned
|
|
|
|
/* 0xb7 */ kKeyNone, // unassigned
|
|
|
|
/* 0xb8 */ kKeyNone, // unassigned
|
|
|
|
/* 0xb9 */ kKeyNone, // unassigned
|
|
|
|
/* 0xba */ kKeyNone, // OEM specific
|
|
|
|
/* 0xbb */ kKeyNone, // OEM specific
|
|
|
|
/* 0xbc */ kKeyNone, // OEM specific
|
|
|
|
/* 0xbd */ kKeyNone, // OEM specific
|
|
|
|
/* 0xbe */ kKeyNone, // OEM specific
|
|
|
|
/* 0xbf */ kKeyNone, // OEM specific
|
|
|
|
/* 0xc0 */ kKeyNone, // OEM specific
|
|
|
|
/* 0xc1 */ kKeyNone, // unassigned
|
|
|
|
/* 0xc2 */ kKeyNone, // unassigned
|
|
|
|
/* 0xc3 */ kKeyNone, // unassigned
|
|
|
|
/* 0xc4 */ kKeyNone, // unassigned
|
|
|
|
/* 0xc5 */ kKeyNone, // unassigned
|
|
|
|
/* 0xc6 */ kKeyNone, // unassigned
|
|
|
|
/* 0xc7 */ kKeyNone, // unassigned
|
|
|
|
/* 0xc8 */ kKeyNone, // unassigned
|
|
|
|
/* 0xc9 */ kKeyNone, // unassigned
|
|
|
|
/* 0xca */ kKeyNone, // unassigned
|
|
|
|
/* 0xcb */ kKeyNone, // unassigned
|
|
|
|
/* 0xcc */ kKeyNone, // unassigned
|
|
|
|
/* 0xcd */ kKeyNone, // unassigned
|
|
|
|
/* 0xce */ kKeyNone, // unassigned
|
|
|
|
/* 0xcf */ kKeyNone, // unassigned
|
|
|
|
/* 0xd0 */ kKeyNone, // unassigned
|
|
|
|
/* 0xd1 */ kKeyNone, // unassigned
|
|
|
|
/* 0xd2 */ kKeyNone, // unassigned
|
|
|
|
/* 0xd3 */ kKeyNone, // unassigned
|
|
|
|
/* 0xd4 */ kKeyNone, // unassigned
|
|
|
|
/* 0xd5 */ kKeyNone, // unassigned
|
|
|
|
/* 0xd6 */ kKeyNone, // unassigned
|
|
|
|
/* 0xd7 */ kKeyNone, // unassigned
|
|
|
|
/* 0xd8 */ kKeyNone, // unassigned
|
|
|
|
/* 0xd9 */ kKeyNone, // unassigned
|
|
|
|
/* 0xda */ kKeyNone, // unassigned
|
|
|
|
/* 0xdb */ kKeyNone, // OEM specific
|
|
|
|
/* 0xdc */ kKeyNone, // OEM specific
|
|
|
|
/* 0xdd */ kKeyNone, // OEM specific
|
|
|
|
/* 0xde */ kKeyNone, // OEM specific
|
|
|
|
/* 0xdf */ kKeyNone, // OEM specific
|
|
|
|
/* 0xe0 */ kKeyNone, // OEM specific
|
|
|
|
/* 0xe1 */ kKeyNone, // OEM specific
|
|
|
|
/* 0xe2 */ kKeyNone, // OEM specific
|
|
|
|
/* 0xe3 */ kKeyNone, // OEM specific
|
|
|
|
/* 0xe4 */ kKeyNone, // OEM specific
|
|
|
|
/* 0xe5 */ kKeyNone, // unassigned
|
|
|
|
/* 0xe6 */ kKeyNone, // OEM specific
|
|
|
|
/* 0xe7 */ kKeyNone, // unassigned
|
|
|
|
/* 0xe8 */ kKeyNone, // unassigned
|
|
|
|
/* 0xe9 */ kKeyNone, // OEM specific
|
|
|
|
/* 0xea */ kKeyNone, // OEM specific
|
|
|
|
/* 0xeb */ kKeyNone, // OEM specific
|
|
|
|
/* 0xec */ kKeyNone, // OEM specific
|
|
|
|
/* 0xed */ kKeyNone, // OEM specific
|
|
|
|
/* 0xee */ kKeyNone, // OEM specific
|
|
|
|
/* 0xef */ kKeyNone, // OEM specific
|
|
|
|
/* 0xf0 */ kKeyNone, // OEM specific
|
|
|
|
/* 0xf1 */ kKeyNone, // OEM specific
|
|
|
|
/* 0xf2 */ kKeyNone, // OEM specific
|
|
|
|
/* 0xf3 */ kKeyNone, // OEM specific
|
|
|
|
/* 0xf4 */ kKeyNone, // OEM specific
|
|
|
|
/* 0xf5 */ kKeyNone, // OEM specific
|
|
|
|
/* 0xf6 */ kKeyNone, // VK_ATTN
|
|
|
|
/* 0xf7 */ kKeyNone, // VK_CRSEL
|
|
|
|
/* 0xf8 */ kKeyNone, // VK_EXSEL
|
|
|
|
/* 0xf9 */ kKeyNone, // VK_EREOF
|
|
|
|
/* 0xfa */ kKeyNone, // VK_PLAY
|
|
|
|
/* 0xfb */ kKeyNone, // VK_ZOOM
|
|
|
|
/* 0xfc */ kKeyNone, // reserved
|
|
|
|
/* 0xfd */ kKeyNone, // VK_PA1
|
|
|
|
/* 0xfe */ kKeyNone, // VK_OEM_CLEAR
|
|
|
|
/* 0xff */ kKeyNone // reserved
|
|
|
|
};
|
2001-11-19 03:33:36 +03:00
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
KeyID
|
|
|
|
CMSWindowsPrimaryScreen::mapKey(
|
|
|
|
WPARAM vkCode,
|
|
|
|
LPARAM info,
|
|
|
|
KeyModifierMask* maskOut)
|
2001-11-19 03:33:36 +03:00
|
|
|
{
|
2002-04-30 20:23:03 +04:00
|
|
|
// note: known microsoft bugs
|
|
|
|
// Q72583 -- MapVirtualKey() maps keypad keys incorrectly
|
|
|
|
// 95,98: num pad vk code -> invalid scan code
|
|
|
|
// 95,98,NT4: num pad scan code -> bad vk code except
|
|
|
|
// SEPARATOR, MULTIPLY, SUBTRACT, ADD
|
|
|
|
|
|
|
|
static const KeyID XK_Multi_key = 0xff20;
|
|
|
|
|
2001-11-25 21:32:41 +03:00
|
|
|
assert(maskOut != NULL);
|
|
|
|
|
|
|
|
// map modifier key
|
2001-11-19 03:33:36 +03:00
|
|
|
KeyModifierMask mask = 0;
|
2002-04-30 20:23:03 +04:00
|
|
|
if (((m_keys[VK_LSHIFT] |
|
|
|
|
m_keys[VK_RSHIFT] |
|
2002-06-11 02:06:45 +04:00
|
|
|
m_keys[VK_SHIFT]) & 0x80) != 0) {
|
2001-11-19 03:33:36 +03:00
|
|
|
mask |= KeyModifierShift;
|
2002-06-11 02:06:45 +04:00
|
|
|
}
|
2002-04-30 20:23:03 +04:00
|
|
|
if (((m_keys[VK_LCONTROL] |
|
|
|
|
m_keys[VK_RCONTROL] |
|
2002-06-11 02:06:45 +04:00
|
|
|
m_keys[VK_CONTROL]) & 0x80) != 0) {
|
2001-11-19 03:33:36 +03:00
|
|
|
mask |= KeyModifierControl;
|
2002-06-11 02:06:45 +04:00
|
|
|
}
|
2002-04-30 20:23:03 +04:00
|
|
|
if (((m_keys[VK_LMENU] |
|
|
|
|
m_keys[VK_RMENU] |
|
2002-06-11 02:06:45 +04:00
|
|
|
m_keys[VK_MENU]) & 0x80) != 0) {
|
2001-11-19 03:33:36 +03:00
|
|
|
mask |= KeyModifierAlt;
|
2002-06-11 02:06:45 +04:00
|
|
|
}
|
2002-04-30 20:23:03 +04:00
|
|
|
if (((m_keys[VK_LWIN] |
|
2002-06-11 02:06:45 +04:00
|
|
|
m_keys[VK_RWIN]) & 0x80) != 0) {
|
2001-11-19 03:33:36 +03:00
|
|
|
mask |= KeyModifierMeta;
|
2002-06-11 02:06:45 +04:00
|
|
|
}
|
|
|
|
if ((m_keys[VK_CAPITAL] & 0x01) != 0) {
|
2002-04-30 20:23:03 +04:00
|
|
|
mask |= KeyModifierCapsLock;
|
2002-06-11 02:06:45 +04:00
|
|
|
}
|
|
|
|
if ((m_keys[VK_NUMLOCK] & 0x01) != 0) {
|
2002-04-30 20:23:03 +04:00
|
|
|
mask |= KeyModifierNumLock;
|
2002-06-11 02:06:45 +04:00
|
|
|
}
|
|
|
|
if ((m_keys[VK_SCROLL] & 0x01) != 0) {
|
2001-11-19 03:33:36 +03:00
|
|
|
mask |= KeyModifierScrollLock;
|
2002-06-11 02:06:45 +04:00
|
|
|
}
|
2001-11-25 21:32:41 +03:00
|
|
|
*maskOut = mask;
|
2002-05-22 21:01:17 +04:00
|
|
|
log((CLOG_DEBUG2 "key in vk=%d info=0x%08x mask=0x%04x", vkCode, info, mask));
|
2001-11-19 03:33:36 +03:00
|
|
|
|
2002-04-30 20:23:03 +04:00
|
|
|
// get the scan code
|
|
|
|
UINT scanCode = static_cast<UINT>((info & 0xff0000) >> 16);
|
|
|
|
|
|
|
|
// convert virtual key to one that distinguishes between left and
|
|
|
|
// right for keys that have left/right versions. known scan codes
|
|
|
|
// that don't have left/right versions are passed through unchanged.
|
|
|
|
// unknown scan codes return 0.
|
|
|
|
UINT vkCode2 = MapVirtualKey(scanCode, 3);
|
|
|
|
|
|
|
|
// work around bug Q72583 (bad num pad conversion in MapVirtualKey())
|
2002-06-11 02:06:45 +04:00
|
|
|
if (vkCode >= VK_NUMPAD0 && vkCode <= VK_DIVIDE) {
|
2002-04-30 20:23:03 +04:00
|
|
|
vkCode2 = vkCode;
|
2002-06-11 02:06:45 +04:00
|
|
|
}
|
2002-04-30 20:23:03 +04:00
|
|
|
|
|
|
|
// MapVirtualKey() appears to map VK_LWIN, VK_RWIN, VK_APPS to
|
|
|
|
// some other meaningless virtual key. work around that bug.
|
2002-06-11 02:06:45 +04:00
|
|
|
else if (vkCode >= VK_LWIN && vkCode <= VK_APPS) {
|
2002-04-30 20:23:03 +04:00
|
|
|
vkCode2 = vkCode;
|
2002-06-11 02:06:45 +04:00
|
|
|
}
|
2002-04-30 20:23:03 +04:00
|
|
|
|
2002-05-22 21:01:17 +04:00
|
|
|
// if MapVirtualKey failed then use original virtual key
|
2002-06-11 02:06:45 +04:00
|
|
|
else if (vkCode2 == 0) {
|
2002-05-22 21:01:17 +04:00
|
|
|
vkCode2 = vkCode;
|
2002-06-11 02:06:45 +04:00
|
|
|
}
|
2002-05-22 21:01:17 +04:00
|
|
|
|
2002-04-30 20:23:03 +04:00
|
|
|
// sadly, win32 will not distinguish between the left and right
|
|
|
|
// control and alt keys using the above function. however, we
|
|
|
|
// can check for those: if bit 24 of info is set then the key
|
|
|
|
// is a "extended" key, such as the right control and right alt
|
|
|
|
// keys.
|
|
|
|
if ((info & 0x1000000) != 0) {
|
|
|
|
switch (vkCode2) {
|
2002-05-22 21:01:17 +04:00
|
|
|
case VK_CONTROL:
|
2002-04-30 20:23:03 +04:00
|
|
|
case VK_LCONTROL:
|
|
|
|
vkCode2 = VK_RCONTROL;
|
|
|
|
break;
|
|
|
|
|
2002-05-22 21:01:17 +04:00
|
|
|
case VK_MENU:
|
2002-04-30 20:23:03 +04:00
|
|
|
case VK_LMENU:
|
|
|
|
vkCode2 = VK_RMENU;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// use left/right distinguishing virtual key
|
|
|
|
vkCode = vkCode2;
|
|
|
|
log((CLOG_DEBUG1 "key vk=%d scan=%d", vkCode, scanCode));
|
|
|
|
|
|
|
|
// handle some keys via table lookup
|
2001-11-25 21:32:41 +03:00
|
|
|
KeyID id = g_virtualKey[vkCode];
|
|
|
|
if (id != kKeyNone) {
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
2002-04-30 20:23:03 +04:00
|
|
|
// check for dead keys
|
|
|
|
if (MapVirtualKey(vkCode, 2) >= 0x8000) {
|
|
|
|
return XK_Multi_key;
|
2001-11-25 21:32:41 +03:00
|
|
|
}
|
|
|
|
|
2002-04-30 20:23:03 +04:00
|
|
|
// ToAscii() maps ctrl+letter to the corresponding control code
|
|
|
|
// and ctrl+backspace to delete. if we've got a control code or
|
|
|
|
// delete then do ToAscii() again but without the control state.
|
|
|
|
// ToAscii() interprets the control modifier state which we don't
|
|
|
|
// want. so save the control state then clear it.
|
|
|
|
BYTE lControl = m_keys[VK_LCONTROL];
|
|
|
|
BYTE rControl = m_keys[VK_RCONTROL];
|
|
|
|
BYTE control = m_keys[VK_CONTROL];
|
|
|
|
m_keys[VK_LCONTROL] = 0;
|
|
|
|
m_keys[VK_RCONTROL] = 0;
|
|
|
|
m_keys[VK_CONTROL] = 0;
|
|
|
|
|
|
|
|
// convert to ascii
|
|
|
|
WORD ascii;
|
|
|
|
int result = ToAscii(vkCode, scanCode, m_keys, &ascii, 0);
|
|
|
|
|
|
|
|
// restore control state
|
|
|
|
m_keys[VK_LCONTROL] = lControl;
|
|
|
|
m_keys[VK_RCONTROL] = rControl;
|
|
|
|
m_keys[VK_CONTROL] = control;
|
|
|
|
|
|
|
|
// if result is less than zero then it was a dead key. that key
|
|
|
|
// is remembered by the keyboard which we don't want. remove it
|
|
|
|
// by calling ToAscii() again with arbitrary arguments.
|
|
|
|
if (result < 0) {
|
|
|
|
ToAscii(vkCode, scanCode, m_keys, &ascii, 0);
|
|
|
|
return XK_Multi_key;
|
|
|
|
}
|
2001-11-25 21:32:41 +03:00
|
|
|
|
2002-04-30 20:23:03 +04:00
|
|
|
// if result is 1 then the key was succesfully converted
|
|
|
|
else if (result == 1) {
|
|
|
|
return static_cast<KeyID>(ascii & 0x00ff);
|
2001-11-25 21:32:41 +03:00
|
|
|
}
|
2002-04-30 20:23:03 +04:00
|
|
|
|
|
|
|
// if result is 2 then a previous dead key could not be composed.
|
|
|
|
// put the old dead key back.
|
|
|
|
else if (result == 2) {
|
|
|
|
// get the scan code of the dead key and the shift state
|
|
|
|
// required to generate it.
|
2002-05-22 21:01:17 +04:00
|
|
|
vkCode = VkKeyScan(static_cast<TCHAR>(ascii & 0x00ff));
|
2002-04-30 20:23:03 +04:00
|
|
|
|
|
|
|
// set shift state required to generate key
|
|
|
|
BYTE keys[256];
|
|
|
|
memset(keys, 0, sizeof(keys));
|
2002-06-11 02:06:45 +04:00
|
|
|
// FIXME -- surely these masks should be different in each if expression
|
|
|
|
if (vkCode & 0x0100) {
|
2002-04-30 20:23:03 +04:00
|
|
|
keys[VK_SHIFT] = 0x80;
|
2002-06-11 02:06:45 +04:00
|
|
|
}
|
|
|
|
if (vkCode & 0x0100) {
|
2002-04-30 20:23:03 +04:00
|
|
|
keys[VK_CONTROL] = 0x80;
|
2002-06-11 02:06:45 +04:00
|
|
|
}
|
|
|
|
if (vkCode & 0x0100) {
|
2002-04-30 20:23:03 +04:00
|
|
|
keys[VK_MENU] = 0x80;
|
2002-06-11 02:06:45 +04:00
|
|
|
}
|
2002-04-30 20:23:03 +04:00
|
|
|
|
|
|
|
// strip shift state off of virtual key code
|
|
|
|
vkCode &= 0x00ff;
|
|
|
|
|
|
|
|
// get the scan code for the key
|
|
|
|
scanCode = MapVirtualKey(vkCode, 0);
|
|
|
|
|
|
|
|
// put it back
|
|
|
|
ToAscii(vkCode, scanCode, keys, &ascii, 0);
|
|
|
|
return XK_Multi_key;
|
2001-11-25 21:32:41 +03:00
|
|
|
}
|
2002-04-30 20:23:03 +04:00
|
|
|
|
|
|
|
// cannot convert key
|
|
|
|
return kKeyNone;
|
2001-11-19 03:33:36 +03:00
|
|
|
}
|
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
ButtonID
|
2002-06-17 17:31:21 +04:00
|
|
|
CMSWindowsPrimaryScreen::mapButton(WPARAM button) const
|
2001-11-19 03:33:36 +03:00
|
|
|
{
|
|
|
|
switch (button) {
|
2002-04-29 18:40:01 +04:00
|
|
|
case WM_LBUTTONDOWN:
|
|
|
|
case WM_LBUTTONUP:
|
2001-11-19 03:33:36 +03:00
|
|
|
return kButtonLeft;
|
|
|
|
|
2002-04-29 18:40:01 +04:00
|
|
|
case WM_MBUTTONDOWN:
|
|
|
|
case WM_MBUTTONUP:
|
2001-11-19 03:33:36 +03:00
|
|
|
return kButtonMiddle;
|
|
|
|
|
2002-04-29 18:40:01 +04:00
|
|
|
case WM_RBUTTONDOWN:
|
|
|
|
case WM_RBUTTONUP:
|
2001-11-19 03:33:36 +03:00
|
|
|
return kButtonRight;
|
|
|
|
|
2002-04-29 18:40:01 +04:00
|
|
|
default:
|
2001-11-19 03:33:36 +03:00
|
|
|
return kButtonNone;
|
|
|
|
}
|
|
|
|
}
|
2002-04-30 20:23:03 +04:00
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
void
|
|
|
|
CMSWindowsPrimaryScreen::updateKeys()
|
2002-04-30 20:23:03 +04:00
|
|
|
{
|
2002-05-22 21:01:17 +04:00
|
|
|
// not using GetKeyboardState() because that doesn't seem to give
|
|
|
|
// up-to-date results. i don't know why that is or why GetKeyState()
|
|
|
|
// should give different results.
|
|
|
|
|
2002-04-30 20:23:03 +04:00
|
|
|
// clear key state
|
|
|
|
memset(m_keys, 0, sizeof(m_keys));
|
|
|
|
|
2002-07-01 19:05:49 +04:00
|
|
|
// we only care about the modifier key states. other keys and the
|
|
|
|
// mouse buttons should be up.
|
2002-05-22 21:01:17 +04:00
|
|
|
m_keys[VK_LSHIFT] = static_cast<BYTE>(GetKeyState(VK_LSHIFT));
|
|
|
|
m_keys[VK_RSHIFT] = static_cast<BYTE>(GetKeyState(VK_RSHIFT));
|
|
|
|
m_keys[VK_SHIFT] = static_cast<BYTE>(GetKeyState(VK_SHIFT));
|
|
|
|
m_keys[VK_LCONTROL] = static_cast<BYTE>(GetKeyState(VK_LCONTROL));
|
|
|
|
m_keys[VK_RCONTROL] = static_cast<BYTE>(GetKeyState(VK_RCONTROL));
|
|
|
|
m_keys[VK_CONTROL] = static_cast<BYTE>(GetKeyState(VK_CONTROL));
|
|
|
|
m_keys[VK_LMENU] = static_cast<BYTE>(GetKeyState(VK_LMENU));
|
|
|
|
m_keys[VK_RMENU] = static_cast<BYTE>(GetKeyState(VK_RMENU));
|
|
|
|
m_keys[VK_MENU] = static_cast<BYTE>(GetKeyState(VK_MENU));
|
|
|
|
m_keys[VK_LWIN] = static_cast<BYTE>(GetKeyState(VK_LWIN));
|
|
|
|
m_keys[VK_RWIN] = static_cast<BYTE>(GetKeyState(VK_RWIN));
|
|
|
|
m_keys[VK_APPS] = static_cast<BYTE>(GetKeyState(VK_APPS));
|
|
|
|
m_keys[VK_CAPITAL] = static_cast<BYTE>(GetKeyState(VK_CAPITAL));
|
|
|
|
m_keys[VK_NUMLOCK] = static_cast<BYTE>(GetKeyState(VK_NUMLOCK));
|
|
|
|
m_keys[VK_SCROLL] = static_cast<BYTE>(GetKeyState(VK_SCROLL));
|
2002-04-30 20:23:03 +04:00
|
|
|
}
|
|
|
|
|
2002-06-11 02:06:45 +04:00
|
|
|
void
|
2002-06-17 17:31:21 +04:00
|
|
|
CMSWindowsPrimaryScreen::updateKey(UINT vkCode, bool press)
|
2002-04-30 20:23:03 +04:00
|
|
|
{
|
|
|
|
if (press) {
|
|
|
|
switch (vkCode) {
|
|
|
|
case VK_LSHIFT:
|
|
|
|
case VK_RSHIFT:
|
|
|
|
case VK_SHIFT:
|
|
|
|
m_keys[vkCode] |= 0x80;
|
|
|
|
m_keys[VK_SHIFT] |= 0x80;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VK_LCONTROL:
|
|
|
|
case VK_RCONTROL:
|
|
|
|
case VK_CONTROL:
|
|
|
|
m_keys[vkCode] |= 0x80;
|
|
|
|
m_keys[VK_CONTROL] |= 0x80;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VK_LMENU:
|
|
|
|
case VK_RMENU:
|
|
|
|
case VK_MENU:
|
|
|
|
m_keys[vkCode] |= 0x80;
|
|
|
|
m_keys[VK_MENU] |= 0x80;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VK_CAPITAL:
|
|
|
|
case VK_NUMLOCK:
|
|
|
|
case VK_SCROLL:
|
|
|
|
// toggle keys
|
|
|
|
m_keys[vkCode] |= 0x80;
|
|
|
|
break;
|
2002-07-01 17:00:12 +04:00
|
|
|
|
|
|
|
default:
|
|
|
|
case VK_LWIN:
|
|
|
|
case VK_RWIN:
|
|
|
|
case VK_APPS:
|
|
|
|
m_keys[vkCode] |= 0x80;
|
|
|
|
break;
|
2002-04-30 20:23:03 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
switch (vkCode) {
|
|
|
|
case VK_LSHIFT:
|
|
|
|
case VK_RSHIFT:
|
|
|
|
case VK_SHIFT:
|
|
|
|
m_keys[vkCode] &= ~0x80;
|
|
|
|
if (((m_keys[VK_LSHIFT] | m_keys[VK_RSHIFT]) & 0x80) == 0) {
|
|
|
|
m_keys[VK_SHIFT] &= ~0x80;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VK_LCONTROL:
|
|
|
|
case VK_RCONTROL:
|
|
|
|
case VK_CONTROL:
|
|
|
|
m_keys[vkCode] &= ~0x80;
|
|
|
|
if (((m_keys[VK_LCONTROL] | m_keys[VK_RCONTROL]) & 0x80) == 0) {
|
|
|
|
m_keys[VK_CONTROL] &= ~0x80;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VK_LMENU:
|
|
|
|
case VK_RMENU:
|
|
|
|
case VK_MENU:
|
|
|
|
m_keys[vkCode] &= ~0x80;
|
|
|
|
if (((m_keys[VK_LMENU] | m_keys[VK_RMENU]) & 0x80) == 0) {
|
|
|
|
m_keys[VK_MENU] &= ~0x80;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VK_CAPITAL:
|
|
|
|
case VK_NUMLOCK:
|
|
|
|
case VK_SCROLL:
|
|
|
|
// toggle keys
|
2002-07-01 17:00:12 +04:00
|
|
|
m_keys[vkCode] &= ~0x80;
|
|
|
|
m_keys[vkCode] ^= 0x01;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
case VK_LWIN:
|
|
|
|
case VK_RWIN:
|
|
|
|
case VK_APPS:
|
|
|
|
m_keys[vkCode] &= ~0x80;
|
2002-04-30 20:23:03 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|