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 
)
static

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

150{
151 UINT16 flags = 0;
152 UINT16 xflags = 0;
153
154 WINPR_ASSERT(sdl);
155
156 if (ev.type == SDL_EVENT_MOUSE_BUTTON_DOWN)
157 {
158 flags |= PTR_FLAGS_DOWN;
159 xflags |= PTR_XFLAGS_DOWN;
160 }
161
162 switch (ev.button)
163 {
164 case 1:
165 flags |= PTR_FLAGS_BUTTON1;
166 break;
167 case 2:
168 flags |= PTR_FLAGS_BUTTON3;
169 break;
170 case 3:
171 flags |= PTR_FLAGS_BUTTON2;
172 break;
173 case 4:
174 xflags |= PTR_XFLAGS_BUTTON1;
175 break;
176 case 5:
177 xflags |= PTR_XFLAGS_BUTTON2;
178 break;
179 default:
180 break;
181 }
182
183 const BOOL relative =
184 freerdp_client_use_relative_mouse_events(sdl->common()) && !sdl->hasCursor();
185 auto x = static_cast<INT32>(relative ? 0 : ev.x);
186 auto y = static_cast<INT32>(relative ? 0 : ev.y);
187
188 if ((flags & (~PTR_FLAGS_DOWN)) != 0)
189 return freerdp_client_send_button_event(sdl->common(), relative, flags, x, y);
190 else if ((xflags & (~PTR_XFLAGS_DOWN)) != 0)
191 return freerdp_client_send_extended_button_event(sdl->common(), relative, xflags, x, y);
192 else
193 return TRUE;
194}

◆ handleEvent() [2/4]

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

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

109{
110 WINPR_ASSERT(sdl);
111
112 if (!sdl->getInputChannelContext().mouse_focus(ev.windowID))
113 return FALSE;
114
115 const BOOL relative =
116 freerdp_client_use_relative_mouse_events(sdl->common()) && !sdl->hasCursor();
117 auto x = static_cast<INT32>(relative ? ev.xrel : ev.x);
118 auto y = static_cast<INT32>(relative ? ev.yrel : ev.y);
119 return freerdp_client_send_button_event(sdl->common(), relative, PTR_FLAGS_MOVE, x, y);
120}

◆ handleEvent() [3/4]

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

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

123{
124 WINPR_ASSERT(sdl);
125
126 const bool flipped = (ev.direction == SDL_MOUSEWHEEL_FLIPPED) &&
127 !SdlPref::instance()->get_bool("UseLocalMouseScrollDirection");
128 const auto x = static_cast<INT32>(ev.x * (flipped ? -1.0f : 1.0f) * 120.0f);
129 const auto y = static_cast<INT32>(ev.y * (flipped ? -1.0f : 1.0f) * 120.0f);
130
131 /* [MS-RDPBCGR] 2.2.8.1.1.3.1.1.3 Pointer Event: a wheel rotation event carries no flags
132 * besides PTR_FLAGS_WHEEL_NEGATIVE and the rotation itself, so the two axes cannot share
133 * one event. Keep the flags apart, the horizontal rotation would otherwise be applied to
134 * the vertical axis. */
135 if (y != 0)
136 {
137 if (!send_mouse_wheel(sdl, PTR_FLAGS_WHEEL, y))
138 return false;
139 }
140
141 if (x != 0)
142 {
143 if (!send_mouse_wheel(sdl, PTR_FLAGS_HWHEEL, x))
144 return false;
145 }
146 return TRUE;
147}

◆ handleEvent() [4/4]

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

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

197{
198 switch (ev.type)
199 {
200 case SDL_EVENT_FINGER_CANCELED:
201 return SdlTouch::touchCancel(sdl, ev);
202 case SDL_EVENT_FINGER_UP:
203 return SdlTouch::touchUp(sdl, ev);
204 case SDL_EVENT_FINGER_DOWN:
205 return SdlTouch::touchDown(sdl, ev);
206 case SDL_EVENT_FINGER_MOTION:
207 return SdlTouch::touchMotion(sdl, ev);
208 default:
209 return false;
210 }
211}

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