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 148 of file SDL3/sdl_touch.cpp.

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

◆ 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 UINT16 flags = 0;
131
132 if (y != 0)
133 {
134 flags |= PTR_FLAGS_WHEEL;
135 if (!send_mouse_wheel(sdl, flags, y))
136 return false;
137 }
138
139 if (x != 0)
140 {
141 flags |= PTR_FLAGS_HWHEEL;
142 if (!send_mouse_wheel(sdl, flags, x))
143 return false;
144 }
145 return TRUE;
146}

◆ handleEvent() [4/4]

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

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

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

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