Apply formatting for files
This commit is contained in:
parent
048d4e8289
commit
28adbd583a
10 changed files with 685 additions and 583 deletions
|
@ -1,5 +1,5 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define INADDRSZ 4
|
#define INADDRSZ 4
|
||||||
|
|
||||||
int inet_pton4(const char *src, unsigned char *dst);
|
int inet_pton4(const char *src, unsigned char *dst);
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "3ds/types.h"
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#include "3ds/types.h"
|
||||||
|
|
||||||
struct settings {
|
struct settings {
|
||||||
char IPString[16];
|
char IPString[16];
|
||||||
int port;
|
int port;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern struct settings settings;
|
extern struct settings settings;
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <3ds.h>
|
#include <3ds.h>
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <netdb.h>
|
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <netdb.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
|
||||||
#include "3ds/services/hid.h"
|
#include "3ds/services/hid.h"
|
||||||
#include "inet_pton.h"
|
#include "inet_pton.h"
|
||||||
#include "sys/_types.h"
|
#include "sys/_types.h"
|
||||||
|
@ -16,87 +17,87 @@
|
||||||
#define DEFAULT_PORT 8889
|
#define DEFAULT_PORT 8889
|
||||||
|
|
||||||
enum NET_COMMANDS {
|
enum NET_COMMANDS {
|
||||||
CONNECT,
|
CONNECT,
|
||||||
KEYS,
|
KEYS,
|
||||||
SCREENSHOT,
|
SCREENSHOT,
|
||||||
};
|
};
|
||||||
|
|
||||||
// It is deliberately set up to have an anonymous struct as well as a named struct for convenience, not a mistake!
|
// It is deliberately set up to have an anonymous struct as well as a named struct for convenience, not a mistake!
|
||||||
struct packet {
|
struct packet {
|
||||||
union {
|
union {
|
||||||
struct packetHeader {
|
struct packetHeader {
|
||||||
unsigned char command;
|
unsigned char command;
|
||||||
unsigned char keyboardActive;
|
unsigned char keyboardActive;
|
||||||
};
|
};
|
||||||
struct packetHeader packetHeader;
|
struct packetHeader packetHeader;
|
||||||
};
|
};
|
||||||
|
|
||||||
union {
|
|
||||||
// CONNECT
|
|
||||||
union {
|
|
||||||
struct connectPacket {
|
|
||||||
};
|
|
||||||
struct connectPacket connectPacket;
|
|
||||||
};
|
|
||||||
|
|
||||||
// KEYS
|
|
||||||
union {
|
|
||||||
struct keysPacket {
|
|
||||||
//Keys
|
|
||||||
unsigned int keys;
|
|
||||||
|
|
||||||
//Cirle Pad
|
|
||||||
struct {
|
|
||||||
short x;
|
|
||||||
short y;
|
|
||||||
} circlePad;
|
|
||||||
|
|
||||||
//Touchpad
|
|
||||||
struct {
|
|
||||||
unsigned short x;
|
|
||||||
unsigned short y;
|
|
||||||
} touch;
|
|
||||||
|
|
||||||
//cStick
|
|
||||||
struct {
|
|
||||||
short x;
|
|
||||||
short y;
|
|
||||||
} cStick;
|
|
||||||
|
|
||||||
//Volume
|
|
||||||
unsigned int volume; //way longer than needed, but it works.
|
|
||||||
|
|
||||||
//Gyroscope
|
union {
|
||||||
struct {
|
// CONNECT
|
||||||
short x;
|
union {
|
||||||
short y;
|
struct connectPacket {
|
||||||
short z;
|
};
|
||||||
} gyro;
|
struct connectPacket connectPacket;
|
||||||
|
};
|
||||||
|
|
||||||
unsigned char padding;
|
// KEYS
|
||||||
|
union {
|
||||||
|
struct keysPacket {
|
||||||
|
// Keys
|
||||||
|
unsigned int keys;
|
||||||
|
|
||||||
//Accelerometer
|
// Cirle Pad
|
||||||
struct {
|
struct {
|
||||||
short x;
|
short x;
|
||||||
short y;
|
short y;
|
||||||
short z;
|
} circlePad;
|
||||||
} accel;
|
|
||||||
|
|
||||||
// unsigned int threeD32;
|
// Touchpad
|
||||||
};
|
struct {
|
||||||
struct keysPacket keysPacket;
|
unsigned short x;
|
||||||
};
|
unsigned short y;
|
||||||
|
} touch;
|
||||||
// SCREENSHOT
|
|
||||||
// union {
|
// cStick
|
||||||
// struct screenshotPacket {
|
struct {
|
||||||
// unsigned short offset;
|
short x;
|
||||||
// unsigned char data[SCREENSHOT_CHUNK];
|
short y;
|
||||||
// };
|
} cStick;
|
||||||
// struct screenshotPacket screenshotPacket;
|
|
||||||
// };
|
// Volume
|
||||||
// This is not even used so...
|
unsigned int volume; // way longer than needed, but it works.
|
||||||
};
|
|
||||||
|
// Gyroscope
|
||||||
|
struct {
|
||||||
|
short x;
|
||||||
|
short y;
|
||||||
|
short z;
|
||||||
|
} gyro;
|
||||||
|
|
||||||
|
unsigned char padding;
|
||||||
|
|
||||||
|
// Accelerometer
|
||||||
|
struct {
|
||||||
|
short x;
|
||||||
|
short y;
|
||||||
|
short z;
|
||||||
|
} accel;
|
||||||
|
|
||||||
|
// unsigned int threeD32;
|
||||||
|
};
|
||||||
|
struct keysPacket keysPacket;
|
||||||
|
};
|
||||||
|
|
||||||
|
// SCREENSHOT
|
||||||
|
// union {
|
||||||
|
// struct screenshotPacket {
|
||||||
|
// unsigned short offset;
|
||||||
|
// unsigned char data[SCREENSHOT_CHUNK];
|
||||||
|
// };
|
||||||
|
// struct screenshotPacket screenshotPacket;
|
||||||
|
// };
|
||||||
|
// This is not even used so...
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
extern int sock;
|
extern int sock;
|
||||||
|
|
399
source/drawing.c
399
source/drawing.c
|
@ -1,177 +1,270 @@
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
|
|
||||||
#include <3ds.h>
|
|
||||||
|
|
||||||
#include "drawing.h"
|
#include "drawing.h"
|
||||||
|
|
||||||
static const char fonts[] = { //Fonte 8x8 1BPP
|
#include <3ds.h>
|
||||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 //tile:0
|
#include <stdarg.h>
|
||||||
, 0x18, 0x18, 0x18, 0x18, 0x18, 0x0, 0x18, 0x0 //tile:1
|
#include <stdio.h>
|
||||||
, 0x6c, 0x6c, 0x6c, 0x0, 0x0, 0x0, 0x0, 0x0 //tile:2
|
#include <string.h>
|
||||||
, 0x6c, 0x6c, 0xfe, 0x6c, 0xfe, 0x6c, 0x6c, 0x0 //tile:3
|
|
||||||
, 0x18, 0x7e, 0xc0, 0x7c, 0x6, 0xfc, 0x18, 0x0 //tile:4
|
static const char fonts[] = {
|
||||||
, 0x0, 0xc6, 0xcc, 0x18, 0x30, 0x66, 0xc6, 0x0 //tile:5
|
// Fonte 8x8 1BPP
|
||||||
, 0x38, 0x6c, 0x38, 0x76, 0xdc, 0xcc, 0x76, 0x0 //tile:6
|
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 // tile:0
|
||||||
, 0x30, 0x30, 0x60, 0x0, 0x0, 0x0, 0x0, 0x0 //tile:7
|
,
|
||||||
, 0xc, 0x18, 0x30, 0x30, 0x30, 0x18, 0xc, 0x0 //tile:8
|
0x18, 0x18, 0x18, 0x18, 0x18, 0x0, 0x18, 0x0 // tile:1
|
||||||
, 0x30, 0x18, 0xc, 0xc, 0xc, 0x18, 0x30, 0x0 //tile:9
|
,
|
||||||
, 0x0, 0x66, 0x3c, 0xff, 0x3c, 0x66, 0x0, 0x0 //tile:10
|
0x6c, 0x6c, 0x6c, 0x0, 0x0, 0x0, 0x0, 0x0 // tile:2
|
||||||
, 0x0, 0x18, 0x18, 0x7e, 0x18, 0x18, 0x0, 0x0 //tile:11
|
,
|
||||||
, 0x0, 0x0, 0x0, 0x0, 0x0, 0x18, 0x18, 0x30 //tile:12
|
0x6c, 0x6c, 0xfe, 0x6c, 0xfe, 0x6c, 0x6c, 0x0 // tile:3
|
||||||
, 0x0, 0x0, 0x0, 0x7e, 0x0, 0x0, 0x0, 0x0 //tile:13
|
,
|
||||||
, 0x0, 0x0, 0x0, 0x0, 0x0, 0x18, 0x18, 0x0 //tile:14
|
0x18, 0x7e, 0xc0, 0x7c, 0x6, 0xfc, 0x18, 0x0 // tile:4
|
||||||
, 0x6, 0xc, 0x18, 0x30, 0x60, 0xc0, 0x80, 0x0 //tile:15
|
,
|
||||||
, 0x7c, 0xce, 0xde, 0xf6, 0xe6, 0xc6, 0x7c, 0x0 //tile:16
|
0x0, 0xc6, 0xcc, 0x18, 0x30, 0x66, 0xc6, 0x0 // tile:5
|
||||||
, 0x18, 0x38, 0x18, 0x18, 0x18, 0x18, 0x7e, 0x0 //tile:17
|
,
|
||||||
, 0x7c, 0xc6, 0x6, 0x7c, 0xc0, 0xc0, 0xfe, 0x0 //tile:18
|
0x38, 0x6c, 0x38, 0x76, 0xdc, 0xcc, 0x76, 0x0 // tile:6
|
||||||
, 0xfc, 0x6, 0x6, 0x3c, 0x6, 0x6, 0xfc, 0x0 //tile:19
|
,
|
||||||
, 0xc, 0xcc, 0xcc, 0xcc, 0xfe, 0xc, 0xc, 0x0 //tile:20
|
0x30, 0x30, 0x60, 0x0, 0x0, 0x0, 0x0, 0x0 // tile:7
|
||||||
, 0xfe, 0xc0, 0xfc, 0x6, 0x6, 0xc6, 0x7c, 0x0 //tile:21
|
,
|
||||||
, 0x7c, 0xc0, 0xc0, 0xfc, 0xc6, 0xc6, 0x7c, 0x0 //tile:22
|
0xc, 0x18, 0x30, 0x30, 0x30, 0x18, 0xc, 0x0 // tile:8
|
||||||
, 0xfe, 0x6, 0x6, 0xc, 0x18, 0x30, 0x30, 0x0 //tile:23
|
,
|
||||||
, 0x7c, 0xc6, 0xc6, 0x7c, 0xc6, 0xc6, 0x7c, 0x0 //tile:24
|
0x30, 0x18, 0xc, 0xc, 0xc, 0x18, 0x30, 0x0 // tile:9
|
||||||
, 0x7c, 0xc6, 0xc6, 0x7e, 0x6, 0x6, 0x7c, 0x0 //tile:25
|
,
|
||||||
, 0x0, 0x18, 0x18, 0x0, 0x0, 0x18, 0x18, 0x0 //tile:26
|
0x0, 0x66, 0x3c, 0xff, 0x3c, 0x66, 0x0, 0x0 // tile:10
|
||||||
, 0x0, 0x18, 0x18, 0x0, 0x0, 0x18, 0x18, 0x30 //tile:27
|
,
|
||||||
, 0xc, 0x18, 0x30, 0x60, 0x30, 0x18, 0xc, 0x0 //tile:28
|
0x0, 0x18, 0x18, 0x7e, 0x18, 0x18, 0x0, 0x0 // tile:11
|
||||||
, 0x0, 0x0, 0x7e, 0x0, 0x7e, 0x0, 0x0, 0x0 //tile:29
|
,
|
||||||
, 0x30, 0x18, 0xc, 0x6, 0xc, 0x18, 0x30, 0x0 //tile:30
|
0x0, 0x0, 0x0, 0x0, 0x0, 0x18, 0x18, 0x30 // tile:12
|
||||||
, 0x3c, 0x66, 0xc, 0x18, 0x18, 0x0, 0x18, 0x0 //tile:31
|
,
|
||||||
, 0x7c, 0xc6, 0xde, 0xde, 0xde, 0xc0, 0x7e, 0x0 //tile:32
|
0x0, 0x0, 0x0, 0x7e, 0x0, 0x0, 0x0, 0x0 // tile:13
|
||||||
, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0x0 //tile:33
|
,
|
||||||
, 0xfc, 0xc6, 0xc6, 0xfc, 0xc6, 0xc6, 0xfc, 0x0 //tile:34
|
0x0, 0x0, 0x0, 0x0, 0x0, 0x18, 0x18, 0x0 // tile:14
|
||||||
, 0x7c, 0xc6, 0xc0, 0xc0, 0xc0, 0xc6, 0x7c, 0x0 //tile:35
|
,
|
||||||
, 0xf8, 0xcc, 0xc6, 0xc6, 0xc6, 0xcc, 0xf8, 0x0 //tile:36
|
0x6, 0xc, 0x18, 0x30, 0x60, 0xc0, 0x80, 0x0 // tile:15
|
||||||
, 0xfe, 0xc0, 0xc0, 0xf8, 0xc0, 0xc0, 0xfe, 0x0 //tile:37
|
,
|
||||||
, 0xfe, 0xc0, 0xc0, 0xf8, 0xc0, 0xc0, 0xc0, 0x0 //tile:38
|
0x7c, 0xce, 0xde, 0xf6, 0xe6, 0xc6, 0x7c, 0x0 // tile:16
|
||||||
, 0x7c, 0xc6, 0xc0, 0xc0, 0xce, 0xc6, 0x7c, 0x0 //tile:39
|
,
|
||||||
, 0xc6, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0x0 //tile:40
|
0x18, 0x38, 0x18, 0x18, 0x18, 0x18, 0x7e, 0x0 // tile:17
|
||||||
, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 0x7e, 0x0 //tile:41
|
,
|
||||||
, 0x6, 0x6, 0x6, 0x6, 0x6, 0xc6, 0x7c, 0x0 //tile:42
|
0x7c, 0xc6, 0x6, 0x7c, 0xc0, 0xc0, 0xfe, 0x0 // tile:18
|
||||||
, 0xc6, 0xcc, 0xd8, 0xf0, 0xd8, 0xcc, 0xc6, 0x0 //tile:43
|
,
|
||||||
, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xfe, 0x0 //tile:44
|
0xfc, 0x6, 0x6, 0x3c, 0x6, 0x6, 0xfc, 0x0 // tile:19
|
||||||
, 0xc6, 0xee, 0xfe, 0xfe, 0xd6, 0xc6, 0xc6, 0x0 //tile:45
|
,
|
||||||
, 0xc6, 0xe6, 0xf6, 0xde, 0xce, 0xc6, 0xc6, 0x0 //tile:46
|
0xc, 0xcc, 0xcc, 0xcc, 0xfe, 0xc, 0xc, 0x0 // tile:20
|
||||||
, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x0 //tile:47
|
,
|
||||||
, 0xfc, 0xc6, 0xc6, 0xfc, 0xc0, 0xc0, 0xc0, 0x0 //tile:48
|
0xfe, 0xc0, 0xfc, 0x6, 0x6, 0xc6, 0x7c, 0x0 // tile:21
|
||||||
, 0x7c, 0xc6, 0xc6, 0xc6, 0xd6, 0xde, 0x7c, 0x6 //tile:49
|
,
|
||||||
, 0xfc, 0xc6, 0xc6, 0xfc, 0xd8, 0xcc, 0xc6, 0x0 //tile:50
|
0x7c, 0xc0, 0xc0, 0xfc, 0xc6, 0xc6, 0x7c, 0x0 // tile:22
|
||||||
, 0x7c, 0xc6, 0xc0, 0x7c, 0x6, 0xc6, 0x7c, 0x0 //tile:51
|
,
|
||||||
, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x0 //tile:52
|
0xfe, 0x6, 0x6, 0xc, 0x18, 0x30, 0x30, 0x0 // tile:23
|
||||||
, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xfe, 0x0 //tile:53
|
,
|
||||||
, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x38, 0x0 //tile:54
|
0x7c, 0xc6, 0xc6, 0x7c, 0xc6, 0xc6, 0x7c, 0x0 // tile:24
|
||||||
, 0xc6, 0xc6, 0xc6, 0xc6, 0xd6, 0xfe, 0x6c, 0x0 //tile:55
|
,
|
||||||
, 0xc6, 0xc6, 0x6c, 0x38, 0x6c, 0xc6, 0xc6, 0x0 //tile:56
|
0x7c, 0xc6, 0xc6, 0x7e, 0x6, 0x6, 0x7c, 0x0 // tile:25
|
||||||
, 0xc6, 0xc6, 0xc6, 0x7c, 0x18, 0x30, 0xe0, 0x0 //tile:57
|
,
|
||||||
, 0xfe, 0x6, 0xc, 0x18, 0x30, 0x60, 0xfe, 0x0 //tile:58
|
0x0, 0x18, 0x18, 0x0, 0x0, 0x18, 0x18, 0x0 // tile:26
|
||||||
, 0x3c, 0x30, 0x30, 0x30, 0x30, 0x30, 0x3c, 0x0 //tile:59
|
,
|
||||||
, 0xc0, 0x60, 0x30, 0x18, 0xc, 0x6, 0x2, 0x0 //tile:60
|
0x0, 0x18, 0x18, 0x0, 0x0, 0x18, 0x18, 0x30 // tile:27
|
||||||
, 0x3c, 0xc, 0xc, 0xc, 0xc, 0xc, 0x3c, 0x0 //tile:61
|
,
|
||||||
, 0x10, 0x38, 0x6c, 0xc6, 0x0, 0x0, 0x0, 0x0 //tile:62
|
0xc, 0x18, 0x30, 0x60, 0x30, 0x18, 0xc, 0x0 // tile:28
|
||||||
, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff //tile:63
|
,
|
||||||
, 0x18, 0x18, 0xc, 0x0, 0x0, 0x0, 0x0, 0x0 //tile:64
|
0x0, 0x0, 0x7e, 0x0, 0x7e, 0x0, 0x0, 0x0 // tile:29
|
||||||
, 0x0, 0x0, 0x7c, 0x6, 0x7e, 0xc6, 0x7e, 0x0 //tile:65
|
,
|
||||||
, 0xc0, 0xc0, 0xc0, 0xfc, 0xc6, 0xc6, 0xfc, 0x0 //tile:66
|
0x30, 0x18, 0xc, 0x6, 0xc, 0x18, 0x30, 0x0 // tile:30
|
||||||
, 0x0, 0x0, 0x7c, 0xc6, 0xc0, 0xc6, 0x7c, 0x0 //tile:67
|
,
|
||||||
, 0x6, 0x6, 0x6, 0x7e, 0xc6, 0xc6, 0x7e, 0x0 //tile:68
|
0x3c, 0x66, 0xc, 0x18, 0x18, 0x0, 0x18, 0x0 // tile:31
|
||||||
, 0x0, 0x0, 0x7c, 0xc6, 0xfe, 0xc0, 0x7c, 0x0 //tile:69
|
,
|
||||||
, 0x1c, 0x36, 0x30, 0x78, 0x30, 0x30, 0x78, 0x0 //tile:70
|
0x7c, 0xc6, 0xde, 0xde, 0xde, 0xc0, 0x7e, 0x0 // tile:32
|
||||||
, 0x0, 0x0, 0x7e, 0xc6, 0xc6, 0x7e, 0x6, 0xfc //tile:71
|
,
|
||||||
, 0xc0, 0xc0, 0xfc, 0xc6, 0xc6, 0xc6, 0xc6, 0x0 //tile:72
|
0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0x0 // tile:33
|
||||||
, 0x18, 0x0, 0x38, 0x18, 0x18, 0x18, 0x3c, 0x0 //tile:73
|
,
|
||||||
, 0x6, 0x0, 0x6, 0x6, 0x6, 0x6, 0xc6, 0x7c //tile:74
|
0xfc, 0xc6, 0xc6, 0xfc, 0xc6, 0xc6, 0xfc, 0x0 // tile:34
|
||||||
, 0xc0, 0xc0, 0xcc, 0xd8, 0xf8, 0xcc, 0xc6, 0x0 //tile:75
|
,
|
||||||
, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x0 //tile:76
|
0x7c, 0xc6, 0xc0, 0xc0, 0xc0, 0xc6, 0x7c, 0x0 // tile:35
|
||||||
, 0x0, 0x0, 0xcc, 0xfe, 0xfe, 0xd6, 0xd6, 0x0 //tile:77
|
,
|
||||||
, 0x0, 0x0, 0xfc, 0xc6, 0xc6, 0xc6, 0xc6, 0x0 //tile:78
|
0xf8, 0xcc, 0xc6, 0xc6, 0xc6, 0xcc, 0xf8, 0x0 // tile:36
|
||||||
, 0x0, 0x0, 0x7c, 0xc6, 0xc6, 0xc6, 0x7c, 0x0 //tile:79
|
,
|
||||||
, 0x0, 0x0, 0xfc, 0xc6, 0xc6, 0xfc, 0xc0, 0xc0 //tile:80
|
0xfe, 0xc0, 0xc0, 0xf8, 0xc0, 0xc0, 0xfe, 0x0 // tile:37
|
||||||
, 0x0, 0x0, 0x7e, 0xc6, 0xc6, 0x7e, 0x6, 0x6 //tile:81
|
,
|
||||||
, 0x0, 0x0, 0xfc, 0xc6, 0xc0, 0xc0, 0xc0, 0x0 //tile:82
|
0xfe, 0xc0, 0xc0, 0xf8, 0xc0, 0xc0, 0xc0, 0x0 // tile:38
|
||||||
, 0x0, 0x0, 0x7e, 0xc0, 0x7c, 0x6, 0xfc, 0x0 //tile:83
|
,
|
||||||
, 0x18, 0x18, 0x7e, 0x18, 0x18, 0x18, 0xe, 0x0 //tile:84
|
0x7c, 0xc6, 0xc0, 0xc0, 0xce, 0xc6, 0x7c, 0x0 // tile:39
|
||||||
, 0x0, 0x0, 0xc6, 0xc6, 0xc6, 0xc6, 0x7e, 0x0 //tile:85
|
,
|
||||||
, 0x0, 0x0, 0xc6, 0xc6, 0xc6, 0x7c, 0x38, 0x0 //tile:86
|
0xc6, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0x0 // tile:40
|
||||||
, 0x0, 0x0, 0xc6, 0xc6, 0xd6, 0xfe, 0x6c, 0x0 //tile:87
|
,
|
||||||
, 0x0, 0x0, 0xc6, 0x6c, 0x38, 0x6c, 0xc6, 0x0 //tile:88
|
0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 0x7e, 0x0 // tile:41
|
||||||
, 0x0, 0x0, 0xc6, 0xc6, 0xc6, 0x7e, 0x6, 0xfc //tile:89
|
,
|
||||||
, 0x0, 0x0, 0xfe, 0xc, 0x38, 0x60, 0xfe, 0x0 //tile:90
|
0x6, 0x6, 0x6, 0x6, 0x6, 0xc6, 0x7c, 0x0 // tile:42
|
||||||
, 0xe, 0x18, 0x18, 0x70, 0x18, 0x18, 0xe, 0x0 //tile:91
|
,
|
||||||
, 0x18, 0x18, 0x18, 0x0, 0x18, 0x18, 0x18, 0x0 //tile:92
|
0xc6, 0xcc, 0xd8, 0xf0, 0xd8, 0xcc, 0xc6, 0x0 // tile:43
|
||||||
, 0x70, 0x18, 0x18, 0xe, 0x18, 0x18, 0x70, 0x0 //tile:93
|
,
|
||||||
, 0x76, 0xdc, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 //tile:94
|
0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xfe, 0x0 // tile:44
|
||||||
, 0x0, 0x10, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0x0 //tile:95
|
,
|
||||||
|
0xc6, 0xee, 0xfe, 0xfe, 0xd6, 0xc6, 0xc6, 0x0 // tile:45
|
||||||
|
,
|
||||||
|
0xc6, 0xe6, 0xf6, 0xde, 0xce, 0xc6, 0xc6, 0x0 // tile:46
|
||||||
|
,
|
||||||
|
0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x0 // tile:47
|
||||||
|
,
|
||||||
|
0xfc, 0xc6, 0xc6, 0xfc, 0xc0, 0xc0, 0xc0, 0x0 // tile:48
|
||||||
|
,
|
||||||
|
0x7c, 0xc6, 0xc6, 0xc6, 0xd6, 0xde, 0x7c, 0x6 // tile:49
|
||||||
|
,
|
||||||
|
0xfc, 0xc6, 0xc6, 0xfc, 0xd8, 0xcc, 0xc6, 0x0 // tile:50
|
||||||
|
,
|
||||||
|
0x7c, 0xc6, 0xc0, 0x7c, 0x6, 0xc6, 0x7c, 0x0 // tile:51
|
||||||
|
,
|
||||||
|
0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x0 // tile:52
|
||||||
|
,
|
||||||
|
0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xfe, 0x0 // tile:53
|
||||||
|
,
|
||||||
|
0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x38, 0x0 // tile:54
|
||||||
|
,
|
||||||
|
0xc6, 0xc6, 0xc6, 0xc6, 0xd6, 0xfe, 0x6c, 0x0 // tile:55
|
||||||
|
,
|
||||||
|
0xc6, 0xc6, 0x6c, 0x38, 0x6c, 0xc6, 0xc6, 0x0 // tile:56
|
||||||
|
,
|
||||||
|
0xc6, 0xc6, 0xc6, 0x7c, 0x18, 0x30, 0xe0, 0x0 // tile:57
|
||||||
|
,
|
||||||
|
0xfe, 0x6, 0xc, 0x18, 0x30, 0x60, 0xfe, 0x0 // tile:58
|
||||||
|
,
|
||||||
|
0x3c, 0x30, 0x30, 0x30, 0x30, 0x30, 0x3c, 0x0 // tile:59
|
||||||
|
,
|
||||||
|
0xc0, 0x60, 0x30, 0x18, 0xc, 0x6, 0x2, 0x0 // tile:60
|
||||||
|
,
|
||||||
|
0x3c, 0xc, 0xc, 0xc, 0xc, 0xc, 0x3c, 0x0 // tile:61
|
||||||
|
,
|
||||||
|
0x10, 0x38, 0x6c, 0xc6, 0x0, 0x0, 0x0, 0x0 // tile:62
|
||||||
|
,
|
||||||
|
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff // tile:63
|
||||||
|
,
|
||||||
|
0x18, 0x18, 0xc, 0x0, 0x0, 0x0, 0x0, 0x0 // tile:64
|
||||||
|
,
|
||||||
|
0x0, 0x0, 0x7c, 0x6, 0x7e, 0xc6, 0x7e, 0x0 // tile:65
|
||||||
|
,
|
||||||
|
0xc0, 0xc0, 0xc0, 0xfc, 0xc6, 0xc6, 0xfc, 0x0 // tile:66
|
||||||
|
,
|
||||||
|
0x0, 0x0, 0x7c, 0xc6, 0xc0, 0xc6, 0x7c, 0x0 // tile:67
|
||||||
|
,
|
||||||
|
0x6, 0x6, 0x6, 0x7e, 0xc6, 0xc6, 0x7e, 0x0 // tile:68
|
||||||
|
,
|
||||||
|
0x0, 0x0, 0x7c, 0xc6, 0xfe, 0xc0, 0x7c, 0x0 // tile:69
|
||||||
|
,
|
||||||
|
0x1c, 0x36, 0x30, 0x78, 0x30, 0x30, 0x78, 0x0 // tile:70
|
||||||
|
,
|
||||||
|
0x0, 0x0, 0x7e, 0xc6, 0xc6, 0x7e, 0x6, 0xfc // tile:71
|
||||||
|
,
|
||||||
|
0xc0, 0xc0, 0xfc, 0xc6, 0xc6, 0xc6, 0xc6, 0x0 // tile:72
|
||||||
|
,
|
||||||
|
0x18, 0x0, 0x38, 0x18, 0x18, 0x18, 0x3c, 0x0 // tile:73
|
||||||
|
,
|
||||||
|
0x6, 0x0, 0x6, 0x6, 0x6, 0x6, 0xc6, 0x7c // tile:74
|
||||||
|
,
|
||||||
|
0xc0, 0xc0, 0xcc, 0xd8, 0xf8, 0xcc, 0xc6, 0x0 // tile:75
|
||||||
|
,
|
||||||
|
0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x0 // tile:76
|
||||||
|
,
|
||||||
|
0x0, 0x0, 0xcc, 0xfe, 0xfe, 0xd6, 0xd6, 0x0 // tile:77
|
||||||
|
,
|
||||||
|
0x0, 0x0, 0xfc, 0xc6, 0xc6, 0xc6, 0xc6, 0x0 // tile:78
|
||||||
|
,
|
||||||
|
0x0, 0x0, 0x7c, 0xc6, 0xc6, 0xc6, 0x7c, 0x0 // tile:79
|
||||||
|
,
|
||||||
|
0x0, 0x0, 0xfc, 0xc6, 0xc6, 0xfc, 0xc0, 0xc0 // tile:80
|
||||||
|
,
|
||||||
|
0x0, 0x0, 0x7e, 0xc6, 0xc6, 0x7e, 0x6, 0x6 // tile:81
|
||||||
|
,
|
||||||
|
0x0, 0x0, 0xfc, 0xc6, 0xc0, 0xc0, 0xc0, 0x0 // tile:82
|
||||||
|
,
|
||||||
|
0x0, 0x0, 0x7e, 0xc0, 0x7c, 0x6, 0xfc, 0x0 // tile:83
|
||||||
|
,
|
||||||
|
0x18, 0x18, 0x7e, 0x18, 0x18, 0x18, 0xe, 0x0 // tile:84
|
||||||
|
,
|
||||||
|
0x0, 0x0, 0xc6, 0xc6, 0xc6, 0xc6, 0x7e, 0x0 // tile:85
|
||||||
|
,
|
||||||
|
0x0, 0x0, 0xc6, 0xc6, 0xc6, 0x7c, 0x38, 0x0 // tile:86
|
||||||
|
,
|
||||||
|
0x0, 0x0, 0xc6, 0xc6, 0xd6, 0xfe, 0x6c, 0x0 // tile:87
|
||||||
|
,
|
||||||
|
0x0, 0x0, 0xc6, 0x6c, 0x38, 0x6c, 0xc6, 0x0 // tile:88
|
||||||
|
,
|
||||||
|
0x0, 0x0, 0xc6, 0xc6, 0xc6, 0x7e, 0x6, 0xfc // tile:89
|
||||||
|
,
|
||||||
|
0x0, 0x0, 0xfe, 0xc, 0x38, 0x60, 0xfe, 0x0 // tile:90
|
||||||
|
,
|
||||||
|
0xe, 0x18, 0x18, 0x70, 0x18, 0x18, 0xe, 0x0 // tile:91
|
||||||
|
,
|
||||||
|
0x18, 0x18, 0x18, 0x0, 0x18, 0x18, 0x18, 0x0 // tile:92
|
||||||
|
,
|
||||||
|
0x70, 0x18, 0x18, 0xe, 0x18, 0x18, 0x70, 0x0 // tile:93
|
||||||
|
,
|
||||||
|
0x76, 0xdc, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 // tile:94
|
||||||
|
,
|
||||||
|
0x0, 0x10, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0x0 // tile:95
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void clearScreen(void) {
|
inline void clearScreen(void) {
|
||||||
u8 *frame = gfxGetFramebuffer(GFX_BOTTOM, GFX_LEFT, NULL, NULL);
|
u8 *frame = gfxGetFramebuffer(GFX_BOTTOM, GFX_LEFT, NULL, NULL);
|
||||||
memset(frame, 0, 320 * 240 * 3);
|
memset(frame, 0, 320 * 240 * 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawPixelRGBFramebuffer(u8 *fb, int x, int y, u8 r, u8 g, u8 b) {
|
void drawPixelRGBFramebuffer(u8 *fb, int x, int y, u8 r, u8 g, u8 b) {
|
||||||
y = 240 - y;
|
y = 240 - y;
|
||||||
x = x;
|
x = x;
|
||||||
u32 v = (y + x * 240) * 3;
|
u32 v = (y + x * 240) * 3;
|
||||||
u8 *topLeftFB = fb ? fb : gfxGetFramebuffer(GFX_BOTTOM, GFX_LEFT, NULL, NULL);
|
u8 *topLeftFB = fb ? fb : gfxGetFramebuffer(GFX_BOTTOM, GFX_LEFT, NULL, NULL);
|
||||||
topLeftFB[v] = (b >> 3) + ((g & 0x1C) << 3);
|
topLeftFB[v] = (b >> 3) + ((g & 0x1C) << 3);
|
||||||
topLeftFB[v+1] = ((g & 0xE0) >> 5) + (r & 0xF8);
|
topLeftFB[v + 1] = ((g & 0xE0) >> 5) + (r & 0xF8);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void drawBoxFramebuffer(u8 *fb, int x, int y, int width, int height, u8 r, u8 g, u8 b) {
|
inline void drawBoxFramebuffer(u8 *fb, int x, int y, int width, int height, u8 r, u8 g, u8 b) {
|
||||||
int lx, ly;
|
int lx, ly;
|
||||||
for(lx = x; lx < x + width; lx++) {
|
for (lx = x; lx < x + width; lx++) {
|
||||||
for(ly = y; ly < y + height; ly++) {
|
for (ly = y; ly < y + height; ly++) {
|
||||||
drawPixelRGBFramebuffer(fb, lx, ly, r, g, b);
|
drawPixelRGBFramebuffer(fb, lx, ly, r, g, b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawStringFramebuffer(u8 *fb, int sx, int sy, char *text, ...) {
|
void drawStringFramebuffer(u8 *fb, int sx, int sy, char *text, ...) {
|
||||||
char str[1024];
|
char str[1024];
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, text);
|
va_start(args, text);
|
||||||
vsnprintf(str, 1023, text, args);
|
vsnprintf(str, 1023, text, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
for(i = 0; i < strlen(str); i++) {
|
for (i = 0; i < strlen(str); i++) {
|
||||||
int fntnum = (str[i] - 32) & 0xFF;
|
int fntnum = (str[i] - 32) & 0xFF;
|
||||||
int y;
|
int y;
|
||||||
for(y = 0; y < 8; y++) {
|
for (y = 0; y < 8; y++) {
|
||||||
int currbyte = fonts[(fntnum * 8) + y];
|
int currbyte = fonts[(fntnum * 8) + y];
|
||||||
//Desenha sprite de 1BPP
|
// Desenha sprite de 1BPP
|
||||||
int x;
|
int x;
|
||||||
int mult = 0x80;
|
int mult = 0x80;
|
||||||
for(x = 0; x < 8; x++) {
|
for (x = 0; x < 8; x++) {
|
||||||
if((currbyte & mult) == mult) {
|
if ((currbyte & mult) == mult) {
|
||||||
drawPixelRGBFramebuffer(fb, sx + x, sy + y, 0xFF, 0xFF, 0xFF);
|
drawPixelRGBFramebuffer(fb, sx + x, sy + y, 0xFF, 0xFF, 0xFF);
|
||||||
drawPixelRGBFramebuffer(fb, sx + x, sy + y + 1, 0, 0, 0); //Sombra
|
drawPixelRGBFramebuffer(fb, sx + x, sy + y + 1, 0, 0, 0); // Sombra
|
||||||
}
|
}
|
||||||
mult /= 2;
|
mult /= 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sx += 8;
|
sx += 8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static u32 brightnessMain;
|
static u32 brightnessMain;
|
||||||
static u32 brightnessSub;
|
static u32 brightnessSub;
|
||||||
|
|
||||||
void disableBacklight() {
|
void disableBacklight() {
|
||||||
u32 off = 0;
|
u32 off = 0;
|
||||||
|
|
||||||
GSPGPU_ReadHWRegs(REG_LCDBACKLIGHTMAIN, &brightnessMain, 4);
|
GSPGPU_ReadHWRegs(REG_LCDBACKLIGHTMAIN, &brightnessMain, 4);
|
||||||
GSPGPU_ReadHWRegs(REG_LCDBACKLIGHTSUB, &brightnessSub, 4);
|
GSPGPU_ReadHWRegs(REG_LCDBACKLIGHTSUB, &brightnessSub, 4);
|
||||||
|
|
||||||
GSPGPU_WriteHWRegs(REG_LCDBACKLIGHTMAIN, &off, 4);
|
GSPGPU_WriteHWRegs(REG_LCDBACKLIGHTMAIN, &off, 4);
|
||||||
GSPGPU_WriteHWRegs(REG_LCDBACKLIGHTSUB, &off, 4);
|
GSPGPU_WriteHWRegs(REG_LCDBACKLIGHTSUB, &off, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void enableBacklight() {
|
void enableBacklight() {
|
||||||
GSPGPU_WriteHWRegs(REG_LCDBACKLIGHTMAIN, &brightnessMain, 4);
|
GSPGPU_WriteHWRegs(REG_LCDBACKLIGHTMAIN, &brightnessMain, 4);
|
||||||
GSPGPU_WriteHWRegs(REG_LCDBACKLIGHTSUB, &brightnessSub, 4);
|
GSPGPU_WriteHWRegs(REG_LCDBACKLIGHTSUB, &brightnessSub, 4);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,44 +1,42 @@
|
||||||
#include "wireless.h"
|
|
||||||
|
|
||||||
#include "inet_pton.h"
|
#include "inet_pton.h"
|
||||||
|
|
||||||
|
#include "wireless.h"
|
||||||
|
|
||||||
int inet_pton4(const char *src, unsigned char *dst) {
|
int inet_pton4(const char *src, unsigned char *dst) {
|
||||||
static const char digits[] = "0123456789";
|
static const char digits[] = "0123456789";
|
||||||
int saw_digit, octets, ch;
|
int saw_digit, octets, ch;
|
||||||
unsigned char tmp[INADDRSZ], *tp;
|
unsigned char tmp[INADDRSZ], *tp;
|
||||||
|
|
||||||
saw_digit = 0;
|
saw_digit = 0;
|
||||||
octets = 0;
|
octets = 0;
|
||||||
tp = tmp;
|
tp = tmp;
|
||||||
*tp = 0;
|
*tp = 0;
|
||||||
while((ch = *src++) != '\0') {
|
while ((ch = *src++) != '\0') {
|
||||||
const char *pch;
|
const char *pch;
|
||||||
|
|
||||||
if((pch = strchr(digits, ch)) != NULL) {
|
if ((pch = strchr(digits, ch)) != NULL) {
|
||||||
unsigned int val = *tp * 10 + (unsigned int)(pch - digits);
|
unsigned int val = *tp * 10 + (unsigned int)(pch - digits);
|
||||||
|
|
||||||
if(saw_digit && *tp == 0)
|
if (saw_digit && *tp == 0)
|
||||||
return (0);
|
return (0);
|
||||||
if(val > 255)
|
if (val > 255)
|
||||||
return (0);
|
return (0);
|
||||||
*tp = (unsigned char)val;
|
*tp = (unsigned char)val;
|
||||||
if(! saw_digit) {
|
if (!saw_digit) {
|
||||||
if(++octets > 4)
|
if (++octets > 4)
|
||||||
return (0);
|
return (0);
|
||||||
saw_digit = 1;
|
saw_digit = 1;
|
||||||
}
|
}
|
||||||
|
} else if (ch == '.' && saw_digit) {
|
||||||
|
if (octets == 4)
|
||||||
|
return (0);
|
||||||
|
*++tp = 0;
|
||||||
|
saw_digit = 0;
|
||||||
|
} else
|
||||||
|
return (0);
|
||||||
}
|
}
|
||||||
else if(ch == '.' && saw_digit) {
|
if (octets < 4)
|
||||||
if(octets == 4)
|
|
||||||
return (0);
|
return (0);
|
||||||
*++tp = 0;
|
memcpy(dst, tmp, INADDRSZ);
|
||||||
saw_digit = 0;
|
return (1);
|
||||||
}
|
|
||||||
else
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
if(octets < 4)
|
|
||||||
return (0);
|
|
||||||
memcpy(dst, tmp, INADDRSZ);
|
|
||||||
return (1);
|
|
||||||
}
|
}
|
||||||
|
|
114
source/input.c
114
source/input.c
|
@ -1,59 +1,69 @@
|
||||||
#include <stdlib.h>
|
#include "input.h"
|
||||||
#include <string.h>
|
|
||||||
#include <malloc.h>
|
|
||||||
|
|
||||||
#include <3ds.h>
|
#include <3ds.h>
|
||||||
|
#include <malloc.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "drawing.h"
|
#include "drawing.h"
|
||||||
|
|
||||||
#include "input.h"
|
|
||||||
|
|
||||||
int inputIP(void) {
|
int inputIP(void) {
|
||||||
touchPosition touch;
|
touchPosition touch;
|
||||||
hidTouchRead(&touch);
|
hidTouchRead(&touch);
|
||||||
|
|
||||||
//Draw Keypad
|
// Draw Keypad
|
||||||
drawString(160-20,50, "1");
|
drawString(160 - 20, 50, "1");
|
||||||
drawString(160, 50, "2");
|
drawString(160, 50, "2");
|
||||||
drawString(160+20, 50, "3");
|
drawString(160 + 20, 50, "3");
|
||||||
|
|
||||||
drawString(160-20, 50+20, "4");
|
drawString(160 - 20, 50 + 20, "4");
|
||||||
drawString(160, 50+20, "5");
|
drawString(160, 50 + 20, "5");
|
||||||
drawString(160+20, 50+20, "6");
|
drawString(160 + 20, 50 + 20, "6");
|
||||||
|
|
||||||
drawString(160-20, 50+40, "7");
|
drawString(160 - 20, 50 + 40, "7");
|
||||||
drawString(160, 50+40, "8");
|
drawString(160, 50 + 40, "8");
|
||||||
drawString(160+20, 50+40, "9");
|
drawString(160 + 20, 50 + 40, "9");
|
||||||
|
|
||||||
drawString(160-10, 50+60, ".");
|
drawString(160 - 10, 50 + 60, ".");
|
||||||
drawString(160+10, 50+60, "0");
|
drawString(160 + 10, 50 + 60, "0");
|
||||||
|
|
||||||
//Bottom Strip
|
// Bottom Strip
|
||||||
if(touch.py > 50+50 && touch.py < 50+70) {
|
if (touch.py > 50 + 50 && touch.py < 50 + 70) {
|
||||||
if(touch.px < 160 && touch.px > 160-20) return 11; // Dot
|
if (touch.px < 160 && touch.px > 160 - 20)
|
||||||
else if(touch.px < 160+20 && touch.px > 160) return 0; // Zero
|
return 11; // Dot
|
||||||
}
|
else if (touch.px < 160 + 20 && touch.px > 160)
|
||||||
|
return 0; // Zero
|
||||||
//First Column
|
}
|
||||||
else if(touch.px < 160-10 && touch.px > 160-30) {
|
|
||||||
if(touch.py < 50+10 && touch.py > 50-10) return 1; // One
|
// First Column
|
||||||
else if(touch.py < 50+30 && touch.py > 50+10) return 4; // Four
|
else if (touch.px < 160 - 10 && touch.px > 160 - 30) {
|
||||||
else if(touch.py < 50+50 && touch.py > 50+30) return 7; // Seven
|
if (touch.py < 50 + 10 && touch.py > 50 - 10)
|
||||||
}
|
return 1; // One
|
||||||
|
else if (touch.py < 50 + 30 && touch.py > 50 + 10)
|
||||||
// Second Column
|
return 4; // Four
|
||||||
else if(touch.px < 160+10 && touch.px > 160-10) {
|
else if (touch.py < 50 + 50 && touch.py > 50 + 30)
|
||||||
if(touch.py < 50+10 && touch.py > 50-10) return 2; // Two
|
return 7; // Seven
|
||||||
else if(touch.py < 50+30 && touch.py > 50+10) return 5; // Five
|
}
|
||||||
else if(touch.py < 50+50 && touch.py > 50+30) return 8; // Eight
|
|
||||||
}
|
// Second Column
|
||||||
|
else if (touch.px < 160 + 10 && touch.px > 160 - 10) {
|
||||||
// Third Column
|
if (touch.py < 50 + 10 && touch.py > 50 - 10)
|
||||||
else if(touch.px < 160+30 && touch.px > 160+10) {
|
return 2; // Two
|
||||||
if(touch.py < 50+10 && touch.py > 50-10) return 3; // Three
|
else if (touch.py < 50 + 30 && touch.py > 50 + 10)
|
||||||
else if(touch.py < 50+30 && touch.py > 50+10) return 6; // Six
|
return 5; // Five
|
||||||
else if(touch.py < 50+50 && touch.py > 50+30) return 9; // Nine
|
else if (touch.py < 50 + 50 && touch.py > 50 + 30)
|
||||||
}
|
return 8; // Eight
|
||||||
|
}
|
||||||
return 10;
|
|
||||||
|
// Third Column
|
||||||
|
else if (touch.px < 160 + 30 && touch.px > 160 + 10) {
|
||||||
|
if (touch.py < 50 + 10 && touch.py > 50 - 10)
|
||||||
|
return 3; // Three
|
||||||
|
else if (touch.py < 50 + 30 && touch.py > 50 + 10)
|
||||||
|
return 6; // Six
|
||||||
|
else if (touch.py < 50 + 50 && touch.py > 50 + 30)
|
||||||
|
return 9; // Nine
|
||||||
|
}
|
||||||
|
|
||||||
|
return 10;
|
||||||
}
|
}
|
|
@ -1,11 +1,11 @@
|
||||||
|
#include "keyboard.h"
|
||||||
|
|
||||||
#include <3ds.h>
|
#include <3ds.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "drawing.h"
|
#include "drawing.h"
|
||||||
|
|
||||||
#include "keyboard.h"
|
|
||||||
|
|
||||||
const char keyboardChars[60] = "!1234567890\x08QWERTYUIOP\13\13ASDFGHJKL-\13\13ZXCVBNM,.?\13\13\0\0\0 \0\0\0\0";
|
const char keyboardChars[60] = "!1234567890\x08QWERTYUIOP\13\13ASDFGHJKL-\13\13ZXCVBNM,.?\13\13\0\0\0 \0\0\0\0";
|
||||||
|
|
||||||
unsigned char keyboardActive = false;
|
unsigned char keyboardActive = false;
|
||||||
|
@ -14,65 +14,65 @@ unsigned char keyboardToggle = true;
|
||||||
unsigned char keyboardGfx[320 * 240 * 3];
|
unsigned char keyboardGfx[320 * 240 * 3];
|
||||||
|
|
||||||
void preRenderKeyboard(void) {
|
void preRenderKeyboard(void) {
|
||||||
const char chars[60] = "!1234567890\x08QWERTYUIOP\13\13ASDFGHJKL-\13\13ZXCVBNM,.?\13\13\0\0\0 \0\0\0\0";
|
const char chars[60] = "!1234567890\x08QWERTYUIOP\13\13ASDFGHJKL-\13\13ZXCVBNM,.?\13\13\0\0\0 \0\0\0\0";
|
||||||
|
|
||||||
int x, y;
|
int x, y;
|
||||||
for(x = 0; x < 12; x++) {
|
for (x = 0; x < 12; x++) {
|
||||||
for(y = 0; y < 4; y++) {
|
for (y = 0; y < 4; y++) {
|
||||||
// Not enter
|
// Not enter
|
||||||
if(chars[x + y * 12] != '\13') {
|
if (chars[x + y * 12] != '\13') {
|
||||||
drawBoxFramebuffer(keyboardGfx, (int)((float)x * 320.0f / 12.0f), (int)(78.0f + (float)y * 320.0f / 12.0f), 25, 25, 31, 31, 31);
|
drawBoxFramebuffer(keyboardGfx, (int)((float)x * 320.0f / 12.0f), (int)(78.0f + (float)y * 320.0f / 12.0f), 25, 25, 31, 31, 31);
|
||||||
drawBoxFramebuffer(keyboardGfx, (int)((float)x * 320.0f / 12.0f) + 1, (int)(78.0f + (float)y * 320.0f / 12.0f) + 1, 24, 24, 31, 0, 0);
|
drawBoxFramebuffer(keyboardGfx, (int)((float)x * 320.0f / 12.0f) + 1, (int)(78.0f + (float)y * 320.0f / 12.0f) + 1, 24, 24, 31, 0, 0);
|
||||||
|
|
||||||
// Backspace
|
// Backspace
|
||||||
if(chars[x + y * 12] == '\x08') {
|
if (chars[x + y * 12] == '\x08') {
|
||||||
drawStringFramebuffer(keyboardGfx, (int)((float)x * 320.0f / 12.0f) + 10, (int)(78.0f + (float)y * 320.0f / 12.0f) + 9, "-");
|
drawStringFramebuffer(keyboardGfx, (int)((float)x * 320.0f / 12.0f) + 10, (int)(78.0f + (float)y * 320.0f / 12.0f) + 9, "-");
|
||||||
drawStringFramebuffer(keyboardGfx, (int)((float)x * 320.0f / 12.0f) + 8, (int)(78.0f + (float)y * 320.0f / 12.0f) + 9, "<");
|
drawStringFramebuffer(keyboardGfx, (int)((float)x * 320.0f / 12.0f) + 8, (int)(78.0f + (float)y * 320.0f / 12.0f) + 9, "<");
|
||||||
}
|
} else
|
||||||
else drawStringFramebuffer(keyboardGfx, (int)((float)x * 320.0f / 12.0f) + 9, (int)(78.0f + (float)y * 320.0f / 12.0f) + 9, "%c", chars[x + y * 12]);
|
drawStringFramebuffer(keyboardGfx, (int)((float)x * 320.0f / 12.0f) + 9, (int)(78.0f + (float)y * 320.0f / 12.0f) + 9, "%c", chars[x + y * 12]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Space
|
// Space
|
||||||
drawBoxFramebuffer(keyboardGfx, (int)((float)3 * 320.0f / 12.0f), (int)(78.0f + (float)4 * 320.0f / 12.0f), (int)(5.0f * 320.0f / 12.0f), 25, 31, 31, 31);
|
drawBoxFramebuffer(keyboardGfx, (int)((float)3 * 320.0f / 12.0f), (int)(78.0f + (float)4 * 320.0f / 12.0f), (int)(5.0f * 320.0f / 12.0f), 25, 31, 31, 31);
|
||||||
drawBoxFramebuffer(keyboardGfx, (int)((float)3 * 320.0f / 12.0f) + 1, (int)(78.0f + (float)4 * 320.0f / 12.0f) + 1, (int)(5.0f * 320.0f / 12.0f) - 1, 24, 31, 0, 0);
|
drawBoxFramebuffer(keyboardGfx, (int)((float)3 * 320.0f / 12.0f) + 1, (int)(78.0f + (float)4 * 320.0f / 12.0f) + 1, (int)(5.0f * 320.0f / 12.0f) - 1, 24, 31, 0, 0);
|
||||||
|
|
||||||
// Enter
|
// Enter
|
||||||
drawBoxFramebuffer(keyboardGfx, (int)((float)10 * 320.0f / 12.0f), (int)(78.0f + (float)1 * 320.0f / 12.0f), (int)(2.0f * 320.0f / 12.0f), (int)(3.0f * 320.0f / 12.0f), 31, 31, 31);
|
drawBoxFramebuffer(keyboardGfx, (int)((float)10 * 320.0f / 12.0f), (int)(78.0f + (float)1 * 320.0f / 12.0f), (int)(2.0f * 320.0f / 12.0f), (int)(3.0f * 320.0f / 12.0f), 31, 31, 31);
|
||||||
drawBoxFramebuffer(keyboardGfx, (int)((float)10 * 320.0f / 12.0f) + 1, (int)(78.0f + (float)1 * 320.0f / 12.0f) + 1, (int)(2.0f * 320.0f / 12.0f) - 1, (int)(3.0f * 320.0f / 12.0f) - 1, 31, 0, 0);
|
drawBoxFramebuffer(keyboardGfx, (int)((float)10 * 320.0f / 12.0f) + 1, (int)(78.0f + (float)1 * 320.0f / 12.0f) + 1, (int)(2.0f * 320.0f / 12.0f) - 1, (int)(3.0f * 320.0f / 12.0f) - 1, 31, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void drawKeyboard(void) {
|
inline void drawKeyboard(void) {
|
||||||
u8 *topLeftFB = gfxGetFramebuffer(GFX_BOTTOM, GFX_LEFT, NULL, NULL);
|
u8 *topLeftFB = gfxGetFramebuffer(GFX_BOTTOM, GFX_LEFT, NULL, NULL);
|
||||||
memcpy(topLeftFB, keyboardGfx, sizeof(keyboardGfx));
|
memcpy(topLeftFB, keyboardGfx, sizeof(keyboardGfx));
|
||||||
|
|
||||||
/*const char chars[60] = "!1234567890\x08QWERTYUIOP\13\13ASDFGHJKL-\13\13ZXCVBNM,.?\13\13\0\0\0 \0\0\0\0";
|
/*const char chars[60] = "!1234567890\x08QWERTYUIOP\13\13ASDFGHJKL-\13\13ZXCVBNM,.?\13\13\0\0\0 \0\0\0\0";
|
||||||
|
|
||||||
int x, y;
|
int x, y;
|
||||||
for(x = 0; x < 12; x++) {
|
for(x = 0; x < 12; x++) {
|
||||||
for(y = 0; y < 4; y++) {
|
for(y = 0; y < 4; y++) {
|
||||||
// Not enter
|
// Not enter
|
||||||
if(chars[x + y * 12] != '\13') {
|
if(chars[x + y * 12] != '\13') {
|
||||||
drawBox((int)((float)x * 320.0f / 12.0f), (int)(78.0f + (float)y * 320.0f / 12.0f), 25, 25, 31, 31, 31);
|
drawBox((int)((float)x * 320.0f / 12.0f), (int)(78.0f + (float)y * 320.0f / 12.0f), 25, 25, 31, 31, 31);
|
||||||
drawBox((int)((float)x * 320.0f / 12.0f) + 1, (int)(78.0f + (float)y * 320.0f / 12.0f) + 1, 24, 24, 31, 0, 0);
|
drawBox((int)((float)x * 320.0f / 12.0f) + 1, (int)(78.0f + (float)y * 320.0f / 12.0f) + 1, 24, 24, 31, 0, 0);
|
||||||
|
|
||||||
// Backspace
|
// Backspace
|
||||||
if(chars[x + y * 12] == '\x08') {
|
if(chars[x + y * 12] == '\x08') {
|
||||||
drawString((int)((float)x * 320.0f / 12.0f) + 10, (int)(78.0f + (float)y * 320.0f / 12.0f) + 9, "-");
|
drawString((int)((float)x * 320.0f / 12.0f) + 10, (int)(78.0f + (float)y * 320.0f / 12.0f) + 9, "-");
|
||||||
drawString((int)((float)x * 320.0f / 12.0f) + 8, (int)(78.0f + (float)y * 320.0f / 12.0f) + 9, "<");
|
drawString((int)((float)x * 320.0f / 12.0f) + 8, (int)(78.0f + (float)y * 320.0f / 12.0f) + 9, "<");
|
||||||
}
|
}
|
||||||
else drawString((int)((float)x * 320.0f / 12.0f) + 9, (int)(78.0f + (float)y * 320.0f / 12.0f) + 9, "%c", chars[x + y * 12]);
|
else drawString((int)((float)x * 320.0f / 12.0f) + 9, (int)(78.0f + (float)y * 320.0f / 12.0f) + 9, "%c", chars[x + y * 12]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Space
|
// Space
|
||||||
drawBox((int)((float)3 * 320.0f / 12.0f), (int)(78.0f + (float)4 * 320.0f / 12.0f), (int)(5.0f * 320.0f / 12.0f), 25, 31, 31, 31);
|
drawBox((int)((float)3 * 320.0f / 12.0f), (int)(78.0f + (float)4 * 320.0f / 12.0f), (int)(5.0f * 320.0f / 12.0f), 25, 31, 31, 31);
|
||||||
drawBox((int)((float)3 * 320.0f / 12.0f) + 1, (int)(78.0f + (float)4 * 320.0f / 12.0f) + 1, (int)(5.0f * 320.0f / 12.0f) - 1, 24, 31, 0, 0);
|
drawBox((int)((float)3 * 320.0f / 12.0f) + 1, (int)(78.0f + (float)4 * 320.0f / 12.0f) + 1, (int)(5.0f * 320.0f / 12.0f) - 1, 24, 31, 0, 0);
|
||||||
|
|
||||||
// Enter
|
// Enter
|
||||||
drawBox((int)((float)10 * 320.0f / 12.0f), (int)(78.0f + (float)1 * 320.0f / 12.0f), (int)(2.0f * 320.0f / 12.0f), (int)(3.0f * 320.0f / 12.0f), 31, 31, 31);
|
drawBox((int)((float)10 * 320.0f / 12.0f), (int)(78.0f + (float)1 * 320.0f / 12.0f), (int)(2.0f * 320.0f / 12.0f), (int)(3.0f * 320.0f / 12.0f), 31, 31, 31);
|
||||||
drawBox((int)((float)10 * 320.0f / 12.0f) + 1, (int)(78.0f + (float)1 * 320.0f / 12.0f) + 1, (int)(2.0f * 320.0f / 12.0f) - 1, (int)(3.0f * 320.0f / 12.0f) - 1, 31, 0, 0);
|
drawBox((int)((float)10 * 320.0f / 12.0f) + 1, (int)(78.0f + (float)1 * 320.0f / 12.0f) + 1, (int)(2.0f * 320.0f / 12.0f) - 1, (int)(3.0f * 320.0f / 12.0f) - 1, 31, 0, 0);
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
213
source/main.c
213
source/main.c
|
@ -1,13 +1,12 @@
|
||||||
|
#include <3ds.h>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <3ds.h>
|
|
||||||
#include "3ds/services/gsplcd.h"
|
#include "3ds/services/gsplcd.h"
|
||||||
#include "3ds/services/hid.h"
|
#include "3ds/services/hid.h"
|
||||||
#include "3ds/services/soc.h"
|
#include "3ds/services/soc.h"
|
||||||
|
|
||||||
#include "drawing.h"
|
#include "drawing.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
// #include "keyboard.h"
|
// #include "keyboard.h"
|
||||||
|
@ -17,129 +16,129 @@
|
||||||
static jmp_buf exitJmp;
|
static jmp_buf exitJmp;
|
||||||
|
|
||||||
void hang(char *message) {
|
void hang(char *message) {
|
||||||
while (aptMainLoop()) {
|
while (aptMainLoop()) {
|
||||||
hidScanInput();
|
hidScanInput();
|
||||||
|
|
||||||
clearScreen();
|
clearScreen();
|
||||||
drawString(10, 10, "%s", message);
|
drawString(10, 10, "%s", message);
|
||||||
drawString(10, 20, "Start and Select to exit");
|
drawString(10, 20, "Start and Select to exit");
|
||||||
|
|
||||||
u32 kHeld = hidKeysHeld();
|
u32 kHeld = hidKeysHeld();
|
||||||
if ((kHeld & KEY_START) && (kHeld & KEY_SELECT))
|
if ((kHeld & KEY_START) && (kHeld & KEY_SELECT))
|
||||||
longjmp(exitJmp, 1);
|
longjmp(exitJmp, 1);
|
||||||
|
|
||||||
gfxFlushBuffers();
|
gfxFlushBuffers();
|
||||||
gspWaitForVBlank();
|
gspWaitForVBlank();
|
||||||
gfxSwapBuffers();
|
gfxSwapBuffers();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
acInit();
|
acInit();
|
||||||
gfxInitDefault();
|
gfxInitDefault();
|
||||||
|
|
||||||
gfxSetDoubleBuffering(GFX_TOP, true);
|
gfxSetDoubleBuffering(GFX_TOP, true);
|
||||||
gfxSetDoubleBuffering(GFX_BOTTOM, true);
|
gfxSetDoubleBuffering(GFX_BOTTOM, true);
|
||||||
|
|
||||||
if (setjmp(exitJmp))
|
if (setjmp(exitJmp))
|
||||||
goto exit;
|
goto exit;
|
||||||
|
|
||||||
// preRenderKeyboard();
|
// preRenderKeyboard();
|
||||||
|
|
||||||
// clearScreen();
|
// clearScreen();
|
||||||
drawString(10, 10, "Initing FS...");
|
drawString(10, 10, "Initing FS...");
|
||||||
gfxFlushBuffers();
|
gfxFlushBuffers();
|
||||||
gfxSwapBuffers();
|
gfxSwapBuffers();
|
||||||
|
|
||||||
fsInit();
|
fsInit();
|
||||||
|
|
||||||
// clearScreen();
|
// clearScreen();
|
||||||
drawString(10, 10, "Initing SOC...");
|
drawString(10, 10, "Initing SOC...");
|
||||||
gfxFlushBuffers();
|
gfxFlushBuffers();
|
||||||
gfxSwapBuffers();
|
gfxSwapBuffers();
|
||||||
|
|
||||||
socInit((u32 *)memalign(0x1000, 0x100000), 0x100000);
|
socInit((u32 *)memalign(0x1000, 0x100000), 0x100000);
|
||||||
|
|
||||||
u32 wifiStatus = 0;
|
u32 wifiStatus = 0;
|
||||||
ACU_GetWifiStatus(&wifiStatus);
|
ACU_GetWifiStatus(&wifiStatus);
|
||||||
if (!wifiStatus) {
|
if (!wifiStatus) {
|
||||||
hang("No WiFi! Is your wireless slider on?");
|
hang("No WiFi! Is your wireless slider on?");
|
||||||
}
|
|
||||||
|
|
||||||
clearScreen();
|
|
||||||
drawString(10, 10, "Reading settings...");
|
|
||||||
gfxFlushBuffers();
|
|
||||||
gfxSwapBuffers();
|
|
||||||
|
|
||||||
if (!readSettings()) {
|
|
||||||
hang("Could not read 3DSController.ini!");
|
|
||||||
}
|
|
||||||
|
|
||||||
clearScreen();
|
|
||||||
drawString(10, 10, "Connecting to %s on port %d...", settings.IPString,
|
|
||||||
settings.port);
|
|
||||||
gfxFlushBuffers();
|
|
||||||
gfxSwapBuffers();
|
|
||||||
|
|
||||||
openSocket(settings.port);
|
|
||||||
sendConnectionRequest();
|
|
||||||
|
|
||||||
// clearScreen();
|
|
||||||
drawString(10, 10, "Sending data to %s on port %d...", settings.IPString,
|
|
||||||
settings.port);
|
|
||||||
gfxFlushBuffers();
|
|
||||||
gfxSwapBuffers();
|
|
||||||
|
|
||||||
GSPLCD_PowerOffAllBacklights();
|
|
||||||
|
|
||||||
while (aptMainLoop()) {
|
|
||||||
hidScanInput();
|
|
||||||
irrstScanInput();
|
|
||||||
|
|
||||||
u32 kHeld = hidKeysHeld();
|
|
||||||
circlePosition circlePad;
|
|
||||||
circlePosition cStick;
|
|
||||||
angularRate gyro;
|
|
||||||
accelVector accel;
|
|
||||||
u8 vol8;
|
|
||||||
u8 *volPointer = &vol8; // As a test for pointing at things.
|
|
||||||
// u8 threeD;
|
|
||||||
// u8 *threeDPointer = &threeD;
|
|
||||||
hidCstickRead(&cStick);
|
|
||||||
hidCircleRead(&circlePad);
|
|
||||||
HIDUSER_EnableGyroscope();
|
|
||||||
hidGyroRead(&gyro);
|
|
||||||
HIDUSER_EnableAccelerometer();
|
|
||||||
hidAccelRead(&accel);
|
|
||||||
HIDUSER_GetSoundVolume(volPointer);
|
|
||||||
// MCUHWC_GetSoundSliderLevel(threeDPointer);
|
|
||||||
u32 volume = (u32)vol8; // Upscale to 32 for transmission
|
|
||||||
// u32 threeD32 = (u32)threeD;
|
|
||||||
touchPosition touch;
|
|
||||||
touchRead(&touch);
|
|
||||||
|
|
||||||
clearScreen();
|
|
||||||
|
|
||||||
sendKeys(kHeld, circlePad, touch, cStick, volume, gyro, accel);
|
|
||||||
// drawString(10, 10, "Volume: %x", volume);
|
|
||||||
// receiveBuffer(sizeof(struct packet));
|
|
||||||
|
|
||||||
if ((kHeld & KEY_START) && (kHeld & KEY_SELECT)) {
|
|
||||||
sendKeys(0, circlePad, touch, cStick, volume, gyro, accel);
|
|
||||||
longjmp(exitJmp, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clearScreen();
|
||||||
|
drawString(10, 10, "Reading settings...");
|
||||||
gfxFlushBuffers();
|
gfxFlushBuffers();
|
||||||
gspWaitForVBlank();
|
|
||||||
gfxSwapBuffers();
|
gfxSwapBuffers();
|
||||||
}
|
|
||||||
|
if (!readSettings()) {
|
||||||
|
hang("Could not read 3DSController.ini!");
|
||||||
|
}
|
||||||
|
|
||||||
|
clearScreen();
|
||||||
|
drawString(10, 10, "Connecting to %s on port %d...", settings.IPString,
|
||||||
|
settings.port);
|
||||||
|
gfxFlushBuffers();
|
||||||
|
gfxSwapBuffers();
|
||||||
|
|
||||||
|
openSocket(settings.port);
|
||||||
|
sendConnectionRequest();
|
||||||
|
|
||||||
|
// clearScreen();
|
||||||
|
drawString(10, 10, "Sending data to %s on port %d...", settings.IPString,
|
||||||
|
settings.port);
|
||||||
|
gfxFlushBuffers();
|
||||||
|
gfxSwapBuffers();
|
||||||
|
|
||||||
|
GSPLCD_PowerOffAllBacklights();
|
||||||
|
|
||||||
|
while (aptMainLoop()) {
|
||||||
|
hidScanInput();
|
||||||
|
irrstScanInput();
|
||||||
|
|
||||||
|
u32 kHeld = hidKeysHeld();
|
||||||
|
circlePosition circlePad;
|
||||||
|
circlePosition cStick;
|
||||||
|
angularRate gyro;
|
||||||
|
accelVector accel;
|
||||||
|
u8 vol8;
|
||||||
|
u8 *volPointer = &vol8; // As a test for pointing at things.
|
||||||
|
// u8 threeD;
|
||||||
|
// u8 *threeDPointer = &threeD;
|
||||||
|
hidCstickRead(&cStick);
|
||||||
|
hidCircleRead(&circlePad);
|
||||||
|
HIDUSER_EnableGyroscope();
|
||||||
|
hidGyroRead(&gyro);
|
||||||
|
HIDUSER_EnableAccelerometer();
|
||||||
|
hidAccelRead(&accel);
|
||||||
|
HIDUSER_GetSoundVolume(volPointer);
|
||||||
|
// MCUHWC_GetSoundSliderLevel(threeDPointer);
|
||||||
|
u32 volume = (u32)vol8; // Upscale to 32 for transmission
|
||||||
|
// u32 threeD32 = (u32)threeD;
|
||||||
|
touchPosition touch;
|
||||||
|
touchRead(&touch);
|
||||||
|
|
||||||
|
clearScreen();
|
||||||
|
|
||||||
|
sendKeys(kHeld, circlePad, touch, cStick, volume, gyro, accel);
|
||||||
|
// drawString(10, 10, "Volume: %x", volume);
|
||||||
|
// receiveBuffer(sizeof(struct packet));
|
||||||
|
|
||||||
|
if ((kHeld & KEY_START) && (kHeld & KEY_SELECT)) {
|
||||||
|
sendKeys(0, circlePad, touch, cStick, volume, gyro, accel);
|
||||||
|
longjmp(exitJmp, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
gfxFlushBuffers();
|
||||||
|
gspWaitForVBlank();
|
||||||
|
gfxSwapBuffers();
|
||||||
|
}
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
GSPLCD_PowerOnAllBacklights();
|
GSPLCD_PowerOnAllBacklights();
|
||||||
socExit();
|
socExit();
|
||||||
svcCloseHandle(fileHandle);
|
svcCloseHandle(fileHandle);
|
||||||
fsExit();
|
fsExit();
|
||||||
gfxExit();
|
gfxExit();
|
||||||
acExit();
|
acExit();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,84 +1,82 @@
|
||||||
#include <stdio.h>
|
#include "settings.h"
|
||||||
#include <malloc.h>
|
|
||||||
|
|
||||||
#include <3ds.h>
|
#include <3ds.h>
|
||||||
|
#include <malloc.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "3ds/services/fs.h"
|
#include "3ds/services/fs.h"
|
||||||
#include "wireless.h"
|
#include "wireless.h"
|
||||||
|
|
||||||
#include "settings.h"
|
|
||||||
|
|
||||||
struct settings settings;
|
struct settings settings;
|
||||||
|
|
||||||
struct settings defaultSettings = {
|
struct settings defaultSettings = {
|
||||||
.IPString = "",
|
.IPString = "",
|
||||||
.port= DEFAULT_PORT,
|
.port = DEFAULT_PORT,
|
||||||
};
|
};
|
||||||
|
|
||||||
Handle fileHandle;
|
Handle fileHandle;
|
||||||
|
|
||||||
static bool getSetting(char *name, char *src, char *dest) {
|
static bool getSetting(char *name, char *src, char *dest) {
|
||||||
char *start = strstr(src, name);
|
char *start = strstr(src, name);
|
||||||
|
|
||||||
if(start) {
|
if (start) {
|
||||||
start += strlen(name);
|
start += strlen(name);
|
||||||
|
|
||||||
char *end = start + strlen(start);
|
char *end = start + strlen(start);
|
||||||
if(strstr(start, "\n") - 1 < end) end = strstr(start, "\n") - 1;
|
if (strstr(start, "\n") - 1 < end) end = strstr(start, "\n") - 1;
|
||||||
size_t size = (size_t)end - (size_t)start;
|
size_t size = (size_t)end - (size_t)start;
|
||||||
|
|
||||||
strncpy(dest, start, size);
|
strncpy(dest, start, size);
|
||||||
dest[size] = '\0';
|
dest[size] = '\0';
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool readSettings(void) {
|
bool readSettings(void) {
|
||||||
char *buffer = NULL;
|
char *buffer = NULL;
|
||||||
u64 size;
|
u64 size;
|
||||||
u32 bytesRead;
|
u32 bytesRead;
|
||||||
|
|
||||||
FS_ArchiveID sdmcArchiveID = (ARCHIVE_SDMC);
|
FS_ArchiveID sdmcArchiveID = (ARCHIVE_SDMC);
|
||||||
// FS_Archive sdmcArchive = (FS_Archive){ARCHIVE_SDMC, (FS_Path){PATH_EMPTY, 1, (u8*)""}};
|
// FS_Archive sdmcArchive = (FS_Archive){ARCHIVE_SDMC, (FS_Path){PATH_EMPTY, 1, (u8*)""}};
|
||||||
FS_Path fileArchive = fsMakePath(PATH_EMPTY, NULL);
|
FS_Path fileArchive = fsMakePath(PATH_EMPTY, NULL);
|
||||||
FS_Path filePath = fsMakePath(PATH_ASCII, "/3DSController.ini");
|
FS_Path filePath = fsMakePath(PATH_ASCII, "/3DSController.ini");
|
||||||
|
|
||||||
Result ret = FSUSER_OpenFileDirectly(&fileHandle, sdmcArchiveID, fileArchive, filePath, FS_OPEN_READ, FS_ATTRIBUTE_HIDDEN);
|
Result ret = FSUSER_OpenFileDirectly(&fileHandle, sdmcArchiveID, fileArchive, filePath, FS_OPEN_READ, FS_ATTRIBUTE_HIDDEN);
|
||||||
if(ret) return false;
|
if (ret) return false;
|
||||||
|
|
||||||
ret = FSFILE_GetSize(fileHandle, &size);
|
ret = FSFILE_GetSize(fileHandle, &size);
|
||||||
if(ret) return false;
|
if (ret) return false;
|
||||||
|
|
||||||
buffer = malloc(size);
|
buffer = malloc(size);
|
||||||
if(!buffer) return false;
|
if (!buffer) return false;
|
||||||
|
|
||||||
ret = FSFILE_Read(fileHandle, &bytesRead, 0x0, buffer, size);
|
ret = FSFILE_Read(fileHandle, &bytesRead, 0x0, buffer, size);
|
||||||
if(ret || size != bytesRead) return false;
|
if (ret || size != bytesRead) return false;
|
||||||
|
|
||||||
ret = FSFILE_Close(fileHandle);
|
ret = FSFILE_Close(fileHandle);
|
||||||
if(ret) return false;
|
if (ret) return false;
|
||||||
|
|
||||||
memcpy(&settings, &defaultSettings, sizeof(struct settings));
|
memcpy(&settings, &defaultSettings, sizeof(struct settings));
|
||||||
|
|
||||||
char setting[64] = { '\0' };
|
char setting[64] = {'\0'};
|
||||||
|
|
||||||
if(getSetting("IP: ", buffer, settings.IPString)) {
|
if (getSetting("IP: ", buffer, settings.IPString)) {
|
||||||
//inet_pton(AF_INET, settings.IPString, &(saout.sin_addr));
|
// inet_pton(AF_INET, settings.IPString, &(saout.sin_addr));
|
||||||
inet_pton4(settings.IPString, (unsigned char *)&(saout.sin_addr));
|
inet_pton4(settings.IPString, (unsigned char *)&(saout.sin_addr));
|
||||||
}
|
} else {
|
||||||
else {
|
free(buffer);
|
||||||
free(buffer);
|
return false;
|
||||||
return false;
|
}
|
||||||
}
|
|
||||||
|
if (getSetting("Port: ", buffer, setting)) {
|
||||||
if(getSetting("Port: ", buffer, setting)) {
|
sscanf(setting, "%d", &settings.port);
|
||||||
sscanf(setting, "%d", &settings.port);
|
}
|
||||||
}
|
|
||||||
|
free(buffer);
|
||||||
free(buffer);
|
|
||||||
|
return true;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
|
#include "wireless.h"
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "keyboard.h"
|
#include "keyboard.h"
|
||||||
#include "sys/_types.h"
|
#include "sys/_types.h"
|
||||||
#include "wireless.h"
|
|
||||||
|
|
||||||
int sock;
|
int sock;
|
||||||
struct sockaddr_in sain, saout;
|
struct sockaddr_in sain, saout;
|
||||||
|
@ -11,50 +13,50 @@ struct packet outBuf, rcvBuf;
|
||||||
socklen_t sockaddr_in_sizePtr = (int)sizeof(struct sockaddr_in);
|
socklen_t sockaddr_in_sizePtr = (int)sizeof(struct sockaddr_in);
|
||||||
|
|
||||||
bool openSocket(int port) {
|
bool openSocket(int port) {
|
||||||
sock = socket(AF_INET, SOCK_DGRAM, 0);
|
sock = socket(AF_INET, SOCK_DGRAM, 0);
|
||||||
|
|
||||||
saout.sin_family = sain.sin_family = AF_INET;
|
saout.sin_family = sain.sin_family = AF_INET;
|
||||||
saout.sin_port = sain.sin_port = htons(port);
|
saout.sin_port = sain.sin_port = htons(port);
|
||||||
sain.sin_addr.s_addr = INADDR_ANY;
|
sain.sin_addr.s_addr = INADDR_ANY;
|
||||||
|
|
||||||
bind(sock, (struct sockaddr *)&sain, sizeof(sain));
|
bind(sock, (struct sockaddr *)&sain, sizeof(sain));
|
||||||
|
|
||||||
fcntl(sock, F_SETFL, O_NONBLOCK);
|
fcntl(sock, F_SETFL, O_NONBLOCK);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void sendBuf(int length) {
|
void sendBuf(int length) {
|
||||||
sendto(sock, (char *)&outBuf, length, 0, (struct sockaddr *)&saout,
|
sendto(sock, (char *)&outBuf, length, 0, (struct sockaddr *)&saout,
|
||||||
sizeof(saout));
|
sizeof(saout));
|
||||||
}
|
}
|
||||||
|
|
||||||
int receiveBuffer(int length) {
|
int receiveBuffer(int length) {
|
||||||
return recvfrom(sock, (char *)&rcvBuf, length, 0, (struct sockaddr *)&sain,
|
return recvfrom(sock, (char *)&rcvBuf, length, 0, (struct sockaddr *)&sain,
|
||||||
&sockaddr_in_sizePtr);
|
&sockaddr_in_sizePtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void sendConnectionRequest(void) {
|
void sendConnectionRequest(void) {
|
||||||
outBuf.command = CONNECT;
|
outBuf.command = CONNECT;
|
||||||
outBuf.keyboardActive = keyboardActive;
|
outBuf.keyboardActive = keyboardActive;
|
||||||
sendBuf(offsetof(struct packet, connectPacket) +
|
sendBuf(offsetof(struct packet, connectPacket) +
|
||||||
sizeof(struct connectPacket));
|
sizeof(struct connectPacket));
|
||||||
}
|
}
|
||||||
|
|
||||||
void sendKeys(unsigned int keys, circlePosition circlePad, touchPosition touch,
|
void sendKeys(unsigned int keys, circlePosition circlePad, touchPosition touch,
|
||||||
circlePosition cStick, unsigned int volume,
|
circlePosition cStick, unsigned int volume,
|
||||||
angularRate gyro, accelVector accel) {
|
angularRate gyro, accelVector accel) {
|
||||||
outBuf.command = KEYS;
|
outBuf.command = KEYS;
|
||||||
outBuf.keyboardActive = keyboardActive;
|
outBuf.keyboardActive = keyboardActive;
|
||||||
memcpy(&outBuf.keys, &keys, 4);
|
memcpy(&outBuf.keys, &keys, 4);
|
||||||
memcpy(&outBuf.circlePad, &circlePad, 4);
|
memcpy(&outBuf.circlePad, &circlePad, 4);
|
||||||
memcpy(&outBuf.touch, &touch, 4);
|
memcpy(&outBuf.touch, &touch, 4);
|
||||||
memcpy(&outBuf.cStick, &cStick, 4);
|
memcpy(&outBuf.cStick, &cStick, 4);
|
||||||
memcpy(&outBuf.volume, &volume, 4);
|
memcpy(&outBuf.volume, &volume, 4);
|
||||||
memcpy(&outBuf.gyro, &gyro, 6);
|
memcpy(&outBuf.gyro, &gyro, 6);
|
||||||
// Padding to separate gyro from accel, making it less confusing when parsing the data
|
// Padding to separate gyro from accel, making it less confusing when parsing the data
|
||||||
outBuf.padding = 0;
|
outBuf.padding = 0;
|
||||||
memcpy(&outBuf.accel, &accel, 6);
|
memcpy(&outBuf.accel, &accel, 6);
|
||||||
// memcpy(&outBuf.threeD32, &threeD32, 4);
|
// memcpy(&outBuf.threeD32, &threeD32, 4);
|
||||||
sendBuf(offsetof(struct packet, keysPacket) + sizeof(struct keysPacket));
|
sendBuf(offsetof(struct packet, keysPacket) + sizeof(struct keysPacket));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue