diff --git a/Makefile b/Makefile index f597fe8..c749882 100644 --- a/Makefile +++ b/Makefile @@ -13,15 +13,12 @@ ifeq ($(DEBUG), 1) export BLOOPAIR_COMMIT_HASH := $(or $(shell git rev-parse HEAD),"ffffffffffffffffffffffffffffffffffffffff") endif -.PHONY: all clean ios_kernel ios_usb ios_pad libbloopair loader pair_menu koopair +.PHONY: all clean ios_kernel ios_usb ios_pad libbloopair loader koopair -all: loader pair_menu koopair +all: loader koopair @echo -e "\033[92mDone!\033[0m" dist: all - mkdir -p dist/wiiu/apps/Bloopair_pair_menu/ - cp pair_menu/Bloopair_pair_menu.rpx dist/wiiu/apps/Bloopair_pair_menu/ - cp pair_menu/Bloopair_pair_menu.wuhb dist/wiiu/apps/Bloopair_pair_menu/ mkdir -p dist/wiiu/apps/Koopair/ cp koopair/Koopair.rpx dist/wiiu/apps/Koopair/ cp koopair/Koopair.wuhb dist/wiiu/apps/Koopair/ @@ -47,10 +44,6 @@ loader: ios_kernel libbloopair @echo -e "\033[92mBuilding $@...\033[0m" @$(MAKE) --no-print-directory -C $(CURDIR)/loader -pair_menu: libbloopair - @echo -e "\033[92mBuilding $@...\033[0m" - @$(MAKE) --no-print-directory -C $(CURDIR)/pair_menu - koopair: libbloopair @echo -e "\033[92mBuilding $@...\033[0m" @$(MAKE) --no-print-directory -C $(CURDIR)/koopair @@ -61,5 +54,4 @@ clean: @$(MAKE) --no-print-directory -C $(CURDIR)/ios/ios_pad clean @$(MAKE) --no-print-directory -C $(CURDIR)/loader clean @$(MAKE) --no-print-directory -C $(CURDIR)/libbloopair clean - @$(MAKE) --no-print-directory -C $(CURDIR)/pair_menu clean @$(MAKE) --no-print-directory -C $(CURDIR)/koopair clean diff --git a/README.md b/README.md index 8dc0706..8f27b25 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ To pair a DualShock 3 to the console, see the [Pairing a DualShock 3](#pairing-a - Copy the `30_bloopair.rpx` from the .zip file to the `modules/setup/` folder of your target environment on the SD Card. This would be `wiiu/environments/tiramisu/modules/setup/` for Tiramisu. - Copy the `wiiu` folder from the .zip and copy it to the root of your SD Card. - If you're using aroma you can delete the `Bloopair_pair_menu.rpx` in the `wiiu/apps` folder and use the .wuhb instead. + If you're using aroma you can delete the `Koopair.rpx` in the `wiiu/apps` folder and use the .wuhb instead. Make sure you're using Tiramisu or Aroma. Follow https://wiiu.hacks.guide/#/ to setup Tiramisu. More info about Tiramisu here: https://maschell.github.io/homebrew/2021/12/31/tiramisu.html @@ -37,10 +37,10 @@ If a controller had been paired in the past, simply turn it on again and it shou ## Pairing a DualShock 3 The DualShock 3 needs to be paired using a USB cable. After the initial pairing it can be used like any other wireless Bluetooth controller. -- Open the Bloopair pairing app from the Wii U menu or Homebrew Launcher. You should now be in the USB pairing menu. +- Open Koopair from the Wii U menu or Homebrew Launcher. Now open the "Controller Pairing" option on the menu. - Connect the DualShock 3 using a USB cable to the front or back ports of the console. -- The screen will say "Paired!" once the controller has been successfully paired. -You can now remove the USB cable from the controller. Press the PS button once back on the Wii U menu to connect it to the console. +- The screen will say "Successfully paired controller!" once the controller has been successfully paired. +You can now remove the USB cable from the controller. Press the PS button to connect it to the console. - Press the HOME button to exit. The DualShock 3 is now ready to use with the console. @@ -76,7 +76,6 @@ Bloopair ├── koopair - Bloopair companion app. ├── libbloopair - Library to communicate with Bloopair IPC. ├── loader - Setup module which loads Bloopair. -├── pair_menu - DS3 pairing application. └── third_party - Third-party content included in Bloopair. ``` diff --git a/koopair/source/screens/ControllerPairingScreen.cpp b/koopair/source/screens/ControllerPairingScreen.cpp index 9d7e9bb..d5973f8 100644 --- a/koopair/source/screens/ControllerPairingScreen.cpp +++ b/koopair/source/screens/ControllerPairingScreen.cpp @@ -23,6 +23,9 @@ namespace { +// Info about the reports can be found here: +// - + #define DS3_VID 0x054c #define DS3_PID 0x0268 diff --git a/pair_menu/Makefile b/pair_menu/Makefile deleted file mode 100644 index 88b0635..0000000 --- a/pair_menu/Makefile +++ /dev/null @@ -1,181 +0,0 @@ -#------------------------------------------------------------------------------- -.SUFFIXES: -#------------------------------------------------------------------------------- - -ifeq ($(strip $(DEVKITPRO)),) -$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=/devkitpro") -endif - -TOPDIR ?= $(CURDIR) - -#------------------------------------------------------------------------------- -# APP_NAME sets the long name of the application -# APP_SHORTNAME sets the short name of the application -# APP_AUTHOR sets the author of the application -#------------------------------------------------------------------------------- -APP_NAME := DS3 Pairing Menu for Bloopair -APP_SHORTNAME := Bloopair Pairing Menu -APP_AUTHOR := GaryOderNichts - -include $(DEVKITPRO)/wut/share/wut_rules - -#------------------------------------------------------------------------------- -# TARGET is the name of the output -# BUILD is the directory where object files & intermediate files will be placed -# SOURCES is a list of directories containing source code -# DATA is a list of directories containing data files -# INCLUDES is a list of directories containing header files -# CONTENT is the path to the bundled folder that will be mounted as /vol/content/ -# ICON is the game icon, leave blank to use default rule -# TV_SPLASH is the image displayed during bootup on the TV, leave blank to use default rule -# DRC_SPLASH is the image displayed during bootup on the DRC, leave blank to use default rule -#------------------------------------------------------------------------------- -TARGET := Bloopair_pair_menu -BUILD := build -SOURCES := . ../common -DATA := data -INCLUDES := ../common -CONTENT := -ICON := icon.png -TV_SPLASH := -DRC_SPLASH := - -#------------------------------------------------------------------------------- -# options for code generation -#------------------------------------------------------------------------------- -CFLAGS := -Wall -O2 -ffunction-sections \ - $(MACHDEP) - -CFLAGS += $(INCLUDE) -D__WIIU__ -D__WUT__ - -CXXFLAGS := $(CFLAGS) - -ASFLAGS := $(ARCH) -LDFLAGS = $(ARCH) $(RPXSPECS) -Wl,-Map,$(notdir $*.map) - -LIBS := -lbloopair -lwut - -#------------------------------------------------------------------------------- -# list of directories containing libraries, this must be the top level -# containing include and lib -#------------------------------------------------------------------------------- -LIBDIRS := $(PORTLIBS) $(WUT_ROOT) $(BLOOPAIR_TOP_DIR)/libbloopair - - -#------------------------------------------------------------------------------- -# no real need to edit anything past this point unless you need to add additional -# rules for different file extensions -#------------------------------------------------------------------------------- -ifneq ($(BUILD),$(notdir $(CURDIR))) -#------------------------------------------------------------------------------- - -export OUTPUT := $(CURDIR)/$(TARGET) -export TOPDIR := $(CURDIR) - -export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ - $(foreach dir,$(DATA),$(CURDIR)/$(dir)) - -export DEPSDIR := $(CURDIR)/$(BUILD) - -CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) -CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) -SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) -BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) - -#------------------------------------------------------------------------------- -# use CXX for linking C++ projects, CC for standard C -#------------------------------------------------------------------------------- -ifeq ($(strip $(CPPFILES)),) -#------------------------------------------------------------------------------- - export LD := $(CC) -#------------------------------------------------------------------------------- -else -#------------------------------------------------------------------------------- - export LD := $(CXX) -#------------------------------------------------------------------------------- -endif -#------------------------------------------------------------------------------- - -export OFILES_BIN := $(addsuffix .o,$(BINFILES)) -export OFILES_SRC := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) -export OFILES := $(OFILES_BIN) $(OFILES_SRC) -export HFILES_BIN := $(addsuffix .h,$(subst .,_,$(BINFILES))) - -export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ - $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ - -I$(CURDIR)/$(BUILD) - -export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) - -ifneq (,$(strip $(CONTENT))) - export APP_CONTENT := $(TOPDIR)/$(CONTENT) -endif - -ifneq (,$(strip $(ICON))) - export APP_ICON := $(TOPDIR)/$(ICON) -else ifneq (,$(wildcard $(TOPDIR)/$(TARGET).png)) - export APP_ICON := $(TOPDIR)/$(TARGET).png -else ifneq (,$(wildcard $(TOPDIR)/icon.png)) - export APP_ICON := $(TOPDIR)/icon.png -endif - -ifneq (,$(strip $(TV_SPLASH))) - export APP_TV_SPLASH := $(TOPDIR)/$(TV_SPLASH) -else ifneq (,$(wildcard $(TOPDIR)/tv-splash.png)) - export APP_TV_SPLASH := $(TOPDIR)/tv-splash.png -else ifneq (,$(wildcard $(TOPDIR)/splash.png)) - export APP_TV_SPLASH := $(TOPDIR)/splash.png -endif - -ifneq (,$(strip $(DRC_SPLASH))) - export APP_DRC_SPLASH := $(TOPDIR)/$(DRC_SPLASH) -else ifneq (,$(wildcard $(TOPDIR)/drc-splash.png)) - export APP_DRC_SPLASH := $(TOPDIR)/drc-splash.png -else ifneq (,$(wildcard $(TOPDIR)/splash.png)) - export APP_DRC_SPLASH := $(TOPDIR)/splash.png -endif - -.PHONY: $(BUILD) clean all - -#------------------------------------------------------------------------------- -all: $(BUILD) - -$(BUILD): - @[ -d $@ ] || mkdir -p $@ - @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile - -#------------------------------------------------------------------------------- -clean: - @echo clean ... - @rm -fr $(BUILD) $(TARGET).wuhb $(TARGET).rpx $(TARGET).elf - -#------------------------------------------------------------------------------- -else -.PHONY: all - -DEPENDS := $(OFILES:.o=.d) - -#------------------------------------------------------------------------------- -# main targets -#------------------------------------------------------------------------------- -all : $(OUTPUT).wuhb - -$(OUTPUT).wuhb : $(OUTPUT).rpx -$(OUTPUT).rpx : $(OUTPUT).elf -$(OUTPUT).elf : $(OFILES) - -$(OFILES_SRC) : $(HFILES_BIN) - -#------------------------------------------------------------------------------- -# you need a rule like this for each extension you use as binary data -#------------------------------------------------------------------------------- -%.bin.o %_bin.h : %.bin -#------------------------------------------------------------------------------- - @echo $(notdir $<) - @$(bin2o) - --include $(DEPENDS) - -#------------------------------------------------------------------------------- -endif -#------------------------------------------------------------------------------- diff --git a/pair_menu/README.md b/pair_menu/README.md deleted file mode 100644 index fb417fa..0000000 --- a/pair_menu/README.md +++ /dev/null @@ -1,2 +0,0 @@ -# Bloopair DS3 Pairing Menu -Simple pairing tool to allow pairing a DualShock 3 via USB. diff --git a/pair_menu/icon.png b/pair_menu/icon.png deleted file mode 100644 index 4c68711..0000000 Binary files a/pair_menu/icon.png and /dev/null differ diff --git a/pair_menu/main.cpp b/pair_menu/main.cpp deleted file mode 100644 index 1246ecd..0000000 --- a/pair_menu/main.cpp +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright (C) 2021 GaryOderNichts - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include - -#include -#include -#include -#include - -#include -#include -#include - -// Info about the reports can be found here: -// - - -#define DS3_VID 0x054c -#define DS3_PID 0x0268 - -#define HID_REPORT_FEATURE 3 - -static uint8_t controller_bda[6]{}; - -static IOSHandle bloopairHandle = -1; - -int ds3ReadBDA(uint32_t handle, uint8_t* outBDA) -{ - __attribute__ ((aligned (0x20))) uint8_t buf[17]{}; - int res = HIDGetReport(handle, HID_REPORT_FEATURE, 0xf2, buf, sizeof(buf), nullptr, nullptr); - if (res >= 0) { - memcpy(outBDA, buf + 4, 6); - } - - return res; -} - -int ds3WriteMasterBDA(uint32_t handle, uint8_t* bda) -{ - __attribute__ ((aligned (0x20))) uint8_t buf[8]{}; - memcpy(buf + 2, bda, 6); - return HIDSetReport(handle, HID_REPORT_FEATURE, 0xf5, buf, sizeof(buf), nullptr, nullptr); -} - -int32_t hidAttachCallback(HIDClient* client, HIDDevice* device, HIDAttachEvent event) -{ - if (event == HID_DEVICE_ATTACH) { - if (__builtin_bswap16(device->vid) == DS3_VID && __builtin_bswap16(device->pid) == DS3_PID) { - uint8_t bda[6]{}; - int res = ds3ReadBDA(device->handle, bda); - if (res < 0) { - WHBLogPrintf("Failed to read bda: %x", res); - WHBLogConsoleDraw(); - return HID_DEVICE_DETACH; - } - - WHBLogPrintf("DualShock 3 (%02x:%02x:%02x:%02x:%02x:%02x) connected", - bda[0], bda[1], bda[2], bda[3], bda[4], bda[5]); - - WHBLogPrintf("Setting master address..."); - WHBLogConsoleDraw(); - - res = ds3WriteMasterBDA(device->handle, controller_bda); - if (res < 0) { - WHBLogPrintf("Failed write master bda: %x", res); - WHBLogConsoleDraw(); - return HID_DEVICE_DETACH; - } - - WHBLogPrintf("Adding pairing..."); - WHBLogConsoleDraw(); - - uint8_t link_key[16]{}; - Bloopair_AddControllerPairing(bloopairHandle, bda, - link_key, // we'll bypass security for a ds3 anyways, so just add an empty link key - "Nintendo RVL-CNT-01-UC", // use the pro controller name - DS3_VID, DS3_PID - ); - - WHBLogPrintf("Paired!"); - WHBLogConsoleDraw(); - } - } - - return HID_DEVICE_DETACH; -} - -int main() -{ - WHBProcInit(); - - // Allow connecting pro controllers while in the pairing menu - WPADInit(); - WPADEnableURCC(1); - - WHBLogConsoleInit(); - WHBLogConsoleSetColor(0); - WHBLogPrintf("=== Bloopair USB Controller pairing ==="); - WHBLogPrintf("Connect a DualShock 3 using a USB cable to pair it"); - WHBLogPrintf("Press HOME to exit"); - WHBLogConsoleDraw(); - - bloopairHandle = Bloopair_Open(); - if (bloopairHandle < 0) { - WHBLogPrintf("Failed to open btrm"); - WHBLogConsoleDraw(); - sleep(2); - goto main_loop; - } - - if (Bloopair_ReadConsoleBDA(bloopairHandle, controller_bda) < 0) { - WHBLogPrintf("Failed to read local bda (Make sure Bloopair is active!)"); - WHBLogConsoleDraw(); - sleep(2); - goto main_loop; - } - - WHBLogPrintf("Local BDA is: %02x:%02x:%02x:%02x:%02x:%02x", - controller_bda[0], controller_bda[1], controller_bda[2], controller_bda[3], controller_bda[4], controller_bda[5]); - WHBLogPrintf(""); - WHBLogConsoleDraw(); - - if (HIDSetup() < 0) { - WHBLogPrintf("Failed to setup HID"); - WHBLogConsoleDraw(); - sleep(2); - goto main_loop; - } - - HIDClient client; - if (HIDAddClient(&client, hidAttachCallback) < 0) { - WHBLogPrintf("Failed to add HID client"); - WHBLogConsoleDraw(); - sleep(2); - goto main_loop; - } - -main_loop: ; - while (WHBProcIsRunning()) { - WHBLogConsoleDraw(); - } - - HIDDelClient(&client); - HIDTeardown(); - - Bloopair_Close(bloopairHandle); - - WHBLogConsoleFree(); - - WPADShutdown(); - WHBProcShutdown(); - return 0; -}