diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2015-10-29 11:05:27 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2015-10-29 11:05:27 +0100 |
commit | 232c2ba8aca7900eaa950c48813ddfaca8a749a8 (patch) | |
tree | c08da2e256be5b5e80fac3f611f956fef275f142 | |
parent | 7128fe581ee2ed25fe8e43ec2be9644e2539e2ad (diff) | |
parent | 06a0a71f27134a86d19612fd786bfc2ca6f4c4bb (diff) |
Merge branch 'unstable' into trackhat
* unstable:
fix vtable mess
xargs sed -i -e s/'FaceTrackNoIR Error/Error/g'
support rift 0.2.5, 0.4.2, 0.8.0
rift: finish 0.2.5 support
buffer flush
rename "clientfiles/" to "contrib/" as customary
add dropbox uploader to contrib
add description on wiki for camera offset
-rwxr-xr-x | CMakeLists.txt | 18 | ||||
-rw-r--r-- | cmake/mingw-w64.cmake | 2 | ||||
-rw-r--r-- | contrib/FlightGear/Protocol/headtracker.xml (renamed from clientfiles/FlightGear/Protocol/headtracker.xml) | 0 | ||||
-rw-r--r-- | contrib/FlightGear/readme.txt (renamed from clientfiles/FlightGear/readme.txt) | 0 | ||||
-rw-r--r-- | contrib/Tir4Fun/npclient.dll (renamed from clientfiles/Tir4Fun/npclient.dll) | bin | 53248 -> 53248 bytes | |||
-rw-r--r-- | contrib/Tir4Fun/readme.txt (renamed from clientfiles/Tir4Fun/readme.txt) | 0 | ||||
-rw-r--r-- | contrib/Tir4Fun/tir4fun.exe (renamed from clientfiles/Tir4Fun/tir4fun.exe) | bin | 36864 -> 36864 bytes | |||
-rw-r--r-- | contrib/aruco/aruco_create_marker.exe (renamed from clientfiles/aruco/aruco_create_marker.exe) | bin | 826368 -> 826368 bytes | |||
-rw-r--r-- | contrib/aruco/test3.jpg (renamed from clientfiles/aruco/test3.jpg) | bin | 2145 -> 2145 bytes | |||
-rw-r--r-- | contrib/cfs3/readme.txt (renamed from clientfiles/cfs3/readme.txt) | 0 | ||||
-rw-r--r-- | contrib/cfs3/tirviews.dll (renamed from clientfiles/cfs3/tirviews.dll) | bin | 109568 -> 109568 bytes | |||
-rw-r--r-- | contrib/cute-octopus-vector-material_15-1831.jpg (renamed from clientfiles/cute-octopus-vector-material_15-1831.jpg) | bin | 71514 -> 71514 bytes | |||
-rw-r--r-- | contrib/dropbox-uploader/README | 1 | ||||
-rw-r--r-- | contrib/dropbox-uploader/dropbox_uploader.sh | 1364 | ||||
-rw-r--r-- | contrib/freepie-udp/com.freepie.android.imu.apk (renamed from clientfiles/freepie-udp/com.freepie.android.imu.apk) | bin | 167989 -> 167989 bytes | |||
-rw-r--r-- | contrib/freepie-udp/license.txt (renamed from clientfiles/freepie-udp/license.txt) | 0 | ||||
-rw-r--r-- | contrib/freetracktest/freetracktest.exe (renamed from clientfiles/freetracktest/freetracktest.exe) | bin | 398848 -> 398848 bytes | |||
-rw-r--r-- | contrib/freetracktest/readme.txt (renamed from clientfiles/freetracktest/readme.txt) | 0 | ||||
-rw-r--r-- | contrib/fs2002 and fs2004/fsuipc.dll (renamed from clientfiles/fs2002 and fs2004/fsuipc.dll) | bin | 210880 -> 210880 bytes | |||
-rw-r--r-- | contrib/glovepie/facetracknoir2trackir.pie (renamed from clientfiles/glovepie/facetracknoir2trackir.pie) | 0 | ||||
-rw-r--r-- | contrib/glovepie/readme.txt (renamed from clientfiles/glovepie/readme.txt) | 0 | ||||
-rw-r--r-- | contrib/ppjoy/ppjoy mapping for facetracknoir.jpg (renamed from clientfiles/ppjoy/ppjoy mapping for facetracknoir.jpg) | bin | 155205 -> 155205 bytes | |||
-rw-r--r-- | contrib/ppjoy/readme.txt (renamed from clientfiles/ppjoy/readme.txt) | 0 | ||||
-rw-r--r-- | contrib/very-important-source-code/README-CREDIT.txt (renamed from clientfiles/very-important-source-code/README-CREDIT.txt) | 0 | ||||
-rw-r--r-- | contrib/very-important-source-code/ft_tester/Makefile.am (renamed from clientfiles/very-important-source-code/ft_tester/Makefile.am) | 0 | ||||
-rw-r--r-- | contrib/very-important-source-code/ft_tester/Makefile.in (renamed from clientfiles/very-important-source-code/ft_tester/Makefile.in) | 0 | ||||
-rw-r--r-- | contrib/very-important-source-code/ft_tester/fttester.rc.in (renamed from clientfiles/very-important-source-code/ft_tester/fttester.rc.in) | 0 | ||||
-rw-r--r-- | contrib/very-important-source-code/ft_tester/main.cpp (renamed from clientfiles/very-important-source-code/ft_tester/main.cpp) | 0 | ||||
-rw-r--r-- | contrib/very-important-source-code/ft_tester/resource.h (renamed from clientfiles/very-important-source-code/ft_tester/resource.h) | 0 | ||||
-rw-r--r-- | contrib/very-important-source-code/important-stuff/NPClient.h (renamed from clientfiles/very-important-source-code/important-stuff/NPClient.h) | 0 | ||||
-rw-r--r-- | contrib/very-important-source-code/important-stuff/NPClient.spec (renamed from clientfiles/very-important-source-code/important-stuff/NPClient.spec) | 0 | ||||
-rw-r--r-- | contrib/very-important-source-code/important-stuff/NPClient_dll.h (renamed from clientfiles/very-important-source-code/important-stuff/NPClient_dll.h) | 0 | ||||
-rw-r--r-- | contrib/very-important-source-code/important-stuff/NPClient_main.c (renamed from clientfiles/very-important-source-code/important-stuff/NPClient_main.c) | 0 | ||||
-rw-r--r-- | contrib/very-important-source-code/important-stuff/game_data.c (renamed from clientfiles/very-important-source-code/important-stuff/game_data.c) | 0 | ||||
-rw-r--r-- | contrib/very-important-source-code/important-stuff/game_data.h (renamed from clientfiles/very-important-source-code/important-stuff/game_data.h) | 0 | ||||
-rw-r--r-- | contrib/very-important-source-code/make-csv.pl (renamed from clientfiles/very-important-source-code/make-csv.pl) | 0 | ||||
-rw-r--r-- | contrib/very-important-source-code/npclient.c (renamed from clientfiles/very-important-source-code/npclient.c) | 0 | ||||
-rw-r--r-- | contrib/very-important-source-code/tester/Makefile.am (renamed from clientfiles/very-important-source-code/tester/Makefile.am) | 0 | ||||
-rw-r--r-- | contrib/very-important-source-code/tester/Makefile.in (renamed from clientfiles/very-important-source-code/tester/Makefile.in) | 0 | ||||
-rw-r--r-- | contrib/very-important-source-code/tester/main.cpp (renamed from clientfiles/very-important-source-code/tester/main.cpp) | 0 | ||||
-rw-r--r-- | contrib/very-important-source-code/tester/npifc.c (renamed from clientfiles/very-important-source-code/tester/npifc.c) | 0 | ||||
-rw-r--r-- | contrib/very-important-source-code/tester/npifc.h (renamed from clientfiles/very-important-source-code/tester/npifc.h) | 0 | ||||
-rw-r--r-- | contrib/very-important-source-code/tester/npview.rc.in (renamed from clientfiles/very-important-source-code/tester/npview.rc.in) | 0 | ||||
-rw-r--r-- | contrib/very-important-source-code/tester/resource.h (renamed from clientfiles/very-important-source-code/tester/resource.h) | 0 | ||||
-rw-r--r-- | contrib/vjoy/VJoy.dll (renamed from clientfiles/vjoy/VJoy.dll) | bin | 94208 -> 94208 bytes | |||
-rw-r--r-- | ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp | 8 | ||||
-rw-r--r-- | ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.cpp | 4 | ||||
-rw-r--r-- | ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.h | 2 | ||||
-rw-r--r-- | ftnoir_tracker_rift_025/ftnoir_rift_025.qrc (renamed from ftnoir_tracker_rift/ftnoir_rift.qrc) | 0 | ||||
-rw-r--r-- | ftnoir_tracker_rift_025/ftnoir_rift_clientcontrols_025.ui (renamed from ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui) | 0 | ||||
-rw-r--r-- | ftnoir_tracker_rift_025/ftnoir_tracker_rift_025.cpp | 92 | ||||
-rw-r--r-- | ftnoir_tracker_rift_025/ftnoir_tracker_rift_025.h | 63 | ||||
-rw-r--r-- | ftnoir_tracker_rift_025/ftnoir_tracker_rift_dialog_025.cpp | 26 | ||||
-rw-r--r-- | ftnoir_tracker_rift_025/images/medium.png (renamed from ftnoir_tracker_rift/images/medium.png) | bin | 5764 -> 5764 bytes | |||
-rw-r--r-- | ftnoir_tracker_rift_025/images/rift_medium.png (renamed from ftnoir_tracker_rift/images/rift_medium.png) | bin | 5764 -> 5764 bytes | |||
-rw-r--r-- | ftnoir_tracker_rift_025/images/rift_small.png (renamed from ftnoir_tracker_rift/images/rift_small.png) | bin | 1212 -> 1212 bytes | |||
-rw-r--r-- | ftnoir_tracker_rift_025/images/rift_tiny.png (renamed from ftnoir_tracker_rift/images/rift_tiny.png) | bin | 624 -> 624 bytes | |||
-rw-r--r-- | ftnoir_tracker_rift_025/images/small.png (renamed from ftnoir_tracker_rift/images/small.png) | bin | 1212 -> 1212 bytes | |||
-rw-r--r-- | ftnoir_tracker_rift_025/images/tiny.png (renamed from ftnoir_tracker_rift/images/tiny.png) | bin | 624 -> 624 bytes | |||
-rw-r--r-- | ftnoir_tracker_rift_042/ftnoir_rift_042.qrc | 7 | ||||
-rw-r--r-- | ftnoir_tracker_rift_042/ftnoir_rift_clientcontrols_042.ui | 176 | ||||
-rw-r--r-- | ftnoir_tracker_rift_042/ftnoir_tracker_rift_042.cpp (renamed from ftnoir_tracker_rift/ftnoir_tracker_rift.cpp) | 4 | ||||
-rw-r--r-- | ftnoir_tracker_rift_042/ftnoir_tracker_rift_042.h | 60 | ||||
-rw-r--r-- | ftnoir_tracker_rift_042/ftnoir_tracker_rift_dialog_042.cpp (renamed from ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp) | 2 | ||||
-rw-r--r-- | ftnoir_tracker_rift_042/images/medium.png | bin | 0 -> 5764 bytes | |||
-rw-r--r-- | ftnoir_tracker_rift_042/images/rift_medium.png | bin | 0 -> 5764 bytes | |||
-rw-r--r-- | ftnoir_tracker_rift_042/images/rift_small.png | bin | 0 -> 1212 bytes | |||
-rw-r--r-- | ftnoir_tracker_rift_042/images/rift_tiny.png | bin | 0 -> 624 bytes | |||
-rw-r--r-- | ftnoir_tracker_rift_042/images/small.png | bin | 0 -> 1212 bytes | |||
-rw-r--r-- | ftnoir_tracker_rift_042/images/tiny.png | bin | 0 -> 624 bytes | |||
-rw-r--r-- | ftnoir_tracker_rift_080/ftnoir_rift_080.qrc | 7 | ||||
-rw-r--r-- | ftnoir_tracker_rift_080/ftnoir_rift_clientcontrols_080.ui | 176 | ||||
-rw-r--r-- | ftnoir_tracker_rift_080/ftnoir_tracker_rift_080.cpp | 69 | ||||
-rw-r--r-- | ftnoir_tracker_rift_080/ftnoir_tracker_rift_080.h (renamed from ftnoir_tracker_rift/ftnoir_tracker_rift.h) | 6 | ||||
-rw-r--r-- | ftnoir_tracker_rift_080/ftnoir_tracker_rift_dialog_080.cpp | 26 | ||||
-rw-r--r-- | ftnoir_tracker_rift_080/images/medium.png | bin | 0 -> 5764 bytes | |||
-rw-r--r-- | ftnoir_tracker_rift_080/images/rift_medium.png | bin | 0 -> 5764 bytes | |||
-rw-r--r-- | ftnoir_tracker_rift_080/images/rift_small.png | bin | 0 -> 1212 bytes | |||
-rw-r--r-- | ftnoir_tracker_rift_080/images/rift_tiny.png | bin | 0 -> 624 bytes | |||
-rw-r--r-- | ftnoir_tracker_rift_080/images/small.png | bin | 0 -> 1212 bytes | |||
-rw-r--r-- | ftnoir_tracker_rift_080/images/tiny.png | bin | 0 -> 624 bytes | |||
-rw-r--r-- | ftnoir_tracker_rs/ftnoir_tracker_rs.cpp | 2 | ||||
-rw-r--r-- | ftnoir_tracker_rs/ftnoir_tracker_rs_controls.cpp | 2 |
83 files changed, 2084 insertions, 33 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index a7c64144..cdd69a57 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -185,18 +185,8 @@ endif() if(LINUX OR APPLE) set(SDK_XPLANE "" CACHE PATH "Path to X-Plane SDK") - set(SDK_ENABLE_LIBEVDEV FALSE CACHE BOOL "libevdev virtual joystick protocol support") endif() -SET(SDK_HYDRA "" CACHE PATH "libSixense path for Razer Hydra") -SET(SDK_HYDRA_AMD64 FALSE CACHE BOOL "whether libSixense is amd64 (else ia-32)") -SET(SDK_RIFT "" CACHE PATH "libOVR path for Oculus Rift") - -set(SDK_ARUCO_LIBPATH "" CACHE FILEPATH "Aruco paper marker tracker static library path") - -set(SDK_HT "" CACHE FILEPATH "Path to headtracker library") -set(SDK_HT_FLANDMARK "" CACHE FILEPATH "Path to flandmark library for headtracker") - if(WIN32) set(SDK_FSUIPC "" CACHE PATH "FSUIPC for older MS FSX path") endif() @@ -362,13 +352,7 @@ endif() opentrack_library(opentrack-proto-udp ftnoir_protocol_ftn) -if(Qt5SerialPort_FOUND AND FALSE) - opentrack_library(opentrack-tracker-hatire ftnoir_tracker_hatire) - target_link_libraries(opentrack-tracker-hatire ${Qt5SerialPort_LIBRARIES}) - target_include_directories(opentrack-tracker-hatire SYSTEM PUBLIC ${Qt5SerialPort_INCLUDE_DIRS}) -endif() - -if(SDK_WINE_PREFIX AND FALSE) +if(SDK_WINE_PREFIX) opentrack_library(opentrack-proto-wine ftnoir_protocol_wine) target_link_libraries(opentrack-proto-wine opentrack-compat opentrack-csv) if(NOT SDK_WINE_NO_WRAPPER) diff --git a/cmake/mingw-w64.cmake b/cmake/mingw-w64.cmake index 1f60993a..8604dafb 100644 --- a/cmake/mingw-w64.cmake +++ b/cmake/mingw-w64.cmake @@ -7,7 +7,7 @@ SET(CMAKE_SYSTEM_NAME Windows) SET(CMAKE_SYSTEM_VERSION 1) # specify the cross compiler -set(c i686-w64-mingw32-) +set(c /c/mingw-w64/i686-4.9.2-posix-sjlj-rt_v4-rev4/mingw32/bin/i686-w64-mingw32-) SET(CMAKE_C_COMPILER ${c}gcc) SET(CMAKE_CXX_COMPILER ${c}g++) diff --git a/clientfiles/FlightGear/Protocol/headtracker.xml b/contrib/FlightGear/Protocol/headtracker.xml index 8c14119a..8c14119a 100644 --- a/clientfiles/FlightGear/Protocol/headtracker.xml +++ b/contrib/FlightGear/Protocol/headtracker.xml diff --git a/clientfiles/FlightGear/readme.txt b/contrib/FlightGear/readme.txt index 48cee837..48cee837 100644 --- a/clientfiles/FlightGear/readme.txt +++ b/contrib/FlightGear/readme.txt diff --git a/clientfiles/Tir4Fun/npclient.dll b/contrib/Tir4Fun/npclient.dll Binary files differindex e392442e..e392442e 100644 --- a/clientfiles/Tir4Fun/npclient.dll +++ b/contrib/Tir4Fun/npclient.dll diff --git a/clientfiles/Tir4Fun/readme.txt b/contrib/Tir4Fun/readme.txt index d64af301..d64af301 100644 --- a/clientfiles/Tir4Fun/readme.txt +++ b/contrib/Tir4Fun/readme.txt diff --git a/clientfiles/Tir4Fun/tir4fun.exe b/contrib/Tir4Fun/tir4fun.exe Binary files differindex a51eced0..a51eced0 100644 --- a/clientfiles/Tir4Fun/tir4fun.exe +++ b/contrib/Tir4Fun/tir4fun.exe diff --git a/clientfiles/aruco/aruco_create_marker.exe b/contrib/aruco/aruco_create_marker.exe Binary files differindex 4400e80e..4400e80e 100644 --- a/clientfiles/aruco/aruco_create_marker.exe +++ b/contrib/aruco/aruco_create_marker.exe diff --git a/clientfiles/aruco/test3.jpg b/contrib/aruco/test3.jpg Binary files differindex 2ff6dbd0..2ff6dbd0 100644 --- a/clientfiles/aruco/test3.jpg +++ b/contrib/aruco/test3.jpg diff --git a/clientfiles/cfs3/readme.txt b/contrib/cfs3/readme.txt index e51cebfa..e51cebfa 100644 --- a/clientfiles/cfs3/readme.txt +++ b/contrib/cfs3/readme.txt diff --git a/clientfiles/cfs3/tirviews.dll b/contrib/cfs3/tirviews.dll Binary files differindex a1fb306f..a1fb306f 100644 --- a/clientfiles/cfs3/tirviews.dll +++ b/contrib/cfs3/tirviews.dll diff --git a/clientfiles/cute-octopus-vector-material_15-1831.jpg b/contrib/cute-octopus-vector-material_15-1831.jpg Binary files differindex c4e5318f..c4e5318f 100644 --- a/clientfiles/cute-octopus-vector-material_15-1831.jpg +++ b/contrib/cute-octopus-vector-material_15-1831.jpg diff --git a/contrib/dropbox-uploader/README b/contrib/dropbox-uploader/README new file mode 100644 index 00000000..49189e17 --- /dev/null +++ b/contrib/dropbox-uploader/README @@ -0,0 +1 @@ +From <https://github.com/andreafabrizi/Dropbox-Uploader> diff --git a/contrib/dropbox-uploader/dropbox_uploader.sh b/contrib/dropbox-uploader/dropbox_uploader.sh new file mode 100644 index 00000000..1e7b830e --- /dev/null +++ b/contrib/dropbox-uploader/dropbox_uploader.sh @@ -0,0 +1,1364 @@ +#!/usr/bin/env bash +# +# Dropbox Uploader +# +# Copyright (C) 2010-2014 Andrea Fabrizi <andrea.fabrizi@gmail.com> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# + +#Default configuration file +CONFIG_FILE=~/.dropbox_uploader + +#Default chunk size in Mb for the upload process +#It is recommended to increase this value only if you have enough free space on your /tmp partition +#Lower values may increase the number of http requests +CHUNK_SIZE=4 + +#Curl location +#If not set, curl will be searched into the $PATH +#CURL_BIN="/usr/bin/curl" + +#Default values +TMP_DIR="/tmp" +DEBUG=0 +QUIET=0 +SHOW_PROGRESSBAR=0 +SKIP_EXISTING_FILES=0 +ERROR_STATUS=0 + +#Don't edit these... +API_REQUEST_TOKEN_URL="https://api.dropbox.com/1/oauth/request_token" +API_USER_AUTH_URL="https://www.dropbox.com/1/oauth/authorize" +API_ACCESS_TOKEN_URL="https://api.dropbox.com/1/oauth/access_token" +API_CHUNKED_UPLOAD_URL="https://api-content.dropbox.com/1/chunked_upload" +API_CHUNKED_UPLOAD_COMMIT_URL="https://api-content.dropbox.com/1/commit_chunked_upload" +API_UPLOAD_URL="https://api-content.dropbox.com/1/files_put" +API_DOWNLOAD_URL="https://api-content.dropbox.com/1/files" +API_DELETE_URL="https://api.dropbox.com/1/fileops/delete" +API_MOVE_URL="https://api.dropbox.com/1/fileops/move" +API_COPY_URL="https://api.dropbox.com/1/fileops/copy" +API_METADATA_URL="https://api.dropbox.com/1/metadata" +API_INFO_URL="https://api.dropbox.com/1/account/info" +API_MKDIR_URL="https://api.dropbox.com/1/fileops/create_folder" +API_SHARES_URL="https://api.dropbox.com/1/shares" +API_SAVEURL_URL="https://api.dropbox.com/1/save_url/auto" +API_SAVEURL_JOB_URL="https://api.dropbox.com/1/save_url_job" +APP_CREATE_URL="https://www.dropbox.com/developers/apps" +RESPONSE_FILE="$TMP_DIR/du_resp_$RANDOM" +CHUNK_FILE="$TMP_DIR/du_chunk_$RANDOM" +TEMP_FILE="$TMP_DIR/du_tmp_$RANDOM" +BIN_DEPS="sed basename date grep stat dd mkdir" +VERSION="0.16" + +umask 077 + +#Check the shell +if [ -z "$BASH_VERSION" ]; then + echo -e "Error: this script requires the BASH shell!" + exit 1 +fi + +shopt -s nullglob #Bash allows filename patterns which match no files to expand to a null string, rather than themselves +shopt -s dotglob #Bash includes filenames beginning with a "." in the results of filename expansion + +#Look for optional config file parameter +while getopts ":qpskdf:" opt; do + case $opt in + + f) + CONFIG_FILE=$OPTARG + ;; + + d) + DEBUG=1 + ;; + + q) + QUIET=1 + ;; + + p) + SHOW_PROGRESSBAR=1 + ;; + + k) + CURL_ACCEPT_CERTIFICATES="-k" + ;; + + s) + SKIP_EXISTING_FILES=1 + ;; + + \?) + echo "Invalid option: -$OPTARG" >&2 + exit 1 + ;; + + :) + echo "Option -$OPTARG requires an argument." >&2 + exit 1 + ;; + + esac +done + +if [[ $DEBUG != 0 ]]; then + echo $VERSION + uname -a 2> /dev/null + cat /etc/issue 2> /dev/null + set -x + RESPONSE_FILE="$TMP_DIR/du_resp_debug" +fi + +if [[ $CURL_BIN == "" ]]; then + BIN_DEPS="$BIN_DEPS curl" + CURL_BIN="curl" +fi + +#Dependencies check +which $BIN_DEPS > /dev/null +if [[ $? != 0 ]]; then + for i in $BIN_DEPS; do + which $i > /dev/null || + NOT_FOUND="$i $NOT_FOUND" + done + echo -e "Error: Required program could not be found: $NOT_FOUND" + exit 1 +fi + +#Check if readlink is installed and supports the -m option +#It's not necessary, so no problem if it's not installed +which readlink > /dev/null +if [[ $? == 0 && $(readlink -m "//test" 2> /dev/null) == "/test" ]]; then + HAVE_READLINK=1 +else + HAVE_READLINK=0 +fi + +#Forcing to use the builtin printf, if it's present, because it's better +#otherwise the external printf program will be used +#Note that the external printf command can cause character encoding issues! +builtin printf "" 2> /dev/null +if [[ $? == 0 ]]; then + PRINTF="builtin printf" + PRINTF_OPT="-v o" +else + PRINTF=$(which printf) + if [[ $? != 0 ]]; then + echo -e "Error: Required program could not be found: printf" + fi + PRINTF_OPT="" +fi + +#Print the message based on $QUIET variable +function print +{ + if [[ $QUIET == 0 ]]; then + echo -ne "$1"; + fi +} + +#Returns unix timestamp +function utime +{ + echo $(date +%s) +} + +#Remove temporary files +function remove_temp_files +{ + if [[ $DEBUG == 0 ]]; then + rm -fr "$RESPONSE_FILE" + rm -fr "$CHUNK_FILE" + rm -fr "$TEMP_FILE" + fi +} + +#Returns the file size in bytes +function file_size +{ + #Generic GNU + SIZE=$(stat --format="%s" "$1" 2> /dev/null) + if [ $? -eq 0 ]; then + echo $SIZE + return + fi + + #Some embedded linux devices + SIZE=$(stat -c "%s" "$1" 2> /dev/null) + if [ $? -eq 0 ]; then + echo $SIZE + return + fi + + #BSD, OSX and other OSs + SIZE=$(stat -f "%z" "$1" 2> /dev/null) + if [ $? -eq 0 ]; then + echo $SIZE + return + fi + + echo "0" +} + + +#Usage +function usage +{ + echo -e "Dropbox Uploader v$VERSION" + echo -e "Andrea Fabrizi - andrea.fabrizi@gmail.com\n" + echo -e "Usage: $0 COMMAND [PARAMETERS]..." + echo -e "\nCommands:" + + echo -e "\t upload <LOCAL_FILE/DIR ...> <REMOTE_FILE/DIR>" + echo -e "\t download <REMOTE_FILE/DIR> [LOCAL_FILE/DIR]" + echo -e "\t delete <REMOTE_FILE/DIR>" + echo -e "\t move <REMOTE_FILE/DIR> <REMOTE_FILE/DIR>" + echo -e "\t copy <REMOTE_FILE/DIR> <REMOTE_FILE/DIR>" + echo -e "\t mkdir <REMOTE_DIR>" + echo -e "\t list [REMOTE_DIR]" + echo -e "\t share <REMOTE_FILE>" + echo -e "\t saveurl <URL> <REMOTE_DIR>" + echo -e "\t info" + echo -e "\t unlink" + + echo -e "\nOptional parameters:" + echo -e "\t-f <FILENAME> Load the configuration file from a specific file" + echo -e "\t-s Skip already existing files when download/upload. Default: Overwrite" + echo -e "\t-d Enable DEBUG mode" + echo -e "\t-q Quiet mode. Don't show messages" + echo -e "\t-p Show cURL progress meter" + echo -e "\t-k Doesn't check for SSL certificates (insecure)" + + echo -en "\nFor more info and examples, please see the README file.\n\n" + remove_temp_files + exit 1 +} + +#Check the curl exit code +function check_http_response +{ + CODE=$? + + #Checking curl exit code + case $CODE in + + #OK + 0) + + ;; + + #Proxy error + 5) + print "\nError: Couldn't resolve proxy. The given proxy host could not be resolved.\n" + + remove_temp_files + exit 1 + ;; + + #Missing CA certificates + 60|58) + print "\nError: cURL is not able to performs peer SSL certificate verification.\n" + print "Please, install the default ca-certificates bundle.\n" + print "To do this in a Debian/Ubuntu based system, try:\n" + print " sudo apt-get install ca-certificates\n\n" + print "If the problem persists, try to use the -k option (insecure).\n" + + remove_temp_files + exit 1 + ;; + + 6) + print "\nError: Couldn't resolve host.\n" + + remove_temp_files + exit 1 + ;; + + 7) + print "\nError: Couldn't connect to host.\n" + + remove_temp_files + exit 1 + ;; + + esac + + #Checking response file for generic errors + if grep -q "HTTP/1.1 400" "$RESPONSE_FILE"; then + ERROR_MSG=$(sed -n -e 's/{"error": "\([^"]*\)"}/\1/p' "$RESPONSE_FILE") + + case $ERROR_MSG in + *access?attempt?failed?because?this?app?is?not?configured?to?have*) + echo -e "\nError: The Permission type/Access level configured doesn't match the DropBox App settings!\nPlease run \"$0 unlink\" and try again." + exit 1 + ;; + esac + + fi + +} + +#Urlencode +function urlencode +{ + #The printf is necessary to correctly decode unicode sequences + local string=$($PRINTF "${1}") + local strlen=${#string} + local encoded="" + + for (( pos=0 ; pos<strlen ; pos++ )); do + c=${string:$pos:1} + case "$c" in + [-_.~a-zA-Z0-9] ) o="${c}" ;; + * ) $PRINTF $PRINTF_OPT '%%%02x' "'$c" + esac + encoded="${encoded}${o}" + done + + echo "$encoded" +} + +function normalize_path +{ + #The printf is necessary to correctly decode unicode sequences + path=$($PRINTF "${1//\/\///}") + if [[ $HAVE_READLINK == 1 ]]; then + new_path=$(readlink -m "$path") + + #Adding back the final slash, if present in the source + if [[ ${path: -1} == "/" && ${#path} > 1 ]]; then + new_path="$new_path/" + fi + + echo "$new_path" + else + echo "$path" + fi +} + +#Check if it's a file or directory +#Returns FILE/DIR/ERR +function db_stat +{ + local FILE=$(normalize_path "$1") + + #Checking if it's a file or a directory + $CURL_BIN $CURL_ACCEPT_CERTIFICATES -s --show-error --globoff -i -o "$RESPONSE_FILE" "$API_METADATA_URL/$ACCESS_LEVEL/$(urlencode "$FILE")?oauth_consumer_key=$APPKEY&oauth_token=$OAUTH_ACCESS_TOKEN&oauth_signature_method=PLAINTEXT&oauth_signature=$APPSECRET%26$OAUTH_ACCESS_TOKEN_SECRET&oauth_timestamp=$(utime)&oauth_nonce=$RANDOM" 2> /dev/null + check_http_response + + #Even if the file/dir has been deleted from DropBox we receive a 200 OK response + #So we must check if the file exists or if it has been deleted + if grep -q "\"is_deleted\":" "$RESPONSE_FILE"; then + local IS_DELETED=$(sed -n 's/.*"is_deleted":.\([^,]*\).*/\1/p' "$RESPONSE_FILE") + else + local IS_DELETED="false" + fi + + #Exits... + grep -q "^HTTP/1.1 200 OK" "$RESPONSE_FILE" + if [[ $? == 0 && $IS_DELETED != "true" ]]; then + + local IS_DIR=$(sed -n 's/^\(.*\)\"contents":.\[.*/\1/p' "$RESPONSE_FILE") + + #It's a directory + if [[ $IS_DIR != "" ]]; then + echo "DIR" + #It's a file + else + echo "FILE" + fi + + #Doesn't exists + else + echo "ERR" + fi +} + +#Generic upload wrapper around db_upload_file and db_upload_dir functions +#$1 = Local source file/dir +#$2 = Remote destination file/dir +function db_upload +{ + local SRC=$(normalize_path "$1") + local DST=$(normalize_path "$2") + + #Checking if the file/dir exists + if [[ ! -e $SRC && ! -d $SRC ]]; then + print " > No such file or directory: $SRC\n" + ERROR_STATUS=1 + return + fi + + #Checking if the file/dir has read permissions + if [[ ! -r $SRC ]]; then + print " > Error reading file $SRC: permission denied\n" + ERROR_STATUS=1 + return + fi + + TYPE=$(db_stat "$DST") + + #If DST it's a file, do nothing, it's the default behaviour + if [[ $TYPE == "FILE" ]]; then + DST="$DST" + + #if DST doesn't exists and doesn't ends with a /, it will be the destination file name + elif [[ $TYPE == "ERR" && "${DST: -1}" != "/" ]]; then + DST="$DST" + + #if DST doesn't exists and ends with a /, it will be the destination folder + elif [[ $TYPE == "ERR" && "${DST: -1}" == "/" ]]; then + local filename=$(basename "$SRC") + DST="$DST/$filename" + + #If DST it'a directory, it will be the destination folder + elif [[ $TYPE == "DIR" ]]; then + local filename=$(basename "$SRC") + DST="$DST/$filename" + fi + + #It's a directory + if [[ -d $SRC ]]; then + db_upload_dir "$SRC" "$DST" + + #It's a file + elif [[ -e $SRC ]]; then + db_upload_file "$SRC" "$DST" + + #Unsupported object... + else + print " > Skipping not regular file \"$SRC\"\n" + fi +} + +#Generic upload wrapper around db_chunked_upload_file and db_simple_upload_file +#The final upload function will be choosen based on the file size +#$1 = Local source file +#$2 = Remote destination file +function db_upload_file +{ + local FILE_SRC=$(normalize_path "$1") + local FILE_DST=$(normalize_path "$2") + + shopt -s nocasematch + + #Checking not allowed file names + basefile_dst=$(basename "$FILE_DST") + if [[ $basefile_dst == "thumbs.db" || \ + $basefile_dst == "desktop.ini" || \ + $basefile_dst == ".ds_store" || \ + $basefile_dst == "icon\r" || \ + $basefile_dst == ".dropbox" || \ + $basefile_dst == ".dropbox.attr" \ + ]]; then + print " > Skipping not allowed file name \"$FILE_DST\"\n" + return + fi + + shopt -u nocasematch + + #Checking file size + FILE_SIZE=$(file_size "$FILE_SRC") + + #Checking if the file already exists + TYPE=$(db_stat "$FILE_DST") + if [[ $TYPE != "ERR" && $SKIP_EXISTING_FILES == 1 ]]; then + print " > Skipping already existing file \"$FILE_DST\"\n" + return + fi + + if [[ $FILE_SIZE -gt 157286000 ]]; then + #If the file is greater than 150Mb, the chunked_upload API will be used + db_chunked_upload_file "$FILE_SRC" "$FILE_DST" + else + db_simple_upload_file "$FILE_SRC" "$FILE_DST" + fi + +} + +#Simple file upload +#$1 = Local source file +#$2 = Remote destination file +function db_simple_upload_file +{ + local FILE_SRC=$(normalize_path "$1") + local FILE_DST=$(normalize_path "$2") + + if [[ $SHOW_PROGRESSBAR == 1 && $QUIET == 0 ]]; then + CURL_PARAMETERS="--progress-bar" + LINE_CR="\n" + else + CURL_PARAMETERS="-s" + LINE_CR="" + fi + + print " > Uploading \"$FILE_SRC\" to \"$FILE_DST\"... $LINE_CR" + $CURL_BIN $CURL_ACCEPT_CERTIFICATES $CURL_PARAMETERS -i --globoff -o "$RESPONSE_FILE" --upload-file "$FILE_SRC" "$API_UPLOAD_URL/$ACCESS_LEVEL/$(urlencode "$FILE_DST")?oauth_consumer_key=$APPKEY&oauth_token=$OAUTH_ACCESS_TOKEN&oauth_signature_method=PLAINTEXT&oauth_signature=$APPSECRET%26$OAUTH_ACCESS_TOKEN_SECRET&oauth_timestamp=$(utime)&oauth_nonce=$RANDOM" + check_http_response + + #Check + if grep -q "^HTTP/1.1 200 OK" "$RESPONSE_FILE"; then + print "DONE\n" + else + print "FAILED\n" + print "An error occurred requesting /upload\n" + ERROR_STATUS=1 + fi +} + +#Chunked file upload +#$1 = Local source file +#$2 = Remote destination file +function db_chunked_upload_file +{ + local FILE_SRC=$(normalize_path "$1") + local FILE_DST=$(normalize_path "$2") + + print " > Uploading \"$FILE_SRC\" to \"$FILE_DST\"" + + local FILE_SIZE=$(file_size "$FILE_SRC") + local OFFSET=0 + local UPLOAD_ID="" + local UPLOAD_ERROR=0 + local CHUNK_PARAMS="" + + #Uploading chunks... + while ([[ $OFFSET != $FILE_SIZE ]]); do + + let OFFSET_MB=$OFFSET/1024/1024 + + #Create the chunk + dd if="$FILE_SRC" of="$CHUNK_FILE" bs=1048576 skip=$OFFSET_MB count=$CHUNK_SIZE 2> /dev/null + + #Only for the first request these parameters are not included + if [[ $OFFSET != 0 ]]; then + CHUNK_PARAMS="upload_id=$UPLOAD_ID&offset=$OFFSET" + fi + + #Uploading the chunk... + echo > "$RESPONSE_FILE" + $CURL_BIN $CURL_ACCEPT_CERTIFICATES -s --show-error --globoff -i -o "$RESPONSE_FILE" --upload-file "$CHUNK_FILE" "$API_CHUNKED_UPLOAD_URL?$CHUNK_PARAMS&oauth_consumer_key=$APPKEY&oauth_token=$OAUTH_ACCESS_TOKEN&oauth_signature_method=PLAINTEXT&oauth_signature=$APPSECRET%26$OAUTH_ACCESS_TOKEN_SECRET&oauth_timestamp=$(utime)&oauth_nonce=$RANDOM" 2> /dev/null + #check_http_response not needed, because we have to retry the request in case of error + + #Check + if grep -q "^HTTP/1.1 200 OK" "$RESPONSE_FILE"; then + print "." + UPLOAD_ERROR=0 + UPLOAD_ID=$(sed -n 's/.*"upload_id": *"*\([^"]*\)"*.*/\1/p' "$RESPONSE_FILE") + OFFSET=$(sed -n 's/.*"offset": *\([^}]*\).*/\1/p' "$RESPONSE_FILE") + else + print "*" + let UPLOAD_ERROR=$UPLOAD_ERROR+1 + + #On error, the upload is retried for max 3 times + if [[ $UPLOAD_ERROR -gt 2 ]]; then + print " FAILED\n" + print "An error occurred requesting /chunked_upload\n" + ERROR_STATUS=1 + return + fi + fi + + done + + UPLOAD_ERROR=0 + + #Commit the upload + while (true); do + + echo > "$RESPONSE_FILE" + $CURL_BIN $CURL_ACCEPT_CERTIFICATES -s --show-error --globoff -i -o "$RESPONSE_FILE" --data "upload_id=$UPLOAD_ID&oauth_consumer_key=$APPKEY&oauth_token=$OAUTH_ACCESS_TOKEN&oauth_signature_method=PLAINTEXT&oauth_signature=$APPSECRET%26$OAUTH_ACCESS_TOKEN_SECRET&oauth_timestamp=$(utime)&oauth_nonce=$RANDOM" "$API_CHUNKED_UPLOAD_COMMIT_URL/$ACCESS_LEVEL/$(urlencode "$FILE_DST")" 2> /dev/null + #check_http_response not needed, because we have to retry the request in case of error + + #Check + if grep -q "^HTTP/1.1 200 OK" "$RESPONSE_FILE"; then + print "." + UPLOAD_ERROR=0 + break + else + print "*" + let UPLOAD_ERROR=$UPLOAD_ERROR+1 + + #On error, the commit is retried for max 3 times + if [[ $UPLOAD_ERROR -gt 2 ]]; then + print " FAILED\n" + print "An error occurred requesting /commit_chunked_upload\n" + ERROR_STATUS=1 + return + fi + fi + + done + + print " DONE\n" +} + +#Directory upload +#$1 = Local source dir +#$2 = Remote destination dir +function db_upload_dir +{ + local DIR_SRC=$(normalize_path "$1") + local DIR_DST=$(normalize_path "$2") + + #Creatig remote directory + db_mkdir "$DIR_DST" + + for file in "$DIR_SRC/"*; do + db_upload "$file" "$DIR_DST" + done +} + +#Generic download wrapper +#$1 = Remote source file/dir +#$2 = Local destination file/dir +function db_download +{ + local SRC=$(normalize_path "$1") + local DST=$(normalize_path "$2") + + TYPE=$(db_stat "$SRC") + + #It's a directory + if [[ $TYPE == "DIR" ]]; then + + #If the DST folder is not specified, I assume that is the current directory + if [[ $DST == "" ]]; then + DST="." + fi + + #Checking if the destination directory exists + if [[ ! -d $DST ]]; then + local basedir="" + else + local basedir=$(basename "$SRC") + fi + + local DEST_DIR=$(normalize_path "$DST/$basedir") + print " > Downloading \"$SRC\" to \"$DEST_DIR\"... \n" + print " > Creating local directory \"$DEST_DIR\"... " + mkdir -p "$DEST_DIR" + + #Check + if [[ $? == 0 ]]; then + print "DONE\n" + else + print "FAILED\n" + ERROR_STATUS=1 + return + fi + + #Extracting directory content [...] + #and replacing "}, {" with "}\n{" + #I don't like this piece of code... but seems to be the only way to do this with SED, writing a portable code... + local DIR_CONTENT=$(sed -n 's/.*: \[{\(.*\)/\1/p' "$RESPONSE_FILE" | sed 's/}, *{/}\ +{/g') + + #Extracting files and subfolders + TMP_DIR_CONTENT_FILE="${RESPONSE_FILE}_$RANDOM" + echo "$DIR_CONTENT" | sed -n 's/.*"path": *"\([^"]*\)",.*"is_dir": *\([^"]*\),.*/\1:\2/p' > $TMP_DIR_CONTENT_FILE + + #For each entry... + while read -r line; do + + local FILE=${line%:*} + local TYPE=${line#*:} + + #Removing unneeded / + FILE=${FILE##*/} + + if [[ $TYPE == "false" ]]; then + db_download_file "$SRC/$FILE" "$DEST_DIR/$FILE" + else + db_download "$SRC/$FILE" "$DEST_DIR" + fi + + done < $TMP_DIR_CONTENT_FILE + + rm -fr $TMP_DIR_CONTENT_FILE + + #It's a file + elif [[ $TYPE == "FILE" ]]; then + + #Checking DST + if [[ $DST == "" ]]; then + DST=$(basename "$SRC") + fi + + #If the destination is a directory, the file will be download into + if [[ -d $DST ]]; then + DST="$DST/$SRC" + fi + + db_download_file "$SRC" "$DST" + + #Doesn't exists + else + print " > No such file or directory: $SRC\n" + ERROR_STATUS=1 + return + fi +} + +#Simple file download +#$1 = Remote source file +#$2 = Local destination file +function db_download_file +{ + local FILE_SRC=$(normalize_path "$1") + local FILE_DST=$(normalize_path "$2") + + if [[ $SHOW_PROGRESSBAR == 1 && $QUIET == 0 ]]; then + CURL_PARAMETERS="--progress-bar" + LINE_CR="\n" + else + CURL_PARAMETERS="-s" + LINE_CR="" + fi + + #Checking if the file already exists + if [[ -e $FILE_DST && $SKIP_EXISTING_FILES == 1 ]]; then + print " > Skipping already existing file \"$FILE_DST\"\n" + return + fi + + #Creating the empty file, that for two reasons: + #1) In this way I can check if the destination file is writable or not + #2) Curl doesn't automatically creates files with 0 bytes size + dd if=/dev/zero of="$FILE_DST" count=0 2> /dev/null + if [[ $? != 0 ]]; then + print " > Error writing file $FILE_DST: permission denied\n" + ERROR_STATUS=1 + return + fi + + print " > Downloading \"$FILE_SRC\" to \"$FILE_DST\"... $LINE_CR" + $CURL_BIN $CURL_ACCEPT_CERTIFICATES $CURL_PARAMETERS --globoff -D "$RESPONSE_FILE" -o "$FILE_DST" "$API_DOWNLOAD_URL/$ACCESS_LEVEL/$(urlencode "$FILE_SRC")?oauth_consumer_key=$APPKEY&oauth_token=$OAUTH_ACCESS_TOKEN&oauth_signature_method=PLAINTEXT&oauth_signature=$APPSECRET%26$OAUTH_ACCESS_TOKEN_SECRET&oauth_timestamp=$(utime)&oauth_nonce=$RANDOM" + check_http_response + + #Check + if grep -q "^HTTP/1.1 200 OK" "$RESPONSE_FILE"; then + print "DONE\n" + else + print "FAILED\n" + rm -fr "$FILE_DST" + ERROR_STATUS=1 + return + fi +} + +#Saveurl +#$1 = URL +#$2 = Remote file destination +function db_saveurl +{ + local URL="$1" + local FILE_DST=$(normalize_path "$2") + local FILE_NAME=$(basename "$URL") + + print " > Downloading \"$URL\" to \"$FILE_DST\"..." + $CURL_BIN $CURL_ACCEPT_CERTIFICATES -s --show-error --globoff -i -o "$RESPONSE_FILE" --data "url=$(urlencode "$URL")&oauth_consumer_key=$APPKEY&oauth_token=$OAUTH_ACCESS_TOKEN&oauth_signature_method=PLAINTEXT&oauth_signature=$APPSECRET%26$OAUTH_ACCESS_TOKEN_SECRET&oauth_timestamp=$(utime)&oauth_nonce=$RANDOM" "$API_SAVEURL_URL/$FILE_DST/$FILE_NAME" 2> /dev/null + check_http_response + + JOB_ID=$(sed -n 's/.*"job": *"*\([^"]*\)"*.*/\1/p' "$RESPONSE_FILE") + if [[ $JOB_ID == "" ]]; then + print " > Error getting the job id\n" + return + fi + + #Checking the status + while (true); do + + $CURL_BIN $CURL_ACCEPT_CERTIFICATES -s --show-error --globoff -i -o "$RESPONSE_FILE" --data "oauth_consumer_key=$APPKEY&oauth_token=$OAUTH_ACCESS_TOKEN&oauth_signature_method=PLAINTEXT&oauth_signature=$APPSECRET%26$OAUTH_ACCESS_TOKEN_SECRET&oauth_timestamp=$(utime)&oauth_nonce=$RANDOM" "$API_SAVEURL_JOB_URL/$JOB_ID" 2> /dev/null + check_http_response + + STATUS=$(sed -n 's/.*"status": *"*\([^"]*\)"*.*/\1/p' "$RESPONSE_FILE") + case $STATUS in + + PENDING) + print "." + ;; + + DOWNLOADING) + print "+" + ;; + + COMPLETE) + print " DONE\n" + break + ;; + + FAILED) + print " ERROR\n" + MESSAGE=$(sed -n 's/.*"error": *"*\([^"]*\)"*.*/\1/p' "$RESPONSE_FILE") + print " > Error: $MESSAGE\n" + break + ;; + + esac + + sleep 2 + + done +} + +#Prints account info +function db_account_info +{ + print "Dropbox Uploader v$VERSION\n\n" + print " > Getting info... " + $CURL_BIN $CURL_ACCEPT_CERTIFICATES -s --show-error --globoff -i -o "$RESPONSE_FILE" --data "oauth_consumer_key=$APPKEY&oauth_token=$OAUTH_ACCESS_TOKEN&oauth_signature_method=PLAINTEXT&oauth_signature=$APPSECRET%26$OAUTH_ACCESS_TOKEN_SECRET&oauth_timestamp=$(utime)&oauth_nonce=$RANDOM" "$API_INFO_URL" 2> /dev/null + check_http_response + + #Check + if grep -q "^HTTP/1.1 200 OK" "$RESPONSE_FILE"; then + + name=$(sed -n 's/.*"display_name": "\([^"]*\).*/\1/p' "$RESPONSE_FILE") + echo -e "\n\nName:\t$name" + + uid=$(sed -n 's/.*"uid": \([0-9]*\).*/\1/p' "$RESPONSE_FILE") + echo -e "UID:\t$uid" + + email=$(sed -n 's/.*"email": "\([^"]*\).*/\1/p' "$RESPONSE_FILE") + echo -e "Email:\t$email" + + quota=$(sed -n 's/.*"quota": \([0-9]*\).*/\1/p' "$RESPONSE_FILE") + let quota_mb=$quota/1024/1024 + echo -e "Quota:\t$quota_mb Mb" + + used=$(sed -n 's/.*"normal": \([0-9]*\).*/\1/p' "$RESPONSE_FILE") + let used_mb=$used/1024/1024 + echo -e "Used:\t$used_mb Mb" + + let free_mb=($quota-$used)/1024/1024 + echo -e "Free:\t$free_mb Mb" + + echo "" + + else + print "FAILED\n" + ERROR_STATUS=1 + fi +} + +#Account unlink +function db_unlink +{ + echo -ne "Are you sure you want unlink this script from your Dropbox account? [y/n]" + read answer + if [[ $answer == "y" ]]; then + rm -fr "$CONFIG_FILE" + echo -ne "DONE\n" + fi +} + +#Delete a remote file +#$1 = Remote file to delete +function db_delete +{ + local FILE_DST=$(normalize_path "$1") + + print " > Deleting \"$FILE_DST\"... " + $CURL_BIN $CURL_ACCEPT_CERTIFICATES -s --show-error --globoff -i -o "$RESPONSE_FILE" --data "oauth_consumer_key=$APPKEY&oauth_token=$OAUTH_ACCESS_TOKEN&oauth_signature_method=PLAINTEXT&oauth_signature=$APPSECRET%26$OAUTH_ACCESS_TOKEN_SECRET&oauth_timestamp=$(utime)&oauth_nonce=$RANDOM&root=$ACCESS_LEVEL&path=$(urlencode "$FILE_DST")" "$API_DELETE_URL" 2> /dev/null + check_http_response + + #Check + if grep -q "^HTTP/1.1 200 OK" "$RESPONSE_FILE"; then + print "DONE\n" + else + print "FAILED\n" + ERROR_STATUS=1 + fi +} + +#Move/Rename a remote file +#$1 = Remote file to rename or move +#$2 = New file name or location +function db_move +{ + local FILE_SRC=$(normalize_path "$1") + local FILE_DST=$(normalize_path "$2") + + TYPE=$(db_stat "$FILE_DST") + + #If the destination it's a directory, the source will be moved into it + if [[ $TYPE == "DIR" ]]; then + local filename=$(basename "$FILE_SRC") + FILE_DST=$(normalize_path "$FILE_DST/$filename") + fi + + print " > Moving \"$FILE_SRC\" to \"$FILE_DST\" ... " + $CURL_BIN $CURL_ACCEPT_CERTIFICATES -s --show-error --globoff -i -o "$RESPONSE_FILE" --data "oauth_consumer_key=$APPKEY&oauth_token=$OAUTH_ACCESS_TOKEN&oauth_signature_method=PLAINTEXT&oauth_signature=$APPSECRET%26$OAUTH_ACCESS_TOKEN_SECRET&oauth_timestamp=$(utime)&oauth_nonce=$RANDOM&root=$ACCESS_LEVEL&from_path=$(urlencode "$FILE_SRC")&to_path=$(urlencode "$FILE_DST")" "$API_MOVE_URL" 2> /dev/null + check_http_response + + #Check + if grep -q "^HTTP/1.1 200 OK" "$RESPONSE_FILE"; then + print "DONE\n" + else + print "FAILED\n" + ERROR_STATUS=1 + fi +} + +#Copy a remote file to a remote location +#$1 = Remote file to rename or move +#$2 = New file name or location +function db_copy +{ + local FILE_SRC=$(normalize_path "$1") + local FILE_DST=$(normalize_path "$2") + + TYPE=$(db_stat "$FILE_DST") + + #If the destination it's a directory, the source will be copied into it + if [[ $TYPE == "DIR" ]]; then + local filename=$(basename "$FILE_SRC") + FILE_DST=$(normalize_path "$FILE_DST/$filename") + fi + + print " > Copying \"$FILE_SRC\" to \"$FILE_DST\" ... " + $CURL_BIN $CURL_ACCEPT_CERTIFICATES -s --show-error --globoff -i -o "$RESPONSE_FILE" --data "oauth_consumer_key=$APPKEY&oauth_token=$OAUTH_ACCESS_TOKEN&oauth_signature_method=PLAINTEXT&oauth_signature=$APPSECRET%26$OAUTH_ACCESS_TOKEN_SECRET&oauth_timestamp=$(utime)&oauth_nonce=$RANDOM&root=$ACCESS_LEVEL&from_path=$(urlencode "$FILE_SRC")&to_path=$(urlencode "$FILE_DST")" "$API_COPY_URL" 2> /dev/null + check_http_response + + #Check + if grep -q "^HTTP/1.1 200 OK" "$RESPONSE_FILE"; then + print "DONE\n" + else + print "FAILED\n" + ERROR_STATUS=1 + fi +} + +#Create a new directory +#$1 = Remote directory to create +function db_mkdir +{ + local DIR_DST=$(normalize_path "$1") + + print " > Creating Directory \"$DIR_DST\"... " + $CURL_BIN $CURL_ACCEPT_CERTIFICATES -s --show-error --globoff -i -o "$RESPONSE_FILE" --data "oauth_consumer_key=$APPKEY&oauth_token=$OAUTH_ACCESS_TOKEN&oauth_signature_method=PLAINTEXT&oauth_signature=$APPSECRET%26$OAUTH_ACCESS_TOKEN_SECRET&oauth_timestamp=$(utime)&oauth_nonce=$RANDOM&root=$ACCESS_LEVEL&path=$(urlencode "$DIR_DST")" "$API_MKDIR_URL" 2> /dev/null + check_http_response + + #Check + if grep -q "^HTTP/1.1 200 OK" "$RESPONSE_FILE"; then + print "DONE\n" + elif grep -q "^HTTP/1.1 403 Forbidden" "$RESPONSE_FILE"; then + print "ALREADY EXISTS\n" + else + print "FAILED\n" + ERROR_STATUS=1 + fi +} + +#List remote directory +#$1 = Remote directory +function db_list +{ + local DIR_DST=$(normalize_path "$1") + + print " > Listing \"$DIR_DST\"... " + $CURL_BIN $CURL_ACCEPT_CERTIFICATES -s --show-error --globoff -i -o "$RESPONSE_FILE" "$API_METADATA_URL/$ACCESS_LEVEL/$(urlencode "$DIR_DST")?oauth_consumer_key=$APPKEY&oauth_token=$OAUTH_ACCESS_TOKEN&oauth_signature_method=PLAINTEXT&oauth_signature=$APPSECRET%26$OAUTH_ACCESS_TOKEN_SECRET&oauth_timestamp=$(utime)&oauth_nonce=$RANDOM" 2> /dev/null + check_http_response + + #Check + if grep -q "^HTTP/1.1 200 OK" "$RESPONSE_FILE"; then + + local IS_DIR=$(sed -n 's/^\(.*\)\"contents":.\[.*/\1/p' "$RESPONSE_FILE") + + #It's a directory + if [[ $IS_DIR != "" ]]; then + + print "DONE\n" + + #Extracting directory content [...] + #and replacing "}, {" with "}\n{" + #I don't like this piece of code... but seems to be the only way to do this with SED, writing a portable code... + local DIR_CONTENT=$(sed -n 's/.*: \[{\(.*\)/\1/p' "$RESPONSE_FILE" | sed 's/}, *{/}\ +{/g') + + #Converting escaped quotes to unicode format + echo "$DIR_CONTENT" | sed 's/\\"/\\u0022/' > "$TEMP_FILE" + + #Extracting files and subfolders + rm -fr "$RESPONSE_FILE" + while read -r line; do + + local FILE=$(echo "$line" | sed -n 's/.*"path": *"\([^"]*\)".*/\1/p') + local IS_DIR=$(echo "$line" | sed -n 's/.*"is_dir": *\([^,]*\).*/\1/p') + local SIZE=$(echo "$line" | sed -n 's/.*"bytes": *\([0-9]*\).*/\1/p') + + echo -e "$FILE:$IS_DIR;$SIZE" >> "$RESPONSE_FILE" + + done < "$TEMP_FILE" + + #Looking for the biggest file size + #to calculate the padding to use + local padding=0 + while read -r line; do + local FILE=${line%:*} + local META=${line##*:} + local SIZE=${META#*;} + + if [[ ${#SIZE} -gt $padding ]]; then + padding=${#SIZE} + fi + done < "$RESPONSE_FILE" + + #For each entry, printing directories... + while read -r line; do + + local FILE=${line%:*} + local META=${line##*:} + local TYPE=${META%;*} + local SIZE=${META#*;} + + #Removing unneeded / + FILE=${FILE##*/} + + if [[ $TYPE == "true" ]]; then + FILE=$(echo -e "$FILE") + $PRINTF " [D] %-${padding}s %s\n" "$SIZE" "$FILE" + fi + + done < "$RESPONSE_FILE" + + #For each entry, printing files... + while read -r line; do + + local FILE=${line%:*} + local META=${line##*:} + local TYPE=${META%;*} + local SIZE=${META#*;} + + #Removing unneeded / + FILE=${FILE##*/} + + if [[ $TYPE == "false" ]]; then + FILE=$(echo -e "$FILE") + $PRINTF " [F] %-${padding}s %s\n" "$SIZE" "$FILE" + fi + + done < "$RESPONSE_FILE" + + #It's a file + else + print "FAILED: $DIR_DST is not a directory!\n" + ERROR_STATUS=1 + fi + + else + print "FAILED\n" + ERROR_STATUS=1 + fi +} + +#Share remote file +#$1 = Remote file +function db_share +{ + local FILE_DST=$(normalize_path "$1") + + $CURL_BIN $CURL_ACCEPT_CERTIFICATES -s --show-error --globoff -i -o "$RESPONSE_FILE" "$API_SHARES_URL/$ACCESS_LEVEL/$(urlencode "$FILE_DST")?oauth_consumer_key=$APPKEY&oauth_token=$OAUTH_ACCESS_TOKEN&oauth_signature_method=PLAINTEXT&oauth_signature=$APPSECRET%26$OAUTH_ACCESS_TOKEN_SECRET&oauth_timestamp=$(utime)&oauth_nonce=$RANDOM&short_url=true" 2> /dev/null + check_http_response + + #Check + if grep -q "^HTTP/1.1 200 OK" "$RESPONSE_FILE"; then + print " > Share link: " + SHARE_LINK=$(sed -n 's/.*"url": "\([^"]*\).*/\1/p' "$RESPONSE_FILE") + echo "$SHARE_LINK" + else + print "FAILED\n" + ERROR_STATUS=1 + fi +} + +################ +#### SETUP #### +################ + +#CHECKING FOR AUTH FILE +if [[ -e $CONFIG_FILE ]]; then + + #Loading data... and change old format config if necesary. + source "$CONFIG_FILE" 2>/dev/null || { + sed -i'' 's/:/=/' "$CONFIG_FILE" && source "$CONFIG_FILE" 2>/dev/null + } + + #Checking the loaded data + if [[ $APPKEY == "" || $APPSECRET == "" || $OAUTH_ACCESS_TOKEN_SECRET == "" || $OAUTH_ACCESS_TOKEN == "" ]]; then + echo -ne "Error loading data from $CONFIG_FILE...\n" + echo -ne "It is recommended to run $0 unlink\n" + remove_temp_files + exit 1 + fi + + #Back compatibility with previous Dropbox Uploader versions + if [[ $ACCESS_LEVEL == "" ]]; then + ACCESS_LEVEL="dropbox" + fi + +#NEW SETUP... +else + + echo -ne "\n This is the first time you run this script.\n\n" + echo -ne " 1) Open the following URL in your Browser, and log in using your account: $APP_CREATE_URL\n" + echo -ne " 2) Click on \"Create App\", then select \"Dropbox API app\"\n" + echo -ne " 3) Now go on with the configuration, choosing the app permissions and access restrictions to your DropBox folder\n" + echo -ne " 4) Enter the \"App Name\" that you prefer (e.g. MyUploader$RANDOM$RANDOM$RANDOM)\n\n" + + echo -ne " Now, click on the \"Create App\" button.\n\n" + + echo -ne " When your new App is successfully created, please type the\n" + echo -ne " App Key, App Secret and the Permission type shown in the confirmation page:\n\n" + + #Getting the app key and secret from the user + while (true); do + + echo -ne " # App key: " + read APPKEY + + echo -ne " # App secret: " + read APPSECRET + + echo -ne "\nPermission type:\n App folder [a]: If you choose that the app only needs access to files it creates\n Full Dropbox [f]: If you choose that the app needs access to files already on Dropbox\n\n # Permission type [a/f]: " + read ACCESS_LEVEL + + if [[ $ACCESS_LEVEL == "a" ]]; then + ACCESS_LEVEL="sandbox" + ACCESS_MSG="App Folder" + else + ACCESS_LEVEL="dropbox" + ACCESS_MSG="Full Dropbox" + fi + + echo -ne "\n > App key is $APPKEY, App secret is $APPSECRET and Access level is $ACCESS_MSG. Looks ok? [y/n]: " + read answer + if [[ $answer == "y" ]]; then + break; + fi + + done + + #TOKEN REQUESTS + echo -ne "\n > Token request... " + $CURL_BIN $CURL_ACCEPT_CERTIFICATES -s --show-error --globoff -i -o "$RESPONSE_FILE" --data "oauth_consumer_key=$APPKEY&oauth_signature_method=PLAINTEXT&oauth_signature=$APPSECRET%26&oauth_timestamp=$(utime)&oauth_nonce=$RANDOM" "$API_REQUEST_TOKEN_URL" 2> /dev/null + check_http_response + OAUTH_TOKEN_SECRET=$(sed -n 's/oauth_token_secret=\([a-z A-Z 0-9]*\).*/\1/p' "$RESPONSE_FILE") + OAUTH_TOKEN=$(sed -n 's/.*oauth_token=\([a-z A-Z 0-9]*\)/\1/p' "$RESPONSE_FILE") + + if [[ $OAUTH_TOKEN != "" && $OAUTH_TOKEN_SECRET != "" ]]; then + echo -ne "OK\n" + else + echo -ne " FAILED\n\n Please, check your App key and secret...\n\n" + remove_temp_files + exit 1 + fi + + while (true); do + + #USER AUTH + echo -ne "\n Please open the following URL in your browser, and allow Dropbox Uploader\n" + echo -ne " to access your DropBox folder:\n\n --> ${API_USER_AUTH_URL}?oauth_token=$OAUTH_TOKEN\n" + echo -ne "\nPress enter when done...\n" + read + + #API_ACCESS_TOKEN_URL + echo -ne " > Access Token request... " + $CURL_BIN $CURL_ACCEPT_CERTIFICATES -s --show-error --globoff -i -o "$RESPONSE_FILE" --data "oauth_consumer_key=$APPKEY&oauth_token=$OAUTH_TOKEN&oauth_signature_method=PLAINTEXT&oauth_signature=$APPSECRET%26$OAUTH_TOKEN_SECRET&oauth_timestamp=$(utime)&oauth_nonce=$RANDOM" "$API_ACCESS_TOKEN_URL" 2> /dev/null + check_http_response + OAUTH_ACCESS_TOKEN_SECRET=$(sed -n 's/oauth_token_secret=\([a-z A-Z 0-9]*\)&.*/\1/p' "$RESPONSE_FILE") + OAUTH_ACCESS_TOKEN=$(sed -n 's/.*oauth_token=\([a-z A-Z 0-9]*\)&.*/\1/p' "$RESPONSE_FILE") + OAUTH_ACCESS_UID=$(sed -n 's/.*uid=\([0-9]*\)/\1/p' "$RESPONSE_FILE") + + if [[ $OAUTH_ACCESS_TOKEN != "" && $OAUTH_ACCESS_TOKEN_SECRET != "" && $OAUTH_ACCESS_UID != "" ]]; then + echo -ne "OK\n" + + #Saving data in new format, compatible with source command. + echo "APPKEY=$APPKEY" > "$CONFIG_FILE" + echo "APPSECRET=$APPSECRET" >> "$CONFIG_FILE" + echo "ACCESS_LEVEL=$ACCESS_LEVEL" >> "$CONFIG_FILE" + echo "OAUTH_ACCESS_TOKEN=$OAUTH_ACCESS_TOKEN" >> "$CONFIG_FILE" + echo "OAUTH_ACCESS_TOKEN_SECRET=$OAUTH_ACCESS_TOKEN_SECRET" >> "$CONFIG_FILE" + + echo -ne "\n Setup completed!\n" + break + else + print " FAILED\n" + ERROR_STATUS=1 + fi + + done; + + remove_temp_files + exit $ERROR_STATUS +fi + +################ +#### START #### +################ + +COMMAND=${@:$OPTIND:1} +ARG1=${@:$OPTIND+1:1} +ARG2=${@:$OPTIND+2:1} + +let argnum=$#-$OPTIND + +#CHECKING PARAMS VALUES +case $COMMAND in + + upload) + + if [[ $argnum -lt 2 ]]; then + usage + fi + + FILE_DST=${@:$#:1} + + for (( i=$OPTIND+1; i<$#; i++ )); do + FILE_SRC=${@:$i:1} + db_upload "$FILE_SRC" "/$FILE_DST" + done + + ;; + + download) + + if [[ $argnum -lt 1 ]]; then + usage + fi + + FILE_SRC=$ARG1 + FILE_DST=$ARG2 + + db_download "/$FILE_SRC" "$FILE_DST" + + ;; + + saveurl) + + if [[ $argnum -lt 1 ]]; then + usage + fi + + URL=$ARG1 + FILE_DST=$ARG2 + + db_saveurl "$URL" "/$FILE_DST" + + ;; + + share) + + if [[ $argnum -lt 1 ]]; then + usage + fi + + FILE_DST=$ARG1 + + db_share "/$FILE_DST" + + ;; + + info) + + db_account_info + + ;; + + delete|remove) + + if [[ $argnum -lt 1 ]]; then + usage + fi + + FILE_DST=$ARG1 + + db_delete "/$FILE_DST" + + ;; + + move|rename) + + if [[ $argnum -lt 2 ]]; then + usage + fi + + FILE_SRC=$ARG1 + FILE_DST=$ARG2 + + db_move "/$FILE_SRC" "/$FILE_DST" + + ;; + + copy) + + if [[ $argnum -lt 2 ]]; then + usage + fi + + FILE_SRC=$ARG1 + FILE_DST=$ARG2 + + db_copy "/$FILE_SRC" "/$FILE_DST" + + ;; + + mkdir) + + if [[ $argnum -lt 1 ]]; then + usage + fi + + DIR_DST=$ARG1 + + db_mkdir "/$DIR_DST" + + ;; + + list) + + DIR_DST=$ARG1 + + #Checking DIR_DST + if [[ $DIR_DST == "" ]]; then + DIR_DST="/" + fi + + db_list "/$DIR_DST" + + ;; + + unlink) + + db_unlink + + ;; + + *) + + if [[ $COMMAND != "" ]]; then + print "Error: Unknown command: $COMMAND\n\n" + ERROR_STATUS=1 + fi + usage + + ;; + +esac + +remove_temp_files +exit $ERROR_STATUS diff --git a/clientfiles/freepie-udp/com.freepie.android.imu.apk b/contrib/freepie-udp/com.freepie.android.imu.apk Binary files differindex b1f052aa..b1f052aa 100644 --- a/clientfiles/freepie-udp/com.freepie.android.imu.apk +++ b/contrib/freepie-udp/com.freepie.android.imu.apk diff --git a/clientfiles/freepie-udp/license.txt b/contrib/freepie-udp/license.txt index c40094f2..c40094f2 100644 --- a/clientfiles/freepie-udp/license.txt +++ b/contrib/freepie-udp/license.txt diff --git a/clientfiles/freetracktest/freetracktest.exe b/contrib/freetracktest/freetracktest.exe Binary files differindex 2965a07f..2965a07f 100644 --- a/clientfiles/freetracktest/freetracktest.exe +++ b/contrib/freetracktest/freetracktest.exe diff --git a/clientfiles/freetracktest/readme.txt b/contrib/freetracktest/readme.txt index ca40906f..ca40906f 100644 --- a/clientfiles/freetracktest/readme.txt +++ b/contrib/freetracktest/readme.txt diff --git a/clientfiles/fs2002 and fs2004/fsuipc.dll b/contrib/fs2002 and fs2004/fsuipc.dll Binary files differindex 264d14c5..264d14c5 100644 --- a/clientfiles/fs2002 and fs2004/fsuipc.dll +++ b/contrib/fs2002 and fs2004/fsuipc.dll diff --git a/clientfiles/glovepie/facetracknoir2trackir.pie b/contrib/glovepie/facetracknoir2trackir.pie index d0839e5d..d0839e5d 100644 --- a/clientfiles/glovepie/facetracknoir2trackir.pie +++ b/contrib/glovepie/facetracknoir2trackir.pie diff --git a/clientfiles/glovepie/readme.txt b/contrib/glovepie/readme.txt index 3639e26b..3639e26b 100644 --- a/clientfiles/glovepie/readme.txt +++ b/contrib/glovepie/readme.txt diff --git a/clientfiles/ppjoy/ppjoy mapping for facetracknoir.jpg b/contrib/ppjoy/ppjoy mapping for facetracknoir.jpg Binary files differindex 052c6899..052c6899 100644 --- a/clientfiles/ppjoy/ppjoy mapping for facetracknoir.jpg +++ b/contrib/ppjoy/ppjoy mapping for facetracknoir.jpg diff --git a/clientfiles/ppjoy/readme.txt b/contrib/ppjoy/readme.txt index 20c52111..20c52111 100644 --- a/clientfiles/ppjoy/readme.txt +++ b/contrib/ppjoy/readme.txt diff --git a/clientfiles/very-important-source-code/README-CREDIT.txt b/contrib/very-important-source-code/README-CREDIT.txt index 82214139..82214139 100644 --- a/clientfiles/very-important-source-code/README-CREDIT.txt +++ b/contrib/very-important-source-code/README-CREDIT.txt diff --git a/clientfiles/very-important-source-code/ft_tester/Makefile.am b/contrib/very-important-source-code/ft_tester/Makefile.am index 02747edb..02747edb 100644 --- a/clientfiles/very-important-source-code/ft_tester/Makefile.am +++ b/contrib/very-important-source-code/ft_tester/Makefile.am diff --git a/clientfiles/very-important-source-code/ft_tester/Makefile.in b/contrib/very-important-source-code/ft_tester/Makefile.in index d1fff34d..d1fff34d 100644 --- a/clientfiles/very-important-source-code/ft_tester/Makefile.in +++ b/contrib/very-important-source-code/ft_tester/Makefile.in diff --git a/clientfiles/very-important-source-code/ft_tester/fttester.rc.in b/contrib/very-important-source-code/ft_tester/fttester.rc.in index 332f3c73..332f3c73 100644 --- a/clientfiles/very-important-source-code/ft_tester/fttester.rc.in +++ b/contrib/very-important-source-code/ft_tester/fttester.rc.in diff --git a/clientfiles/very-important-source-code/ft_tester/main.cpp b/contrib/very-important-source-code/ft_tester/main.cpp index a737f88f..a737f88f 100644 --- a/clientfiles/very-important-source-code/ft_tester/main.cpp +++ b/contrib/very-important-source-code/ft_tester/main.cpp diff --git a/clientfiles/very-important-source-code/ft_tester/resource.h b/contrib/very-important-source-code/ft_tester/resource.h index 8bba17b4..8bba17b4 100644 --- a/clientfiles/very-important-source-code/ft_tester/resource.h +++ b/contrib/very-important-source-code/ft_tester/resource.h diff --git a/clientfiles/very-important-source-code/important-stuff/NPClient.h b/contrib/very-important-source-code/important-stuff/NPClient.h index 770e1c71..770e1c71 100644 --- a/clientfiles/very-important-source-code/important-stuff/NPClient.h +++ b/contrib/very-important-source-code/important-stuff/NPClient.h diff --git a/clientfiles/very-important-source-code/important-stuff/NPClient.spec b/contrib/very-important-source-code/important-stuff/NPClient.spec index 7fe5f1b4..7fe5f1b4 100644 --- a/clientfiles/very-important-source-code/important-stuff/NPClient.spec +++ b/contrib/very-important-source-code/important-stuff/NPClient.spec diff --git a/clientfiles/very-important-source-code/important-stuff/NPClient_dll.h b/contrib/very-important-source-code/important-stuff/NPClient_dll.h index b0bab5db..b0bab5db 100644 --- a/clientfiles/very-important-source-code/important-stuff/NPClient_dll.h +++ b/contrib/very-important-source-code/important-stuff/NPClient_dll.h diff --git a/clientfiles/very-important-source-code/important-stuff/NPClient_main.c b/contrib/very-important-source-code/important-stuff/NPClient_main.c index f892f89e..f892f89e 100644 --- a/clientfiles/very-important-source-code/important-stuff/NPClient_main.c +++ b/contrib/very-important-source-code/important-stuff/NPClient_main.c diff --git a/clientfiles/very-important-source-code/important-stuff/game_data.c b/contrib/very-important-source-code/important-stuff/game_data.c index 48774187..48774187 100644 --- a/clientfiles/very-important-source-code/important-stuff/game_data.c +++ b/contrib/very-important-source-code/important-stuff/game_data.c diff --git a/clientfiles/very-important-source-code/important-stuff/game_data.h b/contrib/very-important-source-code/important-stuff/game_data.h index b71f7a15..b71f7a15 100644 --- a/clientfiles/very-important-source-code/important-stuff/game_data.h +++ b/contrib/very-important-source-code/important-stuff/game_data.h diff --git a/clientfiles/very-important-source-code/make-csv.pl b/contrib/very-important-source-code/make-csv.pl index ee60364e..ee60364e 100644 --- a/clientfiles/very-important-source-code/make-csv.pl +++ b/contrib/very-important-source-code/make-csv.pl diff --git a/clientfiles/very-important-source-code/npclient.c b/contrib/very-important-source-code/npclient.c index 3878f809..3878f809 100644 --- a/clientfiles/very-important-source-code/npclient.c +++ b/contrib/very-important-source-code/npclient.c diff --git a/clientfiles/very-important-source-code/tester/Makefile.am b/contrib/very-important-source-code/tester/Makefile.am index e025209a..e025209a 100644 --- a/clientfiles/very-important-source-code/tester/Makefile.am +++ b/contrib/very-important-source-code/tester/Makefile.am diff --git a/clientfiles/very-important-source-code/tester/Makefile.in b/contrib/very-important-source-code/tester/Makefile.in index cc49d754..cc49d754 100644 --- a/clientfiles/very-important-source-code/tester/Makefile.in +++ b/contrib/very-important-source-code/tester/Makefile.in diff --git a/clientfiles/very-important-source-code/tester/main.cpp b/contrib/very-important-source-code/tester/main.cpp index 95ca0d9b..95ca0d9b 100644 --- a/clientfiles/very-important-source-code/tester/main.cpp +++ b/contrib/very-important-source-code/tester/main.cpp diff --git a/clientfiles/very-important-source-code/tester/npifc.c b/contrib/very-important-source-code/tester/npifc.c index b036464e..b036464e 100644 --- a/clientfiles/very-important-source-code/tester/npifc.c +++ b/contrib/very-important-source-code/tester/npifc.c diff --git a/clientfiles/very-important-source-code/tester/npifc.h b/contrib/very-important-source-code/tester/npifc.h index d580e16d..d580e16d 100644 --- a/clientfiles/very-important-source-code/tester/npifc.h +++ b/contrib/very-important-source-code/tester/npifc.h diff --git a/clientfiles/very-important-source-code/tester/npview.rc.in b/contrib/very-important-source-code/tester/npview.rc.in index 231002f1..231002f1 100644 --- a/clientfiles/very-important-source-code/tester/npview.rc.in +++ b/contrib/very-important-source-code/tester/npview.rc.in diff --git a/clientfiles/very-important-source-code/tester/resource.h b/contrib/very-important-source-code/tester/resource.h index 328d9cb7..328d9cb7 100644 --- a/clientfiles/very-important-source-code/tester/resource.h +++ b/contrib/very-important-source-code/tester/resource.h diff --git a/clientfiles/vjoy/VJoy.dll b/contrib/vjoy/VJoy.dll Binary files differindex e3446675..e3446675 100644 --- a/clientfiles/vjoy/VJoy.dll +++ b/contrib/vjoy/VJoy.dll diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp b/ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp index 57ee132c..eea1cbca 100644 --- a/ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp +++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp @@ -230,11 +230,11 @@ void FTNoIR_Tracker::Initialize( QFrame *videoframe ) } } else { - QMessageBox::warning(0,"FaceTrackNoIR Error", ComPort->errorString(),QMessageBox::Ok,QMessageBox::NoButton); + QMessageBox::warning(0,"Error", ComPort->errorString(),QMessageBox::Ok,QMessageBox::NoButton); } } else { - QMessageBox::warning(0,"FaceTrackNoIR Error", "Unable to open ComPort",QMessageBox::Ok,QMessageBox::NoButton); + QMessageBox::warning(0,"Error", "Unable to open ComPort",QMessageBox::Ok,QMessageBox::NoButton); delete ComPort; ComPort = NULL; } @@ -351,11 +351,11 @@ void FTNoIR_Tracker::start_tracker(QFrame*) Log("Port setup, waiting for HAT frames to process"); qDebug() << QTime::currentTime() << " HAT wait MPU "; } else { - QMessageBox::warning(0,"FaceTrackNoIR Error", ComPort->errorString(),QMessageBox::Ok,QMessageBox::NoButton); + QMessageBox::warning(0,"Error", ComPort->errorString(),QMessageBox::Ok,QMessageBox::NoButton); } } else { - QMessageBox::warning(0,"FaceTrackNoIR Error", "Unable to open ComPort: " + ComPort->errorString(), QMessageBox::Ok,QMessageBox::NoButton); + QMessageBox::warning(0,"Error", "Unable to open ComPort: " + ComPort->errorString(), QMessageBox::Ok,QMessageBox::NoButton); delete ComPort; ComPort = NULL; } diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.cpp b/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.cpp index 90cdeec1..3ef1a764 100644 --- a/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.cpp +++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.cpp @@ -37,7 +37,7 @@ TrackerControls::TrackerControls() : theTracker(NULL), settingsDirty(false), tim // Stop if no SerialPort dispo if (ui.cbSerialPort->count()<1) { - QMessageBox::critical(this,"FaceTrackNoIR Error", "No SerialPort avaible"); + QMessageBox::critical(this,"Error", "No SerialPort avaible"); } else { int indxport =ui.cbSerialPort->findText(settings.SerialPortName,Qt::MatchExactly ); @@ -45,7 +45,7 @@ TrackerControls::TrackerControls() : theTracker(NULL), settingsDirty(false), tim ui.cbSerialPort->setCurrentIndex(indxport); } else { if (settings.SerialPortName != "") - QMessageBox::warning(this,"FaceTrackNoIR Error", "Selected SerialPort modified"); + QMessageBox::warning(this,"Error", "Selected SerialPort modified"); ui.cbSerialPort-> setCurrentIndex(indxport); } } diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.h b/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.h index 7d0fcd83..ebaffc6d 100644 --- a/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.h +++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.h @@ -26,7 +26,7 @@ class TrackerControls: public QWidget, public ITrackerDialog Q_OBJECT public: explicit TrackerControls(); - virtual ~TrackerControls(); + ~TrackerControls() override; #ifdef OPENTRACK_API void Initialize(QWidget *parent) ; // unused void register_tracker(ITracker *tracker); diff --git a/ftnoir_tracker_rift/ftnoir_rift.qrc b/ftnoir_tracker_rift_025/ftnoir_rift_025.qrc index cd174fc4..cd174fc4 100644 --- a/ftnoir_tracker_rift/ftnoir_rift.qrc +++ b/ftnoir_tracker_rift_025/ftnoir_rift_025.qrc diff --git a/ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui b/ftnoir_tracker_rift_025/ftnoir_rift_clientcontrols_025.ui index 20c8f00b..20c8f00b 100644 --- a/ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui +++ b/ftnoir_tracker_rift_025/ftnoir_rift_clientcontrols_025.ui diff --git a/ftnoir_tracker_rift_025/ftnoir_tracker_rift_025.cpp b/ftnoir_tracker_rift_025/ftnoir_tracker_rift_025.cpp new file mode 100644 index 00000000..9588aaf8 --- /dev/null +++ b/ftnoir_tracker_rift_025/ftnoir_tracker_rift_025.cpp @@ -0,0 +1,92 @@ +/* Copyright: "i couldn't care less what anyone does with the 5 lines of code i wrote" - mm0zct */ +#include "ftnoir_tracker_rift_025.h" +#include "opentrack/plugin-api.hpp" +#include "OVR.h" +#include <cstdio> + +using namespace OVR; + +Rift_Tracker::Rift_Tracker() +{ + pManager = NULL; + pSensor = NULL; + pSFusion = NULL; + old_yaw = 0; +} + +Rift_Tracker::~Rift_Tracker() +{ + if (pSensor) + pSensor->Release(); + if (pSFusion) + delete pSFusion; + if (pManager) + pManager->Release(); + System::Destroy(); +} + +void Rift_Tracker::start_tracker(QFrame*) +{ + System::Init(Log::ConfigureDefaultLog(LogMask_All)); + pManager = DeviceManager::Create(); + if (pManager != NULL) + { + DeviceEnumerator<OVR::SensorDevice> enumerator = pManager->EnumerateDevices<OVR::SensorDevice>(); + if (enumerator.IsAvailable()) + { + pSensor = enumerator.CreateDevice(); + + if (pSensor) + { + pSFusion = new OVR::SensorFusion(); + pSFusion->Reset(); + pSFusion->AttachToSensor(pSensor); + } + else + { + QMessageBox::warning(0,"Error", "Unable to create Rift sensor",QMessageBox::Ok,QMessageBox::NoButton); + } + + } + else + { + QMessageBox::warning(0,"Error", "Unable to enumerate Rift tracker",QMessageBox::Ok,QMessageBox::NoButton); + } + } + else + { + QMessageBox::warning(0,"Error", "Unable to start Rift tracker",QMessageBox::Ok,QMessageBox::NoButton); + } +} + + +void Rift_Tracker::data(double *data) +{ + if (pSFusion != NULL && pSensor != NULL) + { + Quatf hmdOrient = pSFusion->GetOrientation(); + double newHeadPose[6]; + + float yaw = 0.0f; + float pitch = 0.0f; + float roll = 0.0f; + hmdOrient.GetEulerAngles<Axis_Y, Axis_X, Axis_Z>(&yaw, &pitch , &roll); + newHeadPose[Pitch] = pitch; + newHeadPose[Roll] = roll; + newHeadPose[Yaw] = yaw; + if (s.useYawSpring) + { + newHeadPose[Yaw] = old_yaw*s.persistence + (yaw-old_yaw); + if(newHeadPose[Yaw] > s.deadzone) + newHeadPose[Yaw] -= s.constant_drift; + if(newHeadPose[Yaw] < -s.deadzone) + newHeadPose[Yaw] += s.constant_drift; + old_yaw=yaw; + } + data[Yaw] = newHeadPose[Yaw] * 57.295781f; + data[Pitch] = newHeadPose[Pitch] * 57.295781f; + data[Roll] = newHeadPose[Roll] * 57.295781f; + } +} + +OPENTRACK_DECLARE_TRACKER(Rift_Tracker, TrackerControls, FTNoIR_TrackerDll) diff --git a/ftnoir_tracker_rift_025/ftnoir_tracker_rift_025.h b/ftnoir_tracker_rift_025/ftnoir_tracker_rift_025.h new file mode 100644 index 00000000..717cbe84 --- /dev/null +++ b/ftnoir_tracker_rift_025/ftnoir_tracker_rift_025.h @@ -0,0 +1,63 @@ +#pragma once +#include "ui_ftnoir_rift_clientcontrols_025.h" +#include <QMessageBox> +#include <QWaitCondition> +#include <cmath> +#include "opentrack/plugin-api.hpp" +#include "OVR.h" +#include <memory> +#include "opentrack/options.hpp" +using namespace options; + +struct settings : opts { + value<bool> useYawSpring; + value<double> constant_drift, persistence, deadzone; + settings() : + opts("Rift-025"), + useYawSpring(b, "yaw-spring", false), + constant_drift(b, "constant-drift", 0.000005), + persistence(b, "persistence", 0.99999), + deadzone(b, "deadzone", 0.02) + {} +}; + +class Rift_Tracker : public ITracker +{ +public: + Rift_Tracker(); + virtual ~Rift_Tracker() override; + void start_tracker(QFrame *) override; + void data(double *data) override; +private: + double old_yaw; + settings s; + static bool isInitialised; + OVR::DeviceManager* pManager; + OVR::SensorDevice* pSensor; + OVR::SensorFusion* pSFusion; +}; + +class TrackerControls: public ITrackerDialog +{ + Q_OBJECT +public: + TrackerControls(); + + void register_tracker(ITracker *) {} + void unregister_tracker() {} + +private: + Ui::UIRiftControls ui; + settings s; +private slots: + void doOK(); + void doCancel(); +}; + +class FTNoIR_TrackerDll : public Metadata +{ +public: + QString name() { return QString("Oculus Rift DK1 -- HMD"); } + QIcon icon() { return QIcon(":/images/rift_tiny.png"); } +}; + diff --git a/ftnoir_tracker_rift_025/ftnoir_tracker_rift_dialog_025.cpp b/ftnoir_tracker_rift_025/ftnoir_tracker_rift_dialog_025.cpp new file mode 100644 index 00000000..8100e362 --- /dev/null +++ b/ftnoir_tracker_rift_025/ftnoir_tracker_rift_dialog_025.cpp @@ -0,0 +1,26 @@ +#include "ftnoir_tracker_rift_025.h" +#include "opentrack/plugin-api.hpp" + +TrackerControls::TrackerControls() +{ + ui.setupUi( this ); + + connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); + connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); + + tie_setting(s.constant_drift, ui.constantDrift); + tie_setting(s.deadzone, ui.deadzone); + tie_setting(s.persistence, ui.persistence); + tie_setting(s.useYawSpring, ui.yawSpring); +} + +void TrackerControls::doOK() { + s.b->save(); + this->close(); +} + +void TrackerControls::doCancel() { + s.b->reload(); + close(); +} + diff --git a/ftnoir_tracker_rift/images/medium.png b/ftnoir_tracker_rift_025/images/medium.png Binary files differindex a5ba49e7..a5ba49e7 100644 --- a/ftnoir_tracker_rift/images/medium.png +++ b/ftnoir_tracker_rift_025/images/medium.png diff --git a/ftnoir_tracker_rift/images/rift_medium.png b/ftnoir_tracker_rift_025/images/rift_medium.png Binary files differindex a5ba49e7..a5ba49e7 100644 --- a/ftnoir_tracker_rift/images/rift_medium.png +++ b/ftnoir_tracker_rift_025/images/rift_medium.png diff --git a/ftnoir_tracker_rift/images/rift_small.png b/ftnoir_tracker_rift_025/images/rift_small.png Binary files differindex 3f18080c..3f18080c 100644 --- a/ftnoir_tracker_rift/images/rift_small.png +++ b/ftnoir_tracker_rift_025/images/rift_small.png diff --git a/ftnoir_tracker_rift/images/rift_tiny.png b/ftnoir_tracker_rift_025/images/rift_tiny.png Binary files differindex 76fe0f58..76fe0f58 100644 --- a/ftnoir_tracker_rift/images/rift_tiny.png +++ b/ftnoir_tracker_rift_025/images/rift_tiny.png diff --git a/ftnoir_tracker_rift/images/small.png b/ftnoir_tracker_rift_025/images/small.png Binary files differindex 3f18080c..3f18080c 100644 --- a/ftnoir_tracker_rift/images/small.png +++ b/ftnoir_tracker_rift_025/images/small.png diff --git a/ftnoir_tracker_rift/images/tiny.png b/ftnoir_tracker_rift_025/images/tiny.png Binary files differindex 76fe0f58..76fe0f58 100644 --- a/ftnoir_tracker_rift/images/tiny.png +++ b/ftnoir_tracker_rift_025/images/tiny.png diff --git a/ftnoir_tracker_rift_042/ftnoir_rift_042.qrc b/ftnoir_tracker_rift_042/ftnoir_rift_042.qrc new file mode 100644 index 00000000..cd174fc4 --- /dev/null +++ b/ftnoir_tracker_rift_042/ftnoir_rift_042.qrc @@ -0,0 +1,7 @@ +<RCC> + <qresource prefix="/"> + <file>images/rift_medium.png</file> + <file>images/rift_small.png</file> + <file>images/rift_tiny.png</file> + </qresource> +</RCC> diff --git a/ftnoir_tracker_rift_042/ftnoir_rift_clientcontrols_042.ui b/ftnoir_tracker_rift_042/ftnoir_rift_clientcontrols_042.ui new file mode 100644 index 00000000..20c8f00b --- /dev/null +++ b/ftnoir_tracker_rift_042/ftnoir_rift_clientcontrols_042.ui @@ -0,0 +1,176 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>UIRiftControls</class> + <widget class="QWidget" name="UIRiftControls"> + <property name="windowModality"> + <enum>Qt::NonModal</enum> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>218</width> + <height>200</height> + </rect> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="windowTitle"> + <string>Oculus Rift tracker settings FaceTrackNoIR</string> + </property> + <property name="windowIcon"> + <iconset> + <normaloff>images/FaceTrackNoIR.png</normaloff>images/FaceTrackNoIR.png</iconset> + </property> + <property name="layoutDirection"> + <enum>Qt::LeftToRight</enum> + </property> + <property name="autoFillBackground"> + <bool>false</bool> + </property> + <layout class="QGridLayout" name="gridLayout_2"> + <item row="0" column="0"> + <widget class="QGroupBox" name="groupBox"> + <property name="title"> + <string>Yaw spring</string> + </property> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0"> + <widget class="QCheckBox" name="yawSpring"> + <property name="text"> + <string>Enable</string> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Persistence</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QDoubleSpinBox" name="persistence"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>0</width> + <height>23</height> + </size> + </property> + <property name="decimals"> + <number>5</number> + </property> + <property name="minimum"> + <double>0.900000000000000</double> + </property> + <property name="maximum"> + <double>1.000000000000000</double> + </property> + <property name="singleStep"> + <double>0.001000000000000</double> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="label_2"> + <property name="text"> + <string>Constant drift</string> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QDoubleSpinBox" name="constantDrift"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>0</width> + <height>23</height> + </size> + </property> + <property name="decimals"> + <number>5</number> + </property> + <property name="minimum"> + <double>0.000100000000000</double> + </property> + <property name="maximum"> + <double>0.100000000000000</double> + </property> + <property name="singleStep"> + <double>0.001000000000000</double> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QLabel" name="label_3"> + <property name="text"> + <string>Deadzone</string> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QDoubleSpinBox" name="deadzone"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>0</width> + <height>23</height> + </size> + </property> + <property name="decimals"> + <number>5</number> + </property> + <property name="maximum"> + <double>0.100000000000000</double> + </property> + <property name="singleStep"> + <double>0.010000000000000</double> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item row="1" column="0"> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections/> + <slots> + <slot>startEngineClicked()</slot> + <slot>stopEngineClicked()</slot> + <slot>cameraSettingsClicked()</slot> + </slots> +</ui> diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp b/ftnoir_tracker_rift_042/ftnoir_tracker_rift_042.cpp index 74208272..deea4a08 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp +++ b/ftnoir_tracker_rift_042/ftnoir_tracker_rift_042.cpp @@ -1,5 +1,5 @@ /* Copyright: "i couldn't care less what anyone does with the 5 lines of code i wrote" - mm0zct */ -#include "ftnoir_tracker_rift.h" +#include "ftnoir_tracker_rift_042.h" #include "opentrack/plugin-api.hpp" #include "OVR_CAPI.h" #include "Kernel/OVR_Math.h" @@ -29,7 +29,7 @@ void Rift_Tracker::start_tracker(QFrame*) { // XXX need change ITracker et al api to allow for failure reporting // this qmessagebox doesn't give any relevant details either -sh 20141012 - QMessageBox::warning(0,"FaceTrackNoIR Error", "Unable to start Rift tracker",QMessageBox::Ok,QMessageBox::NoButton); + QMessageBox::warning(0,"Error", "Unable to start Rift tracker",QMessageBox::Ok,QMessageBox::NoButton); } } diff --git a/ftnoir_tracker_rift_042/ftnoir_tracker_rift_042.h b/ftnoir_tracker_rift_042/ftnoir_tracker_rift_042.h new file mode 100644 index 00000000..437a2a39 --- /dev/null +++ b/ftnoir_tracker_rift_042/ftnoir_tracker_rift_042.h @@ -0,0 +1,60 @@ +#pragma once +#include "ui_ftnoir_rift_clientcontrols_042.h" +#include <QMessageBox> +#include <QWaitCondition> +#include <cmath> +#include "opentrack/plugin-api.hpp" +#include "OVR.h" +#include <memory> +#include "opentrack/options.hpp" +using namespace options; + +struct settings : opts { + value<bool> useYawSpring; + value<double> constant_drift, persistence, deadzone; + settings() : + opts("Rift"), + useYawSpring(b, "yaw-spring", false), + constant_drift(b, "constant-drift", 0.000005), + persistence(b, "persistence", 0.99999), + deadzone(b, "deadzone", 0.02) + {} +}; + +class Rift_Tracker : public ITracker +{ +public: + Rift_Tracker(); + virtual ~Rift_Tracker() override; + void start_tracker(QFrame *) override; + void data(double *data) override; +private: + double old_yaw; + ovrHmd hmd; + settings s; +}; + +class TrackerControls: public ITrackerDialog +{ + Q_OBJECT +public: + TrackerControls(); + + void register_tracker(ITracker *) {} + void unregister_tracker() {} + +private: + Ui::UIRiftControls ui; + settings s; +private slots: + void doOK(); + void doCancel(); +}; + +class FTNoIR_TrackerDll : public Metadata +{ +public: + QString name() { return QString("Oculus Rift runtime 0.4.2 -- HMD"); } + QIcon icon() { return QIcon(":/images/rift_tiny.png"); } +}; + diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp b/ftnoir_tracker_rift_042/ftnoir_tracker_rift_dialog_042.cpp index 6c8e9cd7..9a8b7549 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp +++ b/ftnoir_tracker_rift_042/ftnoir_tracker_rift_dialog_042.cpp @@ -1,4 +1,4 @@ -#include "ftnoir_tracker_rift.h" +#include "ftnoir_tracker_rift_042.h" #include "opentrack/plugin-api.hpp" TrackerControls::TrackerControls() diff --git a/ftnoir_tracker_rift_042/images/medium.png b/ftnoir_tracker_rift_042/images/medium.png Binary files differnew file mode 100644 index 00000000..a5ba49e7 --- /dev/null +++ b/ftnoir_tracker_rift_042/images/medium.png diff --git a/ftnoir_tracker_rift_042/images/rift_medium.png b/ftnoir_tracker_rift_042/images/rift_medium.png Binary files differnew file mode 100644 index 00000000..a5ba49e7 --- /dev/null +++ b/ftnoir_tracker_rift_042/images/rift_medium.png diff --git a/ftnoir_tracker_rift_042/images/rift_small.png b/ftnoir_tracker_rift_042/images/rift_small.png Binary files differnew file mode 100644 index 00000000..3f18080c --- /dev/null +++ b/ftnoir_tracker_rift_042/images/rift_small.png diff --git a/ftnoir_tracker_rift_042/images/rift_tiny.png b/ftnoir_tracker_rift_042/images/rift_tiny.png Binary files differnew file mode 100644 index 00000000..76fe0f58 --- /dev/null +++ b/ftnoir_tracker_rift_042/images/rift_tiny.png diff --git a/ftnoir_tracker_rift_042/images/small.png b/ftnoir_tracker_rift_042/images/small.png Binary files differnew file mode 100644 index 00000000..3f18080c --- /dev/null +++ b/ftnoir_tracker_rift_042/images/small.png diff --git a/ftnoir_tracker_rift_042/images/tiny.png b/ftnoir_tracker_rift_042/images/tiny.png Binary files differnew file mode 100644 index 00000000..76fe0f58 --- /dev/null +++ b/ftnoir_tracker_rift_042/images/tiny.png diff --git a/ftnoir_tracker_rift_080/ftnoir_rift_080.qrc b/ftnoir_tracker_rift_080/ftnoir_rift_080.qrc new file mode 100644 index 00000000..cd174fc4 --- /dev/null +++ b/ftnoir_tracker_rift_080/ftnoir_rift_080.qrc @@ -0,0 +1,7 @@ +<RCC> + <qresource prefix="/"> + <file>images/rift_medium.png</file> + <file>images/rift_small.png</file> + <file>images/rift_tiny.png</file> + </qresource> +</RCC> diff --git a/ftnoir_tracker_rift_080/ftnoir_rift_clientcontrols_080.ui b/ftnoir_tracker_rift_080/ftnoir_rift_clientcontrols_080.ui new file mode 100644 index 00000000..20c8f00b --- /dev/null +++ b/ftnoir_tracker_rift_080/ftnoir_rift_clientcontrols_080.ui @@ -0,0 +1,176 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>UIRiftControls</class> + <widget class="QWidget" name="UIRiftControls"> + <property name="windowModality"> + <enum>Qt::NonModal</enum> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>218</width> + <height>200</height> + </rect> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="windowTitle"> + <string>Oculus Rift tracker settings FaceTrackNoIR</string> + </property> + <property name="windowIcon"> + <iconset> + <normaloff>images/FaceTrackNoIR.png</normaloff>images/FaceTrackNoIR.png</iconset> + </property> + <property name="layoutDirection"> + <enum>Qt::LeftToRight</enum> + </property> + <property name="autoFillBackground"> + <bool>false</bool> + </property> + <layout class="QGridLayout" name="gridLayout_2"> + <item row="0" column="0"> + <widget class="QGroupBox" name="groupBox"> + <property name="title"> + <string>Yaw spring</string> + </property> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0"> + <widget class="QCheckBox" name="yawSpring"> + <property name="text"> + <string>Enable</string> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Persistence</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QDoubleSpinBox" name="persistence"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>0</width> + <height>23</height> + </size> + </property> + <property name="decimals"> + <number>5</number> + </property> + <property name="minimum"> + <double>0.900000000000000</double> + </property> + <property name="maximum"> + <double>1.000000000000000</double> + </property> + <property name="singleStep"> + <double>0.001000000000000</double> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="label_2"> + <property name="text"> + <string>Constant drift</string> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QDoubleSpinBox" name="constantDrift"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>0</width> + <height>23</height> + </size> + </property> + <property name="decimals"> + <number>5</number> + </property> + <property name="minimum"> + <double>0.000100000000000</double> + </property> + <property name="maximum"> + <double>0.100000000000000</double> + </property> + <property name="singleStep"> + <double>0.001000000000000</double> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QLabel" name="label_3"> + <property name="text"> + <string>Deadzone</string> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QDoubleSpinBox" name="deadzone"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>0</width> + <height>23</height> + </size> + </property> + <property name="decimals"> + <number>5</number> + </property> + <property name="maximum"> + <double>0.100000000000000</double> + </property> + <property name="singleStep"> + <double>0.010000000000000</double> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item row="1" column="0"> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections/> + <slots> + <slot>startEngineClicked()</slot> + <slot>stopEngineClicked()</slot> + <slot>cameraSettingsClicked()</slot> + </slots> +</ui> diff --git a/ftnoir_tracker_rift_080/ftnoir_tracker_rift_080.cpp b/ftnoir_tracker_rift_080/ftnoir_tracker_rift_080.cpp new file mode 100644 index 00000000..5495e0e3 --- /dev/null +++ b/ftnoir_tracker_rift_080/ftnoir_tracker_rift_080.cpp @@ -0,0 +1,69 @@ +/* Copyright: "i couldn't care less what anyone does with the 5 lines of code i wrote" - mm0zct */ +#include "ftnoir_tracker_rift_080.h" +#include "opentrack/plugin-api.hpp" +#include "OVR_CAPI.h" +#include "Extras/OVR_Math.h" +#include "OVR_CAPI_0_8_0.h" +#include <cstdio> + +using namespace OVR; + +Rift_Tracker::Rift_Tracker() : old_yaw(0), hmd(nullptr) +{ +} + +Rift_Tracker::~Rift_Tracker() +{ + if (hmd) + ovr_Destroy(hmd); + ovr_Shutdown(); +} + +void Rift_Tracker::start_tracker(QFrame*) +{ + ovrGraphicsLuid luid; + ovrResult result = ovr_Create(&hmd, &luid); + if (OVR_SUCCESS(result)) + { + ovr_ConfigureTracking(hmd, ovrTrackingCap_Orientation | ovrTrackingCap_MagYawCorrection | ovrTrackingCap_Position, ovrTrackingCap_Orientation); + } + else + { + // XXX need change ITracker et al api to allow for failure reporting + // this qmessagebox doesn't give any relevant details either -sh 20141012 + QMessageBox::warning(0,"Error", "Unable to start Rift tracker",QMessageBox::Ok,QMessageBox::NoButton); + } +} + +void Rift_Tracker::data(double *data) +{ + if (hmd) + { + ovrTrackingState ss = ovr_GetTrackingState(hmd, 0, false); + if(ss.StatusFlags & ovrStatus_OrientationTracked) { + auto pose = ss.HeadPose.ThePose; + Quatf quat = pose.Orientation; + float yaw, pitch, roll; + quat.GetEulerAngles<Axis_Y, Axis_X, Axis_Z>(&yaw, &pitch, &roll); + // XXX TODO move to core + if (s.useYawSpring) + { + yaw = old_yaw*s.persistence + (yaw-old_yaw); + if(yaw > s.deadzone) + yaw -= s.constant_drift; + if(yaw < -s.deadzone) + yaw += s.constant_drift; + old_yaw=yaw; + } + constexpr double d2r = 57.295781; + data[Yaw] = yaw * -d2r; + data[Pitch] = pitch * d2r; + data[Roll] = roll * d2r; + data[TX] = pose.Position.x * -1e2; + data[TY] = pose.Position.y * 1e2; + data[TZ] = pose.Position.z * 1e2; + } + } +} + +OPENTRACK_DECLARE_TRACKER(Rift_Tracker, TrackerControls, FTNoIR_TrackerDll) diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift.h b/ftnoir_tracker_rift_080/ftnoir_tracker_rift_080.h index 231648dd..08684dd2 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift.h +++ b/ftnoir_tracker_rift_080/ftnoir_tracker_rift_080.h @@ -1,5 +1,5 @@ #pragma once -#include "ui_ftnoir_rift_clientcontrols.h" +#include "ui_ftnoir_rift_clientcontrols_080.h" #include <QMessageBox> #include <QWaitCondition> #include <cmath> @@ -30,7 +30,7 @@ public: void data(double *data) override; private: double old_yaw; - ovrHmd hmd; + ovrSession hmd; settings s; }; @@ -54,7 +54,7 @@ private slots: class FTNoIR_TrackerDll : public Metadata { public: - QString name() { return QString("Oculus Rift -- HMD"); } + QString name() { return QString("Oculus Rift runtime 0.8.0 -- HMD"); } QIcon icon() { return QIcon(":/images/rift_tiny.png"); } }; diff --git a/ftnoir_tracker_rift_080/ftnoir_tracker_rift_dialog_080.cpp b/ftnoir_tracker_rift_080/ftnoir_tracker_rift_dialog_080.cpp new file mode 100644 index 00000000..0bf797be --- /dev/null +++ b/ftnoir_tracker_rift_080/ftnoir_tracker_rift_dialog_080.cpp @@ -0,0 +1,26 @@ +#include "ftnoir_tracker_rift_080.h" +#include "opentrack/plugin-api.hpp" + +TrackerControls::TrackerControls() +{ + ui.setupUi( this ); + + connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); + connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); + + tie_setting(s.constant_drift, ui.constantDrift); + tie_setting(s.deadzone, ui.deadzone); + tie_setting(s.persistence, ui.persistence); + tie_setting(s.useYawSpring, ui.yawSpring); +} + +void TrackerControls::doOK() { + s.b->save(); + this->close(); +} + +void TrackerControls::doCancel() { + s.b->reload(); + close(); +} + diff --git a/ftnoir_tracker_rift_080/images/medium.png b/ftnoir_tracker_rift_080/images/medium.png Binary files differnew file mode 100644 index 00000000..a5ba49e7 --- /dev/null +++ b/ftnoir_tracker_rift_080/images/medium.png diff --git a/ftnoir_tracker_rift_080/images/rift_medium.png b/ftnoir_tracker_rift_080/images/rift_medium.png Binary files differnew file mode 100644 index 00000000..a5ba49e7 --- /dev/null +++ b/ftnoir_tracker_rift_080/images/rift_medium.png diff --git a/ftnoir_tracker_rift_080/images/rift_small.png b/ftnoir_tracker_rift_080/images/rift_small.png Binary files differnew file mode 100644 index 00000000..3f18080c --- /dev/null +++ b/ftnoir_tracker_rift_080/images/rift_small.png diff --git a/ftnoir_tracker_rift_080/images/rift_tiny.png b/ftnoir_tracker_rift_080/images/rift_tiny.png Binary files differnew file mode 100644 index 00000000..76fe0f58 --- /dev/null +++ b/ftnoir_tracker_rift_080/images/rift_tiny.png diff --git a/ftnoir_tracker_rift_080/images/small.png b/ftnoir_tracker_rift_080/images/small.png Binary files differnew file mode 100644 index 00000000..3f18080c --- /dev/null +++ b/ftnoir_tracker_rift_080/images/small.png diff --git a/ftnoir_tracker_rift_080/images/tiny.png b/ftnoir_tracker_rift_080/images/tiny.png Binary files differnew file mode 100644 index 00000000..76fe0f58 --- /dev/null +++ b/ftnoir_tracker_rift_080/images/tiny.png diff --git a/ftnoir_tracker_rs/ftnoir_tracker_rs.cpp b/ftnoir_tracker_rs/ftnoir_tracker_rs.cpp index f17d7fcb..3e9b23c8 100644 --- a/ftnoir_tracker_rs/ftnoir_tracker_rs.cpp +++ b/ftnoir_tracker_rs/ftnoir_tracker_rs.cpp @@ -81,7 +81,7 @@ void RSTracker::rsImplProcessFinished(int exitCode){ msgBox.exec(); if(msgBox.clickedButton() == triggerSdkInstallation){ - bool pStarted = QProcess::startDetached("clientfiles\\intel_rs_sdk_runtime_websetup_6.0.21.6598.exe --finstall=core,face3d --fnone=all"); + bool pStarted = QProcess::startDetached("contrib\\intel_rs_sdk_runtime_websetup_6.0.21.6598.exe --finstall=core,face3d --fnone=all"); if(!pStarted){ QMessageBox::warning(0, "IntelĀ® RealSenseā¢ Runtime Installation", "Installation process failed to start.", QMessageBox::Ok); } diff --git a/ftnoir_tracker_rs/ftnoir_tracker_rs_controls.cpp b/ftnoir_tracker_rs/ftnoir_tracker_rs_controls.cpp index e5187bd1..6c71d58f 100644 --- a/ftnoir_tracker_rs/ftnoir_tracker_rs_controls.cpp +++ b/ftnoir_tracker_rs/ftnoir_tracker_rs_controls.cpp @@ -20,7 +20,7 @@ RSTrackerControls::RSTrackerControls() void RSTrackerControls::doInstallRSRuntime() { - bool processStarted = QProcess::startDetached("clientfiles\\intel_rs_sdk_runtime_websetup_6.0.21.6598.exe --finstall=core,face3d --fnone=all"); + bool processStarted = QProcess::startDetached("contrib\\intel_rs_sdk_runtime_websetup_6.0.21.6598.exe --finstall=core,face3d --fnone=all"); if(processStarted){ this->close(); } |