Commit 12e9a6d7 authored by Simon Wood's avatar Simon Wood Committed by Jiri Kosina

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: default avatarSimon Wood <simon@mungewell.org>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
parent b3bca326
...@@ -55,7 +55,8 @@ ...@@ -55,7 +55,8 @@
DUALSHOCK4_CONTROLLER_BT) DUALSHOCK4_CONTROLLER_BT)
#define SONY_LED_SUPPORT (SIXAXIS_CONTROLLER | BUZZ_CONTROLLER |\ #define SONY_LED_SUPPORT (SIXAXIS_CONTROLLER | BUZZ_CONTROLLER |\
DUALSHOCK4_CONTROLLER | MOTION_CONTROLLER) DUALSHOCK4_CONTROLLER | MOTION_CONTROLLER)
#define SONY_BATTERY_SUPPORT (SIXAXIS_CONTROLLER | DUALSHOCK4_CONTROLLER) #define SONY_BATTERY_SUPPORT (SIXAXIS_CONTROLLER | DUALSHOCK4_CONTROLLER |\
MOTION_CONTROLLER_BT)
#define SONY_FF_SUPPORT (SIXAXIS_CONTROLLER | DUALSHOCK4_CONTROLLER |\ #define SONY_FF_SUPPORT (SIXAXIS_CONTROLLER | DUALSHOCK4_CONTROLLER |\
MOTION_CONTROLLER) MOTION_CONTROLLER)
...@@ -1041,6 +1042,7 @@ static void sixaxis_parse_report(struct sony_sc *sc, __u8 *rd, int size) ...@@ -1041,6 +1042,7 @@ static void sixaxis_parse_report(struct sony_sc *sc, __u8 *rd, int size)
{ {
static const __u8 sixaxis_battery_capacity[] = { 0, 1, 25, 50, 75, 100 }; static const __u8 sixaxis_battery_capacity[] = { 0, 1, 25, 50, 75, 100 };
unsigned long flags; unsigned long flags;
int offset;
__u8 cable_state, battery_capacity, battery_charging; __u8 cable_state, battery_capacity, battery_charging;
/* /*
...@@ -1049,12 +1051,14 @@ static void sixaxis_parse_report(struct sony_sc *sc, __u8 *rd, int size) ...@@ -1049,12 +1051,14 @@ static void sixaxis_parse_report(struct sony_sc *sc, __u8 *rd, int size)
* It does not report the actual level while charging so it * It does not report the actual level while charging so it
* is set to 100% while charging is in progress. * is set to 100% while charging is in progress.
*/ */
if (rd[30] >= 0xee) { offset = (sc->quirks & MOTION_CONTROLLER) ? 12 : 30;
if (rd[offset] >= 0xee) {
battery_capacity = 100; battery_capacity = 100;
battery_charging = !(rd[30] & 0x01); battery_charging = !(rd[offset] & 0x01);
cable_state = 1; cable_state = 1;
} else { } else {
__u8 index = rd[30] <= 5 ? rd[30] : 5; __u8 index = rd[offset] <= 5 ? rd[offset] : 5;
battery_capacity = sixaxis_battery_capacity[index]; battery_capacity = sixaxis_battery_capacity[index];
battery_charging = 0; battery_charging = 0;
cable_state = 0; cable_state = 0;
...@@ -1154,6 +1158,8 @@ static int sony_raw_event(struct hid_device *hdev, struct hid_report *report, ...@@ -1154,6 +1158,8 @@ static int sony_raw_event(struct hid_device *hdev, struct hid_report *report,
swap(rd[45], rd[46]); swap(rd[45], rd[46]);
swap(rd[47], rd[48]); swap(rd[47], rd[48]);
sixaxis_parse_report(sc, rd, size);
} else if ((sc->quirks & MOTION_CONTROLLER_BT) && rd[0] == 0x01 && size == 49) {
sixaxis_parse_report(sc, rd, size); sixaxis_parse_report(sc, rd, size);
} else if (((sc->quirks & DUALSHOCK4_CONTROLLER_USB) && rd[0] == 0x01 && } else if (((sc->quirks & DUALSHOCK4_CONTROLLER_USB) && rd[0] == 0x01 &&
size == 64) || ((sc->quirks & DUALSHOCK4_CONTROLLER_BT) size == 64) || ((sc->quirks & DUALSHOCK4_CONTROLLER_BT)
...@@ -1976,6 +1982,7 @@ static int sony_check_add(struct sony_sc *sc) ...@@ -1976,6 +1982,7 @@ static int sony_check_add(struct sony_sc *sc)
int n, ret; int n, ret;
if ((sc->quirks & DUALSHOCK4_CONTROLLER_BT) || if ((sc->quirks & DUALSHOCK4_CONTROLLER_BT) ||
(sc->quirks & MOTION_CONTROLLER_BT) ||
(sc->quirks & SIXAXIS_CONTROLLER_BT)) { (sc->quirks & SIXAXIS_CONTROLLER_BT)) {
/* /*
* sony_get_bt_devaddr() attempts to parse the Bluetooth MAC * sony_get_bt_devaddr() attempts to parse the Bluetooth MAC
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment