libsdl2:bump version

* add support for haiku system cursors
* disable direct mode (fix mouse glitch)
This commit is contained in:
Gerasim Troeglazov
2021-03-05 18:49:34 +10:00
parent 33d0033bbf
commit 36423af606
3 changed files with 211 additions and 1299 deletions

View File

@@ -4,11 +4,11 @@ designed to provide low level access to audio, keyboard, mouse, joystick, and \
graphics hardware via OpenGL and Direct3D. It is used by video playback \
software, emulators, and popular games."
HOMEPAGE="https://www.libsdl.org/"
COPYRIGHT="1997-2018 Sam Lantinga"
COPYRIGHT="1997-2021 Sam Lantinga"
LICENSE="Zlib"
REVISION="1"
SOURCE_URI="https://www.libsdl.org/release/SDL2-$portVersion.tar.gz"
CHECKSUM_SHA256="b4656c13a1f0d0023ae2f4a9cf08ec92fffb464e0f24238337784159b8b91d57"
CHECKSUM_SHA256="d8215b571a581be1332d2106f8036fcb03d12a70bae01e20f424976d275432bc"
SOURCE_DIR="SDL2-$portVersion"
PATCHES="libsdl2-$portVersion.patchset"
@@ -17,7 +17,7 @@ SECONDARY_ARCHITECTURES="x86_gcc2 x86"
PROVIDES="
libsdl2$secondaryArchSuffix = $portVersion compat >= 2.0
lib:libSDL2_2.0$secondaryArchSuffix = 0.10.0 compat >= 0
lib:libSDL2_2.0$secondaryArchSuffix = 0.14.0 compat >= 0
"
REQUIRES="
haiku$secondaryArchSuffix
@@ -29,8 +29,8 @@ REQUIRES="
PROVIDES_devel="
libsdl2${secondaryArchSuffix}_devel = $portVersion compat >= 2.0
cmd:sdl2_config$secondaryArchSuffix = $portVersion compat >= 2.0
devel:libSDL2$secondaryArchSuffix = 0.10.0 compat >= 0
devel:libSDL2_2.0$secondaryArchSuffix = 0.10.0 compat >= 0
devel:libSDL2$secondaryArchSuffix = 0.14.0 compat >= 0
devel:libSDL2_2.0$secondaryArchSuffix = 0.14.0 compat >= 0
"
REQUIRES_devel="
libsdl2$secondaryArchSuffix == $portVersion base

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,206 @@
From cab82bafaa473b144c3bb04d04faf27627848a7c Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Fri, 5 Mar 2021 17:29:13 +1000
Subject: Fix relative mode for mouse
diff --git a/src/video/haiku/SDL_bvideo.cc b/src/video/haiku/SDL_bvideo.cc
index 817fccf..234eaf0 100644
--- a/src/video/haiku/SDL_bvideo.cc
+++ b/src/video/haiku/SDL_bvideo.cc
@@ -37,6 +37,12 @@ extern "C" {
#include "SDL_bframebuffer.h"
#include "SDL_bevents.h"
+#include "SDL_BWin.h"
+
+static SDL_INLINE SDL_BWin *_ToBeWin(SDL_Window *window) {
+ return ((SDL_BWin*)(window->driverdata));
+}
+
#include <Url.h>
/* FIXME: Undefined functions */
@@ -152,12 +158,34 @@ static int HAIKU_ShowCursor(SDL_Cursor *cur)
return 0;
}
+static int
+HAIKU_SetRelativeMouseMode(SDL_bool enabled)
+{
+ SDL_Window *window = SDL_GetMouseFocus();
+ if (!window) {
+ return 0;
+ }
+
+ SDL_BWin *bewin = _ToBeWin(window);
+ BGLView *_SDL_GLView = bewin->GetGLView();
+
+ bewin->Lock();
+ if (enabled)
+ _SDL_GLView->SetEventMask(B_POINTER_EVENTS | B_KEYBOARD_EVENTS, B_NO_POINTER_HISTORY);
+ else
+ _SDL_GLView->SetEventMask(0, 0);
+ bewin->Unlock();
+
+ return 0;
+}
+
static void HAIKU_MouseInit(_THIS)
{
SDL_Mouse *mouse = SDL_GetMouse();
if (!mouse)
return;
mouse->ShowCursor = HAIKU_ShowCursor;
+ mouse->SetRelativeMouseMode = HAIKU_SetRelativeMouseMode;
mouse->cur_cursor = (SDL_Cursor*)0x1;
mouse->def_cursor = (SDL_Cursor*)0x2;
}
--
2.30.0
From 3325c1a3db41dbe80e3914b2534a73ec7a5382b7 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Fri, 5 Mar 2021 17:30:08 +1000
Subject: Add support for system cursors
diff --git a/src/video/haiku/SDL_BWin.h b/src/video/haiku/SDL_BWin.h
index 34f0d5f..220d60a 100644
--- a/src/video/haiku/SDL_BWin.h
+++ b/src/video/haiku/SDL_BWin.h
@@ -37,6 +37,7 @@ extern "C" {
#include <stdio.h>
#include <AppKit.h>
+#include <Cursor.h>
#include <InterfaceKit.h>
#include <game/DirectWindow.h>
#if SDL_VIDEO_OPENGL
diff --git a/src/video/haiku/SDL_bvideo.cc b/src/video/haiku/SDL_bvideo.cc
index 234eaf0..0948451 100644
--- a/src/video/haiku/SDL_bvideo.cc
+++ b/src/video/haiku/SDL_bvideo.cc
@@ -141,20 +141,72 @@ void HAIKU_DeleteDevice(SDL_VideoDevice * device)
SDL_free(device);
}
-static int HAIKU_ShowCursor(SDL_Cursor *cur)
+static SDL_Cursor *
+HAIKU_CreateSystemCursor(SDL_SystemCursor id)
+{
+ SDL_Cursor *cursor;
+ BCursorID cursorId = B_CURSOR_ID_SYSTEM_DEFAULT;
+
+ switch(id)
+ {
+ default:
+ SDL_assert(0);
+ return NULL;
+ case SDL_SYSTEM_CURSOR_ARROW: cursorId = B_CURSOR_ID_SYSTEM_DEFAULT; break;
+ case SDL_SYSTEM_CURSOR_IBEAM: cursorId = B_CURSOR_ID_I_BEAM; break;
+ case SDL_SYSTEM_CURSOR_WAIT: cursorId = B_CURSOR_ID_PROGRESS; break;
+ case SDL_SYSTEM_CURSOR_CROSSHAIR: cursorId = B_CURSOR_ID_CROSS_HAIR; break;
+ case SDL_SYSTEM_CURSOR_WAITARROW: cursorId = B_CURSOR_ID_PROGRESS; break;
+ case SDL_SYSTEM_CURSOR_SIZENWSE: cursorId = B_CURSOR_ID_RESIZE_NORTH_WEST_SOUTH_EAST; break;
+ case SDL_SYSTEM_CURSOR_SIZENESW: cursorId = B_CURSOR_ID_RESIZE_NORTH_EAST_SOUTH_WEST; break;
+ case SDL_SYSTEM_CURSOR_SIZEWE: cursorId = B_CURSOR_ID_RESIZE_EAST_WEST; break;
+ case SDL_SYSTEM_CURSOR_SIZENS: cursorId = B_CURSOR_ID_RESIZE_NORTH_SOUTH; break;
+ case SDL_SYSTEM_CURSOR_SIZEALL: cursorId = B_CURSOR_ID_MOVE; break;
+ case SDL_SYSTEM_CURSOR_NO: cursorId = B_CURSOR_ID_NOT_ALLOWED; break;
+ case SDL_SYSTEM_CURSOR_HAND: cursorId = B_CURSOR_ID_FOLLOW_LINK; break;
+ }
+
+ cursor = (SDL_Cursor *) SDL_calloc(1, sizeof(*cursor));
+ if (cursor) {
+ cursor->driverdata = (void *)new BCursor(cursorId);
+ } else {
+ SDL_OutOfMemory();
+ }
+
+ return cursor;
+}
+
+static SDL_Cursor *
+HAIKU_CreateDefaultCursor()
+{
+ return HAIKU_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW);
+}
+
+static void
+HAIKU_FreeCursor(SDL_Cursor * cursor)
+{
+ if (cursor->driverdata) {
+ delete (BCursor*) cursor->driverdata;
+ }
+ SDL_free(cursor);
+}
+
+static int HAIKU_ShowCursor(SDL_Cursor *cursor)
{
SDL_Mouse *mouse = SDL_GetMouse();
- int show;
+
if (!mouse)
return 0;
- show = (cur || !mouse->focus);
- if (show) {
- if (be_app->IsCursorHidden())
- be_app->ShowCursor();
+
+ if (cursor) {
+ BCursor *hCursor = (BCursor*)cursor->driverdata;
+ be_app->SetCursor(hCursor);
} else {
- if (!be_app->IsCursorHidden())
- be_app->HideCursor();
+ BCursor *hCursor = new BCursor(B_CURSOR_ID_NO_CURSOR);
+ be_app->SetCursor(hCursor);
+ delete hCursor;
}
+
return 0;
}
@@ -184,10 +236,12 @@ static void HAIKU_MouseInit(_THIS)
SDL_Mouse *mouse = SDL_GetMouse();
if (!mouse)
return;
+ mouse->CreateSystemCursor = HAIKU_CreateSystemCursor;
mouse->ShowCursor = HAIKU_ShowCursor;
+ mouse->FreeCursor = HAIKU_FreeCursor;
mouse->SetRelativeMouseMode = HAIKU_SetRelativeMouseMode;
- mouse->cur_cursor = (SDL_Cursor*)0x1;
- mouse->def_cursor = (SDL_Cursor*)0x2;
+
+ SDL_SetDefaultCursor(HAIKU_CreateDefaultCursor());
}
int HAIKU_VideoInit(_THIS)
--
2.30.0
From 74d61a5e46f4ba2b1fd628ee2ca89a7eaeee120b Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Fri, 5 Mar 2021 17:31:02 +1000
Subject: Disable direct mode for BGLView
diff --git a/src/video/haiku/SDL_BWin.h b/src/video/haiku/SDL_BWin.h
index 220d60a..2b01d11 100644
--- a/src/video/haiku/SDL_BWin.h
+++ b/src/video/haiku/SDL_BWin.h
@@ -142,7 +142,7 @@ class SDL_BWin:public BDirectWindow
}
AddChild(_SDL_GLView);
_SDL_GLView->SetEventMask(B_POINTER_EVENTS | B_KEYBOARD_EVENTS, B_NO_POINTER_HISTORY);
- _SDL_GLView->EnableDirectMode(true);
+ _SDL_GLView->EnableDirectMode(false); /* Disable direct mode */
_SDL_GLView->LockGL(); /* "New" GLViews are created */
Unlock();
return (_SDL_GLView);
--
2.30.0