FreeRDP
Loading...
Searching...
No Matches
SdlTouch Class Reference

#include <sdl_touch.hpp>

Static Public Member Functions

static bool handleEvent (SdlContext *sdl, const SDL_MouseMotionEvent &ev)
static bool handleEvent (SdlContext *sdl, const SDL_MouseWheelEvent &ev)
static bool handleEvent (SdlContext *sdl, const SDL_MouseButtonEvent &ev)
static bool handleEvent (SdlContext *sdl, const SDL_TouchFingerEvent &ev)

Detailed Description

FreeRDP: A Remote Desktop Protocol Implementation FreeRDP SDL touch/mouse input

Copyright 2022 Armin Novak armin.nosp@m..nov.nosp@m.ak@th.nosp@m.inca.nosp@m.st.co.nosp@m.m

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Definition at line 27 of file SDL3/sdl_touch.hpp.

Member Function Documentation

◆ handleEvent() [1/4]

bool SdlTouch::handleEvent ( SdlContext * sdl,
const SDL_MouseButtonEvent & ev )
staticnodiscard

Definition at line 165 of file SDL3/sdl_touch.cpp.

166{
167 UINT16 flags = 0;
168 UINT16 xflags = 0;
169
170 WINPR_ASSERT(sdl);
171
172 if (ev.type == SDL_EVENT_MOUSE_BUTTON_DOWN)
173 {
174 flags |= PTR_FLAGS_DOWN;
175 xflags |= PTR_XFLAGS_DOWN;
176 }
177
178 switch (ev.button)
179 {
180 case 1:
181 flags |= PTR_FLAGS_BUTTON1;
182 break;
183 case 2:
184 flags |= PTR_FLAGS_BUTTON3;
185 break;
186 case 3:
187 flags |= PTR_FLAGS_BUTTON2;
188 break;
189 case 4:
190 xflags |= PTR_XFLAGS_BUTTON1;
191 break;
192 case 5:
193 xflags |= PTR_XFLAGS_BUTTON2;
194 break;
195 default:
196 break;
197 }
198
199 const BOOL relative =
200 freerdp_client_use_relative_mouse_events(sdl->common()) && !sdl->hasCursor();
201 auto x = static_cast<INT32>(relative ? 0 : ev.x);
202 auto y = static_cast<INT32>(relative ? 0 : ev.y);
203
204 if ((flags & (~PTR_FLAGS_DOWN)) != 0)
205 return sdl::utils::inputSent(
206 sdl->context(), sdl->getWLog(),
207 freerdp_client_send_button_event(sdl->common(), relative, flags, x, y), "mouse button");
208 else if ((xflags & (~PTR_XFLAGS_DOWN)) != 0)
209 return sdl::utils::inputSent(
210 sdl->context(), sdl->getWLog(),
211 freerdp_client_send_extended_button_event(sdl->common(), relative, xflags, x, y),
212 "mouse button");
213 else
214 return TRUE;
215}

◆ handleEvent() [2/4]

bool SdlTouch::handleEvent ( SdlContext * sdl,
const SDL_MouseMotionEvent & ev )
staticnodiscard

Definition at line 120 of file SDL3/sdl_touch.cpp.

121{
122 WINPR_ASSERT(sdl);
123
124 if (!sdl->getInputChannelContext().mouse_focus(ev.windowID))
125 return FALSE;
126
127 const BOOL relative =
128 freerdp_client_use_relative_mouse_events(sdl->common()) && !sdl->hasCursor();
129 auto x = static_cast<INT32>(relative ? ev.xrel : ev.x);
130 auto y = static_cast<INT32>(relative ? ev.yrel : ev.y);
131 return sdl::utils::inputSent(
132 sdl->context(), sdl->getWLog(),
133 freerdp_client_send_button_event(sdl->common(), relative, PTR_FLAGS_MOVE, x, y),
134 "mouse move");
135}

◆ handleEvent() [3/4]

bool SdlTouch::handleEvent ( SdlContext * sdl,
const SDL_MouseWheelEvent & ev )
staticnodiscard

Definition at line 137 of file SDL3/sdl_touch.cpp.

138{
139 WINPR_ASSERT(sdl);
140
141 const bool flipped = (ev.direction == SDL_MOUSEWHEEL_FLIPPED) &&
142 !SdlPref::instance()->get_bool("UseLocalMouseScrollDirection");
143 const float sign = flipped ? -1.0f : 1.0f;
144 const auto x = sdl->wheelAxis(true).add(ev.x * sign);
145 const auto y = sdl->wheelAxis(false).add(ev.y * sign);
146
147 /* [MS-RDPBCGR] 2.2.8.1.1.3.1.1.3 Pointer Event: a wheel rotation event carries no flags
148 * besides PTR_FLAGS_WHEEL_NEGATIVE and the rotation itself, so the two axes cannot share
149 * one event. Keep the flags apart, the horizontal rotation would otherwise be applied to
150 * the vertical axis. */
151 if (y != 0)
152 {
153 if (!send_mouse_wheel(sdl, PTR_FLAGS_WHEEL, y))
154 return false;
155 }
156
157 if (x != 0)
158 {
159 if (!send_mouse_wheel(sdl, PTR_FLAGS_HWHEEL, x))
160 return false;
161 }
162 return TRUE;
163}

◆ handleEvent() [4/4]

bool SdlTouch::handleEvent ( SdlContext * sdl,
const SDL_TouchFingerEvent & ev )
staticnodiscard

Definition at line 217 of file SDL3/sdl_touch.cpp.

218{
219 switch (ev.type)
220 {
221 case SDL_EVENT_FINGER_CANCELED:
222 return SdlTouch::touchCancel(sdl, ev);
223 case SDL_EVENT_FINGER_UP:
224 return SdlTouch::touchUp(sdl, ev);
225 case SDL_EVENT_FINGER_DOWN:
226 return SdlTouch::touchDown(sdl, ev);
227 case SDL_EVENT_FINGER_MOTION:
228 return SdlTouch::touchMotion(sdl, ev);
229 default:
230 return false;
231 }
232}

The documentation for this class was generated from the following files: