libmanta
A cross-platform API for the Snyderphonics Manta
|
00001 #ifndef _MANTAUSB_H 00002 #define _MANTAUSB_H 00003 00004 00005 #include <stdint.h> 00006 #include <list> 00007 00008 using namespace std; 00009 00010 /* forward-declare hidapi types so we don't need to include the 00011 * whole header file */ 00012 00013 typedef struct hid_device_ hid_device; 00014 00015 /************************************************************************/ 00028 class MantaUSB 00029 { 00030 public: 00031 MantaUSB(void); 00032 virtual ~MantaUSB(void); 00033 void WriteFrame(uint8_t *frame, bool forceQueued); 00034 bool IsConnected(void); 00035 void Connect(int connectionSerial = 0); 00036 void Disconnect(); 00037 int GetSerialNumber(void); 00038 bool MessageQueued(void); 00039 00040 static void HandleEvents(void); 00041 00042 protected: 00043 virtual void FrameReceived(int8_t *frame) = 0; 00044 virtual void DebugPrint(const char *fmt, ...) {} 00045 static const int OutPacketLen = 16; 00046 static const int InPacketLen = 64; 00047 int SerialNumber; 00048 int MantaIndex; 00049 00050 private: 00051 struct MantaTxQueueEntry 00052 { 00053 MantaUSB *TargetManta; 00054 uint8_t OutFrame[17]; 00055 }; 00056 00057 MantaTxQueueEntry *GetQueuedTxMessage(); 00058 00059 static const int Interface = 0; 00060 static const int EndpointIn = 0x81; /* endpoint 0x81 address for IN */ 00061 static const int EndpointOut = 0x02; /* endpoint 1 address for OUT */ 00062 static const int Timeout = 5000; /* timeout in ms */ 00063 static const int VendorID = 0x2424; 00064 static const int ProductID = 0x2424; 00065 00066 hid_device *DeviceHandle; 00067 00068 static list<MantaUSB *> mantaList; 00069 static list<MantaTxQueueEntry *> txQueue; 00070 }; 00071 00072 #endif // _MANTAUSB_H