Skip to content

Commit

Permalink
Merge branch 'ps2homebrew:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
israpps authored Apr 4, 2023
2 parents 111099e + d26da79 commit 7476010
Show file tree
Hide file tree
Showing 30 changed files with 230 additions and 1,567 deletions.
3 changes: 2 additions & 1 deletion .clang-format-ignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
./modules/network/lwnbdsvr/nbd-protocol.h
./modules/isofs/lz4.c
./modules/isofs/lz4.h
./modules/network/lwNBD
./thirdparty/clang-format-lint-action
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ DETAILED_CHANGELOG
pc/iso2usbld/bin/iso2usbld
IOPRP_img.c

#
# 3rd party
#
*modules/network/lwNBD
*thirdparty/clang-format-lint-action

# language
lng/lang_*.lng
*lng_src
Expand Down
31 changes: 19 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,11 @@ EE_DEPS = $($(filter %.o,$(EE_OBJS)):%.o=%.d)

.SILENT:

.PHONY: all release debug iopcore_debug eesio_debug ingame_debug deci2_debug clean rebuild pc_tools pc_tools_win32 oplversion format format-check ps2sdk-not-setup download_lng languages
.PHONY: all release debug iopcore_debug eesio_debug ingame_debug deci2_debug clean rebuild pc_tools pc_tools_win32 oplversion format format-check ps2sdk-not-setup download_lng download_lwNBD languages

ifdef PS2SDK

all: download_lng languages
all: download_lng download_lwNBD languages
echo "Building Open PS2 Loader $(OPL_VERSION)..."
echo "-Interface"
ifneq ($(NOT_PACKED),1)
Expand All @@ -218,7 +218,7 @@ else
$(MAKE) $(EE_BIN)
endif

release: download_lng languages $(EE_VPKD).ZIP
release: download_lng download_lwNBD languages $(EE_VPKD).ZIP

debug:
$(MAKE) DEBUG=1 all
Expand All @@ -235,7 +235,7 @@ ingame_debug:
deci2_debug:
$(MAKE) DEBUG=1 INGAME_DEBUG=1 DECI2_DEBUG=1 all

clean:
clean: download_lwNBD
echo "Cleaning..."
echo "-Interface"
rm -fr $(MAPFILE) $(EE_BIN) $(EE_BIN_PACKED) $(EE_BIN_STRIPPED) $(EE_VPKD).* $(EE_OBJS_DIR) $(EE_ASM_DIR)
Expand Down Expand Up @@ -287,7 +287,7 @@ clean:
echo " -genvmc"
$(MAKE) -C modules/vmc/genvmc clean
echo " -lwnbdsvr"
$(MAKE) -C modules/network/lwnbdsvr clean
$(MAKE) -C modules/network/lwNBD/ TARGET=iop clean
echo " -udptty-ingame"
$(MAKE) -C modules/debug/udptty-ingame clean
echo " -ps2link"
Expand Down Expand Up @@ -322,11 +322,12 @@ pc_tools_win32:
echo "Building WIN32 iso2opl, opl2iso and genvmc..."
$(MAKE) _WIN32=1 -C pc

format:
find . -type f -a \( -iname \*.h -o -iname \*.c \) | xargs clang-format -i
cfla = "thirdparty/clang-format-lint-action"
format-check: download_cfla
@python3 $(cfla)/run-clang-format.py --clang-format-executable $(cfla)/clang-format/clang-format12 -r .

format-check:
@! find . -type f -a \( -iname \*.h -o -iname \*.c \) | xargs clang-format -style=file -output-replacements-xml | grep "<replacement " >/dev/null
format: download_cfla
@python3 $(cfla)/run-clang-format.py --clang-format-executable $(cfla)/clang-format/clang-format12 -r . -i true

$(EE_ASM_DIR):
@mkdir -p $@
Expand Down Expand Up @@ -607,10 +608,10 @@ modules/vmc/genvmc/genvmc.irx: modules/vmc/genvmc
$(EE_ASM_DIR)genvmc.s: modules/vmc/genvmc/genvmc.irx | $(EE_ASM_DIR)
$(BIN2S) $< $@ genvmc_irx

