From 3f93ec470a6306475172118975857e7432654fed Mon Sep 17 00:00:00 2001
From: Brad Smith <[EMAIL REDACTED]>
Date: Fri, 26 Aug 2022 20:52:56 -0400
Subject: [PATCH] Add support for OpenBSD's ujoy(4)
---
src/joystick/bsd/SDL_bsdjoystick.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/joystick/bsd/SDL_bsdjoystick.c b/src/joystick/bsd/SDL_bsdjoystick.c
index 71e99d7d9db..43a4ef56762 100644
--- a/src/joystick/bsd/SDL_bsdjoystick.c
+++ b/src/joystick/bsd/SDL_bsdjoystick.c
@@ -23,7 +23,7 @@
#ifdef SDL_JOYSTICK_USBHID
/*
- * Joystick driver for the uhid(4) interface found in OpenBSD,
+ * Joystick driver for the uhid(4) / ujoy(4) interface found in OpenBSD,
* NetBSD and FreeBSD.
*
* Maintainer: <vedge at csoft.org>
@@ -226,7 +226,11 @@ BSD_JoystickInit(void)
for (i = 0; i < MAX_UHID_JOYS; i++) {
SDL_Joystick nj;
- SDL_snprintf(s, SDL_arraysize(s), "/dev/uhid%d", i);
+#if defined(__OpenBSD__) && (OpenBSD >= 202105)
+ SDL_snprintf(s, SDL_arraysize(s), "/dev/ujoy/%d", i);
+#else
+ SDL_snprintf(s, SDL_arraysize(s), "/dev/uhid/%d", i);
+#endif
joynames[numjoysticks] = SDL_strdup(s);