Configurable dual joysticks

Added the ability to map mouse, circle pad and c stick to 2 separate
joysticks.
This was partly added before for c stick but now it's configurable.
This commit is contained in:
Poke 2015-09-06 11:56:53 +09:30
parent f2241d3e73
commit c84990d3dd
4 changed files with 36 additions and 16 deletions

View file

@ -1,6 +1,7 @@
Default port is 8889, if you change this, you must change it in the 3DS's 3DSController.ini as well, Default port is 8889, if you change this, you must change it in the 3DS's 3DSController.ini as well,
Circle Pad and Touch can be either JOYSTICK or MOUSE, Circle Pad, C Stick and Touch can be MOUSE, JOYSTICK1 or JOYSTICK2
JOYSTICK1 uses X and Y. JOYSTICK2 uses Rx and Ry. These are 0, 1, 3 and 4 respectively, leaving 2 and 5 unused which may cause confusion.
Mouse Speed controls how fast the Circle Pad or Touch Screen moves the mouse. If set to 0 and using the Touch Screen, it will set to the absolute position, rather than moving relatively to last position, Mouse Speed controls how fast the Circle Pad or Touch Screen moves the mouse. If set to 0 and using the Touch Screen, it will set to the absolute position, rather than moving relatively to last position,
@ -17,10 +18,11 @@ Make sure to use a single space, not a tab for seperating settings,
Port: 8889 Port: 8889
Throttle: 20 Throttle: 20
Circle Pad: JOYSTICK Circle Pad: JOYSTICK1
C Stick: JOYSTICK C Stick: JOYSTICK1
Touch: MOUSE Touch: JOYSTICK2
Mouse Speed: 0 Mouse Speed:
A: A A: A
B: B B: B
X: X X: X

View file

@ -6,7 +6,8 @@
enum analogue { enum analogue {
mouse, mouse,
joystick, joystick1,
joystick2,
}; };
struct settings { struct settings {

View file

@ -29,8 +29,6 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmd, int nShow)
UINT iInterface = 1; UINT iInterface = 1;
iReport.wAxisZ = JOY_MIDDLE; iReport.wAxisZ = 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.wAxisZRot = JOY_MIDDLE;
iReport.wSlider = JOY_MIDDLE; iReport.wSlider = JOY_MIDDLE;
iReport.lButtons = 0; iReport.lButtons = 0;
@ -160,10 +158,15 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmd, int nShow)
SetCursorPos((int)((double)currentTouch.x * widthMultiplier), (int)((double)currentTouch.y * heightMultiplier)); SetCursorPos((int)((double)currentTouch.x * widthMultiplier), (int)((double)currentTouch.y * heightMultiplier));
} }
} }
else if(settings.touch == joystick) { else if(settings.touch == joystick1) {
joyX = (currentTouch.x) * 128; joyX = (currentTouch.x) * 128;
joyY = (currentTouch.y) * 128; joyY = (currentTouch.y) * 128;
} }
else if(settings.touch == joystick2) {
joyRX = (currentTouch.x) * 128;
joyRY = (currentTouch.y) * 128;
}
else { else {
handleKey(KEY_TOUCH, settings.Tap); handleKey(KEY_TOUCH, settings.Tap);
} }
@ -177,11 +180,16 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmd, int nShow)
GetCursorPos(&p); GetCursorPos(&p);
SetCursorPos(p.x + (circlePad.x * settings.mouseSpeed) / 32, p.y - (circlePad.y * settings.mouseSpeed) / 32); SetCursorPos(p.x + (circlePad.x * settings.mouseSpeed) / 32, p.y - (circlePad.y * settings.mouseSpeed) / 32);
} }
else if(settings.circlePad == joystick) { else if(settings.circlePad == joystick1) {
joyX = (circlePad.x + 128) * 128; joyX = (circlePad.x + 128) * 128;
joyY = (128 - circlePad.y) * 128; joyY = (128 - circlePad.y) * 128;
} }
else if(settings.circlePad == joystick2) {
joyRX = (circlePad.x + 128) * 128;
joyRY = (128 - circlePad.y) * 128;
}
if(settings.cStick == mouse) { if(settings.cStick == mouse) {
if(abs(cStick.x) < settings.mouseSpeed * 3) cStick.x = 0; if(abs(cStick.x) < settings.mouseSpeed * 3) cStick.x = 0;
if(abs(cStick.y) < settings.mouseSpeed * 3) cStick.y = 0; if(abs(cStick.y) < settings.mouseSpeed * 3) cStick.y = 0;
@ -190,7 +198,13 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmd, int nShow)
GetCursorPos(&p); GetCursorPos(&p);
SetCursorPos(p.x + (cStick.x * settings.mouseSpeed) / 32, p.y - (cStick.y * settings.mouseSpeed) / 32); SetCursorPos(p.x + (cStick.x * settings.mouseSpeed) / 32, p.y - (cStick.y * settings.mouseSpeed) / 32);
} }
else if(settings.cStick == joystick) {
else if(settings.cStick == joystick1) {
joyX = (cStick.x + 128) * 128;
joyY = (128 - cStick.y) * 128;
}
else if(settings.cStick == joystick2) {
joyRX = (cStick.x + 128) * 128; joyRX = (cStick.x + 128) * 128;
joyRY = (128 - cStick.y) * 128; joyRY = (128 - cStick.y) * 128;
} }

