From 61f3572ee5d9aaed57a75592ea716f7b3ba70a9e Mon Sep 17 00:00:00 2001 From: CTurt Date: Sat, 6 Dec 2014 13:29:38 +0000 Subject: [PATCH] Base of custom key bindings --- PC/include/settings.h | 19 +++++++++++++++++ PC/source/main.c | 38 ++++++++++++++++++--------------- PC/source/settings.c | 30 ++++++++++++++++++++++++++ Release/3DS/3DSController.smdh | Bin 0 -> 14016 bytes 4 files changed, 70 insertions(+), 17 deletions(-) create mode 100644 PC/include/settings.h create mode 100644 PC/source/settings.c create mode 100644 Release/3DS/3DSController.smdh diff --git a/PC/include/settings.h b/PC/include/settings.h new file mode 100644 index 0000000..cea633a --- /dev/null +++ b/PC/include/settings.h @@ -0,0 +1,19 @@ +#pragma once + +#include + +enum analogue { + mouse, + joystick, +}; + +struct settings { + enum analogue circlePad; + enum analogue touch; + int A, B, X, Y, L, R, Left, Right, Up, Down, Start, Select, Tap; +}; + +extern struct settings settings; +extern struct settings defaultSettings; + +bool readSettings(void); diff --git a/PC/source/main.c b/PC/source/main.c index 59bf07d..fc35eaa 100644 --- a/PC/source/main.c +++ b/PC/source/main.c @@ -10,6 +10,7 @@ #include "keys.h" #include "general.h" #include "joystick.h" +#include "settings.h" int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmd, int nShow) { printf("3DS Controller Server %.2f\n", VERSION); @@ -18,13 +19,13 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmd, int nShow) UINT iInterface = 1; if(vJoy && !vJoyEnabled()) { - printf("vJoy failed (1)! Buttons will still work, but control stick won't work.\n"); + printf("vJoy failed (1)! Buttons will still work, but joy stick won't work.\n"); vJoy = false; } enum VjdStat status = GetVJDStatus(iInterface); if(vJoy && (status == VJD_STAT_OWN || (status == VJD_STAT_FREE && !AcquireVJD(iInterface)))) { - printf("vJoy failed (2)! Buttons will still work, but control stick won't work.\n"); + printf("vJoy failed (2)! Buttons will still work, but joy stick won't work.\n"); vJoy = false; } @@ -32,7 +33,7 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmd, int nShow) //int DiscPovNumber = GetVJDDiscPovNumber(iInterface); if(vJoy && !updateJoystick(128 * 128, 128 * 128)) { - printf("vJoy failed (3)! Buttons will still work, but control stick won't work.\n"); + printf("vJoy failed (3)! Buttons will still work, but joy stick won't work.\n"); vJoy = false; } @@ -40,6 +41,10 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmd, int nShow) printf("Running on: %s\n\n", hostName); + if(!readSettings()) { + printf("Couldn't read settings file, using default key bindings\n"); + } + startListening(); while(1) { @@ -84,20 +89,19 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmd, int nShow) memcpy(¤tTouch, &((struct packet *)buffer)->touch, 4); #pragma GCC diagnostic pop - handleKey(KEY_A, 'A'); - handleKey(KEY_B, 'B'); - handleKey(KEY_SELECT, VK_BACK); - handleKey(KEY_START, VK_RETURN); - handleKey(KEY_DRIGHT, VK_RIGHT); - handleKey(KEY_DLEFT, VK_LEFT); - handleKey(KEY_DUP, VK_UP); - handleKey(KEY_DDOWN, VK_DOWN); - handleKey(KEY_R, 'R'); - handleKey(KEY_L, 'L'); - handleKey(KEY_X, 'X'); - handleKey(KEY_Y, 'Y'); - - //handleKey(KEY_TOUCH, VK_LBUTTON); + handleKey(KEY_A, settings.A); + handleKey(KEY_B, settings.B); + handleKey(KEY_SELECT, settings.Select); + handleKey(KEY_START, settings.Start); + handleKey(KEY_DRIGHT, settings.Right); + handleKey(KEY_DLEFT, settings.Left); + handleKey(KEY_DUP, settings.Up); + handleKey(KEY_DDOWN, settings.Down); + handleKey(KEY_R, settings.R); + handleKey(KEY_L, settings.L); + handleKey(KEY_X, settings.X); + handleKey(KEY_Y, settings.Y); + handleKey(KEY_TOUCH, settings.Tap); //handleKey(KEY_LID, 'I'); if(newpress(KEY_TOUCH)) { diff --git a/PC/source/settings.c b/PC/source/settings.c new file mode 100644 index 0000000..32c1500 --- /dev/null +++ b/PC/source/settings.c @@ -0,0 +1,30 @@ +#include +#include +#include + +#include "settings.h" + +struct settings settings; + +struct settings defaultSettings = { + circlePad: joystick, + touch: mouse, + A: 'A', + B: 'B', + X: 'X', + Y: 'Y', + L: 'L', + R: 'R', + Left: VK_LEFT, + Right: VK_RIGHT, + Up: VK_UP, + Down: VK_DOWN, + Start: VK_RETURN, + Select: VK_BACK, + Tap: 'T', +}; + +bool readSettings(void) { + memcpy(&settings, &defaultSettings, sizeof(struct settings)); + return true; +} diff --git a/Release/3DS/3DSController.smdh b/Release/3DS/3DSController.smdh new file mode 100644 index 0000000000000000000000000000000000000000..1abd09439c4a5d0a1a530f21f405af0580f8a579 GIT binary patch literal 14016 zcmeHNF-Tic6upB(28Ta%_=7_PhYAjcT52GRwuLHWQ0t)JAmUI`TiVp2NEZniL>x-! zAd(@VgAj*6G6-e~m_e|E5C_3OWcY(ah7Nz|@Op2r&;LV=`9F%!;oS`H{r~Q}_rCk? zdH23gX5w$&0n!V212YhY*YFuW!8iDd?MM7AWAAb36})^LMNd-8Yj_W<=<9Eatke6i z$nn=|_5N%8Yy7Llpi1o;{~G@q|0)rvR=38##=pkDS`4bxuJNz&uko)EfogSY{A>Jc z{Hw*FO6?l|8vh#qDiNqwx5mH5zsA2>464+w8vos{U1$p6fl`r~OU0O7G3#cSxNNtpUg8)%w9JD zO2yx60PHV0H)c<5o*(rtQS64V19+ex;A;N-s2XKm#5LZZ09(mYk+^6V3Yo0ad4`vxkXcD^ z4DU}rAGZYWM`La7)Dm?wo?zarQ@~whDr7?A07hz{KZk3z(EoilKp`X7OdzqH#pTl0~Wn~r?J z6WMznQEr=&U`_ErS>ev4oK*rFzQFcB|y0-N$3GsID3Ui+&?C4li ze)5~|TxtG#LGzpPl~lwRtQvnT(|NZ9G9WNGEE}?-VO`REQkbMCnND z+%Ue%I)^nH@l!*zs|S_`g$Rvvy)+ggX-sw$V0lnJ1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