Initial n3ds
First commit, the bulk of the changes. ZL and ZR work, but neither cStick nor circlePad work. So something's broken.
This commit is contained in:
parent
da319963b6
commit
e4aee2a977
11 changed files with 62 additions and 8 deletions
|
@ -54,6 +54,11 @@ struct packet {
|
|||
unsigned short x;
|
||||
unsigned short y;
|
||||
} touch;
|
||||
|
||||
struct {
|
||||
short x;
|
||||
short y;
|
||||
} cStick;
|
||||
};
|
||||
struct keysPacket keysPacket;
|
||||
};
|
||||
|
@ -79,4 +84,4 @@ bool openSocket(int port);
|
|||
void sendBuf(int length);
|
||||
int receiveBuffer(int length);
|
||||
void sendConnectionRequest(void);
|
||||
void sendKeys(unsigned int keys, circlePosition circlePad, touchPosition touch);
|
||||
void sendKeys(unsigned int keys, circlePosition circlePad, touchPosition touch, circlePosition cStick);
|
||||
|
|
|
@ -87,12 +87,14 @@ int main(void) {
|
|||
|
||||
while(aptMainLoop()) {
|
||||
hidScanInput();
|
||||
//irrstScanInput();
|
||||
irrstScanInput();
|
||||
|
||||
u32 kHeld = hidKeysHeld();
|
||||
|
||||
circlePosition circlePad;
|
||||
//hidCstickRead(&cstick);
|
||||
circlePosition cStick;
|
||||
hidCircleRead(&circlePad);
|
||||
irrstCstickRead(&cStick);
|
||||
touchPosition touch;
|
||||
touchRead(&touch);
|
||||
|
||||
|
@ -133,7 +135,7 @@ int main(void) {
|
|||
}
|
||||
}
|
||||
|
||||
sendKeys(kHeld, circlePad, touch);
|
||||
sendKeys(kHeld, circlePad, touch, cStick);
|
||||
|
||||
receiveBuffer(sizeof(struct packet));
|
||||
|
||||
|
|
|
@ -38,11 +38,12 @@ void sendConnectionRequest(void) {
|
|||
sendBuf(offsetof(struct packet, connectPacket) + sizeof(struct connectPacket));
|
||||
}
|
||||
|
||||
void sendKeys(unsigned int keys, circlePosition circlePad, touchPosition touch) {
|
||||
void sendKeys(unsigned int keys, circlePosition circlePad, touchPosition touch, circlePosition cStick) {
|
||||
outBuf.command = KEYS;
|
||||
outBuf.keyboardActive = keyboardActive;
|
||||
memcpy(&outBuf.keys, &keys, 4);
|
||||
memcpy(&outBuf.circlePad, &circlePad, 4);
|
||||
memcpy(&outBuf.touch, &touch, 4);
|
||||
memcpy(&outBuf.cStick, &cStick, 4);
|
||||
sendBuf(offsetof(struct packet, keysPacket) + sizeof(struct keysPacket));
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ Make sure to use a single space, not a tab for seperating settings,
|
|||
Port: 8889
|
||||
Throttle: 20
|
||||
Circle Pad: JOYSTICK
|
||||
C Stick: JOYSTICK
|
||||
Touch: MOUSE
|
||||
Mouse Speed: 0
|
||||
A: A
|
||||
|
@ -26,6 +27,8 @@ X: X
|
|||
Y: Y
|
||||
L: L
|
||||
R: R
|
||||
ZL: Q
|
||||
ZR: W
|
||||
Left: LEFT
|
||||
Right: RIGHT
|
||||
Up: UP
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
|
||||
#define joyX iReport.wAxisX
|
||||
#define joyY iReport.wAxisY
|
||||
#define joyRX iReport.wAxisXRot
|
||||
#define joyRY iReport.wAxisYRot
|
||||
#define joyButtons iReport.lButtons
|
||||
|
||||
#define JOY_MIDDLE (128 * 128)
|
||||
|
|
|
@ -78,6 +78,11 @@ struct circlePad {
|
|||
short y;
|
||||
};
|
||||
|
||||
struct cStick {
|
||||
short x;
|
||||
short y;
|
||||
};
|
||||
|
||||
struct touch {
|
||||
short x;
|
||||
short y;
|
||||
|
@ -87,6 +92,7 @@ extern unsigned int lastKeys;
|
|||
extern unsigned int currentKeys;
|
||||
|
||||
extern struct circlePad circlePad;
|
||||
extern struct cStick cStick;
|
||||
extern struct touch lastTouch;
|
||||
extern struct touch currentTouch;
|
||||
|
||||
|
|
|
@ -13,9 +13,10 @@ struct settings {
|
|||
int port;
|
||||
int throttle;
|
||||
enum analogue circlePad;
|
||||
enum analogue cStick;
|
||||
enum analogue touch;
|
||||
int mouseSpeed;
|
||||
struct keyMapping A, B, X, Y, L, R, Left, Right, Up, Down, Start, Select, Tap;
|
||||
struct keyMapping A, B, X, Y, L, R, ZL, ZR, Left, Right, Up, Down, Start, Select, Tap;
|
||||
};
|
||||
|
||||
extern struct settings settings;
|
||||
|
|
|
@ -46,6 +46,11 @@ struct packet {
|
|||
unsigned short x;
|
||||
unsigned short y;
|
||||
} touch;
|
||||
|
||||
struct {
|
||||
short x;
|
||||
short y;
|
||||
} cStick;
|
||||
};
|
||||
struct keysPacket keysPacket;
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ unsigned int lastKeys;
|
|||
unsigned int currentKeys;
|
||||
|
||||
struct circlePad circlePad;
|
||||
struct cStick cStick;
|
||||
struct touch lastTouch;
|
||||
struct touch currentTouch;
|
||||
|
||||
|
|
|
@ -29,8 +29,8 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmd, int nShow)
|
|||
UINT iInterface = 1;
|
||||
|
||||
iReport.wAxisZ = JOY_MIDDLE;
|
||||
iReport.wAxisXRot = JOY_MIDDLE;
|
||||
iReport.wAxisYRot = JOY_MIDDLE;
|
||||
//iReport.wAxisXRot = JOY_MIDDLE; Using these for c stick. Likely reported as axes 4 and 5, skipping 3 as z? Not sure if that's ideal?
|
||||
//iReport.wAxisYRot = JOY_MIDDLE; Makes most sense in vJoy though.
|
||||
iReport.wAxisZRot = JOY_MIDDLE;
|
||||
iReport.wSlider = JOY_MIDDLE;
|
||||
iReport.lButtons = 0;
|
||||
|
@ -93,6 +93,8 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmd, int nShow)
|
|||
lastTouch.y = 0;
|
||||
currentTouch.x = 0;
|
||||
currentTouch.y = 0;
|
||||
cStick.x = 0;
|
||||
cStick.y = 0;
|
||||
|
||||
buffer.command = CONNECT;
|
||||
printf("3DS Connected!\n");
|
||||
|
@ -114,6 +116,7 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmd, int nShow)
|
|||
memcpy(¤tKeys, &buffer.keys, 4);
|
||||
memcpy(&circlePad, &buffer.circlePad, 4);
|
||||
memcpy(¤tTouch, &buffer.touch, 4);
|
||||
memcpy(&cStick, &buffer.cStick, 4);
|
||||
|
||||
handleKey(KEY_A, settings.A);
|
||||
handleKey(KEY_B, settings.B);
|
||||
|
@ -125,6 +128,8 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmd, int nShow)
|
|||
handleKey(KEY_DDOWN, settings.Down);
|
||||
handleKey(KEY_R, settings.R);
|
||||
handleKey(KEY_L, settings.L);
|
||||
handleKey(KEY_ZR, settings.ZR);
|
||||
handleKey(KEY_ZL, settings.ZL);
|
||||
handleKey(KEY_X, settings.X);
|
||||
handleKey(KEY_Y, settings.Y);
|
||||
|
||||
|
@ -177,6 +182,19 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmd, int nShow)
|
|||
joyY = (128 - circlePad.y) * 128;
|
||||
}
|
||||
|
||||
if(settings.cStick == mouse) {
|
||||
if(abs(cStick.x) < settings.mouseSpeed * 3) cStick.x = 0;
|
||||
if(abs(cStick.y) < settings.mouseSpeed * 3) cStick.y = 0;
|
||||
|
||||
POINT p;
|
||||
GetCursorPos(&p);
|
||||
SetCursorPos(p.x + (cStick.x * settings.mouseSpeed) / 32, p.y - (cStick.y * settings.mouseSpeed) / 32);
|
||||
}
|
||||
else if(settings.cStick == joystick) {
|
||||
joyRX = (cStick.x + 128) * 128;
|
||||
joyRY = (128 - cStick.y) * 128;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ struct settings defaultSettings = {
|
|||
port: 8889,
|
||||
throttle: 20,
|
||||
circlePad: joystick,
|
||||
cStick: joystick,
|
||||
touch: mouse,
|
||||
mouseSpeed: 4,
|
||||
A: { 1, {'A'} },
|
||||
|
@ -21,6 +22,8 @@ struct settings defaultSettings = {
|
|||
Y: { 1, {'Y'} },
|
||||
L: { 1, {'L'} },
|
||||
R: { 1, {'R'} },
|
||||
ZL: { 1, {'Q'} },
|
||||
ZR: { 1, {'W'} },
|
||||
Left: { 1, {VK_LEFT} },
|
||||
Right: { 1, {VK_RIGHT} },
|
||||
Up: { 1, {VK_UP} },
|
||||
|
@ -121,6 +124,11 @@ bool readSettings(void) {
|
|||
else if(strcmp(setting, "JOYSTICK") == 0) settings.circlePad = joystick;
|
||||
}
|
||||
|
||||
if(getSetting("C Stick: ", buffer, setting)) {
|
||||
if(strcmp(setting, "MOUSE") == 0) settings.cStick = mouse;
|
||||
else if(strcmp(setting, "JOYSTICK") == 0) settings.cStick = joystick;
|
||||
}
|
||||
|
||||
if(getSetting("Touch: ", buffer, setting)) {
|
||||
if(strcmp(setting, "MOUSE") == 0) settings.touch = mouse;
|
||||
else if(strcmp(setting, "JOYSTICK") == 0) settings.touch = joystick;
|
||||
|
@ -136,6 +144,8 @@ bool readSettings(void) {
|
|||
if(getSetting("Y: ", buffer, setting)) settings.Y = getButton(setting);
|
||||
if(getSetting("L: ", buffer, setting)) settings.L = getButton(setting);
|
||||
if(getSetting("R: ", buffer, setting)) settings.R = getButton(setting);
|
||||
if(getSetting("ZL: ", buffer, setting)) settings.ZL = getButton(setting);
|
||||
if(getSetting("ZR: ", buffer, setting)) settings.ZR = getButton(setting);
|
||||
if(getSetting("Left: ", buffer, setting)) settings.Left = getButton(setting);
|
||||
if(getSetting("Right: ", buffer, setting)) settings.Right = getButton(setting);
|
||||
if(getSetting("Up: ", buffer, setting)) settings.Up = getButton(setting);
|
||||
|
|
Loading…
Reference in a new issue