Skip to content
This repository was archived by the owner on Dec 12, 2017. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
c49680a
implemented and tested osx sierra fix
willoftw Jul 16, 2017
872bef0
Added basic .gitignore file with some custom exceptions
maephisto666 Dec 3, 2018
4cc0039
Minor changes to Readme.md and more generic way of describing a mappi…
maephisto666 Dec 3, 2018
7ab99ac
Minor changes to Readme.md for OS compatibility list
maephisto666 Dec 3, 2018
a304a24
Better example for mapping keys
maephisto666 Dec 3, 2018
c52ed37
Merge pull request #1 from maephisto666/feature/polishing-the-diamond
willoftw Dec 8, 2018
ff35403
Add only keyboard config
Jun 5, 2019
2da4956
Remap keys
Jun 7, 2019
a37da0c
Final mapping I guess
Jun 7, 2019
7272c86
Silence terminal output
Jun 14, 2019
a4884c9
Update Readme.md
Jun 19, 2019
abc6f35
Add KeyMapping image
Jun 19, 2019
3d4396b
Update Readme.md
Jun 19, 2019
5135ce8
Update Readme.md
Jun 19, 2019
bcfeb5a
Update Readme.md
Jun 19, 2019
971833c
Update only_keyboard.se file
Jun 19, 2019
8d30faa
Update Readme.md
Jun 19, 2019
68c5781
Update Readme.md
Jun 19, 2019
0b347a9
Merge pull request #2 from backslash-f/master
willoftw Apr 6, 2020
88a2e83
Set python2 as the default
Oct 28, 2020
05d0297
Update Readme.md
Oct 28, 2020
f0a4f30
Update Readme.md
Nov 12, 2020
6005383
fixed readme issues
Jan 19, 2021
79a8bd7
working towards 3.6 implementation
Jan 19, 2021
b117207
updated prints
Jan 19, 2021
59f909a
Merge pull request #3 from backslash-f/master
willoftw Jan 19, 2021
e14bcf5
working python3 implementation
Jan 19, 2021
cd54aa8
Merge branch 'feature/python3'
Jan 19, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
211 changes: 211 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@

# Created by https://www.gitignore.io/api/python,objective-c,visualstudiocode
# Edit at https://www.gitignore.io/?templates=python,objective-c,visualstudiocode

### Objective-C ###
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore

## Build generated
build/
DerivedData/

## Various settings
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata/

## Other
*.moved-aside
*.xccheckout
*.xcscmblueprint

## Obj-C/Swift specific
*.hmap
*.ipa
*.dSYM.zip
*.dSYM

# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
# Pods/
#
# Add this line if you want to avoid checking in source code from the Xcode workspace
# *.xcworkspace

# Carthage
#
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts

Carthage/Build

# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/#source-control

fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots/**/*.png
fastlane/test_output

# Code Injection
#
# After new code Injection tools there's a generated folder /iOSInjectionProject
# https://github.com/johnno1962/injectionforxcode

iOSInjectionProject/

### Objective-C Patch ###

### Python ###
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

### Python Patch ###
.venv/

### VisualStudioCode ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

### VisualStudioCode Patch ###
# Ignore all local history of files
.history

# End of https://www.gitignore.io/api/python,objective-c,visualstudiocode

### Custom exclusions ###

