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)

This commit is contained in:
Olivier PARRA 2018-01-25 02:20:52 +01:00
parent 4dc6eb0ae4
commit 8bff69eae8
3 changed files with 34 additions and 8 deletions

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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",