Skip to content
This repository has been archived by the owner on May 8, 2024. It is now read-only.

Commit

Permalink
Merge pull request #2831 from brooksytech/dev
Browse files Browse the repository at this point in the history
RK3399: Rename built in gamepad to rg552_joypad to avoid conflicts
  • Loading branch information
r3claimer authored Feb 5, 2024
2 parents 1d31342 + dd47989 commit 5168939
Show file tree
Hide file tree
Showing 17 changed files with 125 additions and 34 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[GCPad1]
Device = evdev/0/retrogame_joypad
Device = evdev/0/rg552_joypad
Buttons/A = Button 0
Buttons/B = Button 3
Buttons/Start = Button 8
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[GCPad1]
Device = evdev/0/retrogame_joypad
Device = evdev/0/rg552_joypad
Buttons/A = Button 1
Buttons/B = Button 0
Buttons/Start = Button 8
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[Wiimote1]
Device = evdev/0/retrogame_joypad
Device = evdev/0/rg552_joypad
Extension = Classic
Source = 1
Classic/Buttons/A = Button 1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[Wiimote1]
Device = evdev/0/retrogame_joypad
Device = evdev/0/rg552_joypad
Buttons/A = Button 0
Buttons/B = Button 1
Buttons/1 = Button 3
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[Wiimote1]
Device = evdev/0/retrogame_joypad
Device = evdev/0/rg552_joypad
Extension = Nunchuk
Buttons/A = Button 0
Buttons/B = Button 1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[Wiimote1]
Device = evdev/0/retrogame_joypad
Device = evdev/0/rg552_joypad
Buttons/A = Button 0
Buttons/B = Button 1
Buttons/1 = Button 3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ bind9 = 9:btn_start

[emulator]
dead_zone = 10
mapping_name = retrogame_joypad
mapping_name = rg552_joypad
rumble_power = 100
version = 3

Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ mode = 2
# Specifies which joystick is bound to this controller: -1=No joystick, 0 or more= SDL Joystick number
device = 0
# SDL joystick name (or Keyboard)
name = "retrogame_joypad"
name = "rg552_joypad"
# Specifies whether this controller is 'plugged in' to the simulated N64
plugged = True
# Specifies which type of expansion pak is in the controller: 1=None, 2=Mem pak, 4=Transfer pak, 5=Rumble pak
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
; RG552 Gamepad - default.ini
[retrogame_joypad]
[rg552_joypad]
plugged = True
mouse = False
AnalogDeadzone = 0,0
Expand All @@ -22,4 +22,4 @@ Mempak switch =
Rumblepak switch =
# Analog axis configuration mappings
X Axis = axis(0-,0+)
Y Axis = axis(1-,1+)
Y Axis = axis(1-,1+)
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
; RG552 Gamepad - zlswap.ini
[retrogame_joypad]
[rg552_joypad]
plugged = True
mouse = False
AnalogDeadzone = 0,0
Expand All @@ -22,4 +22,4 @@ Mempak switch =
Rumblepak switch =
# Analog axis configuration mappings
X Axis = axis(0-,0+)
Y Axis = axis(1-,1+)
Y Axis = axis(1-,1+)
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
19009321b0c300000002000010000000,XU10 Gamepad,platform:Linux,x:b3,a:b2,b:b1,y:b0,back:b8,guide:b16,start:b9,dpleft:b14,dpdown:b13,dpright:b15,dpup:b12,leftshoulder:b4,lefttrigger:b7,rightshoulder:b5,righttrigger:b6,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,
190014b3010000009178000000050000,r33s_joypad,platform:Linux,x:b2,a:b1,b:b0,y:b3,back:b8,start:b9,dpleft:b12,dpdown:b11,dpright:b13,dpup:b10,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,
1900e5914b4800007711000077010000,RGB20S Gamepad,platform:Linux,x:b2,a:b1,b:b0,y:b3,back:b12,start:b13,dpleft:b10,dpdown:b9,dpright:b11,dpup:b8,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,leftstick:b14,rightstick:b15,leftx:a0,lefty:a1,rightx:a2,righty:a3,
1900e7444b4800000111000034020000,rg552_joypad,platform:Linux,x:b2,a:b1,b:b0,y:b3,back:b8,start:b9,dpleft:b15,dpdown:b14,dpright:b16,dpup:b13,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,leftstick:b11,rightstick:b12,leftx:a0,lefty:a1,rightx:a2,righty:a3,
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
input_driver = "udev"
input_device = "rg552_joypad"
input_device_display_name = "Anbernic RG552 Joypad"