modules/network/lwnbdsvr/lwnbdsvr.irx: modules/network/lwnbdsvr
$(MAKE) -C $<
modules/network/lwNBD/lwnbdsvr.irx: modules/network/lwNBD
$(MAKE) TARGET=iop -C $<

$(EE_ASM_DIR)lwnbdsvr.s: modules/network/lwnbdsvr/lwnbdsvr.irx | $(EE_ASM_DIR)
$(EE_ASM_DIR)lwnbdsvr.s: modules/network/lwNBD/lwnbdsvr.irx | $(EE_ASM_DIR)
$(BIN2S) $< $@ lwnbdsvr_irx

$(EE_ASM_DIR)udptty.s: $(PS2SDK)/iop/irx/udptty.irx | $(EE_ASM_DIR)
Expand Down Expand Up @@ -743,6 +744,12 @@ languages: $(ENGLISH_TEMPLATE_YML) $(TRANSLATIONS_YML) $(ENGLISH_LNG) $(TRANSLAT
download_lng:
./download_lng.sh

download_lwNBD:
./download_lwNBD.sh

download_cfla:
./download_cfla.sh

$(TRANSLATIONS_LNG): $(LNG_DIR)lang_%.lng: $(LNG_SRC_DIR)%.yml $(BASE_LANGUAGE) $(LANG_COMPILER)
python3 $(LANG_COMPILER) --make_lng --base $(BASE_LANGUAGE) --translation $< $@

Expand Down
12 changes: 12 additions & 0 deletions download_cfla.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh

REPO_URL="https://github.com/DoozyX/clang-format-lint-action.git"
REPO_FOLDER="thirdparty/clang-format-lint-action"
COMMIT="c3b2c943e924028b93a707a5b1b017976ab8d50c"

if test ! -d "$REPO_FOLDER"; then
git clone $REPO_URL "$REPO_FOLDER" || { exit 1; }
(cd $REPO_FOLDER && git checkout "$COMMIT" && cd -) || { exit 1; }
else
(cd "$REPO_FOLDER" && git fetch origin && git checkout "$COMMIT" && cd - )|| exit 1
fi
12 changes: 12 additions & 0 deletions download_lwNBD.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

## Download lwNBD
REPO_URL="https://github.com/bignaux/lwNBD.git"
REPO_FOLDER="modules/network/lwNBD"
COMMIT="9777a10f840679ef89b1ec6a588e2d93803d7c37"
if test ! -d "$REPO_FOLDER"; then
git clone $REPO_URL "$REPO_FOLDER" || { exit 1; }
(cd $REPO_FOLDER && git checkout "$COMMIT" && cd -) || { exit 1; }
else
(cd "$REPO_FOLDER" && git fetch origin && git checkout "$COMMIT" && cd - )|| exit 1
fi
68 changes: 64 additions & 4 deletions include/ds34common.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@
#define USB_SUBCLASS_RF_CONTROLLER 0x01
#define USB_PROTOCOL_BLUETOOTH_PROG 0x01

#define DS34_VID 0x054C // Sony Corporation
#define DS3_PID 0x0268 // PS3 Controller
#define DS4_PID 0x05C4 // PS4 Controller
#define DS4_PID_SLIM 0x09CC // PS4 Slim Controller
#define SONY_VID 0x12ba // Sony
#define DS34_VID 0x054C // Sony Corporation
#define DS3_PID 0x0268 // PS3 Controller
#define DS4_PID 0x05C4 // PS4 Controller
#define DS4_PID_SLIM 0x09CC // PS4 Slim Controller
#define GUITAR_HERO_PS3_PID 0x0100 // PS3 Guitar Hero Guitar
#define ROCK_BAND_PS3_PID 0x0200 // PS3 Rock Band Guitar

// NOTE: struct member prefixed with "n" means it's active-low (i.e. value of 0 indicates button is pressed, value 1 is released)
enum DS2ButtonBitNumber {
Expand Down Expand Up @@ -164,6 +167,55 @@ struct ds3report

} __attribute__((packed));

struct ds3guitarreport
{
union
{
uint16_t ButtonState;
struct
{
uint8_t ButtonStateL; // Main buttons low byte
uint8_t ButtonStateH; // Main buttons high byte
};
struct
{
uint16_t Blue : 1;
uint16_t Green : 1;
uint16_t Red : 1;
uint16_t Yellow : 1;
uint16_t Orange : 1;
uint16_t StarPower : 1;
uint16_t : 1;
uint16_t : 1;
uint16_t Select : 1;
uint16_t Start : 1;
uint16_t : 1;
uint16_t : 1;
uint16_t PSButton : 1;
uint16_t : 1;
uint16_t : 1;
uint16_t : 1;
};
};
uint8_t Dpad; // hat format, 0x08 is released, 0=N, 1=NE, 2=E, 3=SE, 4=S, 5=SW, 6=W, 7=NW
uint8_t : 8;
uint8_t : 8;
uint8_t Whammy; // Whammy axis 0 - 255, 128 is mid
uint8_t : 8;
uint8_t PressureRightYellow; // digital Pad Right + Yellow button Pressure 0 - 255 (if both are pressed, then they cancel eachother out)
uint8_t PressureLeft; // digital Pad Left button Pressure 0 - 255
uint8_t PressureUpGreen; // digital Pad Up + Green button Pressure 0 - 255 (if both are pressed, then they cancel eachother out)
uint8_t PressureDownOrange; // digital Pad Down + Orange button Pressure 0 - 255 (if both are pressed, then they cancel eachother out)
uint8_t PressureBlue; // digital Pad Blue button Pressure 0 - 255
uint8_t PressureRed; // digital Pad Red button Pressure 0 - 255
uint8_t Reserved3[6]; // Unknown
int16_t AccelX;
int16_t AccelZ;
int16_t AccelY;
int16_t GyroZ;

} __attribute__((packed));

enum DS4DpadDirections {
DS4DpadDirectionN = 0,
DS4DpadDirectionNE,
Expand Down Expand Up @@ -239,6 +291,14 @@ struct ds4report
*/
void translate_pad_ds3(const struct ds3report *in, struct ds2report *out, uint8_t pressure_emu);

/**
* Translate PS3 Guitar pad data into DS2 Guitar pad data.
* @param in PS3 Guitar report
* @param out PS2 Guitar report
* @param guitar_hero_format set to 1 if this is a guitar hero guitar, set to 0 if this is a rock band guitar
*/
void translate_pad_guitar(const struct ds3guitarreport *in, struct ds2report *out, uint8_t guitar_hero_format);

/**
* Translate DS3 pad data into DS2 pad data.
* @param in DS4 report
Expand Down
6 changes: 3 additions & 3 deletions labs/lwnbdsvr/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ clean:
$(MAKE) -C ../../modules/network/SMSMAP clean
$(MAKE) -C ../../modules/hdd/atad clean
$(MAKE) -C ../../modules/hdd/ps2hdd clean
$(MAKE) -C ../../modules/network/lwnbdsvr clean
$(MAKE) -C ../../modules/network/lwNBD clean
rm -f *.elf *.o *.a *.s

rebuild: clean all
Expand Down Expand Up @@ -56,8 +56,8 @@ ps2hdd.s:
$(BIN2S) ../../modules/hdd/ps2hdd/ps2hdd.irx ps2hdd.s ps2hdd_irx

lwnbdsvr.s:
$(MAKE) -C ../../modules/network/lwnbdsvr
$(BIN2S) ../../modules/network/lwnbdsvr/lwnbdsvr.irx lwnbdsvr.s lwnbdsvr_irx
$(MAKE) -C ../../modules/network/lwNBD
$(BIN2S) ../../modules/network/lwNBD/lwnbdsvr.irx lwnbdsvr.s lwnbdsvr_irx

iomanx.s:
$(BIN2S) $(PS2SDK)/iop/irx/iomanX.irx iomanx.s iomanx_irx
Expand Down
25 changes: 0 additions & 25 deletions modules/network/lwnbdsvr/LICENSE

This file was deleted.

18 changes: 0 additions & 18 deletions modules/network/lwnbdsvr/Makefile

This file was deleted.

55 changes: 0 additions & 55 deletions modules/network/lwnbdsvr/README.md

This file was deleted.

43 changes: 0 additions & 43 deletions modules/network/lwnbdsvr/drivers/atad_d.c

This file was deleted.

Loading

0 comments on commit 7476010

Please sign in to comment.