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,
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,
@ -17,10 +18,11 @@ 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
Circle Pad: JOYSTICK1
C Stick: JOYSTICK1
Touch: JOYSTICK2
Mouse Speed:
A: A
B: B
X: X

View File

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

View File

@ -29,8 +29,6 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmd, int nShow)
UINT iInterface = 1;
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.wSlider = JOY_MIDDLE;
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));
}
}
else if(settings.touch == joystick) {
else if(settings.touch == joystick1) {
joyX = (currentTouch.x) * 128;
joyY = (currentTouch.y) * 128;
}
else if(settings.touch == joystick2) {
joyRX = (currentTouch.x) * 128;
joyRY = (currentTouch.y) * 128;
}
else {
handleKey(KEY_TOUCH, settings.Tap);
}
@ -177,11 +180,16 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmd, int nShow)
GetCursorPos(&p);
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;
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(abs(cStick.x) < settings.mouseSpeed * 3) cStick.x = 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);
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;
joyRY = (128 - cStick.y) * 128;
}

View File

@ -12,8 +12,8 @@ struct settings settings;
struct settings defaultSettings = {
port: 8889,
throttle: 20,
circlePad: joystick,
cStick: joystick,
circlePad: joystick1,
cStick: joystick2,
touch: mouse,
mouseSpeed: 4,
A: { 1, {'A'} },
@ -121,17 +121,20 @@ bool readSettings(void) {
if(getSetting("Circle Pad: ", buffer, setting)) {
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(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(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)) {