forked from silicontrip/SkyReader
-
Notifications
You must be signed in to change notification settings - Fork 8
/
portalio.h
54 lines (39 loc) · 1.19 KB
/
portalio.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#pragma once
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include <unistd.h>
#include <string.h>
// unix io functions
#include <fcntl.h>
#include "hidapi.h"
#include "fileio.h"
#include "crypt.h"
#define rw_buf_size 0x21
#define TIMEOUT 30000
#define SKYLANDER_SIZE 1024
#define MAX_STR 255
typedef struct {
unsigned char buf[rw_buf_size];
int dwBytesTransferred;
} RWBlock;
class PortalIO {
hid_device *hPortalHandle;
public:
PortalIO() throw (int);
~PortalIO();
bool WriteSkylanderToPortal(unsigned char *, unsigned char *);
bool ReadBlock (unsigned int , unsigned char [0x10], int ) throw (int);
void SetPortalColor(unsigned char , unsigned char , unsigned char ) throw (int);
bool WriteBlock(unsigned int , unsigned char [0x10], int ) throw (int);
void flash (void) throw (int);
private:
void OpenPortalHandle() throw (int);
void Write(RWBlock *) throw (int);
void RestartPortal(void) throw (int);
void ActivatePortal(int) throw (int);
unsigned char PortalStatus() throw (int);
void DisconnectPortal(void);
void ConnectToPortal(void) throw (int);
bool CheckResponse (RWBlock *, char ) throw (int);
};