From 2d297b2d3702d24662819016b57f0a67d902990d Mon Sep 17 00:00:00 2001
From: Jonathan Schleifer <js@nil.im>
Date: Sun, 23 Mar 2025 15:14:57 +0000
Subject: [PATCH] Improve check for GameController.framework

FossilOrigin-Name: 75f164f64bc9d9712a8b78967f6b2c0b9977db4a60ac7fda12d66f562011928c
---
 configure.ac                              | 18 +++++++++++++++++-
 src/hid/OHDualSenseGamepad+Private.h      |  4 ++--
 src/hid/OHDualSenseGamepad.m              |  8 ++++----
 src/hid/OHDualShock4Gamepad+Private.h     |  4 ++--
 src/hid/OHDualShock4Gamepad.m             |  8 ++++----
 src/hid/OHExtendedN64Controller+Private.h |  4 ++--
 src/hid/OHExtendedN64Controller.m         |  8 ++++----
 src/hid/OHGameController.m                |  4 ++--
 src/hid/OHJoyConPair+Private.h            |  4 ++--
 src/hid/OHJoyConPair.m                    | 14 +++++++-------
 src/hid/OHLeftJoyCon+Private.h            |  4 ++--
 src/hid/OHLeftJoyCon.m                    | 10 +++++-----
 src/hid/OHN64Controller.m                 |  4 ++--
 src/hid/OHNESGamepad+Private.h            |  4 ++--
 src/hid/OHNESGamepad.m                    |  8 ++++----
 src/hid/OHRightJoyCon+Private.h           |  4 ++--
 src/hid/OHRightJoyCon.m                   | 10 +++++-----
 src/hid/OHSNESGamepad+Private.h           |  4 ++--
 src/hid/OHSNESGamepad.m                   |  8 ++++----
 src/hid/OHStadiaGamepad+Private.h         |  4 ++--
 src/hid/OHStadiaGamepad.m                 | 10 +++++-----
 src/hid/OHSwitchProController+Private.h   |  4 ++--
 src/hid/OHSwitchProController.m           |  8 ++++----
 23 files changed, 87 insertions(+), 71 deletions(-)

diff --git a/configure.ac b/configure.ac
index 6bf5abe89..4d6794f3a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2485,13 +2485,29 @@ mingw*)
 	AC_SUBST(USE_SRCS_XINPUT, '${SRCS_XINPUT}')
 	;;
 darwin*)
