diff --git a/base b/base index 31fd2ba4e..e0da7633a 160000 --- a/base +++ b/base @@ -1 +1 @@ -Subproject commit 31fd2ba4ee508ba49c6d9fd367b409ef54cb7a9f +Subproject commit e0da7633a70eef43d713883d4d1a59d07394d2b4 diff --git a/doc/Building.md b/doc/Building.md index 4f136c77c..c9da0e98b 100644 --- a/doc/Building.md +++ b/doc/Building.md @@ -28,13 +28,11 @@ To get and compile the source you must have: - `unzip` - `wget` -For running the emulator / tests: -- `SDL2` - Optional: - `7z`: for packing releases and the Android build assets - `ccache`: recommended for faster recompilation times - `luacheck`, `shellcheck` and `shfmt`: for linting the codebase with `./kodev check` +- `SDL3`: for running the emulator / tests (if not installed, a version will automatically be built) ### Alpine Linux @@ -43,7 +41,7 @@ Install the prerequisites using apk: ``` sudo apk add autoconf automake bash cmake coreutils curl diffutils \ findutils g++ gcc gettext-dev git grep gzip libtool linux-headers \ - make meson nasm ninja-build patch perl pkgconf procps-ng sdl2 tar \ + make meson nasm ninja-build patch perl pkgconf procps-ng sdl3 tar \ unzip wget ``` @@ -61,7 +59,7 @@ Install the prerequisites using pacman: ``` run0 pacman -S base-devel ca-certificates cmake gcc-libs git \ - meson nasm ninja perl sdl2 unzip wget + meson nasm ninja perl sdl3 unzip wget ``` Optional: @@ -75,10 +73,23 @@ Install the prerequisites using APT: ``` sudo apt install autoconf automake build-essential ca-certificates cmake \ - gcc-multilib gettext git libsdl2-2.0-0 libtool libtool-bin meson nasm \ + gcc-multilib gettext git libtool libtool-bin meson nasm \ ninja-build patch perl pkg-config unzip wget ``` +To install SDL3, on recent enough distributions: +``` +sudo apt install libsdl3-0 +``` + +For building SDL3 on distributions that don't provide it: +``` +# Minimal Wayland support. +sudo apt install libegl-dev libwayland-dev +# Minimal X11 support. +sudo apt install libx11-dev libxext-dev +``` + **Note:** Debian distributions might need `meson` to be installed from `bookworm-backports` because the version provided by the default repositories is too old: ``` @@ -98,16 +109,16 @@ Install the prerequisites using DNF: ``` sudo dnf install autoconf automake cmake gcc gcc-c++ gettext git libtool meson \ - nasm ninja-build patch perl-FindBin procps-ng SDL2 unzip wget + nasm ninja-build patch perl-FindBin procps-ng SDL3 unzip wget ``` Optional: ``` -sudo dnf install ccache p7zip +sudo dnf install ccache p7zip shellcheck shfmt ``` And for luacheck: ``` -sudo dnf install lua-argparse lua-filesystem luarocks shellcheck shfmt +sudo dnf install lua-argparse lua-filesystem luarocks luarocks install luacheck ``` @@ -117,8 +128,7 @@ Install the prerequisites using [Homebrew](https://brew.sh/): ``` brew install autoconf automake bash binutils cmake coreutils findutils \ - gettext gnu-getopt libtool make meson nasm ninja pkg-config sdl2 \ - util-linux + gettext gnu-getopt libtool make meson nasm ninja pkg-config util-linux ``` You will also have to ensure Homebrew's findutils, gnu-getopt, make & util-linux are in your path, e.g., via diff --git a/frontend/device.lua b/frontend/device.lua index a92b0de12..4ce83bbb9 100644 --- a/frontend/device.lua +++ b/frontend/device.lua @@ -43,7 +43,7 @@ local function probeDevice() -- return require("device/newport/device") -- end - if util.loadSDL2() then + if util.loadSDL3() then return require("device/sdl/device") end diff --git a/frontend/device/dummy/device.lua b/frontend/device/dummy/device.lua index 98e596c90..5bc54d204 100644 --- a/frontend/device/dummy/device.lua +++ b/frontend/device/dummy/device.lua @@ -15,7 +15,7 @@ local Device = Generic:extend{ } function Device:init() - self.screen = require("ffi/framebuffer_SDL2_0"):new{ + self.screen = require("ffi/framebuffer_SDL3"):new{ dummy = true, device = self, debug = logger.dbg, diff --git a/frontend/device/input.lua b/frontend/device/input.lua index 1c471b6cd..e21baa09e 100644 --- a/frontend/device/input.lua +++ b/frontend/device/input.lua @@ -215,7 +215,7 @@ function Input:init() if self.input then -- luacheck: ignore 542 -- Already setup (e.g. stubbed by the testsuite). elseif self.device:isSDL() then - self.input = require("ffi/input_SDL2_0") + self.input = require("ffi/input_SDL3") self.hasClipboardText = function() return self.input.hasClipboardText() end @@ -939,7 +939,7 @@ function Input:handleTouchEv(ev) -- * PocketBook, because of our InkView EVT_POINTERMOVE translation -- (c.f., translateEvent @ ffi/input_pocketbook.lua). -- * SDL, because of our SDL_MOUSEMOTION/SDL_FINGERMOTION translation - -- (c.f., waitForEvent @ ffi/SDL2_0.lua). + -- (c.f., waitForEvent @ ffi/SDL3.lua). if ev.code == C.ABS_MT_SLOT then self:setupSlotData(ev.value) elseif ev.code == C.ABS_MT_TRACKING_ID then @@ -1028,7 +1028,7 @@ function Input:handleTouchEvSnow(ev) -- * PocketBook, because of our InkView EVT_POINTERMOVE translation -- (c.f., translateEvent @ ffi/input_pocketbook.lua). -- * SDL, because of our SDL_MOUSEMOTION/SDL_FINGERMOTION translation - -- (c.f., waitForEvent @ ffi/SDL2_0.lua). + -- (c.f., waitForEvent @ ffi/SDL3.lua). if ev.code == C.ABS_MT_SLOT then self:setupSlotData(ev.value) elseif ev.code == C.ABS_MT_TRACKING_ID then diff --git a/frontend/device/sdl/device.lua b/frontend/device/sdl/device.lua index 86a3eb657..15738b751 100644 --- a/frontend/device/sdl/device.lua +++ b/frontend/device/sdl/device.lua @@ -2,7 +2,7 @@ local Event = require("ui/event") local Geom = require("ui/geometry") local Generic = require("device/generic/device") local UIManager -local SDL = require("ffi/SDL2_0") +local SDL = require("ffi/SDL3") local ffi = require("ffi") local logger = require("logger") local time = require("ui/time") @@ -177,7 +177,7 @@ function Device:init() end self.hasClipboard = yes - self.screen = require("ffi/framebuffer_SDL2_0"):new{ + self.screen = require("ffi/framebuffer_SDL3"):new{ device = self, debug = logger.dbg, w = self.window.width, @@ -199,22 +199,10 @@ function Device:init() event_map = dofile("frontend/device/sdl/event_map_sdl2.lua"), handleSdlEv = function(device_input, ev) - - -- SDL events can remain cdata but are almost completely transparent - local SDL_TEXTINPUT = 771 - local SDL_MOUSEWHEEL = 1027 - local SDL_MULTIGESTURE = 2050 - local SDL_DROPFILE = 4096 - local SDL_WINDOWEVENT_MOVED = 4 - local SDL_WINDOWEVENT_RESIZED = 5 - - if ev.code == SDL_MOUSEWHEEL then + if ev.code == SDL.SDL.SDL_EVENT_MOUSE_WHEEL then local scrolled_x = ev.value.x local scrolled_y = ev.value.y - local up = 1 - local down = -1 - local pos = Geom:new{ x = 0, y = 0, @@ -231,6 +219,7 @@ function Device:init() pos = pos, time = time.timeval(ev.time), mousewheel_direction = scrolled_y, + direction = scrolled_y > 0 and "south" or "north" } local fake_ges_release = { ges = "pan_release", @@ -242,25 +231,15 @@ function Device:init() } local fake_pan_ev = Event:new("Pan", nil, fake_ges) local fake_release_ev = Event:new("Gesture", fake_ges_release) - if scrolled_y == down then - fake_ges.direction = "north" - UIManager:sendEvent(fake_pan_ev) - UIManager:sendEvent(fake_release_ev) - elseif scrolled_y == up then - fake_ges.direction = "south" - UIManager:sendEvent(fake_pan_ev) - UIManager:sendEvent(fake_release_ev) - end - elseif ev.code == SDL_MULTIGESTURE then - -- no-op for now - do end -- luacheck: ignore 541 - elseif ev.code == SDL_DROPFILE then + UIManager:sendEvent(fake_pan_ev) + UIManager:sendEvent(fake_release_ev) + elseif ev.code == SDL.SDL.SDL_EVENT_DROP_FILE then local dropped_file_path = ev.value if dropped_file_path and dropped_file_path ~= "" then local ReaderUI = require("apps/reader/readerui") ReaderUI:doShowReader(dropped_file_path) end - elseif ev.code == SDL_WINDOWEVENT_RESIZED then + elseif ev.code == SDL.SDL.SDL_EVENT_WINDOW_RESIZED then device_input.device.screen.resize(device_input.device.screen, ev.value.data1, ev.value.data2) self.window.width = ev.value.data1 self.window.height = ev.value.data2 @@ -289,10 +268,10 @@ function Device:init() -- make sure dialogs are displayed UIManager:setDirty("all", "ui") - elseif ev.code == SDL_WINDOWEVENT_MOVED then + elseif ev.code == SDL.SDL.SDL_EVENT_WINDOW_MOVED then self.window.left = ev.value.data1 self.window.top = ev.value.data2 - elseif ev.code == SDL_TEXTINPUT then + elseif ev.code == SDL.SDL.SDL_EVENT_TEXT_INPUT then UIManager:sendEvent(Event:new("TextInput", tostring(ev.value))) end end, diff --git a/frontend/device/sdl/powerd.lua b/frontend/device/sdl/powerd.lua index 5456bccbf..98ecf469c 100644 --- a/frontend/device/sdl/powerd.lua +++ b/frontend/device/sdl/powerd.lua @@ -1,5 +1,5 @@ local BasePowerD = require("device/generic/powerd") -local SDL = require("ffi/SDL2_0") +local SDL = require("ffi/SDL3") local SDLPowerD = BasePowerD:new{ -- these values are just used on the emulator diff --git a/tools/shell.nix b/tools/shell.nix index c8cba1852..542162782 100644 --- a/tools/shell.nix +++ b/tools/shell.nix @@ -19,7 +19,7 @@ pkgs.mkShell { ninja perl pkg-config - SDL2 + sdl3 unzip wget # optional