# Ignore all files generated after a successful build
iohid_wrap.dylib
mapKeys.h
Binary file added KeyMapping.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added KeyMapping.sketch
Binary file not shown.
42 changes: 29 additions & 13 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,36 @@
Setup
=====
[![macos-catalina](https://img.shields.io/badge/macos-catalina-brightgreen.svg)](https://www.apple.com/macos/catalina-preview)
[![macos-mojave](https://img.shields.io/badge/macos-mojave-brightgreen.svg)](https://www.apple.com/lae/macos/mojave)

ShockEmu requires the OS X command line development tools to be installed. Installation steps:
# Key Mapping
`only_keyboard.se` goes like this:

git clone https://github.com/daeken/ShockEmu.git
./build.sh <filename>.se
./run.sh
![Key Mapping](https://github.com/backslash-f/ShockEmu/blob/master/KeyMapping.png)

It depends on your system having PS4 Remote Play installed at `/Applications/RemotePlay.app`. If this is not the case, you'll need to modify `run.sh` accordingly.
# Setup
```zsh
./build.sh only_keyboard.se
./run.sh
```

SE file format
==============
It depends on your system having [PS4 Remote Play](https://remoteplay.dl.playstation.net/remoteplay/lang/en/index.html) installed at `/Applications/RemotePlay.app`. If this is not the case, you'll need to modify `run.sh` accordingly.

SE files are, generally speaking, a mapping between an input key, mouse button, or mouse movement to a DualShock 4 input. See the example file (`nomanssky.se`) for a breakdown of the format.
The `OS X Command Line Tools` needs [to be installed](https://stackoverflow.com/a/53078282/584548).

How it works
============
Relies on `python2` (see #2), which can be installed via `brew install python@2`

ShockEmu works by intercepting the IOHID calls of PS4 Remote Play application and presents an emulated DualShock controller. It also hooks into the input routines of the application, to catch keyboard and mouse inputs, which then get mapped according to your SE file.
# SE File Format
SE files are, generally speaking, a mapping between an input key, mouse button, or mouse movement to a DualShock 4 input. See the example file (`example.se`) for a breakdown of the format.

# How It Works
ShockEmu works by intercepting the IOHID calls of PS4 Remote Play application and presents an emulated DualShock controller. It also hooks into the input routines of the application, to catch keyboard and mouse inputs, which then get mapped according to your SE file.

# But It Is Not Working!
You may have to [turn off System Integrity Protection via 'csrutil'](https://www.imore.com/how-turn-system-integrity-protection-macos) in order for `DYLD_INSERT_LIBRARIES` to function on the newest macOS. Thanks [Ben](https://github.com/benh57) for figuring this out!

# Pro Tip
The `alias` below allows for typing `play` / `enter` anywhere in `Terminal` and have `RemotePlay.app` launched with the above keys mapped:
```
$ cat ~/.zshrc | grep play
alias play="pushd [REPOSITORY_ROOT]; ./run.sh &; popd"
```
👆🏻`ShockEmu` repo location must be updated according to your machine.
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash

python shockemu.py $1
python2 shockemu.py $1
clang -dynamiclib -std=gnu99 iohid_wrap.m -current_version 1.0 -compatibility_version 1.0 -lobjc -framework Foundation -framework AppKit -framework CoreFoundation -o iohid_wrap.dylib
22 changes: 11 additions & 11 deletions nomanssky.se → example.se
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
# Map movement controls to the left stick
# Map movement controls to the left stick. The same can be done using 'right' instead of 'left'.
w = leftY-
a = leftX-
s = leftY+
d = leftX+

space = X
e = square
y = X
u = square
i = O
o = triangle

leftMouse = R2
rightMouse = L1
g = R1
h = R2
leftMouse = L1
rightMouse = L2

x = L2
p = PS
t = touchpad

up = dpadUp
left = dpadLeft
right = dpadRight
down = dpadDown

p = PS
t = touchpad

escape = O

# Map mouse to the right stick
mouseLook.type = linear # 1:1 translation mode, no curve
mouseLook.stick = right
Expand Down
2 changes: 1 addition & 1 deletion iohid_wrap.m
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ - (void)tick {
prep->left_y = (uint8_t) fmin(fmax(128 + leftY * 127, 0), 255);
prep->right_x = (uint8_t) fmin(fmax(128 + rightX * 127, 0), 255);
prep->right_y = (uint8_t) fmin(fmax(128 + rightY * 127, 0), 255);
callback(context, kIOReturnSuccess, self, kIOHIDReportTypeInput, 1, report, 64);
callback(context, kIOReturnSuccess, (void *)0xDEADBEEF, kIOHIDReportTypeInput, 0x01, report, 64);

ticks++;
}
Expand Down
32 changes: 32 additions & 0 deletions only_keyboard.se
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Map movement controls to the left stick. The same can be done using 'right' instead of 'left'.

e = L2
q = L1

w = leftY-
a = leftX-
s = leftY+
d = leftX+

up = dpadUp
left = dpadLeft
right = dpadRight
down = dpadDown

t = PS
space = touchpad
1 = share
0 = options

u = R2
o = R1

i = rightY-
j = rightX-
k = rightY+
l = rightX+

f = square
c = X
h = triangle
n = O
2 changes: 1 addition & 1 deletion run.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash

DYLD_FORCE_FLAT_NAMESPACE=1 DYLD_INSERT_LIBRARIES=iohid_wrap.dylib /Applications/RemotePlay.app/Contents/MacOS/RemotePlay
DYLD_FORCE_FLAT_NAMESPACE=1 DYLD_INSERT_LIBRARIES=iohid_wrap.dylib /Applications/RemotePlay.app/Contents/MacOS/RemotePlay >/dev/null 2>&1
2 changes: 1 addition & 1 deletion shockemu.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,4 @@ def parse(data):
{stick}X = {stick}Y = 0;
}}'''.format(**mouseLook)
else:
print 'Unknown mouseLook type:', mouseLook
print 'Unknown mouseLook type:', mouseLook
Loading