diff --git a/PC/3DSController.ini b/PC/3DSController.ini index 747ac7f..2bb191b 100644 --- a/PC/3DSController.ini +++ b/PC/3DSController.ini @@ -1,11 +1,13 @@ Default port is 8889, if you change this, you must change it in the 3DS's 3DSController.ini as well, 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. +JOYSTICK1 uses X and Y. JOYSTICK2 uses Rx and Ry. These are 0, 1, 3 and 4 respectively, leaving 2 and 5 unused. 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, -Buttons can be a letter for a keyboard key (like Q, W, E, R, T, or Y), a special keyboard key (like SPACE, CLICK, RIGHT CLICK, ENTER, BACKSPACE, SHIFT, TAB, LEFT, RIGHT, UP, DOWN, PAGE UP, PAGE DOWN, or WINDOWS), or a joypad button (JOY1, JOY2, JOY3, to JOY8), +Buttons can be a letter for a keyboard key (like Q, W, E, R, T, or Y), a special keyboard key (like SPACE, CLICK, RIGHT CLICK, ENTER, BACKSPACE, SHIFT, TAB, LEFT, RIGHT, UP, DOWN, PAGE UP, PAGE DOWN, or WINDOWS), or a joypad button (JOY1, JOY2, JOY3, to JOY16). + +If you want to use JOY9 through JOY16 you need to reconfigure vJoy. Search for vJoyConf in your start menu and set buttons to 16. Alternatively, you can disable a key by binding it to NONE, diff --git a/PC/include/keys.h b/PC/include/keys.h index 790b645..f362629 100644 --- a/PC/include/keys.h +++ b/PC/include/keys.h @@ -21,14 +21,18 @@ #define release(key) (!(currentKeys & key) && (lastKeys & key)) #define handleKey(DSKey, PCKey) do {\ - if(PCKey.useKeyboard) {\ + if(!PCKey.useJoypad) {\ if(newpress(DSKey)) simulateKeyNewpress(PCKey.virtualKey);\ if(release(DSKey)) simulateKeyRelease(PCKey.virtualKey);\ }\ - else {\ + else if(PCKey.useJoypad == 1) {\ if(currentKeys & DSKey) joyButtons |= PCKey.joypadButton;\ else joyButtons &= ~PCKey.joypadButton;\ }\ + else if(PCKey.useJoypad == 2) {\ + if(currentKeys & DSKey) joyButtons |= PCKey.joypadButton << 8;\ + else joyButtons &= ~(PCKey.joypadButton << 8);\ + }\ } while(0) #define BIT(n) (1 << (n)) @@ -66,7 +70,7 @@ typedef enum { } KEYPAD_BITS; struct keyMapping { - unsigned char useKeyboard; // 0 joypad button, 1 keyboard key + unsigned char useJoypad; // 0 keyboard key, 1 joypad1-8, 2 joypad9-16 union { unsigned char virtualKey; unsigned char joypadButton; diff --git a/PC/source/main.c b/PC/source/main.c index 52568cb..f0b5378 100644 --- a/PC/source/main.c +++ b/PC/source/main.c @@ -28,9 +28,14 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmd, int nShow) bool vJoy = true; UINT iInterface = 1; + iReport.wAxisX = JOY_MIDDLE; + iReport.wAxisY = JOY_MIDDLE; iReport.wAxisZ = JOY_MIDDLE; + iReport.wAxisXRot = JOY_MIDDLE; + iReport.wAxisYRot = JOY_MIDDLE; iReport.wAxisZRot = JOY_MIDDLE; iReport.wSlider = JOY_MIDDLE; + iReport.wDial = JOY_MIDDLE; iReport.lButtons = 0; iReport.bHats = -1; @@ -59,6 +64,9 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmd, int nShow) initNetwork(); + char nButtons = GetVJDButtonNumber(iInterface); + if(nButtons <16) printf("Your vJoy has less than 16 buttons (8 by default), some may not work!\n"); + printf("Port: %d\n", settings.port); printf("Running on: %s\n", hostName); diff --git a/PC/source/settings.c b/PC/source/settings.c index e02ef43..1af66c3 100644 --- a/PC/source/settings.c +++ b/PC/source/settings.c @@ -55,6 +55,7 @@ static bool getSetting(char *name, char *src, char *dest) { static struct keyMapping getButton(char *string) { struct keyMapping k = { 1, {0} }; + k.useJoypad = 0; if(strcmp(string, "SPACE") == 0) k.virtualKey = VK_SPACE; else if(strcmp(string, "CLICK") == 0) k.virtualKey = VK_LBUTTON; else if(strcmp(string, "RIGHT CLICK") == 0) k.virtualKey = VK_RBUTTON; @@ -71,14 +72,22 @@ static struct keyMapping getButton(char *string) { else if(strcmp(string, "WINDOWS") == 0) k.virtualKey = VK_LWIN; else if(strcmp(string, "NONE") == 0) k.virtualKey = 0; - else if(strcmp(string, "JOY1") == 0) { k.useKeyboard = 0; k.joypadButton = 1 << 0; } - else if(strcmp(string, "JOY2") == 0) { k.useKeyboard = 0; k.joypadButton = 1 << 1; } - else if(strcmp(string, "JOY3") == 0) { k.useKeyboard = 0; k.joypadButton = 1 << 2; } - else if(strcmp(string, "JOY4") == 0) { k.useKeyboard = 0; k.joypadButton = 1 << 3; } - else if(strcmp(string, "JOY5") == 0) { k.useKeyboard = 0; k.joypadButton = 1 << 4; } - else if(strcmp(string, "JOY6") == 0) { k.useKeyboard = 0; k.joypadButton = 1 << 5; } - else if(strcmp(string, "JOY7") == 0) { k.useKeyboard = 0; k.joypadButton = 1 << 6; } - else if(strcmp(string, "JOY8") == 0) { k.useKeyboard = 0; k.joypadButton = 1 << 7; } + else if(strcmp(string, "JOY1") == 0) { k.useJoypad = 1; k.joypadButton = 1 << 0; } + else if(strcmp(string, "JOY2") == 0) { k.useJoypad = 1; k.joypadButton = 1 << 1; } + else if(strcmp(string, "JOY3") == 0) { k.useJoypad = 1; k.joypadButton = 1 << 2; } + else if(strcmp(string, "JOY4") == 0) { k.useJoypad = 1; k.joypadButton = 1 << 3; } + else if(strcmp(string, "JOY5") == 0) { k.useJoypad = 1; k.joypadButton = 1 << 4; } + else if(strcmp(string, "JOY6") == 0) { k.useJoypad = 1; k.joypadButton = 1 << 5; } + else if(strcmp(string, "JOY7") == 0) { k.useJoypad = 1; k.joypadButton = 1 << 6; } + else if(strcmp(string, "JOY8") == 0) { k.useJoypad = 1; k.joypadButton = 1 << 7; } + else if(strcmp(string, "JOY9") == 0) { k.useJoypad = 2; k.joypadButton = 1 << 0; } + else if(strcmp(string, "JOY10") == 0) { k.useJoypad = 2; k.joypadButton = 1 << 1; } + else if(strcmp(string, "JOY11") == 0) { k.useJoypad = 2; k.joypadButton = 1 << 2; } + else if(strcmp(string, "JOY12") == 0) { k.useJoypad = 2; k.joypadButton = 1 << 3; } + else if(strcmp(string, "JOY13") == 0) { k.useJoypad = 2; k.joypadButton = 1 << 4; } + else if(strcmp(string, "JOY14") == 0) { k.useJoypad = 2; k.joypadButton = 1 << 5; } + else if(strcmp(string, "JOY15") == 0) { k.useJoypad = 2; k.joypadButton = 1 << 6; } + else if(strcmp(string, "JOY16") == 0) { k.useJoypad = 2; k.joypadButton = 1 << 7; } else k.virtualKey = (int)string[0];