Made vJoy Device configurabe

You can now choose which vJoy device to output to in the .ini, allowing
you to use multiple 3DS, each controlling their own virtual Joystick.
This commit is contained in:
Poke 2015-10-16 16:34:36 +10:30
parent 7e64fea254
commit 0684a4811e
6 changed files with 21 additions and 14 deletions

View File

@ -13,6 +13,8 @@ Alternatively, you can disable a key by binding it to NONE,
Throttle controls the delay between checking for new packets (in milliseconds), a high number will have slightly more lag between pressing a button on the 3DS and receiving it on the PC, however will make the application use less CPU. In my experience, 20 is a reasonable throttling amount,
vJoy Device chooses which device to connect to. Set this to 2 in a second instance of 3DSController to use a second 3DS at the same time, perhaps for multiplayer.
Make sure to use a single space, not a tab for seperating settings,
@ -24,6 +26,7 @@ Circle Pad: JOYSTICK1
C Stick: JOYSTICK2
Touch: MOUSE
Mouse Speed: 0
vJoy Device: 1
A: A
B: B

View File

@ -18,9 +18,8 @@
#define JOY_MIDDLE (128 * 128)
extern int ContPovNumber;
extern UINT iInterface;
//extern BOOL ContinuousPOV;
extern JOYSTICK_POSITION iReport;
BOOL updateJoystick(void);
BOOL updateJoystick(int);

View File

@ -17,6 +17,7 @@ struct settings {
enum analogue cStick;
enum analogue touch;
int mouseSpeed;
UINT vJoyDevice;
struct keyMapping A, B, X, Y, L, R, ZL, ZR, Left, Right, Up, Down, Start, Select, Tap;
};

View File

@ -4,12 +4,11 @@
#include "joystick.h"
int ContPovNumber;
UINT iInterface = 1;
//BOOL ContinuousPOV = FALSE;
JOYSTICK_POSITION iReport;
BOOL updateJoystick(void) {
BOOL updateJoystick(iInterface) {
BYTE id = (BYTE)iInterface;
iReport.bDevice = id;

View File

@ -22,8 +22,12 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmd, int nShow)
double widthMultiplier = screenWidth / 320.0;
double heightMultiplier = screenHeight / 240.0;
if(!readSettings()) {
printf("Couldn't read settings file, using default key bindings.\n");
}
bool vJoy = true;
UINT iInterface = 1;
UINT iInterface = settings.vJoyDevice;
iReport.wAxisX = JOY_MIDDLE;
iReport.wAxisY = JOY_MIDDLE;
@ -50,19 +54,15 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmd, int nShow)
ContPovNumber = GetVJDContPovNumber(iInterface);
//int DiscPovNumber = GetVJDDiscPovNumber(iInterface);
if(vJoy && !updateJoystick()) {
printf("vJoy failed (3)! Buttons will still work, but joystick won't work.\n");
if(vJoy && !updateJoystick(iInterface)) {
printf("vJoy failed (3)! Buttons will still work, but joystick won't work.\nIs vJoy device %d configured?\n",iInterface);
vJoy = false;
}
if(!readSettings()) {
printf("Couldn't read settings file, using default key bindings.\n");
}
} else printf("Connected to vJoy device %d\n",iInterface);
initNetwork();
char nButtons = GetVJDButtonNumber(iInterface);
if(nButtons <16) printf("Your vJoy has %d buttons, 3DSController supports 16!\n", nButtons);
if(vJoy && nButtons <16) printf("Your vJoy has %d buttons, 3DSController supports 16!\n", nButtons);
printf("Port: %d\n", settings.port);
@ -217,7 +217,7 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmd, int nShow)
break;
}
if(vJoy) updateJoystick();
if(vJoy) updateJoystick(iInterface);
}
error("accept()");

View File

@ -16,6 +16,7 @@ struct settings defaultSettings = {
cStick: joystick2,
touch: mouse,
mouseSpeed: 4,
vJoyDevice: 1,
A: { 1, {'A'} },
B: { 1, {'B'} },
X: { 1, {'X'} },
@ -150,6 +151,10 @@ bool readSettings(void) {
sscanf(setting, "%d", &settings.mouseSpeed);
}
if(getSetting("vJoy Device: ", buffer, setting)) {
sscanf(setting, "%d", &settings.vJoyDevice);
}
if(getSetting("A: ", buffer, setting)) settings.A = getButton(setting);
if(getSetting("B: ", buffer, setting)) settings.B = getButton(setting);
if(getSetting("X: ", buffer, setting)) settings.X = getButton(setting);