On Mon, Jan 28, 2019 at 7:16 AM Bastien Nocera <hadess@xxxxxxxxxx> wrote: > > On Sun, 2019-01-27 at 22:04 -0600, Daniel J. Ogorchock wrote: > > The switchcon driver supports the Nintendo Switch Pro Controllers and > > the Joy-Cons. The Pro Controllers can be used over USB or Bluetooth. > > > > The Joy-Cons each create their own, independent input devices, so it > > is > > up to userspace to combine them if desired. > > > <snip> > > +static void switchcon_parse_report(struct switchcon_ctlr *ctlr, u8 > > *data) > > +{ > > + struct input_dev *dev = ctlr->input; > > + enum switchcon_ctlr_type type = ctlr->type; > > + u32 btns; > > + > > + btns = hid_field_extract(ctlr->hdev, data + 3, 0, 24); > > + > > + if (type == SWITCHCON_CTLR_TYPE_PROCON || > > + type == SWITCHCON_CTLR_TYPE_JOYCON_L) { > > <snip> > > + } > > + if (type == SWITCHCON_CTLR_TYPE_PROCON || > > + type == SWITCHCON_CTLR_TYPE_JOYCON_R) { > > Did I read this code correctly, in that the 2 joy-cons will each report > their status as if they were independent? > > I know that the Switch has a settings panel and probably some platform- > level code to deal with multiple sets of joycons being available, such > a pair attached to the body of the device and another pair used > individually by 2 players. > > The "these 2 discrete devices are actually one" case could be handled > by a library that Peter is working on. > Yes. The v1 patch had the joy-con combination as well as the horizontal orientation mode built into the driver. It made the driver needlessly convoluted though, and it was decided that that functionality belongs in userspace. > However, have you tested the joy-cons with a "charging grip"? Does the > power_supply reporting work for the joy-cons when charging via this > method? Do the joy-cons change behaviour, or work differently when > plugged in to the charging grip? Or do the joy-cons not have a "wired" > mode at all, and all the data is always sent via Bluetooth. > I actually don't have a charging grip to test with. I believe the Joy-Cons still operate independently via bluetooth in the grip. The controllers use the same protocol to report charging/battery/powered status regardless of controller type, so I believe the battery parsing code will continue working with the grip. If anyone reading this happens to have a charging grip and can test it, that would be much appreciated! > > + if (match) { > > + if (size > SC_MAX_RESP_SIZE) > > + copy_size = SC_MAX_RESP_SIZE; > > + else > > + copy_size = size; > > Use MIN()? > > Cheers > Thanks, Daniel