~ubuntu-branches/ubuntu/vivid/freerdp/vivid

« back to all changes in this revision

Viewing changes to server/Windows/wf_input.c

  • Committer: Package Import Robot
  • Author(s): Iain Lane
  • Date: 2014-11-11 12:20:50 UTC
  • mfrom: (1.1.9) (9.1.17 sid)
  • Revision ID: package-import@ubuntu.com-20141111122050-wyr8hrnwco9fcmum
Tags: 1.1.0~git20140921.1.440916e+dfsg1-2ubuntu1
* Merge with Debian unstable, remaining changes
  - Disable ffmpeg support
* Disable gstreamer support, this relies on gstreamer 0.10 and we don't want
  to add any more deps on that.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * FreeRDP: A Remote Desktop Protocol Implementation
 
3
 * FreeRDP Windows Server
 
4
 *
 
5
 * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
 
6
 *
 
7
 * Licensed under the Apache License, Version 2.0 (the "License");
 
8
 * you may not use this file except in compliance with the License.
 
9
 * You may obtain a copy of the License at
 
10
 *
 
11
 *     http://www.apache.org/licenses/LICENSE-2.0
 
12
 *
 
13
 * Unless required by applicable law or agreed to in writing, software
 
14
 * distributed under the License is distributed on an "AS IS" BASIS,
 
15
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
16
 * See the License for the specific language governing permissions and
 
17
 * limitations under the License.
 
18
 */
 
19
 
 
20
#ifdef HAVE_CONFIG_H
 
21
#include "config.h"
 
22
#endif
 
23
 
 
24
#include <winpr/windows.h>
 
25
 
 
26
#include "wf_input.h"
 
27
#include "wf_info.h"
 
28
 
 
29
void wf_peer_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code)
 
30
{
 
31
        INPUT keyboard_event;
 
32
 
 
33
        keyboard_event.type = INPUT_KEYBOARD;
 
34
        keyboard_event.ki.wVk = 0;
 
35
        keyboard_event.ki.wScan = code;
 
36
        keyboard_event.ki.dwFlags = KEYEVENTF_SCANCODE;
 
37
        keyboard_event.ki.dwExtraInfo = 0;
 
38
        keyboard_event.ki.time = 0;
 
39
 
 
40
        if (flags & KBD_FLAGS_RELEASE)
 
41
                keyboard_event.ki.dwFlags |= KEYEVENTF_KEYUP;
 
42
 
 
43
        if (flags & KBD_FLAGS_EXTENDED)
 
44
                keyboard_event.ki.dwFlags |= KEYEVENTF_EXTENDEDKEY;
 
45
 
 
46
        SendInput(1, &keyboard_event, sizeof(INPUT));
 
47
}
 
48
 
 
49
void wf_peer_unicode_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code)
 
50
{
 
51
        INPUT keyboard_event;
 
52
 
 
53
        keyboard_event.type = INPUT_KEYBOARD;
 
54
        keyboard_event.ki.wVk = 0;
 
55
        keyboard_event.ki.wScan = code;
 
56
        keyboard_event.ki.dwFlags = KEYEVENTF_UNICODE;
 
57
        keyboard_event.ki.dwExtraInfo = 0;
 
58
        keyboard_event.ki.time = 0;
 
59
 
 
60
        if (flags & KBD_FLAGS_RELEASE)
 
61
                keyboard_event.ki.dwFlags |= KEYEVENTF_KEYUP;
 
62
 
 
63
        SendInput(1, &keyboard_event, sizeof(INPUT));
 
64
}
 
65
 
 
66
void wf_peer_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y)
 
