22 #include "../../SDL_internal.h" 24 #if SDL_VIDEO_DRIVER_KMSDRM 30 #include "../../events/SDL_mouse_c.h" 31 #include "../../events/default_cursor.h" 33 static SDL_Cursor *KMSDRM_CreateDefaultCursor(
void);
39 static int KMSDRM_WarpMouseGlobal(
int x,
int y);
42 KMSDRM_CreateDefaultCursor(
void)
49 KMSDRM_IsCursorSizeSupported (
int w,
int h,
uint32_t bo_format) {
55 struct gbm_bo *bo = KMSDRM_gbm_bo_create(vdata->
gbm, w, h, bo_format,
56 GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE);
59 SDL_SetError(
"Could not create GBM cursor BO width size %dx%d for size testing", w, h);
63 bo_handle = KMSDRM_gbm_bo_get_handle(bo).u32;
64 ret = KMSDRM_drmModeSetCursor(vdata->
drm_fd, vdata->
crtc_id, bo_handle, w, h);
70 KMSDRM_gbm_bo_destroy(bo);
76 KMSDRM_gbm_bo_destroy(bo);
91 int i, ret, usable_cursor_w, usable_cursor_h;
98 bo_format = GBM_FORMAT_RGB332;
101 bo_format = GBM_FORMAT_ARGB4444;
104 bo_format = GBM_FORMAT_RGBA4444;
107 bo_format = GBM_FORMAT_ABGR4444;
110 bo_format = GBM_FORMAT_BGRA4444;
113 bo_format = GBM_FORMAT_ARGB1555;
116 bo_format = GBM_FORMAT_RGBA5551;
119 bo_format = GBM_FORMAT_ABGR1555;
122 bo_format = GBM_FORMAT_BGRA5551;
125 bo_format = GBM_FORMAT_RGB565;
128 bo_format = GBM_FORMAT_BGR565;
132 bo_format = GBM_FORMAT_RGB888;
136 bo_format = GBM_FORMAT_BGR888;
139 bo_format = GBM_FORMAT_RGBX8888;
142 bo_format = GBM_FORMAT_BGRX8888;
145 bo_format = GBM_FORMAT_ARGB8888;
148 bo_format = GBM_FORMAT_RGBA8888;
151 bo_format = GBM_FORMAT_ABGR8888;
154 bo_format = GBM_FORMAT_BGRA8888;
157 bo_format = GBM_FORMAT_ARGB2101010;
164 if (!KMSDRM_gbm_device_is_format_supported(vdata->
gbm, bo_format, GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE)) {
170 if (cursor ==
NULL) {
175 if (curdata ==
NULL) {
186 usable_cursor_w = surface->
w;
187 usable_cursor_h = surface->
h;
190 if (KMSDRM_IsCursorSizeSupported(usable_cursor_w, usable_cursor_h, bo_format)) {
194 usable_cursor_w += usable_cursor_w;
195 usable_cursor_h += usable_cursor_h;
198 if (!cursor_supported) {
199 SDL_SetError(
"Could not find a cursor size supported by the kernel driver");
204 curdata->
hot_y = hot_y;
205 curdata->
w = usable_cursor_w;
206 curdata->
h = usable_cursor_h;
208 curdata->
bo = KMSDRM_gbm_bo_create(vdata->
gbm, usable_cursor_w, usable_cursor_h, bo_format,
209 GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE);
211 if (curdata->
bo ==
NULL) {
216 bo_stride = KMSDRM_gbm_bo_get_stride(curdata->
bo);
217 bufsize = bo_stride * curdata->
h;
219 if (surface->
pitch != bo_stride) {
222 if (buffer ==
NULL) {
238 for (i = 0; i < surface->
h; i++) {
248 if (KMSDRM_gbm_bo_write(curdata->
bo, buffer, bufsize)) {
265 ret = KMSDRM_gbm_bo_write(curdata->
bo, surface->
pixels, bufsize);
282 if (buffer !=
NULL) {
285 if (cursor !=
NULL) {
288 if (curdata !=
NULL) {
289 if (curdata->
bo !=
NULL) {
290 KMSDRM_gbm_bo_destroy(curdata->
bo);
317 if (display !=
NULL) {
322 if (cursor ==
NULL) {
328 ret = KMSDRM_drmModeSetCursor(vdata->
drm_fd, curdata->
crtc_id, 0, 0, 0);
330 SDL_SetError(
"Could not hide current cursor with drmModeSetCursor().");
341 ret = KMSDRM_drmModeSetCursor(vdata->
drm_fd, ddata->
crtc_id, 0, 0, 0);
343 SDL_SetError(
"Could not hide display's cursor with drmModeSetCursor().");
352 if (display ==
NULL) {
353 return SDL_SetError(
"Could not get display for mouse.");
356 return SDL_SetError(
"Could not get display driverdata.");
361 return SDL_SetError(
"Cursor not initialized properly.");
364 bo_handle = KMSDRM_gbm_bo_get_handle(curdata->
bo).u32;
365 if (curdata->
hot_x == 0 && curdata->
hot_y == 0) {
366 ret = KMSDRM_drmModeSetCursor(vdata->
drm_fd, ddata->
crtc_id, bo_handle,
367 curdata->
w, curdata->
h);
369 ret = KMSDRM_drmModeSetCursor2(vdata->
drm_fd, ddata->
crtc_id, bo_handle,
370 curdata->
w, curdata->
h,
390 if (cursor !=
NULL) {
394 if (curdata->
bo !=
NULL) {
396 drm_fd = KMSDRM_gbm_device_get_fd(KMSDRM_gbm_bo_get_device(curdata->
bo));
398 KMSDRM_drmModeSetCursor(drm_fd, curdata->
crtc_id, 0, 0, 0);
401 KMSDRM_gbm_bo_destroy(curdata->
bo);
415 KMSDRM_WarpMouseGlobal(x, y);
420 KMSDRM_WarpMouseGlobal(
int x,
int y)
435 drm_fd = KMSDRM_gbm_device_get_fd(KMSDRM_gbm_bo_get_device(curdata->
bo));
436 ret = KMSDRM_drmModeMoveCursor(drm_fd, curdata->
crtc_id, x, y);
447 return SDL_SetError(
"Cursor not initialized properly.");
490 drm_fd = KMSDRM_gbm_device_get_fd(KMSDRM_gbm_bo_get_device(curdata->
bo));
491 ret = KMSDRM_drmModeMoveCursor(drm_fd, curdata->
crtc_id, mouse->
x, mouse->
y);
SDL_Mouse * SDL_GetMouse(void)
void KMSDRM_QuitMouse(_THIS)
int(* ShowCursor)(SDL_Cursor *cursor)
#define SDL_UnlockSurface
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 cleanup[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 beq endif SRC MASK if dst_r_bpp DST_R else add endif PF add sub src_basereg pixdeinterleave mask_basereg pixdeinterleave dst_r_basereg process_pixblock_head pixblock_size cache_preload_simple process_pixblock_tail pixinterleave dst_w_basereg irp beq endif process_pixblock_tail_head tst beq irp if pixblock_size chunk_size tst beq pixld_src SRC pixld MASK if DST_R else pixld DST_R endif if src_basereg pixdeinterleave mask_basereg pixdeinterleave dst_r_basereg process_pixblock_head if pixblock_size cache_preload_simple endif process_pixblock_tail pixinterleave dst_w_basereg irp if pixblock_size chunk_size tst beq if DST_W else pixst DST_W else mov ORIG_W endif add lsl if lsl endif if lsl endif lsl endif lsl endif lsl endif subs mov DST_W if regs_shortage str endif bge start_of_loop_label endm macro generate_composite_function
GLint GLint GLint GLint GLint x
void KMSDRM_InitMouse(_THIS)
GLfloat GLfloat GLfloat GLfloat h
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
GLenum GLuint GLsizei bufsize
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)
GLubyte GLubyte GLubyte GLubyte w
int uint32_t uint32_t uint32_t uint32_t uint32_t int drmModeModeInfoPtr mode int uint32_t uint32_t bo_handle
GLint GLint GLint GLint GLint GLint y
void SDL_SetDefaultCursor(SDL_Cursor *cursor)
int(* WarpMouseGlobal)(int x, int y)
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
void(* FreeCursor)(SDL_Cursor *cursor)
#define SDL_OutOfMemory()
static const unsigned char default_cmask[]
SDL_VideoDisplay * SDL_GetDisplayForWindow(SDL_Window *window)
EGLSurface EGLNativeWindowType * window
The type used to identify a window.
void(* WarpMouse)(SDL_Window *window, int x, int y)
SDL_VideoDevice * SDL_GetVideoDevice(void)
static const unsigned char default_cdata[]
void(* MoveCursor)(SDL_Cursor *cursor)
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