Skip to content

Commit

Permalink
discovery + DualShock4/DualSense directions
Browse files Browse the repository at this point in the history
Notable Things:
- Updated chiaki discovery cli to finish properly or timeout
- Updated automation to use improved discovery cli, fixing timing issues
- Automation now works for users without ping access to console
- DualShock4/DualSense udev rules + instructions for native gyro/touchpad
- Updated documentation to reflect changes + added releases section & banner

Fixes #2
  • Loading branch information
streetpea committed Sep 14, 2022
1 parent f99c093 commit fc92f5e
Show file tree
Hide file tree
Showing 26 changed files with 629 additions and 116 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ set(CHIAKI_VERSION_PATCH 1)
set(CHIAKI_VERSION ${CHIAKI_VERSION_MAJOR}.${CHIAKI_VERSION_MINOR}.${CHIAKI_VERSION_PATCH})

set(CPACK_PACKAGE_NAME "chiaki4deck")
set(CPACK_PACKAGE_DESCRIPTION "Open Source PS4 remote play client")
set(CPACK_PACKAGE_DESCRIPTION "Open Source PlayStation Remote Play client")
set(CPACK_PACKAGE_VERSION_MAJOR ${CHIAKI_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${CHIAKI_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${CHIAKI_VERSION_PATCH})
Expand Down
32 changes: 27 additions & 5 deletions cli/src/discover.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,21 @@
#include <string.h>
#include <netinet/in.h>

static char doc[] = "Send a PS4 discovery request.";
static char doc[] = "Send a PS4 or PS5 discovery request.";

#define ARG_KEY_HOST 'h'
#define ARG_KEY_TIMEOUT 't'

static struct argp_option options[] = {
{ "host", ARG_KEY_HOST, "Host", 0, "Host to send discovery request to", 0 },
{ "timeout", ARG_KEY_TIMEOUT, "Timeout", 0, "Number of seconds to wait for request to return (default=2)", 0},
{ 0 }
};

typedef struct arguments
{
const char *host;
const char *timeout;
} Arguments;

static int parse_opt(int key, char *arg, struct argp_state *state)
Expand All @@ -34,6 +37,9 @@ static int parse_opt(int key, char *arg, struct argp_state *state)
case ARG_KEY_HOST:
arguments->host = arg;
break;
case ARG_KEY_TIMEOUT:
arguments->timeout = arg;
break;
case ARGP_KEY_ARG:
argp_usage(state);
break;
Expand Down Expand Up @@ -84,6 +90,7 @@ static void discovery_cb(ChiakiDiscoveryHost *host, void *user)
CHIAKI_EXPORT int chiaki_cli_cmd_discover(ChiakiLog *log, int argc, char *argv[])
{
Arguments arguments = { 0 };
float timeout_sec = 2;
error_t argp_r = argp_parse(&argp, argc, argv, ARGP_IN_ORDER, NULL, &arguments);
if(argp_r != 0)
return 1;
Expand All @@ -94,6 +101,11 @@ CHIAKI_EXPORT int chiaki_cli_cmd_discover(ChiakiLog *log, int argc, char *argv[]
return 1;
}

if(arguments.timeout)
{
timeout_sec = atof(arguments.timeout);
}

ChiakiDiscovery discovery;
ChiakiErrorCode err = chiaki_discovery_init(&discovery, log, AF_INET); // TODO: IPv6
if(err != CHIAKI_ERR_SUCCESS)
Expand All @@ -103,7 +115,7 @@ CHIAKI_EXPORT int chiaki_cli_cmd_discover(ChiakiLog *log, int argc, char *argv[]
}

ChiakiDiscoveryThread thread;
err = chiaki_discovery_thread_start(&thread, &discovery, discovery_cb, NULL);
err = chiaki_discovery_thread_start_oneshot(&thread, &discovery, discovery_cb, NULL);
if(err != CHIAKI_ERR_SUCCESS)
{
CHIAKI_LOGE(log, "Discovery thread init failed");
Expand Down Expand Up @@ -155,9 +167,19 @@ CHIAKI_EXPORT int chiaki_cli_cmd_discover(ChiakiLog *log, int argc, char *argv[]
err = chiaki_discovery_send(&discovery, &packet, host_addr, host_addr_len);
if(err != CHIAKI_ERR_SUCCESS)
CHIAKI_LOGE(log, "Failed to send discovery packet for PS5: %s", chiaki_error_string(err));

while(1)
sleep(1); // TODO: wtf
uint64_t timeout_ms=(timeout_sec * 1000);
err = chiaki_thread_timedjoin(&thread.thread, NULL, timeout_ms);
if(err != CHIAKI_ERR_SUCCESS)
{
if(err == CHIAKI_ERR_TIMEOUT)
{
CHIAKI_LOGE(log, "Discovery request timed out after timeout: %.*f seconds", 1, timeout_sec);
chiaki_discovery_thread_stop(&thread);
}
chiaki_discovery_fini(&discovery);
return err;
}
chiaki_discovery_fini(&discovery);

return 0;
}
2 changes: 1 addition & 1 deletion cli/src/wakeup.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <argp.h>
#include <string.h>

static char doc[] = "Send a PS4 wakeup packet.";
static char doc[] = "Send a PS4 or PS5 wakeup packet.";

#define ARG_KEY_HOST 'h'
#define ARG_KEY_REGISTKEY 'r'
Expand Down
32 changes: 32 additions & 0 deletions doc/71-chiaki4deck.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Enable access to Touchpad and accelerometer (gyro) for DualShock4 & DualSense controllers for PlayStation Remote Play
# DualShock 4
# USB
SUBSYSTEM=="input", ATTRS{idVendor}=="054c", ATTRS{idProduct}=="05c4", ENV{ID_INPUT_TOUCHPAD}=="?*", TAG+="uaccess"
SUBSYSTEM=="input", ATTRS{idVendor}=="054c", ATTRS{idProduct}=="05c4", ENV{ID_INPUT_ACCELEROMETER}=="?*", TAG+="uaccess"
# Bluetooth
SUBSYSTEM=="input", KERNELS=="*054C:05C4*", ENV{ID_INPUT_TOUCHPAD}=="?*", TAG+="uaccess"
SUBSYSTEM=="input", KERNELS=="*054C:05C4*", ENV{ID_INPUT_ACCELEROMETER}=="?*", TAG+="uaccess"

# DualShock 4 wireless adapter
# USB
SUBSYSTEM=="input", ATTRS{idVendor}=="054c", ATTRS{idProduct}=="0ba0", ENV{ID_INPUT_TOUCHPAD}=="?*", TAG+="uaccess"
SUBSYSTEM=="input", ATTRS{idVendor}=="054c", ATTRS{idProduct}=="0ba0", ENV{ID_INPUT_ACCELEROMETER}=="?*", TAG+="uaccess"
# Bluetooth
SUBSYSTEM=="input", KERNELS=="*054C:0BA0*", ENV{ID_INPUT_TOUCHPAD}=="?*", TAG+="uaccess"
SUBSYSTEM=="input", KERNELS=="*054C:0BA0*", ENV{ID_INPUT_ACCELEROMETER}=="?*", TAG+="uaccess"

# DualShock 4 Slim
# USB
SUBSYSTEM=="input", ATTRS{idVendor}=="054c", ATTRS{idProduct}=="09cc", ENV{ID_INPUT_TOUCHPAD}=="?*", TAG+="uaccess"
SUBSYSTEM=="input", ATTRS{idVendor}=="054c", ATTRS{idProduct}=="09cc", ENV{ID_INPUT_ACCELEROMETER}=="?*", TAG+="uaccess"
# Bluetooth
SUBSYSTEM=="input", KERNELS=="*054C:09CC*", ENV{ID_INPUT_TOUCHPAD}=="?*", TAG+="uaccess"
SUBSYSTEM=="input", KERNELS=="*054C:09CC*", ENV{ID_INPUT_ACCELEROMETER}=="?*", TAG+="uaccess"

# PS5 DualSense controller
# USB
SUBSYSTEM=="input", ATTRS{idVendor}=="054c", ATTRS{idProduct}=="0ce6", ENV{ID_INPUT_TOUCHPAD}=="?*", TAG+="uaccess"
SUBSYSTEM=="input", ATTRS{idVendor}=="054c", ATTRS{idProduct}=="0ce6", ENV{ID_INPUT_ACCELEROMETER}=="?*", TAG+="uaccess"
# Bluetooth
SUBSYSTEM=="input", KERNELS=="*054C:0CE6*", ENV{ID_INPUT_TOUCHPAD}=="?*", TAG+="uaccess"
SUBSYSTEM=="input", KERNELS=="*054C:0CE6*", ENV{ID_INPUT_ACCELEROMETER}=="?*", TAG+="uaccess"
4 changes: 4 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

Start by visiting the [Setup section](setup/index.md){target="_blank" rel="noopener noreferrer"} and following each of the subsections to learn how to setup Chiaki for the best experience on your Steam Deck using `chiaki4deck`.

## Getting Updates

Visit [chiaki4deck Releases](updates/releases.md){target="_blank" rel="noopener noreferrer"} for instructions on updating to the newest release, with notes for each release.

## Additional Information

### About Chiaki
Expand Down
Loading

0 comments on commit fc92f5e

Please sign in to comment.