summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNebuleon <nebuleon@alakazam>2013-10-20 16:05:17 +0000
committerNebuleon <nebuleon@alakazam>2013-10-20 16:55:04 +0000
commit4b90e900f076c4ab1671c265ebc63cbb7766e3e5 (patch)
tree52a6ad5ba9c1a53cd0869079dc01bb8056afd7ce
parentc8a6cefc73f2e65e2a100785749b9578355e3c8c (diff)
downloadReGBA-4b90e900f076c4ab1671c265ebc63cbb7766e3e5.zip
ReGBA-4b90e900f076c4ab1671c265ebc63cbb7766e3e5.tar.gz
ReGBA-4b90e900f076c4ab1671c265ebc63cbb7766e3e5.tar.bz2
OpenDingux: Allow the analog directions to be mapped to hotkeys and buttons.
-rw-r--r--source/opendingux/gui.c12
-rw-r--r--source/opendingux/od-input.c14
-rw-r--r--source/opendingux/od-input.h6
3 files changed, 28 insertions, 4 deletions
diff --git a/source/opendingux/gui.c b/source/opendingux/gui.c
index 95e68cc..28a353e 100644
--- a/source/opendingux/gui.c
+++ b/source/opendingux/gui.c
@@ -390,6 +390,10 @@ static char* OpenDinguxButtonText[OPENDINGUX_BUTTON_COUNT] = {
"A",
LEFT_FACE_BUTTON_NAME,
TOP_FACE_BUTTON_NAME,
+ "Analog Down",
+ "Analog Up",
+ "Analog Left",
+ "Analog Right",
};
/*
@@ -500,16 +504,20 @@ static void DisplayHotkeyValue(struct MenuEntry* DrawnMenuEntry, struct MenuEntr
static char OpenDinguxButtonSave[OPENDINGUX_BUTTON_COUNT] = {
'L',
'R',
- 'v',
+ 'v', // D-pad directions.
'^',
'<',
- '>',
+ '>', // (end)
'S',
's',
'B',
'A',
'Y', // Using the SNES/DS/A320 mapping, this is the left face button.
'X', // Using the SNES/DS/A320 mapping, this is the upper face button.
+ 'd', // Analog nub directions (GCW Zero).
+ 'u',
+ 'l',
+ 'r', // (end)
};
static void LoadMappingFunction(struct MenuEntry* ActiveMenuEntry, char* Value)
diff --git a/source/opendingux/od-input.c b/source/opendingux/od-input.c
index a657e77..c85bbcc 100644
--- a/source/opendingux/od-input.c
+++ b/source/opendingux/od-input.c
@@ -32,7 +32,7 @@ static bool JoystickInitialised = false;
// Mandatory remapping for OpenmDingux keys. Each OpenmDingux key maps to a
// key on the keyboard, but not all keys on the keyboard map to these.
// They are not in GBA bitfield order in this array.
-uint32_t OpenDinguxKeys[12] = {
+uint32_t OpenDinguxKeys[OPENDINGUX_BUTTON_COUNT] = {
SDLK_TAB, // L
SDLK_BACKSPACE, // R
SDLK_DOWN, // Down
@@ -45,6 +45,10 @@ uint32_t OpenDinguxKeys[12] = {
SDLK_LCTRL, // Right face button (A)
SDLK_LSHIFT, // Left face button (GCW X, A320 Y)
SDLK_SPACE, // Upper face button (GCW Y, A320 X)
+ 0,
+ 0,
+ 0,
+ 0,
};
// These must be OpenDingux buttons at the bit suitable for the ReGBA_Buttons
@@ -141,6 +145,14 @@ static void UpdateOpenDinguxButtons()
break;
}
}
+
+ LastButtons &= ~(OPENDINGUX_ANALOG_LEFT | OPENDINGUX_ANALOG_RIGHT
+ | OPENDINGUX_ANALOG_UP | OPENDINGUX_ANALOG_DOWN);
+ int16_t X = GetHorizontalAxisValue(), Y = GetVerticalAxisValue();
+ if (X > 16000) LastButtons |= OPENDINGUX_ANALOG_RIGHT;
+ else if (X < -16000) LastButtons |= OPENDINGUX_ANALOG_LEFT;
+ if (Y > 16000) LastButtons |= OPENDINGUX_ANALOG_DOWN;
+ else if (Y < -16000) LastButtons |= OPENDINGUX_ANALOG_UP;
}
void ProcessSpecialKeys()
diff --git a/source/opendingux/od-input.h b/source/opendingux/od-input.h
index 431bb8b..ad8be14 100644
--- a/source/opendingux/od-input.h
+++ b/source/opendingux/od-input.h
@@ -20,7 +20,7 @@
#ifndef __OD_INPUT_H__
#define __OD_INPUT_H__
-#define OPENDINGUX_BUTTON_COUNT 12
+#define OPENDINGUX_BUTTON_COUNT 16
// These must be in the order defined in OpenDinguxKeys in od-input.c.
enum OpenDingux_Buttons {
@@ -36,6 +36,10 @@ enum OpenDingux_Buttons {
OPENDINGUX_BUTTON_FACE_RIGHT = 0x0200,
OPENDINGUX_BUTTON_FACE_LEFT = 0x0400,
OPENDINGUX_BUTTON_FACE_UP = 0x0800,
+ OPENDINGUX_ANALOG_DOWN = 0x1000,
+ OPENDINGUX_ANALOG_UP = 0x2000,
+ OPENDINGUX_ANALOG_LEFT = 0x4000,
+ OPENDINGUX_ANALOG_RIGHT = 0x8000,
};
enum GUI_Action {