67
{
 
68
        INPUT mouse_event;
 
69
        float width, height;
 
70
 
 
71
        ZeroMemory(&mouse_event, sizeof(INPUT));
 
72
        mouse_event.type = INPUT_MOUSE;
 
73
 
 
74
        if (flags & PTR_FLAGS_WHEEL)
 
75
        {
 
76
                mouse_event.mi.dwFlags = MOUSEEVENTF_WHEEL;
 
77
                mouse_event.mi.mouseData = flags & WheelRotationMask;
 
78
 
 
79
                if (flags & PTR_FLAGS_WHEEL_NEGATIVE)
 
80
                        mouse_event.mi.mouseData *= -1;
 
81
 
 
82
                SendInput(1, &mouse_event, sizeof(INPUT));
 
83
        }
 
84
        else
 
85
        {
 
86
                wfInfo * wfi;
 
87
                
 
88
                wfi = wf_info_get_instance();
 
89
 
 
90
                //width and height of primary screen (even in multimon setups
 
91
                width = (float) GetSystemMetrics(SM_CXSCREEN);
 
92
                height = (float) GetSystemMetrics(SM_CYSCREEN);
 
93
 
 
94
                x += wfi->servscreen_xoffset;
 
95
                y += wfi->servscreen_yoffset;
 
96
 
 
97
                mouse_event.mi.dx = (LONG) ((float) x * (65535.0f / width));
 
98
                mouse_event.mi.dy = (LONG) ((float) y * (65535.0f / height));
 
99
                mouse_event.mi.dwFlags = MOUSEEVENTF_ABSOLUTE;
 
100
 
 
101
                if (flags & PTR_FLAGS_MOVE)
 
102
                {
 
103
                        mouse_event.mi.dwFlags |= MOUSEEVENTF_MOVE;
 
104
                        SendInput(1, &mouse_event, sizeof(INPUT));
 
105
                }
 
106
 
 
107
                mouse_event.mi.dwFlags = MOUSEEVENTF_ABSOLUTE;
 
108
 
 
109
                if (flags & PTR_FLAGS_BUTTON1)
 
110
                {
 
111
                        if (flags & PTR_FLAGS_DOWN)
 
112
                                mouse_event.mi.dwFlags |= MOUSEEVENTF_LEFTDOWN;
 
113
                        else
 
114
                                mouse_event.mi.dwFlags |= MOUSEEVENTF_LEFTUP;
 
115
 
 
116
                        SendInput(1, &mouse_event, sizeof(INPUT));
 
117
                }
 
118
                else if (flags & PTR_FLAGS_BUTTON2)
 
119
                {
 
120
                        if (flags & PTR_FLAGS_DOWN)
 
121
                                mouse_event.mi.dwFlags |= MOUSEEVENTF_RIGHTDOWN;
 
122
                        else
 
123
                                mouse_event.mi.dwFlags |= MOUSEEVENTF_RIGHTUP;
 
124
 
 
125
                        SendInput(1, &mouse_event, sizeof(INPUT));
 
126
                }
 
127
                else if (flags & PTR_FLAGS_BUTTON3)
 
128
                {
 
129
                        if (flags & PTR_FLAGS_DOWN)
 
130
                                mouse_event.mi.dwFlags |= MOUSEEVENTF_MIDDLEDOWN;
 
131
                        else
 
132
                                mouse_event.mi.dwFlags |= MOUSEEVENTF_MIDDLEUP;
 
133
 
 
134
                        SendInput(1, &mouse_event, sizeof(INPUT));
 
135
                }
 
136
        }
 
137
}
 
138
 
 
139
void wf_peer_extended_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y)
 
140
{
 
141
        if ((flags & PTR_XFLAGS_BUTTON1) || (flags & PTR_XFLAGS_BUTTON2))
 
142
        {
 
143
                INPUT mouse_event;
 
144
                ZeroMemory(&mouse_event, sizeof(INPUT));
 
145
 
 
146
                mouse_event.type = INPUT_MOUSE;
 
147
 
 
148
                if (flags & PTR_FLAGS_MOVE)
 
149
                {
 
150
                        float width, height;
 
151
                        wfInfo * wfi;
 
152
 
 
153
                        wfi = wf_info_get_instance();
 
154
                        //width and height of primary screen (even in multimon setups
 
155
                        width = (float) GetSystemMetrics(SM_CXSCREEN);
 
156
                        height = (float) GetSystemMetrics(SM_CYSCREEN);
 
157
 
 
158
                        x += wfi->servscreen_xoffset;
 
159
                        y += wfi->servscreen_yoffset;
 
160
 
 
161
                        //mouse_event.mi.dx = x * (0xFFFF / width);
 
162
                        //mouse_event.mi.dy = y * (0xFFFF / height);
 
163
                        mouse_event.mi.dx = (LONG) ((float) x * (65535.0f / width));
 
164
                        mouse_event.mi.dy = (LONG) ((float) y * (65535.0f / height));
 
165
                        mouse_event.mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE;
 
166
 
 
167
                        SendInput(1, &mouse_event, sizeof(INPUT));
 
168
                }
 
169
 
 
170
                mouse_event.mi.dx = mouse_event.mi.dy = mouse_event.mi.dwFlags = 0;
 
171
 
 
172
                if (flags & PTR_XFLAGS_DOWN)
 
173
                        mouse_event.mi.dwFlags |= MOUSEEVENTF_XDOWN;
 
174
                else
 
175
                        mouse_event.mi.dwFlags |= MOUSEEVENTF_XUP;
 
176
 
 
177
                if (flags & PTR_XFLAGS_BUTTON1)
 
178
                        mouse_event.mi.mouseData = XBUTTON1;
 
179
                else if (flags & PTR_XFLAGS_BUTTON2)
 
180
                        mouse_event.mi.mouseData = XBUTTON2;
 
181
 
 
182
                SendInput(1, &mouse_event, sizeof(INPUT));
 
183
        }
 
184
        else
 
185
        {
 
186
                wf_peer_mouse_event(input, flags, x, y);
 
187
        }
 
188
}
 
189
 
 
190
 
 
191
void wf_peer_keyboard_event_dummy(rdpInput* input, UINT16 flags, UINT16 code)
 
192
{
 
193
}
 
194
 
 
195
void wf_peer_unicode_keyboard_event_dummy(rdpInput* input, UINT16 flags, UINT16 code)
 
196
{
 
197
}
 
198
 
 
199
void wf_peer_mouse_event_dummy(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y)
 
200
{
 
201
}
 
202
 
 
203
void wf_peer_extended_mouse_event_dummy(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y)
 
204
{
 
205
}