From a2113dbb1acf41dc5cb789231b1316a9de5e3ade Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 3 Oct 2015 09:35:29 +0200 Subject: declutter clientfiles/ --- clientfiles/make-csv.pl | 72 ---------------------- clientfiles/very-important-source-code/make-csv.pl | 72 ++++++++++++++++++++++ 2 files changed, 72 insertions(+), 72 deletions(-) delete mode 100644 clientfiles/make-csv.pl create mode 100644 clientfiles/very-important-source-code/make-csv.pl diff --git a/clientfiles/make-csv.pl b/clientfiles/make-csv.pl deleted file mode 100644 index ee60364e..00000000 --- a/clientfiles/make-csv.pl +++ /dev/null @@ -1,72 +0,0 @@ -#!/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/clientfiles/very-important-source-code/make-csv.pl b/clientfiles/very-important-source-code/make-csv.pl new file mode 100644 index 00000000..ee60364e --- /dev/null +++ b/clientfiles/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()); -- cgit v1.2.3 From 95122c69e5d0ab5f3605a54b845739d13b83a712 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 3 Oct 2015 11:29:00 +0200 Subject: pose-widget: use bilinear filtering now The Octopus looks better. --- pose-widget/glwidget.cpp | 52 +++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 43 insertions(+), 9 deletions(-) diff --git a/pose-widget/glwidget.cpp b/pose-widget/glwidget.cpp index 2cb858d7..749817b2 100644 --- a/pose-widget/glwidget.cpp +++ b/pose-widget/glwidget.cpp @@ -11,6 +11,7 @@ #include #include +//#include GLWidget::GLWidget(QWidget *parent) : QWidget(parent) { @@ -159,20 +160,53 @@ void GLWidget::project_quad_texture() { // we have symmetry so only one lookup is needed -sh 20150831 if (triangles[i].barycentric_coords(pos, uv)) { - const int px = origs[i][0].x() + const float fx = origs[i][0].x() + uv.x() * (origs[i][2].x() - origs[i][0].x()) + uv.y() * (origs[i][1].x() - origs[i][0].x()); - const int py = origs[i][0].y() + const float fy = origs[i][0].y() + uv.x() * (origs[i][2].y() - origs[i][0].y()) + uv.y() * (origs[i][1].y() - origs[i][0].y()); - - const unsigned char r = orig[py * orig_pitch + px * orig_depth + 2]; - const unsigned char g = orig[py * orig_pitch + px * orig_depth + 1]; - const unsigned char b = orig[py * orig_pitch + px * orig_depth + 0]; - dest[y * dest_pitch + x * dest_depth + 0] = r; - dest[y * dest_pitch + x * dest_depth + 1] = g; - dest[y * dest_pitch + x * dest_depth + 2] = b; + const int px_ = std::max(0, fx - .5f); + const int py_ = std::max(0, fy - .5f); + const int px = fx; + const int py = fy; + const float ax_ = fabs(fx - px); + const float ay_ = fabs(fy - py); + const float ax = 1.f - ax_; + const float ay = 1.f - ay_; + + // 0, 0 -- ax, ay + const int orig_pos = py * orig_pitch + px * orig_depth; + const unsigned char r = orig[orig_pos + 2]; + const unsigned char g = orig[orig_pos + 1]; + const unsigned char b = orig[orig_pos + 0]; + + // 1, 1 -- ax_, ay_ + const int orig_pos_ = py_ * orig_pitch + px_ * orig_depth; + const unsigned char r_ = orig[orig_pos_ + 2]; + const unsigned char g_ = orig[orig_pos_ + 1]; + const unsigned char b_ = orig[orig_pos_ + 0]; + + // 1, 0 -- ax_, ay + const int orig_pos__ = py * orig_pitch + px_ * orig_depth; + const unsigned char r__ = orig[orig_pos__ + 2]; + const unsigned char g__ = orig[orig_pos__ + 1]; + const unsigned char b__ = orig[orig_pos__ + 0]; + + // 0, 1 -- ax, ay_ + const int orig_pos___ = py_ * orig_pitch + px * orig_depth; + const unsigned char r___ = orig[orig_pos___ + 2]; + const unsigned char g___ = orig[orig_pos___ + 1]; + const unsigned char b___ = orig[orig_pos___ + 0]; + + const int pos = y * dest_pitch + x * dest_depth; + + //qDebug() << "pos" << fx << fy << "uv" << ax << ay; + + dest[pos + 0] = (r * ax + r__ * ax_) * ay + (r___ * ax + r_ * ax_) * ay_; + dest[pos + 1] = (g * ax + g__ * ax_) * ay + (g___ * ax + g_ * ax_) * ay_; + dest[pos + 2] = (b * ax + b__ * ax_) * ay + (b___ * ax + b_ * ax_) * ay_; break; } -- cgit v1.2.3 From ef30c80f747490ecce295cbba16f79eac94ef1b7 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 3 Oct 2015 11:37:17 +0200 Subject: cmake: simplify --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c54b1780..6266ef51 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -439,7 +439,7 @@ if(SDK_HYDRA) ) install(FILES "${SDK_HYDRA}/bin/win32/release_dll/sixense.dll" #"${SDK_HYDRA}/bin/win32/release_dll/sixense_utils.dll" - DESTINATION . PERMISSIONS WORLD_READ WORLD_EXECUTE OWNER_WRITE OWNER_READ OWNER_EXECUTE) + DESTINATION . ${opentrack-perms}) else() if(SDK_HYDRA_AMD64) set(underscore-sixtyfour _x64) -- cgit v1.2.3 From f6f0bca1bf1c3c07a1bbc002c5ae9743f4490e6b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 3 Oct 2015 11:37:47 +0200 Subject: ft: reformat --- clientfiles/very-important-source-code/npclient.c | 51 ++++++++++++----------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/clientfiles/very-important-source-code/npclient.c b/clientfiles/very-important-source-code/npclient.c index d5b78aff..b8ec65ff 100644 --- a/clientfiles/very-important-source-code/npclient.c +++ b/clientfiles/very-important-source-code/npclient.c @@ -46,7 +46,7 @@ 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 +#define NP_AXIS_MAX 16383 static BOOL FTCreateMapping(void); static void FTDestroyMapping(void); @@ -109,7 +109,7 @@ BOOL DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) return TRUE; } /****************************************************************** - * NPPriv_ClientNotify (NPCLIENT.1) + * NPPriv_ClientNotify (NPCLIENT.1) */ NP_EXPORT(int) NPPriv_ClientNotify(void) @@ -119,7 +119,7 @@ NP_EXPORT(int) NPPriv_ClientNotify(void) return 0; } /****************************************************************** - * NPPriv_GetLastError (NPCLIENT.2) + * NPPriv_GetLastError (NPCLIENT.2) */ NP_EXPORT(int) NPPriv_GetLastError(void) @@ -129,7 +129,7 @@ NP_EXPORT(int) NPPriv_GetLastError(void) return 0; } /****************************************************************** - * NPPriv_SetData (NPCLIENT.3) + * NPPriv_SetData (NPCLIENT.3) */ NP_EXPORT(int) NPPriv_SetData(void) @@ -139,7 +139,7 @@ NP_EXPORT(int) NPPriv_SetData(void) return 0; } /****************************************************************** - * NPPriv_SetLastError (NPCLIENT.4) + * NPPriv_SetLastError (NPCLIENT.4) */ NP_EXPORT(int) NPPriv_SetLastError(void) @@ -149,7 +149,7 @@ NP_EXPORT(int) NPPriv_SetLastError(void) return 0; } /****************************************************************** - * NPPriv_SetParameter (NPCLIENT.5) + * NPPriv_SetParameter (NPCLIENT.5) */ NP_EXPORT(int) NPPriv_SetParameter(void) @@ -159,7 +159,7 @@ NP_EXPORT(int) NPPriv_SetParameter(void) return 0; } /****************************************************************** - * NPPriv_SetSignature (NPCLIENT.6) + * NPPriv_SetSignature (NPCLIENT.6) */ NP_EXPORT(int) NPPriv_SetSignature(void) @@ -169,7 +169,7 @@ NP_EXPORT(int) NPPriv_SetSignature(void) return 0; } /****************************************************************** - * NPPriv_SetVersion (NPCLIENT.7) + * NPPriv_SetVersion (NPCLIENT.7) */ NP_EXPORT(int) NPPriv_SetVersion(void) @@ -263,7 +263,7 @@ static __inline void enhance(unsigned char buf[], unsigned int size, } /****************************************************************** - * NP_GetData (NPCLIENT.8) + * NP_GetData (NPCLIENT.8) */ NP_EXPORT(int) NP_GetData(tir_data_t * data) @@ -316,7 +316,7 @@ NP_EXPORT(int) NP_GetData(tir_data_t * data) data->ty = scale2AnalogLimits (ty, -500.0, 500.0); data->tz = scale2AnalogLimits (tz, -500.0, 500.0); - for(i = 0; i < 9; ++i){ + for(i = 0; i < 9; ++i) { data->padding[i] = 0.0; } @@ -325,13 +325,14 @@ NP_EXPORT(int) NP_GetData(tir_data_t * data) #endif data->cksum = cksum((unsigned char*)data, sizeof(tir_data_t)); - if(bEncryption){ + + if(bEncryption) { enhance((unsigned char*)data, sizeof(tir_data_t), table, sizeof(table)); } return 0; } /****************************************************************** - * NP_GetParameter (NPCLIENT.9) + * NP_GetParameter (NPCLIENT.9) */ NP_EXPORT(int) NP_GetParameter(int arg0, int arg1) @@ -341,7 +342,7 @@ NP_EXPORT(int) NP_GetParameter(int arg0, int arg1) } /****************************************************************** - * NP_GetSignature (NPCLIENT.10) + * NP_GetSignature (NPCLIENT.10) * * */ @@ -442,7 +443,7 @@ NP_EXPORT(int) NP_QueryVersion(unsigned short * version) return 0; } /****************************************************************** - * NP_ReCenter (NPCLIENT.12) + * NP_ReCenter (NPCLIENT.12) */ NP_EXPORT(int) NP_ReCenter(void) @@ -452,7 +453,7 @@ NP_EXPORT(int) NP_ReCenter(void) } /****************************************************************** - * NP_RegisterProgramProfileID (NPCLIENT.13) + * NP_RegisterProgramProfileID (NPCLIENT.13) */ NP_EXPORT(int) NP_RegisterProgramProfileID(unsigned short id) @@ -463,7 +464,7 @@ NP_EXPORT(int) NP_RegisterProgramProfileID(unsigned short id) return 0; } /****************************************************************** - * NP_RegisterWindowHandle (NPCLIENT.14) + * NP_RegisterWindowHandle (NPCLIENT.14) */ NP_EXPORT(int) NP_RegisterWindowHandle(HWND hwnd) @@ -472,7 +473,7 @@ NP_EXPORT(int) NP_RegisterWindowHandle(HWND hwnd) return (int) 0; } /****************************************************************** - * NP_RequestData (NPCLIENT.15) + * NP_RequestData (NPCLIENT.15) */ NP_EXPORT(int) NP_RequestData(unsigned short req) @@ -481,7 +482,7 @@ NP_EXPORT(int) NP_RequestData(unsigned short req) return (int) 0; } /****************************************************************** - * NP_SetParameter (NPCLIENT.16) + * NP_SetParameter (NPCLIENT.16) */ NP_EXPORT(int) NP_SetParameter(int arg0, int arg1) @@ -490,7 +491,7 @@ NP_EXPORT(int) NP_SetParameter(int arg0, int arg1) return (int) 0; } /****************************************************************** - * NP_StartCursor (NPCLIENT.17) + * NP_StartCursor (NPCLIENT.17) */ NP_EXPORT(int) NP_StartCursor(void) @@ -499,7 +500,7 @@ NP_EXPORT(int) NP_StartCursor(void) return (int) 0; } /****************************************************************** - * NP_StartDataTransmission (NPCLIENT.18) + * NP_StartDataTransmission (NPCLIENT.18) */ NP_EXPORT(int) NP_StartDataTransmission(void) @@ -509,7 +510,7 @@ NP_EXPORT(int) NP_StartDataTransmission(void) return (int) 0; } /****************************************************************** - * NP_StopCursor (NPCLIENT.19) + * NP_StopCursor (NPCLIENT.19) */ NP_EXPORT(int) NP_StopCursor(void) @@ -518,7 +519,7 @@ NP_EXPORT(int) NP_StopCursor(void) return (int) 0; } /****************************************************************** - * NP_StopDataTransmission (NPCLIENT.20) + * NP_StopDataTransmission (NPCLIENT.20) */ NP_EXPORT(int) NP_StopDataTransmission(void) @@ -526,7 +527,7 @@ NP_EXPORT(int) NP_StopDataTransmission(void) return (int) 0; } /****************************************************************** - * NP_UnregisterWindowHandle (NPCLIENT.21) + * NP_UnregisterWindowHandle (NPCLIENT.21) */ NP_EXPORT(int) NP_UnregisterWindowHandle(void) @@ -538,9 +539,9 @@ NP_EXPORT(int) NP_UnregisterWindowHandle(void) static BOOL FTCreateMapping(void) { BOOL bMappingExists = FALSE; - if ( pMemData != NULL ) { + + if (pMemData) return TRUE; - } dbg_report("FTCreateMapping request (pMemData == NULL).\n"); -- cgit v1.2.3 From b6877457bfc72fc3a4345157535dc6e499494128 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 3 Oct 2015 11:38:00 +0200 Subject: ft: don't alloc "int i" as bss --- clientfiles/very-important-source-code/npclient.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clientfiles/very-important-source-code/npclient.c b/clientfiles/very-important-source-code/npclient.c index b8ec65ff..5e403ede 100644 --- a/clientfiles/very-important-source-code/npclient.c +++ b/clientfiles/very-important-source-code/npclient.c @@ -268,7 +268,8 @@ static __inline void enhance(unsigned char buf[], unsigned int size, NP_EXPORT(int) NP_GetData(tir_data_t * data) { - static int frameno = 0, i; + static int frameno = 0; + int i; #if DEBUG int recv = 0; #endif -- cgit v1.2.3 From cd213cfffe6d4492302808e69f508ccf6259d453 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 3 Oct 2015 11:38:09 +0200 Subject: ft: change nonsensical frame step --- clientfiles/very-important-source-code/npclient.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/clientfiles/very-important-source-code/npclient.c b/clientfiles/very-important-source-code/npclient.c index 5e403ede..3878f809 100644 --- a/clientfiles/very-important-source-code/npclient.c +++ b/clientfiles/very-important-source-code/npclient.c @@ -302,10 +302,11 @@ NP_EXPORT(int) NP_GetData(tir_data_t * data) 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 += 10; + data->frame = frameno += 1; data->status = 0; data->cksum = 0; @@ -330,6 +331,7 @@ NP_EXPORT(int) NP_GetData(tir_data_t * data) if(bEncryption) { enhance((unsigned char*)data, sizeof(tir_data_t), table, sizeof(table)); } + return 0; } /****************************************************************** -- cgit v1.2.3 From 32e67f4ea87461624e74390b25f41aede618d5f0 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 3 Oct 2015 11:38:17 +0200 Subject: ft: add locking back --- ftnoir_protocol_ft/ftnoir_protocol_ft.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp b/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp index b38b0730..97caaefc 100644 --- a/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp +++ b/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp @@ -65,6 +65,8 @@ void FTNoIR_Protocol::pose(const double* headpose) { FTHeap* ft = pMemData; FTData* data = &ft->data; + + shm.lock(); data->RawX = 0; data->RawY = 0; @@ -107,6 +109,8 @@ void FTNoIR_Protocol::pose(const double* headpose) { } data->DataID += 1; + + shm.unlock(); } void FTNoIR_Protocol::start_tirviews() { -- cgit v1.2.3