70 lines
3 KiB
Diff
70 lines
3 KiB
Diff
From f00e8526825f14b8f6706afeabcbbfe7acfec057 Mon Sep 17 00:00:00 2001
|
|
From: Johnny on Flame <johnnyonflame@hotmail.com>
|
|
Date: Sun, 6 Aug 2023 20:58:34 +0000
|
|
Subject: [PATCH 4/7] KMSDRM: Rotate the cursor
|
|
|
|
---
|
|
src/video/kmsdrm/SDL_kmsdrmmouse.c | 13 +++++++++----
|
|
1 file changed, 9 insertions(+), 4 deletions(-)
|
|
|
|
diff --git a/src/video/kmsdrm/SDL_kmsdrmmouse.c b/src/video/kmsdrm/SDL_kmsdrmmouse.c
|
|
index 955045a7e..4c445ecf1 100644
|
|
--- a/src/video/kmsdrm/SDL_kmsdrmmouse.c
|
|
+++ b/src/video/kmsdrm/SDL_kmsdrmmouse.c
|
|
@@ -150,6 +150,7 @@ static int KMSDRM_DumpCursorToBO(SDL_VideoDisplay *display, SDL_Cursor *cursor)
|
|
uint8_t *src_row;
|
|
|
|
int i;
|
|
+ int j;
|
|
int ret;
|
|
|
|
if (curdata == NULL || !dispdata->cursor_bo) {
|
|
@@ -170,8 +171,10 @@ static int KMSDRM_DumpCursorToBO(SDL_VideoDisplay *display, SDL_Cursor *cursor)
|
|
|
|
/* Copy from the cursor buffer to a buffer that we can dump to the GBM BO. */
|
|
for (i = 0; i < curdata->h; i++) {
|
|
- src_row = &((uint8_t *)curdata->buffer)[i * curdata->w * 4];
|
|
- SDL_memcpy(ready_buffer + (i * bo_stride), src_row, (size_t)4 * curdata->w);
|
|
+ for (j = 0; j < curdata->w; j++) {
|
|
+ src_row = ((uint32_t*)curdata->buffer)[i * curdata->w + j];
|
|
+ SDL_memcpy(ready_buffer + ((curdata->w - j + 1) * bo_stride) + i, &src_row, 4);
|
|
+ }
|
|
}
|
|
|
|
/* Dump the cursor buffer to our GBM BO. */
|
|
@@ -370,6 +373,7 @@ static int KMSDRM_WarpMouseGlobal(int x, int y)
|
|
|
|
SDL_Window *window = mouse->focus;
|
|
SDL_DisplayData *dispdata = (SDL_DisplayData *)SDL_GetDisplayForWindow(window)->driverdata;
|
|
+ KMSDRM_CursorData *curdata = mouse->cur_cursor->driverdata;
|
|
|
|
/* Update internal mouse position. */
|
|
SDL_SendMouseMotion(mouse->focus, mouse->mouseID, 0, x, y);
|
|
@@ -378,7 +382,7 @@ static int KMSDRM_WarpMouseGlobal(int x, int y)
|
|
if (dispdata->cursor_bo) {
|
|
int ret = 0;
|
|
|
|
- ret = KMSDRM_drmModeMoveCursor(dispdata->cursor_bo_drm_fd, dispdata->crtc->crtc_id, x, y);
|
|
+ ret = KMSDRM_drmModeMoveCursor(dispdata->cursor_bo_drm_fd, dispdata->crtc->crtc_id, y, dispdata->mode.vdisplay + curdata->w - x);
|
|
|
|
if (ret) {
|
|
SDL_SetError("drmModeMoveCursor() failed.");
|
|
@@ -432,13 +436,14 @@ static void KMSDRM_MoveCursor(SDL_Cursor *cursor)
|
|
|
|
SDL_Window *window = mouse->focus;
|
|
SDL_DisplayData *dispdata = (SDL_DisplayData *)SDL_GetDisplayForWindow(window)->driverdata;
|
|
+ KMSDRM_CursorData *curdata = mouse->cur_cursor->driverdata;
|
|
|
|
if (!dispdata->cursor_bo) {
|
|
SDL_SetError("Cursor not initialized properly.");
|
|
return;
|
|
}
|
|
|
|
- ret = KMSDRM_drmModeMoveCursor(dispdata->cursor_bo_drm_fd, dispdata->crtc->crtc_id, mouse->x, mouse->y);
|
|
+ ret = KMSDRM_drmModeMoveCursor(dispdata->cursor_bo_drm_fd, dispdata->crtc->crtc_id, mouse->y, dispdata->mode.vdisplay - curdata->w - mouse->x);
|
|
|
|
if (ret) {
|
|
SDL_SetError("drmModeMoveCursor() failed.");
|
|
--
|
|
2.20.1
|
|
|