.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * Device Modules for Nintendo Wii / Wii U HID Driver |
---|
3 | 4 | * Copyright (c) 2011-2013 David Herrmann <dh.herrmann@gmail.com> |
---|
4 | 5 | */ |
---|
5 | 6 | |
---|
6 | 7 | /* |
---|
7 | | - * This program is free software; you can redistribute it and/or modify it |
---|
8 | | - * under the terms of the GNU General Public License as published by the Free |
---|
9 | | - * Software Foundation; either version 2 of the License, or (at your option) |
---|
10 | | - * any later version. |
---|
11 | 8 | */ |
---|
12 | 9 | |
---|
13 | 10 | /* |
---|
.. | .. |
---|
1091 | 1088 | * is the same as before. |
---|
1092 | 1089 | */ |
---|
1093 | 1090 | |
---|
| 1091 | + static const s8 digital_to_analog[3] = {0x20, 0, -0x20}; |
---|
| 1092 | + |
---|
1094 | 1093 | if (wdata->state.flags & WIIPROTO_FLAG_MP_ACTIVE) { |
---|
1095 | | - lx = ext[0] & 0x3e; |
---|
1096 | | - ly = ext[1] & 0x3e; |
---|
| 1094 | + if (wiimote_dpad_as_analog) { |
---|
| 1095 | + lx = digital_to_analog[1 - !(ext[4] & 0x80) |
---|
| 1096 | + + !(ext[1] & 0x01)]; |
---|
| 1097 | + ly = digital_to_analog[1 - !(ext[4] & 0x40) |
---|
| 1098 | + + !(ext[0] & 0x01)]; |
---|
| 1099 | + } else { |
---|
| 1100 | + lx = (ext[0] & 0x3e) - 0x20; |
---|
| 1101 | + ly = (ext[1] & 0x3e) - 0x20; |
---|
| 1102 | + } |
---|
1097 | 1103 | } else { |
---|
1098 | | - lx = ext[0] & 0x3f; |
---|
1099 | | - ly = ext[1] & 0x3f; |
---|
| 1104 | + if (wiimote_dpad_as_analog) { |
---|
| 1105 | + lx = digital_to_analog[1 - !(ext[4] & 0x80) |
---|
| 1106 | + + !(ext[5] & 0x02)]; |
---|
| 1107 | + ly = digital_to_analog[1 - !(ext[4] & 0x40) |
---|
| 1108 | + + !(ext[5] & 0x01)]; |
---|
| 1109 | + } else { |
---|
| 1110 | + lx = (ext[0] & 0x3f) - 0x20; |
---|
| 1111 | + ly = (ext[1] & 0x3f) - 0x20; |
---|
| 1112 | + } |
---|
1100 | 1113 | } |
---|
1101 | 1114 | |
---|
1102 | 1115 | rx = (ext[0] >> 3) & 0x18; |
---|
.. | .. |
---|
1113 | 1126 | rt <<= 1; |
---|
1114 | 1127 | lt <<= 1; |
---|
1115 | 1128 | |
---|
1116 | | - input_report_abs(wdata->extension.input, ABS_HAT1X, lx - 0x20); |
---|
1117 | | - input_report_abs(wdata->extension.input, ABS_HAT1Y, ly - 0x20); |
---|
| 1129 | + input_report_abs(wdata->extension.input, ABS_HAT1X, lx); |
---|
| 1130 | + input_report_abs(wdata->extension.input, ABS_HAT1Y, ly); |
---|
1118 | 1131 | input_report_abs(wdata->extension.input, ABS_HAT2X, rx - 0x20); |
---|
1119 | 1132 | input_report_abs(wdata->extension.input, ABS_HAT2Y, ry - 0x20); |
---|
1120 | 1133 | input_report_abs(wdata->extension.input, ABS_HAT3X, rt); |
---|
1121 | 1134 | input_report_abs(wdata->extension.input, ABS_HAT3Y, lt); |
---|
1122 | 1135 | |
---|
1123 | | - input_report_key(wdata->extension.input, |
---|
1124 | | - wiimod_classic_map[WIIMOD_CLASSIC_KEY_RIGHT], |
---|
1125 | | - !(ext[4] & 0x80)); |
---|
1126 | | - input_report_key(wdata->extension.input, |
---|
1127 | | - wiimod_classic_map[WIIMOD_CLASSIC_KEY_DOWN], |
---|
1128 | | - !(ext[4] & 0x40)); |
---|
1129 | 1136 | input_report_key(wdata->extension.input, |
---|
1130 | 1137 | wiimod_classic_map[WIIMOD_CLASSIC_KEY_LT], |
---|
1131 | 1138 | !(ext[4] & 0x20)); |
---|
.. | .. |
---|
1160 | 1167 | wiimod_classic_map[WIIMOD_CLASSIC_KEY_ZR], |
---|
1161 | 1168 | !(ext[5] & 0x04)); |
---|
1162 | 1169 | |
---|
1163 | | - if (wdata->state.flags & WIIPROTO_FLAG_MP_ACTIVE) { |
---|
| 1170 | + if (!wiimote_dpad_as_analog) { |
---|
1164 | 1171 | input_report_key(wdata->extension.input, |
---|
1165 | | - wiimod_classic_map[WIIMOD_CLASSIC_KEY_LEFT], |
---|
1166 | | - !(ext[1] & 0x01)); |
---|
| 1172 | + wiimod_classic_map[WIIMOD_CLASSIC_KEY_RIGHT], |
---|
| 1173 | + !(ext[4] & 0x80)); |
---|
1167 | 1174 | input_report_key(wdata->extension.input, |
---|
1168 | | - wiimod_classic_map[WIIMOD_CLASSIC_KEY_UP], |
---|
1169 | | - !(ext[0] & 0x01)); |
---|
1170 | | - } else { |
---|
1171 | | - input_report_key(wdata->extension.input, |
---|
1172 | | - wiimod_classic_map[WIIMOD_CLASSIC_KEY_LEFT], |
---|
1173 | | - !(ext[5] & 0x02)); |
---|
1174 | | - input_report_key(wdata->extension.input, |
---|
1175 | | - wiimod_classic_map[WIIMOD_CLASSIC_KEY_UP], |
---|
1176 | | - !(ext[5] & 0x01)); |
---|
| 1175 | + wiimod_classic_map[WIIMOD_CLASSIC_KEY_DOWN], |
---|
| 1176 | + !(ext[4] & 0x40)); |
---|
| 1177 | + |
---|
| 1178 | + if (wdata->state.flags & WIIPROTO_FLAG_MP_ACTIVE) { |
---|
| 1179 | + input_report_key(wdata->extension.input, |
---|
| 1180 | + wiimod_classic_map[WIIMOD_CLASSIC_KEY_LEFT], |
---|
| 1181 | + !(ext[1] & 0x01)); |
---|
| 1182 | + input_report_key(wdata->extension.input, |
---|
| 1183 | + wiimod_classic_map[WIIMOD_CLASSIC_KEY_UP], |
---|
| 1184 | + !(ext[0] & 0x01)); |
---|
| 1185 | + } else { |
---|
| 1186 | + input_report_key(wdata->extension.input, |
---|
| 1187 | + wiimod_classic_map[WIIMOD_CLASSIC_KEY_LEFT], |
---|
| 1188 | + !(ext[5] & 0x02)); |
---|
| 1189 | + input_report_key(wdata->extension.input, |
---|
| 1190 | + wiimod_classic_map[WIIMOD_CLASSIC_KEY_UP], |
---|
| 1191 | + !(ext[5] & 0x01)); |
---|
| 1192 | + } |
---|
1177 | 1193 | } |
---|
1178 | 1194 | |
---|
1179 | 1195 | input_sync(wdata->extension.input); |
---|