2002-08-02 19:57:46 +00:00
|
|
|
/*
|
|
|
|
* synergy -- mouse and keyboard sharing utility
|
|
|
|
* Copyright (C) 2002 Chris Schoeneman
|
|
|
|
*
|
|
|
|
* This package is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* found in the file COPYING that should have accompanied this file.
|
|
|
|
*
|
|
|
|
* This package is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*/
|
|
|
|
|
2001-11-19 00:33:36 +00:00
|
|
|
#ifndef CMSWINDOWSSECONDARYSCREEN_H
|
|
|
|
#define CMSWINDOWSSECONDARYSCREEN_H
|
|
|
|
|
2002-06-20 11:13:37 +00:00
|
|
|
// ensure that we get SendInput()
|
|
|
|
#if _WIN32_WINNT <= 0x400
|
|
|
|
#undef _WIN32_WINNT
|
|
|
|
#define _WIN32_WINNT 0x401
|
|
|
|
#endif
|
|
|
|
|
2002-07-15 15:01:36 +00:00
|
|
|
#include "CSecondaryScreen.h"
|
|
|
|
#include "IMSWindowsScreenEventHandler.h"
|
2002-06-08 21:48:00 +00:00
|
|
|
#include "CMutex.h"
|
|
|
|
#include "CString.h"
|
2002-06-01 19:26:11 +00:00
|
|
|
#include "stdvector.h"
|
2001-11-19 00:33:36 +00:00
|
|
|
|
2002-07-15 15:01:36 +00:00
|
|
|
class CMSWindowsScreen;
|
2002-07-11 13:13:37 +00:00
|
|
|
class IScreenReceiver;
|
|
|
|
|
2002-07-30 14:59:36 +00:00
|
|
|
//! Microsoft windows secondary screen implementation
|
2002-07-15 15:01:36 +00:00
|
|
|
class CMSWindowsSecondaryScreen :
|
|
|
|
public CSecondaryScreen, public IMSWindowsScreenEventHandler {
|
2002-04-29 14:40:01 +00:00
|
|
|
public:
|
2002-07-11 13:13:37 +00:00
|
|
|
CMSWindowsSecondaryScreen(IScreenReceiver*);
|
2001-11-19 00:33:36 +00:00
|
|
|
virtual ~CMSWindowsSecondaryScreen();
|
|
|
|
|
2002-07-15 15:01:36 +00:00
|
|
|
// CSecondaryScreen overrides
|
2001-11-19 00:33:36 +00:00
|
|
|
virtual void keyDown(KeyID, KeyModifierMask);
|
|
|
|
virtual void keyRepeat(KeyID, KeyModifierMask, SInt32 count);
|
|
|
|
virtual void keyUp(KeyID, KeyModifierMask);
|
|
|
|
virtual void mouseDown(ButtonID);
|
|
|
|
virtual void mouseUp(ButtonID);
|
|
|
|
virtual void mouseMove(SInt32 xAbsolute, SInt32 yAbsolute);
|
|
|
|
virtual void mouseWheel(SInt32 delta);
|
2002-07-15 15:01:36 +00:00
|
|
|
virtual IScreen* getScreen() const;
|
2001-11-19 00:33:36 +00:00
|
|
|
|
2002-07-15 15:01:36 +00:00
|
|
|
// IMSWindowsScreenEventHandler overrides
|
|
|
|
virtual void onScreensaver(bool activated);
|
2002-07-12 20:41:23 +00:00
|
|
|
virtual bool onPreDispatch(const CEvent* event);
|
|
|
|
virtual bool onEvent(CEvent* event);
|
2002-07-15 15:01:36 +00:00
|
|
|
virtual SInt32 getJumpZoneSize() const;
|
|
|
|
virtual void postCreateWindow(HWND);
|
|
|
|
virtual void preDestroyWindow(HWND);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
// CSecondaryScreen overrides
|
2002-07-30 15:17:44 +00:00
|
|
|
virtual void onPreMainLoop();
|
2002-07-15 15:01:36 +00:00
|
|
|
virtual void onPreOpen();
|
|
|
|
virtual void onPreEnter();
|
|
|
|
virtual void onPreLeave();
|
|
|
|
virtual void createWindow();
|
|
|
|
virtual void destroyWindow();
|
|
|
|
virtual void showWindow();
|
|
|
|
virtual void hideWindow();
|
|
|
|
virtual void warpCursor(SInt32 x, SInt32 y);
|
|
|
|
virtual void updateKeys();
|
|
|
|
virtual void setToggleState(KeyModifierMask);
|
2001-11-19 00:33:36 +00:00
|
|
|
|
2002-04-29 14:40:01 +00:00
|
|
|
private:
|
2002-05-04 18:08:22 +00:00
|
|
|
enum EKeyAction { kPress, kRelease, kRepeat };
|
|
|
|
class Keystroke {
|
|
|
|
public:
|
|
|
|
UINT m_virtualKey;
|
|
|
|
bool m_press;
|
|
|
|
bool m_repeat;
|
|
|
|
};
|
2002-04-30 16:23:03 +00:00
|
|
|
typedef std::vector<Keystroke> Keystrokes;
|
2002-06-08 21:48:00 +00:00
|
|
|
|
|
|
|
// open/close desktop (for windows 95/98/me)
|
|
|
|
bool openDesktop();
|
|
|
|
void closeDesktop();
|
|
|
|
|
|
|
|
// make desk the thread desktop (for windows NT/2000/XP)
|
|
|
|
bool switchDesktop(HDESK desk);
|
|
|
|
|
2002-06-20 11:13:37 +00:00
|
|
|
// returns true iff there appear to be multiple monitors
|
|
|
|
bool isMultimon() const;
|
|
|
|
|
2002-06-08 21:48:00 +00:00
|
|
|
// key and button queries and operations
|
2002-05-04 18:08:22 +00:00
|
|
|
DWORD mapButton(ButtonID button, bool press) const;
|
2002-04-30 16:23:03 +00:00
|
|
|
KeyModifierMask mapKey(Keystrokes&, UINT& virtualKey, KeyID,
|
2002-06-10 22:06:45 +00:00
|
|
|
KeyModifierMask, EKeyAction) const;
|
2002-05-04 18:08:22 +00:00
|
|
|
void doKeystrokes(const Keystrokes&, SInt32 count);
|
2002-04-30 16:23:03 +00:00
|
|
|
|
2002-07-01 13:03:16 +00:00
|
|
|
void releaseKeys();
|
2002-04-30 17:48:11 +00:00
|
|
|
void toggleKey(UINT virtualKey, KeyModifierMask mask);
|
2002-05-22 17:01:17 +00:00
|
|
|
UINT virtualKeyToScanCode(UINT& virtualKey);
|
|
|
|
bool isExtendedKey(UINT virtualKey);
|
|
|
|
void sendKeyEvent(UINT virtualKey, bool press);
|
2001-11-19 00:33:36 +00:00
|
|
|
|
2002-04-29 14:40:01 +00:00
|
|
|
private:
|
2002-06-08 21:48:00 +00:00
|
|
|
CMutex m_mutex;
|
2002-07-15 15:01:36 +00:00
|
|
|
CMSWindowsScreen* m_screen;
|
2002-06-08 21:48:00 +00:00
|
|
|
|
|
|
|
// true if windows 95/98/me
|
|
|
|
bool m_is95Family;
|
|
|
|
|
2002-07-15 15:01:36 +00:00
|
|
|
// our window
|
2001-11-19 00:33:36 +00:00
|
|
|
HWND m_window;
|
2002-06-08 21:48:00 +00:00
|
|
|
|
2002-04-30 16:23:03 +00:00
|
|
|
// virtual key states
|
|
|
|
BYTE m_keys[256];
|
|
|
|
|
|
|
|
// current active modifiers
|
|
|
|
KeyModifierMask m_mask;
|
2001-11-19 00:33:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|