Skip to content

Commit

Permalink
Updated The Android lib and hardware mappings for Joy-Cons
Browse files Browse the repository at this point in the history
Fixes #170 and #166
  • Loading branch information
AlexKhayrullin committed Jun 26, 2021
1 parent 2c4e9ae commit 7274089
Show file tree
Hide file tree
Showing 13 changed files with 245 additions and 177 deletions.
82 changes: 0 additions & 82 deletions SonicTimeTwisted.gmx/SonicTimeTwisted.project.gmx
Original file line number Diff line number Diff line change
Expand Up @@ -2158,88 +2158,6 @@
</ConfigOptions>
<filename>057e_2006_057e_2007_joy_con__l__joy_con__r_.csv</filename>
</datafile>
<datafile>
<name>057e_2006_joy_con__l_.csv</name>
<exists>-1</exists>
<size>652</size>
<exportAction>2</exportAction>
<exportDir></exportDir>
<overwrite>0</overwrite>
<freeData>-1</freeData>
<removeEnd>0</removeEnd>
<store>0</store>
<ConfigOptions>
<Config name="Default">
<CopyToMask>9223372036854775807</CopyToMask>
</Config>
<Config name="Windows">
<CopyToMask>2097160</CopyToMask>
</Config>
<Config name="AndroidSmartphone">
<CopyToMask>9223372036854775807</CopyToMask>
</Config>
<Config name="AndroidConsole">
<CopyToMask>9223372036854775807</CopyToMask>
</Config>
<Config name="MacOS">
<CopyToMask>9223372036854775807</CopyToMask>
</Config>
<Config name="iPhone">
<CopyToMask>9223372036854775807</CopyToMask>
</Config>
<Config name="AppleTV">
<CopyToMask>9223372036854775807</CopyToMask>
</Config>
<Config name="Linux">
<CopyToMask>2097160</CopyToMask>
</Config>
<Config name="PlayStation">
<CopyToMask>9223372036854775807</CopyToMask>
</Config>
</ConfigOptions>
<filename>057e_2006_joy_con__l_.csv</filename>
</datafile>
<datafile>
<name>057e_2007_joy_con__r_.csv</name>
<exists>-1</exists>
<size>652</size>
<exportAction>2</exportAction>
<exportDir></exportDir>
<overwrite>0</overwrite>
<freeData>-1</freeData>
<removeEnd>0</removeEnd>
<store>0</store>
<ConfigOptions>
<Config name="Default">
<CopyToMask>9223372036854775807</CopyToMask>
</Config>
<Config name="Windows">
<CopyToMask>2097160</CopyToMask>
</Config>
<Config name="AndroidSmartphone">
<CopyToMask>9223372036854775807</CopyToMask>
</Config>
<Config name="AndroidConsole">
<CopyToMask>9223372036854775807</CopyToMask>
</Config>
<Config name="MacOS">
<CopyToMask>9223372036854775807</CopyToMask>
</Config>
<Config name="iPhone">
<CopyToMask>9223372036854775807</CopyToMask>
</Config>
<Config name="AppleTV">
<CopyToMask>9223372036854775807</CopyToMask>
</Config>
<Config name="Linux">
<CopyToMask>2097160</CopyToMask>
</Config>
<Config name="PlayStation">
<CopyToMask>9223372036854775807</CopyToMask>
</Config>
</ConfigOptions>
<filename>057e_2007_joy_con__r_.csv</filename>
</datafile>
</datafiles>
</datafiles>
<datafile>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,101 @@
min_api,max_api,vendor,product,other_vendor,other_product,event_device,event_type,event_code,event_value,mapped_type,mapped_code,mapped_value,comment
,,057e,2006,057e,2007,0,axis,15,-1,axis,1,-1,"Joy-Con (L)/Joy-Con (R), Left Stick UP"
,,,,,,,,15,1,,1,1,Left Stick DOWN
,,,,,,,,16,1,,0,-1,Left Stick LEFT
,,,,,,,,16,-1,,0,1,Left Stick RIGHT
,,,,,,,button,98,,,16,-1,D-Pad UP
,,,,,,,,97,,,16,1,D-Pad DOWN
,,,,,,,,96,,,15,-1,D-Pad LEFT
,,,,,,,,99,,,15,1,D-Pad RIGHT
,,,,,,1,axis,15,1,,14,-1,Right Stick UP
,,,,,,,,15,-1,,14,1,Right Stick DOWN
,,,,,,,,16,-1,,11,-1,Right Stick LEFT
,,,,,,,,16,1,,11,1,Right Stick RIGHT
,,,,,,,button,98,,button,96,,Cross/A/Bottom button
,,,,,,,,96,,,97,,Circle/B/Right button
,,,,,,,,99,,,99,,Square/X/Left button
,,,,,,,,97,,,100,,Triangle/Y/Top button
,,,,,,,,105,,,108,,Start button
,,,,,,0,,104,,,109,,Select button
,,,,,,,,107,,,102,,L1 button
,,,,,,1,,107,,,103,,R1 button
,,,,,,0,,0,,,104,,L2 button
,,,,,,1,,0,,,105,,R2 button
,,,,,,0,,109,,,106,,Left stick press
,,,,,,1,,108,,,107,,Right stick press
,29,057e,2006,,,,,,,,,,Left Joy-Con
,,,,,,,button,96,,button,96,,down key is A
,,,,,,,,97,,,97,,right key is B
,,,,,,,,98,,,99,,left key is X
,,,,,,,,99,,,100,,right key is Y
,,,,,,,,100,,,102,,SL is L1
,,,,,,,,101,,,103,,SR is R1
,,,,,,,,104,,,108,,Minus is START
,,,,,,,,106,,,109,,Screenshot is SELECT
,,,,,,,,107,,,104,,L is L2
,,,,,,,,0,,,105,,ZL is R2
,,,,,,,,109,,,110,,Thumbstick press is MODE
,,,,,,,axis,15,,axis,15,,Hat X axis works as intended out-of-the-box
,,,,,,,,16,,,16,,Hat Y axis works as intended out-of-the-box
,29,057e,2007,,,,,,,,,,Right Joy-Con
,,,,,,,button,96,,button,96,,down key is A
,,,,,,,,97,,,97,,right key is B
,,,,,,,,98,,,99,,left key is X
,,,,,,,,99,,,100,,right key is Y
,,,,,,,,100,,,102,,SL is L1
,,,,,,,,101,,,103,,SR is R1
,,,,,,,,105,,,108,,Minus is START
,,,,,,,,110,,,109,,Home is SELECT
,,,,,,,,107,,,104,,R is L2
,,,,,,,,0,,,105,,ZR is R2
,,,,,,,,108,,,110,,Thumbstick press is MODE
,,,,,,,axis,15,,axis,15,,Hat X axis works as intended out-of-the-box
,,,,,,,,16,,,16,,Hat Y axis works as intended out-of-the-box
,29,057e,2006,057e,2007,,,,,,,,Joy-Cons for Android 10-
,,,,,,0,button,98,,axis,16,-1,UP is Hat Y -1
,,,,,,,,97,,,16,1,DOWN is Hat Y +1
,,,,,,,,96,,,15,-1,LEFT is Hat X -1
,,,,,,,,99,,,15,1,RIGHT is Hat X +1
,,,,,,,,107,,button,102,,L is L1
,,,,,,,,0,,,104,,ZL is L2
,,,,,,,,109,,,106,,Left Thumbstick is L3
,,,,,,,,104,,,109,,Minus is SELECT
,,,,,,,,106,,,110,,Screenshot is Mode
,,,,,,,,100,,,188,,SL is Generic 1
,,,,,,,,101,,,189,,SR is Generic 2
,,,,,,,axis,15,-1,axis,1,-1,Joy-Con's X axis is combined gamepad's Y axis
,,,,,,,,15,1,,1,1,
,,,,,,,,16,1,,0,-1,"Joy-Con's Y axis is combined gamepad's X axis, inverted"
,,,,,,,,16,-1,,0,1,
,,,,,,1,button,98,,button,96,,B is A
,,,,,,,,96,,,97,,A is B
,,,,,,,,99,,,99,,Y is X
,,,,,,,,97,,,100,,X is Y
,,,,,,,,105,,,108,,Plus is START
,,,,,,,,107,,,103,,R is R1
,,,,,,,,0,,,105,,ZR is R2
,,,,,,,,108,,,107,,Right Thumbstick is R3
,,,,,,,,101,,,190,,SR is Generic 3
,,,,,,,,100,,,191,,SL is Generic 4
,,,,,,,axis,16,-1,axis,11,-1,Joy-Con's Y axis is combined gamepad's Z axis
,,,,,,,,16,1,,11,1,
,,,,,,,,15,1,,14,-1,"Joy-Con's X axis is combined gamepad's RZ axis, inverted"
,,,,,,,,15,-1,,14,1,
30,,057e,2006,057e,2007,,,,,,,,"Joy-Cons for Android 11+ are pre-mapped, but the D-Pad doesn't work"
,,,,,,0,,102,,button,102,,
,,,,,,,,104,,,104,,
,,,,,,,,106,,,106,,
,,,,,,,,109,,,109,,
,,,,,,,,110,,,110,,
,,,,,,,,101,,,101,,
,,,,,,,axis,1,-1,axis,1,-1,
,,,,,,,,1,1,,1,1,
,,,,,,,,0,-1,,0,-1,
,,,,,,,,0,1,,0,1,
,,,,,,1,button,96,,button,96,,
,,,,,,,,97,,,97,,
,,,,,,,,99,,,100,,
,,,,,,,,100,,,99,,
,,,,,,,,108,,,108,,
,,,,,,,,103,,,103,,
,,,,,,,,105,,,105,,
,,,,,,,,107,,,107,,
,,,,,,,,190,,,190,,
,,,,,,,,191,,,191,,
,,,,,,,axis,12,-1,axis,12,-1,
,,,,,,,,12,1,,12,1,
,,,,,,,,13,-1,,13,-1,
,,,,,,,,13,1,,13,1,
,,,,,,,,110,,,110,,
30,,057e,2007,,,,,,,,,,Right Joy-Con (just switching two buttons around for consistency's sake)
,,,,,,,button,96,,button,96,,
,,,,,,,,97,,,97,,
,,,,,,,,99,,,100,,
,,,,,,,,100,,,99,,
,,,,,,,,108,,,108,,
,,,,,,,,103,,,103,,
,,,,,,,,105,,,105,,
,,,,,,,,107,,,107,,
,,,,,,,,190,,,190,,
,,,,,,,,191,,,191,,
,,,,,,,axis,12,-1,axis,12,-1,
,,,,,,,,12,1,,12,1,
,,,,,,,,13,-1,,13,-1,
,,,,,,,,13,1,,13,1,
,,,,,,,,110,,,110,,

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -1271,7 +1271,15 @@ protected boolean processKeyEventAnyKeyOn(KeyEvent event) {
);
return true;
} else {
return false;
if (!hardwareMappings.containsValue(eventInt)) {
this.setPressState(
eventInt, 0,
event.getAction() == KeyEvent.ACTION_DOWN
);
return true;
} else {
return false;
}
}
}

