3dscontroller-ng/PC/include/wireless.h

85 lines
1.4 KiB
C
Raw Normal View History

2014-12-05 20:03:50 +00:00
#pragma once
#ifndef WINVER
#define WINVER 0x0500
#endif
#include <windows.h>
#include <winsock.h>
2014-12-28 11:23:48 +00:00
#include <stddef.h>
#define SCREENSHOT_CHUNK 4000
2014-12-05 20:03:50 +00:00
#define IP INADDR_ANY
enum NET_COMMANDS {
CONNECT,
KEYS,
2014-12-28 11:23:48 +00:00
SCREENSHOT,
2014-12-05 20:03:50 +00:00
};
2014-12-28 11:23:48 +00:00
// It is deliberately set up to have an anonymous struct as well as a named struct for convenience, not a mistake!
2014-12-05 20:03:50 +00:00
struct packet {
2014-12-15 20:41:12 +00:00
struct packetHeader {
unsigned char command;
unsigned char keyboardActive;
};
2014-12-28 11:23:48 +00:00
struct packetHeader packetHeader;
2014-12-05 20:03:50 +00:00
2014-12-15 20:41:12 +00:00
union {
// CONNECT
struct connectPacket {
};
2014-12-28 11:23:48 +00:00
struct connectPacket connectPacket;
2014-12-15 20:41:12 +00:00
// KEYS
struct keysPacket {
unsigned int keys;
struct {
short x;
short y;
} circlePad;
struct {
unsigned short x;
unsigned short y;
} touch;
struct {
short x;
short y;
} cStick;
unsigned int volume;
2014-12-15 20:41:12 +00:00
};
2014-12-28 11:23:48 +00:00
struct keysPacket keysPacket;
// SCREENSHOT
struct screenshotPacket {
unsigned short offset;
unsigned char data[SCREENSHOT_CHUNK];
};
struct screenshotPacket screenshotPacket;
2014-12-15 20:41:12 +00:00
};
2014-12-05 20:03:50 +00:00
};
extern SOCKET listener;
extern SOCKET client;
extern struct sockaddr_in client_in;
extern int sockaddr_in_sizePtr;
2014-12-08 17:34:52 +00:00
extern struct packet buffer;
2014-12-05 20:03:50 +00:00
extern char hostName[80];
void initNetwork(void);
2014-12-08 18:27:03 +00:00
void printIPs(void);
2014-12-05 20:03:50 +00:00
void startListening(void);
void sendBuffer(int length);
int receiveBuffer(int length);
2014-12-28 11:23:48 +00:00
void sendScreenshot(void);