err4o4 / spotify-car-thing-reverse-engineering

426 stars 4 forks source link

Car thing as a macropad! #23

Open lmore377 opened 2 years ago

lmore377 commented 2 years ago

Join the Car Thing Hax Discord for more info! https://discord.gg/CwwrT6xPEF

Also check out the GitHub org: https://github.com/Car-Thing-Hax-Community

The instructions below currently don't work with the modern version of Macro Deck but the developer is working on some fixes specifically for the Car Thing. Visit the Discord for more info.

Thanks to u/Jaba_Haba on reddit for bringing Macro Deck (the software making this possible) to my attention! https://www.reddit.com/r/carthinghax/comments/yq5p77/macro_deck_for_car_thing/

  1. Flash the ADB image from here: https://github.com/err4o4/spotify-car-thing-reverse-engineering/issues/22 There's instructions on how to do it in the folder with the firmware images.
  2. Make sure adb is installed and working on your PC. XDA has a decent walkthrough
  3. Install and set up Macro Deck https://macrodeck.org/
  4. Download these files: https://github.com/Macro-Deck-org/Macro-Deck-Web-Client (Click Code then Download zip) https://gist.github.com/lmore377/4c944a97407e34e10d998ee6a3e33f6a (For both files right click Raw then Save link as...) Currently not up to date, will fix soon ™️
  5. Extract the zip file to any folder then run these commands:
    adb shell mount -o remount,rw /
    adb push supervisord.conf /etc
    adb shell cp -r /usr/share/qt-superbird-app/webapp/ /usr/share/qt-superbird-app/webapp.bak/
    adb shell rm -rf /usr/share/qt-superbird-app/webapp/*
    adb push Macro-Deck-Web-Client-main/* /usr/share/qt-superbird-app/webapp/
    adb push index-edited.html /usr/share/qt-superbird-app/webapp/index.html
    adb reboot
  6. After the car thing reboots you should see the macro deck web ui load up. At this point just run adb reverse tcp:8191 tcp:8191 (change 8191 if you use a different port) then press connect on the car thing. You'll need to do this every time you reboot your pc or unplug/plug in car thing

The only caveat is that none of the physical buttons work. I think this is just a limitation of macro deck but if you manage to figure out how to get keyboard keys working here's the mapping: Preset 1-4: Numbers 1-4 on a keyboard Menu: M Back: ESC Wheel Button: Either space or enter. I can't remember which Wheel: Mouse scroll wheel

The only edit on the index-edited.html file is at line 104 to autofill the IP address since there's no form of keyboard input on the car thing. supervisord.conf was just edited to disable swupdate and the process that handles phone communication to free up some resources.

Edit: one more thing, if you ever want to update the web client for whatever reason you just need to edit line 104 in index.html to match what I edited and push the updated files over ADB to /usr/share/qt-superbird-app/webapp/

lmore377 commented 2 years ago

Looks like they're planning on adding adb support so once they do that step 7 probably won't be necessary

https://github.com/Macro-Deck-org/Macro-Deck/issues/104

lmore377 commented 2 years ago

20221109_005234.jpg

r3pwn commented 1 year ago

Awesome work, @lmore377! To add on, I managed to move the buttons from the top-left into being controlled by the hardware buttons using the following steps:

In the index.html file you're working with, add style="visibility:hidden" onto the 3 buttons, like this:

image

Then create a file in the js folder called superbird_buttons.js with the following contents:

/*
 * Button support for Spotify Car Thing (superbird)
 */
(function () {
    document.onkeypress = function (e) {
        switch ((e || window.event).key) {
            case "1":
                back();
                break;
            case "m":
                toggleDark();
                break;
        }
    };
})();

And lastly, add a script tag for it at the bottom of your index.html file

image

Make sure the updated index.html and superbird_buttons.js files are pushed to the device, and (after a reboot) the left-most top button will function as "Back", and the right-most top button will function as the dark mode toggle.

End result:

image

maclyn commented 1 year ago

