Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xbox One S BT Controller patch so it can reconnect #624

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

MasterJubei
Copy link

@MasterJubei MasterJubei commented Apr 16, 2021

Hi, I noticed the Xbox One S BT is unable to reconnect. It only works if it is also being paired. This is because it does not save the link key. This is a bit useless in this state.
#623

Most of the hard work was done by @HisashiKato

This patch saves the bluetooth address and link key to EEPROM (EEPROM.h). I don't think there is a way around this.
The patch also checks if an Xbox One S BT controller is connecting so it handles it appropriately and does not break other controllers.

I tested with a PS4 controller after making these changes, it can pair and can reconnect just fine.

This will break support for the STM32, although that can be fixed pretty easily by including an arduino EEPROM emulation library. I am not sure about other microcontrollers.

EDIT: The checks with platform.io are complaining about #include <EEPROM.h>
Anyone know why? It compiles fine locally.

@Lauszus
Copy link
Collaborator

Lauszus commented May 4, 2021

The reason why I didn't do this was because not all boards supports the Arduino EEPROM API. For instance the ESP8622 requires you to call EEPROM.begin to pre-allocate some flash to be used for EEPROM and you also need to call EEPROM.commit to actually store the content.

Some other boards simply do not have any EEPROM at all, thus this will break support for those board for the entire library.

I think it would be better to have a callback and then deal with writing and reading from the EEPROM in the ino file. I'll make a new PR based on this.

@Lauszus
Copy link
Collaborator

Lauszus commented May 4, 2021

Also I would rather not hardcode the EEPROM address deep down in the library, as it will be quite confusing for people if their EEPROM data is overridden.

Anyway I'll base my code on yours, but with a callback instead :)

@MasterJubei
Copy link
Author

MasterJubei commented May 5, 2021

@Lauszus
Yup makes sense, thanks. The callback is a good idea, that would solve that. I was thinking along the lines of checking if the board is for e.g. an arduino uno, then it would call EEPROM that. Your idea is better.

As for hadcoding the location to write to...
At least their program data would go to a good cause. /s

There is one more issue with the Xbox One S BT controller. The controller data has significantly changed with a firmware update, so a lot of the buttons are mapped incorrectly.
#627 (comment)

You can access all the data with the least amount of effort by doing what I did instead, but the way Hisashi did it, is the correct way. I will see if I can eventually make a PR request doing it the proper way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants