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_LEGACY_CreateDefaultCursor(
void);
39 static int KMSDRM_LEGACY_WarpMouseGlobal(
int x,
int y);
42 KMSDRM_LEGACY_CreateDefaultCursor(
void)
49 KMSDRM_LEGACY_IsCursorSizeSupported (
int w,
int h,
uint32_t bo_format) {
57 struct gbm_bo *bo = KMSDRM_LEGACY_gbm_bo_create(viddata->
gbm,
w,
h, bo_format,
58 GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE);
61 SDL_SetError(
"Could not create GBM cursor BO width size %dx%d for size testing",
w,
h);
65 bo_handle = KMSDRM_LEGACY_gbm_bo_get_handle(bo).u32;
72 KMSDRM_LEGACY_gbm_bo_destroy(bo);
78 KMSDRM_LEGACY_gbm_bo_destroy(bo);
93 int i, ret, usable_cursor_w, usable_cursor_h;
100 bo_format = GBM_FORMAT_RGB332;
103 bo_format = GBM_FORMAT_ARGB4444;
106 bo_format = GBM_FORMAT_RGBA4444;
109 bo_format = GBM_FORMAT_ABGR4444;
112 bo_format = GBM_FORMAT_BGRA4444;
115 bo_format = GBM_FORMAT_ARGB1555;
118 bo_format = GBM_FORMAT_RGBA5551;
121 bo_format = GBM_FORMAT_ABGR1555;
124 bo_format = GBM_FORMAT_BGRA5551;
127 bo_format = GBM_FORMAT_RGB565;
130 bo_format = GBM_FORMAT_BGR565;
134 bo_format = GBM_FORMAT_RGB888;
138 bo_format = GBM_FORMAT_BGR888;
141 bo_format = GBM_FORMAT_RGBX8888;
144 bo_format = GBM_FORMAT_BGRX8888;
147 bo_format = GBM_FORMAT_ARGB8888;
150 bo_format = GBM_FORMAT_RGBA8888;
153 bo_format = GBM_FORMAT_ABGR8888;
156 bo_format = GBM_FORMAT_BGRA8888;
159 bo_format = GBM_FORMAT_ARGB2101010;
166 if (!KMSDRM_LEGACY_gbm_device_is_format_supported(viddata->
gbm, bo_format, GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE)) {
192 if (KMSDRM_LEGACY_IsCursorSizeSupported(usable_cursor_w, usable_cursor_h, bo_format)) {
196 usable_cursor_w += usable_cursor_w;
197 usable_cursor_h += usable_cursor_h;
200 if (!cursor_supported) {
201 SDL_SetError(
"Could not find a cursor size supported by the kernel driver");
206 curdata->
hot_y = hot_y;
207 curdata->
w = usable_cursor_w;
208 curdata->
h = usable_cursor_h;
210 curdata->
bo = KMSDRM_LEGACY_gbm_bo_create(viddata->
gbm, usable_cursor_w, usable_cursor_h, bo_format,
211 GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE);
218 bo_stride = KMSDRM_LEGACY_gbm_bo_get_stride(curdata->
bo);
221 if (
surface->pitch != bo_stride) {
292 KMSDRM_LEGACY_gbm_bo_destroy(curdata->
bo);
330 ret = KMSDRM_LEGACY_drmModeSetCursor(viddata->
drm_fd, curdata->
crtc_id, 0, 0, 0);
332 SDL_SetError(
"Could not hide current cursor with drmModeSetCursor().");
342 if (dispdata && dispdata->
crtc_id != 0) {
343 ret = KMSDRM_LEGACY_drmModeSetCursor(viddata->
drm_fd, dispdata->
crtc_id, 0, 0, 0);
345 SDL_SetError(
"Could not hide display's cursor with drmModeSetCursor().");
355 return SDL_SetError(
"Could not get display for mouse.");
358 return SDL_SetError(
"Could not get display driverdata.");
362 if (!curdata || !curdata->
bo) {
363 return SDL_SetError(
"Cursor not initialized properly.");
366 bo_handle = KMSDRM_LEGACY_gbm_bo_get_handle(curdata->
bo).u32;
367 if (curdata->
hot_x == 0 && curdata->
hot_y == 0) {
369 curdata->
w, curdata->
h);
372 curdata->
w, curdata->
h, curdata->
hot_x, curdata->
hot_y);
397 drm_fd = KMSDRM_LEGACY_gbm_device_get_fd(KMSDRM_LEGACY_gbm_bo_get_device(curdata->
bo));
399 KMSDRM_LEGACY_drmModeSetCursor(drm_fd, curdata->
crtc_id, 0, 0, 0);
402 KMSDRM_LEGACY_gbm_bo_destroy(curdata->
bo);
416 KMSDRM_LEGACY_WarpMouseGlobal(
x,
y);
421 KMSDRM_LEGACY_WarpMouseGlobal(
int x,
int y)
436 drm_fd = KMSDRM_LEGACY_gbm_device_get_fd(KMSDRM_LEGACY_gbm_bo_get_device(curdata->
bo));
437 ret = KMSDRM_LEGACY_drmModeMoveCursor(drm_fd, curdata->
crtc_id,
x,
y);
448 return SDL_SetError(
"Cursor not initialized properly.");
467 mouse->
WarpMouse = KMSDRM_LEGACY_WarpMouse;
491 drm_fd = KMSDRM_LEGACY_gbm_device_get_fd(KMSDRM_LEGACY_gbm_bo_get_device(curdata->
bo));
492 ret = KMSDRM_LEGACY_drmModeMoveCursor(drm_fd, curdata->
crtc_id, mouse->
x, mouse->
y);
#define SDL_UnlockSurface
#define SDL_OutOfMemory()
void KMSDRM_LEGACY_QuitMouse(_THIS)
void KMSDRM_LEGACY_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
int uint32_t uint32_t uint32_t uint32_t uint32_t int drmModeModeInfoPtr mode int uint32_t uint32_t bo_handle
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 GLint GLint GLint GLint x
GLenum GLuint GLsizei bufsize
GLfloat GLfloat GLfloat GLfloat h
GLubyte GLubyte GLubyte GLubyte w
@ SDL_PIXELFORMAT_ABGR4444
@ SDL_PIXELFORMAT_BGRA4444
@ SDL_PIXELFORMAT_RGBA8888
@ SDL_PIXELFORMAT_RGBA5551
@ SDL_PIXELFORMAT_ARGB1555
@ SDL_PIXELFORMAT_BGRX8888
@ SDL_PIXELFORMAT_ABGR8888
@ SDL_PIXELFORMAT_BGRA8888
@ SDL_PIXELFORMAT_ABGR1555
@ SDL_PIXELFORMAT_ARGB8888
@ SDL_PIXELFORMAT_ARGB4444
@ SDL_PIXELFORMAT_RGBX8888
@ SDL_PIXELFORMAT_BGRA5551
@ SDL_PIXELFORMAT_ARGB2101010
@ SDL_PIXELFORMAT_RGBA4444
void * SDL_GetDisplayDriverData(int displayIndex)
SDL_VideoDevice * SDL_GetVideoDevice(void)
SDL_VideoDisplay * SDL_GetDisplayForWindow(SDL_Window *window)
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)
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
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 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
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.