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

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

◆ handleEvent() [2/4]

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

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

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

◆ handleEvent() [3/4]

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

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

122{
123 WINPR_ASSERT(sdl);
124
125 const BOOL flipped = (ev.direction == SDL_MOUSEWHEEL_FLIPPED);
126 const auto x = static_cast<INT32>(ev.x * (flipped ? -1.0f : 1.0f) * 120.0f);
127 const auto y = static_cast<INT32>(ev.y * (flipped ? -1.0f : 1.0f) * 120.0f);
128 UINT16 flags = 0;
129
130 if (y != 0)
131 {
132 flags |= PTR_FLAGS_WHEEL;
133 if (!send_mouse_wheel(sdl, flags, y))
134 return false;
135 }
136
137 if (x != 0)
138 {
139 flags |= PTR_FLAGS_HWHEEL;
140 if (!send_mouse_wheel(sdl, flags, x))
141 return false;
142 }
143 return TRUE;
144}

◆ handleEvent() [4/4]

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

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

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

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