--- a/meson.build
+++ b/meson.build	2026-04-29 11:16:09.000000000 +0800
@@ -1039,9 +1039,6 @@
              dependency('wayland-cursor', version: '>= 1.21.0', required: get_option('wayland')),
              dependency('wayland-protocols', version: '>= 1.31', required: get_option('wayland')),
              dependency('xkbcommon', version: '>= 0.3.0', required: get_option('wayland'))],
-    'header': cc.has_header('linux/input-event-codes.h', required: get_option('wayland'),
-                            # Pass CFLAGS from a related package as a hint for non-Linux
-                            dependencies: dependency('wayland-client', required: get_option('wayland'))),
     'scanner': find_program('wayland-scanner', required: get_option('wayland')),
 }
 wayland_deps = true
@@ -1051,7 +1048,7 @@
         break
     endif
 endforeach
-features += {'wayland': wayland_deps and wayland['header'] and wayland['scanner'].found()}
+features += {'wayland': wayland_deps and wayland['scanner'].found()}
 
 if features['wayland']
     subdir(join_paths('video', 'out'))

--- a/video/out/wayland_common.c	2025-12-22 03:08:20.000000000 +0800
+++ b/video/out/wayland_common.c	2026-04-29 11:48:10.000000000 +0800
@@ -17,12 +17,17 @@
 
 #include <errno.h>
 #include <limits.h>
-#include <linux/input-event-codes.h>
 #include <poll.h>
 #include <time.h>
 #include <unistd.h>
 #include <wayland-cursor.h>
 #include <xkbcommon/xkbcommon.h>
+#ifdef __linux__
+#include <linux/input-event-codes.h>
+#else
+#include "input-event-codes.h"
+#include "osdep/pipe2.h"
+#endif
 
 #include "common/msg.h"
 #include "input/input.h"

--- a/player/clipboard/clipboard-wayland.c	2025-12-22 03:08:20.000000000 +0800
+++ b/player/clipboard/clipboard-wayland.c	2026-04-29 12:09:06.000000000 +0800
@@ -26,6 +26,9 @@
 #include "osdep/io.h"
 #include "osdep/poll_wrapper.h"
 #include "osdep/threads.h"
+#ifndef __linux__
+#include "osdep/pipe2.h"
+#endif
 
 static const uint8_t MESSAGE_DEATH = 0;
 static const uint8_t MESSAGE_CREATE_SOURCES = 1;

