Skip to content

Commit 12e9a6d

Browse files
mungewellJiri Kosina
authored andcommitted
HID: sony: Add support PS3 Move Battery via BT
Add support for the battery charge level and state to be read via BT. This is not support via USB as there is no know way to get the device sending 'input' reports over USB. Signed-off-by: Simon Wood <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent b3bca32 commit 12e9a6d

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

drivers/hid/hid-sony.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@
5555
DUALSHOCK4_CONTROLLER_BT)
5656
#define SONY_LED_SUPPORT (SIXAXIS_CONTROLLER | BUZZ_CONTROLLER |\
5757
DUALSHOCK4_CONTROLLER | MOTION_CONTROLLER)
58-
#define SONY_BATTERY_SUPPORT (SIXAXIS_CONTROLLER | DUALSHOCK4_CONTROLLER)
58+
#define SONY_BATTERY_SUPPORT (SIXAXIS_CONTROLLER | DUALSHOCK4_CONTROLLER |\
59+
MOTION_CONTROLLER_BT)
5960
#define SONY_FF_SUPPORT (SIXAXIS_CONTROLLER | DUALSHOCK4_CONTROLLER |\
6061
MOTION_CONTROLLER)
6162

@@ -1041,6 +1042,7 @@ static void sixaxis_parse_report(struct sony_sc *sc, __u8 *rd, int size)
10411042
{
10421043
static const __u8 sixaxis_battery_capacity[] = { 0, 1, 25, 50, 75, 100 };
10431044
unsigned long flags;
1045+
int offset;
10441046
__u8 cable_state, battery_capacity, battery_charging;
10451047

10461048
/*
@@ -1049,12 +1051,14 @@ static void sixaxis_parse_report(struct sony_sc *sc, __u8 *rd, int size)
10491051
* It does not report the actual level while charging so it
10501052
* is set to 100% while charging is in progress.
10511053
*/
1052-
if (rd[30] >= 0xee) {
1054+
offset = (sc->quirks & MOTION_CONTROLLER) ? 12 : 30;
1055+
1056+
if (rd[offset] >= 0xee) {
10531057
battery_capacity = 100;
1054-
battery_charging = !(rd[30] & 0x01);
1058+
battery_charging = !(rd[offset] & 0x01);
10551059
cable_state = 1;
10561060
} else {
1057-
__u8 index = rd[30] <= 5 ? rd[30] : 5;
1061+
__u8 index = rd[offset] <= 5 ? rd[offset] : 5;
10581062
battery_capacity = sixaxis_battery_capacity[index];
10591063
battery_charging = 0;
10601064
cable_state = 0;
@@ -1154,6 +1158,8 @@ static int sony_raw_event(struct hid_device *hdev, struct hid_report *report,
11541158
swap(rd[45], rd[46]);
11551159
swap(rd[47], rd[48]);
11561160

1161+
sixaxis_parse_report(sc, rd, size);
1162+
} else if ((sc->quirks & MOTION_CONTROLLER_BT) && rd[0] == 0x01 && size == 49) {
11571163
sixaxis_parse_report(sc, rd, size);
11581164
} else if (((sc->quirks & DUALSHOCK4_CONTROLLER_USB) && rd[0] == 0x01 &&
11591165
size == 64) || ((sc->quirks & DUALSHOCK4_CONTROLLER_BT)
@@ -1976,6 +1982,7 @@ static int sony_check_add(struct sony_sc *sc)
19761982
int n, ret;
19771983

19781984
if ((sc->quirks & DUALSHOCK4_CONTROLLER_BT) ||
1985+
(sc->quirks & MOTION_CONTROLLER_BT) ||
19791986
(sc->quirks & SIXAXIS_CONTROLLER_BT)) {
19801987
/*
19811988
* sony_get_bt_devaddr() attempts to parse the Bluetooth MAC

0 commit comments

Comments
 (0)