summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--Readme.md89
-rw-r--r--UNLICENSE24
-rw-r--r--main.c3
4 files changed, 118 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index cc86136..b76ec19 100644
--- a/Makefile
+++ b/Makefile
@@ -1,3 +1,5 @@
+# SPDX-License-Identifier: Unlicense
+
CFLAGS=-Wall -Wextra -Wstrict-prototypes
main:
diff --git a/Readme.md b/Readme.md
index e69de29..fb77c9a 100644
--- a/Readme.md
+++ b/Readme.md
@@ -0,0 +1,89 @@
+# Dualshock 4 Keyboard
+> Use your DS4 gamepad as a keyboard with touchpad while laying on the couch!
+
+This is a proof of concept implementation of virtual keyboard device that
+enables you to press any of these keyboard buttons with Dualshock 4 gamepad. It
+currently words only on Linux and have non-trivial way to set up and run.
+
+## Installation on Linux
+
+You will need a C compiler (GCC or Clang) and `make` utility. Download and
+unpack zip archive of this repo or clone it with git. Then run the following
+from the root of the downloaded repo directory:
+
+```
+make
+```
+
+It will produce a binary named `main`.
+
+## Run
+
+First of all you need to be able to open `/dev/uinput` as a user, unless you
+decided to do everything from root. Do this for your `user` as root if you want
+to be able to run the virtual keyboard as user:
+
+```
+chown user:user /dev/uinput
+```
+
+### USB
+
+Open up a file `/proc/bus/input/events` with some text editor or viewer. For example:
+
+```
+less /proc/bus/input/devices
+```
+
+Then find there an entry for `"Sony Interactive Entertainment Wireless Controller"`. It will look like this:
+
+```
+I: Bus=0003 Vendor=054c Product=09cc Version=8111
+N: Name="Sony Interactive Entertainment Wireless Controller"
+P: Phys=usb-0000:02:00.0-1.4.2.4/input3
+S: Sysfs=/devices/pci0000:00/0000:00:01.2/0000:02:00.0/usb1/1-1/1-1.4/1-1.4.2/1-1.4.2.4/1-1.4.2.4:1.3/0003:054C:09CC.000B/input/input27
+U: Uniq=d0:bc:c1:a2:be:9f
+H: Handlers=js0 event23
+B: PROP=0
+B: EV=1b
+B: KEY=7fdb000000000000 0 0 0 0
+B: ABS=3003f
+B: MSC=10
+```
+
+If you don't see any entries for "Sony Interactive Entertainment something something..." and you are sure your USB cable is good, then go mess around with your kernel and find a way to enable DS4 support in the kernel.
+
+The line `H: Handlers=js0 event23` is what wee need. `event23` is the gamepad device. You may end up with different event number. You must use it in the following commands instead of `event23`.
+
+Once again, if you are planning to use virtual keyboard as `user`, run this as root:
+
+```
+chown oxore:oxore -R /dev/input/event23
+```
+
+Then run the program like this:
+
+```
+./main /dev/input/event23
+```
+
+### Bluetooth
+
+TODO: Describe how to run when the gamepad is connected via Bluetooth
+
+## Usage
+
+Now you can issue keyboard keypresses by pressing some combinations of the gamepad buttons as shown in the following chart:
+
+![Key mapping](layout.svg)
+
+## Meta
+
+Authors:
+- Vladimir Novikov – oxore@protonmail.com
+
+This is free and unencumbered software released into the public domain. See
+``UNLICENSE`` for more information.
+
+<!-- Markdown link & img dfn's -->
+[readme-template]: https://github.com/dbader/readme-template
diff --git a/UNLICENSE b/UNLICENSE
new file mode 100644
index 0000000..68a49da
--- /dev/null
+++ b/UNLICENSE
@@ -0,0 +1,24 @@
+This is free and unencumbered software released into the public domain.
+
+Anyone is free to copy, modify, publish, use, compile, sell, or
+distribute this software, either in source code form or as a compiled
+binary, for any purpose, commercial or non-commercial, and by any
+means.
+
+In jurisdictions that recognize copyright laws, the author or authors
+of this software dedicate any and all copyright interest in the
+software to the public domain. We make this dedication for the benefit
+of the public at large and to the detriment of our heirs and
+successors. We intend this dedication to be an overt act of
+relinquishment in perpetuity of all present and future rights to this
+software under copyright law.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+For more information, please refer to <http://unlicense.org/>
diff --git a/main.c b/main.c
index 44ab4fe..33bf1b1 100644
--- a/main.c
+++ b/main.c
@@ -1,3 +1,6 @@
+/* SPDX-License-Identifier: Unlicense
+ */
+
#include <linux/uinput.h>
#include <unistd.h>
#include <fcntl.h>