From 8bff69eae898d55d94dc38f038292e7ee72fb9f7 Mon Sep 17 00:00:00 2001 From: Olivier PARRA Date: Thu, 25 Jan 2018 02:20:52 +0100 Subject: [PATCH] 1.[IOS9]Remove HID entry from menu as IOKIT is not available 2.[OSX]Add robustness and determinism to HID buttons detection code (add controller buttons in a sorted list) --- configuration.c | 5 ++++ input/drivers_hid/iohidmanager_hid.c | 28 +++++++++++++++++-- .../RetroArch_iOS9.xcodeproj/project.pbxproj | 9 ++---- 3 files changed, 34 insertions(+), 8 deletions(-) diff --git a/configuration.c b/configuration.c index 2249f1bab3..dc1b167bc2 100644 --- a/configuration.c +++ b/configuration.c @@ -228,6 +228,7 @@ enum joypad_driver_enum JOYPAD_HID, JOYPAD_QNX, JOYPAD_RWEBPAD, + JOYPAD_MFI, JOYPAD_NULL }; @@ -460,6 +461,8 @@ static enum joypad_driver_enum JOYPAD_DEFAULT_DRIVER = JOYPAD_HID; static enum joypad_driver_enum JOYPAD_DEFAULT_DRIVER = JOYPAD_QNX; #elif defined(EMSCRIPTEN) static enum joypad_driver_enum JOYPAD_DEFAULT_DRIVER = JOYPAD_RWEBPAD; +#elif defined(IOS) +static enum joypad_driver_enum JOYPAD_DEFAULT_DRIVER = JOYPAD_MFI; #else static enum joypad_driver_enum JOYPAD_DEFAULT_DRIVER = JOYPAD_NULL; #endif @@ -863,6 +866,8 @@ const char *config_get_default_joypad(void) return "rwebpad"; case JOYPAD_DOS: return "dos"; + case JOYPAD_MFI: + return "mfi"; case JOYPAD_NULL: break; } diff --git a/input/drivers_hid/iohidmanager_hid.c b/input/drivers_hid/iohidmanager_hid.c index c2c215ec80..9ad99ebe2f 100644 --- a/input/drivers_hid/iohidmanager_hid.c +++ b/input/drivers_hid/iohidmanager_hid.c @@ -1,6 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2013-2014 - Jason Fetters * Copyright (C) 2011-2017 - Daniel De Matteis + * Courtesy Contributor - Olivier Parra * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- @@ -94,6 +95,29 @@ static void iohidmanager_append_record(apple_input_rec_t *rec, apple_input_rec_t tmp->next = b; } +/* Insert a new detected button into a button ordered list. + * Button list example with Nimbus Controller: + * +-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+ + * "id" list member | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 144 | 145 | 146 | 147 | 547 | + * Final Button ID | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | + * +-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+ + * Ranges |< X/Y/A/B/L1/L2/R1/R2 buttons >|< D-PAD >|MENU | + * In that way, HID button IDs allocation: + * - becomes robust and determinist + * - remains compatible with previous algorithm (i.e. btn->id = (uint32_t)(use - 1)) and so + * compatible with previous autoconfig files. + */ +static void iohidmanager_append_record_ordered(apple_input_rec_t **p_rec, apple_input_rec_t *b) +{ + apple_input_rec_t *tmp = *p_rec; + while(tmp && (tmp->id <= b->id)) { + p_rec = &tmp->next; + tmp = tmp->next; + } + b->next = tmp; + *p_rec = b; +} + static bool iohidmanager_hid_joypad_query(void *data, unsigned pad) { return pad < MAX_USERS; @@ -662,14 +686,14 @@ static void iohidmanager_hid_device_add(void *data, IOReturn result, if(iohidmanager_check_for_id(adapter->buttons,btn->id)) { if(tmpButtons) - iohidmanager_append_record(tmpButtons, btn); + iohidmanager_append_record_ordered(&tmpButtons, btn); else tmpButtons = btn; } else { if(adapter->buttons) - iohidmanager_append_record(adapter->buttons, btn); + iohidmanager_append_record_ordered(&adapter->buttons, btn); else adapter->buttons = btn; } diff --git a/pkg/apple/RetroArch_iOS9.xcodeproj/project.pbxproj b/pkg/apple/RetroArch_iOS9.xcodeproj/project.pbxproj index 20a3b8cefc..30534c7f2e 100644 --- a/pkg/apple/RetroArch_iOS9.xcodeproj/project.pbxproj +++ b/pkg/apple/RetroArch_iOS9.xcodeproj/project.pbxproj @@ -251,7 +251,7 @@ ORGANIZATIONNAME = RetroArch; TargetAttributes = { 0FDA2A701BE1AFA800F2B5DA = { - DevelopmentTeam = UK699V5ZS8; + DevelopmentTeam = 38QVPJE4NW; }; }; }; @@ -341,7 +341,7 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_RESOURCE_RULES_PATH = "$(SDKROOT)/ResourceRules.plist"; - DEVELOPMENT_TEAM = UK699V5ZS8; + DEVELOPMENT_TEAM = 38QVPJE4NW; ENABLE_BITCODE = NO; GCC_PRECOMPILE_PREFIX_HEADER = NO; GCC_PREFIX_HEADER = ""; @@ -360,7 +360,6 @@ OTHER_CFLAGS = ( "-DHAVE_NETWORKGAMEPAD", "-DHAVE_CORETEXT", - "-DHAVE_HID", "-DHAVE_NETWORKING", "-DHAVE_AVFOUNDATION", "-DHAVE_GRIFFIN", @@ -424,7 +423,7 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_RESOURCE_RULES_PATH = "$(SDKROOT)/ResourceRules.plist"; - DEVELOPMENT_TEAM = UK699V5ZS8; + DEVELOPMENT_TEAM = 38QVPJE4NW; ENABLE_BITCODE = NO; GCC_PRECOMPILE_PREFIX_HEADER = NO; GCC_PREFIX_HEADER = ""; @@ -444,7 +443,6 @@ "-DNDEBUG", "-DHAVE_NETWORKGAMEPAD", "-DHAVE_CORETEXT", - "-DHAVE_HID", "-DHAVE_NETWORKING", "-DHAVE_AVFOUNDATION", "-DHAVE_GRIFFIN", @@ -495,7 +493,6 @@ "-DNDEBUG", "-DHAVE_NETWORKGAMEPAD", "-DHAVE_CORETEXT", - "-DHAVE_HID", "-DHAVE_NETWORKING", "-DHAVE_AVFOUNDATION", "-DHAVE_GRIFFIN",