Expand Down Expand Up @@ -1432,14 +1440,23 @@ public void updateSoftwareMappings(
* @param softwareMappings A map of software mapping entries
*/
protected void updateSoftwareMappingsFromMap(Map<Integer, Integer> softwareMappings) {
boolean hwKeyFound;
for (Entry<Integer, Integer> entry : softwareMappings.entrySet()) {
int inputCode = entry.getValue();
int keyCode = entry.getKey();
hwKeyFound = false;
for (Entry<Integer, Integer> hwEntry : hardwareMappings.entrySet()) {
if (hwEntry.getValue() == inputCode) {
directMappings.put(hwEntry.getKey(), keyCode);
hwKeyFound = true;
break;
}
if (!hwKeyFound) {
hwKeyFound = inputCode == hwEntry.getKey() || inputCode == hwEntry.getValue();
}
}
if(!hwKeyFound) {
directMappings.put(inputCode, keyCode);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ if(objProgram.inputManager.device_label == "")
var dd_state = real(android_double_device_detecting_mode_get_state());
if(dd_state == 0)
{
var currentDeviceLabel = string(android_get_device_label(0, -1));
var currentDeviceLabel = string(android_get_device_label(0, 30));
if(currentDeviceLabel != "")
{
objProgram.inputManager.device_label = currentDeviceLabel;
Expand Down
21 changes: 12 additions & 9 deletions SonicTimeTwisted.gmx/scripts/menu_part_android_btusb_items.gml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@ if(android_get_input_mode())
//menu_fn_add_option(tr("_btusb_joymap_Rumble"), 0, 1, "< " + tr("_Off") + " >");
// codes below 31 are used for mapping
menu_fn_add_option(tr("_btusb_joymap_Device"), 31);
menu_fn_add_option(tr("_options_menu_Remap_all"), 1);
menu_fn_add_option(tr("_buttonname_Up"), 2, 1, "");
menu_fn_add_option(tr("_buttonname_Down"), 3, 1, "");
menu_fn_add_option(tr("_buttonname_Left"), 4, 1, "");
menu_fn_add_option(tr("_buttonname_Right"), 5, 1, "");
menu_fn_add_option(tr("_buttonname_A"), 6, 1, "");
menu_fn_add_option(tr("_buttonname_B"), 7, 1, "");
menu_fn_add_option(tr("_buttonname_C"), 8, 1, "");
menu_fn_add_option(tr("_buttonname_Start"), 9, 1, "");
if (string_length(objProgram.inputManager.device_label) > 0)
{
menu_fn_add_option(tr("_options_menu_Remap_all"), 1);
menu_fn_add_option(tr("_buttonname_Up"), 2, 1, "");
menu_fn_add_option(tr("_buttonname_Down"), 3, 1, "");
menu_fn_add_option(tr("_buttonname_Left"), 4, 1, "");
menu_fn_add_option(tr("_buttonname_Right"), 5, 1, "");
menu_fn_add_option(tr("_buttonname_A"), 6, 1, "");
menu_fn_add_option(tr("_buttonname_B"), 7, 1, "");
menu_fn_add_option(tr("_buttonname_C"), 8, 1, "");
menu_fn_add_option(tr("_buttonname_Start"), 9, 1, "");
}
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ min_api,max_api,vendor,product,other_vendor,other_product,event_device,event_typ
,,,,,,,,108,,,110,,Thumbstick press is MODE
,,,,,,,axis,15,,axis,15,,Hat X axis works as intended out-of-the-box
,,,,,,,,16,,,16,,Hat Y axis works as intended out-of-the-box
,29,057e,2006,057e,2007,,,,,,,,Joy-Cons
,29,057e,2006,057e,2007,,,,,,,,Joy-Cons for Android 10-
,,,,,,0,button,98,,axis,16,-1,UP is Hat Y -1
,,,,,,,,97,,,16,1,DOWN is Hat Y +1
,,,,,,,,96,,,15,-1,LEFT is Hat X -1
Expand Down Expand Up @@ -57,3 +57,45 @@ min_api,max_api,vendor,product,other_vendor,other_product,event_device,event_typ
,,,,,,,,16,1,,11,1,
,,,,,,,,15,1,,14,-1,"Joy-Con's X axis is combined gamepad's RZ axis, inverted"
,,,,,,,,15,-1,,14,1,
30,,057e,2006,057e,2007,,,,,,,,"Joy-Cons for Android 11+ are pre-mapped, but the D-Pad doesn't work"
,,,,,,0,,102,,button,102,,
,,,,,,,,104,,,104,,
,,,,,,,,106,,,106,,
,,,,,,,,109,,,109,,
,,,,,,,,110,,,110,,
,,,,,,,,101,,,101,,
,,,,,,,axis,1,-1,axis,1,-1,
,,,,,,,,1,1,,1,1,
,,,,,,,,0,-1,,0,-1,
,,,,,,,,0,1,,0,1,
,,,,,,1,button,96,,button,96,,
,,,,,,,,97,,,97,,
,,,,,,,,99,,,100,,
,,,,,,,,100,,,99,,
,,,,,,,,108,,,108,,
,,,,,,,,103,,,103,,
,,,,,,,,105,,,105,,
,,,,,,,,107,,,107,,
,,,,,,,,190,,,190,,
,,,,,,,,191,,,191,,
,,,,,,,axis,12,-1,axis,12,-1,
,,,,,,,,12,1,,12,1,
,,,,,,,,13,-1,,13,-1,
,,,,,,,,13,1,,13,1,
,,,,,,,,110,,,110,,
30,,057e,2007,,,,,,,,,,Right Joy-Con (just switching two buttons around for consistency's sake)
,,,,,,,button,96,,button,96,,
,,,,,,,,97,,,97,,
,,,,,,,,99,,,100,,
,,,,,,,,100,,,99,,
,,,,,,,,108,,,108,,
,,,,,,,,103,,,103,,
,,,,,,,,105,,,105,,
,,,,,,,,107,,,107,,
,,,,,,,,190,,,190,,
,,,,,,,,191,,,191,,
,,,,,,,axis,12,-1,axis,12,-1,
,,,,,,,,12,1,,12,1,
,,,,,,,,13,-1,,13,-1,
,,,,,,,,13,1,,13,1,
,,,,,,,,110,,,110,,
Loading

0 comments on commit 7274089

Please sign in to comment.