summaryrefslogtreecommitdiffhomepage
path: root/contrib
diff options
context:
space:
mode:
Diffstat (limited to 'contrib')
-rw-r--r--contrib/FlightGear/Protocol/headtracker.xml54
-rw-r--r--contrib/FlightGear/readme.txt8
-rw-r--r--contrib/Tir4Fun/npclient.dllbin0 -> 53248 bytes
-rw-r--r--contrib/Tir4Fun/readme.txt9
-rw-r--r--contrib/Tir4Fun/tir4fun.exebin0 -> 36864 bytes
-rw-r--r--contrib/aruco/aruco_create_marker.exebin0 -> 826368 bytes
-rw-r--r--contrib/aruco/test3.jpgbin0 -> 2145 bytes
-rw-r--r--contrib/cfs3/readme.txt27
-rw-r--r--contrib/cfs3/tirviews.dllbin0 -> 109568 bytes
-rw-r--r--contrib/cute-octopus-vector-material_15-1831.jpgbin0 -> 71514 bytes
-rw-r--r--contrib/dropbox-uploader/README1
-rw-r--r--contrib/dropbox-uploader/dropbox_uploader.sh1364
-rw-r--r--contrib/freepie-udp/com.freepie.android.imu.apkbin0 -> 167989 bytes
-rw-r--r--contrib/freepie-udp/license.txt22
-rw-r--r--contrib/freetracktest/freetracktest.exebin0 -> 398848 bytes
-rw-r--r--contrib/freetracktest/readme.txt20
-rw-r--r--contrib/fs2002 and fs2004/fsuipc.dllbin0 -> 210880 bytes
-rw-r--r--contrib/glovepie/facetracknoir2trackir.pie16
-rw-r--r--contrib/glovepie/readme.txt24
-rw-r--r--contrib/ppjoy/ppjoy mapping for facetracknoir.jpgbin0 -> 155205 bytes
-rw-r--r--contrib/ppjoy/readme.txt24
-rw-r--r--contrib/very-important-source-code/README-CREDIT.txt6
-rw-r--r--contrib/very-important-source-code/ft_tester/Makefile.am54
-rw-r--r--contrib/very-important-source-code/ft_tester/Makefile.in491
-rw-r--r--contrib/very-important-source-code/ft_tester/fttester.rc.in67
-rw-r--r--contrib/very-important-source-code/ft_tester/main.cpp211
-rw-r--r--contrib/very-important-source-code/ft_tester/resource.h27
-rw-r--r--contrib/very-important-source-code/important-stuff/NPClient.h17
-rw-r--r--contrib/very-important-source-code/important-stuff/NPClient.spec23
-rw-r--r--contrib/very-important-source-code/important-stuff/NPClient_dll.h58
-rw-r--r--contrib/very-important-source-code/important-stuff/NPClient_main.c444
-rw-r--r--contrib/very-important-source-code/important-stuff/game_data.c166
-rw-r--r--contrib/very-important-source-code/important-stuff/game_data.h17
-rw-r--r--contrib/very-important-source-code/make-csv.pl72
-rw-r--r--contrib/very-important-source-code/npclient.c587
-rw-r--r--contrib/very-important-source-code/tester/Makefile.am78
-rw-r--r--contrib/very-important-source-code/tester/Makefile.in512
-rw-r--r--contrib/very-important-source-code/tester/main.cpp100
-rw-r--r--contrib/very-important-source-code/tester/npifc.c302
-rw-r--r--contrib/very-important-source-code/tester/npifc.h66
-rw-r--r--contrib/very-important-source-code/tester/npview.rc.in49
-rw-r--r--contrib/very-important-source-code/tester/resource.h23
-rw-r--r--contrib/vjoy/VJoy.dllbin0 -> 94208 bytes
43 files changed, 4939 insertions, 0 deletions
diff --git a/contrib/FlightGear/Protocol/headtracker.xml b/contrib/FlightGear/Protocol/headtracker.xml
new file mode 100644
index 00000000..8c14119a
--- /dev/null
+++ b/contrib/FlightGear/Protocol/headtracker.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0"?>
+
+<PropertyList>
+ <generic>
+ <input>
+ <binary_mode>true</binary_mode>
+ <binary_footer>none</binary_footer>
+ <byte_order>host</byte_order>
+ <record_length>52</record_length>
+
+ <chunk>
+ <name>x</name>
+ <type>double</type>
+ <node>/sim/current-view/x-offset-m</node>
+ </chunk>
+
+ <chunk>
+ <name>y</name>
+ <type>double</type>
+ <node>/sim/current-view/y-offset-m</node>
+ </chunk>
+
+ <chunk>
+ <name>z</name>
+ <type>double</type>
+ <node>/sim/current-view/z-offset-m</node>
+ </chunk>
+
+ <chunk>
+ <name>heading</name>
+ <type>double</type>
+ <node>/sim/current-view/heading-offset-deg</node>
+ </chunk>
+
+ <chunk>
+ <name>pitch</name>
+ <type>double</type>
+ <node>/sim/current-view/pitch-offset-deg</node>
+ </chunk>
+
+ <chunk>
+ <name>roll</name>
+ <type>double</type>
+ <node>/sim/current-view/roll-offset-deg</node>
+ </chunk>
+
+ <chunk>
+ <name>status</name>
+ <type>int</type>
+ <node>/sim/current-view/headtracker-debug-status</node>
+ </chunk>
+ </input>
+ </generic>
+</PropertyList>
diff --git a/contrib/FlightGear/readme.txt b/contrib/FlightGear/readme.txt
new file mode 100644
index 00000000..48cee837
--- /dev/null
+++ b/contrib/FlightGear/readme.txt
@@ -0,0 +1,8 @@
+Copy Protocol/headtracker.xml to fgdata/Protocol/headtracker.xml
+
+$ fgfs --generic=socket,in,25,localhost,5542,udp,headtracker
+
+Adjust paths as necessary.
+
+cheers,
+-sh 20131008
diff --git a/contrib/Tir4Fun/npclient.dll b/contrib/Tir4Fun/npclient.dll
new file mode 100644
index 00000000..e392442e
--- /dev/null
+++ b/contrib/Tir4Fun/npclient.dll
Binary files differ
diff --git a/contrib/Tir4Fun/readme.txt b/contrib/Tir4Fun/readme.txt
new file mode 100644
index 00000000..d64af301
--- /dev/null
+++ b/contrib/Tir4Fun/readme.txt
@@ -0,0 +1,9 @@
+What is TIR4FUN?
+
+TIR4FUN is a free utility for dedicated gamers. It enables 6DOF POV control with mouse and joystick axes.
+
+Software is provided as it is. Configuration is straightforward. GUI says it all!
+
+Installation:
+
+Copy all files to a directory. Launch tir4fun.exe to bring up the GUI.
diff --git a/contrib/Tir4Fun/tir4fun.exe b/contrib/Tir4Fun/tir4fun.exe
new file mode 100644
index 00000000..a51eced0
--- /dev/null
+++ b/contrib/Tir4Fun/tir4fun.exe
Binary files differ
diff --git a/contrib/aruco/aruco_create_marker.exe b/contrib/aruco/aruco_create_marker.exe
new file mode 100644
index 00000000..4400e80e
--- /dev/null
+++ b/contrib/aruco/aruco_create_marker.exe
Binary files differ
diff --git a/contrib/aruco/test3.jpg b/contrib/aruco/test3.jpg
new file mode 100644
index 00000000..2ff6dbd0
--- /dev/null
+++ b/contrib/aruco/test3.jpg
Binary files differ
diff --git a/contrib/cfs3/readme.txt b/contrib/cfs3/readme.txt
new file mode 100644
index 00000000..e51cebfa
--- /dev/null
+++ b/contrib/cfs3/readme.txt
@@ -0,0 +1,27 @@
+FaceTrackNoIR for
+
+ * Combat Flight Simulator 3 (also works for Over Flanders Fields)
+ * Wings of War
+ * NASCAR Racing Season 2003
+ * Colin McRae Rally 4
+ * Race Driver 2
+ * F1 Challenge
+ * Richard Burns Rally
+
+FaceTrackNoIR was made compatible with these programs with the help of the functions TrackIR provides in the dll TIRViews.dll.
+This dll can be downloaded from the TrackIR website: http://www.naturalpoint.com/trackir/06-support/support-download-software-and-manuals.html
+
+To make the functions work, copy the dll in the FaceTrackNoIR installation folder. Then tick the 'use TIRViews.dll' checkbox for the 'fake TrackIR' game protocol.
+
+Please let us know if you like the program, if you have ideas for improvements or any questions you might have.
+
+
+
+The FaceTrackNoIR team:
+
+Wim Vriend
+Ron Hendriks
+
+
+
+Disclaimer: For usage of 3rd party software like FlightGear, the FaceTrackNoIR team is not responsible. Use it at your own risk. \ No newline at end of file
diff --git a/contrib/cfs3/tirviews.dll b/contrib/cfs3/tirviews.dll
new file mode 100644
index 00000000..a1fb306f
--- /dev/null
+++ b/contrib/cfs3/tirviews.dll
Binary files differ
diff --git a/contrib/cute-octopus-vector-material_15-1831.jpg b/contrib/cute-octopus-vector-material_15-1831.jpg
new file mode 100644
index 00000000..c4e5318f
--- /dev/null
+++ b/contrib/cute-octopus-vector-material_15-1831.jpg
Binary files differ
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/contrib/freepie-udp/com.freepie.android.imu.apk b/contrib/freepie-udp/com.freepie.android.imu.apk
new file mode 100644
index 00000000..b1f052aa
--- /dev/null
+++ b/contrib/freepie-udp/com.freepie.android.imu.apk
Binary files differ
diff --git a/contrib/freepie-udp/license.txt b/contrib/freepie-udp/license.txt
new file mode 100644
index 00000000..c40094f2
--- /dev/null
+++ b/contrib/freepie-udp/license.txt
@@ -0,0 +1,22 @@
+The MIT License (MIT)
+
+Copyright (c) 2012-2015 Anders Malmgren
+Copyright (c) 2014-2015 Stanislaw Halik
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/contrib/freetracktest/freetracktest.exe b/contrib/freetracktest/freetracktest.exe
new file mode 100644
index 00000000..2965a07f
--- /dev/null
+++ b/contrib/freetracktest/freetracktest.exe
Binary files differ
diff --git a/contrib/freetracktest/readme.txt b/contrib/freetracktest/readme.txt
new file mode 100644
index 00000000..ca40906f
--- /dev/null
+++ b/contrib/freetracktest/readme.txt
@@ -0,0 +1,20 @@
+FaceTrackNoIR for Free-track 'enabled' games.
+
+FaceTrackNoIR was made compatible with the Free-track protocol, for which the Free-track source (a well, part of it) was
+translated from Delphi Pascal to C++ (Visual Studio C++, with Qt).
+
+To start the Free-track protocol-server in FaceTrackNoIR, select Free-track in the 'game-protocol' listbox. The program
+'FreeTrackTest.exe' is provided to check, if the protocol-server is running.
+
+FreeTrackTest.exe was created by the Free-track team.
+
+
+
+The FaceTrackNoIR team:
+
+Wim Vriend
+Ron Hendriks
+
+
+
+Disclaimer: For usage of 3rd party software like FreeTrackTest, the FaceTrackNoIR team is not responsible. Use it at your own risk. \ No newline at end of file
diff --git a/contrib/fs2002 and fs2004/fsuipc.dll b/contrib/fs2002 and fs2004/fsuipc.dll
new file mode 100644
index 00000000..264d14c5
--- /dev/null
+++ b/contrib/fs2002 and fs2004/fsuipc.dll
Binary files differ
diff --git a/contrib/glovepie/facetracknoir2trackir.pie b/contrib/glovepie/facetracknoir2trackir.pie
new file mode 100644
index 00000000..d0839e5d
--- /dev/null
+++ b/contrib/glovepie/facetracknoir2trackir.pie
@@ -0,0 +1,16 @@
+//
+// 6 Degrees of Freedom Headtracking with FaceTrackNoIR
+// 2010 by Wim Vriend
+//
+pie.FrameRate = 120Hz
+var.multiply = 1.5
+var.R2D = 57.295781
+FakeTrackIR.pitch=(Joystick.pitch - 0.10) * var.R2D * var.multiply
+FakeTrackIR.yaw=(Joystick.yaw - 0.10) * var.R2D * var.multiply
+FakeTrackIR.roll=(Joystick.roll - 0.10) * var.R2D * var.multiply
+FakeTrackIR.x=(Joystick.x - 0.10) * var.R2D * var.multiply
+FakeTrackIR.y=(Joystick.y - 0.10) * var.R2D * var.multiply
+FakeTrackIR.z=(Joystick.z - 0.10) * var.R2D * var.multiply
+debug = 'pitch='+FakeTrackIR.pitch+' roll='+FakeTrackIR.roll+' yaw='+FakeTrackIR.yaw+' xyz=('+FakeTrackIR.x+','+FakeTrackIR.y+','+FakeTrackIR.z+')'
+//debug = FakeTrackIR.active
+
diff --git a/contrib/glovepie/readme.txt b/contrib/glovepie/readme.txt
new file mode 100644
index 00000000..3639e26b
--- /dev/null
+++ b/contrib/glovepie/readme.txt
@@ -0,0 +1,24 @@
+FaceTrackNoIR for PPJoy 'enabled' games/programs.
+
+FaceTrackNoIR was made compatible with the PPJoy virtual joystick(s), that can be used by various other programs as input. GlovePIE is one of the most powerfull we know (we have also tried tir4fun, but that is quite limited).
+
+To start the PPJoy protocol-server in FaceTrackNoIR, select Virtual Joystick in the 'game-protocol' listbox. The
+settings, necessary to configure PPJoy for FaceTrackNoIR as included in the PPJoy folder.
+
+GlovePIE was made by Carl Kenner and may NOT be used for military purposes. You can download it from the website
+http://glovepie.org/glovepie.php
+
+The script FaceTrackNoIR2TrackIR.PIE, which was included in this folder, surves as an example for GlovePIE. If anyone
+want to use, change or improve it: feel free to do so. In fact, if you do, we would like to receive a copy :-)
+
+Regards,
+
+
+The FaceTrackNoIR team:
+
+Wim Vriend
+Ron Hendriks
+
+
+
+Disclaimer: For usage of 3rd party software like GlovePIE, the FaceTrackNoIR team is not responsible. Use it at your own risk. \ No newline at end of file
diff --git a/contrib/ppjoy/ppjoy mapping for facetracknoir.jpg b/contrib/ppjoy/ppjoy mapping for facetracknoir.jpg
new file mode 100644
index 00000000..052c6899
--- /dev/null
+++ b/contrib/ppjoy/ppjoy mapping for facetracknoir.jpg
Binary files differ
diff --git a/contrib/ppjoy/readme.txt b/contrib/ppjoy/readme.txt
new file mode 100644
index 00000000..20c52111
--- /dev/null
+++ b/contrib/ppjoy/readme.txt
@@ -0,0 +1,24 @@
+FaceTrackNoIR for PPJoy 'enabled' games/programs.
+
+FaceTrackNoIR was made compatible with the PPJoy virtual joystick(s), that can be used by various other programs as input.
+
+To start the PPJoy protocol-server in FaceTrackNoIR, select Virtual Joystick in the 'game-protocol' listbox. The
+settings, necessary to configure PPJoy for FaceTrackNoIR as included in the PPJoy folder, in the file
+PPJoy mapping for FaceTrackNoIR.jpg.
+
+PPJoy was made by Deon van der Westhuysen and is unfortunately not updated anymore. You can download it from the website
+http://shareware.pcmag.com/free/Miscellaneous-Utilities/PPJoy/75176.html, but possibly from others as well...
+
+
+Regards,
+
+
+The FaceTrackNoIR team:
+
+Wim Vriend
+Ron Hendriks
+
+
+
+
+Disclaimer: For usage of 3rd party software like PPJoy, the FaceTrackNoIR team is not responsible. Use it at your own risk. \ No newline at end of file
diff --git a/contrib/very-important-source-code/README-CREDIT.txt b/contrib/very-important-source-code/README-CREDIT.txt
new file mode 100644
index 00000000..82214139
--- /dev/null
+++ b/contrib/very-important-source-code/README-CREDIT.txt
@@ -0,0 +1,6 @@
+The contents of the directory written by one and only, uglyDwarf.
+
+Obtained at epoch time 1412397452 from the mithril-mine's shaft, where
+the elite dwarves reside.
+
+For the latest happenings, visit <https://code.google.com/p/linux-track/>
diff --git a/contrib/very-important-source-code/ft_tester/Makefile.am b/contrib/very-important-source-code/ft_tester/Makefile.am
new file mode 100644
index 00000000..02747edb
--- /dev/null
+++ b/contrib/very-important-source-code/ft_tester/Makefile.am
@@ -0,0 +1,54 @@
+noinst_SCRIPTS =
+if WINE_PLUGIN
+ noinst_SCRIPTS += ftc.exe.so
+endif #WINE_PLUGIN
+
+if DARWIN
+ LDFLAGS += -Wl,-no_arch_warnings
+else
+ LDFLAGS += -Wl,--no-warn-search-mismatch
+endif
+
+CC = winegcc
+
+CXX = wineg++
+
+SUFFIXES = .o .cpp .c .rc
+
+.cpp.o :
+ $(CXX) -c $(CXXFLAGS_PRE) $(CXXFLAGS) $(CPPFLAGS) -m32 -o $@ $<
+
+.c.o :
+ $(CC) -c $(CFLAGS_PRE) $(CFLAGS) $(CPPFLAGS) -m32 -o $@ $<
+
+.rc.o :
+ wrc -o $@ $(RCFLAGS) $<
+
+CXXFLAGS_PRE = -g -DHAVE_CONFIG_H -I../../.. -I. -I@srcdir@/../.. -I@top_builddir@
+CFLAGS_PRE = -g -I../.. -I../../.. -DHAVE_CONFIG_H -I@srcdir@/../.. -I@top_builddir@
+RCFLAGS = -I @srcdir@
+#VPATH = ../..:@srcdir@/../..:@top_builddir@:@srcdir@
+vpath %.h @srcdir@/../..
+vpath %.h @top_builddir@
+vpath %.c @srcdir@
+vpath %.c @srcdir@/../..
+
+ftc.exe.so : main.o fttester.o
+ wineg++ -g -o $@ -L. $(WINE_LIBS) $(LDFLAGS) -m32 -Wall -Wextra $^
+
+fttester.o : fttester.rc resource.h config.h
+
+main.o : main.cpp
+
+clean-local: clean-local-check
+.PHONY: clean-local-check
+clean-local-check:
+ rm -f *.exe* *.dll* *.sh *.o
+
+distclean-local: distclean-local-check
+.PHONY: distclean-local-check
+distclean-local-check:
+ rm -f *.exe* *.dll* *.sh *.o
+
+EXTRA_DIST = resource.h fttester.rc main.cpp
+
diff --git a/contrib/very-important-source-code/ft_tester/Makefile.in b/contrib/very-important-source-code/ft_tester/Makefile.in
new file mode 100644
index 00000000..d1fff34d
--- /dev/null
+++ b/contrib/very-important-source-code/ft_tester/Makefile.in
@@ -0,0 +1,491 @@
+# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__make_running_with_option = \
+ case $${target_option-} in \
+ ?) ;; \
+ *) echo "am__make_running_with_option: internal error: invalid" \
+ "target option '$${target_option-}' specified" >&2; \
+ exit 1;; \
+ esac; \
+ has_opt=no; \
+ sane_makeflags=$$MAKEFLAGS; \
+ if $(am__is_gnu_make); then \
+ sane_makeflags=$$MFLAGS; \
+ else \
+ case $$MAKEFLAGS in \
+ *\\[\ \ ]*) \
+ bs=\\; \
+ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
+ esac; \
+ fi; \
+ skip_next=no; \
+ strip_trailopt () \
+ { \
+ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+ }; \
+ for flg in $$sane_makeflags; do \
+ test $$skip_next = yes && { skip_next=no; continue; }; \
+ case $$flg in \
+ *=*|--*) continue;; \
+ -*I) strip_trailopt 'I'; skip_next=yes;; \
+ -*I?*) strip_trailopt 'I';; \
+ -*O) strip_trailopt 'O'; skip_next=yes;; \
+ -*O?*) strip_trailopt 'O';; \
+ -*l) strip_trailopt 'l'; skip_next=yes;; \
+ -*l?*) strip_trailopt 'l';; \
+ -[dEDm]) skip_next=yes;; \
+ -[JT]) skip_next=yes;; \
+ esac; \
+ case $$flg in \
+ *$$target_option*) has_opt=yes; break;; \
+ esac; \
+ done; \
+ test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+@WINE_PLUGIN_TRUE@am__append_1 = ftc.exe.so
+@DARWIN_TRUE@am__append_2 = -Wl,-no_arch_warnings
+@DARWIN_FALSE@am__append_3 = -Wl,--no-warn-search-mismatch
+subdir = src/wine_bridge/ft_tester
+DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
+ $(srcdir)/fttester.rc.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
+ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
+ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
+ $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES = fttester.rc
+CONFIG_CLEAN_VPATH_FILES =
+SCRIPTS = $(noinst_SCRIPTS)
+AM_V_P = $(am__v_P_@AM_V@)
+am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo " GEN " $@;
+am__v_GEN_1 =
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 =
+depcomp =
+am__depfiles_maybe =
+SOURCES =
+DIST_SOURCES =
+am__can_run_installinfo = \
+ case $$AM_UPDATE_INFO_DIR in \
+ n|no|NO) false;; \
+ *) (install-info --version) >/dev/null 2>&1;; \
+ esac
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BISON = @BISON@
+CC = winegcc
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = wineg++
+CXXCPP = @CXXCPP@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@ $(am__append_2) $(am__append_3)
+LEX = @LEX@
+LEXLIB = @LEXLIB@
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
+LIB32DIR = @LIB32DIR@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MKDIR_P = @MKDIR_P@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJC = @OBJC@
+OBJCFLAGS = @OBJCFLAGS@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OPENCV_CFLAGS = @OPENCV_CFLAGS@
+OPENCV_LIBS = @OPENCV_LIBS@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
+PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
+QMAKE_PATH = @QMAKE_PATH@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+WINE64_LIBS = @WINE64_LIBS@
+WINE_LIBS = @WINE_LIBS@
+XPL_CPPFLAGS = @XPL_CPPFLAGS@
+YACC = @YACC@
+YFLAGS = @YFLAGS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+ac_ct_OBJC = @ac_ct_OBJC@
+am__leading_dot = @am__leading_dot@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+with_makensis = @with_makensis@
+with_wine64 = @with_wine64@
+noinst_SCRIPTS = $(am__append_1)
+SUFFIXES = .o .cpp .c .rc
+CXXFLAGS_PRE = -g -DHAVE_CONFIG_H -I../../.. -I. -I@srcdir@/../.. -I@top_builddir@
+CFLAGS_PRE = -g -I../.. -I../../.. -DHAVE_CONFIG_H -I@srcdir@/../.. -I@top_builddir@
+RCFLAGS = -I @srcdir@
+EXTRA_DIST = resource.h fttester.rc main.cpp
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .o .cpp .c .rc
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu --ignore-deps src/wine_bridge/ft_tester/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --gnu --ignore-deps src/wine_bridge/ft_tester/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+fttester.rc: $(top_builddir)/config.status $(srcdir)/fttester.rc.in
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+tags TAGS:
+
+ctags CTAGS:
+
+cscope cscopelist:
+
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(SCRIPTS)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ if test -z '$(STRIP)'; then \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ install; \
+ else \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+ fi
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-local mostlyclean-am
+
+distclean: distclean-am
+ -rm -f Makefile
+distclean-am: clean-am distclean-generic distclean-local
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: all all-am check check-am clean clean-generic clean-libtool \
+ clean-local cscopelist-am ctags-am distclean distclean-generic \
+ distclean-libtool distclean-local distdir dvi dvi-am html \
+ html-am info info-am install install-am install-data \
+ install-data-am install-dvi install-dvi-am install-exec \
+ install-exec-am install-html install-html-am install-info \
+ install-info-am install-man install-pdf install-pdf-am \
+ install-ps install-ps-am install-strip installcheck \
+ installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-generic \
+ mostlyclean-libtool pdf pdf-am ps ps-am tags-am uninstall \
+ uninstall-am
+
+
+.cpp.o :
+ $(CXX) -c $(CXXFLAGS_PRE) $(CXXFLAGS) $(CPPFLAGS) -m32 -o $@ $<
+
+.c.o :
+ $(CC) -c $(CFLAGS_PRE) $(CFLAGS) $(CPPFLAGS) -m32 -o $@ $<
+
+.rc.o :
+ wrc -o $@ $(RCFLAGS) $<
+#VPATH = ../..:@srcdir@/../..:@top_builddir@:@srcdir@
+vpath %.h @srcdir@/../..
+vpath %.h @top_builddir@
+vpath %.c @srcdir@
+vpath %.c @srcdir@/../..
+
+ftc.exe.so : main.o fttester.o
+ wineg++ -g -o $@ -L. $(WINE_LIBS) $(LDFLAGS) -m32 -Wall -Wextra $^
+
+fttester.o : fttester.rc resource.h config.h
+
+main.o : main.cpp
+
+clean-local: clean-local-check
+.PHONY: clean-local-check
+clean-local-check:
+ rm -f *.exe* *.dll* *.sh *.o
+
+distclean-local: distclean-local-check
+.PHONY: distclean-local-check
+distclean-local-check:
+ rm -f *.exe* *.dll* *.sh *.o
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/contrib/very-important-source-code/ft_tester/fttester.rc.in b/contrib/very-important-source-code/ft_tester/fttester.rc.in
new file mode 100644
index 00000000..332f3c73
--- /dev/null
+++ b/contrib/very-important-source-code/ft_tester/fttester.rc.in
@@ -0,0 +1,67 @@
+// Generated by ResEdit 1.5.9
+// Copyright (C) 2006-2011
+// http://www.resedit.net
+
+#include <windows.h>
+#include <commctrl.h>
+#include <richedit.h>
+#include "resource.h"
+
+#ifdef HAVE_CONFIG_H
+ #include "../../../config.h"
+#endif
+
+
+
+
+//
+// Dialog resources
+//
+//LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
+IDD_DIALOG1 DIALOGEX 0, 0, 333, 183
+STYLE DS_3DLOOK | DS_CENTER | DS_MODALFRAME | DS_SHELLFONT | WS_CAPTION | WS_VISIBLE | WS_POPUP | WS_SYSMENU
+CAPTION "FreeTrack client test utility v@PACKAGE_VERSION@"
+FONT 8, "Ms Shell Dlg", 400, 0, 1
+{
+ DEFPUSHBUTTON "Quit", IDQUIT, 262, 153, 50, 14
+ PUSHBUTTON "Start", IDC_START, 199, 153, 50, 14
+ EDITTEXT IDC_YAW, 38, 15, 48, 14, ES_AUTOHSCROLL
+ RTEXT "Yaw", IDC_STATIC, 12, 17, 21, 14, SS_RIGHT
+ EDITTEXT IDC_PITCH, 38, 38, 48, 14, ES_AUTOHSCROLL
+ RTEXT "Pitch", IDC_STATIC, 16, 40, 17, 14, SS_RIGHT
+ EDITTEXT IDC_ROLL, 38, 61, 48, 14, ES_AUTOHSCROLL
+ RTEXT "Roll", IDC_STATIC, 20, 63, 13, 14, SS_RIGHT
+ EDITTEXT IDC_X, 38, 84, 48, 14, ES_AUTOHSCROLL
+ RTEXT "X", IDC_STATIC, 27, 86, 6, 14, SS_RIGHT
+ EDITTEXT IDC_Y, 38, 107, 48, 14, ES_AUTOHSCROLL
+ RTEXT "Y", IDC_STATIC, 27, 109, 6, 14, SS_RIGHT
+ EDITTEXT IDC_Z, 38, 130, 48, 14, ES_AUTOHSCROLL
+ RTEXT "Z", IDC_STATIC, 27, 132, 6, 14, SS_RIGHT
+ EDITTEXT IDC_RYAW, 137, 15, 48, 14, ES_AUTOHSCROLL
+ RTEXT "Raw Yaw", IDC_STATIC, 101, 17, 32, 8, SS_RIGHT
+ EDITTEXT IDC_RPITCH, 137, 38, 48, 14, ES_AUTOHSCROLL
+ RTEXT "Raw Pitch", IDC_STATIC, 99, 40, 34, 8, SS_RIGHT
+ EDITTEXT IDC_RROLL, 137, 61, 48, 14, ES_AUTOHSCROLL
+ RTEXT "Raw Roll", IDC_STATIC, 103, 63, 30, 8, SS_RIGHT
+ EDITTEXT IDC_RX, 137, 84, 48, 14, ES_AUTOHSCROLL
+ RTEXT "Raw X", IDC_STATIC, 111, 86, 22, 8, SS_RIGHT
+ EDITTEXT IDC_RY, 137, 107, 48, 14, ES_AUTOHSCROLL
+ RTEXT "Raw Y", IDC_STATIC, 111, 109, 22, 8, SS_RIGHT
+ EDITTEXT IDC_RZ, 137, 130, 48, 14, ES_AUTOHSCROLL
+ RTEXT "Raw Z", IDC_STATIC, 111, 132, 22, 8, SS_RIGHT
+ EDITTEXT IDC_NUM, 264, 15, 48, 14, ES_AUTOHSCROLL
+ RTEXT "Frame Number", IDC_STATIC, 212, 17, 47, 8, SS_RIGHT
+ EDITTEXT IDC_RES, 264, 38, 48, 14, ES_AUTOHSCROLL
+ RTEXT "Camera Resolution", IDC_STATIC, 199, 40, 60, 8, SS_RIGHT
+ EDITTEXT IDC_PT0, 227, 61, 85, 14, ES_AUTOHSCROLL
+ RTEXT "Point 1", IDC_STATIC, 199, 63, 23, 8, SS_RIGHT
+ EDITTEXT IDC_PT1, 227, 84, 85, 14, ES_AUTOHSCROLL
+ RTEXT "Point 2", IDC_STATIC, 199, 86, 23, 8, SS_RIGHT
+ EDITTEXT IDC_PT2, 227, 107, 85, 14, ES_AUTOHSCROLL
+ RTEXT "Point 3", IDC_STATIC, 199, 109, 23, 8, SS_RIGHT
+ EDITTEXT IDC_PT3, 227, 130, 85, 14, ES_AUTOHSCROLL
+ RTEXT "Point 4", IDC_STATIC, 199, 132, 23, 8, SS_RIGHT
+ EDITTEXT IDC_TITLE, 38, 153, 147, 14, ES_AUTOHSCROLL
+ RTEXT "Title", IDC_STATIC, 19, 155, 14, 8, SS_RIGHT
+}
+
diff --git a/contrib/very-important-source-code/ft_tester/main.cpp b/contrib/very-important-source-code/ft_tester/main.cpp
new file mode 100644
index 00000000..a737f88f
--- /dev/null
+++ b/contrib/very-important-source-code/ft_tester/main.cpp
@@ -0,0 +1,211 @@
+#define WIN32_LEAN_AND_MEAN
+
+#include <windows.h>
+#include <cstdio>
+#include <stdint.h>
+#include <sstream>
+#include <cstdlib>
+#include <iomanip>
+
+#include "resource.h"
+
+HINSTANCE hInst;
+UINT_PTR timer = 0;
+
+HMODULE ftclient;
+
+typedef struct
+{
+ unsigned int dataID;
+ int res_x; int res_y;
+ float yaw; // positive yaw to the left
+ float pitch;// positive pitch up
+ float roll;// positive roll to the left
+ float x;
+ float y;
+ float z;
+ // raw pose with no smoothing, sensitivity, response curve etc.
+ float ryaw;
+ float rpitch;
+ float rroll;
+ float rx;
+ float ry;
+ float rz;
+ // raw points, sorted by Y, origin top left corner
+ float x0, y0;
+ float x1, y1;
+ float x2, y2;
+ float x3, y3;
+}FreeTrackData;
+
+
+typedef bool (WINAPI *importGetData)(FreeTrackData * data);
+typedef char *(WINAPI *importGetDllVersion)(void);
+typedef void (WINAPI *importReportName)(char *name);
+typedef char *(WINAPI *importProvider)(void);
+
+importGetData getData;
+importGetDllVersion getDllVersion;
+importReportName reportName;
+importProvider provider;
+
+
+char *client_path()
+{
+ HKEY hkey = 0;
+ RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\Freetrack\\FreetrackClient", 0,
+ KEY_QUERY_VALUE, &hkey);
+ if(!hkey){
+ printf("Can't open registry key\n");
+ return NULL;
+ }
+
+ BYTE path[1024];
+ DWORD buf_len = 1024;
+ LONG result = RegQueryValueEx(hkey, "Path", NULL, NULL, path, &buf_len);
+ char *full_path = (char *)malloc(2048);
+ if(result == ERROR_SUCCESS && buf_len > 0){
+ sprintf(full_path, "%s\\FreeTrackClient.dll", path);
+ }
+ RegCloseKey(hkey);
+ return full_path;
+}
+
+
+bool start(HWND hwnd)
+{
+ char *libname = client_path();
+ if(libname == NULL){
+ printf("Freetrack client not found!\n");
+ return false;
+ }
+ ftclient = LoadLibrary(libname);
+ if(ftclient == NULL){
+ printf("Couldn't load Freetrack client library '%s'!\n", libname);
+ return false;
+ }
+ printf("Freetrack client library %s loaded.\n", client_path());
+
+
+ getData = (importGetData)GetProcAddress(ftclient, "FTGetData");
+ getDllVersion = (importGetDllVersion)GetProcAddress(ftclient, "FTGetDllVersion");
+ reportName = (importReportName)GetProcAddress(ftclient, "FTReportName");
+ provider = (importProvider)GetProcAddress(ftclient, "FTProvider");
+
+ if((getData == NULL) || (getDllVersion == NULL) || (reportName == NULL) || (provider == NULL)){
+ printf("Couldn't load Freetrack client functions!\n");
+ FreeLibrary(ftclient);
+ return false;
+ }
+
+ printf("Dll version: %s\n", getDllVersion());
+ printf("Provider: %s\n", provider());
+ char title[1024];
+ GetDlgItemText(hwnd, IDC_TITLE, title, 1020);
+ reportName(title);
+ return true;
+}
+
+void reportError(std::string msg)
+{
+ MessageBoxA(0, "FreeTrack client test", msg.c_str(), 0);
+}
+VOID CALLBACK TimerProcedure(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
+{
+ (void) uMsg;
+ (void) idEvent;
+ (void) dwTime;
+ FreeTrackData d;
+ getData(&d);
+ SetDlgItemInt(hwnd, IDC_PITCH, d.pitch, true);
+ SetDlgItemInt(hwnd, IDC_ROLL, d.roll, true);
+ SetDlgItemInt(hwnd, IDC_YAW, d.yaw, true);
+
+ SetDlgItemInt(hwnd, IDC_X, d.x, true);
+ SetDlgItemInt(hwnd, IDC_Y, d.y, true);
+ SetDlgItemInt(hwnd, IDC_Z, d.z, true);
+
+ SetDlgItemInt(hwnd, IDC_RPITCH, d.rpitch, true);
+ SetDlgItemInt(hwnd, IDC_RROLL, d.rroll, true);
+ SetDlgItemInt(hwnd, IDC_RYAW, d.ryaw, true);
+
+ SetDlgItemInt(hwnd, IDC_RX, d.rx, true);
+ SetDlgItemInt(hwnd, IDC_RY, d.ry, true);
+ SetDlgItemInt(hwnd, IDC_RZ, d.rz, true);
+
+ std::ostringstream s;
+ s.str(std::string());
+ s<<"("<<std::fixed<<std::setprecision(1)<<d.x0<<"; "<<d.y0<<")";
+ SetDlgItemText(hwnd, IDC_PT0, s.str().c_str());
+
+ s.str(std::string());
+ s<<"("<<std::fixed<<std::setprecision(1)<<d.x1<<"; "<<d.y1<<")";
+ SetDlgItemText(hwnd, IDC_PT1, s.str().c_str());
+
+ s.str(std::string());
+ s<<"("<<std::fixed<<std::setprecision(1)<<d.x2<<"; "<<d.y2<<")";
+ SetDlgItemText(hwnd, IDC_PT2, s.str().c_str());
+
+ s.str(std::string());
+ s<<"("<<std::fixed<<std::setprecision(1)<<d.x3<<"; "<<d.y3<<")";
+ SetDlgItemText(hwnd, IDC_PT3, s.str().c_str());
+
+ s.str(std::string());
+ s<<d.res_x<<"x"<<d.res_y;
+ SetDlgItemText(hwnd, IDC_RES, s.str().c_str());
+ SetDlgItemInt(hwnd, IDC_NUM, d.dataID, true);
+}
+
+BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ (void) lParam;
+ switch(uMsg)
+ {
+ case WM_INITDIALOG:
+ SetDlgItemText(hwndDlg, IDC_TITLE, "Default");
+ return TRUE;
+
+ case WM_CLOSE:
+ EndDialog(hwndDlg, 0);
+ return TRUE;
+
+ case WM_COMMAND:
+ switch(LOWORD(wParam))
+ {
+ /*
+ * TODO: Add more control ID's, when needed.
+ */
+ case IDQUIT:
+ FreeLibrary(ftclient);
+ EndDialog(hwndDlg, 0);
+ return TRUE;
+ case IDC_START:
+ start(hwndDlg);
+//l int ok;
+// int num = GetDlgItemInt(hwndDlg, IDC_APPID, (BOOL*)&ok, false);
+ if(timer != 0){
+ KillTimer(hwndDlg, timer);
+ timer = 0;
+ }
+ timer = SetTimer(hwndDlg, 0, 50, TimerProcedure);
+ break;
+
+ }
+ }
+
+ return FALSE;
+}
+
+
+int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
+{
+ (void) hPrevInstance;
+ (void) lpCmdLine;
+ (void) nShowCmd;
+ hInst = hInstance;
+
+ // The user interface is a modal dialog box
+ return DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), NULL, (DLGPROC)DialogProc);
+}
+
+
diff --git a/contrib/very-important-source-code/ft_tester/resource.h b/contrib/very-important-source-code/ft_tester/resource.h
new file mode 100644
index 00000000..8bba17b4
--- /dev/null
+++ b/contrib/very-important-source-code/ft_tester/resource.h
@@ -0,0 +1,27 @@
+#ifndef IDC_STATIC
+#define IDC_STATIC (-1)
+#endif
+
+#define IDD_DIALOG1 100
+#define IDQUIT 1002
+#define IDC_YAW 1005
+#define IDC_PITCH 1023
+#define IDC_ROLL 1024
+#define IDC_X 1025
+#define IDC_Y 1026
+#define IDC_Z 1027
+#define IDC_RYAW 1028
+#define IDC_RPITCH 1029
+#define IDC_RROLL 1030
+#define IDC_RX 1031
+#define IDC_RY 1032
+#define IDC_RZ 1033
+#define IDC_NUM 1034
+#define IDC_RES 1035
+#define IDC_PT0 1036
+#define IDC_PT1 1037
+#define IDC_PT2 1038
+#define IDC_PT3 1039
+#define IDC_START 1040
+#define IDC_TITLE 1041
+
diff --git a/contrib/very-important-source-code/important-stuff/NPClient.h b/contrib/very-important-source-code/important-stuff/NPClient.h
new file mode 100644
index 00000000..770e1c71
--- /dev/null
+++ b/contrib/very-important-source-code/important-stuff/NPClient.h
@@ -0,0 +1,17 @@
+
+extern int NP_RegisterWindowHandle (HWND hwnd);
+extern int NP_UnregisterWindowHandle (void);
+extern int NP_RegisterProgramProfileID (unsigned short id);
+extern int NP_QueryVersion (unsigned short *version);
+extern int NP_RequestData (unsigned short req);
+extern int NP_GetSignature (tir_signature_t *sig);
+extern int NP_GetData (tir_data_t *data);
+extern int NP_GetParameter (void);
+extern int NP_SetParameter (void);
+extern int NP_StartCursor (void);
+extern int NP_StopCursor (void);
+extern int NP_ReCenter (void);
+extern int NP_StartDataTransmission (void);
+extern int NP_StopDataTransmission (void);
+
+
diff --git a/contrib/very-important-source-code/important-stuff/NPClient.spec b/contrib/very-important-source-code/important-stuff/NPClient.spec
new file mode 100644
index 00000000..7fe5f1b4
--- /dev/null
+++ b/contrib/very-important-source-code/important-stuff/NPClient.spec
@@ -0,0 +1,23 @@
+# Generated from NPClient.dll by winedump
+
+1 stub NPPriv_ClientNotify
+2 stub NPPriv_GetLastError
+3 stub NPPriv_SetData
+4 stub NPPriv_SetLastError
+5 stub NPPriv_SetParameter
+6 stub NPPriv_SetSignature
+7 stub NPPriv_SetVersion
+8 stdcall NP_GetData( ptr ) NPCLIENT_NP_GetData
+9 stdcall NP_GetParameter( long long) NPCLIENT_NP_GetParameter
+10 stdcall NP_GetSignature( ptr ) NPCLIENT_NP_GetSignature
+11 stdcall NP_QueryVersion( ptr ) NPCLIENT_NP_QueryVersion
+12 stdcall NP_ReCenter() NPCLIENT_NP_ReCenter
+13 stdcall NP_RegisterProgramProfileID( long ) NPCLIENT_NP_RegisterProgramProfileID
+14 stdcall NP_RegisterWindowHandle( ptr ) NPCLIENT_NP_RegisterWindowHandle
+15 stdcall NP_RequestData( long ) NPCLIENT_NP_RequestData
+16 stdcall NP_SetParameter( long long ) NPCLIENT_NP_SetParameter
+17 stdcall NP_StartCursor() NPCLIENT_NP_StartCursor
+18 stdcall NP_StartDataTransmission() NPCLIENT_NP_StartDataTransmission
+19 stdcall NP_StopCursor() NPCLIENT_NP_StopCursor
+20 stdcall NP_StopDataTransmission() NPCLIENT_NP_StopDataTransmission
+21 stdcall NP_UnregisterWindowHandle() NPCLIENT_NP_UnregisterWindowHandle
diff --git a/contrib/very-important-source-code/important-stuff/NPClient_dll.h b/contrib/very-important-source-code/important-stuff/NPClient_dll.h
new file mode 100644
index 00000000..b0bab5db
--- /dev/null
+++ b/contrib/very-important-source-code/important-stuff/NPClient_dll.h
@@ -0,0 +1,58 @@
+/*
+ * NPClient.dll
+ *
+ * Generated from NPClient.dll by winedump.
+ *
+ * DO NOT SEND GENERATED DLLS FOR INCLUSION INTO WINE !
+ *
+ */
+#ifndef __WINE_NPCLIENT_DLL_H
+#define __WINE_NPCLIENT_DLL_H
+
+#include "windef.h"
+#include "wine/debug.h"
+#include "winbase.h"
+#include "winnt.h"
+
+#pragma pack(1)
+typedef struct tir_data{
+ short status;
+ short frame;
+ unsigned int cksum;
+ float roll, pitch, yaw;
+ float tx, ty, tz;
+ float padding[9];
+} tir_data_t;
+
+typedef struct tir_signature{
+ char DllSignature[200];
+ char AppSignature[200];
+} tir_signature_t;
+#pragma pack(0)
+
+
+/* __stdcall NPCLIENT_NPPriv_ClientNotify(); */
+/* __stdcall NPCLIENT_NPPriv_GetLastError(); */
+/* __stdcall NPCLIENT_NPPriv_SetData(); */
+/* __stdcall NPCLIENT_NPPriv_SetLastError(); */
+/* __stdcall NPCLIENT_NPPriv_SetParameter(); */
+/* __stdcall NPCLIENT_NPPriv_SetSignature(); */
+/* __stdcall NPCLIENT_NPPriv_SetVersion(); */
+int __stdcall NPCLIENT_NP_GetData(tir_data_t * data);
+int __stdcall NPCLIENT_NP_GetParameter(int arg0, int arg1);
+int __stdcall NPCLIENT_NP_GetSignature(tir_signature_t * sig);
+int __stdcall NPCLIENT_NP_QueryVersion(unsigned short * version);
+int __stdcall NPCLIENT_NP_ReCenter(void);
+int __stdcall NPCLIENT_NP_RegisterProgramProfileID(unsigned short id);
+int __stdcall NPCLIENT_NP_RegisterWindowHandle(HWND hwnd);
+int __stdcall NPCLIENT_NP_RequestData(unsigned short req);
+int __stdcall NPCLIENT_NP_SetParameter(int arg0, int arg1);
+int __stdcall NPCLIENT_NP_StartCursor(void);
+int __stdcall NPCLIENT_NP_StartDataTransmission(void);
+int __stdcall NPCLIENT_NP_StopCursor(void);
+int __stdcall NPCLIENT_NP_StopDataTransmission(void);
+int __stdcall NPCLIENT_NP_UnregisterWindowHandle(void);
+
+
+
+#endif /* __WINE_NPCLIENT_DLL_H */
diff --git a/contrib/very-important-source-code/important-stuff/NPClient_main.c b/contrib/very-important-source-code/important-stuff/NPClient_main.c
new file mode 100644
index 00000000..f892f89e
--- /dev/null
+++ b/contrib/very-important-source-code/important-stuff/NPClient_main.c
@@ -0,0 +1,444 @@
+/*
+ * NPClient.dll
+ *
+ * Generated from NPClient.dll by winedump.
+ *
+ * DO NOT SUBMIT GENERATED DLLS FOR INCLUSION INTO WINE!
+ *
+ */
+
+#include <linuxtrack.h>
+#include "rest.h"
+//#include "config.h"
+#define __WINESRC__
+
+#include <stdarg.h>
+#include <string.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "windef.h"
+#include "winbase.h"
+#include "NPClient_dll.h"
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(NPClient);
+
+bool crypted = false;
+static unsigned char table[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+static int dbg_flag;
+
+static void dbg_report(const char *msg,...)
+{
+ static FILE *f = NULL;
+ if(dbg_flag){
+ if(f == NULL){
+ f = fopen("NPClient.log", "w");
+ }
+ va_list ap;
+ va_start(ap,msg);
+ vfprintf(f, msg, ap);
+ fflush(f);
+ va_end(ap);
+ }
+}
+
+
+BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
+{
+ TRACE("(0x%p, %d, %p)\n", hinstDLL, fdwReason, lpvReserved);
+
+ switch (fdwReason)
+ {
+ case DLL_WINE_PREATTACH:
+ return TRUE;
+ case DLL_PROCESS_ATTACH:
+ DisableThreadLibraryCalls(hinstDLL);
+ dbg_flag = getDebugFlag('w');
+ dbg_report("Attach request\n");
+ break;
+ case DLL_PROCESS_DETACH:
+ linuxtrack_shutdown();
+ break;
+ }
+
+ return TRUE;
+}
+/******************************************************************
+ * NPPriv_ClientNotify (NPCLIENT.1)
+ *
+ *
+ */
+#if 0
+__stdcall NPCLIENT_NPPriv_ClientNotify()
+{
+ /* @stub in .spec */
+}
+#endif
+/******************************************************************
+ * NPPriv_GetLastError (NPCLIENT.2)
+ *
+ *
+ */
+#if 0
+__stdcall NPCLIENT_NPPriv_GetLastError()
+{
+ /* @stub in .spec */
+}
+#endif
+/******************************************************************
+ * NPPriv_SetData (NPCLIENT.3)
+ *
+ *
+ */
+#if 0
+__stdcall NPCLIENT_NPPriv_SetData()
+{
+ /* @stub in .spec */
+}
+#endif
+/******************************************************************
+ * NPPriv_SetLastError (NPCLIENT.4)
+ *
+ *
+ */
+#if 0
+__stdcall NPCLIENT_NPPriv_SetLastError()
+{
+ /* @stub in .spec */
+}
+#endif
+/******************************************************************
+ * NPPriv_SetParameter (NPCLIENT.5)
+ *
+ *
+ */
+#if 0
+__stdcall NPCLIENT_NPPriv_SetParameter()
+{
+ /* @stub in .spec */
+}
+#endif
+/******************************************************************
+ * NPPriv_SetSignature (NPCLIENT.6)
+ *
+ *
+ */
+#if 0
+__stdcall NPCLIENT_NPPriv_SetSignature()
+{
+ /* @stub in .spec */
+}
+#endif
+/******************************************************************
+ * NPPriv_SetVersion (NPCLIENT.7)
+ *
+ *
+ */
+#if 0
+__stdcall NPCLIENT_NPPriv_SetVersion()
+{
+ /* @stub in .spec */
+}
+#endif
+
+static float limit_num(float min, float val, float max)
+{
+ if(val < min) return min;
+ if(val > max) return max;
+ return val;
+}
+
+static unsigned int cksum(unsigned char buf[], unsigned int size)
+{
+ if((size == 0) || (buf == NULL)){
+ return 0;
+ }
+
+ int rounds = size >> 2;
+ int rem = size % 4;
+
+ int c = size;
+ int a0, a2;
+// printf("Orig: ");
+//for(a0 = 0; a0 < (int)size; ++a0)
+//{
+// printf("%02X", buf[a0]);
+//}
+//printf("\n");
+ while(rounds != 0){
+ a0 = *(short int*)buf;
+ a2 = *(short int*)(buf+2);
+ buf += 4;
+ c += a0;
+ a2 ^= (c << 5);
+ a2 <<= 11;
+ c ^= a2;
+ c += (c >> 11);
+ --rounds;
+ }
+ switch(rem){
+ case 3:
+ a0 = *(short int*)buf;
+ a2 = *(signed char*)(buf+2);
+ c += a0;
+ a2 = (a2 << 2) ^ c;
+ c ^= (a2 << 16);
+ a2 = (c >> 11);
+ break;
+ case 2:
+ a2 = *(short int*)buf;
+ c += a2;
+ c ^= (c << 11);
+ a2 = (c >> 17);
+ break;
+ case 1:
+ a2 = *(signed char*)(buf);
+ c += a2;
+ c ^= (c << 10);
+ a2 = (c >> 1);
+ break;
+ default:
+ break;
+ }
+ if(rem != 0){
+ c+=a2;
+ }
+
+ c ^= (c << 3);
+ c += (c >> 5);
+ c ^= (c << 4);
+ c += (c >> 17);
+ c ^= (c << 25);
+ c += (c >> 6);
+
+ return (unsigned int)c;
+}
+
+static void enhance(unsigned char buf[], unsigned int size,
+ unsigned char codetable[], unsigned int table_size)
+{
+ unsigned int table_ptr = 0;
+ unsigned char var = 0x88;
+ unsigned char tmp;
+ if((size <= 0) || (table_size <= 0) ||
+ (buf == NULL) || (codetable == NULL)){
+ return;
+ }
+ do{
+ tmp = buf[--size];
+ buf[size] = tmp ^ codetable[table_ptr] ^ var;
+ var += size + tmp;
+ ++table_ptr;
+ if(table_ptr >= table_size){
+ table_ptr -= table_size;
+ }
+ }while(size != 0);
+}
+
+
+/******************************************************************
+ * NP_GetData (NPCLIENT.8)
+ *
+ *
+ */
+int __stdcall NPCLIENT_NP_GetData(tir_data_t * data)
+{
+ float r, p, y, tx, ty, tz;
+ unsigned int frame;
+ int res = linuxtrack_get_pose(&y, &p, &r, &tx, &ty, &tz, &frame);
+ memset((char *)data, 0, sizeof(tir_data_t));
+ data->status = (linuxtrack_get_tracking_state() == RUNNING) ? 0 : 1;
+ data->frame = frame & 0xFFFF;
+ data->cksum = 0;
+ data->roll = r / 180.0 * 16383;
+ data->pitch = -p / 180.0 * 16383;
+ data->yaw = y / 180.0 * 16383;
+ data->tx = -limit_num(-16383.0, 15 * tx, 16383);
+ data->ty = limit_num(-16383.0, 15 * ty, 16383);
+ data->tz = limit_num(-16383.0, 15 * tz, 16383);
+ data->cksum = cksum((unsigned char*)data, sizeof(tir_data_t));
+ //printf("Cksum: %04X\n", data->cksum);
+ if(crypted){
+ enhance((unsigned char*)data, sizeof(tir_data_t), table, sizeof(table));
+ }
+ return (res >= 0) ? 0: 1;
+}
+/******************************************************************
+ * NP_GetParameter (NPCLIENT.9)
+ *
+ *
+ */
+int __stdcall NPCLIENT_NP_GetParameter(int arg0, int arg1)
+{
+ dbg_report("GetParameter request: %d %d\n", arg0, arg1);
+ TRACE("(void): stub\n");
+ return (int) 0;
+}
+
+/******************************************************************
+ * NP_GetSignature (NPCLIENT.10)
+ *
+ *
+ */
+int __stdcall NPCLIENT_NP_GetSignature(tir_signature_t * sig)
+{
+ dbg_report("GetSignature request\n");
+ if(getSomeSeriousPoetry(sig->DllSignature, sig->AppSignature)){
+ printf("Signature result: OK\n");
+ return 0;
+ }else{
+ printf("Signature result: NOT OK!\n");
+ return 1;
+ }
+}
+/******************************************************************
+ * NP_QueryVersion (NPCLIENT.11)
+ *
+ *
+ */
+int __stdcall NPCLIENT_NP_QueryVersion(unsigned short * version)
+{
+ dbg_report("QueryVersion request\n");
+ *version=0x0500;
+ return 0;
+}
+/******************************************************************
+ * NP_ReCenter (NPCLIENT.12)
+ *
+ *
+ */
+int __stdcall NPCLIENT_NP_ReCenter(void)
+{
+ dbg_report("ReCenter request\n");
+ linuxtrack_recenter();
+ return 0;
+}
+
+/******************************************************************
+ * NP_RegisterProgramProfileID (NPCLIENT.13)
+ *
+ *
+ */
+int __stdcall NPCLIENT_NP_RegisterProgramProfileID(unsigned short id)
+{
+ dbg_report("RegisterProgramProfileID request: %d\n", id);
+ game_desc_t gd;
+ if(game_data_get_desc(id, &gd)){
+ printf("Application ID: %d - %s!!!\n", id, gd.name);
+ if(game_data_get_desc(id, &gd)){
+ crypted = gd.encrypted;
+ if(gd.encrypted){
+ printf("Table: %02X %02X %02X %02X %02X %02X %02X %02X\n", table[0],table[1],table[2],table[3],table[4],
+ table[5], table[6], table[7]);
+ table[0] = (unsigned char)(gd.key1&0xff); gd.key1 >>= 8;
+ table[1] = (unsigned char)(gd.key1&0xff); gd.key1 >>= 8;
+ table[2] = (unsigned char)(gd.key1&0xff); gd.key1 >>= 8;
+ table[3] = (unsigned char)(gd.key1&0xff); gd.key1 >>= 8;
+ table[4] = (unsigned char)(gd.key2&0xff); gd.key2 >>= 8;
+ table[5] = (unsigned char)(gd.key2&0xff); gd.key2 >>= 8;
+ table[6] = (unsigned char)(gd.key2&0xff); gd.key2 >>= 8;
+ table[7] = (unsigned char)(gd.key2&0xff); gd.key2 >>= 8;
+ }
+ }
+ if(linuxtrack_init(gd.name) != 0){
+ return 1;
+ }
+ }else{
+ if(!linuxtrack_init("Default")){
+ return 1;
+ }
+ }
+ linuxtrack_suspend();
+ return 0;
+}
+/******************************************************************
+ * NP_RegisterWindowHandle (NPCLIENT.14)
+ *
+ *
+ */
+int __stdcall NPCLIENT_NP_RegisterWindowHandle(HWND hwnd)
+{
+ dbg_report("RegisterWindowHandle request: 0x%X\n", hwnd);
+ TRACE("((HWND)%p): stub\n",hwnd);
+ return (int) 0;
+}
+/******************************************************************
+ * NP_RequestData (NPCLIENT.15)
+ *
+ *
+ */
+int __stdcall NPCLIENT_NP_RequestData(unsigned short req)
+{
+ dbg_report("RequestData request: %d\n", req);
+ TRACE("((unsigned short)%d): stub\n",req);
+ return (int) 0;
+}
+/******************************************************************
+ * NP_SetParameter (NPCLIENT.16)
+ *
+ *
+ */
+int __stdcall NPCLIENT_NP_SetParameter(int arg0, int arg1)
+{
+ dbg_report("SetParameter request: %d %d\n", arg0, arg1);
+ TRACE("(void): stub\n");
+ return (int) 0;
+}
+/******************************************************************
+ * NP_StartCursor (NPCLIENT.17)
+ *
+ *
+ */
+int __stdcall NPCLIENT_NP_StartCursor(void)
+{
+ dbg_report("StartCursor request\n");
+ TRACE("(void): stub\n");
+ return (int) 0;
+}
+/******************************************************************
+ * NP_StartDataTransmission (NPCLIENT.18)
+ *
+ *
+ */
+int __stdcall NPCLIENT_NP_StartDataTransmission(void)
+{
+ dbg_report("StartDataTransmission request\n");
+ linuxtrack_wakeup();
+ return 0;
+}
+/******************************************************************
+ * NP_StopCursor (NPCLIENT.19)
+ *
+ *
+ */
+int __stdcall NPCLIENT_NP_StopCursor(void)
+{
+ dbg_report("StopCursor request\n");
+ TRACE("(void): stub\n");
+ return (int) 0;
+}
+/******************************************************************
+ * NP_StopDataTransmission (NPCLIENT.20)
+ *
+ *
+ */
+int __stdcall NPCLIENT_NP_StopDataTransmission(void)
+{
+ dbg_report("StopDataTransmission request\n");
+ linuxtrack_suspend();
+ return 0;
+}
+/******************************************************************
+ * NP_UnregisterWindowHandle (NPCLIENT.21)
+ *
+ *
+ */
+int __stdcall NPCLIENT_NP_UnregisterWindowHandle(void)
+{
+ dbg_report("UnregisterWindowHandle request\n");
+ TRACE("(void): stub\n");
+ return (int) 0;
+}
+
diff --git a/contrib/very-important-source-code/important-stuff/game_data.c b/contrib/very-important-source-code/important-stuff/game_data.c
new file mode 100644
index 00000000..48774187
--- /dev/null
+++ b/contrib/very-important-source-code/important-stuff/game_data.c
@@ -0,0 +1,166 @@
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <stdlib.h>
+#include <mxml.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <sys/stat.h>
+#include <string.h>
+
+//First 5 bytes is MD5 hash of "NaturalPoint"
+static uint8_t secret_key[] = {0x0e, 0x9a, 0x63, 0x71, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+static uint8_t S[256] = {0};
+
+static char *decoded = NULL;
+
+static mxml_node_t *xml = NULL;
+static mxml_node_t *tree = NULL;
+
+static void ksa(uint8_t key[], size_t len)
+{
+ unsigned int i, j;
+ for(i = 0; i < 256; ++i){
+ S[i] = i;
+ }
+ j = 0;
+ for(i = 0; i < 256; ++i){
+ j = (j + S[i] + key[i % len]) % 256;
+ uint8_t tmp = S[i];
+ S[i] = S[j];
+ S[j] = tmp;
+ }
+}
+
+static uint8_t rc4()
+{
+ static uint8_t i = 0;
+ static uint8_t j = 0;
+
+ i += 1;
+ j += S[i];
+ uint8_t tmp = S[i];
+ S[i] = S[j];
+ S[j] = tmp;
+ return S[(S[i] + S[j]) % 256];
+}
+
+static bool decrypt_file(const char *fname, bool from_update)
+{
+ uint32_t header[5];
+ size_t datlen;
+ ksa(secret_key, 16);
+ FILE *inp;
+ struct stat fst;
+
+ if((inp = fopen(fname, "rb")) == NULL){
+ printf("Can't open input file '%s'", fname);
+ return false;
+ }
+
+ if(fstat(fileno(inp), &fst) != 0){
+ fclose(inp);
+ printf("Cannot stat file '%s'\n", fname);
+ return false;
+ }
+
+ if(from_update){
+ if(fread(&header, sizeof(uint32_t), 5, inp) != 5){
+ fclose(inp);
+ printf("Can't read the header - file '%s' is less than 20 bytes long?\n", fname);
+ return false;
+ }
+ datlen = header[4];
+ }else{
+ datlen = fst.st_size;
+ }
+ if((decoded = (char *)malloc(datlen+1)) == NULL){
+ printf("malloc failed!\n");
+ return false;
+ }
+ memset(decoded, 0, datlen+1);
+ size_t i;
+ size_t len = fread(decoded, 1, datlen, inp);
+ (void) len;
+ for(i = 0; i < datlen; ++i) decoded[i] ^= rc4();
+ fclose(inp);
+
+ //inp = fopen("tmp.dump", "w");
+ //fwrite(decoded, 1, datlen, inp);
+ //fclose(inp);
+
+ return true;
+}
+
+static bool game_data_init(const char *fname, bool from_update)
+{
+ static bool initialized = false;
+ if(initialized){
+ return true;
+ }
+ if(!decrypt_file(fname, from_update)){
+ printf("Error decrypting file!\n");
+ return false;
+ }
+ xml = mxmlNewXML("1.0");
+ tree = mxmlLoadString(xml, decoded, MXML_TEXT_CALLBACK);
+ return (tree != NULL);
+}
+
+static void game_data_close()
+{
+ mxmlDelete(tree);
+ free(decoded);
+}
+
+#define ltr_int_log_message(...) fprintf(stderr, __VA_ARGS__)
+
+static void remove_newlines(const char* str, char* out, int out_len)
+{
+ int i, j;
+ int len = strlen(str);
+ for (i = 0, j = 0; str[i] && j + 1 < out_len; i++)
+ {
+ if (str[i] == '\r' || str[i] == '\n')
+ continue;
+ out[j++] = str[i];
+ }
+ if (j < out_len)
+ out[j] = '\0';
+}
+
+bool get_game_data(const char *input_fname, const char *output_fname, bool from_update)
+{
+ FILE *outfile = NULL;
+ if((outfile = (output_fname ? fopen(output_fname, "w") : stdout)) == NULL){
+ ltr_int_log_message("Can't open the output file '%s'!\n", output_fname);
+ return false;
+ }
+ if(!game_data_init(input_fname, from_update)){
+ ltr_int_log_message("Can't process the data file '%s'!\n", input_fname);
+ return false;
+ }
+
+ mxml_node_t *game;
+ const char *name;
+ const char *id;
+ for(game = mxmlFindElement(tree, tree, "Game", NULL, NULL, MXML_DESCEND);
+ game != NULL;
+ game = mxmlFindElement(game, tree, "Game", NULL, NULL, MXML_DESCEND))
+ {
+ name = mxmlElementGetAttr(game, "Name");
+ id = mxmlElementGetAttr(game, "Id");
+
+ mxml_node_t *appid = mxmlFindElement(game, game, "ApplicationID", NULL, NULL, MXML_DESCEND);
+ char name_[256];
+ remove_newlines(name, name_, sizeof(name_));
+ if(appid == NULL)
+ fprintf(outfile, "%s \"%s\"\n", id, name_);
+ else
+ fprintf(outfile, "%s \"%s\" (%s)\n", id, name_, appid->child->value.text.string);
+ }
+ fclose(outfile);
+ game_data_close();
+ return true;
+}
+
+int main(int argc, char** argv) { return argc > 1 && get_game_data(argv[1], NULL, false); }
diff --git a/contrib/very-important-source-code/important-stuff/game_data.h b/contrib/very-important-source-code/important-stuff/game_data.h
new file mode 100644
index 00000000..b71f7a15
--- /dev/null
+++ b/contrib/very-important-source-code/important-stuff/game_data.h
@@ -0,0 +1,17 @@
+#ifndef GAME_DATA__H
+#define GAME_DATA__H
+
+#include <stdbool.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+bool get_game_data(const char *input_fname, const char *output_fname, bool from_update);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif
diff --git a/contrib/very-important-source-code/make-csv.pl b/contrib/very-important-source-code/make-csv.pl
new file mode 100644
index 00000000..ee60364e
--- /dev/null
+++ b/contrib/very-important-source-code/make-csv.pl
@@ -0,0 +1,72 @@
+#!/usr/bin/env perl
+
+use strict;
+use List::Util qw'reduce';
+
+sub get_games_1 {
+ my @games;
+
+ open my $fd, "<", $ARGV[1] or die "open: $!";
+ <$fd>;
+
+ while (defined(my $line = <$fd>)) {
+ chomp $line;
+ if ($line !~ /^(\d+)\s+"([^"]+)"(?:\s+\(([0-9A-F]{16})\))?$/) {
+ warn "Broken line";
+ next;
+ }
+ push @games, +{ id => $1, name => $2, key => defined $3 ? (sprintf "%04X", $1) . $3 . '00' : undef};
+ }
+
+ [@games];
+}
+
+sub get_games_2 {
+ open my $fd, "<", $ARGV[0] or die "open: $!";
+ <$fd>;
+ my @games;
+ while (defined(my $line = <$fd>)) {
+ chomp $line;
+ my @line = split/;/, $line;
+ if (@line != 8) {
+ warn "Broken line";
+ next;
+ }
+ my @cols = qw'no name proto since verified by id key';
+ push @games, +{ map { $cols[$_] => $line[$_] } 0..$#cols };
+ }
+ [@games];
+}
+
+sub merge {
+ my ($new_games, $old_games) = @_;
+ my $no = (reduce { $a->{no} > $b->{no} ? $a : $b } +{id=>0}, @$old_games)->{no} + 1;
+ my %game_hash = map { $_->{name} => $_ } @$old_games;
+ my %ids = map { $_->{id} => 1 } @$old_games;
+ for my $g (@$new_games) {
+ if (!exists $game_hash{$g->{name}} && !exists $ids{$g->{id}}) {
+ $game_hash{$g->{name}} = +{
+ no => $no++,
+ name => $g->{name},
+ proto => 'FreeTrack20',
+ since => (defined $g->{key} ? 'V170' : 'V160'),
+ verified => '',
+ by => '',
+ id => $g->{id},
+ key => $g->{key}
+ };
+ }
+ }
+ print "No;Game Name;Game protocol;Supported since;Verified;By;INTERNATIONAL_ID;FTN_ID\n";
+ for (sort { lc($a->{name}) cmp lc($b->{name}) } values %game_hash) {
+ my $g = {%$_};
+ if (!defined $g->{key}) {
+ $g->{key} = (sprintf "%04X", $g->{no}) . (join"", map { sprintf "%02X", int rand 256 } 0 .. 7) . '00';
+ }
+ my @cols = qw'no name proto since verified by id key';
+ print join";", map { $g->{$_} } @cols;
+ print "\n";
+ }
+}
+
+merge(get_games_1(), get_games_2());
diff --git a/contrib/very-important-source-code/npclient.c b/contrib/very-important-source-code/npclient.c
new file mode 100644
index 00000000..3878f809
--- /dev/null
+++ b/contrib/very-important-source-code/npclient.c
@@ -0,0 +1,587 @@
+#include <stdarg.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <windows.h>
+#include <tchar.h>
+
+#define FREETRACK_MUTEX "FT_Mutext"
+#define FT_MM_DATA "FT_SharedMem"
+
+typedef struct TFreeTrackData {
+ int DataID;
+ int CamWidth;
+ int CamHeight;
+ float Yaw;
+ float Pitch;
+ float Roll;
+ float X;
+ float Y;
+ float Z;
+ float RawYaw;
+ float RawPitch;
+ float RawRoll;
+ float RawX;
+ float RawY;
+ float RawZ;
+ float X1;
+ float Y1;
+ float X2;
+ float Y2;
+ float X3;
+ float Y3;
+ float X4;
+ float Y4;
+} TFreeTrackData;
+
+typedef struct FTMemMap {
+ TFreeTrackData data;
+ __int32 GameId;
+ unsigned char table[8];
+ __int32 GameId2;
+} FTMemMap;
+
+static BOOL bEncryptionChecked = FALSE;
+static double r = 0, p = 0, y = 0, tx = 0, ty = 0, tz = 0;
+
+#define NP_DECLSPEC __declspec(dllexport)
+#define NP_EXPORT(t) t NP_DECLSPEC __stdcall
+#define NP_AXIS_MAX 16383
+
+static BOOL FTCreateMapping(void);
+static void FTDestroyMapping(void);
+static __inline double scale2AnalogLimits( double x, double min_x, double max_x );
+static __inline double getDegreesFromRads ( double rads );
+
+#if DEBUG
+static FILE *debug_stream;
+#define dbg_report(...) do { if (debug_stream) { fprintf(debug_stream, __VA_ARGS__); fflush(debug_stream); } } while(0);
+#else
+#define dbg_report(...)
+#endif
+
+static HANDLE hFTMemMap = 0;
+static FTMemMap *pMemData = 0;
+static HANDLE hFTMutex = 0;
+static BOOL bEncryption = FALSE;
+static unsigned char table[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+
+typedef struct tir_data{
+ short status;
+ short frame;
+ unsigned int cksum;
+ float roll, pitch, yaw;
+ float tx, ty, tz;
+ float padding[9];
+} tir_data_t;
+
+typedef struct tir_signature{
+ char DllSignature[200];
+ char AppSignature[200];
+} tir_signature_t;
+
+BOOL DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
+{
+ switch (fdwReason) {
+ case DLL_PROCESS_ATTACH:
+#if DEBUG
+ debug_stream = fopen("c:\\NPClient.log", "a");
+#endif
+#ifdef _WIN64
+ dbg_report("\n= WIN64 =========================================================================================\n");
+#else
+ dbg_report("\n= WIN32 =========================================================================================\n");
+#endif
+ dbg_report("DllMain: (%p, %ld, %p)\n", (void*) hinstDLL, (long) fdwReason, lpvReserved);
+ dbg_report("DllMain: Attach request\n");
+ DisableThreadLibraryCalls(hinstDLL);
+ timeBeginPeriod(1);
+ break;
+
+ case DLL_PROCESS_DETACH:
+ dbg_report("DllMain: Detach\n");
+ dbg_report("DllMain: (%p, %ld, %p)\n", (void*) hinstDLL, (long) fdwReason, lpvReserved);
+ dbg_report("==========================================================================================\n");
+ timeEndPeriod(1);
+ FTDestroyMapping();
+ break;
+ }
+ return TRUE;
+}
+/******************************************************************
+ * NPPriv_ClientNotify (NPCLIENT.1)
+ */
+
+NP_EXPORT(int) NPPriv_ClientNotify(void)
+{
+ dbg_report("stub\n");
+ /* @stub in .spec */
+ return 0;
+}
+/******************************************************************
+ * NPPriv_GetLastError (NPCLIENT.2)
+ */
+
+NP_EXPORT(int) NPPriv_GetLastError(void)
+{
+ dbg_report("stub\n");
+ /* @stub in .spec */
+ return 0;
+}
+/******************************************************************
+ * NPPriv_SetData (NPCLIENT.3)
+ */
+
+NP_EXPORT(int) NPPriv_SetData(void)
+{
+ dbg_report("stub\n");
+ /* @stub in .spec */
+ return 0;
+}
+/******************************************************************
+ * NPPriv_SetLastError (NPCLIENT.4)
+ */
+
+NP_EXPORT(int) NPPriv_SetLastError(void)
+{
+ dbg_report("stub\n");
+ /* @stub in .spec */
+ return 0;
+}
+/******************************************************************
+ * NPPriv_SetParameter (NPCLIENT.5)
+ */
+
+NP_EXPORT(int) NPPriv_SetParameter(void)
+{
+ dbg_report("stub\n");
+ /* @stub in .spec */
+ return 0;
+}
+/******************************************************************
+ * NPPriv_SetSignature (NPCLIENT.6)
+ */
+
+NP_EXPORT(int) NPPriv_SetSignature(void)
+{
+ dbg_report("stub\n");
+ /* @stub in .spec */
+ return 0;
+}
+/******************************************************************
+ * NPPriv_SetVersion (NPCLIENT.7)
+ */
+
+NP_EXPORT(int) NPPriv_SetVersion(void)
+{
+ dbg_report("stub\n");
+ /* @stub in .spec */
+ return 0;
+}
+
+/* TIR5 requires a checksum to be calculated over the headpose-data and to be relayed to the game. */
+static unsigned int cksum(unsigned char buf[], unsigned int size)
+{
+ int rounds = size >> 2;
+ int rem = size % 4;
+
+ int c = size;
+ int a0, a2;
+
+ if((size == 0) || (buf == NULL)){
+ return 0;
+ }
+
+ while(rounds != 0){
+ a0 = *(short int*)buf;
+ a2 = *(short int*)(buf+2);
+ buf += 4;
+ c += a0;
+ a2 ^= (c << 5);
+ a2 <<= 11;
+ c ^= a2;
+ c += (c >> 11);
+ --rounds;
+ }
+ switch(rem){
+ case 3:
+ a0 = *(short int*)buf;
+ a2 = *(signed char*)(buf+2);
+ c += a0;
+ a2 = (a2 << 2) ^ c;
+ c ^= (a2 << 16);
+ a2 = (c >> 11);
+ break;
+ case 2:
+ a2 = *(short int*)buf;
+ c += a2;
+ c ^= (c << 11);
+ a2 = (c >> 17);
+ break;
+ case 1:
+ a2 = *(signed char*)(buf);
+ c += a2;
+ c ^= (c << 10);
+ a2 = (c >> 1);
+ break;
+ default:
+ break;
+ }
+ if(rem != 0){
+ c+=a2;
+ }
+
+ c ^= (c << 3);
+ c += (c >> 5);
+ c ^= (c << 4);
+ c += (c >> 17);
+ c ^= (c << 25);
+ c += (c >> 6);
+
+ return (unsigned int)c;
+}
+
+static __inline void enhance(unsigned char buf[], unsigned int size,
+ unsigned char table[], int table_size)
+{
+ unsigned int table_ptr = 0;
+ unsigned char var = 0x88;
+ unsigned char tmp;
+ if((size <= 0) || (table_size <= 0) ||
+ (buf == NULL) || (table == NULL)){
+ return;
+ }
+ do{
+ tmp = buf[--size];
+ buf[size] = tmp ^ table[table_ptr] ^ var;
+ var += size + tmp;
+ ++table_ptr;
+ if(table_ptr >= table_size){
+ table_ptr -= table_size;
+ }
+ }while(size != 0);
+}
+
+/******************************************************************
+ * NP_GetData (NPCLIENT.8)
+ */
+
+NP_EXPORT(int) NP_GetData(tir_data_t * data)
+{
+ static int frameno = 0;
+ int i;
+#if DEBUG
+ int recv = 0;
+#endif
+ if (!FTCreateMapping())
+ {
+ dbg_report("Can't open mapping\n");
+ return 0;
+ }
+
+ if (pMemData && hFTMutex && WaitForSingleObject(hFTMutex, 15) == WAIT_OBJECT_0) {
+#if DEBUG
+ recv = 1;
+#endif
+ y = getDegreesFromRads( pMemData->data.Yaw );
+ p = getDegreesFromRads( pMemData->data.Pitch );
+ r = getDegreesFromRads( pMemData->data.Roll );
+ tx = pMemData->data.X;
+ ty = pMemData->data.Y;
+ tz = pMemData->data.Z;
+
+ if (!bEncryptionChecked) {
+ dbg_report("NP_GetData: game = %d\n", pMemData->GameId);
+ memcpy(table, pMemData->table, 8);
+ for (i = 0; i < 8; i++)
+ if (table[i])
+ {
+ bEncryption = TRUE;
+ break;
+ }
+ dbg_report("NP_GetData: Table = %02d %02d %02d %02d %02d %02d %02d %02d\n", table[0],table[1],table[2],table[3],table[4],table[5], table[6], table[7]);
+ bEncryptionChecked = pMemData->GameId2 == pMemData->GameId;
+ }
+
+ ReleaseMutex(hFTMutex);
+ }
+
+ data->frame = frameno += 1;
+ data->status = 0;
+ data->cksum = 0;
+
+ data->roll = scale2AnalogLimits (r, -180.0, 180.0);
+ data->pitch = scale2AnalogLimits (p, -180.0, 180.0);
+ data->yaw = scale2AnalogLimits (y, -180.0, 180.0);
+
+ data->tx = scale2AnalogLimits (tx, -500.0, 500.0);
+ data->ty = scale2AnalogLimits (ty, -500.0, 500.0);
+ data->tz = scale2AnalogLimits (tz, -500.0, 500.0);
+
+ for(i = 0; i < 9; ++i) {
+ data->padding[i] = 0.0;
+ }
+
+#if DEBUG
+ dbg_report("GetData: rotation: %d %f %f %f\n", recv, data->yaw, data->pitch, data->roll);
+#endif
+
+ data->cksum = cksum((unsigned char*)data, sizeof(tir_data_t));
+
+ if(bEncryption) {
+ enhance((unsigned char*)data, sizeof(tir_data_t), table, sizeof(table));
+ }
+
+ return 0;
+}
+/******************************************************************
+ * NP_GetParameter (NPCLIENT.9)
+ */
+
+NP_EXPORT(int) NP_GetParameter(int arg0, int arg1)
+{
+ dbg_report("GetParameter request: %d %d\n", arg0, arg1);
+ return (int) 0;
+}
+
+/******************************************************************
+ * NP_GetSignature (NPCLIENT.10)
+ *
+ *
+ */
+
+static volatile unsigned char part2_2[200] = {
+ 0xe3, 0xe5, 0x8e, 0xe8, 0x06, 0xd4, 0xab,
+ 0xcf, 0xfa, 0x51, 0xa6, 0x84, 0x69, 0x52,
+ 0x21, 0xde, 0x6b, 0x71, 0xe6, 0xac, 0xaa,
+ 0x16, 0xfc, 0x89, 0xd6, 0xac, 0xe7, 0xf8,
+ 0x7c, 0x09, 0x6a, 0x8b, 0x8b, 0x64, 0x0b,
+ 0x7c, 0xc3, 0x61, 0x7f, 0xc2, 0x97, 0xd3,
+ 0x33, 0xd9, 0x99, 0x59, 0xbe, 0xed, 0xdc,
+ 0x2c, 0x5d, 0x93, 0x5c, 0xd4, 0xdd, 0xdf,
+ 0x8b, 0xd5, 0x1d, 0x46, 0x95, 0xbd, 0x10,
+ 0x5a, 0xa9, 0xd1, 0x9f, 0x71, 0x70, 0xd3,
+ 0x94, 0x3c, 0x71, 0x5d, 0x53, 0x1c, 0x52,
+ 0xe4, 0xc0, 0xf1, 0x7f, 0x87, 0xd0, 0x70,
+ 0xa4, 0x04, 0x07, 0x05, 0x69, 0x2a, 0x16,
+ 0x15, 0x55, 0x85, 0xa6, 0x30, 0xc8, 0xb6,
+ 0x00
+};
+
+
+static volatile unsigned char part1_2[200] = {
+ 0x6d, 0x0b, 0xab, 0x56, 0x74, 0xe6, 0x1c,
+ 0xff, 0x24, 0xe8, 0x34, 0x8f, 0x00, 0x63,
+ 0xed, 0x47, 0x5d, 0x9b, 0xe1, 0xe0, 0x1d,
+ 0x02, 0x31, 0x22, 0x89, 0xac, 0x1f, 0xc0,
+ 0xbd, 0x29, 0x13, 0x23, 0x3e, 0x98, 0xdd,
+ 0xd0, 0x2a, 0x98, 0x7d, 0x29, 0xff, 0x2a,
+ 0x7a, 0x86, 0x6c, 0x39, 0x22, 0x3b, 0x86,
+ 0x86, 0xfa, 0x78, 0x31, 0xc3, 0x54, 0xa4,
+ 0x78, 0xaa, 0xc3, 0xca, 0x77, 0x32, 0xd3,
+ 0x67, 0xbd, 0x94, 0x9d, 0x7e, 0x6d, 0x31,
+ 0x6b, 0xa1, 0xc3, 0x14, 0x8c, 0x17, 0xb5,
+ 0x64, 0x51, 0x5b, 0x79, 0x51, 0xa8, 0xcf,
+ 0x5d, 0x1a, 0xb4, 0x84, 0x9c, 0x29, 0xf0,
+ 0xe6, 0x69, 0x73, 0x66, 0x0e, 0x4b, 0x3c,
+ 0x7d, 0x99, 0x8b, 0x4e, 0x7d, 0xaf, 0x86,
+ 0x92, 0xff
+};
+
+static volatile unsigned char part2_1[200] = {
+ 0x8b, 0x84, 0xfc, 0x8c, 0x71, 0xb5, 0xd9,
+ 0xaa, 0xda, 0x32, 0xc7, 0xe9, 0x0c, 0x20,
+ 0x40, 0xd4, 0x4b, 0x02, 0x89, 0xca, 0xde,
+ 0x61, 0x9d, 0xfb, 0xb3, 0x8c, 0x97, 0x8a,
+ 0x13, 0x6a, 0x0f, 0xf8, 0xf8, 0x0d, 0x65,
+ 0x1b, 0xe3, 0x05, 0x1e, 0xb6, 0xf6, 0xd9,
+ 0x13, 0xad, 0xeb, 0x38, 0xdd, 0x86, 0xfc,
+ 0x59, 0x2e, 0xf6, 0x2e, 0xf4, 0xb0, 0xb0,
+ 0xfd, 0xb0, 0x70, 0x23, 0xfb, 0xc9, 0x1a,
+ 0x50, 0x89, 0x92, 0xf0, 0x01, 0x09, 0xa1,
+ 0xfd, 0x5b, 0x19, 0x29, 0x73, 0x59, 0x2b,
+ 0x81, 0x83, 0x9e, 0x11, 0xf3, 0xa2, 0x1f,
+ 0xc8, 0x24, 0x53, 0x60, 0x0a, 0x42, 0x78,
+ 0x7a, 0x39, 0xea, 0xc1, 0x59, 0xad, 0xc5,
+ 0x00
+};
+
+static volatile unsigned char part1_1[200] = {
+ 0x1d, 0x79, 0xce, 0x35, 0x1d, 0x95, 0x79,
+ 0xdf, 0x4c, 0x8d, 0x55, 0xeb, 0x20, 0x17,
+ 0x9f, 0x26, 0x3e, 0xf0, 0x88, 0x8e, 0x7a,
+ 0x08, 0x11, 0x52, 0xfc, 0xd8, 0x3f, 0xb9,
+ 0xd2, 0x5c, 0x61, 0x03, 0x56, 0xfd, 0xbc,
+ 0xb4, 0x0a, 0xf1, 0x13, 0x5d, 0x90, 0x0a,
+ 0x0e, 0xee, 0x09, 0x19, 0x45, 0x5a, 0xeb,
+ 0xe3, 0xf0, 0x58, 0x5f, 0xac, 0x23, 0x84,
+ 0x1f, 0xc5, 0xe3, 0xa6, 0x18, 0x5d, 0xb8,
+ 0x47, 0xdc, 0xe6, 0xf2, 0x0b, 0x03, 0x55,
+ 0x61, 0xab, 0xe3, 0x57, 0xe3, 0x67, 0xcc,
+ 0x16, 0x38, 0x3c, 0x11, 0x25, 0x88, 0x8a,
+ 0x24, 0x7f, 0xf7, 0xeb, 0xf2, 0x5d, 0x82,
+ 0x89, 0x05, 0x53, 0x32, 0x6b, 0x28, 0x54,
+ 0x13, 0xf6, 0xe7, 0x21, 0x1a, 0xc6, 0xe3,
+ 0xe1, 0xff
+};
+
+NP_EXPORT(int) NP_GetSignature(tir_signature_t * sig)
+{
+ int i;
+ dbg_report("GetSignature request\n");
+
+ for (i = 0; i < 200; i++)
+ sig->DllSignature[i] = part1_2[i] ^ part1_1[i];
+ for (i = 0; i < 200; i++)
+ sig->AppSignature[i] = part2_1[i] ^ part2_2[i];
+ memset(sig->DllSignature + strlen(sig->DllSignature), 0, 200 - strlen(sig->DllSignature));
+ memset(sig->AppSignature + strlen(sig->AppSignature), 0, 200 - strlen(sig->AppSignature));
+ return 0;
+}
+
+NP_EXPORT(int) NP_QueryVersion(unsigned short * version)
+{
+ dbg_report("QueryVersion request\n");
+ *version=0x0500;
+ return 0;
+}
+/******************************************************************
+ * NP_ReCenter (NPCLIENT.12)
+ */
+
+NP_EXPORT(int) NP_ReCenter(void)
+{
+ dbg_report("ReCenter request\n");
+ return 0;
+}
+
+/******************************************************************
+ * NP_RegisterProgramProfileID (NPCLIENT.13)
+ */
+
+NP_EXPORT(int) NP_RegisterProgramProfileID(unsigned short id)
+{
+ if (FTCreateMapping())
+ pMemData->GameId = id;
+ dbg_report("RegisterProgramProfileID request: %d\n", id);
+ return 0;
+}
+/******************************************************************
+ * NP_RegisterWindowHandle (NPCLIENT.14)
+ */
+
+NP_EXPORT(int) NP_RegisterWindowHandle(HWND hwnd)
+{
+ dbg_report("RegisterWindowHandle request: %p\n", (void*) hwnd);
+ return (int) 0;
+}
+/******************************************************************
+ * NP_RequestData (NPCLIENT.15)
+ */
+
+NP_EXPORT(int) NP_RequestData(unsigned short req)
+{
+ dbg_report("RequestData request: %d\n", req);
+ return (int) 0;
+}
+/******************************************************************
+ * NP_SetParameter (NPCLIENT.16)
+ */
+
+NP_EXPORT(int) NP_SetParameter(int arg0, int arg1)
+{
+ dbg_report("SetParameter request: %d %d\n", arg0, arg1);
+ return (int) 0;
+}
+/******************************************************************
+ * NP_StartCursor (NPCLIENT.17)
+ */
+
+NP_EXPORT(int) NP_StartCursor(void)
+{
+ dbg_report("StartCursor request\n");
+ return (int) 0;
+}
+/******************************************************************
+ * NP_StartDataTransmission (NPCLIENT.18)
+ */
+
+NP_EXPORT(int) NP_StartDataTransmission(void)
+{
+ dbg_report("StartDataTransmission request.\n");
+
+ return (int) 0;
+}
+/******************************************************************
+ * NP_StopCursor (NPCLIENT.19)
+ */
+
+NP_EXPORT(int) NP_StopCursor(void)
+{
+ dbg_report("StopCursor request\n");
+ return (int) 0;
+}
+/******************************************************************
+ * NP_StopDataTransmission (NPCLIENT.20)
+ */
+
+NP_EXPORT(int) NP_StopDataTransmission(void)
+{
+ return (int) 0;
+}
+/******************************************************************
+ * NP_UnregisterWindowHandle (NPCLIENT.21)
+ */
+
+NP_EXPORT(int) NP_UnregisterWindowHandle(void)
+{
+ dbg_report("UnregisterWindowHandle request\n");
+ return (int) 0;
+}
+
+static BOOL FTCreateMapping(void)
+{
+ BOOL bMappingExists = FALSE;
+
+ if (pMemData)
+ return TRUE;
+
+ dbg_report("FTCreateMapping request (pMemData == NULL).\n");
+
+ hFTMutex = CreateMutexA(NULL, FALSE, FREETRACK_MUTEX);
+ hFTMemMap = CreateFileMappingA( INVALID_HANDLE_VALUE, 00, PAGE_READWRITE, 0, sizeof( FTMemMap ), (LPCSTR) FT_MM_DATA );
+ pMemData = (FTMemMap *) MapViewOfFile(hFTMemMap, FILE_MAP_WRITE, 0, 0, sizeof( FTMemMap ) );
+ return pMemData != NULL && hFTMutex != NULL;
+}
+
+static void FTDestroyMapping(void)
+{
+ if ( pMemData != NULL ) {
+ UnmapViewOfFile ( pMemData );
+ }
+
+ CloseHandle( hFTMutex );
+ CloseHandle( hFTMemMap );
+ pMemData = 0;
+ hFTMemMap = 0;
+}
+
+static __inline double getDegreesFromRads ( double rads ) {
+ return (rads * 57.295781);
+}
+
+static __inline double scale2AnalogLimits( double x, double min_x, double max_x ) {
+ double y;
+ double local_x;
+
+ local_x = x;
+ if (local_x > max_x) {
+ local_x = max_x;
+ }
+ if (local_x < min_x) {
+ local_x = min_x;
+ }
+ y = ( NP_AXIS_MAX * local_x ) / max_x;
+
+ return y;
+}
diff --git a/contrib/very-important-source-code/tester/Makefile.am b/contrib/very-important-source-code/tester/Makefile.am
new file mode 100644
index 00000000..e025209a
--- /dev/null
+++ b/contrib/very-important-source-code/tester/Makefile.am
@@ -0,0 +1,78 @@
+noinst_SCRIPTS =
+if WINE_PLUGIN
+ noinst_SCRIPTS += Tester.exe
+if WINE64
+ noinst_SCRIPTS += Tester64.exe
+endif #WINE64
+endif #WINE_PLUGIN
+
+if DARWIN
+ LDFLAGS += -Wl,-no_arch_warnings
+else
+ LDFLAGS += -Wl,--no-warn-search-mismatch
+endif
+
+CC = winegcc
+
+CXX = wineg++
+
+SUFFIXES = .o .cpp .c .rc 64.o
+
+.cpp.o :
+ $(CXX) -c $(CXXFLAGS) -m32 -o $@ $<
+
+.c.o :
+ $(CC) -c $(CFLAGS) -m32 -o $@ $<
+
+.cpp64.o :
+ $(CXX) -c $(CXXFLAGS) -o $@ $<
+
+.c64.o :
+ $(CC) -c $(CFLAGS) -o $@ $<
+
+.rc.o :
+ wrc -o $@ $(RCFLAGS) $<
+
+CXXFLAGS += -g -DHAVE_CONFIG_H -I../../.. -I. -I@srcdir@/../.. -I@top_builddir@
+CFLAGS += -g -I../.. -I../../.. -DHAVE_CONFIG_H -I@srcdir@/../.. -I@top_builddir@
+RCFLAGS = -I @srcdir@
+#VPATH = ../..:@srcdir@/../..:@top_builddir@:@srcdir@
+vpath %.h @srcdir@/../..
+vpath %.h @top_builddir@
+vpath %.c @srcdir@
+vpath %.c @srcdir@/../..
+
+
+Tester64.exe : main64.o rest64.o npifc64.o npview.o
+ wineg++ -g -o Tester64 -L. $(WINE64_LIBS) $(LDFLAGS) -Wall -Wextra $^
+
+Tester.exe : main.o npview.o rest.o npifc.o
+ wineg++ -g -o Tester -L. $(WINE_LIBS) $(LDFLAGS) -m32 -Wall -Wextra $^
+
+main.o : main.cpp Makefile
+
+main64.o : main.cpp Makefile
+
+npview.o : npview.rc
+
+rest.o : rest.c rest.h Makefile
+
+rest64.o : rest.c rest.h Makefile
+
+npifc.o : npifc.c npifc.h Makefile
+
+npifc64.o : CFLAGS+="-DFOR_WIN64=1"
+npifc64.o : npifc.c npifc.h Makefile
+
+clean-local: clean-local-check
+.PHONY: clean-local-check
+clean-local-check:
+ rm -f *.exe* *.dll* *.sh *.o
+
+distclean-local: distclean-local-check
+.PHONY: distclean-local-check
+distclean-local-check:
+ rm -f *.exe* *.dll* *.sh *.o
+
+EXTRA_DIST = main.cpp npifc.c npifc.h resource.h rest.c rest.h
+
diff --git a/contrib/very-important-source-code/tester/Makefile.in b/contrib/very-important-source-code/tester/Makefile.in
new file mode 100644
index 00000000..cc49d754
--- /dev/null
+++ b/contrib/very-important-source-code/tester/Makefile.in
@@ -0,0 +1,512 @@
+# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__make_running_with_option = \
+ case $${target_option-} in \
+ ?) ;; \
+ *) echo "am__make_running_with_option: internal error: invalid" \
+ "target option '$${target_option-}' specified" >&2; \
+ exit 1;; \
+ esac; \
+ has_opt=no; \
+ sane_makeflags=$$MAKEFLAGS; \
+ if $(am__is_gnu_make); then \
+ sane_makeflags=$$MFLAGS; \
+ else \
+ case $$MAKEFLAGS in \
+ *\\[\ \ ]*) \
+ bs=\\; \
+ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
+ esac; \
+ fi; \
+ skip_next=no; \
+ strip_trailopt () \
+ { \
+ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+ }; \
+ for flg in $$sane_makeflags; do \
+ test $$skip_next = yes && { skip_next=no; continue; }; \
+ case $$flg in \
+ *=*|--*) continue;; \
+ -*I) strip_trailopt 'I'; skip_next=yes;; \
+ -*I?*) strip_trailopt 'I';; \
+ -*O) strip_trailopt 'O'; skip_next=yes;; \
+ -*O?*) strip_trailopt 'O';; \
+ -*l) strip_trailopt 'l'; skip_next=yes;; \
+ -*l?*) strip_trailopt 'l';; \
+ -[dEDm]) skip_next=yes;; \
+ -[JT]) skip_next=yes;; \
+ esac; \
+ case $$flg in \
+ *$$target_option*) has_opt=yes; break;; \
+ esac; \
+ done; \
+ test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+@WINE_PLUGIN_TRUE@am__append_1 = Tester.exe
+@WINE64_TRUE@@WINE_PLUGIN_TRUE@am__append_2 = Tester64.exe
+@DARWIN_TRUE@am__append_3 = -Wl,-no_arch_warnings
+@DARWIN_FALSE@am__append_4 = -Wl,--no-warn-search-mismatch
+subdir = src/wine_bridge/tester
+DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
+ $(srcdir)/npview.rc.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
+ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
+ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
+ $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES = npview.rc
+CONFIG_CLEAN_VPATH_FILES =
+SCRIPTS = $(noinst_SCRIPTS)
+AM_V_P = $(am__v_P_@AM_V@)
+am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo " GEN " $@;
+am__v_GEN_1 =
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 =
+depcomp =
+am__depfiles_maybe =
+SOURCES =
+DIST_SOURCES =
+am__can_run_installinfo = \
+ case $$AM_UPDATE_INFO_DIR in \
+ n|no|NO) false;; \
+ *) (install-info --version) >/dev/null 2>&1;; \
+ esac
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BISON = @BISON@
+CC = winegcc
+CFLAGS = @CFLAGS@ -g -I../.. -I../../.. -DHAVE_CONFIG_H \
+ -I@srcdir@/../.. -I@top_builddir@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = wineg++
+CXXCPP = @CXXCPP@
+CXXFLAGS = @CXXFLAGS@ -g -DHAVE_CONFIG_H -I../../.. -I. \
+ -I@srcdir@/../.. -I@top_builddir@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@ $(am__append_3) $(am__append_4)
+LEX = @LEX@
+LEXLIB = @LEXLIB@
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
+LIB32DIR = @LIB32DIR@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MKDIR_P = @MKDIR_P@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJC = @OBJC@
+OBJCFLAGS = @OBJCFLAGS@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OPENCV_CFLAGS = @OPENCV_CFLAGS@
+OPENCV_LIBS = @OPENCV_LIBS@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
+PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
+QMAKE_PATH = @QMAKE_PATH@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+WINE64_LIBS = @WINE64_LIBS@
+WINE_LIBS = @WINE_LIBS@
+XPL_CPPFLAGS = @XPL_CPPFLAGS@
+YACC = @YACC@
+YFLAGS = @YFLAGS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+ac_ct_OBJC = @ac_ct_OBJC@
+am__leading_dot = @am__leading_dot@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+with_makensis = @with_makensis@
+with_wine64 = @with_wine64@
+noinst_SCRIPTS = $(am__append_1) $(am__append_2)
+SUFFIXES = .o .cpp .c .rc 64.o
+RCFLAGS = -I @srcdir@
+EXTRA_DIST = main.cpp npifc.c npifc.h resource.h rest.c rest.h
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .o .cpp .c .rc 64.o
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu --ignore-deps src/wine_bridge/tester/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --gnu --ignore-deps src/wine_bridge/tester/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+npview.rc: $(top_builddir)/config.status $(srcdir)/npview.rc.in
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+tags TAGS:
+
+ctags CTAGS:
+
+cscope cscopelist:
+
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(SCRIPTS)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ if test -z '$(STRIP)'; then \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ install; \
+ else \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+ fi
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-local mostlyclean-am
+
+distclean: distclean-am
+ -rm -f Makefile
+distclean-am: clean-am distclean-generic distclean-local
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: all all-am check check-am clean clean-generic clean-libtool \
+ clean-local cscopelist-am ctags-am distclean distclean-generic \
+ distclean-libtool distclean-local distdir dvi dvi-am html \
+ html-am info info-am install install-am install-data \
+ install-data-am install-dvi install-dvi-am install-exec \
+ install-exec-am install-html install-html-am install-info \
+ install-info-am install-man install-pdf install-pdf-am \
+ install-ps install-ps-am install-strip installcheck \
+ installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-generic \
+ mostlyclean-libtool pdf pdf-am ps ps-am tags-am uninstall \
+ uninstall-am
+
+
+.cpp.o :
+ $(CXX) -c $(CXXFLAGS) -m32 -o $@ $<
+
+.c.o :
+ $(CC) -c $(CFLAGS) -m32 -o $@ $<
+
+.cpp64.o :
+ $(CXX) -c $(CXXFLAGS) -o $@ $<
+
+.c64.o :
+ $(CC) -c $(CFLAGS) -o $@ $<
+
+.rc.o :
+ wrc -o $@ $(RCFLAGS) $<
+#VPATH = ../..:@srcdir@/../..:@top_builddir@:@srcdir@
+vpath %.h @srcdir@/../..
+vpath %.h @top_builddir@
+vpath %.c @srcdir@
+vpath %.c @srcdir@/../..
+
+Tester64.exe : main64.o rest64.o npifc64.o npview.o
+ wineg++ -g -o Tester64 -L. $(WINE64_LIBS) $(LDFLAGS) -Wall -Wextra $^
+
+Tester.exe : main.o npview.o rest.o npifc.o
+ wineg++ -g -o Tester -L. $(WINE_LIBS) $(LDFLAGS) -m32 -Wall -Wextra $^
+
+main.o : main.cpp Makefile
+
+main64.o : main.cpp Makefile
+
+npview.o : npview.rc
+
+rest.o : rest.c rest.h Makefile
+
+rest64.o : rest.c rest.h Makefile
+
+npifc.o : npifc.c npifc.h Makefile
+
+npifc64.o : CFLAGS+="-DFOR_WIN64=1"
+npifc64.o : npifc.c npifc.h Makefile
+
+clean-local: clean-local-check
+.PHONY: clean-local-check
+clean-local-check:
+ rm -f *.exe* *.dll* *.sh *.o
+
+distclean-local: distclean-local-check
+.PHONY: distclean-local-check
+distclean-local-check:
+ rm -f *.exe* *.dll* *.sh *.o
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/contrib/very-important-source-code/tester/main.cpp b/contrib/very-important-source-code/tester/main.cpp
new file mode 100644
index 00000000..95ca0d9b
--- /dev/null
+++ b/contrib/very-important-source-code/tester/main.cpp
@@ -0,0 +1,100 @@
+#define WIN32_LEAN_AND_MEAN
+
+#include <windows.h>
+#include <stdio.h>
+#include <stdint.h>
+#include "resource.h"
+#include "rest.h"
+#include "npifc.h"
+
+HINSTANCE hInst;
+UINT_PTR timer = 0;
+
+VOID CALLBACK TimerProcedure(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
+{
+ (void) uMsg;
+ (void) idEvent;
+ (void) dwTime;
+ tir_data_t td;
+ npifc_getdata(&td);
+ SetDlgItemInt(hwnd, IDC_PITCH, td.pitch, true);
+ SetDlgItemInt(hwnd, IDC_ROLL, td.roll, true);
+ SetDlgItemInt(hwnd, IDC_YAW, td.yaw, true);
+
+ SetDlgItemInt(hwnd, IDC_X1, td.tx, true);
+ SetDlgItemInt(hwnd, IDC_Y1, td.ty, true);
+ SetDlgItemInt(hwnd, IDC_Z1, td.tz, true);
+
+ SetDlgItemInt(hwnd, IDC_X2, td.padding[0], true);
+ SetDlgItemInt(hwnd, IDC_Y2, td.padding[1], true);
+ SetDlgItemInt(hwnd, IDC_Z2, td.padding[2], true);
+ SetDlgItemInt(hwnd, IDC_X3, td.padding[3], true);
+ SetDlgItemInt(hwnd, IDC_Y3, td.padding[4], true);
+ SetDlgItemInt(hwnd, IDC_Z3, td.padding[5], true);
+ SetDlgItemInt(hwnd, IDC_S, td.status, true);
+ SetDlgItemInt(hwnd, IDC_F, td.frame, true);
+}
+
+BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ (void) lParam;
+ switch(uMsg)
+ {
+ case WM_INITDIALOG:
+ SetDlgItemInt(hwndDlg, IDC_APPID, 2307, true);
+ return TRUE;
+
+ case WM_CLOSE:
+ EndDialog(hwndDlg, 0);
+ return TRUE;
+
+ case WM_COMMAND:
+ switch(LOWORD(wParam))
+ {
+ /*
+ * TODO: Add more control ID's, when needed.
+ */
+ case IDQUIT:
+ npifc_close();
+ EndDialog(hwndDlg, 0);
+ return TRUE;
+ case IDSTART:
+ int ok;
+ int num = GetDlgItemInt(hwndDlg, IDC_APPID, (BOOL*)&ok, false);
+ if(!ok){
+ num = 2307;
+ }
+ game_desc_t gd;
+ if(timer != 0){
+ KillTimer(hwndDlg, timer);
+ timer = 0;
+ }
+ if(game_data_get_desc(num, &gd)){
+ printf("Application ID: %d - %s\n", num, gd.name);
+ if(npifc_init(hwndDlg, num)){
+ timer = SetTimer(hwndDlg, 0, 50, TimerProcedure);
+ }
+ }else{
+ printf("Unknown Application ID: %d\n", num);
+ }
+ break;
+
+ }
+ }
+
+ return FALSE;
+}
+
+
+int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
+{
+ (void) hPrevInstance;
+ (void) lpCmdLine;
+ (void) nShowCmd;
+ hInst = hInstance;
+
+ // The user interface is a modal dialog box
+ return DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), NULL, (DLGPROC)DialogProc);
+}
+
+
diff --git a/contrib/very-important-source-code/tester/npifc.c b/contrib/very-important-source-code/tester/npifc.c
new file mode 100644
index 00000000..b036464e
--- /dev/null
+++ b/contrib/very-important-source-code/tester/npifc.c
@@ -0,0 +1,302 @@
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <stdint.h>
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#include "npifc.h"
+#include "rest.h"
+
+
+tir_signature_t ts;
+HMODULE npclient;
+/*
+typedef int (*NP_RegisterWindowHandle_t)(HWND hwnd);
+typedef int (*NP_UnregisterWindowHandle_t)(void);
+typedef int (*NP_RegisterProgramProfileID_t)(unsigned short id);
+typedef int (*NP_QueryVersion_t)(unsigned short *version);
+typedef int (*NP_RequestData_t)(unsigned short req);
+typedef int (*NP_GetSignature_t)(tir_signature_t *sig);
+typedef int (*NP_GetData_t)(tir_data_t *data);
+typedef int (*NP_GetParameter_t)(void);
+typedef int (*NP_SetParameter_t)(void);
+typedef int (*NP_StartCursor_t)(void);
+typedef int (*NP_StopCursor_t)(void);
+typedef int (*NP_ReCenter_t)(void);
+typedef int (*NP_StartDataTransmission_t)(void);
+typedef int (*NP_StopDataTransmission_t)(void);
+*/
+NP_RegisterWindowHandle_t NP_RegisterWindowHandle = NULL;
+NP_UnregisterWindowHandle_t NP_UnregisterWindowHandle = NULL;
+NP_RegisterProgramProfileID_t NP_RegisterProgramProfileID = NULL;
+NP_QueryVersion_t NP_QueryVersion = NULL;
+NP_RequestData_t NP_RequestData = NULL;
+NP_GetSignature_t NP_GetSignature = NULL;
+NP_GetData_t NP_GetData = NULL;
+NP_GetParameter_t NP_GetParameter = NULL;
+NP_SetParameter_t NP_SetParameter = NULL;
+NP_StartCursor_t NP_StartCursor = NULL;
+NP_StopCursor_t NP_StopCursor = NULL;
+NP_ReCenter_t NP_ReCenter = NULL;
+NP_StartDataTransmission_t NP_StartDataTransmission = NULL;
+NP_StopDataTransmission_t NP_StopDataTransmission = NULL;
+
+bool crypted = false;
+
+
+
+unsigned char table[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+
+char *client_path()
+{
+ HKEY hkey = 0;
+ RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\NaturalPoint\\NATURALPOINT\\NPClient Location", 0,
+ KEY_QUERY_VALUE, &hkey);
+ if(!hkey){
+ printf("Can't open registry key\n");
+ return NULL;
+ }
+
+ BYTE path[1024];
+ DWORD buf_len = 1024;
+ LONG result = RegQueryValueEx(hkey, "Path", NULL, NULL, path, &buf_len);
+ char *full_path = NULL;
+ int res = -1;
+ if(result == ERROR_SUCCESS && buf_len > 0){
+#ifdef FOR_WIN64
+ res = asprintf(&full_path, "%s/NPClient64.dll", path);
+#else
+ res = asprintf(&full_path, "%s/NPClient.dll", path);
+#endif
+ }
+ RegCloseKey(hkey);
+ if(res > 0){
+ return full_path;
+ }else{
+ return NULL;
+ }
+}
+
+bool initialized = false;
+
+bool npifc_init(HWND wnd, int id)
+{
+ //table[] = {0xb3, 0x16, 0x36, 0xeb, 0xb9, 0x05, 0x4f, 0xa4};
+ game_desc_t gd;
+ if(game_data_get_desc(id, &gd)){
+ crypted = gd.encrypted;
+ if(gd.encrypted){
+ table[0] = (unsigned char)(gd.key1&0xff); gd.key1 >>= 8;
+ table[1] = (unsigned char)(gd.key1&0xff); gd.key1 >>= 8;
+ table[2] = (unsigned char)(gd.key1&0xff); gd.key1 >>= 8;
+ table[3] = (unsigned char)(gd.key1&0xff); gd.key1 >>= 8;
+ table[4] = (unsigned char)(gd.key2&0xff); gd.key2 >>= 8;
+ table[5] = (unsigned char)(gd.key2&0xff); gd.key2 >>= 8;
+ table[6] = (unsigned char)(gd.key2&0xff); gd.key2 >>= 8;
+ table[7] = (unsigned char)(gd.key2&0xff); gd.key2 >>= 8;
+ }
+ }
+ printf("0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
+ table[0], table[1], table[2], table[3],
+ table[4], table[5], table[6], table[7]);
+
+ char *client = client_path();
+ if(client == NULL){
+ printf("Couldn't obtain client path!\n");
+ return false;
+ }
+ npclient = LoadLibrary(client);
+ if(!npclient){
+ printf("Can't load client %s\n", client);
+ return false;
+ }
+
+ NP_RegisterWindowHandle = (NP_RegisterWindowHandle_t)GetProcAddress(npclient, "NP_RegisterWindowHandle");
+ NP_UnregisterWindowHandle = (NP_UnregisterWindowHandle_t)GetProcAddress(npclient, "NP_UnregisterWindowHandle");
+ NP_RegisterProgramProfileID = (NP_RegisterProgramProfileID_t)GetProcAddress(npclient, "NP_RegisterProgramProfileID");
+ NP_QueryVersion = (NP_QueryVersion_t)GetProcAddress(npclient, "NP_QueryVersion");
+ NP_RequestData = (NP_RequestData_t)GetProcAddress(npclient, "NP_RequestData");
+ NP_GetSignature = (NP_GetSignature_t)GetProcAddress(npclient, "NP_GetSignature");
+ NP_GetData = (NP_GetData_t)GetProcAddress(npclient, "NP_GetData");
+ NP_GetParameter = (NP_GetParameter_t)GetProcAddress(npclient, "NP_GetParameter");
+ NP_SetParameter = (NP_SetParameter_t)GetProcAddress(npclient, "NP_SetParameter");
+ NP_StartCursor = (NP_StartCursor_t)GetProcAddress(npclient, "NP_StartCursor");
+ NP_StopCursor = (NP_StopCursor_t)GetProcAddress(npclient, "NP_StopCursor");
+ NP_ReCenter = (NP_ReCenter_t)GetProcAddress(npclient, "NP_ReCenter");
+ NP_StartDataTransmission = (NP_StartDataTransmission_t)GetProcAddress(npclient, "NP_StartDataTransmission");
+ NP_StopDataTransmission = (NP_StopDataTransmission_t)GetProcAddress(npclient, "NP_StopDataTransmission");
+ if((NP_RegisterWindowHandle == NULL) || (NP_UnregisterWindowHandle == NULL)
+ || (NP_RegisterProgramProfileID == NULL) || (NP_QueryVersion == NULL) || (NP_RequestData == NULL)
+ || (NP_GetSignature == NULL) || (NP_GetData == NULL) || (NP_GetParameter == NULL)
+ || (NP_SetParameter == NULL) || (NP_StartCursor == NULL) || (NP_StopCursor == NULL)
+ || (NP_ReCenter == NULL) || (NP_StartDataTransmission == NULL) || (NP_StopDataTransmission == NULL)){
+ printf("Couldn't bind all necessary functions!\n");
+ return false;
+ }
+ tir_signature_t sig;
+ int res;
+ if((res = NP_GetSignature(&sig)) != 0){
+ printf("Error retrieving signature! %d\n", res);
+ return false;
+ }
+ printf("Dll Sig:%s\nApp Sig2:%s\n", sig.DllSignature, sig.AppSignature);
+ NP_RegisterWindowHandle(wnd);
+ if(NP_RegisterProgramProfileID(id) != 0){
+ printf("Couldn't register profile id!\n");
+ return false;
+ }
+ printf("Program profile registered!\n");
+ NP_RequestData(65535);
+ NP_StopCursor();
+ NP_StartDataTransmission();
+ initialized = true;
+ return true;
+}
+
+void npifc_close()
+{
+ if(initialized){
+ NP_StopDataTransmission();
+ NP_StartCursor();
+ NP_UnregisterWindowHandle();
+ }
+ initialized = false;
+}
+
+void c_encrypt(unsigned char buf[], unsigned int size,
+ unsigned char code_table[], unsigned int table_size)
+{
+ unsigned int table_ptr = 0;
+ unsigned char var = 0x88;
+ unsigned char tmp;
+ if((size <= 0) || (table_size <= 0) ||
+ (buf == NULL) || (code_table == NULL))
+ return;
+ do{
+ tmp = buf[--size];
+ buf[size] = tmp ^ code_table[table_ptr] ^ var;
+ var += size + tmp;
+ ++table_ptr;
+ if(table_ptr >= table_size){
+ table_ptr -= table_size;
+ }
+ }while(size != 0);
+}
+
+
+
+void decrypt(unsigned char buf[], unsigned int size,
+ unsigned char code_table[], unsigned int table_size)
+{
+ unsigned int table_ptr = 0;
+ unsigned char var = 0x88;
+ unsigned char tmp;
+ if((size <= 0) || (table_size <= 0) ||
+ (buf == NULL) || (code_table == NULL)){
+ return;
+ }
+ do{
+ tmp = buf[--size];
+ buf[size] = tmp ^ code_table[table_ptr] ^ var;
+ var += size + buf[size];
+ ++table_ptr;
+ if(table_ptr >= table_size){
+ table_ptr -= table_size;
+ }
+ }while(size != 0);
+}
+
+unsigned int cksum(unsigned char buf[], unsigned int size)
+{
+ if((size == 0) || (buf == NULL)){
+ return 0;
+ }
+ int rounds = size >> 2;
+ int rem = size % 4;
+
+ int c = size;
+ int a0 = 0;
+ int a2 = 0;
+
+ while(rounds != 0){
+ a0 = *(short int*)buf;
+ a2 = *(short int*)(buf+2);
+ buf += 4;
+ c += a0;
+ a2 ^= (c << 5);
+ a2 <<= 11;
+ c ^= a2;
+ c += (c >> 11);
+ --rounds;
+ }
+ switch(rem){
+ case 3:
+ a0 = *(short int*)buf;
+ a2 = *(signed char*)(buf+2);
+ c += a0;
+ a2 = (a2 << 2) ^ c;
+ c ^= (a2 << 16);
+ a2 = (c >> 11);
+ break;
+ case 2:
+ a2 = *(short int*)buf;
+ c += a2;
+ c ^= (c << 11);
+ a2 = (c >> 17);
+ break;
+ case 1:
+ a2 = *(signed char*)(buf);
+ c += a2;
+ c ^= (c << 10);
+ a2 = (c >> 1);
+ break;
+ default:
+ break;
+ }
+ if(rem != 0){
+ c+=a2;
+ }
+
+ c ^= (c << 3);
+ c += (c >> 5);
+ c ^= (c << 4);
+ c += (c >> 17);
+ c ^= (c << 25);
+ c += (c >> 6);
+
+ return (unsigned int)c;
+}
+
+int decode_frame(tir_data_t *td)
+{
+ //printf("0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
+ // table[0], table[1], table[2], table[3],
+ // table[4], table[5], table[6], table[7]);
+ unsigned int csum;
+ decrypt((unsigned char*)td, sizeof(*td), table, sizeof(table));
+ csum = td->cksum;
+ td->cksum = 0;
+ if(csum != cksum((unsigned char*)td, sizeof(*td))){
+ printf("Problem with frame!\n");
+ //int a0;
+ //printf("Dec: ");
+ //for(a0 = 0; a0 < (int)sizeof(tir_data_t); ++a0)
+ //{
+ // printf("%02X", ((unsigned char *)td)[a0]);
+ //}
+ //printf("\n");
+ //printf("Cksum: %04X vs computed: %04X\n", csum, cksum((unsigned char*)td, sizeof(*td)));
+ return -1;
+ }
+ //printf("Frame OK!\n");
+ return 0;
+}
+
+int npifc_getdata(tir_data_t *data)
+{
+ int res = NP_GetData(data);
+ if(crypted){
+ decode_frame(data);
+ }
+ return res;
+}
+
diff --git a/contrib/very-important-source-code/tester/npifc.h b/contrib/very-important-source-code/tester/npifc.h
new file mode 100644
index 00000000..d580e16d
--- /dev/null
+++ b/contrib/very-important-source-code/tester/npifc.h
@@ -0,0 +1,66 @@
+#ifndef NPIFC__H
+#define NPIFC__H
+
+
+#include <stdbool.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+ bool npifc_init(HWND wnd, int id);
+ void npifc_close();
+
+#pragma pack(1)
+typedef struct tir_data{
+ short status;
+ short frame;
+ unsigned int cksum;
+ float roll, pitch, yaw;
+ float tx, ty, tz;
+ float padding[9];
+} tir_data_t;
+
+typedef struct tir_signature{
+ char DllSignature[200];
+ char AppSignature[200];
+} tir_signature_t;
+#pragma pack(0)
+
+int npifc_getdata(tir_data_t *data);
+
+typedef int __stdcall (*NP_RegisterWindowHandle_t)(HWND hwnd);
+typedef int __stdcall (*NP_UnregisterWindowHandle_t)(void);
+typedef int __stdcall (*NP_RegisterProgramProfileID_t)(unsigned short id);
+typedef int __stdcall (*NP_QueryVersion_t)(unsigned short *version);
+typedef int __stdcall (*NP_RequestData_t)(unsigned short req);
+typedef int __stdcall (*NP_GetSignature_t)(tir_signature_t *sig);
+typedef int __stdcall (*NP_GetData_t)(tir_data_t *data);
+typedef int __stdcall (*NP_GetParameter_t)(void);
+typedef int __stdcall (*NP_SetParameter_t)(void);
+typedef int __stdcall (*NP_StartCursor_t)(void);
+typedef int __stdcall (*NP_StopCursor_t)(void);
+typedef int __stdcall (*NP_ReCenter_t)(void);
+typedef int __stdcall (*NP_StartDataTransmission_t)(void);
+typedef int __stdcall (*NP_StopDataTransmission_t)(void);
+
+extern NP_RegisterWindowHandle_t NP_RegisterWindowHandle;
+extern NP_UnregisterWindowHandle_t NP_UnregisterWindowHandle;
+extern NP_RegisterProgramProfileID_t NP_RegisterProgramProfileID;
+extern NP_QueryVersion_t NP_QueryVersion;
+extern NP_RequestData_t NP_RequestData;
+extern NP_GetSignature_t NP_GetSignature;
+extern NP_GetData_t NP_GetData;
+extern NP_GetParameter_t NP_GetParameter;
+extern NP_SetParameter_t NP_SetParameter;
+extern NP_StartCursor_t NP_StartCursor;
+extern NP_StopCursor_t NP_StopCursor;
+extern NP_ReCenter_t NP_ReCenter;
+extern NP_StartDataTransmission_t NP_StartDataTransmission;
+extern NP_StopDataTransmission_t NP_StopDataTransmission;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/contrib/very-important-source-code/tester/npview.rc.in b/contrib/very-important-source-code/tester/npview.rc.in
new file mode 100644
index 00000000..231002f1
--- /dev/null
+++ b/contrib/very-important-source-code/tester/npview.rc.in
@@ -0,0 +1,49 @@
+// Generated by ResEdit 1.5.9
+// Copyright (C) 2006-2011
+// http://www.resedit.net
+
+#include <windows.h>
+#include <commctrl.h>
+#include <richedit.h>
+#include "resource.h"
+
+#ifdef HAVE_CONFIG_H
+ #include "../../../config.h"
+#endif
+
+
+
+//
+// Dialog resources
+//
+//LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
+IDD_DIALOG1 DIALOGEX 0, 0, 379, 124
+STYLE DS_3DLOOK | DS_CENTER | DS_MODALFRAME | DS_SHELLFONT | WS_CAPTION | WS_VISIBLE | WS_POPUP | WS_SYSMENU
+CAPTION "NPTest v@PACKAGE_VERSION@"
+FONT 8, "Ms Shell Dlg", 400, 0, 1
+{
+ DEFPUSHBUTTON "Quit", IDQUIT, 262, 102, 50, 14
+ DEFPUSHBUTTON "Start", IDSTART, 7, 102, 50, 14
+ EDITTEXT IDC_PITCH, 32, 32, 51, 14, ES_AUTOHSCROLL
+ LTEXT "Pitch", IDC_STATIC, 11, 34, 20, 8, SS_LEFT
+ LTEXT "Yaw", IDC_STATIC, 11, 59, 20, 8, SS_LEFT
+ EDITTEXT IDC_YAW, 32, 57, 51, 14, ES_AUTOHSCROLL
+ LTEXT "Roll", IDC_STATIC, 11, 84, 20, 8, SS_LEFT
+ EDITTEXT IDC_ROLL, 32, 82, 51, 14, ES_AUTOHSCROLL
+ LTEXT "X", IDC_STATIC, 101, 35, 6, 8, SS_LEFT
+ EDITTEXT IDC_X1, 112, 32, 51, 14, ES_AUTOHSCROLL
+ LTEXT "Y", IDC_STATIC, 101, 60, 6, 8, SS_LEFT
+ EDITTEXT IDC_Y1, 112, 57, 51, 14, ES_AUTOHSCROLL
+ LTEXT "Z", IDC_STATIC, 101, 85, 6, 8, SS_LEFT
+ EDITTEXT IDC_Z1, 112, 82, 51, 14, ES_AUTOHSCROLL
+ EDITTEXT IDC_X2, 172, 32, 51, 14, ES_AUTOHSCROLL
+ EDITTEXT IDC_Y2, 172, 57, 51, 14, ES_AUTOHSCROLL
+ EDITTEXT IDC_Z2, 172, 82, 51, 14, ES_AUTOHSCROLL
+ EDITTEXT IDC_X3, 232, 32, 51, 14, ES_AUTOHSCROLL
+ EDITTEXT IDC_Y3, 232, 57, 51, 14, ES_AUTOHSCROLL
+ EDITTEXT IDC_Z3, 232, 82, 51, 14, ES_AUTOHSCROLL
+ EDITTEXT IDC_S, 292, 32, 51, 14, ES_AUTOHSCROLL
+ EDITTEXT IDC_F, 292, 57, 51, 14, ES_AUTOHSCROLL
+ EDITTEXT IDC_APPID, 32, 12, 51, 12, ES_AUTOHSCROLL
+ LTEXT "ID", IDC_STATIC, 17, 14, 8, 8, SS_LEFT
+}
diff --git a/contrib/very-important-source-code/tester/resource.h b/contrib/very-important-source-code/tester/resource.h
new file mode 100644
index 00000000..328d9cb7
--- /dev/null
+++ b/contrib/very-important-source-code/tester/resource.h
@@ -0,0 +1,23 @@
+#ifndef IDC_STATIC
+#define IDC_STATIC (-1)
+#endif
+
+#define IDD_DIALOG1 100
+#define IDQUIT 1002
+#define IDSTART 1003
+#define IDC_APPID 1016
+#define IDC_PITCH 1017
+#define IDC_YAW 1018
+#define IDC_ROLL 1019
+#define IDC_X1 1020
+#define IDC_X2 1021
+#define IDC_X3 1022
+#define IDC_Y1 1023
+#define IDC_Y2 1024
+#define IDC_Y3 1025
+#define IDC_Z1 1026
+#define IDC_Z2 1027
+#define IDC_Z3 1028
+#define IDC_S 1029
+#define IDC_F 1030
+
diff --git a/contrib/vjoy/VJoy.dll b/contrib/vjoy/VJoy.dll
new file mode 100644
index 00000000..e3446675
--- /dev/null
+++ b/contrib/vjoy/VJoy.dll
Binary files differ