diff --git a/evidence/touchpad-stylus/capture.json b/evidence/touchpad-stylus/capture.json new file mode 100644 index 0000000..e02ae19 --- /dev/null +++ b/evidence/touchpad-stylus/capture.json @@ -0,0 +1,164 @@ +{ + "step": "touchpad-stylus", + "recorded": "2026-10-07T23:09:55.018212+00:00", + "revision": "working tree on 3de11ab", + "command": "PS5_FRONTENDS=\"es-de picker\" PS5_VULKAN_TEMPLATE=\"$PWD/build/picker-template\" tools/verify.sh; after repair: tools/verify.sh build integration evidence", + "raw_capture": "klog/touchpad-stylus/gates-final.log", + "raw_lines": 1817, + "raw_bytes": 111021, + "lines": [ + "format: PASS (klog/touchpad-stylus/gates.log)", + "PS5 joypad: touchpad stylus contact, hover, click, release, disconnect and scope PASS", + "Core stylus tests: hover, scale, Vulkan geometry, software pixels and clipping PASS", + "Final patches match native core build provenance: PASS", + "Ran 182 tests in 247.117s", + "verify: PASS (build integration evidence)", + "Stored console eboot.bin and both cores match staged SHA-256: PASS" + ], + "staged_artifacts": { + "eboot.bin": { + "bytes": 38772204, + "sha256": "11c1168c587008dd04cd2b060ee12975df9c3f207db9d8e4421baad985929cff" + }, + "cores/desmume_libretro.so": { + "bytes": 5642792, + "sha256": "57e321510e339017310143521087e799346ebaadbc72a2ed1aa74128b7d05500" + }, + "cores/azahar_libretro.so": { + "bytes": 62186680, + "sha256": "8a8dab00afafcb92fc60839512dbb1c572ff16c928b0d9b6fe0ee302fc7ac85b" + }, + "manifest.sha256": { + "bytes": 1785503, + "sha256": "149f65281ecb8c9fb7c250990a8deb08b68f1f2ee6bb381cdc1cf85d2c6c1c6b" + } + }, + "native_cores": { + "desmume": { + "sha256": "57e321510e339017310143521087e799346ebaadbc72a2ed1aa74128b7d05500", + "bytes": 5642792, + "needed": [ + "libkernel_web.sprx", + "libSceLibcInternal.sprx", + "libScePosixForWebKit.sprx" + ], + "libretro_exports": [ + "retro_api_version", + "retro_cheat_reset", + "retro_cheat_set", + "retro_deinit", + "retro_get_memory_data", + "retro_get_memory_size", + "retro_get_region", + "retro_get_system_av_info", + "retro_get_system_info", + "retro_init", + "retro_load_game", + "retro_load_game_special", + "retro_reset", + "retro_run", + "retro_serialize", + "retro_serialize_size", + "retro_set_audio_sample", + "retro_set_audio_sample_batch", + "retro_set_controller_port_device", + "retro_set_environment", + "retro_set_input_poll", + "retro_set_input_state", + "retro_set_video_refresh", + "retro_unload_game", + "retro_unserialize" + ], + "abi_passed": true, + "console_loading_verified": false, + "source_revision": "54540709d343bd93d021487af4408679ca187825", + "port_inputs_sha256": { + "tools/core-fork.sh": "392c8a7577eaa7a81e99f58a6e006cecab92610d959dc460aabc3ef1064ac1b0", + "tooling/native/ps5-core.ld": "5ffe0f0e99e23de5245afb46fa6dfda6dd860b53d942a5fe2f06eaf9e520df42", + "tooling/native/core_cxx_runtime.cpp": "6d7c11d8595f47601b3a281e616033ea5d28c6329872aa286d4d81c597509433", + "tools/build-desmume.sh": "55ad2647a5cb5333eb6dd4e3454af5cc93e5be2ea235910e5bc18d7506e63b24", + "tooling/desmume/touchpad-stylus.patch": "abb72fdd9711444bc47913c4110b70aa4fd209f9949e053f74af2ff4535bf9ec" + } + }, + "azahar": { + "sha256": "8a8dab00afafcb92fc60839512dbb1c572ff16c928b0d9b6fe0ee302fc7ac85b", + "bytes": 62186680, + "needed": [ + "libkernel_web.sprx", + "libSceLibcInternal.sprx", + "libScePosixForWebKit.sprx" + ], + "libretro_exports": [ + "retro_api_version", + "retro_cheat_reset", + "retro_cheat_set", + "retro_deinit", + "retro_get_memory_data", + "retro_get_memory_size", + "retro_get_region", + "retro_get_system_av_info", + "retro_get_system_info", + "retro_init", + "retro_load_game", + "retro_load_game_special", + "retro_reset", + "retro_run", + "retro_serialize", + "retro_serialize_size", + "retro_set_audio_sample", + "retro_set_audio_sample_batch", + "retro_set_controller_port_device", + "retro_set_environment", + "retro_set_input_poll", + "retro_set_input_state", + "retro_set_video_refresh", + "retro_unload_game", + "retro_unserialize" + ], + "abi_passed": true, + "console_loading_verified": false, + "source_revision": "4aef900a1a903d0aa6ea86fdb1e18236fb0d5907", + "port_inputs_sha256": { + "tools/core-fork.sh": "392c8a7577eaa7a81e99f58a6e006cecab92610d959dc460aabc3ef1064ac1b0", + "tooling/native/ps5-core.ld": "5ffe0f0e99e23de5245afb46fa6dfda6dd860b53d942a5fe2f06eaf9e520df42", + "tooling/native/core_cxx_runtime.cpp": "6d7c11d8595f47601b3a281e616033ea5d28c6329872aa286d4d81c597509433", + "tools/build-azahar.sh": "2418b991f7f4a71c4c4c984ab7831dad085861c6a40e82c0e8ca791acee2f40c", + "tooling/azahar/ps5-toolchain.cmake": "930762cf6f56d1e8b1a927bd70ac5e782f77cdb9b9622617973ef92ce881c398", + "tooling/azahar/touchpad-stylus.patch": "9c5881c02b3c7f8e71f45ad6114f88351de28bd3403e195ce2f5a9703ffe8f89" + } + } + }, + "deployed_readback": { + "eboot.bin": { + "bytes": 38772204, + "sha256": "11c1168c587008dd04cd2b060ee12975df9c3f207db9d8e4421baad985929cff", + "matches_staged": true + }, + "cores/desmume_libretro.so": { + "bytes": 5642792, + "sha256": "57e321510e339017310143521087e799346ebaadbc72a2ed1aa74128b7d05500", + "matches_staged": true + }, + "cores/azahar_libretro.so": { + "bytes": 62186680, + "sha256": "8a8dab00afafcb92fc60839512dbb1c572ff16c928b0d9b6fe0ee302fc7ac85b", + "matches_staged": true + } + }, + "tests": { + "driver": "Production PS5 driver with mocked native pad samples; first contact, hover, click, finger switch, lift/recontact, duplicate polling, disconnection, interception and read error. Core/menu gating, other cores and Select preserved outside DS/3DS.", + "core": "Pinned fork patches applied in a temporary tree. Production DeSmuME normal/hybrid RGB565/XRGB8888 cursor code and Azahar mouse update, Vulkan cursor vertices and software cursor compiled under ASan/UBSan. Hover, drag, release, render scaling and lower-screen bounds.", + "preview": "klog/touchpad-stylus/stylus-preview.png: host render of production DeSmuME DrawStylus; visually inspected." + }, + "initial_build_failure": { + "raw_capture": "klog/touchpad-stylus/gates.log", + "reason": "DeSmuME hybrid cursor std::max mixed signed factor and unsigned scale.", + "repair": "Use unsigned minimum; expanded host cursor test compiles and exercises both normal and hybrid wrappers. Final native build passes." + }, + "software_followup": "Azahar software rendering is a selectable shipped option. Its cursor was also converted from crosshair to stylus, then rebuilt and the full integration gate rerun.", + "console_run": "Final title and both cores uploaded and exact stored hashes verified. No title launch or physical DualSense stylus interaction performed in this turn.", + "limits": [ + "Physical movement, press/drag/release and cursor appearance on console require owner verification.", + "DeSmuME requires Mouse/Pointer enabled and Pointer Type Mouse; Azahar requires mouse touchscreen enabled (all defaults)." + ] +} diff --git a/evidence/touchpad-stylus/expectation.json b/evidence/touchpad-stylus/expectation.json new file mode 100644 index 0000000..3a88afa --- /dev/null +++ b/evidence/touchpad-stylus/expectation.json @@ -0,0 +1,17 @@ +{ + "step": "touchpad-stylus", + "note": "Host/native/deployment evidence; physical controller acceptance remains pending.", + "must_contain": [ + "format: PASS", + "Core stylus tests:", + "Final patches match native core build provenance: PASS", + "Ran 182 tests", + "verify: PASS (build integration evidence)", + "Stored console eboot.bin and both cores match staged SHA-256: PASS" + ], + "must_not_contain": [ + "FAILED", + "ERROR" + ], + "human_check": "Restart the title; in DeSmuME and Azahar, slide without pressing (hover), physically click (touch), hold and slide (drag), then release. Confirm the stylus nib hits the intended lower-screen point, lifting/recontacting does not jump, and menu/other-core touchpad Select still works." +} diff --git a/src/input_ps5.cpp b/src/input_ps5.cpp index 9edf39a..ba86419 100644 --- a/src/input_ps5.cpp +++ b/src/input_ps5.cpp @@ -60,6 +60,7 @@ * Reference: docs/REFERENCE.md, "Input". */ +#include #include #include #include @@ -180,7 +181,14 @@ struct PadSample std::uint8_t right_y; std::uint8_t left_trigger; std::uint8_t right_trigger; - std::uint8_t reserved_to_connected[66]; + std::uint8_t reserved_to_touch[42]; + std::uint8_t touch_count; + std::uint8_t reserved_touch[7]; + struct + { + std::uint16_t x, y; + std::uint8_t id, reserved[3]; + } touches[2]; std::int32_t connected; std::uint64_t timestamp_us; std::uint8_t extension[16]; @@ -190,6 +198,9 @@ struct PadSample static_assert(sizeof(PadSample) == 120, "the console's pad samples are 120 bytes"); static_assert(offsetof(PadSample, left_x) == 0x04, "the stick bytes follow the button word"); +// Touch fields verified by PS5_Proton's ps5/src/platform.c. +static_assert(offsetof(PadSample, touch_count) == 0x34, "touch count sits at 0x34"); +static_assert(offsetof(PadSample, touches) == 0x3c, "touch contacts sit at 0x3c"); static_assert(offsetof(PadSample, connected) == 0x4c, "connection state sits at 0x4c"); static_assert(offsetof(PadSample, timestamp_us) == 0x50, "the timestamp sits at 0x50"); @@ -216,6 +227,28 @@ extern "C" void ps5_input_trace(const char *line) noexcept; namespace { +// Relative contact tracking adapted from PS5_Proton src/proton_touchpad.h +// (LGPL-2.1-or-later; provenance and licence in third_party/proton_touchpad). +struct Touchpad +{ + bool active = false, clicked = false; + unsigned finger = 0; + int x = 0, y = 0, pending_x = 0, pending_y = 0; + std::int16_t frame_x = 0, frame_y = 0; +}; + +bool stylus_enabled() noexcept +{ +#ifdef HAVE_MENU + if (menu_state_get_ptr()->flags & MENU_ST_FLAG_ALIVE) + return false; +#endif + const auto *runloop = runloop_state_get_ptr(); + const char *name = runloop->system.info.library_name; + return (runloop->flags & RUNLOOP_FLAG_CORE_RUNNING) && name && + (!std::strcmp(name, "DeSmuME") || !std::strcmp(name, "Azahar")); +} + struct PadState { std::int32_t user_id = -1; @@ -227,6 +260,7 @@ struct PadState * holds older frames and must not be reported as current. */ std::int32_t sample_count = 0; std::uint32_t buttons = 0; + Touchpad touch; /* Last motor levels pushed to the pad: one scePadSetVibration call carries * both, while RetroArch sets one motor at a time. Atomic because the * haptic feeder thread reads them from outside the input path. */ @@ -750,6 +784,8 @@ void poll_pad(void *data) noexcept PadState *state = state_of(data); if (state == nullptr || state->handle < 0) return; + if (state->port != 0 || !stylus_enabled()) + state->touch = {}; const std::int32_t count = scePadRead(state->handle, state->samples, sample_capacity); if (count == 0) return; // No new samples: preserve the last state across a second binding poll. @@ -760,11 +796,30 @@ void poll_pad(void *data) noexcept * down. */ state->sample_count = 0; state->buttons = 0; + state->touch = {}; return; } state->sample_count = count; const PadSample *newest = newest_sample(*state); state->buttons = newest != nullptr ? newest->buttons : 0; + if (newest && state->port == 0 && stylus_enabled()) + { + auto &touch = state->touch; + const auto &finger = newest->touches[0]; + const bool touching = newest->touch_count != 0; + if (touching && touch.active && finger.id == touch.finger) + { + touch.pending_x = std::clamp(touch.pending_x + finger.x - touch.x, -32767, 32767); + touch.pending_y = std::clamp(touch.pending_y + finger.y - touch.y, -32767, 32767); + } + touch.active = touching; + touch.clicked = (newest->buttons & pad_button_touch_pad) != 0; + touch.finger = finger.id; + touch.x = finger.x; + touch.y = finger.y; + } + else + state->touch = {}; /* Successful button transitions are routine, not diagnostics. Keep pad-open * failures and lifecycle logs, without a synchronous file write per press. */ @@ -1245,7 +1300,10 @@ std::uint32_t joypad_buttons(unsigned port) noexcept const PadSample *sample = newest_sample(*state); if (!sample) return scripted; - auto mask = pad_buttons_to_retropad(sample->buttons) | scripted; + auto buttons = sample->buttons; + if (port == 0 && stylus_enabled()) + buttons &= ~pad_button_touch_pad; + auto mask = pad_buttons_to_retropad(buttons) | scripted; if (sample->left_trigger > 127) mask |= UINT32_C(1) << RETRO_DEVICE_ID_JOYPAD_L2; if (sample->right_trigger > 127) @@ -1372,6 +1430,17 @@ void *ps5_input_init(const char *) noexcept } void ps5_input_poll(void *) noexcept { + if (auto *pad = pad_at(0)) + { + auto &touch = pad->touch; + if (!stylus_enabled()) + touch = {}; + // Joypad polling precedes this callback. Snapshot once per input poll: + // repeated core queries see the same delta; binding polls lose no motion. + touch.frame_x = static_cast(touch.pending_x); + touch.frame_y = static_cast(touch.pending_y); + touch.pending_x = touch.pending_y = 0; + } /* An update to install: asked of this process's own WebUI, or of the daemon's * (src/webui_link.h), which installs once the title has closed. */ if ((ps5_update::exit_requested() || ps5_webui_link_install_requested()) && !update_exit_armed) @@ -1388,16 +1457,30 @@ void ps5_input_free(void *) noexcept } std::int16_t ps5_input_state(void *, const input_device_driver_t *, const input_device_driver_t *, - rarch_joypad_info_t *, const retro_keybind_set *, bool, unsigned, - unsigned, unsigned, unsigned) noexcept + rarch_joypad_info_t *, const retro_keybind_set *, bool, unsigned port, + unsigned device, unsigned, unsigned id) noexcept { + if (port == 0 && device == RETRO_DEVICE_MOUSE && stylus_enabled()) + if (const auto *pad = pad_at(0)) + { + switch (id) + { + case RETRO_DEVICE_ID_MOUSE_X: + return pad->touch.frame_x; + case RETRO_DEVICE_ID_MOUSE_Y: + return pad->touch.frame_y; + case RETRO_DEVICE_ID_MOUSE_LEFT: + return pad->touch.clicked; + } + } return 0; // Mapped joypad input is supplied by RetroArch's input_state_wrap. } std::uint64_t ps5_input_capabilities(void *data) noexcept { (void)data; - return (UINT64_C(1) << RETRO_DEVICE_JOYPAD) | (UINT64_C(1) << RETRO_DEVICE_ANALOG); + return (UINT64_C(1) << RETRO_DEVICE_JOYPAD) | (UINT64_C(1) << RETRO_DEVICE_ANALOG) | + (UINT64_C(1) << RETRO_DEVICE_MOUSE); } } // namespace diff --git a/tests/input_ps5_test.cpp b/tests/input_ps5_test.cpp index 68d6982..88beb7f 100644 --- a/tests/input_ps5_test.cpp +++ b/tests/input_ps5_test.cpp @@ -544,6 +544,97 @@ int main() login_users[1] = login_users[2] = login_users[3] = -1; } + assert(ps5_joypad.init(input)); + // Proton-style relative tracking: hover, drag, finger identity, release, + // duplicate binding polls and loss of the pad must not jump or stick. + auto mouse = [&](unsigned id, unsigned port = 0) + { + return input_ps5.input_state(input, &ps5_joypad, nullptr, nullptr, nullptr, false, port, + RETRO_DEVICE_MOUSE, 0, id); + }; + for (const char *core : {"DeSmuME", "Azahar"}) + { + test_runloop.system.info.library_name = core; + test_runloop.flags |= RUNLOOP_FLAG_CORE_RUNNING; + p = sample(); + p.touch_count = 1; + p.touches[0].id = 7; + p.touches[0].x = 500; + p.touches[0].y = 400; + feed(p); + input_ps5.poll(input); + assert(mouse(RETRO_DEVICE_ID_MOUSE_X) == 0); + p.touches[0].x += 20; + p.touches[0].y -= 10; + feed(p); + ps5_joypad.poll(); // No new sample: pending movement is retained. + input_ps5.poll(input); + assert(mouse(RETRO_DEVICE_ID_MOUSE_X) == 20); + assert(mouse(RETRO_DEVICE_ID_MOUSE_X) == 20); // Stable within this poll. + assert(mouse(RETRO_DEVICE_ID_MOUSE_Y) == -10); + assert(!mouse(RETRO_DEVICE_ID_MOUSE_LEFT)); + assert(!mouse(RETRO_DEVICE_ID_MOUSE_X, 1)); + input_ps5.poll(input); + assert(!mouse(RETRO_DEVICE_ID_MOUSE_X)); + p.buttons = pad_button_touch_pad; + feed(p); + input_ps5.poll(input); + assert(mouse(RETRO_DEVICE_ID_MOUSE_LEFT)); + assert(!ps5_joypad.button(0, RETRO_DEVICE_ID_JOYPAD_SELECT)); + p.touches[0].id = 8; + p.touches[0].x = 10; + feed(p); + input_ps5.poll(input); + assert(!mouse(RETRO_DEVICE_ID_MOUSE_X) && mouse(RETRO_DEVICE_ID_MOUSE_LEFT)); + p.touch_count = 0; + p.buttons = 0; + feed(p); + input_ps5.poll(input); + assert(!mouse(RETRO_DEVICE_ID_MOUSE_LEFT)); + p.touch_count = 1; + p.touches[0].x = 800; + feed(p); + input_ps5.poll(input); + assert(!mouse(RETRO_DEVICE_ID_MOUSE_X)); + for (int failure = 0; failure < 3; ++failure) + { + p.connected = 1; + p.buttons = pad_button_touch_pad; + feed(p); + input_ps5.poll(input); + assert(mouse(RETRO_DEVICE_ID_MOUSE_LEFT)); + if (failure == 0) + p.connected = 0; + if (failure == 1) + p.buttons |= pad_button_intercepted; + if (failure == 2) + { + read_results[1] = -1; + ps5_joypad.poll(); + } + else + feed(p); + input_ps5.poll(input); + assert(!mouse(RETRO_DEVICE_ID_MOUSE_LEFT)); + } + test_runloop.flags &= ~RUNLOOP_FLAG_CORE_RUNNING; + p = sample(); + p.buttons = pad_button_touch_pad; + feed(p); + input_ps5.poll(input); + assert(!mouse(RETRO_DEVICE_ID_MOUSE_LEFT)); + assert(ps5_joypad.button(0, RETRO_DEVICE_ID_JOYPAD_SELECT)); + } + test_runloop.system.info.library_name = "Other core"; + test_runloop.flags |= RUNLOOP_FLAG_CORE_RUNNING; + feed(p); + assert(!mouse(RETRO_DEVICE_ID_MOUSE_LEFT)); + assert(ps5_joypad.button(0, RETRO_DEVICE_ID_JOYPAD_SELECT)); + test_runloop.flags = 0; + test_runloop.system.info.library_name = nullptr; + + ps5_joypad.destroy(); + // STOP ends the run on the next frame, as --max-frames does, and only once. test_video.frame_count = 1234; actions[0] = ScriptAction{0.0, false, ScriptActionKind::stop, -1, {}, {}}; @@ -583,7 +674,8 @@ int main() assert(test_runloop.max_frames == 51); // repeated polls cannot postpone exit request_update_exit = false; std::puts("PS5 joypad: raw binding capture, axes, user mappings, rumble, poll retention, " - "lifecycle, four players by signed-in user and the script's STOP and OPTION PASS"); + "lifecycle, touchpad stylus, four players by signed-in user and the script's STOP " + "and OPTION PASS"); } namespace ps5_update diff --git a/tests/test_touchpad_stylus.py b/tests/test_touchpad_stylus.py new file mode 100644 index 0000000..24ee031 --- /dev/null +++ b/tests/test_touchpad_stylus.py @@ -0,0 +1,252 @@ +"""Exercise patched core input/cursor code without a console or game image.""" +from pathlib import Path +import os +import subprocess +import tempfile +import unittest + +ROOT = Path(__file__).resolve().parent.parent + + +def function(source, signature): + start = source.index(signature) + brace = source.index('{', start) + depth = 1 + end = brace + 1 + while depth: + depth += (source[end] == '{') - (source[end] == '}') + end += 1 + return source[start:end] + + +class TouchpadStylus(unittest.TestCase): + def compile_run(self, source): + with tempfile.TemporaryDirectory() as td: + cpp = Path(td, 'test.cpp') + cpp.write_text(source) + binary = str(Path(td, 'test')) + subprocess.run(['c++', '-std=c++17', '-fsanitize=address,undefined', + '-fno-omit-frame-pointer', str(cpp), '-o', binary], check=True) + subprocess.run([binary], check=True, env=dict(os.environ, ASAN_OPTIONS='detect_leaks=0')) + + def patched(self, core, path): + # Apply the committed patch to the exact pinned fork, independent of the + # current configured build. This also checks build reproducibility. + script = (ROOT / f'tools/build-{core}.sh').read_text() + revision = script.split('revision=')[1].split()[0] + patch = ROOT / f'tooling/{core}/touchpad-stylus.patch' + paths = [line[6:] for line in patch.read_text().splitlines() if line.startswith('+++ b/')] + with tempfile.TemporaryDirectory() as td: + for filename in paths: + output = Path(td, filename) + output.parent.mkdir(parents=True, exist_ok=True) + output.write_bytes(subprocess.check_output( + ['git', '-C', str(ROOT / f'.deps/{core}-src'), 'show', f'{revision}:{filename}'])) + subprocess.run(['patch', '-s', '-p1', '-i', str(patch)], cwd=td, check=True) + return Path(td, path).read_text() + + def test_core_and_menu_scope(self): + source = (ROOT / 'src/input_ps5.cpp').read_text() + self.compile_run(''' +#include +#include +#define HAVE_MENU +constexpr unsigned MENU_ST_FLAG_ALIVE = 1, RUNLOOP_FLAG_CORE_RUNNING = 2; +struct {unsigned flags;} menu{}; +struct {unsigned flags; struct {struct {const char* library_name;} info;} system;} runloop{}; +auto menu_state_get_ptr() {return &menu;} +auto runloop_state_get_ptr() {return &runloop;} +''' + function(source, 'bool stylus_enabled()') + ''' +int main() { + runloop.system.info.library_name = "Azahar"; + assert(!stylus_enabled()); + runloop.flags = RUNLOOP_FLAG_CORE_RUNNING; + assert(stylus_enabled()); + menu.flags = MENU_ST_FLAG_ALIVE; + assert(!stylus_enabled()); + menu.flags = 0; + runloop.system.info.library_name = "DeSmuME"; + assert(stylus_enabled()); + runloop.system.info.library_name = "Other"; + assert(!stylus_enabled()); + runloop.system.info.library_name = nullptr; + assert(!stylus_enabled()); +} +''') + + def test_desmume_stylus_pixels_and_clipping(self): + source = self.patched('desmume', 'desmume/src/frontend/libretro/libretro.cpp') + self.compile_run(''' +#include +#include +#include +#include +constexpr int RETRO_PIXEL_FORMAT_XRGB8888 = 1; +int colorMode; +uint32_t pointer_color_32=0xffffff; +uint16_t pointer_colour=0xffff; +unsigned scale=1, GPU_LR_FRAMEBUFFER_NATIVE_WIDTH=256, GPU_LR_FRAMEBUFFER_NATIVE_HEIGHT=192; +int TouchX=0,TouchY=0,FramesWithPointer=600,hybrid_layout_scale=1,hybrid_layout_ratio=3,bpp=2; +int gap_size(){return 0;} +''' + function(source, 'static inline int32_t Saturate(') + + function(source, 'static void DrawStylus(') + + function(source, 'static void DrawPointer(') + + function(source, 'static void DrawPointerHybrid(') + ''' +int main() { + for (int mode : {0,1}) { + colorMode=mode; bpp=mode ? 4 : 2; + std::vector frame(768*1152); + for (int hybrid : {1,3}) { + hybrid_layout_scale=hybrid; + FramesWithPointer=600; TouchX=255; TouchY=191; + DrawPointer(reinterpret_cast(frame.data()),768); + DrawPointerHybrid(reinterpret_cast(frame.data()),768,true); + DrawPointerHybrid(reinterpret_cast(frame.data()),768,false); + } + } + for (int mode : {0,1}) for (int scale : {1,5}) { + colorMode = mode; + const int w = 32*scale, h = 24*scale, pitch = w+8; + for (int x : {-3, 0, w-1}) for (int y : {-3,0,h-1}) { + std::vector pixels(pitch*h+8, 0x12345678); + DrawStylus(reinterpret_cast(pixels.data()),pitch,w,h,x,y,scale); + for (int row=0;row(pixels.data())[row*pitch+col] == + ((row*pitch+col)%2 ? 0x1234 : 0x5678)); + } + assert(pixels.back()==0x12345678); + if(x==0 && y==0) { + if(mode) assert(pixels[0]==0 && pixels[scale*pitch+scale]==0xffffff); + else {auto p=reinterpret_cast(pixels.data()); + assert(p[0]==0 && p[scale*pitch+scale]==0xffff);} + } + } + } +} +''') + + def test_azahar_software_stylus(self): + source = self.patched('azahar', 'src/citra_libretro/input/mouse_tracker.cpp') + self.compile_run(""" +#include +#include +#include +#include +namespace Layout { +struct FramebufferLayout { + bool IsWithinTouchscreen(int x,int y)const{return x>=10&&x<30&&y>=20&&y<40;} +}; } +struct SoftwareCursorRenderer { + void Render(int,int,float,float,float,const Layout::FramebufferLayout&,void*); +}; +""" + function(source, 'void SoftwareCursorRenderer::Render(') + """ +int main() { + SoftwareCursorRenderer cursor; Layout::FramebufferLayout layout; + for(float x : {10.f,29.f}) for(float y : {20.f,39.f}) { + std::vector pixels(40*50,0xff123456); + cursor.Render(40,50,x,y,8,layout,pixels.data()); + assert(pixels[static_cast(y)*40+static_cast(x)]==0xffedcba9); + for(int py=0;py<50;++py) for(int px=0;px<40;++px) + if(!layout.IsWithinTouchscreen(px,py)) assert(pixels[py*40+px]==0xff123456); + } + cursor.Render(40,50,10,20,8,layout,nullptr); +} +""") + + def test_azahar_stylus_geometry(self): + source = self.patched('azahar', 'src/video_core/renderer_vulkan/renderer_vulkan.cpp') + start = source.index(' const float buf_w', source.index('void RendererVulkan::DrawCursor(')) + end = source.index(' const u64 size = sizeof(vertices);', start) + self.compile_run(""" +#include +#include +#include +#include +struct Rect {float left,top,right,bottom; float GetHeight()const{return bottom-top;}}; +int main() { + for(float scale : {1.f,18.f}) for(float x : {0.f,160.f,319.f}) + for(float y : {0.f,120.f,239.f}) { + struct {float width,height; Rect bottom_screen;} layout{ + 400*scale,480*scale,{40*scale,240*scale,360*scale,480*scale}}; + struct {float projected_x,projected_y;} cursor{x*scale,y*scale}; +""" + source[start:end] + """ + assert(sizeof(vertices)/sizeof(float)==18); + assert(vertices[0]==cx && vertices[1]==cy); // nib is the exact touch point + for(unsigned i=0;i<18;i+=2) { + assert(vertices[i]>=bl && vertices[i]<=br); + assert(vertices[i+1]>=bt && vertices[i+1]<=bb); + } + } +} +""") + + def test_azahar_hover_drag_and_resolution(self): + source = self.patched('azahar', 'src/citra_libretro/input/mouse_tracker.cpp') + bodies = '\n'.join(function(source, signature) for signature in [ + 'void MouseTracker::OnMouseMove(', 'void MouseTracker::Restrict(', + 'void MouseTracker::Update(']) + self.compile_run(''' +#include +#include +#include +#include +#include +#include +enum {RETRO_DEVICE_MOUSE,RETRO_DEVICE_POINTER,RETRO_DEVICE_JOYPAD,RETRO_DEVICE_ANALOG}; +enum {RETRO_DEVICE_ID_MOUSE_X,RETRO_DEVICE_ID_MOUSE_Y,RETRO_DEVICE_ID_MOUSE_LEFT}; +enum {RETRO_DEVICE_ID_POINTER_X,RETRO_DEVICE_ID_POINTER_Y,RETRO_DEVICE_ID_POINTER_PRESSED}; +constexpr int RETRO_DEVICE_ID_JOYPAD_R3=0, RETRO_DEVICE_INDEX_ANALOG_RIGHT=0; +constexpr int RETRO_DEVICE_ID_ANALOG_X=0, RETRO_DEVICE_ID_ANALOG_Y=1; +namespace Layout { +struct Rect {int left=0, top=0, right=320,bottom=240; +int GetWidth() const {return right-left;} int GetHeight() const{return bottom-top;}}; +struct FramebufferLayout {Rect bottom_screen; +bool IsWithinTouchscreen(int x,int y) const {return x>=bottom_screen.left && +x=bottom_screen.top && y0); + inputs[RETRO_DEVICE_MOUSE][0]=0; inputs[RETRO_DEVICE_MOUSE][1]=0; + inputs[RETRO_DEVICE_MOUSE][2]=1; + // Unpressed absolute pointer coordinates must never snap a mouse click. + inputs[RETRO_DEVICE_POINTER][0]=32767; + update(); + assert(tracker.isPressed && tracker.x==160*scale && tracker.y==120*scale); + inputs[RETRO_DEVICE_MOUSE][0]=32767; inputs[RETRO_DEVICE_MOUSE][1]=32767; + update(); assert(tracker.x==320*scale-1 && tracker.y==240*scale-1); + inputs[RETRO_DEVICE_MOUSE][0]=-32767; inputs[RETRO_DEVICE_MOUSE][1]=-32767; + inputs[RETRO_DEVICE_MOUSE][2]=0; + update(); assert(tracker.x==0 && tracker.y==0 && !tracker.isPressed); +} +} +''') diff --git a/third_party/proton_touchpad/LICENSE b/third_party/proton_touchpad/LICENSE new file mode 100644 index 0000000..f6683e7 --- /dev/null +++ b/third_party/proton_touchpad/LICENSE @@ -0,0 +1,501 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, see . + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Moe Ghoul, President of Vice + +That's all there is to it! diff --git a/third_party/proton_touchpad/source.json b/third_party/proton_touchpad/source.json new file mode 100644 index 0000000..926eb03 --- /dev/null +++ b/third_party/proton_touchpad/source.json @@ -0,0 +1,9 @@ +{ + "repository": "https://github.com/mihawk-99/PS5_Proton", + "revision": "a25fce0f9c270e221e82cd43af7252afe2bf2c88", + "files": [ + "src/proton_touchpad.h", + "ps5/src/platform.c" + ], + "adaptation": "src/input_ps5.cpp: contact identity, relative movement, physical press and verified raw touch layout." +} diff --git a/tooling/azahar/touchpad-stylus.patch b/tooling/azahar/touchpad-stylus.patch new file mode 100644 index 0000000..31b3415 --- /dev/null +++ b/tooling/azahar/touchpad-stylus.patch @@ -0,0 +1,186 @@ +--- a/src/citra_libretro/input/mouse_tracker.cpp ++++ b/src/citra_libretro/input/mouse_tracker.cpp +@@ -63,7 +63,8 @@ + } + }; + +-MouseTracker::MouseTracker() { ++MouseTracker::MouseTracker() : x(0), y(0), lastMouseX(0), lastMouseY(0), ++ projectedX(0), projectedY(0), isPressed(false) { + // Create renderer-specific cursor renderer based on current graphics API + cursor_renderer = nullptr; + switch (Settings::values.graphics_api.GetValue()) { +@@ -104,13 +105,24 @@ + + if (LibRetro::settings.enable_mouse_touchscreen) { + state |= LibRetro::CheckInput(0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_LEFT); +- } +- +- if (LibRetro::settings.enable_touch_touchscreen) { +- state |= LibRetro::CheckInput(0, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_PRESSED); +- } +- +- if (state == true) { ++ const int dx = LibRetro::CheckInput(0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_X); ++ const int dy = LibRetro::CheckInput(0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_Y); ++ // DualSense contact units are 1920 x 1080, independent of render scale. ++ mouseRemainderX += dx * layout.bottom_screen.GetWidth() / 1920.0f; ++ mouseRemainderY += dy * layout.bottom_screen.GetHeight() / 1080.0f; ++ const int mx = static_cast(mouseRemainderX); ++ const int my = static_cast(mouseRemainderY); ++ OnMouseMove(mx, my); ++ mouseRemainderX -= mx; ++ mouseRemainderY -= my; ++ wasMoved = dx != 0 || dy != 0; ++ } ++ ++ const bool pointerPressed = LibRetro::settings.enable_touch_touchscreen && ++ LibRetro::CheckInput(0, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_PRESSED); ++ state |= pointerPressed; ++ ++ if (pointerPressed) { + auto pointerX = LibRetro::CheckInput(0, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_X); + auto pointerY = LibRetro::CheckInput(0, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_Y); + auto newX = static_cast((pointerX + 0x7fff) / (float)(0x7fff * 2) * bufferWidth); +@@ -172,7 +184,8 @@ + static_cast(controllerY * heightSpeed)); + } + +- Restrict(0, 0, layout.bottom_screen.GetWidth(), layout.bottom_screen.GetHeight()); ++ Restrict(0, 0, std::max(0, static_cast(layout.bottom_screen.GetWidth()) - 1), ++ std::max(0, static_cast(layout.bottom_screen.GetHeight()) - 1)); + + // Store as bottom-screen-local pixel coordinates + projectedX = static_cast(x); +@@ -180,7 +193,7 @@ + + isPressed = state; + +- if (wasMoved) { ++ if (wasMoved || state) { + last_moved = std::chrono::steady_clock::now(); + } + +@@ -340,49 +353,24 @@ + return; // No framebuffer data available + } + +- // Convert coordinates to screen space +- int centerX = static_cast(projectedX); +- int centerY = static_cast(projectedY); +- int radius = static_cast(renderRatio); +- +- // Calculate cursor dimensions within bounds +- int verticalLeft = std::max(centerX - radius / 5, static_cast(layout.bottom_screen.left)); +- int verticalRight = +- std::min(centerX + radius / 5, static_cast(layout.bottom_screen.right)); +- int verticalTop = std::max(centerY - radius, static_cast(layout.bottom_screen.top)); +- int verticalBottom = std::min(centerY + radius, static_cast(layout.bottom_screen.bottom)); +- +- int horizontalLeft = std::max(centerX - radius, static_cast(layout.bottom_screen.left)); +- int horizontalRight = std::min(centerX + radius, static_cast(layout.bottom_screen.right)); +- int horizontalTop = std::max(centerY - radius / 5, static_cast(layout.bottom_screen.top)); +- int horizontalBottom = +- std::min(centerY + radius / 5, static_cast(layout.bottom_screen.bottom)); +- +- // Draw cursor directly to framebuffer (assuming RGBA8888 format) +- uint32_t* pixels = static_cast(framebuffer_data); +- const uint32_t cursorColor = 0xFFFFFFFF; // White cursor +- +- // Draw vertical line of cursor +- for (int y = verticalTop; y < verticalBottom; ++y) { +- for (int x = verticalLeft; x < verticalRight; ++x) { +- if (x >= 0 && x < bufferWidth && y >= 0 && y < bufferHeight) { +- int pixelIndex = y * bufferWidth + x; +- // XOR blend for visibility on any background +- pixels[pixelIndex] ^= cursorColor; ++ // A pen whose nib is the touch point, clipped to the bottom screen. ++ static const char glyph[12][13] = { ++ "## ", "#.# ", " #.# ", " #.## ", ++ " #..# ", " #...# ", " #...# ", " #...# ", ++ " #...# ", " #...#", " #.# ", " # " ++ }; ++ const int size = std::max(1, static_cast(renderRatio / 8)); ++ auto* pixels = static_cast(framebuffer_data); ++ for (int row = 0; row < 12 * size; ++row) { ++ for (int col = 0; col < 12 * size; ++col) { ++ const int x = static_cast(projectedX) + col; ++ const int y = static_cast(projectedY) + row; ++ if (glyph[row / size][col / size] == '#' && x >= 0 && y >= 0 && ++ x < bufferWidth && y < bufferHeight && layout.IsWithinTouchscreen(x, y)) { ++ pixels[y * bufferWidth + x] ^= 0x00ffffff; + } + } + } +- +- // Draw horizontal line of cursor +- for (int y = horizontalTop; y < horizontalBottom; ++y) { +- for (int x = horizontalLeft; x < horizontalRight; ++x) { +- if (x >= 0 && x < bufferWidth && y >= 0 && y < bufferHeight) { +- int pixelIndex = y * bufferWidth + x; +- // XOR blend for visibility on any background +- pixels[pixelIndex] ^= cursorColor; +- } +- } +- } + } + + } // namespace Input +--- a/src/citra_libretro/input/mouse_tracker.h ++++ b/src/citra_libretro/input/mouse_tracker.h +@@ -61,6 +61,7 @@ + private: + int x; + int y; ++ float mouseRemainderX = 0, mouseRemainderY = 0; + + float lastMouseX; + float lastMouseY; +--- a/src/video_core/renderer_vulkan/renderer_vulkan.cpp ++++ b/src/video_core/renderer_vulkan/renderer_vulkan.cpp +@@ -1087,28 +1087,15 @@ + const float br = (layout.bottom_screen.right / buf_w) * 2.0f - 1.0f; + const float bb = (layout.bottom_screen.bottom / buf_h) * 2.0f - 1.0f; + +- // Crosshair geometry clamped to bottom screen bounds +- const float vl = std::fmax(cx - rw / 5.0f, bl); +- const float vr = std::fmin(cx + rw / 5.0f, br); +- const float vt = std::fmax(cy - rh, bt); +- const float vb = std::fmin(cy + rh, bb); +- +- const float hl = std::fmax(cx - rw, bl); +- const float hr = std::fmin(cx + rw, br); +- const float ht = std::fmax(cy - rh / 5.0f, bt); +- const float hb = std::fmin(cy + rh / 5.0f, bb); +- +- // 12 vertices = 4 triangles (2 for vertical bar, 2 for horizontal bar) +- // clang-format off ++ // Stylus silhouette: the nib stays exactly at the touch coordinate. ++ // Use the existing inversion pipeline so it remains visible over the game. ++ const auto px = [&](float v) { return std::clamp(cx + v * rw / 4.0f, bl, br); }; ++ const auto py = [&](float v) { return std::clamp(cy + v * rh / 4.0f, bt, bb); }; + const float vertices[] = { +- // Vertical bar +- vl, vt, vr, vt, vr, vb, +- vl, vt, vr, vb, vl, vb, +- // Horizontal bar +- hl, ht, hr, ht, hr, hb, +- hl, ht, hr, hb, hl, hb, +- }; +- // clang-format on ++ px(0), py(0), px(1), py(4), px(4), py(1), // nib ++ px(2), py(5), px(5), py(2), px(12), py(9), // shaft ++ px(2), py(5), px(12), py(9), px(9), py(12), ++ }; + + const u64 size = sizeof(vertices); + auto [data, offset, invalidate] = vertex_buffer.Map(size, 16); +@@ -1119,7 +1106,7 @@ + cmdbuf.bindPipeline(vk::PipelineBindPoint::eGraphics, pipeline); + cmdbuf.bindVertexBuffers(0, vertex_buffer.Handle(), {0}); + const u32 first_vertex = static_cast(offset) / (sizeof(float) * 2); +- cmdbuf.draw(12, 1, first_vertex, 0); ++ cmdbuf.draw(9, 1, first_vertex, 0); + }); + } + diff --git a/tooling/desmume/touchpad-stylus.patch b/tooling/desmume/touchpad-stylus.patch new file mode 100644 index 0000000..af72995 --- /dev/null +++ b/tooling/desmume/touchpad-stylus.patch @@ -0,0 +1,122 @@ +--- a/desmume/src/frontend/libretro/libretro.cpp ++++ b/desmume/src/frontend/libretro/libretro.cpp +@@ -183,28 +183,29 @@ + static const uint32_t FramesWithPointerBase = 60 * 10; + static int32_t FramesWithPointer; + +-static void DrawPointerLine_32(uint32_t* aOut, uint32_t aPitchInPix) +-{ +- for(int i = 0; i < (5 * scale) ; i ++) +- aOut[aPitchInPix * i] = pointer_color_32; +-} +- +-static void DrawPointerLineSmall_32(uint32_t* aOut, uint32_t aPitchInPix, int factor) +-{ +- for(int i = 0; i < (factor * scale) ; i ++) +- aOut[aPitchInPix * i] = pointer_color_32; +-} +- +-static void DrawPointerLine(uint16_t* aOut, uint32_t aPitchInPix) +-{ +- for(int i = 0; i < (5 * scale) ; i ++) +- aOut[aPitchInPix * i] = pointer_colour; +-} +- +-static void DrawPointerLineSmall(uint16_t* aOut, uint32_t aPitchInPix, int factor) +-{ +- for(int i = 0; i < (factor * scale) ; i ++) +- aOut[aPitchInPix * i] = pointer_colour; ++// A pen with its nib at the touch coordinate. Clip every pixel, including ++// hybrid layouts and both framebuffer formats, so the cursor cannot bleed. ++static void DrawStylus(uint16_t* output, unsigned pitch, int width, int height, ++ int x, int y, int size) ++{ ++ static const char glyph[12][13] = { ++ "## ", "#.# ", " #.# ", " #.## ", ++ " #..# ", " #...# ", " #...# ", " #...# ", ++ " #...# ", " #...#", " #.# ", " # " ++ }; ++ for (int row = 0; row < 12 * size; ++row) ++ for (int col = 0; col < 12 * size; ++col) ++ { ++ char pixel = glyph[row / size][col / size]; ++ int px = x + col, py = y + row; ++ if (pixel == ' ' || px < 0 || py < 0 || px >= width || py >= height) ++ continue; ++ if (colorMode == RETRO_PIXEL_FORMAT_XRGB8888) ++ reinterpret_cast(output)[py * pitch + px] = ++ pixel == '#' ? (pointer_color_32 == 0 ? 0xffffff : 0) : pointer_color_32; ++ else ++ output[py * pitch + px] = pixel == '#' ? (pointer_colour == 0 ? 0xffff : 0) : pointer_colour; ++ } + } + + static void DrawPointer(uint16_t* aOut, uint32_t aPitchInPix) +@@ -215,21 +216,8 @@ + TouchX = Saturate(0, (GPU_LR_FRAMEBUFFER_NATIVE_WIDTH-1), TouchX); + TouchY = Saturate(0, (GPU_LR_FRAMEBUFFER_NATIVE_HEIGHT-1), TouchY); + +- if (colorMode != RETRO_PIXEL_FORMAT_XRGB8888) +- { +- if (TouchX > (5 * scale)) DrawPointerLine(&aOut[TouchY * aPitchInPix + TouchX - (5 * scale) ], 1); +- if (TouchX < (GPU_LR_FRAMEBUFFER_NATIVE_WIDTH - (5 * scale) )) DrawPointerLine(&aOut[TouchY * aPitchInPix + TouchX + 1], 1); +- if (TouchY > (5 * scale)) DrawPointerLine(&aOut[(TouchY - (5 * scale) ) * aPitchInPix + TouchX], aPitchInPix); +- if (TouchY < (GPU_LR_FRAMEBUFFER_NATIVE_HEIGHT-(5 * scale) )) DrawPointerLine(&aOut[(TouchY + 1) * aPitchInPix + TouchX], aPitchInPix); +- } +- else +- { +- uint32_t *aOut_32 = (uint32_t *) aOut; +- if (TouchX > (5 * scale)) DrawPointerLine_32(&aOut_32[TouchY * aPitchInPix + TouchX - (5 * scale) ], 1); +- if (TouchX < (GPU_LR_FRAMEBUFFER_NATIVE_WIDTH - (5 * scale) )) DrawPointerLine_32(&aOut_32[TouchY * aPitchInPix + TouchX + 1], 1); +- if (TouchY > (5 * scale)) DrawPointerLine_32(&aOut_32[(TouchY - (5 * scale) ) * aPitchInPix + TouchX], aPitchInPix); +- if (TouchY < (GPU_LR_FRAMEBUFFER_NATIVE_HEIGHT-(5 * scale) )) DrawPointerLine_32(&aOut_32[(TouchY + 1) * aPitchInPix + TouchX], aPitchInPix); +- } ++ DrawStylus(aOut, aPitchInPix, GPU_LR_FRAMEBUFFER_NATIVE_WIDTH, ++ GPU_LR_FRAMEBUFFER_NATIVE_HEIGHT, TouchX, TouchY, scale); + } + + static void DrawPointerHybrid(uint16_t* aOut, uint32_t aPitchInPix, bool large) +@@ -272,21 +260,8 @@ + else + factor = hybrid_layout_ratio; + +- if (colorMode != RETRO_PIXEL_FORMAT_XRGB8888) +- { +- if (DrawX > (factor * scale)) DrawPointerLineSmall(&aOut[DrawY * aPitchInPix + DrawX - (factor * scale) ], 1, factor); +- if (DrawX < (width - (factor * scale) )) DrawPointerLineSmall(&aOut[DrawY * aPitchInPix + DrawX + 1], 1, factor); +- if (DrawY > (factor * scale)) DrawPointerLineSmall(&aOut[(DrawY - (factor * scale) ) * aPitchInPix + DrawX], aPitchInPix, factor); +- if (DrawY < (height-(factor * scale) )) DrawPointerLineSmall(&aOut[(DrawY + 1) * aPitchInPix + DrawX], aPitchInPix, factor); +- } +- else +- { +- uint32_t *aOut_32 = (uint32_t *) aOut; +- if (DrawX > (factor * scale)) DrawPointerLineSmall_32(&aOut_32[DrawY * aPitchInPix + DrawX - (factor * scale) ], 1, factor); +- if (DrawX < (width - (factor * scale) )) DrawPointerLineSmall_32(&aOut_32[DrawY * aPitchInPix + DrawX + 1], 1, factor); +- if (DrawY > (factor * scale)) DrawPointerLineSmall_32(&aOut_32[(DrawY - (factor * scale) ) * aPitchInPix + DrawX], aPitchInPix, factor); +- if (DrawY < (height-(factor * scale) )) DrawPointerLineSmall_32(&aOut_32[(DrawY + 1) * aPitchInPix + DrawX], aPitchInPix, factor); +- } ++ DrawStylus(aOut, aPitchInPix, width, height, DrawX, DrawY, ++ std::max(1u, factor * scale / 5)); + } + + static bool NDS_3D_ChangeCore(int newCore) +@@ -1937,8 +1912,8 @@ + rotate_input(mouseX, mouseY, input_rotation); + have_touch = have_touch || input_cb(0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_LEFT); + +- mouse_x_delta += mouseX * mouse_speed; +- mouse_y_delta += mouseY * mouse_speed; ++ mouse_x_delta += mouseX * mouse_speed * GPU_LR_FRAMEBUFFER_NATIVE_WIDTH / 1920.0; ++ mouse_y_delta += mouseY * mouse_speed * GPU_LR_FRAMEBUFFER_NATIVE_HEIGHT / 1080.0; + + mouseX = (int16_t) trunc(mouse_x_delta); + mouse_x_delta -= mouseX; +@@ -1947,7 +1922,7 @@ + + TouchX = Saturate(0, (GPU_LR_FRAMEBUFFER_NATIVE_WIDTH-1), TouchX + mouseX); + TouchY = Saturate(0, (GPU_LR_FRAMEBUFFER_NATIVE_HEIGHT-1), TouchY + mouseY); +- FramesWithPointer = (mouseX || mouseY) ? FramesWithPointerBase : FramesWithPointer; ++ FramesWithPointer = (mouseX || mouseY || have_touch) ? FramesWithPointerBase : FramesWithPointer; + } + // TOUCH: Pointer + else if(input_cb(0, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_PRESSED)) diff --git a/tooling/notices/components.json b/tooling/notices/components.json index 5ecebf4..872db3a 100644 --- a/tooling/notices/components.json +++ b/tooling/notices/components.json @@ -336,7 +336,7 @@ "copyright": ["Copyright the DeSmuME team and contributors"], "texts": [{"from": ".deps/desmume-src/desmume/COPYING", "to": "COPYING"}], "source": {"kind": "core", "build": "desmume", "tree": ".deps/desmume-src", "remote": "https://github.com/mihawk-99/PS5_DeSmuME"}, - "modifications": "The fork's commits over libretro/desmume." + "modifications": "The fork's commits over libretro/desmume; tooling/desmume/touchpad-stylus.patch adds the PS5 touchpad scale and stylus cursor." }, { "id": "azahar", @@ -347,7 +347,7 @@ "copyright": ["Copyright the Citra Emulator Project / Azahar Emulator Project", "Copyright MerryMage and the Dynarmic contributors"], "texts": [{"from": ".deps/azahar-src/license.txt", "to": "license.txt"}, {"from": ".deps/azahar-src/externals/dynarmic/LICENSE.txt", "to": "dynarmic-LICENSE.txt"}], "source": {"kind": "core", "build": "azahar", "tree": ".deps/azahar-src", "remote": "https://github.com/mihawk-99/PS5_Azahar"}, - "modifications": "The fork's commits over azahar-emu/azahar; externals/dynarmic is mihawk-99/PS5_Dynarmic." + "modifications": "The fork's commits over azahar-emu/azahar; externals/dynarmic is mihawk-99/PS5_Dynarmic; tooling/azahar/touchpad-stylus.patch adds relative mouse hover and a stylus cursor." }, { "id": "flycast", @@ -759,6 +759,31 @@ "remote": "https://github.com/mihawk-99/PS5_RetroArch" }, "modifications": "Unmodified upstream C source vendored in third_party/qrcodegen; upstream URL, version and SHA-256 digests in source.json. Shared runtime WebUI QR wrapper in src/ps5_webui_qr.c." + }, + { + "id": "proton-touchpad", + "name": "PS5 Proton touchpad tracking (adapted)", + "kind": "code", + "always": true, + "artifacts": [ + "eboot.bin" + ], + "licence": "LGPL-2.1-or-later", + "copyright": [ + "Copyright the PS5 Proton contributors" + ], + "texts": [ + { + "from": "third_party/proton_touchpad/LICENSE", + "to": "LGPL-2.1.txt" + } + ], + "source": { + "kind": "git", + "path": ".", + "remote": "https://github.com/mihawk-99/PS5_RetroArch" + }, + "modifications": "Relative contact tracking adapted in src/input_ps5.cpp; original revision and files in third_party/proton_touchpad/source.json." } ] } diff --git a/tools/build-azahar.sh b/tools/build-azahar.sh index 2fe2b78..281a7f0 100644 --- a/tools/build-azahar.sh +++ b/tools/build-azahar.sh @@ -22,6 +22,7 @@ core_stamp_skip azahar \ revision=4aef900a1a903d0aa6ea86fdb1e18236fb0d5907 # ../PS5_Azahar main core_fork_setup core_fork_checkout PS5_Azahar "$revision" submodules +git -C "$source_dir" apply "$root/tooling/azahar/touchpad-stylus.patch" core_fork_info azahar_libretro.info c5bff8202e7ed32bce79ef0ab34dbeabde0637a298ef19a9e9c0ff5ea363aac3 # The libretro build turns off every frontend that cannot be part of a core @@ -42,4 +43,5 @@ cmake --build "$build" --target citra_libretro --parallel "${JOBS:-16}" built=$(find "$build" -name azahar_libretro.so -print -quit) [[ -n $built ]] || { echo "error: no azahar_libretro.so was produced" >&2; exit 2; } core_fork_stage "$built" "$core_info" "$revision" tools/build-azahar.sh \ - tooling/azahar/ps5-toolchain.cmake + tooling/azahar/ps5-toolchain.cmake \ + tooling/azahar/touchpad-stylus.patch diff --git a/tools/build-desmume.sh b/tools/build-desmume.sh index 9dfe265..9015306 100644 --- a/tools/build-desmume.sh +++ b/tools/build-desmume.sh @@ -17,15 +17,17 @@ source "$root/tools/core-fork.sh" core_stamp_skip desmume \ "$root/build/cores/stage/cores/desmume_libretro.so" \ "$root/build/cores/stage/info/desmume_libretro.info" \ - -- "$root/tools/build-desmume.sh" "$root/tools/core-fork.sh" + -- "$root/tools/build-desmume.sh" "$root/tools/core-fork.sh" "$root/tooling/desmume" [[ $# == 0 ]] || { echo "usage: ${0##*/}" >&2; exit 2; } revision=54540709d343bd93d021487af4408679ca187825 # ../PS5_DeSmuME main core_fork_setup core_fork_checkout PS5_DeSmuME "$revision" +git -C "$source_dir" apply "$root/tooling/desmume/touchpad-stylus.patch" core_fork_info desmume_libretro.info 82730a4bcd36df5631f1791f50a66f056075ef47b501c19258f703b73966101b # LDFLAGS goes in the environment: the makefiles add their own to it. LDFLAGS="$core_ldflags $core_libs" make -C "$source_dir/desmume/src/frontend/libretro" -f Makefile.libretro -j"${JOBS:-16}" platform=ps5 DESMUME_JIT=1 \ CC="$core_cc" CXX="$core_cxx" AR="$AR" -core_fork_stage "$source_dir/desmume/src/frontend/libretro/desmume_libretro.so" "$core_info" "$revision" tools/build-desmume.sh +core_fork_stage "$source_dir/desmume/src/frontend/libretro/desmume_libretro.so" "$core_info" "$revision" tools/build-desmume.sh \ + tooling/desmume/touchpad-stylus.patch