--- /dev/null	2026-04-29 08:35:52.000000000 +0800
+++ b/video/out/input-event-codes.h	2026-04-29 11:42:05.000000000 +0800
@@ -0,0 +1,150 @@
+/*
+ * Input event codes compatibility header for non-Linux systems
+ *
+ * On Linux, these come from <linux/input.h> or <linux/input-event-codes.h>
+ * On other systems, we provide the subset needed by Weston clients.
+ */
+
+#ifndef INPUT_EVENT_CODES_H
+#define INPUT_EVENT_CODES_H
+
+/* Event types */
+#define EV_SYN       0x00
+#define EV_KEY       0x01
+#define EV_REL       0x02
+#define EV_ABS       0x03
+
+/* Mouse buttons */
+#define BTN_MISC     0x100
+#define BTN_MOUSE    0x110
+#define BTN_LEFT     0x110
+#define BTN_RIGHT    0x111
+#define BTN_MIDDLE   0x112
+#define BTN_SIDE     0x113
+#define BTN_EXTRA    0x114
+#define BTN_FORWARD  0x115
+#define BTN_JOYSTICK 0x120
+
+#define BTN_STYLUS3  0x149
+#define BTN_TOUCH    0x14a
+#define BTN_STYLUS   0x14b
+#define BTN_STYLUS2  0x14c
+
+/* Keyboard keys - common subset */
+#define KEY_RESERVED         0
+#define KEY_ESC              1
+#define KEY_1                2
+#define KEY_2                3
+#define KEY_3                4
+#define KEY_4                5
+#define KEY_5                6
+#define KEY_6                7
+#define KEY_7                8
+#define KEY_8                9
+#define KEY_9                10
+#define KEY_0                11
+#define KEY_MINUS            12
+#define KEY_EQUAL            13
+#define KEY_BACKSPACE        14
+#define KEY_TAB              15
+#define KEY_Q                16
+#define KEY_W                17
+#define KEY_E                18
+#define KEY_R                19
+#define KEY_T                20
+#define KEY_Y                21
+#define KEY_U                22
+#define KEY_I                23
+#define KEY_O                24
+#define KEY_P                25
+#define KEY_LEFTBRACE        26
+#define KEY_RIGHTBRACE       27
+#define KEY_ENTER            28
+#define KEY_LEFTCTRL         29
+#define KEY_A                30
+#define KEY_S                31
+#define KEY_D                32
+#define KEY_F                33
+#define KEY_G                34
+#define KEY_H                35
+#define KEY_J                36
+#define KEY_K                37
+#define KEY_L                38
+#define KEY_SEMICOLON        39
+#define KEY_APOSTROPHE       40
+#define KEY_GRAVE            41
+#define KEY_LEFTSHIFT        42
+#define KEY_BACKSLASH        43
+#define KEY_Z                44
+#define KEY_X                45
+#define KEY_C                46
+#define KEY_V                47
+#define KEY_B                48
+#define KEY_N                49
+#define KEY_M                50
+#define KEY_COMMA            51
+#define KEY_DOT              52
+#define KEY_SLASH            53
+#define KEY_RIGHTSHIFT       54
+#define KEY_KPASTERISK       55
+#define KEY_LEFTALT          56
+#define KEY_SPACE            57
+#define KEY_CAPSLOCK         58
+#define KEY_F1               59
+#define KEY_F2               60
+#define KEY_F3               61
+#define KEY_F4               62
+#define KEY_F5               63
+#define KEY_F6               64
+#define KEY_F7               65
+#define KEY_F8               66
+#define KEY_F9               67
+#define KEY_F10              68
+#define KEY_NUMLOCK          69
+#define KEY_SCROLLLOCK       70
+#define KEY_KP7              71
+#define KEY_KP8              72
+#define KEY_KP9              73
+#define KEY_KPMINUS          74
+#define KEY_KP4              75
+#define KEY_KP5              76
+#define KEY_KP6              77
+#define KEY_KPPLUS           78
+#define KEY_KP1              79
+#define KEY_KP2              80
+#define KEY_KP3              81
+#define KEY_KP0              82
+#define KEY_KPDOT            83
+#define KEY_F11              87
+#define KEY_F12              88
+#define KEY_KPENTER          96
+#define KEY_RIGHTCTRL        97
+#define KEY_KPSLASH          98
+#define KEY_RIGHTALT         100
+#define KEY_HOME             102
+#define KEY_UP               103
+#define KEY_PAGEUP           104
+#define KEY_LEFT             105
+#define KEY_RIGHT            106
+#define KEY_END              107
+#define KEY_DOWN             108
+#define KEY_PAGEDOWN         109
+#define KEY_INSERT           110
+#define KEY_DELETE           111
+#define KEY_KPEQUAL          117
+#define KEY_PAUSE            119
+#define KEY_LEFTMETA         125
+#define KEY_RIGHTMETA        126
+#define KEY_COMPOSE          127
+
+/* Relative axes */
+#define REL_X        0x00
+#define REL_Y        0x01
+#define REL_WHEEL    0x08
+
+/* Absolute axes */
+#define ABS_X        0x00
+#define ABS_Y        0x01
+#define ABS_PRESSURE 0x18
+
+#endif /* INPUT_EVENT_CODES_H */

--- /dev/null	2026-04-29 08:35:52.000000000 +0800
+++ b/osdep/pipe2.h	2026-04-29 12:08:16.000000000 +0800
@@ -0,0 +1,35 @@
+/*
+ * This file is part of mpv.
+ *
+ * mpv 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.
+ *
+ * mpv 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 mpv.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <fcntl.h>
+#include <unistd.h>
+
+static inline int pipe2(int pipefd[2], int flags) {
+	int ret = pipe(pipefd);
+	if (ret == -1)
+		return -1;
+
+	if (flags & O_CLOEXEC) {
+		fcntl(pipefd[0], F_SETFD, FD_CLOEXEC);
+		fcntl(pipefd[1], F_SETFD, FD_CLOEXEC);
+	}
+	if (flags & O_NONBLOCK) {
+		fcntl(pipefd[0], F_SETFL, O_NONBLOCK);
+		fcntl(pipefd[1], F_SETFL, O_NONBLOCK);
+	}
+	return 0;
+}