-	AC_CHECK_HEADERS(GameController/GameController.h, [
+	AC_MSG_CHECKING(new enough GameController.framework)
+	AC_COMPILE_IFELSE([
+		AC_LANG_PROGRAM([
+			#import <GameController/GameController.h>
+		], [
+			if (@available(macOS 14.0, iOS 17.0, *)) {
+				GCController *controller =
+				    GCController.controllers[[0]];
+				(void)controller.input;
+			}
+		])
+	], [
+		AC_MSG_RESULT(yes)
 		AC_SUBST(USE_SRCS_GCF, '${SRCS_GCF}')
+		AC_DEFINE(OF_HAVE_GCF, 1,
+			[Whether we have GameController.framework])
 		tmp="-framework GameController"
 		HID_STATIC_LIBS="$tmp \${libdir}/libobjfwbridge.a $HID_LIBS"
 		HID_LIBS="$tmp -lobjfwbridge $HID_LIBS"
 		tmp="$tmp -framework ObjFWBridge"
 		HID_FRAMEWORK_LIBS="$tmp $HID_FRAMEWORK_LIBS"
+	], [
+		AC_MSG_RESULT(no)
 	])
 	;;
 esac
diff --git a/src/hid/OHDualSenseGamepad+Private.h b/src/hid/OHDualSenseGamepad+Private.h
index 5ae1f2bec..4e19e289f 100644
--- a/src/hid/OHDualSenseGamepad+Private.h
+++ b/src/hid/OHDualSenseGamepad+Private.h
@@ -22,7 +22,7 @@
 #if defined(OF_LINUX) && defined(OF_HAVE_FILES)
 # import "OHEvdevGameController.h"
 #endif
-#ifdef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifdef OF_HAVE_GCF
 # import "OHGCFGameController.h"
 #endif
 
@@ -33,7 +33,7 @@ OF_DIRECT_MEMBERS
 #if defined(OF_LINUX) && defined(OF_HAVE_FILES)
     <OHEvdevMapping>
 #endif
-#ifdef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifdef OF_HAVE_GCF
     <OHGCFMapping>
 #endif
 
diff --git a/src/hid/OHDualSenseGamepad.m b/src/hid/OHDualSenseGamepad.m
index b7709951a..52c3586e0 100644
--- a/src/hid/OHDualSenseGamepad.m
+++ b/src/hid/OHDualSenseGamepad.m
@@ -22,7 +22,7 @@
 #import "OHDualSenseGamepad.h"
 #import "OHDualSenseGamepad+Private.h"
 #import "OFDictionary.h"
-#ifdef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifdef OF_HAVE_GCF
 # import "OFString+NSObject.h"
 #endif
 #import "OHEmulatedGameControllerTriggerButton.h"
@@ -44,7 +44,7 @@
 };
 static const size_t numButtons = sizeof(buttonNames) / sizeof(*buttonNames);
 
-#ifdef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifdef OF_HAVE_GCF
 static OFDictionary<OFString *, NSString *> *buttonsMap;
 static OFDictionary<OFString *, NSString *> *directionalPadsMap;
 #endif
@@ -52,7 +52,7 @@
 @implementation OHDualSenseGamepad
 @synthesize buttons = _buttons, directionalPads = _directionalPads;
 
-#ifdef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifdef OF_HAVE_GCF
 + (void)initialize
 {
 	void *pool;
@@ -363,7 +363,7 @@ - (OHGameControllerAxis *)oh_axisForEvdevAxis: (uint16_t)axis
 }
 #endif
 
-#ifdef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifdef OF_HAVE_GCF
 - (OFDictionary<OFString *, NSString *> *)oh_buttonsMap
 {
 	return buttonsMap;
diff --git a/src/hid/OHDualShock4Gamepad+Private.h b/src/hid/OHDualShock4Gamepad+Private.h
index ed5183523..42d3ea0dc 100644
--- a/src/hid/OHDualShock4Gamepad+Private.h
+++ b/src/hid/OHDualShock4Gamepad+Private.h
@@ -22,7 +22,7 @@
 #if defined(OF_LINUX) && defined(OF_HAVE_FILES)
 # import "OHEvdevGameController.h"
 #endif
-#ifdef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifdef OF_HAVE_GCF
 # import "OHGCFGameController.h"
 #endif
 
@@ -33,7 +33,7 @@ OF_DIRECT_MEMBERS
 #if defined(OF_LINUX) && defined(OF_HAVE_FILES)
     <OHEvdevMapping>
 #endif
-#ifdef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifdef OF_HAVE_GCF
     <OHGCFMapping>
 #endif
 
diff --git a/src/hid/OHDualShock4Gamepad.m b/src/hid/OHDualShock4Gamepad.m
index 9e3840523..21c474946 100644
--- a/src/hid/OHDualShock4Gamepad.m
+++ b/src/hid/OHDualShock4Gamepad.m
@@ -22,7 +22,7 @@
 #import "OHDualShock4Gamepad.h"
 #import "OHDualShock4Gamepad+Private.h"
 #import "OFDictionary.h"
-#ifdef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifdef OF_HAVE_GCF
 # import "OFString+NSObject.h"
 #endif
 #import "OHEmulatedGameControllerTriggerButton.h"
@@ -44,7 +44,7 @@
 };
 static const size_t numButtons = sizeof(buttonNames) / sizeof(*buttonNames);
 
-#ifdef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifdef OF_HAVE_GCF
 static OFDictionary<OFString *, NSString *> *buttonsMap;
 static OFDictionary<OFString *, NSString *> *directionalPadsMap;
 #endif
@@ -52,7 +52,7 @@
 @implementation OHDualShock4Gamepad
 @synthesize buttons = _buttons, directionalPads = _directionalPads;
 
-#ifdef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifdef OF_HAVE_GCF
 + (void)initialize
 {
 	void *pool;
@@ -363,7 +363,7 @@ - (OHGameControllerAxis *)oh_axisForEvdevAxis: (uint16_t)axis
 }
 #endif
 
-#ifdef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifdef OF_HAVE_GCF
 - (OFDictionary<OFString *, NSString *> *)oh_buttonsMap
 {
 	return buttonsMap;
diff --git a/src/hid/OHExtendedN64Controller+Private.h b/src/hid/OHExtendedN64Controller+Private.h
index d98e32f78..41c1f5ceb 100644
--- a/src/hid/OHExtendedN64Controller+Private.h
+++ b/src/hid/OHExtendedN64Controller+Private.h
@@ -19,7 +19,7 @@
 
 #import "OHExtendedN64Controller.h"
 
-#ifdef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifdef OF_HAVE_GCF
 # import "OHGCFGameController.h"
 #endif
 
@@ -27,7 +27,7 @@ OF_ASSUME_NONNULL_BEGIN
 
 OF_DIRECT_MEMBERS
 @interface OHExtendedN64Controller ()
-#ifdef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifdef OF_HAVE_GCF
     <OHGCFMapping>
 #endif
 @end
diff --git a/src/hid/OHExtendedN64Controller.m b/src/hid/OHExtendedN64Controller.m
index 25816954b..77f48e7d9 100644
--- a/src/hid/OHExtendedN64Controller.m
+++ b/src/hid/OHExtendedN64Controller.m
@@ -23,7 +23,7 @@
 #import "OHN64Controller.h"
 #import "OHN64Controller+Private.h"
 #import "OFDictionary.h"
-#ifdef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifdef OF_HAVE_GCF
 # import "OFString+NSObject.h"
 #endif
 #import "OHGameControllerButton.h"
@@ -39,13 +39,13 @@
 };
 static const size_t numButtons = sizeof(buttonNames) / sizeof(*buttonNames);
 
-#ifdef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifdef OF_HAVE_GCF
 static OFDictionary<OFString *, NSString *> *buttonsMap;
 static OFDictionary<OFString *, NSString *> *directionalPadsMap;
 #endif
 
 @implementation OHExtendedN64Controller
-#ifdef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifdef OF_HAVE_GCF
 + (void)initialize
 {
 	void *pool;
@@ -120,7 +120,7 @@ - (OHGameControllerButton *)oh_buttonForEvdevButton: (uint16_t)button
 }
 #endif
 
-#ifdef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifdef OF_HAVE_GCF
 - (OFDictionary<OFString *, NSString *> *)oh_buttonsMap
 {
 	return buttonsMap;
diff --git a/src/hid/OHGameController.m b/src/hid/OHGameController.m
index afd6a0248..b872d1d97 100644
--- a/src/hid/OHGameController.m
+++ b/src/hid/OHGameController.m
@@ -42,7 +42,7 @@
 #ifdef OF_NINTENDO_SWITCH
 # import "OHNintendoSwitchGameController.h"
 #endif
-#ifdef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifdef OF_HAVE_GCF
 # import "OHGCFGameController.h"
 #endif
 
@@ -81,7 +81,7 @@ @implementation OHGameController
 	return [OHWiiGameController controllers];
 #elif defined(OF_NINTENDO_SWITCH)
 	return [OHNintendoSwitchGameController controllers];
-#elif defined(HAVE_GAMECONTROLLER_GAMECONTROLLER_H)
+#elif defined(OF_HAVE_GCF)
 	if (@available(macOS 14.0, iOS 17.0, *))
 		return [OHGCFGameController controllers];
 	else
diff --git a/src/hid/OHJoyConPair+Private.h b/src/hid/OHJoyConPair+Private.h
index 6c3ca8a89..871799415 100644
--- a/src/hid/OHJoyConPair+Private.h
+++ b/src/hid/OHJoyConPair+Private.h
@@ -19,7 +19,7 @@
 
 #import "OHJoyConPair.h"
 
-#ifdef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifdef OF_HAVE_GCF
 # import "OHGCFGameController.h"
 #endif
 
@@ -27,7 +27,7 @@ OF_ASSUME_NONNULL_BEGIN
 
 OF_DIRECT_MEMBERS
 @interface OHJoyConPair ()
-#ifdef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifdef OF_HAVE_GCF
     <OHGCFMapping>
 #endif
 
diff --git a/src/hid/OHJoyConPair.m b/src/hid/OHJoyConPair.m
index 3f6012792..696c4eff8 100644
--- a/src/hid/OHJoyConPair.m
+++ b/src/hid/OHJoyConPair.m
@@ -24,7 +24,7 @@
 #import "OFDictionary.h"
 #import "OFNotification.h"
 #import "OFNotificationCenter.h"
-#ifdef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifdef OF_HAVE_GCF
 # import "OFString+NSObject.h"
 #endif
 #import "OHGameController.h"
@@ -51,13 +51,13 @@ - (void)oh_rightJoyConDirectionalPadValueDidChange:
 	@"A", @"B", @"X", @"Y", @"L", @"R", @"ZL", @"ZR", @"Left Thumbstick",
 	@"Right Thumbstick", @"+", @"-",
 	/* GameController.framework doesn't expose a lot of buttons. */
-#ifndef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifndef OF_HAVE_GCF
 	@"Home", @"Capture",
 #endif
 };
 static const size_t numButtons = sizeof(buttonNames) / sizeof(*buttonNames);
 
-#ifdef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifdef OF_HAVE_GCF
 static OFDictionary<OFString *, NSString *> *buttonsMap;
 static OFDictionary<OFString *, NSString *> *directionalPadsMap;
 #endif
@@ -171,7 +171,7 @@ OFDictionary OF_GENERIC(OFString *, OHGameControllerDirectionalPad *)
 @implementation OHJoyConPair
 @synthesize buttons = _buttons, directionalPads = _directionalPads;
 
-#ifdef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifdef OF_HAVE_GCF
 + (void)initialize
 {
 	void *pool;
@@ -228,7 +228,7 @@ - (instancetype)oh_init
 		OFMutableDictionary *directionalPads;
 		OHGameControllerAxis *xAxis, *yAxis;
 		OHGameControllerDirectionalPad *directionalPad;
-#ifndef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifndef OF_HAVE_GCF
 		OHGameControllerButton *up, *down, *left, *right;
 #endif
 
@@ -272,7 +272,7 @@ - (instancetype)oh_init
 		[directionalPads setObject: directionalPad
 				    forKey: @"Right Thumbstick"];
 
-#ifdef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifdef OF_HAVE_GCF
 		xAxis = [OHGameControllerAxis oh_elementWithName: @"D-Pad X"
 							  analog: false];
 		yAxis = [OHGameControllerAxis oh_elementWithName: @"D-Pad Y"
@@ -517,7 +517,7 @@ - (OHGameControllerDirectionalPad *)dPad
 	return [_directionalPads objectForKey: @"D-Pad"];
 }
 
-#ifdef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifdef OF_HAVE_GCF
 - (OFDictionary<OFString *, NSString *> *)oh_buttonsMap
 {
 	return buttonsMap;
diff --git a/src/hid/OHLeftJoyCon+Private.h b/src/hid/OHLeftJoyCon+Private.h
index 158e7635c..775aadecf 100644
--- a/src/hid/OHLeftJoyCon+Private.h
+++ b/src/hid/OHLeftJoyCon+Private.h
@@ -22,7 +22,7 @@
 #if defined(OF_LINUX) && defined(OF_HAVE_FILES)
 # import "OHEvdevGameController.h"
 #endif
-#ifdef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifdef OF_HAVE_GCF
 # import "OHGCFGameController.h"
 #endif
 
@@ -33,7 +33,7 @@ OF_DIRECT_MEMBERS
 #if defined(OF_LINUX) && defined(OF_HAVE_FILES)
     <OHEvdevMapping>
 #endif
-#ifdef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifdef OF_HAVE_GCF
     <OHGCFMapping>
 #endif
 
diff --git a/src/hid/OHLeftJoyCon.m b/src/hid/OHLeftJoyCon.m
index d56353bbc..d11423c24 100644
--- a/src/hid/OHLeftJoyCon.m
+++ b/src/hid/OHLeftJoyCon.m
@@ -22,7 +22,7 @@
 #import "OHLeftJoyCon.h"
 #import "OHLeftJoyCon+Private.h"
 #import "OFDictionary.h"
-#ifdef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifdef OF_HAVE_GCF
 # import "OFString+NSObject.h"
 #endif
 #import "OHGameControllerAxis.h"
@@ -40,14 +40,14 @@
 
 static OFString *const buttonNames[] = {
 	@"North", @"South", @"West", @"East", @"SL", @"SR", @"-",
-#ifndef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifndef OF_HAVE_GCF
 	/* GameController.framework doesn't expose a lot of buttons. */
 	@"L", @"ZL", @"Left Thumbstick", @"Capture"
 #endif
 };
 static const size_t numButtons = sizeof(buttonNames) / sizeof(*buttonNames);
 
-#ifdef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifdef OF_HAVE_GCF
 static OFDictionary<OFString *, NSString *> *buttonsMap;
 static OFDictionary<OFString *, NSString *> *directionalPadsMap;
 #endif
@@ -55,7 +55,7 @@
 @implementation OHLeftJoyCon
 @synthesize buttons = _buttons, directionalPads = _directionalPads;
 
-#ifdef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifdef OF_HAVE_GCF
 + (void)initialize
 {
 	void *pool;
@@ -193,7 +193,7 @@ - (OHGameControllerAxis *)oh_axisForEvdevAxis: (uint16_t)axis
 }
 #endif
 
-#ifdef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifdef OF_HAVE_GCF
 - (OFDictionary<OFString *, NSString *> *)oh_buttonsMap
 {
 	return buttonsMap;
diff --git a/src/hid/OHN64Controller.m b/src/hid/OHN64Controller.m
index 114bdb5d9..4301f5cbc 100644
--- a/src/hid/OHN64Controller.m
+++ b/src/hid/OHN64Controller.m
@@ -57,7 +57,7 @@ - (instancetype)oh_init
 		OFMutableDictionary *directionalPads;
 		OHGameControllerAxis *xAxis, *yAxis;
 		OHGameControllerDirectionalPad *directionalPad;
-#ifndef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifndef OF_HAVE_GCF
 		OHGameControllerButton *up, *down, *left, *right;
 #endif
 
@@ -98,7 +98,7 @@ - (instancetype)oh_init
 			    analog: false];
 		[directionalPads setObject: directionalPad forKey: @"D-Pad"];
 
-#ifdef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifdef OF_HAVE_GCF
 		xAxis = [OHGameControllerAxis oh_elementWithName: @"C-Buttons X"
 							  analog: false];
 		yAxis = [OHGameControllerAxis oh_elementWithName: @"C-Buttons Y"
diff --git a/src/hid/OHNESGamepad+Private.h b/src/hid/OHNESGamepad+Private.h
index 4de2871db..52ce2e16e 100644
--- a/src/hid/OHNESGamepad+Private.h
+++ b/src/hid/OHNESGamepad+Private.h
@@ -22,7 +22,7 @@
 #if defined(OF_LINUX) && defined(OF_HAVE_FILES)
 # import "OHEvdevGameController.h"
 #endif
-#ifdef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifdef OF_HAVE_GCF
 # import "OHGCFGameController.h"
 #endif
 
@@ -33,7 +33,7 @@ OF_DIRECT_MEMBERS
 #if defined(OF_LINUX) && defined(OF_HAVE_FILES)
     <OHEvdevMapping>
 #endif
-#ifdef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifdef OF_HAVE_GCF
     <OHGCFMapping>
 #endif
 
diff --git a/src/hid/OHNESGamepad.m b/src/hid/OHNESGamepad.m
index adc9121d6..804243812 100644
--- a/src/hid/OHNESGamepad.m
+++ b/src/hid/OHNESGamepad.m
@@ -22,7 +22,7 @@
 #import "OHNESGamepad.h"
 #import "OHNESGamepad+Private.h"
 #import "OFDictionary.h"
-#ifdef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifdef OF_HAVE_GCF
 # import "OFString+NSObject.h"
 #endif
 #import "OHEmulatedGameControllerTriggerButton.h"
@@ -43,7 +43,7 @@
 };
 static const size_t numButtons = sizeof(buttonNames) / sizeof(*buttonNames);
 
-#ifdef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifdef OF_HAVE_GCF
 static OFDictionary<OFString *, NSString *> *buttonsMap;
 static OFDictionary<OFString *, NSString *> *directionalPadsMap;
 #endif
@@ -51,7 +51,7 @@
 @implementation OHNESGamepad
 @synthesize buttons = _buttons, directionalPads = _directionalPads;
 
-#ifdef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifdef OF_HAVE_GCF
 + (void)initialize
 {
 	void *pool;
@@ -245,7 +245,7 @@ - (OHGameControllerAxis *)oh_axisForEvdevAxis: (uint16_t)axis
 }
 #endif
 
-#ifdef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifdef OF_HAVE_GCF
 - (OFDictionary<OFString *, NSString *> *)oh_buttonsMap
 {
 	return buttonsMap;
diff --git a/src/hid/OHRightJoyCon+Private.h b/src/hid/OHRightJoyCon+Private.h
index d1e67dec6..e9e43e44f 100644
--- a/src/hid/OHRightJoyCon+Private.h
+++ b/src/hid/OHRightJoyCon+Private.h
@@ -22,7 +22,7 @@
 #if defined(OF_LINUX) && defined(OF_HAVE_FILES)
 # import "OHEvdevGameController.h"
 #endif
-#ifdef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifdef OF_HAVE_GCF
 # import "OHGCFGameController.h"
 #endif
 
@@ -33,7 +33,7 @@ OF_DIRECT_MEMBERS
 #if defined(OF_LINUX) && defined(OF_HAVE_FILES)
     <OHEvdevMapping>
 #endif
-#ifdef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifdef OF_HAVE_GCF
     <OHGCFMapping>
 #endif
 
diff --git a/src/hid/OHRightJoyCon.m b/src/hid/OHRightJoyCon.m
index daaff6628..27921a06c 100644
--- a/src/hid/OHRightJoyCon.m
+++ b/src/hid/OHRightJoyCon.m
@@ -22,7 +22,7 @@
 #import "OHRightJoyCon.h"
 #import "OHRightJoyCon+Private.h"
 #import "OFDictionary.h"
-#ifdef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifdef OF_HAVE_GCF
 # import "OFString+NSObject.h"
 #endif
 #import "OHGameControllerAxis.h"
@@ -40,14 +40,14 @@
 
 static OFString *const buttonNames[] = {
 	@"X", @"B", @"A", @"Y", @"SL", @"SR", @"+",
-#ifndef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifndef OF_HAVE_GCF
 	/* GameController.framework doesn't expose a lot of buttons. */
 	@"R", @"ZR", @"Left Thumbstick", @"Home"
 #endif
 };
 static const size_t numButtons = sizeof(buttonNames) / sizeof(*buttonNames);
 
-#ifdef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifdef OF_HAVE_GCF
 static OFDictionary<OFString *, NSString *> *buttonsMap;
 static OFDictionary<OFString *, NSString *> *directionalPadsMap;
 #endif
@@ -55,7 +55,7 @@
 @implementation OHRightJoyCon
 @synthesize buttons = _buttons, directionalPads = _directionalPads;
 
-#ifdef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifdef OF_HAVE_GCF
 + (void)initialize
 {
 	void *pool;
@@ -209,7 +209,7 @@ - (OHGameControllerAxis *)oh_axisForEvdevAxis: (uint16_t)axis
 }
 #endif
 
-#ifdef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifdef OF_HAVE_GCF
 - (OFDictionary<OFString *, NSString *> *)oh_buttonsMap
 {
 	return buttonsMap;
diff --git a/src/hid/OHSNESGamepad+Private.h b/src/hid/OHSNESGamepad+Private.h
index 0aab8c840..a4d1f639d 100644
--- a/src/hid/OHSNESGamepad+Private.h
+++ b/src/hid/OHSNESGamepad+Private.h
@@ -22,7 +22,7 @@
 #if defined(OF_LINUX) && defined(OF_HAVE_FILES)
 # import "OHEvdevGameController.h"
 #endif
-#ifdef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifdef OF_HAVE_GCF
 # import "OHGCFGameController.h"
 #endif
 
@@ -32,7 +32,7 @@ OF_ASSUME_NONNULL_BEGIN
 #if defined(OF_LINUX) && defined(OF_HAVE_FILES)
     <OHEvdevMapping>
 #endif
-#ifdef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifdef OF_HAVE_GCF
     <OHGCFMapping>
 #endif
 
diff --git a/src/hid/OHSNESGamepad.m b/src/hid/OHSNESGamepad.m
index bdeba90fa..e8dba49a9 100644
--- a/src/hid/OHSNESGamepad.m
+++ b/src/hid/OHSNESGamepad.m
@@ -22,7 +22,7 @@
 #import "OHSNESGamepad.h"
 #import "OHSNESGamepad+Private.h"
 #import "OFDictionary.h"
-#ifdef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifdef OF_HAVE_GCF
 # import "OFString+NSObject.h"
 #endif
 #import "OHGameControllerAxis.h"
@@ -41,7 +41,7 @@
 };
 static const size_t numButtons = sizeof(buttonNames) / sizeof(*buttonNames);
 
-#ifdef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifdef OF_HAVE_GCF
 static OFDictionary<OFString *, NSString *> *buttonsMap;
 static OFDictionary<OFString *, NSString *> *directionalPadsMap;
 #endif
@@ -49,7 +49,7 @@
 @implementation OHSNESGamepad
 @synthesize buttons = _buttons, directionalPads = _directionalPads;
 
-#ifdef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifdef OF_HAVE_GCF
 + (void)initialize
 {
 	void *pool;
@@ -232,7 +232,7 @@ - (OHGameControllerAxis *)oh_axisForEvdevAxis: (uint16_t)axis
 }
 #endif
 
-#ifdef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifdef OF_HAVE_GCF
 - (OFDictionary<OFString *, NSString *> *)oh_buttonsMap
 {
 	return buttonsMap;
diff --git a/src/hid/OHStadiaGamepad+Private.h b/src/hid/OHStadiaGamepad+Private.h
index 00967ca6f..3497b3543 100644
--- a/src/hid/OHStadiaGamepad+Private.h
+++ b/src/hid/OHStadiaGamepad+Private.h
@@ -22,7 +22,7 @@
 #if defined(OF_LINUX) && defined(OF_HAVE_FILES)
 # import "OHEvdevGameController.h"
 #endif
-#ifdef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifdef OF_HAVE_GCF
 # import "OHGCFGameController.h"
 #endif
 
@@ -33,7 +33,7 @@ OF_DIRECT_MEMBERS
 #if defined(OF_LINUX) && defined(OF_HAVE_FILES)
     <OHEvdevMapping>
 #endif
-#ifdef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifdef OF_HAVE_GCF
     <OHGCFMapping>
 #endif
 
diff --git a/src/hid/OHStadiaGamepad.m b/src/hid/OHStadiaGamepad.m
index cda11fab2..d9087d950 100644
--- a/src/hid/OHStadiaGamepad.m
+++ b/src/hid/OHStadiaGamepad.m
@@ -22,7 +22,7 @@
 #import "OHStadiaGamepad.h"
 #import "OHStadiaGamepad+Private.h"
 #import "OFDictionary.h"
-#ifdef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifdef OF_HAVE_GCF
 # import "OFString+NSObject.h"
 #endif
 #import "OHEmulatedGameControllerTriggerButton.h"
@@ -40,14 +40,14 @@
 static OFString *const buttonNames[] = {
 	@"A", @"B", @"X", @"Y", @"L1", @"R1", @"L3", @"R3", @"Menu", @"Options",
 	@"Capture", @"Stadia",
-#ifndef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifndef OF_HAVE_GCF
 	/* Not supported by GameController.framework */
 	@"Assistant"
 #endif
 };
 static const size_t numButtons = sizeof(buttonNames) / sizeof(*buttonNames);
 
-#ifdef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifdef OF_HAVE_GCF
 static OFDictionary<OFString *, NSString *> *buttonsMap;
 static OFDictionary<OFString *, NSString *> *directionalPadsMap;
 #endif
@@ -55,7 +55,7 @@
 @implementation OHStadiaGamepad
 @synthesize buttons = _buttons, directionalPads = _directionalPads;
 
-#ifdef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifdef OF_HAVE_GCF
 + (void)initialize
 {
 	void *pool;
@@ -372,7 +372,7 @@ - (OHGameControllerAxis *)oh_axisForEvdevAxis: (uint16_t)axis
 }
 #endif
 
-#ifdef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifdef OF_HAVE_GCF
 - (OFDictionary<OFString *, NSString *> *)oh_buttonsMap
 {
 	return buttonsMap;
diff --git a/src/hid/OHSwitchProController+Private.h b/src/hid/OHSwitchProController+Private.h
index a65c0d3e3..fc52263b2 100644
--- a/src/hid/OHSwitchProController+Private.h
+++ b/src/hid/OHSwitchProController+Private.h
@@ -22,7 +22,7 @@
 #if defined(OF_LINUX) && defined(OF_HAVE_FILES)
 # import "OHEvdevGameController.h"
 #endif
-#ifdef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifdef OF_HAVE_GCF
 # import "OHGCFGameController.h"
 #endif
 
@@ -33,7 +33,7 @@ OF_DIRECT_MEMBERS
 #if defined(OF_LINUX) && defined(OF_HAVE_FILES)
     <OHEvdevMapping>
 #endif
-#ifdef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifdef OF_HAVE_GCF
     <OHGCFMapping>
 #endif
 
diff --git a/src/hid/OHSwitchProController.m b/src/hid/OHSwitchProController.m
index 0fdac0146..7d0f21f09 100644
--- a/src/hid/OHSwitchProController.m
+++ b/src/hid/OHSwitchProController.m
@@ -22,7 +22,7 @@
 #import "OHSwitchProController.h"
 #import "OHSwitchProController+Private.h"
 #import "OFDictionary.h"
-#ifdef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifdef OF_HAVE_GCF
 # import "OFString+NSObject.h"
 #endif
 #import "OHGameControllerAxis.h"
@@ -43,7 +43,7 @@
 };
 static const size_t numButtons = sizeof(buttonNames) / sizeof(*buttonNames);
 
-#ifdef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifdef OF_HAVE_GCF
 static OFDictionary<OFString *, NSString *> *buttonsMap;
 static OFDictionary<OFString *, NSString *> *directionalPadsMap;
 #endif
@@ -51,7 +51,7 @@
 @implementation OHSwitchProController
 @synthesize buttons = _buttons, directionalPads = _directionalPads;
 
-#ifdef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifdef OF_HAVE_GCF
 + (void)initialize
 {
 	void *pool;
@@ -341,7 +341,7 @@ - (OHGameControllerAxis *)oh_axisForEvdevAxis: (uint16_t)axis
 }
 #endif
 
-#ifdef HAVE_GAMECONTROLLER_GAMECONTROLLER_H
+#ifdef OF_HAVE_GCF
 - (OFDictionary<OFString *, NSString *> *)oh_buttonsMap
 {
 	return buttonsMap;
