54 lines
960 B
C++
54 lines
960 B
C++
|
#pragma once
|
||
|
|
||
|
#include <stdexcept>
|
||
|
#include <cstdint>
|
||
|
#include <wchar.h>
|
||
|
#include "hidapi.h"
|
||
|
|
||
|
/*
|
||
|
A singleton Ergodox interface. Wraps all hidapi methods, including
|
||
|
hid_init() and hid_exit().
|
||
|
*/
|
||
|
class Ergodox {
|
||
|
public:
|
||
|
static Ergodox& init(
|
||
|
unsigned short vendor_id,
|
||
|
unsigned short product_id,
|
||
|
unsigned short usage,
|
||
|
unsigned short usage_page
|
||
|
);
|
||
|
|
||
|
~Ergodox();
|
||
|
|
||
|
int write(
|
||
|
uint8_t* data,
|
||
|
size_t length
|
||
|
) const;
|
||
|
|
||
|
|
||
|
private:
|
||
|
Ergodox(
|
||
|
unsigned short vendor_id,
|
||
|
unsigned short product_id,
|
||
|
unsigned short usage,
|
||
|
unsigned short usage_page
|
||
|
);
|
||
|
|
||
|
// Disable copy and assignment
|
||
|
//Ergodox(void);
|
||
|
//Ergodox(Ergodox& other);
|
||
|
//Ergodox& operator=(Ergodox& other);
|
||
|
|
||
|
void open();
|
||
|
void close();
|
||
|
|
||
|
// USB Device paramaters
|
||
|
const unsigned short vendor_id;
|
||
|
const unsigned short product_id;
|
||
|
const unsigned short usage;
|
||
|
const unsigned short usage_page;
|
||
|
|
||
|
// HID device.
|
||
|
// NULL if not opened.
|
||
|
hid_device* handle;
|
||
|
};
|