@@ -1088,12 +1088,28 @@ static void wiimod_classic_in_ext(struct wiimote_data *wdata, const __u8 *ext)
1088
1088
* is the same as before.
1089
1089
*/
1090
1090
1091
+ static const s8 digital_to_analog [3 ] = {0x20 , 0 , -0x20 };
1092
+
1091
1093
if (wdata -> state .flags & WIIPROTO_FLAG_MP_ACTIVE ) {
1092
- lx = ext [0 ] & 0x3e ;
1093
- 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
+ }
1094
1103
} else {
1095
- lx = ext [0 ] & 0x3f ;
1096
- 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
+ }
1097
1113
}
1098
1114
1099
1115
rx = (ext [0 ] >> 3 ) & 0x18 ;
@@ -1110,19 +1126,13 @@ static void wiimod_classic_in_ext(struct wiimote_data *wdata, const __u8 *ext)
1110
1126
rt <<= 1 ;
1111
1127
lt <<= 1 ;
1112
1128
1113
- input_report_abs (wdata -> extension .input , ABS_HAT1X , lx - 0x20 );
1114
- 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 );
1115
1131
input_report_abs (wdata -> extension .input , ABS_HAT2X , rx - 0x20 );
1116
1132
input_report_abs (wdata -> extension .input , ABS_HAT2Y , ry - 0x20 );
1117
1133
input_report_abs (wdata -> extension .input , ABS_HAT3X , rt );
1118
1134
input_report_abs (wdata -> extension .input , ABS_HAT3Y , lt );
1119
1135
1120
- input_report_key (wdata -> extension .input ,
1121
- wiimod_classic_map [WIIMOD_CLASSIC_KEY_RIGHT ],
1122
- !(ext [4 ] & 0x80 ));
1123
- input_report_key (wdata -> extension .input ,
1124
- wiimod_classic_map [WIIMOD_CLASSIC_KEY_DOWN ],
1125
- !(ext [4 ] & 0x40 ));
1126
1136
input_report_key (wdata -> extension .input ,
1127
1137
wiimod_classic_map [WIIMOD_CLASSIC_KEY_LT ],
1128
1138
!(ext [4 ] & 0x20 ));
@@ -1157,20 +1167,29 @@ static void wiimod_classic_in_ext(struct wiimote_data *wdata, const __u8 *ext)
1157
1167
wiimod_classic_map [WIIMOD_CLASSIC_KEY_ZR ],
1158
1168
!(ext [5 ] & 0x04 ));
1159
1169
1160
- if (wdata -> state .flags & WIIPROTO_FLAG_MP_ACTIVE ) {
1161
- input_report_key (wdata -> extension .input ,
1162
- wiimod_classic_map [WIIMOD_CLASSIC_KEY_LEFT ],
1163
- !(ext [1 ] & 0x01 ));
1164
- input_report_key (wdata -> extension .input ,
1165
- wiimod_classic_map [WIIMOD_CLASSIC_KEY_UP ],
1166
- !(ext [0 ] & 0x01 ));
1167
- } else {
1170
+ if (!wiimote_dpad_as_analog ) {
1168
1171
input_report_key (wdata -> extension .input ,
1169
- wiimod_classic_map [WIIMOD_CLASSIC_KEY_LEFT ],
1170
- !(ext [5 ] & 0x02 ));
1172
+ wiimod_classic_map [WIIMOD_CLASSIC_KEY_RIGHT ],
1173
+ !(ext [4 ] & 0x80 ));
1171
1174
input_report_key (wdata -> extension .input ,
1172
- wiimod_classic_map [WIIMOD_CLASSIC_KEY_UP ],
1173
- !(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
+ }
1174
1193
}
1175
1194
1176
1195
input_sync (wdata -> extension .input );
0 commit comments