input_b_btn = "0"
input_a_btn = "1"
input_x_btn = "2"
input_y_btn = "3"

input_select_btn = "8"
input_start_btn = "9"


input_l_btn = "4"
input_r_btn = "5"
input_l2_btn = "6"
input_r2_btn = "7"
input_l3_btn = "11"
input_r3_btn = "12"

input_up_btn = "13"
input_down_btn = "14"
input_left_btn = "15"
input_right_btn = "16"

input_l_x_minus_axis = "-0"
input_l_x_plus_axis = "+0"
input_l_y_minus_axis = "-1"
input_l_y_plus_axis = "+1"

input_r_x_minus_axis = "-2"
input_r_x_plus_axis = "+2"
input_r_y_minus_axis = "-3"
input_r_y_plus_axis = "+3"

# Hotkeys
input_enable_hotkey_btn = "8"
input_exit_emulator_btn = "9"

input_menu_toggle_btn = "2"
input_fps_toggle_btn = "3"

input_load_state_btn = "4"
input_save_state_btn = "5"

input_rewind_btn = "11"
input_toggle_fast_forward_btn = "12"
16 changes: 16 additions & 0 deletions packages/hardware/quirks/devices/Anbernic RG552/050-game-configs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2024-present JELOS (https://github.com/JustEnoughLinuxOS)

. /etc/profile

#Remap joypad name to rg552_joypad
sed -i '/^mapping_name = retrogame_joypad/c\mapping_name = rg552_joypad' /storage/.config/flycast/mappings/SDL_retrogame_joypad.cfg
sed -i '/retrogame_joypad/c\[rg552_joypad]' /storage/.config/mupen64plus/custominput.ini
sed -i '/name = "retrogame_joypad"/c\name = "rg552_joypad"' /storage/.config/mupen64plus/mupen64plus.cfg

#Fix ES input
for config in "/storage/.config/emulationstation/es_input.cfg"; do
if ! grep -q rg552_joypad "$config"; then
cp -r /usr/config/emulationstation/es_input.cfg /storage/.config/emulationstation/es_input.cfg
fi
done;
27 changes: 27 additions & 0 deletions packages/ui/emulationstation/config/common/es_input.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -1419,4 +1419,31 @@
<input name="x" type="button" id="3" value="1" />
<input name="y" type="button" id="2" value="1" />
</inputConfig>
<inputConfig type="joystick" deviceName="rg552_joypad" deviceGUID="1900e7444b4800000111000034020000">
<input name="a" type="button" id="1" value="1" />
<input name="b" type="button" id="0" value="1" />
<input name="down" type="button" id="14" value="1" />
<input name="hotkeyenable" type="button" id="8" value="1" />
<input name="left" type="button" id="15" value="1" />
<input name="leftanalogdown" type="axis" id="1" value="1" />
<input name="leftanalogleft" type="axis" id="0" value="-1" />
<input name="leftanalogright" type="axis" id="0" value="1" />
<input name="leftanalogup" type="axis" id="1" value="-1" />
<input name="leftshoulder" type="button" id="4" value="1" />
<input name="leftthumb" type="button" id="11" value="1" />
<input name="lefttrigger" type="button" id="6" value="1" />
<input name="right" type="button" id="16" value="1" />
<input name="rightanalogdown" type="axis" id="3" value="1" />
<input name="rightanalogleft" type="axis" id="2" value="-1" />
<input name="rightanalogright" type="axis" id="2" value="1" />
<input name="rightanalogup" type="axis" id="3" value="-1" />
<input name="rightshoulder" type="button" id="5" value="1" />
<input name="rightthumb" type="button" id="12" value="1" />
<input name="righttrigger" type="button" id="7" value="1" />
<input name="select" type="button" id="8" value="1" />
<input name="start" type="button" id="9" value="1" />
<input name="up" type="button" id="13" value="1" />
<input name="x" type="button" id="2" value="1" />
<input name="y" type="button" id="3" value="1" />
</inputConfig>
</inputList>
2 changes: 1 addition & 1 deletion projects/Rockchip/devices/RK3399/linux/linux.aarch64.conf
Original file line number Diff line number Diff line change
Expand Up @@ -1857,7 +1857,7 @@ CONFIG_JOYSTICK_XPAD_LEDS=y
# CONFIG_JOYSTICK_PXRC is not set
# CONFIG_JOYSTICK_QWIIC is not set
# CONFIG_JOYSTICK_FSIA6B is not set
CONFIG_JOYSTICK_SINGLEADCJOY=y
CONFIG_JOYSTICK_RG552=y
# CONFIG_JOYSTICK_SENSEHAT is not set
# CONFIG_INPUT_TABLET is not set
CONFIG_INPUT_TOUCHSCREEN=y
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,16 @@ diff -rupN linux.orig/arch/arm64/boot/dts/rockchip/rk3399-anbernic-rg552.dts lin
+ };
+
+ joypad: singleadc-joypad {
+ compatible = "singleadc-joypad";
+ compatible = "rg552_joypad";
+
+ pwms = <&pwm3 0 200000000 0>;
+ pwm-names = "enable";
+ rumble-boost-weak = <0x0000>;
+ rumble-boost-strong = <0x0000>;
+
+ joypad-name = "retrogame_joypad";
+ joypad-name = "rg552_joypad";
+ joypad-product = <0x1101>;
+ joypad-revision = <0x0200>;
+ joypad-revision = <0x0234>;
+
+ status = "okay";
+
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -451,9 +451,9 @@ diff -rupN linux.orig/drivers/input/joystick/Kconfig linux/drivers/input/joystic
To compile this driver as a module, choose M here: the
module will be called fsia6b.

+config JOYSTICK_SINGLEADCJOY
+ tristate "Single SARADC dual-joystick gamepad driver"
+ select INPUT_POLLDEV
+config JOYSTICK_RG552
+ tristate "Anbernic RG552 gamepad driver"
+ select INPUT_POLLDEV
+ help
+ The 1-in 4-out SARADC joypad driver.
+
Expand All @@ -467,22 +467,22 @@ diff -rupN linux.orig/drivers/input/joystick/Makefile linux/drivers/input/joysti
obj-$(CONFIG_JOYSTICK_QWIIC) += qwiic-joystick.o
obj-$(CONFIG_JOYSTICK_SENSEHAT) += sensehat-joystick.o
obj-$(CONFIG_JOYSTICK_SIDEWINDER) += sidewinder.o
+obj-$(CONFIG_JOYSTICK_SINGLEADCJOY) += singleadcjoy.o
+obj-$(CONFIG_JOYSTICK_RG552) += rg552_joypad.o
obj-$(CONFIG_JOYSTICK_SPACEBALL) += spaceball.o
obj-$(CONFIG_JOYSTICK_SPACEORB) += spaceorb.o
obj-$(CONFIG_JOYSTICK_STINGER) += stinger.o
diff -rupN linux.orig/drivers/input/joystick/singleadcjoy.c linux/drivers/input/joystick/singleadcjoy.c
--- linux.orig/drivers/input/joystick/singleadcjoy.c 1970-01-01 00:00:00.000000000 +0000
+++ linux/drivers/input/joystick/singleadcjoy.c 2024-01-08 18:43:54.081267482 +0000
diff -rupN linux.orig/drivers/input/joystick/rg552_joypad.c linux/drivers/input/joystick/rg552_joypad.c
--- linux.orig/drivers/input/joystick/rg552_joypad.c 1970-01-01 00:00:00.000000000 +0000
+++ linux/drivers/input/joystick/rg552_joypad.c 2024-01-08 18:43:54.081267482 +0000
@@ -0,0 +1,1448 @@
+/*----------------------------------------------------------------------------*/
+
+/*
+ * Copyright (c) 2008-2021 Anbernic
+ * Copyright (c) 2008-2021 Anbernic
+ */
+
+/*
+ * Single SARADC dual-joystick gamepad driver
+ * Anbernic RG552 gamepad driver
+ */
+
+/*----------------------------------------------------------------------------*/
Expand All @@ -504,7 +504,7 @@ diff -rupN linux.orig/drivers/input/joystick/singleadcjoy.c linux/drivers/input/
+#include <linux/pwm.h>
+
+/*----------------------------------------------------------------------------*/
+#define DRV_NAME "retrogame_joypad"
+#define DRV_NAME "rg552_joypad"
+
+/*----------------------------------------------------------------------------*/
+#define ADC_MAX_VOLTAGE 1800
Expand Down Expand Up @@ -739,7 +739,7 @@ diff -rupN linux.orig/drivers/input/joystick/singleadcjoy.c linux/drivers/input/
+/*
+ * ATTRIBUTES:
+ *
+ * /sys/devices/platform/retrogame_joypad/poll_interval [rw]
+ * /sys/devices/platform/rg552_joypad/poll_interval [rw]
+ */
+/*----------------------------------------------------------------------------*/
+static ssize_t joypad_store_poll_interval(struct device *dev,
Expand Down Expand Up @@ -777,7 +777,7 @@ diff -rupN linux.orig/drivers/input/joystick/singleadcjoy.c linux/drivers/input/
+/*
+ * ATTRIBUTES:
+ *
+ * /sys/devices/platform/retrogame_joypad/adc_fuzz [r]
+ * /sys/devices/platform/rg552_joypad/adc_fuzz [r]
+ */
+/*----------------------------------------------------------------------------*/
+static ssize_t joypad_show_adc_fuzz(struct device *dev,
Expand All @@ -799,7 +799,7 @@ diff -rupN linux.orig/drivers/input/joystick/singleadcjoy.c linux/drivers/input/
+/*
+ * ATTRIBUTES:
+ *
+ * /sys/devices/platform/retrogame_joypad/adc_flat [r]
+ * /sys/devices/platform/rg552_joypad/adc_flat [r]
+ */
+/*----------------------------------------------------------------------------*/
+static ssize_t joypad_show_adc_flat(struct device *dev,
Expand All @@ -821,7 +821,7 @@ diff -rupN linux.orig/drivers/input/joystick/singleadcjoy.c linux/drivers/input/
+/*
+ * ATTRIBUTES:
+ *
+ * /sys/devices/platform/retrogame_joypad/enable [rw]
+ * /sys/devices/platform/rg552_joypad/enable [rw]
+ */
+/*----------------------------------------------------------------------------*/
+static ssize_t joypad_store_enable(struct device *dev,
Expand Down Expand Up @@ -859,7 +859,7 @@ diff -rupN linux.orig/drivers/input/joystick/singleadcjoy.c linux/drivers/input/
+/*
+ * ATTRIBUTES:
+ *
+ * /sys/devices/platform/retrogame_joypad/adc_cal [rw]
+ * /sys/devices/platform/rg552_joypad/adc_cal [rw]
+ */
+/*----------------------------------------------------------------------------*/
+static ssize_t joypad_store_adc_cal(struct device *dev,
Expand Down Expand Up @@ -921,7 +921,7 @@ diff -rupN linux.orig/drivers/input/joystick/singleadcjoy.c linux/drivers/input/
+/*
+ * ATTRIBUTES:
+ *
+ * /sys/devices/platform/retrogame_joypad/amux_debug [rw]
+ * /sys/devices/platform/rg552_joypad/amux_debug [rw]
+ *
+ * echo [debug channel] > amux_debug
+ * cat amux_debug : debug channel mux set & adc read
Expand Down Expand Up @@ -1108,7 +1108,7 @@ diff -rupN linux.orig/drivers/input/joystick/singleadcjoy.c linux/drivers/input/
+/*
+ * ATTRIBUTES:
+ *
+ * /sys/devices/platform/singleadc-joypad/hdst [rw]
+ * /sys/devices/platform/rg552_joypad/hdst [rw]
+ */
+/*----------------------------------------------------------------------------*/
+static ssize_t joypad_store_hdst(struct device *dev,
Expand Down Expand Up @@ -1892,7 +1892,7 @@ diff -rupN linux.orig/drivers/input/joystick/singleadcjoy.c linux/drivers/input/
+
+/*----------------------------------------------------------------------------*/
+static const struct of_device_id joypad_of_match[] = {
+ { .compatible = "singleadc-joypad", },
+ { .compatible = "rg552_joypad", },
+ {},
+};
+
Expand Down

0 comments on commit 5168939

Please sign in to comment.