From 930dccc4307cae741ed36619e643944e27603d43 Mon Sep 17 00:00:00 2001 From: Relintai Date: Sun, 12 Mar 2023 15:32:44 +0100 Subject: [PATCH] Ported: iOS: Implement missing gamepad.buttonOptions, buttonMenu, and buttonHome joy buttons. - BZ1234567890 https://github.com/godotengine/godot/commit/0a85e4db7183898d57fc783d9481011cef279eb0 --- platform/iphone/joypad_iphone.mm | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/platform/iphone/joypad_iphone.mm b/platform/iphone/joypad_iphone.mm index 6acc25767..420bbbb37 100644 --- a/platform/iphone/joypad_iphone.mm +++ b/platform/iphone/joypad_iphone.mm @@ -32,9 +32,9 @@ #include "core/config/project_settings.h" #include "drivers/coreaudio/audio_driver_coreaudio.h" -#import "pandemonium_view.h" #include "main/main.h" #include "os_iphone.h" +#import "pandemonium_view.h" JoypadIPhone::JoypadIPhone() { observer = [[JoypadIPhoneObserver alloc] init]; @@ -309,6 +309,20 @@ void JoypadIPhone::start_processing() { float value = gamepad.rightTrigger.value; OSIPhone::get_singleton()->joy_axis(joy_id, JOY_ANALOG_R2, value); } + + if (@available(iOS 13, *)) { + if (element == gamepad.buttonOptions) { + OSIPhone::get_singleton()->joy_button(joy_id, JOY_BUTTON_10, gamepad.buttonOptions.isPressed); + } else if (element == gamepad.buttonMenu) { + OSIPhone::get_singleton()->joy_button(joy_id, JOY_BUTTON_11, gamepad.buttonMenu.isPressed); + } + } + + if (@available(iOS 14, *)) { + if (element == gamepad.buttonHome) { + OSIPhone::get_singleton()->joy_button(joy_id, JOY_GUIDE, gamepad.buttonHome.isPressed); + } + } }; } else if (controller.microGamepad != nil) { // micro gamepads were added in OS 9 and feature just 2 buttons and a d-pad