21 #include "../../SDL_internal.h"
23 #if SDL_VIDEO_DRIVER_RPI
31 #include "../SDL_sysvideo.h"
32 #include "../../events/SDL_mouse_c.h"
33 #include "../../events/default_cursor.h"
37 #define ELEMENT_CHANGE_LAYER (1<<0)
38 #define ELEMENT_CHANGE_OPACITY (1<<1)
39 #define ELEMENT_CHANGE_DEST_RECT (1<<2)
40 #define ELEMENT_CHANGE_SRC_RECT (1<<3)
41 #define ELEMENT_CHANGE_MASK_RESOURCE (1<<4)
42 #define ELEMENT_CHANGE_TRANSFORM (1<<5)
45 static SDL_Cursor *RPI_CreateDefaultCursor(
void);
51 static int RPI_WarpMouseGlobal(
int x,
int y);
56 RPI_CreateDefaultCursor(
void)
65 RPI_CursorData *curdata;
79 curdata = (RPI_CursorData *)
SDL_calloc(1,
sizeof(*curdata));
80 if (curdata ==
NULL) {
86 curdata->hot_x =
hot_x;
87 curdata->hot_y = hot_y;
92 curdata->resource = vc_dispmanx_resource_create(VC_IMAGE_ARGB8888,
surface->w | (
surface->pitch << 16),
surface->h | (
surface->h << 16), &dummy);
94 vc_dispmanx_rect_set(&dst_rect, 0, 0, curdata->w, curdata->h);
101 ret = vc_dispmanx_resource_write_data(curdata->resource, VC_IMAGE_ARGB8888,
surface->pitch,
surface->pixels, &dst_rect);
115 DISPMANX_UPDATE_HANDLE_T update;
116 RPI_CursorData *curdata;
117 VC_RECT_T src_rect, dst_rect;
121 VC_DISPMANX_ALPHA_T
alpha = { DISPMANX_FLAGS_ALPHA_FROM_SOURCE , 255 , 0 };
130 if (
cursor != global_cursor) {
131 if (global_cursor !=
NULL) {
132 curdata = (RPI_CursorData *) global_cursor->
driverdata;
133 if (curdata && curdata->element > DISPMANX_NO_HANDLE) {
134 update = vc_dispmanx_update_start(0);
136 ret = vc_dispmanx_element_remove(update, curdata->element);
138 ret = vc_dispmanx_update_submit_sync(update);
140 curdata->element = DISPMANX_NO_HANDLE;
160 if (display ==
NULL) {
169 if (curdata->element == DISPMANX_NO_HANDLE) {
170 vc_dispmanx_rect_set(&src_rect, 0, 0, curdata->w << 16, curdata->h << 16);
171 vc_dispmanx_rect_set(&dst_rect, mouse->
x - curdata->hot_x, mouse->
y - curdata->hot_y, curdata->w, curdata->h);
173 update = vc_dispmanx_update_start(0);
181 curdata->element = vc_dispmanx_element_add(update,
182 data->dispman_display,
187 DISPMANX_PROTECTION_NONE,
191 SDL_assert(curdata->element > DISPMANX_NO_HANDLE);
192 ret = vc_dispmanx_update_submit_sync(update);
204 DISPMANX_UPDATE_HANDLE_T update;
205 RPI_CursorData *curdata;
211 if (curdata->element != DISPMANX_NO_HANDLE) {
212 update = vc_dispmanx_update_start(0);
214 ret = vc_dispmanx_element_remove(update, curdata->element);
216 ret = vc_dispmanx_update_submit_sync(update);
220 if (curdata->resource != DISPMANX_NO_HANDLE) {
221 ret = vc_dispmanx_resource_delete(curdata->resource);
228 if (
cursor == global_cursor) {
229 global_cursor =
NULL;
238 RPI_WarpMouseGlobal(
x,
y);
243 RPI_WarpMouseGlobal(
int x,
int y)
245 RPI_CursorData *curdata;
246 DISPMANX_UPDATE_HANDLE_T update;
260 if (curdata->element == DISPMANX_NO_HANDLE) {
264 update = vc_dispmanx_update_start(0);
271 src_rect.width = curdata->w << 16;
272 src_rect.height = curdata->h << 16;
273 dst_rect.x =
x - curdata->hot_x;
274 dst_rect.y =
y - curdata->hot_y;
275 dst_rect.width = curdata->w;
276 dst_rect.height = curdata->h;
278 ret = vc_dispmanx_element_change_attributes(
288 if (ret != DISPMANX_SUCCESS) {
289 return SDL_SetError(
"vc_dispmanx_element_change_attributes() failed");
293 ret = vc_dispmanx_update_submit(update, 0,
NULL);
294 if (ret != DISPMANX_SUCCESS) {
295 return SDL_SetError(
"vc_dispmanx_update_submit() failed");
302 RPI_WarpMouseGlobalGraphicOnly(
int x,
int y)
304 RPI_CursorData *curdata;
305 DISPMANX_UPDATE_HANDLE_T update;
316 if (curdata->element == DISPMANX_NO_HANDLE) {
320 update = vc_dispmanx_update_start(0);
327 src_rect.width = curdata->w << 16;
328 src_rect.height = curdata->h << 16;
329 dst_rect.x =
x - curdata->hot_x;
330 dst_rect.y =
y - curdata->hot_y;
331 dst_rect.width = curdata->w;
332 dst_rect.height = curdata->h;
334 ret = vc_dispmanx_element_change_attributes(
344 if (ret != DISPMANX_SUCCESS) {
345 return SDL_SetError(
"vc_dispmanx_element_change_attributes() failed");
349 ret = vc_dispmanx_update_submit(update, 0,
NULL);
350 if (ret != DISPMANX_SUCCESS) {
351 return SDL_SetError(
"vc_dispmanx_update_submit() failed");
386 RPI_WarpMouseGlobalGraphicOnly(mouse->
x, mouse->
y);
#define SDL_assert(condition)
#define SDL_OutOfMemory()
#define SDL_HINT_RPI_VIDEO_LAYER
Tell SDL which Dispmanx layer to use on a Raspberry PI.
int uint32_t uint32_t uint32_t uint32_t uint32_t int drmModeModeInfoPtr mode int uint32_t uint32_t uint32_t uint32_t int32_t hot_x
SDL_Mouse * SDL_GetMouse(void)
void SDL_SetDefaultCursor(SDL_Cursor *cursor)
int SDL_SendMouseMotion(SDL_Window *window, SDL_MouseID mouseID, int relative, int x, int y)
GLint GLint GLint GLint GLint GLint y
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLint GLint GLint GLint GLint x
GLfloat GLfloat GLfloat alpha
GLenum GLuint GLint GLint layer
@ SDL_PIXELFORMAT_ARGB8888
void RPI_QuitMouse(_THIS)
void RPI_InitMouse(_THIS)
#define SDL_RPI_MOUSELAYER
SDL_VideoDisplay * SDL_GetDisplayForWindow(SDL_Window *window)
static const unsigned char default_cdata[]
static const unsigned char default_cmask[]
EGLSurface EGLNativeWindowType * window
set set set set set set set macro pixldst1 abits if abits op else op endif endm macro pixldst2 abits if abits op else op endif endm macro pixldst4 abits if abits op else op endif endm macro pixldst0 abits op endm macro pixldst3 mem_operand op endm macro pixldst30 mem_operand op endm macro pixldst abits if abits elseif abits elseif abits elseif abits elseif abits pixldst0 abits else pixldst0 abits pixldst0 abits pixldst0 abits pixldst0 abits endif elseif abits else pixldst0 abits pixldst0 abits endif elseif abits else error unsupported bpp *numpix else pixst endif endm macro pixld1_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl else error unsupported endif endm macro pixld2_s mem_operand if mov asr add asl add asl mov asr sub UNIT_X add asl mov asr add asl add asl mov asr add UNIT_X add asl else pixld1_s mem_operand pixld1_s mem_operand endif endm macro pixld0_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl endif endm macro pixld_s_internal mem_operand if mem_operand pixld2_s mem_operand pixdeinterleave basereg elseif mem_operand elseif mem_operand elseif mem_operand elseif mem_operand pixld0_s mem_operand else pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else error unsupported mem_operand if bpp mem_operand endif endm macro vuzp8 reg2 vuzp d d ®2 endm macro vzip8 reg2 vzip d d ®2 endm macro pixdeinterleave basereg basereg basereg basereg basereg endif endm macro pixinterleave basereg basereg basereg basereg basereg endif endm macro PF boost_increment endif if endif PF tst PF addne PF subne PF cmp ORIG_W if endif if endif if endif PF subge ORIG_W PF subges if endif if endif if endif endif endm macro cache_preload_simple endif if dst_r_bpp pld[DST_R, #(PREFETCH_DISTANCE_SIMPLE *dst_r_bpp/8)] endif if mask_bpp pld if[MASK, #(PREFETCH_DISTANCE_SIMPLE *mask_bpp/8)] endif endif endm macro fetch_mask_pixblock pixld mask_basereg pixblock_size MASK endm macro ensure_destination_ptr_alignment process_pixblock_tail_head if beq irp skip1(dst_w_bpp<=(lowbit *8)) &&((lowbit *8)<(pixblock_size *dst_w_bpp)) .if lowbit< 16 tst DST_R
void(* WarpMouse)(SDL_Window *window, int x, int y)
SDL_Cursor *(* CreateCursor)(SDL_Surface *surface, int hot_x, int hot_y)
void(* FreeCursor)(SDL_Cursor *cursor)
int(* ShowCursor)(SDL_Cursor *cursor)
int(* WarpMouseGlobal)(int x, int y)
void(* MoveCursor)(SDL_Cursor *cursor)
A collection of pixels used in software blitting.
The type used to identify a window.