View file

@ -12,8 +12,8 @@ struct settings settings;
struct settings defaultSettings = { struct settings defaultSettings = {
port: 8889, port: 8889,
throttle: 20, throttle: 20,
circlePad: joystick, circlePad: joystick1,
cStick: joystick, cStick: joystick2,
touch: mouse, touch: mouse,
mouseSpeed: 4, mouseSpeed: 4,
A: { 1, {'A'} }, A: { 1, {'A'} },
@ -121,17 +121,20 @@ bool readSettings(void) {
if(getSetting("Circle Pad: ", buffer, setting)) { if(getSetting("Circle Pad: ", buffer, setting)) {
if(strcmp(setting, "MOUSE") == 0) settings.circlePad = mouse; if(strcmp(setting, "MOUSE") == 0) settings.circlePad = mouse;
else if(strcmp(setting, "JOYSTICK") == 0) settings.circlePad = joystick; else if(strcmp(setting, "JOYSTICK1") == 0) settings.circlePad = joystick1;
else if(strcmp(setting, "JOYSTICK2") == 0) settings.circlePad = joystick2;
} }
if(getSetting("C Stick: ", buffer, setting)) { if(getSetting("C Stick: ", buffer, setting)) {
if(strcmp(setting, "MOUSE") == 0) settings.cStick = mouse; if(strcmp(setting, "MOUSE") == 0) settings.cStick = mouse;
else if(strcmp(setting, "JOYSTICK") == 0) settings.cStick = joystick; else if(strcmp(setting, "JOYSTICK1") == 0) settings.cStick = joystick1;
else if(strcmp(setting, "JOYSTICK2") == 0) settings.cStick = joystick2;
} }
if(getSetting("Touch: ", buffer, setting)) { if(getSetting("Touch: ", buffer, setting)) {
if(strcmp(setting, "MOUSE") == 0) settings.touch = mouse; if(strcmp(setting, "MOUSE") == 0) settings.touch = mouse;
else if(strcmp(setting, "JOYSTICK") == 0) settings.touch = joystick; else if(strcmp(setting, "JOYSTICK1") == 0) settings.touch = joystick1;
else if(strcmp(setting, "JOYSTICK2") == 0) settings.touch = joystick2;
} }
if(getSetting("Mouse Speed: ", buffer, setting)) { if(getSetting("Mouse Speed: ", buffer, setting)) {