Skip to content

Commit

Permalink
Updated typescript and mouse server code
Browse files Browse the repository at this point in the history
Fixed Mouse not displaying in web viewer
Updated Mouse struct to account for padding added by compiler.
  • Loading branch information
smasherprog committed May 6, 2016
1 parent 3fd84b5 commit 4e8f61d
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 34 deletions.
1 change: 0 additions & 1 deletion Core/ApplicationDirectory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ std::string executable_path(const char *argv0)
}
#else


#include <stdio.h>
#include <stdlib.h>
#include <boost/filesystem/operations.hpp>
Expand Down
1 change: 1 addition & 0 deletions Core/Core.vcxitems
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
<Command>tsc $(SolutionDir)wwwroot\Core.ts</Command>
<Outputs>$(OutDir)wwwroot\Core.js</Outputs>
<TreatOutputAsContent>true</TreatOutputAsContent>
<LinkObjects>false</LinkObjects>
</None>
<None Include="$(MSBuildThisFileDirectory)..\wwwroot\index.html" />
</ItemGroup>
Expand Down
4 changes: 3 additions & 1 deletion Core/Core.vcxitems.filters
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@
<None Include="$(MSBuildThisFileDirectory)..\wwwroot\index.html">
<Filter>wwwroot</Filter>
</None>
<None Include="$(MSBuildThisFileDirectory)..\wwwroot\Core.ts" />
<None Include="$(MSBuildThisFileDirectory)..\wwwroot\Core.ts">
<Filter>wwwroot</Filter>
</None>
</ItemGroup>
</Project>
3 changes: 1 addition & 2 deletions Core/HttpHeader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ namespace SL {
{
if (in[i] == '%')
{

if (i + 3 <= in.size())
{
int value = 0;
Expand All @@ -26,7 +25,6 @@ namespace SL {
}
else
{

return std::string("/");
}
}
Expand All @@ -51,6 +49,7 @@ namespace SL {
}
}


std::unordered_map<std::string, std::string> SL::Remote_Access_Library::Network::HttpHeader::Parse(std::string defaultheaderversion, std::istream& stream)
{
std::unordered_map<std::string, std::string> header;
Expand Down
4 changes: 2 additions & 2 deletions Core/Mouse.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
namespace SL {
namespace Remote_Access_Library {
namespace Input {
enum MouseEvents : unsigned char {
enum MouseEvents : unsigned int {
LEFT,
RIGHT,
MIDDLE,
SCROLL,
NO_EVENTDATA
};
enum MousePress : unsigned char {
enum MousePress : unsigned int {
UP,
DOWN,
NO_PRESS_DATA
Expand Down
4 changes: 2 additions & 2 deletions Core/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ namespace SL {
}
LastScreen = img;//swap
}


void OnMouseImg(std::shared_ptr<Utilities::Image> img)
{
if (!LastMouse) {
Expand Down Expand Up @@ -112,12 +114,10 @@ namespace SL {
}
}
}

Server_Status get_Status() const {
return Status;
}
};

}
}

Expand Down
4 changes: 2 additions & 2 deletions Core/ServerNetworkDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace SL {


void MouseEvent(const std::shared_ptr<ISocket>& socket, std::shared_ptr<Packet>& p) {
assert(p->Payload_Length == sizeof(Input::MouseEvent::EventData) + sizeof(Input::MouseEvent::Pos) + sizeof(Input::MouseEvent::ScrollDelta) + sizeof(Input::MouseEvent::PressData));
assert(p->Payload_Length == sizeof(Input::MouseEvent));
_IServerDriver->OnMouse((Input::MouseEvent*) p->Payload);
}
public:
Expand All @@ -53,7 +53,7 @@ namespace SL {
virtual void OnClose(const std::shared_ptr<ISocket>& socket)override {
_IServerDriver->OnClose(socket);
std::lock_guard<std::mutex> lock(_ClientsLock);
_Clients.erase(std::remove_if(begin(_Clients), end(_Clients), [socket](const std::shared_ptr<ISocket>& p) { return p == socket; }), _Clients.end());
_Clients.erase(std::remove_if(begin(_Clients), end(_Clients), [&socket](const std::shared_ptr<ISocket>& p) { return p == socket; }), _Clients.end());
}

virtual void OnReceive(const std::shared_ptr<ISocket>& socket, std::shared_ptr<Packet>& p) override
Expand Down
2 changes: 0 additions & 2 deletions Core/SocketImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ SL::Remote_Access_Library::Network::SocketStats SL::Remote_Access_Library::Netwo
{
return _SocketStats;
}


char* SL::Remote_Access_Library::Network::SocketImpl::get_ReadBuffer()
{
_IncomingBuffer.reserve(ReadPacketHeader.Payload_Length);
Expand Down
17 changes: 7 additions & 10 deletions wwwroot/Core.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,14 @@ var SL;
this.PressData = PressData;
}
MouseEvent.sizeof = function () {
return 1 + Utilities.Point.sizeof() + 4 + 1;
return 4 + Utilities.Point.sizeof() + 4 + 4;
};
MouseEvent.prototype.Fill = function (d, offset) {
var dt = new DataView(d, offset);
dt.setUint8(0, this.EventData);

this.Pos.Fill(d, offset + 1);

dt.setInt32(offset + 1 + Utilities.Point.sizeof(), this.ScrollDelta, true);

dt.setUint8(offset + 1 + Utilities.Point.sizeof() + 4, this.PressData);
dt.setUint32(0, this.EventData, true);
this.Pos.Fill(d, offset + 4);
dt.setInt32(offset + 4 + Utilities.Point.sizeof(), this.ScrollDelta, true);
dt.setUint32(offset + 4 + Utilities.Point.sizeof() + 4, this.PressData, true);
};
return MouseEvent;
})();
Expand Down Expand Up @@ -160,7 +157,7 @@ var SL;
_this._HTMLCanvasScreenImage.style.left = _this._HTMLCanvasScreenImage.style.top = _this._HTMLCanvasScreenImage.style.zIndex = '0';

_this._HTMLCanvasMouseImage = document.createElement('canvas');

_this._HTMLCanvasMouseImage.style.position = 'absolute';
_this._HTMLCanvasMouseImage.style.left = _this._HTMLCanvasMouseImage.style.top = '0';
_this._HTMLCanvasMouseImage.style.zIndex = '1';

Expand Down Expand Up @@ -446,7 +443,7 @@ var SL;
_this._IClientDriver.OnReceive_ImageDif(_this._Socket, Utilities.Rect.FromArray(data), _this._arrayBufferToBase64(data, Utilities.Rect.sizeof()));
};
this.MouseImage = function (data) {
_this._IClientDriver.OnReceive_MouseImage(_this._Socket, Utilities.Point.FromArray(data), new Uint8Array(data.buffer, Utilities.Point.sizeof()));
_this._IClientDriver.OnReceive_MouseImage(_this._Socket, Utilities.Point.FromArray(data), new Uint8Array(data.slice(Utilities.Point.sizeof()).buffer));
};
this.MousePos = function (data) {
_this._IClientDriver.OnReceive_MousePos(_this._Socket, Utilities.Point.FromArray(data));
Expand Down
19 changes: 7 additions & 12 deletions wwwroot/Core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,13 @@ module SL {
public ScrollDelta = 0,
public PressData = MousePress.NO_PRESS_DATA) { }

static sizeof() { return 1 + Utilities.Point.sizeof() + 4 + 1; }//actual bytes used
static sizeof() { return 4 + Utilities.Point.sizeof() + 4 + 4; }//actual bytes used
Fill(d: ArrayBuffer, offset: number): void {

var dt = new DataView(d, offset);
dt.setUint8(0, this.EventData);

this.Pos.Fill(d, offset + 1);

dt.setInt32(offset + 1 + Utilities.Point.sizeof(), this.ScrollDelta, true);

dt.setUint8(offset + 1 + Utilities.Point.sizeof() + 4, this.PressData);
dt.setUint32(0, this.EventData, true);
this.Pos.Fill(d, offset + 4);
dt.setInt32(offset + 4 + Utilities.Point.sizeof(), this.ScrollDelta, true);
dt.setUint32(offset + 4 + Utilities.Point.sizeof() + 4, this.PressData, true);

}
};
Expand Down Expand Up @@ -137,7 +133,7 @@ module SL {
this._HTMLCanvasScreenImage.style.left = this._HTMLCanvasScreenImage.style.top = this._HTMLCanvasScreenImage.style.zIndex = '0';

this._HTMLCanvasMouseImage = document.createElement('canvas');

this._HTMLCanvasMouseImage.style.position = 'absolute';
this._HTMLCanvasMouseImage.style.left = this._HTMLCanvasMouseImage.style.top = '0';
this._HTMLCanvasMouseImage.style.zIndex = '1';

Expand Down Expand Up @@ -436,8 +432,7 @@ module SL {
this._arrayBufferToBase64(data, Utilities.Rect.sizeof()));
}
MouseImage = (data: Uint8Array): void => {

this._IClientDriver.OnReceive_MouseImage(this._Socket, Utilities.Point.FromArray(data), new Uint8Array(data.buffer, Utilities.Point.sizeof()));
this._IClientDriver.OnReceive_MouseImage(this._Socket, Utilities.Point.FromArray(data), new Uint8Array(data.slice(Utilities.Point.sizeof()).buffer));
}
MousePos = (data: Uint8Array): void => {
this._IClientDriver.OnReceive_MousePos(this._Socket, Utilities.Point.FromArray(data));
Expand Down

0 comments on commit 4e8f61d

Please sign in to comment.