21 #include "../../SDL_internal.h" 23 #if SDL_VIDEO_DRIVER_RPI 32 #include "../SDL_sysvideo.h" 33 #include "../../events/SDL_mouse_c.h" 34 #include "../../events/default_cursor.h" 38 #define ELEMENT_CHANGE_LAYER (1<<0) 39 #define ELEMENT_CHANGE_OPACITY (1<<1) 40 #define ELEMENT_CHANGE_DEST_RECT (1<<2) 41 #define ELEMENT_CHANGE_SRC_RECT (1<<3) 42 #define ELEMENT_CHANGE_MASK_RESOURCE (1<<4) 43 #define ELEMENT_CHANGE_TRANSFORM (1<<5) 46 static SDL_Cursor *RPI_CreateDefaultCursor(
void);
52 static int RPI_WarpMouseGlobal(
int x,
int y);
55 RPI_CreateDefaultCursor(
void)
64 RPI_CursorData *curdata;
78 curdata = (RPI_CursorData *)
SDL_calloc(1,
sizeof(*curdata));
79 if (curdata ==
NULL) {
85 curdata->hot_x =
hot_x;
86 curdata->hot_y = hot_y;
87 curdata->w = surface->
w;
88 curdata->h = surface->
h;
91 curdata->resource = vc_dispmanx_resource_create(VC_IMAGE_ARGB8888, surface->
w | (surface->
pitch << 16), surface->
h | (surface->
h << 16), &dummy);
93 vc_dispmanx_rect_set(&dst_rect, 0, 0, curdata->w, curdata->h);
100 ret = vc_dispmanx_resource_write_data(curdata->resource, VC_IMAGE_ARGB8888, surface->
pitch, surface->
pixels, &dst_rect);
114 DISPMANX_UPDATE_HANDLE_T update;
115 RPI_CursorData *curdata;
116 VC_RECT_T src_rect, dst_rect;
120 VC_DISPMANX_ALPHA_T
alpha = { DISPMANX_FLAGS_ALPHA_FROM_SOURCE , 255 , 0 };
129 if (cursor ==
NULL) {
134 if (curdata->element > DISPMANX_NO_HANDLE) {
135 update = vc_dispmanx_update_start(10);
137 ret = vc_dispmanx_element_remove(update, curdata->element);
139 ret = vc_dispmanx_update_submit_sync(update);
141 curdata->element = DISPMANX_NO_HANDLE;
147 curdata = (RPI_CursorData *) cursor->
driverdata;
157 if (display ==
NULL) {
166 if (curdata->element == DISPMANX_NO_HANDLE) {
167 vc_dispmanx_rect_set(&src_rect, 0, 0, curdata->w << 16, curdata->h << 16);
168 vc_dispmanx_rect_set(&dst_rect, mouse->
x, mouse->
y, curdata->w, curdata->h);
170 update = vc_dispmanx_update_start(10);
178 curdata->element = vc_dispmanx_element_add(update,
184 DISPMANX_PROTECTION_NONE,
188 SDL_assert(curdata->element > DISPMANX_NO_HANDLE);
189 ret = vc_dispmanx_update_submit_sync(update);
201 DISPMANX_UPDATE_HANDLE_T update;
202 RPI_CursorData *curdata;
204 if (cursor !=
NULL) {
205 curdata = (RPI_CursorData *) cursor->
driverdata;
208 if (curdata->element != DISPMANX_NO_HANDLE) {
209 update = vc_dispmanx_update_start(10);
211 ret = vc_dispmanx_element_remove(update, curdata->element);
213 ret = vc_dispmanx_update_submit_sync(update);
217 if (curdata->resource != DISPMANX_NO_HANDLE) {
218 ret = vc_dispmanx_resource_delete(curdata->resource);
232 RPI_WarpMouseGlobal(x, y);
237 RPI_WarpMouseGlobal(
int x,
int y)
239 RPI_CursorData *curdata;
240 DISPMANX_UPDATE_HANDLE_T update;
254 if (curdata->element == DISPMANX_NO_HANDLE) {
258 update = vc_dispmanx_update_start(10);
265 src_rect.width = curdata->w << 16;
266 src_rect.height = curdata->h << 16;
269 dst_rect.width = curdata->w;
270 dst_rect.height = curdata->h;
272 ret = vc_dispmanx_element_change_attributes(
282 if (ret != DISPMANX_SUCCESS) {
283 return SDL_SetError(
"vc_dispmanx_element_change_attributes() failed");
287 ret = vc_dispmanx_update_submit(update, 0,
NULL);
288 if (ret != DISPMANX_SUCCESS) {
289 return SDL_SetError(
"vc_dispmanx_update_submit() failed");
296 RPI_WarpMouseGlobalGraphicOnly(
int x,
int y)
298 RPI_CursorData *curdata;
299 DISPMANX_UPDATE_HANDLE_T update;
310 if (curdata->element == DISPMANX_NO_HANDLE) {
314 update = vc_dispmanx_update_start(10);
321 src_rect.width = curdata->w << 16;
322 src_rect.height = curdata->h << 16;
325 dst_rect.width = curdata->w;
326 dst_rect.height = curdata->h;
328 ret = vc_dispmanx_element_change_attributes(
338 if (ret != DISPMANX_SUCCESS) {
339 return SDL_SetError(
"vc_dispmanx_element_change_attributes() failed");
343 ret = vc_dispmanx_update_submit(update, 0,
NULL);
344 if (ret != DISPMANX_SUCCESS) {
345 return SDL_SetError(
"vc_dispmanx_update_submit() failed");
381 RPI_WarpMouseGlobalGraphicOnly(mouse->
x, mouse->
y);
SDL_Mouse * SDL_GetMouse(void)
int(* ShowCursor)(SDL_Cursor *cursor)
GLint GLint GLint GLint GLint x
#define SDL_RPI_MOUSELAYER
A collection of pixels used in software blitting.
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 local skip1(dst_w_bpp<=(lowbit *8)) &&((lowbit *8)<(pixblock_size *dst_w_bpp)) .if lowbit< 16 tst DST_R
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLenum GLuint GLint GLint layer
GLfloat GLfloat GLfloat alpha
SDL_Cursor *(* CreateCursor)(SDL_Surface *surface, int hot_x, int hot_y)
int SDL_SendMouseMotion(SDL_Window *window, SDL_MouseID mouseID, int relative, int x, int y)
GLint GLint GLint GLint GLint GLint y
DISPMANX_DISPLAY_HANDLE_T dispman_display
void SDL_SetDefaultCursor(SDL_Cursor *cursor)
int(* WarpMouseGlobal)(int x, int y)
void(* FreeCursor)(SDL_Cursor *cursor)
#define SDL_assert(condition)
#define SDL_OutOfMemory()
static const unsigned char default_cmask[]
#define SDL_HINT_RPI_VIDEO_LAYER
Tell SDL which Dispmanx layer to use on a Raspberry PI.
SDL_VideoDisplay * SDL_GetDisplayForWindow(SDL_Window *window)
EGLSurface EGLNativeWindowType * window
The type used to identify a window.
void RPI_QuitMouse(_THIS)
void(* WarpMouse)(SDL_Window *window, int x, int y)
static const unsigned char default_cdata[]
void(* MoveCursor)(SDL_Cursor *cursor)
void RPI_InitMouse(_THIS)
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