This is awesome! I took a swing at updating some things in the Web Client so I could use this as a daily driver, and wrote a quick-and-dirty patch to do a few things --

Gist for the patch -- https://gist.github.com/maclyn/9b1059469c5b46bea7097c965fd42033

Edit: Added some more tweaks for the autoconnection behavior so it doesn't reload the page every time it tries causing a somewhat annoying flicker. The only thing that I think is keeping this from being really convenient is the USB connection seems like it needs to happen after my PC starts, so right now I have to unplug -> replug the Car Thing and run the reverse command every time my computer starts/wakes from sleep. I wonder if there's a way to run the ADB script on a loop until it connects...

toomyzoom commented 1 year ago

This is awesome! I took a swing at updating some things in the Web Client so I could use this as a daily driver, and wrote a quick-and-dirty patch to do a few things --

* Hide the buttons like @r3pwn did, with some of the padding reclaimed by updating `autoSize()`

* Instead of mapping the buttons to back/dark/fullscreen, I setup mapping so 1-4 and menu map to clicking the buttons in the first row, the dial (scroll down/scroll up/press) maps to the leftmost, rightmost, and center buttons in the middle row, and back button to map to the last row's rightmost button. Just update `HW_KEY_TO_COL_ROW` if you want a different hardware key to onscreen button mapping.

* The Car Thing tries to connect as soon as the page loads. It's visually a little annoying since the page refreshes if it fails to connect, but if you have the adb port forwarding setup to run when your computer starts you shouldn't need to interact with the Car Thing at all for it to get into the connected MacroPad

* I also added a single line change to disable the cookie alert, since it seems like cookies aren't being persisted.

Gist for the patch -- https://gist.github.com/maclyn/9b1059469c5b46bea7097c965fd42033

Edit: Added some more tweaks for the autoconnection behavior so it doesn't reload the page every time it tries causing a somewhat annoying flicker. The only thing that I think is keeping this from being really convenient is the USB connection seems like it needs to happen after my PC starts, so right now I have to unplug -> replug the Car Thing and run the reverse command every time my computer starts/wakes from sleep. I wonder if there's a way to run the ADB script on a loop until it connects...

Do you know which version of macrodeck your patch applied to? I don't think it's the latest version 2.5.0. I assume it's 2.37.3 as you had 2.37.3.windows.1 on last line of your patch.

maclyn commented 1 year ago

Commented on the gist, but at some point it stopped applying successfully -- updated so it patches cleanly on v2.5.1 (the last line of the patch is just the version of Git I was using to make the patch)

MichaelGreco commented 1 year ago

Hi, I am using superbird_tool.py trying to load in the image that I downloaded. I am using the second one here (https://mega.nz/folder/NxNXQCaT#-n1zkoXsJuw-5rQ-ZYzRJw/folder/5kECGT5C) and trying to follow the read me. I also double checked the file extensions like it says. I am getting the below error. Would anyone happen to know why?

Traceback (most recent call last): File "\superbird-tool-main\superbird_tool.py", line 242, in dev.restore_partition('env', f'{FOLDER_NAME}/env.dump') File "\superbird-tool-main\superbird_device.py", line 404, in restore_partition raise ValueError('Failed to validate partition size!') ValueError: Failed to validate partition size!

ValueError: Failed to validate partition size!

ComicalHysteria commented 5 months ago

Chiming in that this still works. running the last adb command for tcp connection isn't necessary for me on Macro Deck v 2.14.1 If Macro Deck is crashing for you I had to disable "Automatically wake screen and start Macro Deck Client when connected" in Connection.

polyinnovator commented 4 months ago

How would someone with limited knowledge be able to do this? If I can figure it out with some help, I could even make a video about it too. This is the first thing I've seen someone do to actually replace the need. Other attempts have been windows or android, which its too under powered obv for.

Is is persistent? As in don't have to reup every once in a while, and what does the dial do now?

lmore377 commented 4 months ago

Unfortunately these instructions don't work with the current version of Macro Deck but the developer is working on some fixes. In the meantime you should visit the Discord for more info.