Added 4 dir hat switch and more keys
4 Direction POV hat switch, and escape, control, alt as keys.
This commit is contained in:
parent
f3381fb2d3
commit
b0faecd8a6
5 changed files with 29 additions and 4 deletions
|
@ -6,9 +6,9 @@ Circle Pad and C Stick may also be set to KEYS, which will enable Pad directions
|
|||
|
||||
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 JOY16).
|
||||
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, WINDOWS, ESCAPE, CONTROL or ALT), a joypad button (JOY1, JOY2, JOY3, to JOY16) or vJoy Hat Switch direction (NORTH, EAST, SOUTH or WEST) (The hat switch must be enabled in vJoy Config. 4 way only, not continuous!)
|
||||
|
||||
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.
|
||||
If you want to use JOY9 through JOY16 you need to reconfigure vJoy. Search for vJoy Config in your start menu and set buttons to 16.
|
||||
|
||||
Alternatively, you can disable a key by binding it to NONE,
|
||||
|
||||
|
|
|
@ -35,6 +35,10 @@
|
|||
if(currentKeys & DSKey) joyButtons |= PCKey.joypadButton << 8;\
|
||||
else joyButtons &= ~(PCKey.joypadButton << 8);\
|
||||
}\
|
||||
else if(PCKey.useJoypad == 3) {\
|
||||
if(currentKeys & DSKey) hatButtons |= PCKey.joypadButton;\
|
||||
else hatButtons &= ~(PCKey.joypadButton);\
|
||||
}\
|
||||
} while(0)
|
||||
|
||||
#define BIT(n) (1 << (n))
|
||||
|
@ -72,7 +76,7 @@ typedef enum {
|
|||
} KEYPAD_BITS;
|
||||
|
||||
struct keyMapping {
|
||||
unsigned char useJoypad; // 0 keyboard key, 1 joypad1-8, 2 joypad9-16
|
||||
unsigned char useJoypad; // 0 keyboard key, 1 joypad1-8, 2 joypad9-16, 3 hat
|
||||
union {
|
||||
unsigned char virtualKey;
|
||||
unsigned char joypadButton;
|
||||
|
@ -105,3 +109,4 @@ extern struct touch currentTouch;
|
|||
inline unsigned int mapVirtualKey(unsigned int key);
|
||||
void simulateKeyNewpress(unsigned int key);
|
||||
void simulateKeyRelease(unsigned int key);
|
||||
void handleHat(unsigned int hat);
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
#include "keys.h"
|
||||
#include "joystick.h"
|
||||
|
||||
// Sideband comunication with vJoy Device
|
||||
//{781EF630-72B2-11d2-B852-00C04FAD5101}
|
||||
DEFINE_GUID(GUID_DEVINTERFACE_VJOY, 0x781EF630, 0x72B2, 0x11d2, 0xB8, 0x52, 0x00, 0xC0, 0x4F, 0xAD, 0x51, 0x01);
|
||||
//DEFINE_GUID(GUID_DEVINTERFACE_VJOY, 0x781EF630, 0x72B2, 0x11d2, 0xB8, 0x52, 0x00, 0xC0, 0x4F, 0xAD, 0x51, 0x01);
|
||||
|
||||
unsigned int lastKeys;
|
||||
unsigned int currentKeys;
|
||||
|
@ -76,3 +77,11 @@ void simulateKeyRelease(unsigned int key) {
|
|||
|
||||
SendInput(1, &ip, sizeof(INPUT));
|
||||
}
|
||||
|
||||
void handleHat(unsigned int hat) {
|
||||
if(hat & BIT(0)) iReport.bHats = 0;
|
||||
else if(hat & BIT(1)) iReport.bHats = 1;
|
||||
else if(hat & BIT(2)) iReport.bHats = 2;
|
||||
else if(hat & BIT(3)) iReport.bHats = 3;
|
||||
else iReport.bHats = -1;
|
||||
}
|
|
@ -28,6 +28,7 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmd, int nShow)
|
|||
|
||||
bool vJoy = true;
|
||||
UINT iInterface = settings.vJoyDevice;
|
||||
int hatButtons = 0;
|
||||
|
||||
iReport.wAxisX = JOY_MIDDLE;
|
||||
iReport.wAxisY = JOY_MIDDLE;
|
||||
|
@ -136,6 +137,8 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmd, int nShow)
|
|||
handleKey(KEY_X, settings.X);
|
||||
handleKey(KEY_Y, settings.Y);
|
||||
|
||||
handleHat(hatButtons);
|
||||
|
||||
if(settings.circlePad == keys) {
|
||||
handleKey(KEY_CPAD_RIGHT, settings.PadRight);
|
||||
handleKey(KEY_CPAD_LEFT, settings.PadLeft);
|
||||
|
|
|
@ -71,6 +71,9 @@ static struct keyMapping getButton(char *string) {
|
|||
else if(strcmp(string, "PAGE UP") == 0) k.virtualKey = VK_PRIOR;
|
||||
else if(strcmp(string, "PAGE DOWN") == 0) k.virtualKey = VK_NEXT;
|
||||
else if(strcmp(string, "WINDOWS") == 0) k.virtualKey = VK_LWIN;
|
||||
else if(strcmp(string, "ESCAPE") == 0) k.virtualKey = VK_ESCAPE;
|
||||
else if(strcmp(string, "CONTROL") == 0) k.virtualKey = VK_CONTROL;
|
||||
else if(strcmp(string, "ALT") == 0) k.virtualKey = VK_MENU;
|
||||
else if(strcmp(string, "NONE") == 0) k.virtualKey = 0;
|
||||
|
||||
else if(strcmp(string, "JOY1") == 0) { k.useJoypad = 1; k.joypadButton = 1 << 0; }
|
||||
|
@ -90,6 +93,11 @@ static struct keyMapping getButton(char *string) {
|
|||
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 if(strcmp(string, "NORTH") == 0) { k.useJoypad = 3; k.joypadButton = 1 << 0; }
|
||||
else if(strcmp(string, "EAST") == 0) { k.useJoypad = 3; k.joypadButton = 1 << 1; }
|
||||
else if(strcmp(string, "SOUTH") == 0) { k.useJoypad = 3; k.joypadButton = 1 << 2; }
|
||||
else if(strcmp(string, "WEST") == 0) { k.useJoypad = 3; k.joypadButton = 1 << 3; }
|
||||
|
||||
else k.virtualKey = (int)string[0];
|
||||
|
||||
return k;
|
||||
|
|
Loading…
Reference in a new issue