6
0
mirror of https://github.com/JKornev/hidden synced 2024-06-26 00:48:05 +00:00
hidden/HiddenCLI/Connection.cpp

53 lines
847 B
C++
Raw Normal View History

2016-12-04 19:27:46 +00:00
#include "Connection.h"
2016-12-05 22:37:18 +00:00
using namespace std;
Connection::Connection(Arguments& args) :
m_context(nullptr)
{
wstring arg;
if (!args.Probe(arg))
return;
do
{
if (arg == L"/gate")
2016-12-05 22:37:18 +00:00
{
args.SwitchToNext();
if (!args.GetNext(m_deviceName))
throw WException(-2, L"Error, mismatched argument for command 'gate'");
}
else
{
break;
}
}
while (args.Probe(arg));
}
Connection::~Connection()
{
if (m_context)
Hid_Destroy(m_context);
}
void Connection::Open()
{
HidStatus status;
const wchar_t* deviceName = nullptr;
if (m_deviceName.size())
deviceName = m_deviceName.c_str();
//status = Hid_Initialize(&m_context, deviceName);
//if (!HID_STATUS_SUCCESSFUL(status))
// throw WException(HID_STATUS_CODE(status), L"Error, can't connect to gate");
}
HidContext Connection::GetContext()
{
return m_context;
}