-
Notifications
You must be signed in to change notification settings - Fork 0
/
Mouse.cpp
80 lines (68 loc) · 2.26 KB
/
Mouse.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// Mouse.cpp: implementation of the CMouse class.
//
//////////////////////////////////////////////////////////////////////
/*
* Copyright (C) 2002 Maesc software consultants. All Rights Reserved.
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This software 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.
*
* You should have received a copy of the GNU General Public License
* along with this software; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*/
#include "stdafx.h"
#include "Mouse.h"
#include "rfb.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CMouse::CMouse()
{
m_iLastX = -1;
m_iLastY = -1;
m_iLastButtonMask = 0;
}
CMouse::~CMouse()
{
}
void CMouse::Event(HWND hWnd, int x, int y, int ButtonMask)
{
DWORD flags = MOUSEEVENTF_ABSOLUTE;
int update;
if (x != m_iLastX || y != m_iLastY) {
flags |= MOUSEEVENTF_MOVE;
m_iLastX = x;
m_iLastY = y;
update = TRUE;
}
if ( (ButtonMask & rfbButton1Mask) != (m_iLastButtonMask & rfbButton1Mask) ) {
flags |= (ButtonMask & rfbButton1Mask) ? MOUSEEVENTF_LEFTDOWN : MOUSEEVENTF_LEFTUP;
update = TRUE;
}
if ( (ButtonMask & rfbButton2Mask) != (m_iLastButtonMask & rfbButton2Mask) )
{
flags |= (ButtonMask & rfbButton2Mask)
? MOUSEEVENTF_MIDDLEDOWN : MOUSEEVENTF_MIDDLEUP;
update = TRUE;
}
if ( (ButtonMask & rfbButton3Mask) != (m_iLastButtonMask & rfbButton3Mask) )
{
flags |= (ButtonMask & rfbButton3Mask)
? MOUSEEVENTF_RIGHTDOWN : MOUSEEVENTF_RIGHTUP;
update = TRUE;
}
if (update) {
// Do the pointer event
mouse_event(flags, (DWORD) x, (DWORD) y, 0, 0);
m_iLastButtonMask = ButtonMask;
}
}