Skip to content

Commit

Permalink
Merge pull request #312 from thp/moved-v2
Browse files Browse the repository at this point in the history
New move daemon and macOS monitoring improvements
  • Loading branch information
thp committed Sep 10, 2017
2 parents 4d5a1d9 + 9545934 commit 3816435
Show file tree
Hide file tree
Showing 24 changed files with 1,215 additions and 432 deletions.
4 changes: 2 additions & 2 deletions docs/build.rst
Expand Up @@ -117,8 +117,8 @@ To build manually without the tracker::

Or use the ready-made build script::

sh -x scripts/mingw64/cross-compile x86_64-w64-mingw32
sh -x scripts/mingw64/cross-compile i686-w64-mingw32
bash -x scripts/mingw64/cross-compile x86_64-w64-mingw32
bash -x scripts/mingw64/cross-compile i686-w64-mingw32



Expand Down
12 changes: 8 additions & 4 deletions docs/moved.rst
Expand Up @@ -11,20 +11,24 @@ with 20 move controllers distributed over 3 PCs.

.. _`Edgar Rice Soiree`: http://thp.io/2012/tarzan/

moved_hosts.txt
---------------
moved2_hosts.txt
----------------

You need to place a file "moved_hosts.txt" into the data directory of PS Move
You need to place a file "moved2_hosts.txt" into the data directory of PS Move
API (usually ~/.psmoveapi/, in Windows %APPDATA%/.psmoveapi/) with one IP
address per line that points to a moved instance.

Example moved_hosts.txt contents::
Example moved2_hosts.txt contents::

192.168.0.2

This would try to use the moved running on 192.168.0.2. You can have multiple
IPs listed there (one per line), the servers will be tried in order.

If you add * on a single line, this will enable local network auto-discovery,
meaning that any running Move Daemon instances can be auto-discovered via UDP
broadcast.


API Usage
---------
Expand Down
16 changes: 2 additions & 14 deletions examples/c/example_new_api.cpp
Expand Up @@ -36,13 +36,10 @@


struct ExampleHandler : public psmoveapi::Handler {
ExampleHandler() : color{0.f, 0.f, 0.f} , bt_controllers(0), rumble(0.f), quit(false), interactive(false) {}
ExampleHandler() : color{0.f, 0.f, 0.f} , rumble(0.f), interactive(false) {}

virtual void connect(Controller *controller) {
printf("Connect: %s\n", controller->serial);
if (controller->bluetooth) {
bt_controllers++;
}
}

virtual void update(Controller *controller) {
Expand All @@ -64,23 +61,14 @@ struct ExampleHandler : public psmoveapi::Handler {
printf("Magnetometer: %.2f, %.2f, %.2f\n", controller->magnetometer.x, controller->magnetometer.y, controller->magnetometer.z);
printf("Connection [%c] USB [%c] Bluetooth; Buttons: 0x%04x\n", controller->usb ? 'x' : ' ', controller->bluetooth ? 'x' : ' ', controller->buttons);
}

if ((controller->buttons & Btn_PS) != 0) {
quit = true;
}
}

virtual void disconnect(Controller *controller) {
printf("Disconnect: %s\n", controller->serial);
if (controller->bluetooth) {
bt_controllers--;
}
}

RGB color;
int bt_controllers;
float rumble;
bool quit;
bool interactive;
};

Expand Down Expand Up @@ -108,7 +96,7 @@ main(int argc, char* argv[])
api.update();

handler.interactive = true;
while (handler.bt_controllers > 0 && !handler.quit) {
while (true) {
api.update();
}

Expand Down
16 changes: 11 additions & 5 deletions examples/c/moved_client_test.c
Expand Up @@ -33,21 +33,27 @@
int main(int argc, char *argv[])
{
moved_client *client = moved_client_create("127.0.0.1");
int connected = moved_client_send(client, MOVED_REQ_COUNT_CONNECTED, 0, NULL);

if (moved_client_send(client, MOVED_REQ_COUNT_CONNECTED, 0, NULL, 0) == 0) {
printf("Could not send count connected\n");
}

int i;

int connected = client->response_buf.count_connected.count;

printf("Connected: %d\n", connected);
unsigned char output[] = {2, 0, 255, 255, 0, 0, 0};

for (i=0; i<connected; i++) {
printf("Writing to dev %d...\n", i);
moved_client_send(client, MOVED_REQ_WRITE, i, output);
moved_client_send(client, MOVED_REQ_SET_LEDS, i, output, sizeof(output));
}

if (moved_client_send(client, MOVED_REQ_READ, 0, NULL)) {
if (moved_client_send(client, MOVED_REQ_READ_INPUT, 0, NULL, 0)) {
printf("====================\n");
for (i=0; i<MOVED_SIZE_READ_RESPONSE; i++) {
printf("%02x ", client->read_response_buf[i]);
for (i=0; i<sizeof(client->response_buf); i++) {
printf("%02x ", client->response_buf.bytes[i]);
}
printf("\n====================\n");
}
Expand Down
12 changes: 7 additions & 5 deletions src/CMakeLists.txt
Expand Up @@ -74,7 +74,9 @@ IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -stdlib=libc++")
set(CMAKE_STATIC_LIBRARY_FLAGS "${CMAKE_STATIC_LIBRARY_FLAGS} -stdlib=libc++")


list(APPEND PSMOVEAPI_MOVED_SRC
${CMAKE_CURRENT_LIST_DIR}/daemon/moved_monitor_osx.mm)
ELSEIF(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
list(APPEND PSMOVEAPI_REQUIRED_LIBS setupapi bthprops kernel32 ws2_32 winmm version imm32)

Expand All @@ -89,7 +91,6 @@ ELSEIF(${CMAKE_SYSTEM_NAME} MATCHES "Windows")

list(APPEND PSMOVEAPI_PLATFORM_SRC
${CMAKE_CURRENT_LIST_DIR}/platform/psmove_port_windows.c)

ELSE()
# Linux
find_package(PkgConfig REQUIRED)
Expand Down Expand Up @@ -119,6 +120,8 @@ ELSE()
list(APPEND PSMOVEAPI_PLATFORM_SRC
${CMAKE_CURRENT_LIST_DIR}/platform/psmove_port_linux.c)

list(APPEND PSMOVEAPI_MOVED_SRC
${CMAKE_CURRENT_LIST_DIR}/daemon/moved_monitor_linux.c)
ENDIF()

include_directories(${ROOT_DIR}/include)
Expand All @@ -128,9 +131,8 @@ configure_file(${ROOT_DIR}/include/psmove_config.h.in
@ONLY)


file(GLOB PSMOVEAPI_MOVED_SRC
"${CMAKE_CURRENT_LIST_DIR}/daemon/*.c"
)
list(APPEND PSMOVEAPI_MOVED_SRC
"${CMAKE_CURRENT_LIST_DIR}/daemon/moved_client.cpp")

file(GLOB PSMOVEAPI_MOVED_HEADER
"${CMAKE_CURRENT_LIST_DIR}/daemon/*.h"
Expand Down

0 comments on commit 3816435

Please sign in to comment.