Base of custom key bindings
This commit is contained in:
parent
e25f852267
commit
61f3572ee5
4 changed files with 70 additions and 17 deletions
19
PC/include/settings.h
Normal file
19
PC/include/settings.h
Normal file
|
@ -0,0 +1,19 @@
|
|||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
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);
|
|
@ -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)) {
|
||||
|
|
30
PC/source/settings.c
Normal file
30
PC/source/settings.c
Normal file
|
@ -0,0 +1,30 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <windows.h>
|
||||
|
||||
#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;
|
||||
}
|
BIN
Release/3DS/3DSController.smdh
Normal file
BIN
Release/3DS/3DSController.smdh
Normal file
Binary file not shown.
Loading…
Add table
Reference in a new issue