Skip to content

Commit

Permalink
Wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
p-sam committed Dec 17, 2017
1 parent e3dfcdd commit e6802b2
Show file tree
Hide file tree
Showing 10 changed files with 85 additions and 12 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*.dylib
.DS_Store
.DS_Store
!out/.keep
out/*
20 changes: 16 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Spoof OSX version of PS4 Remote play into thinking that the Hori Mini Wired Gamepad is a Dualshock 4 controller.

## Getting Started
## Building

### Prerequisites

Expand All @@ -13,17 +13,29 @@ You need to have the official PS4 Remote play, and XCode Command Line Tools inst
```
git clone https://github.com/sperrichon/hori-mini-wired-gamepad-remote-play
cd hori-mini-wired-gamepad-remote-play
./build.sh
./build/compile-lib.sh # out/iohid_wrap.dylib created
```

If everything went well, run this script to launch Remote Play:
### Testing

If everything went well, run this script to test Remote Play:

```
./run.sh
./build/run.sh
```

**Note**: The script assumes Remote play is installed at `/Applications/RemotePlay.app`. If this is not the case, you'll need to modify run.sh accordingly.

### Creating wrapper

Once compiled, you can create a wrapper which makes running Remote Play more comfortable

```
./build/make-wrapper.sh # out/RemotePlayWrapper.app created
```

The wrapper searches for RemotePlay.app first in its own `Contents/Resources` folder, and fallbacks to `/Applications`

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details
Expand Down
3 changes: 0 additions & 3 deletions build.sh

This file was deleted.

4 changes: 4 additions & 0 deletions build/compile-lib.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
PROJECT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/.." || exit 1

exec clang -dynamiclib -std=gnu99 "$PROJECT_DIR/iohid_wrap.m" -current_version 1.0 -compatibility_version 1.0 -lobjc -framework Foundation -framework AppKit -framework CoreFoundation -o "$PROJECT_DIR/out/iohid_wrap.dylib"
18 changes: 18 additions & 0 deletions build/make-wrapper.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
PROJECT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/.." || exit 1

if [ ! -f "$PROJECT_DIR/out/iohid_wrap.dylib" ]; then
echo "Compiled lib not found" 1>&2
exit 1
fi

APP_NAME="RemotePlayWrapper.app"
APP_PATH="$PROJECT_DIR/out/$APP_NAME"

rm -rf "$APP_PATH" &> /dev/null
cp -r "$PROJECT_DIR/wrapper_skel" "$APP_PATH" || exit 1
chmod a+x "$APP_PATH/Contents/MacOS/RemotePlayWrapper"
cp "$PROJECT_DIR/out/iohid_wrap.dylib" "$APP_PATH/Contents/Resources/iohid_wrap.dylib" || exit 1

echo "Wrapper created at '$APP_PATH'."
echo "You copy RemotePlay.app into the the Contents/Resources folder inside the wrapper. It will default to use the one installed in /Applications"
4 changes: 4 additions & 0 deletions build/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
PROJECT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/.." || exit 1

DYLD_FORCE_FLAT_NAMESPACE=1 DYLD_INSERT_LIBRARIES="$PROJECT_DIR/out/iohid_wrap.dylib" /Applications/RemotePlay.app/Contents/MacOS/RemotePlay
3 changes: 0 additions & 3 deletions run.sh

This file was deleted.

12 changes: 12 additions & 0 deletions wrapper_skel/Contents/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleExecutable</key>
<string>RemotePlayWrapper</string>
<key>CFBundleIconFile</key>
<string>AppIcon.icns</string>
<key>CFBundleName</key>
<string>RemotePlayWrapper</string>
</dict>
</plist>
28 changes: 28 additions & 0 deletions wrapper_skel/Contents/MacOS/RemotePlayWrapper
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash
function die {
osascript -e "tell application (path to frontmost application as text) to display dialog \"$1\" buttons {\"OK\"} with icon stop"
exit 1
}

RESOURCES_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/../Resources"

IOHID_WRAP_DYLIB_PATH="$RESOURCES_DIR/iohid_wrap.dylib"

if [ ! -f "$IOHID_WRAP_DYLIB_PATH" ]; then
die "$IOHID_WRAP_DYLIB_PATH could not be found"
fi

export DYLD_FORCE_FLAT_NAMESPACE=1
export DYLD_INSERT_LIBRARIES="$IOHID_WRAP_DYLIB_PATH"

EXE_PATH="./Contents/MacOS/RemotePlay"

APP_PATH="$RESOURCES_DIR/RemotePlay.app"
if [ ! -x "$APP_PATH/$EXE_PATH" ]; then
APP_PATH="/Applications/RemotePlay.app"
fi

if [ ! -x "$APP_PATH/$EXE_PATH" ]; then
die "RemotePlay.app was not found in Resources nor in /Applications"
fi
exec "$APP_PATH/$EXE_PATH"
Binary file added wrapper_skel/Contents/Resources/AppIcon.icns
Binary file not shown.

0 comments on commit e6802b2

Please sign in to comment.