Skip to content

Instantly share code, notes, and snippets.

@Langerz82
Created May 12, 2021 06:29
Show Gist options
  • Save Langerz82/c84a2e6723fa35bdc2132b79a64cdb03 to your computer and use it in GitHub Desktop.
Save Langerz82/c84a2e6723fa35bdc2132b79a64cdb03 to your computer and use it in GitHub Desktop.
diff --git a/advance/lib/joy.c b/advance/lib/joy.c
index 123cc0df..2d2ae445 100644
--- a/advance/lib/joy.c
+++ b/advance/lib/joy.c
@@ -28,6 +28,11 @@ struct joy_entry {
};
static struct joy_entry JOY_BUTTON[] = {
+ { "dpLeft", JOYB_DPL },
+ { "dpRight", JOYB_DPR },
+ { "dpUp", JOYB_DPU },
+ { "dpDown", JOYB_DPD },
+
{ "a", JOYB_A },
{ "b", JOYB_B },
{ "c", JOYB_C },
@@ -105,4 +110,3 @@ adv_bool joy_button_is_defined(unsigned code)
return 0;
}
-
diff --git a/advance/lib/joy.h b/advance/lib/joy.h
index 2e15e71c..8df4ebbe 100644
--- a/advance/lib/joy.h
+++ b/advance/lib/joy.h
@@ -75,6 +75,11 @@ extern "C" {
#define JOYB_GEAR_DOWN 143 /* wheel */
#define JOYB_GEAR_UP 144 /* wheel */
+#define JOYB_DPL JOYB_15
+#define JOYB_DPR JOYB_14
+#define JOYB_DPU JOYB_12
+#define JOYB_DPD JOYB_13
+
#define JOYB_MAX 256
/*@}*/
@@ -89,4 +94,3 @@ adv_bool joy_button_is_defined(unsigned code);
#endif
/*@}*/
-
diff --git a/advance/linux/event.c b/advance/linux/event.c
index f6fa4c35..69e756f6 100644
--- a/advance/linux/event.c
+++ b/advance/linux/event.c
@@ -763,6 +763,20 @@ static void event_key_log(int f)
#ifdef BTN_DEAD
case BTN_DEAD: desc = "BTN_DEAD"; break;
#endif
+
+#ifdef BTN_DPL
+ case BTN_DPL: desc = "BTN_DPL"; break;
+#endif
+#ifdef BTN_DPR
+ case BTN_DPR: desc = "BTN_DPR"; break;
+#endif
+#ifdef BTN_DPU
+ case BTN_DPU: desc = "BTN_DPU"; break;
+#endif
+#ifdef BTN_DPD
+ case BTN_DPD: desc = "BTN_DPD"; break;
+#endif
+
#ifdef BTN_A
case BTN_A: desc = "BTN_A"; break;
#endif
@@ -2301,4 +2315,3 @@ unsigned event_locate(struct event_location* event_map, unsigned event_max, cons
return event_mac;
}
-
diff --git a/advance/linux/jevent.c b/advance/linux/jevent.c
index fd4f2367..77c7b463 100644
--- a/advance/linux/jevent.c
+++ b/advance/linux/jevent.c
@@ -265,6 +265,20 @@ static adv_error joystickb_setup(struct joystick_item_context* item, int f)
#ifdef BTN_TRIGGER_HAPPY16
{ BTN_TRIGGER_HAPPY16, "happy16" }, /* joystick */
#endif
+
+#ifdef BTN_DPL
+ { BTN_DPL, "dpLeft", JOYB_DPL }, /* gamepad */
+#endif
+#ifdef BTN_DPR
+ { BTN_DPR, "dpRight", JOYB_DPR }, /* gamepad */
+#endif
+#ifdef BTN_DPU
+ { BTN_DPU, "dpUp", JOYB_DPU }, /* gamepad */
+#endif
+#ifdef BTN_DPD
+ { BTN_DPD, "dpDown", JOYB_DPD }, /* gamepad */
+#endif
+
#ifdef BTN_A
{ BTN_A, "a", JOYB_A }, /* gamepad */
#endif
@@ -1124,4 +1138,3 @@ joystickb_driver joystickb_event_driver = {
joystickb_event_bind,
joystickb_event_revbind
};
-
diff --git a/advance/linux/joverride.dat b/advance/linux/joverride.dat
index 98b4d72d..36e17b2e 100644
--- a/advance/linux/joverride.dat
+++ b/advance/linux/joverride.dat
@@ -1191,6 +1191,11 @@
{ 0x054c, 0x0268, "SHANWAN PS3 GamePad", 8, "select", JOYB_SELECT },
{ 0x054c, 0x0268, "SHANWAN PS3 GamePad", 9, "start", JOYB_START },
{ 0x054c, 0x0268, "SHANWAN PS3 GamePad", 10, "mode", JOYB_MODE },
+ { 0x054c, 0x0268, "SHANWAN PS3 GamePad", 13, "dpUp", JOYB_DPU },
+ { 0x054c, 0x0268, "SHANWAN PS3 GamePad", 14, "dpDown", JOYB_DPD },
+ { 0x054c, 0x0268, "SHANWAN PS3 GamePad", 16, "dpRight", JOYB_DPR },
+ { 0x054c, 0x0268, "SHANWAN PS3 GamePad", 15, "dpLeft", JOYB_DPL },
+
/* SHANWAN PS3 GamePad */
{ 0x054c, 0x0268, "SHANWAN PS3 GamePad", 1, "a", JOYB_A },
{ 0x054c, 0x0268, "SHANWAN PS3 GamePad", 0, "b", JOYB_B },
@@ -1202,6 +1207,12 @@
{ 0x054c, 0x0268, "SHANWAN PS3 GamePad", 7, "tr2", JOYB_TR2 },
{ 0x054c, 0x0268, "SHANWAN PS3 GamePad", 8, "select", JOYB_SELECT },
{ 0x054c, 0x0268, "SHANWAN PS3 GamePad", 9, "start", JOYB_START },
+ { 0x054c, 0x0268, "SHANWAN PS3 GamePad", 10, "mode", JOYB_MODE },
+ { 0x054c, 0x0268, "SHANWAN PS3 GamePad", 13, "dpUp", JOYB_DPU },
+ { 0x054c, 0x0268, "SHANWAN PS3 GamePad", 14, "dpDown", JOYB_DPD },
+ { 0x054c, 0x0268, "SHANWAN PS3 GamePad", 16, "dpRight", JOYB_DPR },
+ { 0x054c, 0x0268, "SHANWAN PS3 GamePad", 15, "dpLeft", JOYB_DPL },
+
/* CYPRESS USB Gamepad */
{ 0x04b4, 0x010a, "CYPRESS USB Gamepad", 2, "a", JOYB_A },
{ 0x04b4, 0x010a, "CYPRESS USB Gamepad", 1, "b", JOYB_B },
@@ -1296,6 +1307,11 @@
{ 0x054c, 0x0268, "PLAYSTATION(R)3 Controller", 0, "select", JOYB_SELECT },
{ 0x054c, 0x0268, "PLAYSTATION(R)3 Controller", 3, "start", JOYB_START },
{ 0x054c, 0x0268, "PLAYSTATION(R)3 Controller", 16, "mode", JOYB_MODE },
+ { 0x054c, 0x0268, "PLAYSTATION(R)3 Controller", 4, "dpUp", JOYB_DPU },
+ { 0x054c, 0x0268, "PLAYSTATION(R)3 Controller", 6, "dpDown", JOYB_DPD },
+ { 0x054c, 0x0268, "PLAYSTATION(R)3 Controller", 5, "dpRight", JOYB_DPR },
+ { 0x054c, 0x0268, "PLAYSTATION(R)3 Controller", 7, "dpLeft", JOYB_DPL },
+
/* Sony Computer Entertainment Wireless Controller */
{ 0x054c, 0x0268, "Sony Computer Entertainment Wireless Controller", 13, "a", JOYB_A },
{ 0x054c, 0x0268, "Sony Computer Entertainment Wireless Controller", 14, "b", JOYB_B },
@@ -1308,6 +1324,11 @@
{ 0x054c, 0x0268, "Sony Computer Entertainment Wireless Controller", 0, "select", JOYB_SELECT },
{ 0x054c, 0x0268, "Sony Computer Entertainment Wireless Controller", 3, "start", JOYB_START },
{ 0x054c, 0x0268, "Sony Computer Entertainment Wireless Controller", 16, "mode", JOYB_MODE },
+ { 0x054c, 0x0268, "Sony Computer Entertainment Wireless Controller", 4, "dpUp", JOYB_DPU },
+ { 0x054c, 0x0268, "Sony Computer Entertainment Wireless Controller", 6, "dpDown", JOYB_DPD },
+ { 0x054c, 0x0268, "Sony Computer Entertainment Wireless Controller", 5, "dpRight", JOYB_DPR },
+ { 0x054c, 0x0268, "Sony Computer Entertainment Wireless Controller", 7, "dpLeft", JOYB_DPL },
+
/* Sony PLAYSTATION(R)3 Controller */
{ 0x054c, 0x0268, "Sony PLAYSTATION(R)3 Controller", 1, "a", JOYB_A },
{ 0x054c, 0x0268, "Sony PLAYSTATION(R)3 Controller", 0, "b", JOYB_B },
@@ -1320,6 +1341,11 @@
{ 0x054c, 0x0268, "Sony PLAYSTATION(R)3 Controller", 8, "select", JOYB_SELECT },
{ 0x054c, 0x0268, "Sony PLAYSTATION(R)3 Controller", 9, "start", JOYB_START },
{ 0x054c, 0x0268, "Sony PLAYSTATION(R)3 Controller", 10, "mode", JOYB_MODE },
+ { 0x054c, 0x0268, "Sony PLAYSTATION(R)3 Controller", 13, "dpUp", JOYB_DPU },
+ { 0x054c, 0x0268, "Sony PLAYSTATION(R)3 Controller", 14, "dpDown", JOYB_DPD },
+ { 0x054c, 0x0268, "Sony PLAYSTATION(R)3 Controller", 16, "dpRight", JOYB_DPR },
+ { 0x054c, 0x0268, "Sony PLAYSTATION(R)3 Controller", 15, "dpLeft", JOYB_DPL },
+
/* Wireless Controller */
{ 0x054c, 0x05c4, "Wireless Controller", 1, "a", JOYB_A },
{ 0x054c, 0x05c4, "Wireless Controller", 0, "b", JOYB_B },
@@ -1815,4 +1841,3 @@
{ 0x05ac, 0x033d, "xiaoji Gamesir-G3v 1.00", 9, "tr2", JOYB_TR2 },
{ 0x05ac, 0x033d, "xiaoji Gamesir-G3v 1.00", 10, "select", JOYB_SELECT },
{ 0x05ac, 0x033d, "xiaoji Gamesir-G3v 1.00", 11, "start", JOYB_START },
-
diff --git a/src/inptport.c b/src/inptport.c
index 8cec535b..e0ac2aa6 100644
--- a/src/inptport.c
+++ b/src/inptport.c
@@ -438,10 +438,10 @@ const char *input_port_default_strings[] =
static const input_port_default_entry default_ports_builtin[] =
{
- INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, JOYSTICK_UP, "P1 Up", SEQ_DEF_3(KEYCODE_UP, CODE_OR, JOYCODE_1_UP) )
- INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, JOYSTICK_DOWN, "P1 Down", SEQ_DEF_3(KEYCODE_DOWN, CODE_OR, JOYCODE_1_DOWN) )
- INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, JOYSTICK_LEFT, "P1 Left", SEQ_DEF_3(KEYCODE_LEFT, CODE_OR, JOYCODE_1_LEFT) )
- INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, JOYSTICK_RIGHT, "P1 Right", SEQ_DEF_3(KEYCODE_RIGHT, CODE_OR, JOYCODE_1_RIGHT) )
+ INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, JOYSTICK_UP, "P1 Up", SEQ_DEF_5(KEYCODE_UP, CODE_OR, JOYCODE_1_UP, CODE_OR, JOYCODE_1_BUTTON12) )
+ INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, JOYSTICK_DOWN, "P1 Down", SEQ_DEF_5(KEYCODE_DOWN, CODE_OR, JOYCODE_1_DOWN, CODE_OR, JOYCODE_1_BUTTON13) )
+ INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, JOYSTICK_LEFT, "P1 Left", SEQ_DEF_5(KEYCODE_LEFT, CODE_OR, JOYCODE_1_LEFT, CODE_OR, JOYCODE_1_BUTTON15) )
+ INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, JOYSTICK_RIGHT, "P1 Right", SEQ_DEF_5(KEYCODE_RIGHT, CODE_OR, JOYCODE_1_RIGHT, CODE_OR, JOYCODE_1_BUTTON14) )
INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, JOYSTICKRIGHT_UP, "P1 Right/Up", SEQ_DEF_3(KEYCODE_I, CODE_OR, JOYCODE_1_BUTTON2) )
INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, JOYSTICKRIGHT_DOWN, "P1 Right/Down", SEQ_DEF_3(KEYCODE_K, CODE_OR, JOYCODE_1_BUTTON3) )
INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, JOYSTICKRIGHT_LEFT, "P1 Right/Left", SEQ_DEF_3(KEYCODE_J, CODE_OR, JOYCODE_1_BUTTON1) )
@@ -492,10 +492,10 @@ static const input_port_default_entry default_ports_builtin[] =
INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, MAHJONG_BIG, "P1 Mahjong Big", SEQ_DEF_1(KEYCODE_ENTER) )
INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, MAHJONG_SMALL, "P1 Mahjong Small", SEQ_DEF_1(KEYCODE_BACKSPACE) )
- INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, JOYSTICK_UP, "P2 Up", SEQ_DEF_3(KEYCODE_R, CODE_OR, JOYCODE_2_UP) )
- INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, JOYSTICK_DOWN, "P2 Down", SEQ_DEF_3(KEYCODE_F, CODE_OR, JOYCODE_2_DOWN) )
- INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, JOYSTICK_LEFT, "P2 Left", SEQ_DEF_3(KEYCODE_D, CODE_OR, JOYCODE_2_LEFT) )
- INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, JOYSTICK_RIGHT, "P2 Right", SEQ_DEF_3(KEYCODE_G, CODE_OR, JOYCODE_2_RIGHT) )
+ INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, JOYSTICK_UP, "P2 Up", SEQ_DEF_5(KEYCODE_R, CODE_OR, JOYCODE_2_UP, CODE_OR, JOYCODE_2_BUTTON12) )
+ INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, JOYSTICK_DOWN, "P2 Down", SEQ_DEF_5(KEYCODE_F, CODE_OR, JOYCODE_2_DOWN, CODE_OR, JOYCODE_2_BUTTON13) )
+ INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, JOYSTICK_LEFT, "P2 Left", SEQ_DEF_5(KEYCODE_D, CODE_OR, JOYCODE_2_LEFT, CODE_OR, JOYCODE_2_BUTTON15) )
+ INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, JOYSTICK_RIGHT, "P2 Right", SEQ_DEF_5(KEYCODE_G, CODE_OR, JOYCODE_2_RIGHT, CODE_OR, JOYCODE_2_BUTTON14) )
INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, JOYSTICKRIGHT_UP, "P2 Right/Up", SEQ_DEF_0 )
INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, JOYSTICKRIGHT_DOWN, "P2 Right/Down", SEQ_DEF_0 )
INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, JOYSTICKRIGHT_LEFT, "P2 Right/Left", SEQ_DEF_0 )
diff --git a/src/input.c b/src/input.c
index 8a79be68..6b2325e8 100644
--- a/src/input.c
+++ b/src/input.c
@@ -193,6 +193,7 @@ static struct
STANDARD_CODE_STRING(JOYCODE_1_BUTTON16)
STANDARD_CODE_STRING(JOYCODE_1_START)
STANDARD_CODE_STRING(JOYCODE_1_SELECT)
+
STANDARD_CODE_STRING(JOYCODE_2_LEFT)
STANDARD_CODE_STRING(JOYCODE_2_RIGHT)
STANDARD_CODE_STRING(JOYCODE_2_UP)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment