Rebase 'Add generic rumble gain to input settings' by davidgfnet

This commit is contained in:
Michael Burgardt 2021-09-04 16:29:54 +02:00
parent 8a31b732dd
commit 303d17e2e6
72 changed files with 221 additions and 150 deletions

View file

@ -1464,7 +1464,9 @@ static const bool enable_device_vibration = false;
/* Defines the strength of rumble effects
* on OpenDingux devices */
#if defined(DINGUX) && defined(HAVE_LIBSHAKE)
#define DEFAULT_DINGUX_RUMBLE_GAIN 50
#define DEFAULT_RUMBLE_GAIN 50
#else
#define DEFAULT_RUMBLE_GAIN 100
#endif
#ifdef HAVE_VULKAN

View file

@ -2080,9 +2080,7 @@ static struct config_uint_setting *populate_settings_uint(
SETTING_UINT("input_mouse_scale", &settings->uints.input_mouse_scale, true, DEFAULT_MOUSE_SCALE, false);
#endif
SETTING_UINT("input_touch_scale", &settings->uints.input_touch_scale, true, DEFAULT_TOUCH_SCALE, false);
#if defined(DINGUX) && defined(HAVE_LIBSHAKE)
SETTING_UINT("input_dingux_rumble_gain", &settings->uints.input_dingux_rumble_gain, true, DEFAULT_DINGUX_RUMBLE_GAIN, false);
#endif
SETTING_UINT("input_rumble_gain", &settings->uints.input_rumble_gain, true, DEFAULT_RUMBLE_GAIN, false);
SETTING_UINT("input_auto_game_focus", &settings->uints.input_auto_game_focus, true, DEFAULT_INPUT_AUTO_GAME_FOCUS, false);
SETTING_UINT("audio_latency", &settings->uints.audio_latency, false, 0 /* TODO */, false);
SETTING_UINT("audio_resampler_quality", &settings->uints.audio_resampler_quality, true, audio_resampler_quality_level, false);

View file

@ -190,7 +190,7 @@ typedef struct settings
unsigned input_menu_toggle_gamepad_combo;
unsigned input_keyboard_gamepad_mapping_type;
unsigned input_poll_type_behavior;
unsigned input_dingux_rumble_gain;
unsigned input_rumble_gain;
unsigned input_auto_game_focus;
unsigned input_max_users;

View file

@ -550,6 +550,7 @@ input_device_driver_t ps3_joypad = {
ps3_joypad_axis,
ps3_joypad_poll,
ps3_joypad_rumble,
NULL,
ps3_joypad_name,
"ps3",
};

View file

@ -253,6 +253,7 @@ input_device_driver_t android_joypad = {
android_joypad_axis,
android_joypad_poll,
android_joypad_rumble,
NULL,
android_joypad_name,
"android",
};

View file

@ -219,6 +219,7 @@ input_device_driver_t ctr_joypad = {
ctr_joypad_axis,
ctr_joypad_poll,
NULL,
NULL,
ctr_joypad_name,
"ctr",
};

View file

@ -56,6 +56,7 @@ input_device_driver_t dinput_joypad = {
dinput_joypad_axis,
dinput_joypad_poll,
dinput_joypad_set_rumble,
NULL,
dinput_joypad_name,
"dinput",
};

View file

@ -271,6 +271,7 @@ input_device_driver_t dos_joypad = {
dos_joypad_axis,
dos_joypad_poll,
NULL,
NULL,
dos_joypad_name,
"dos",
};

View file

@ -668,6 +668,7 @@ input_device_driver_t gx_joypad = {
gx_joypad_axis,
gx_joypad_poll,
NULL,
NULL,
gx_joypad_name,
"gx",
};

View file

@ -130,6 +130,7 @@ input_device_driver_t hid_joypad = {
hid_joypad_axis,
hid_joypad_poll,
hid_joypad_rumble,
NULL,
hid_joypad_name,
"hid"
};

View file

@ -402,6 +402,7 @@ input_device_driver_t linuxraw_joypad = {
linuxraw_joypad_axis,
linuxraw_joypad_poll,
NULL,
NULL,
linuxraw_joypad_name,
"linuxraw",
};

View file

@ -481,6 +481,7 @@ input_device_driver_t mfi_joypad = {
apple_gamecontroller_joypad_axis,
apple_gamecontroller_joypad_poll,
NULL,
NULL,
apple_gamecontroller_joypad_name,
"mfi",
};

View file

@ -412,6 +412,7 @@ input_device_driver_t parport_joypad = {
parport_joypad_axis,
parport_joypad_poll,
NULL,
NULL,
parport_joypad_name,
"parport",
};

View file

@ -261,6 +261,7 @@ input_device_driver_t ps2_joypad = {
ps2_joypad_axis,
ps2_joypad_poll,
ps2_joypad_rumble,
NULL,
ps2_joypad_name,
"ps2",
};

View file

@ -289,6 +289,7 @@ input_device_driver_t ps3_joypad = {
ps3_joypad_axis,
ps3_joypad_poll,
ps3_joypad_rumble,
NULL,
ps3_joypad_name,
"ps3",
};

View file

@ -242,6 +242,7 @@ input_device_driver_t ps4_joypad = {
ps4_joypad_axis,
ps4_joypad_poll,
ps4_joypad_rumble,
NULL,
ps4_joypad_name,
"ps4",
};

View file

@ -432,6 +432,7 @@ input_device_driver_t psp_joypad = {
psp_joypad_axis,
psp_joypad_poll,
psp_joypad_rumble,
NULL,
psp_joypad_name,
#ifdef VITA
"vita",

View file

@ -163,6 +163,7 @@ input_device_driver_t qnx_joypad = {
qnx_joypad_axis,
qnx_joypad_poll,
NULL,
NULL,
qnx_joypad_name,
"qnx",
};

View file

@ -219,6 +219,7 @@ input_device_driver_t rwebpad_joypad = {
rwebpad_joypad_axis,
rwebpad_joypad_poll,
NULL,
NULL,
rwebpad_joypad_name,
"rwebpad",
};

View file

@ -29,6 +29,7 @@
#if defined(HAVE_LIBSHAKE)
#include <shake.h>
#include "../../configuration.h"
#include "../../config.def.h"
#endif
#if defined(RS90) || defined (RETROFW)
@ -100,15 +101,11 @@ static dingux_joypad_t dingux_joypad;
static bool sdl_dingux_rumble_init(dingux_joypad_rumble_t *rumble)
{
settings_t *settings = config_get_ptr();
unsigned rumble_gain = settings ? settings->uints.input_dingux_rumble_gain : 0;
unsigned rumble_gain = settings ? settings->uints.input_rumble_gain
: DEFAULT_RUMBLE_GAIN;
bool weak_uploaded = false;
bool strong_uploaded = false;
/* If gain is zero, rumble is disabled
* > No need to initialise device */
if (rumble_gain == 0)
goto error;
if (Shake_NumOfDevices() < 1)
goto error;
@ -163,8 +160,7 @@ static bool sdl_dingux_rumble_init(dingux_joypad_rumble_t *rumble)
return true;
error:
if (rumble_gain != 0)
RARCH_WARN("[libShake]: Input device does not support rumble effects.\n");
RARCH_WARN("[libShake]: Input device does not support rumble effects.\n");
if (rumble->device)
{
@ -238,7 +234,8 @@ static bool sdl_dingux_joypad_set_rumble(unsigned pad,
{
dingux_joypad_t *joypad = (dingux_joypad_t*)&dingux_joypad;
if (!joypad->rumble.device)
if ((pad != 0) ||
!joypad->rumble.device)
return false;
switch (effect)
@ -257,6 +254,27 @@ static bool sdl_dingux_joypad_set_rumble(unsigned pad,
return false;
}
static bool sdl_dingux_joypad_set_rumble_gain(unsigned pad, unsigned gain)
{
dingux_joypad_t *joypad = (dingux_joypad_t*)&dingux_joypad;
if ((pad != 0) ||
!joypad->rumble.device)
return false;
/* Gain is automatically capped by Shake_SetGain(),
* but do it explicitly here for clarity */
if (gain > 100)
gain = 100;
/* Set gain */
if (Shake_QueryGainSupport(joypad->rumble.device))
if (Shake_SetGain(joypad->rumble.device, (int)gain) == SHAKE_OK)
return true;
return false;
}
#endif
static const char *sdl_dingux_joypad_name(unsigned port)
@ -727,8 +745,10 @@ input_device_driver_t sdl_dingux_joypad = {
sdl_dingux_joypad_poll,
#if defined(HAVE_LIBSHAKE)
sdl_dingux_joypad_set_rumble,
sdl_dingux_joypad_set_rumble_gain,
#else
NULL,
NULL,
#endif
sdl_dingux_joypad_name,
"sdl_dingux",

View file

@ -535,6 +535,7 @@ input_device_driver_t sdl_joypad = {
#else
NULL,
#endif
NULL,
sdl_joypad_name,
#ifdef HAVE_SDL2
"sdl2",

View file

@ -456,6 +456,7 @@ input_device_driver_t switch_joypad = {
#else
NULL, /* set_rumble */
#endif
NULL,
switch_joypad_name,
"switch"
};

View file

@ -36,6 +36,9 @@
#include "../input_driver.h"
#include "../../configuration.h"
#include "../../config.def.h"
#include "../../tasks/tasks_internal.h"
#include "../../verbosity.h"
@ -81,6 +84,7 @@ struct udev_joypad
uint8_t axes_bind[ABS_MAX];
uint16_t strength[2];
uint16_t configured_strength[2];
unsigned rumble_gain;
char ident[255];
bool has_set_ff[2];
@ -147,6 +151,35 @@ error:
return -1;
}
static bool udev_set_rumble_gain(unsigned i, unsigned gain)
{
struct input_event ie;
struct udev_joypad *pad = (struct udev_joypad*)&udev_pads[i];
/* Does not support > 100 gains */
if ((pad->fd < 0) ||
(gain > 100))
return false;
if (pad->rumble_gain == gain)
return true;
memset(&ie, 0, sizeof(ie));
ie.type = EV_FF;
ie.code = FF_GAIN;
ie.value = 0xFFFF * (gain/100.0);
if (write(pad->fd, &ie, sizeof(ie)) < (ssize_t)sizeof(ie))
{
RARCH_ERR("[udev]: Failed to set rumble gain on pad #%u.\n", i);
return false;
}
pad->rumble_gain = gain;
return true;
}
static int udev_add_pad(struct udev_device *dev, unsigned p, int fd, const char *path)
{
int i;
@ -266,6 +299,15 @@ static int udev_add_pad(struct udev_device *dev, unsigned p, int fd, const char
p, path, pad->num_effects);
}
/* Set rumble gain here, if supported */
if (test_bit(FF_RUMBLE, ffbit))
{
settings_t *settings = config_get_ptr();
unsigned rumble_gain = settings ? settings->uints.input_rumble_gain
: DEFAULT_RUMBLE_GAIN;
udev_set_rumble_gain(p, rumble_gain);
}
return ret;
}
@ -748,6 +790,7 @@ input_device_driver_t udev_joypad = {
udev_joypad_axis,
udev_joypad_poll,
udev_set_rumble,
udev_set_rumble_gain,
udev_joypad_name,
"udev",
};

View file

@ -130,6 +130,7 @@ input_device_driver_t hidpad_driver =
hidpad_axis,
hidpad_poll,
NULL,
NULL,
hidpad_name,
"hid"
};

View file

@ -299,6 +299,7 @@ input_device_driver_t kpad_driver =
kpad_axis,
kpad_poll,
NULL,
NULL,
kpad_name,
"wiimote",
};

View file

@ -370,6 +370,7 @@ input_device_driver_t wpad_driver =
wpad_axis,
wpad_poll,
NULL,
NULL,
wpad_name,
"gamepad",
};

View file

@ -153,6 +153,7 @@ input_device_driver_t wiiu_joypad =
wiiu_joypad_axis,
wiiu_joypad_poll,
NULL,
NULL,
wiiu_joypad_name,
"wiiu",
};

View file

@ -325,6 +325,7 @@ input_device_driver_t xdk_joypad = {
xdk_joypad_axis,
xdk_joypad_poll,
NULL,
NULL,
xdk_joypad_name,
"xdk",
};

View file

@ -695,6 +695,7 @@ input_device_driver_t xinput_joypad = {
xinput_joypad_axis,
xinput_joypad_poll,
xinput_joypad_rumble,
NULL,
xinput_joypad_name,
"xinput",
};

View file

@ -395,6 +395,7 @@ input_device_driver_t xinput_joypad = {
xinput_joypad_axis,
xinput_joypad_poll,
xinput_joypad_rumble,
NULL,
xinput_joypad_name,
"xinput",
};

View file

@ -78,7 +78,8 @@ static input_device_driver_t null_joypad = {
NULL, /* get_buttons */
NULL, /* axis */
NULL, /* poll */
NULL,
NULL, /* rumble */
NULL, /* rumble_gain */
NULL, /* name */
"null",
};
@ -326,6 +327,25 @@ bool input_driver_set_rumble(
/**************************************/
bool input_driver_set_rumble_gain(
input_driver_state_t *driver_state, unsigned gain,
unsigned input_max_users)
{
unsigned i;
if (driver_state->primary_joypad
&& driver_state->primary_joypad->set_rumble_gain)
{
for (i = 0; i < input_max_users; i++)
driver_state->primary_joypad->set_rumble_gain(i, gain);
return true;
}
else
return false;
}
/**************************************/
bool input_driver_set_sensor(
input_driver_state_t *driver_state, unsigned port, bool sensors_enable,
enum retro_sensor_action action, unsigned rate)

View file

@ -340,6 +340,7 @@ struct rarch_joypad_driver
int16_t (*axis)(unsigned, uint32_t);
void (*poll)(void);
bool (*set_rumble)(unsigned, enum retro_rumble_effect, uint16_t);
bool (*set_rumble_gain)(unsigned, unsigned);
const char *(*name)(unsigned);
const char *ident;
@ -381,6 +382,18 @@ const char* config_get_input_driver_options(void);
bool input_driver_set_rumble(
input_driver_state_t *driver_state, unsigned port, unsigned joy_idx,
enum retro_rumble_effect effect, uint16_t strength);
/**
* Sets the rumble gain.
*
* @param driver_state
* @param gain Rumble gain, 0-100 [%]
* @param input_max_users
*
* @return true if the rumble gain has been successfully set
**/
bool input_driver_set_rumble_gain(
input_driver_state_t *driver_state, unsigned gain,
unsigned input_max_users);
/**
* Sets the sensor state.

View file

@ -2018,8 +2018,6 @@ MSG_HASH(
MENU_ENUM_LABEL_VALUE_ENABLE_DEVICE_VIBRATION,
"تمكين اهتزاز الجهاز (للنواة المدعومة)"
)
#if defined(DINGUX) && defined(HAVE_LIBSHAKE)
#endif
/* Settings > Input > Menu Controls */

View file

@ -902,8 +902,6 @@ MSG_HASH(
/* Settings > Input > Haptic Feedback/Vibration */
#if defined(DINGUX) && defined(HAVE_LIBSHAKE)
#endif
/* Settings > Input > Menu Controls */

View file

@ -2230,16 +2230,14 @@ MSG_HASH(
MENU_ENUM_LABEL_VALUE_ENABLE_DEVICE_VIBRATION,
"启用设备振动 (对支持的核心)"
)
#if defined(DINGUX) && defined(HAVE_LIBSHAKE)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_DINGUX_RUMBLE_GAIN,
MENU_ENUM_LABEL_VALUE_INPUT_RUMBLE_GAIN,
"振动强度 (需要重启)"
)
MSG_HASH(
MENU_ENUM_SUBLABEL_INPUT_DINGUX_RUMBLE_GAIN,
MENU_ENUM_SUBLABEL_INPUT_RUMBLE_GAIN,
"指定触觉反馈效果的强弱。"
)
#endif
/* Settings > Input > Menu Controls */

View file

@ -1822,8 +1822,6 @@ MSG_HASH(
MENU_ENUM_LABEL_VALUE_ENABLE_DEVICE_VIBRATION,
"啟用設備振動(對於支援的內核)"
)
#if defined(DINGUX) && defined(HAVE_LIBSHAKE)
#endif
/* Settings > Input > Menu Controls */

View file

@ -1114,8 +1114,6 @@ MSG_HASH(
/* Settings > Input > Haptic Feedback/Vibration */
#if defined(DINGUX) && defined(HAVE_LIBSHAKE)
#endif
/* Settings > Input > Menu Controls */

View file

@ -1098,8 +1098,6 @@ MSG_HASH(
/* Settings > Input > Haptic Feedback/Vibration */
#if defined(DINGUX) && defined(HAVE_LIBSHAKE)
#endif
/* Settings > Input > Menu Controls */

View file

@ -162,8 +162,6 @@ MSG_HASH(
/* Settings > Input > Haptic Feedback/Vibration */
#if defined(DINGUX) && defined(HAVE_LIBSHAKE)
#endif
/* Settings > Input > Menu Controls */

View file

@ -2190,16 +2190,14 @@ MSG_HASH(
MENU_ENUM_LABEL_VALUE_ENABLE_DEVICE_VIBRATION,
"Vibration aktivieren (für unterstützte Cores)"
)
#if defined(DINGUX) && defined(HAVE_LIBSHAKE)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_DINGUX_RUMBLE_GAIN,
MENU_ENUM_LABEL_VALUE_INPUT_RUMBLE_GAIN,
"Vibrationsstärke (Neustart erforderlich)"
)
MSG_HASH(
MENU_ENUM_SUBLABEL_INPUT_DINGUX_RUMBLE_GAIN,
MENU_ENUM_SUBLABEL_INPUT_RUMBLE_GAIN,
"Die Größenordnung der haptischen Feedback-Effekte angeben."
)
#endif
/* Settings > Input > Menu Controls */

View file

@ -1838,8 +1838,6 @@ MSG_HASH(
MENU_ENUM_LABEL_VALUE_ENABLE_DEVICE_VIBRATION,
"Ενεργοποίηση Δόνησης Συσκευής (Για Υποστηριζόμενους Πυρήνες)"
)
#if defined(DINGUX) && defined(HAVE_LIBSHAKE)
#endif
/* Settings > Input > Menu Controls */

View file

@ -438,8 +438,6 @@ MSG_HASH(
/* Settings > Input > Haptic Feedback/Vibration */
#if defined(DINGUX) && defined(HAVE_LIBSHAKE)
#endif
/* Settings > Input > Menu Controls */

View file

@ -2290,16 +2290,14 @@ MSG_HASH(
MENU_ENUM_LABEL_VALUE_ENABLE_DEVICE_VIBRATION,
"Activar vibración de dispositivo (en núcleos compatibles)"
)
#if defined(DINGUX) && defined(HAVE_LIBSHAKE)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_DINGUX_RUMBLE_GAIN,
MENU_ENUM_LABEL_VALUE_INPUT_RUMBLE_GAIN,
"Intensidad de vibración (es necesario reiniciar)"
)
MSG_HASH(
MENU_ENUM_SUBLABEL_INPUT_DINGUX_RUMBLE_GAIN,
MENU_ENUM_SUBLABEL_INPUT_RUMBLE_GAIN,
"Especifica la fuerza de los efectos de respuesta háptica."
)
#endif
/* Settings > Input > Menu Controls */

View file

@ -382,8 +382,6 @@ MSG_HASH(
/* Settings > Input > Haptic Feedback/Vibration */
#if defined(DINGUX) && defined(HAVE_LIBSHAKE)
#endif
/* Settings > Input > Menu Controls */

View file

@ -2246,16 +2246,14 @@ MSG_HASH(
MENU_ENUM_LABEL_VALUE_ENABLE_DEVICE_VIBRATION,
"Ota laitteen värinä käyttöön (tuetuille ytimille)"
)
#if defined(DINGUX) && defined(HAVE_LIBSHAKE)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_DINGUX_RUMBLE_GAIN,
MENU_ENUM_LABEL_VALUE_INPUT_RUMBLE_GAIN,
"Tärinän voimakkuus (Uudelleenkäynnistys vaaditaan)"
)
MSG_HASH(
MENU_ENUM_SUBLABEL_INPUT_DINGUX_RUMBLE_GAIN,
MENU_ENUM_SUBLABEL_INPUT_RUMBLE_GAIN,
"Määritä haptisen palautteen voimakkuus."
)
#endif
/* Settings > Input > Menu Controls */

View file

@ -2278,16 +2278,14 @@ MSG_HASH(
MENU_ENUM_LABEL_VALUE_ENABLE_DEVICE_VIBRATION,
"Activer la vibration du périphérique (pour les cœurs pris en charge)"
)
#if defined(DINGUX) && defined(HAVE_LIBSHAKE)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_DINGUX_RUMBLE_GAIN,
MENU_ENUM_LABEL_VALUE_INPUT_RUMBLE_GAIN,
"Force de la vibration (Redémarrage requis)"
)
MSG_HASH(
MENU_ENUM_SUBLABEL_INPUT_DINGUX_RUMBLE_GAIN,
MENU_ENUM_SUBLABEL_INPUT_RUMBLE_GAIN,
"Spécifier l'ampleur des effets de retour haptique."
)
#endif
/* Settings > Input > Menu Controls */

View file

@ -1090,8 +1090,6 @@ MSG_HASH(
/* Settings > Input > Haptic Feedback/Vibration */
#if defined(DINGUX) && defined(HAVE_LIBSHAKE)
#endif
/* Settings > Input > Menu Controls */

View file

@ -490,8 +490,6 @@ MSG_HASH(
/* Settings > Input > Haptic Feedback/Vibration */
#if defined(DINGUX) && defined(HAVE_LIBSHAKE)
#endif
/* Settings > Input > Menu Controls */

View file

@ -370,8 +370,6 @@ MSG_HASH(
/* Settings > Input > Haptic Feedback/Vibration */
#if defined(DINGUX) && defined(HAVE_LIBSHAKE)
#endif
/* Settings > Input > Menu Controls */

View file

@ -2022,16 +2022,14 @@ MSG_HASH(
MENU_ENUM_LABEL_VALUE_ENABLE_DEVICE_VIBRATION,
"Aktifkan Getaran Perangkat (Untuk Core yang Didukung)"
)
#if defined(DINGUX) && defined(HAVE_LIBSHAKE)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_DINGUX_RUMBLE_GAIN,
MENU_ENUM_LABEL_VALUE_INPUT_RUMBLE_GAIN,
"Kekuatan Getaran (Diperlukan Restart)"
)
MSG_HASH(
MENU_ENUM_SUBLABEL_INPUT_DINGUX_RUMBLE_GAIN,
MENU_ENUM_SUBLABEL_INPUT_RUMBLE_GAIN,
"Tentukan besarnya efek umpan balik haptic."
)
#endif
/* Settings > Input > Menu Controls */

View file

@ -2266,16 +2266,14 @@ MSG_HASH(
MENU_ENUM_LABEL_VALUE_ENABLE_DEVICE_VIBRATION,
"Abilita Vibrazione Dispositivo (Per i Core Supportati)"
)
#if defined(DINGUX) && defined(HAVE_LIBSHAKE)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_DINGUX_RUMBLE_GAIN,
MENU_ENUM_LABEL_VALUE_INPUT_RUMBLE_GAIN,
"Forza Vibrazione (Richiesta)"
)
MSG_HASH(
MENU_ENUM_SUBLABEL_INPUT_DINGUX_RUMBLE_GAIN,
MENU_ENUM_SUBLABEL_INPUT_RUMBLE_GAIN,
"Specifica l'entità degli effetti di feedback tattili."
)
#endif
/* Settings > Input > Menu Controls */

View file

@ -2182,16 +2182,14 @@ MSG_HASH(
MENU_ENUM_LABEL_VALUE_ENABLE_DEVICE_VIBRATION,
"(対応コアで)デバイスの振動を有効"
)
#if defined(DINGUX) && defined(HAVE_LIBSHAKE)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_DINGUX_RUMBLE_GAIN,
MENU_ENUM_LABEL_VALUE_INPUT_RUMBLE_GAIN,
"振動の強さ (再起動が必要)"
)
MSG_HASH(
MENU_ENUM_SUBLABEL_INPUT_DINGUX_RUMBLE_GAIN,
MENU_ENUM_SUBLABEL_INPUT_RUMBLE_GAIN,
"触覚フィードバック効果の大きさを指定します."
)
#endif
/* Settings > Input > Menu Controls */

View file

@ -2318,16 +2318,14 @@ MSG_HASH(
MENU_ENUM_LABEL_VALUE_ENABLE_DEVICE_VIBRATION,
"장치 진동 사용 (지원 코어 한정)"
)
#if defined(DINGUX) && defined(HAVE_LIBSHAKE)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_DINGUX_RUMBLE_GAIN,
MENU_ENUM_LABEL_VALUE_INPUT_RUMBLE_GAIN,
"진동 세기 (재시작 필요)"
)
MSG_HASH(
MENU_ENUM_SUBLABEL_INPUT_DINGUX_RUMBLE_GAIN,
MENU_ENUM_SUBLABEL_INPUT_RUMBLE_GAIN,
"햅틱 피드백으로 사용될 진동의 세기를 설정합니다."
)
#endif
/* Settings > Input > Menu Controls */

View file

@ -5038,12 +5038,10 @@ MSG_HASH(
MENU_ENUM_LABEL_INPUT_HAPTIC_FEEDBACK_SETTINGS,
"input_haptic_feedback_settings"
)
#if defined(DINGUX) && defined(HAVE_LIBSHAKE)
MSG_HASH(
MENU_ENUM_LABEL_INPUT_DINGUX_RUMBLE_GAIN,
"input_dingux_rumble_gain"
MENU_ENUM_LABEL_INPUT_RUMBLE_GAIN,
"input_rumble_gain"
)
#endif
MSG_HASH(
MENU_ENUM_LABEL_INPUT_TURBO_MODE,
"input_turbo_mode"

View file

@ -1798,8 +1798,6 @@ MSG_HASH(
MENU_ENUM_LABEL_VALUE_ENABLE_DEVICE_VIBRATION,
"Toestel trillen inschakelen (voor ondersteunde Cores)"
)
#if defined(DINGUX) && defined(HAVE_LIBSHAKE)
#endif
/* Settings > Input > Menu Controls */

View file

@ -250,8 +250,6 @@ MSG_HASH(
/* Settings > Input > Haptic Feedback/Vibration */
#if defined(DINGUX) && defined(HAVE_LIBSHAKE)
#endif
/* Settings > Input > Menu Controls */

View file

@ -2214,16 +2214,14 @@ MSG_HASH(
MENU_ENUM_LABEL_VALUE_ENABLE_DEVICE_VIBRATION,
"Włącz wibracje urządzenia (dla obsługiwanych rdzeni)"
)
#if defined(DINGUX) && defined(HAVE_LIBSHAKE)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_DINGUX_RUMBLE_GAIN,
MENU_ENUM_LABEL_VALUE_INPUT_RUMBLE_GAIN,
"Siła wibracji (wymagany restart)"
)
MSG_HASH(
MENU_ENUM_SUBLABEL_INPUT_DINGUX_RUMBLE_GAIN,
MENU_ENUM_SUBLABEL_INPUT_RUMBLE_GAIN,
"Określ skalę efektów wibracji."
)
#endif
/* Settings > Input > Menu Controls */

View file

@ -2254,16 +2254,14 @@ MSG_HASH(
MENU_ENUM_LABEL_VALUE_ENABLE_DEVICE_VIBRATION,
"Ativar vibração do dispositivo (para núcleos suportados)"
)
#if defined(DINGUX) && defined(HAVE_LIBSHAKE)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_DINGUX_RUMBLE_GAIN,
MENU_ENUM_LABEL_VALUE_INPUT_RUMBLE_GAIN,
"Força da vibração (requer reinício)"
)
MSG_HASH(
MENU_ENUM_SUBLABEL_INPUT_DINGUX_RUMBLE_GAIN,
MENU_ENUM_SUBLABEL_INPUT_RUMBLE_GAIN,
"Determine a magnitude dos efeitos do retorno táctil."
)
#endif
/* Settings > Input > Menu Controls */

View file

@ -1730,8 +1730,6 @@ MSG_HASH(
/* Settings > Input > Haptic Feedback/Vibration */
#if defined(DINGUX) && defined(HAVE_LIBSHAKE)
#endif
/* Settings > Input > Menu Controls */

View file

@ -2310,16 +2310,14 @@ MSG_HASH(
MENU_ENUM_LABEL_VALUE_ENABLE_DEVICE_VIBRATION,
"Вибрация устройством (если поддерживается ядром)"
)
#if defined(DINGUX) && defined(HAVE_LIBSHAKE)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_DINGUX_RUMBLE_GAIN,
MENU_ENUM_LABEL_VALUE_INPUT_RUMBLE_GAIN,
"Сила виброотдачи (требуется перезапуск)"
)
MSG_HASH(
MENU_ENUM_SUBLABEL_INPUT_DINGUX_RUMBLE_GAIN,
MENU_ENUM_SUBLABEL_INPUT_RUMBLE_GAIN,
"Настройка интенсивности эффекта тактильной отдачи."
)
#endif
/* Settings > Input > Menu Controls */

View file

@ -1774,8 +1774,6 @@ MSG_HASH(
/* Settings > Input > Haptic Feedback/Vibration */
#if defined(DINGUX) && defined(HAVE_LIBSHAKE)
#endif
/* Settings > Input > Menu Controls */

View file

@ -1782,8 +1782,6 @@ MSG_HASH(
MENU_ENUM_LABEL_VALUE_ENABLE_DEVICE_VIBRATION,
"Aktivera enheters vibration (för kärnor som stödjer det)"
)
#if defined(DINGUX) && defined(HAVE_LIBSHAKE)
#endif
/* Settings > Input > Menu Controls */

View file

@ -2286,16 +2286,14 @@ MSG_HASH(
MENU_ENUM_LABEL_VALUE_ENABLE_DEVICE_VIBRATION,
"Cihaz Titreşimini Etkinleştir (Desteklenen Çekirdekler İçin)"
)
#if defined(DINGUX) && defined(HAVE_LIBSHAKE)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_DINGUX_RUMBLE_GAIN,
MENU_ENUM_LABEL_VALUE_INPUT_RUMBLE_GAIN,
"Titreşim Gücü (Yeniden Başlatılmalı)"
)
MSG_HASH(
MENU_ENUM_SUBLABEL_INPUT_DINGUX_RUMBLE_GAIN,
MENU_ENUM_SUBLABEL_INPUT_RUMBLE_GAIN,
"Dokunsal geri bildirim efektlerinin büyüklüğünü belirtir."
)
#endif
/* Settings > Input > Menu Controls */

View file

@ -2222,8 +2222,6 @@ MSG_HASH(
MENU_ENUM_LABEL_VALUE_VIBRATE_ON_KEYPRESS,
"Вібрувати при натисканні клавіші"
)
#if defined(DINGUX) && defined(HAVE_LIBSHAKE)
#endif
/* Settings > Input > Menu Controls */

View file

@ -2362,16 +2362,14 @@ MSG_HASH(
MENU_ENUM_LABEL_VALUE_ENABLE_DEVICE_VIBRATION,
"Enable Device Vibration (For Supported Cores)"
)
#if defined(DINGUX) && defined(HAVE_LIBSHAKE)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_DINGUX_RUMBLE_GAIN,
"Vibration Strength (Restart Required)"
MENU_ENUM_LABEL_VALUE_INPUT_RUMBLE_GAIN,
"Vibration Strength"
)
MSG_HASH(
MENU_ENUM_SUBLABEL_INPUT_DINGUX_RUMBLE_GAIN,
MENU_ENUM_SUBLABEL_INPUT_RUMBLE_GAIN,
"Specify the magnitude of haptic feedback effects."
)
#endif
/* Settings > Input > Menu Controls */

View file

@ -634,8 +634,6 @@ MSG_HASH(
/* Settings > Input > Haptic Feedback/Vibration */
#if defined(DINGUX) && defined(HAVE_LIBSHAKE)
#endif
/* Settings > Input > Menu Controls */

View file

@ -359,9 +359,7 @@ DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_input_turbo_period, MENU_
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_input_duty_cycle, MENU_ENUM_SUBLABEL_INPUT_DUTY_CYCLE)
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_input_turbo_mode, MENU_ENUM_SUBLABEL_INPUT_TURBO_MODE)
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_input_turbo_default_button, MENU_ENUM_SUBLABEL_INPUT_TURBO_DEFAULT_BUTTON)
#if defined(DINGUX) && defined(HAVE_LIBSHAKE)
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_input_dingux_rumble_gain, MENU_ENUM_SUBLABEL_INPUT_DINGUX_RUMBLE_GAIN)
#endif
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_input_rumble_gain, MENU_ENUM_SUBLABEL_INPUT_RUMBLE_GAIN)
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_video_vertical_sync, MENU_ENUM_SUBLABEL_VIDEO_VSYNC)
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_video_adaptive_vsync, MENU_ENUM_SUBLABEL_VIDEO_ADAPTIVE_VSYNC)
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_core_allow_rotate, MENU_ENUM_SUBLABEL_VIDEO_ALLOW_ROTATE)
@ -3599,11 +3597,9 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs,
case MENU_ENUM_LABEL_INPUT_TURBO_DEFAULT_BUTTON:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_input_turbo_default_button);
break;
#if defined(DINGUX) && defined(HAVE_LIBSHAKE)
case MENU_ENUM_LABEL_INPUT_DINGUX_RUMBLE_GAIN:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_input_dingux_rumble_gain);
case MENU_ENUM_LABEL_INPUT_RUMBLE_GAIN:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_input_rumble_gain);
break;
#endif
case MENU_ENUM_LABEL_INPUT_BIND_TIMEOUT:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_input_bind_timeout);
break;

View file

@ -5593,14 +5593,10 @@ unsigned menu_displaylist_build_list(
PARSE_ONLY_BOOL, false) == 0)
count++;
}
#if defined(DINGUX) && defined(HAVE_LIBSHAKE)
if (string_is_equal(joypad_driver_id, "sdl_dingux"))
if (MENU_DISPLAYLIST_PARSE_SETTINGS_ENUM(list,
MENU_ENUM_LABEL_INPUT_DINGUX_RUMBLE_GAIN,
PARSE_ONLY_UINT, false) == 0)
if (MENU_DISPLAYLIST_PARSE_SETTINGS_ENUM(list,
MENU_ENUM_LABEL_INPUT_RUMBLE_GAIN,
PARSE_ONLY_UINT, false) == 0)
count++;
#endif
}
break;
case DISPLAYLIST_INPUT_HOTKEY_BINDS_LIST:

View file

@ -8139,6 +8139,12 @@ static void general_write_handler(rarch_setting_t *setting)
*setting->value.target.unsigned_integer);
}
break;
case MENU_ENUM_LABEL_INPUT_RUMBLE_GAIN:
{
input_set_rumble_gain(
*setting->value.target.unsigned_integer);
}
break;
case MENU_ENUM_LABEL_WIFI_ENABLED:
#ifdef HAVE_NETWORKING
if (*setting->value.target.boolean)
@ -12918,13 +12924,12 @@ static bool setting_append_list(
SD_FLAG_NONE
);
#if defined(DINGUX) && defined(HAVE_LIBSHAKE)
CONFIG_UINT(
list, list_info,
&settings->uints.input_dingux_rumble_gain,
MENU_ENUM_LABEL_INPUT_DINGUX_RUMBLE_GAIN,
MENU_ENUM_LABEL_VALUE_INPUT_DINGUX_RUMBLE_GAIN,
DEFAULT_DINGUX_RUMBLE_GAIN,
&settings->uints.input_rumble_gain,
MENU_ENUM_LABEL_INPUT_RUMBLE_GAIN,
MENU_ENUM_LABEL_VALUE_INPUT_RUMBLE_GAIN,
DEFAULT_RUMBLE_GAIN,
&group_info,
&subgroup_info,
parent_group,
@ -12932,8 +12937,9 @@ static bool setting_append_list(
general_read_handler);
(*list)[list_info->index - 1].ui_type = ST_UI_TYPE_UINT_COMBOBOX;
(*list)[list_info->index - 1].action_ok = &setting_action_ok_uint_special;
(*list)[list_info->index - 1].get_string_representation =
&setting_get_string_representation_percentage;
menu_settings_list_current_add_range(list, list_info, 0, 100, 5, true, true);
#endif
CONFIG_UINT(
list, list_info,
&settings->uints.input_poll_type_behavior,
@ -13337,17 +13343,13 @@ static bool setting_append_list(
menu_settings_list_current_add_range(list, list_info, 1, 10, 1, true, true);
SETTINGS_DATA_LIST_CURRENT_ADD_FLAGS(list, list_info, SD_FLAG_ADVANCED);
if (string_is_equal(settings->arrays.input_driver, "android") ||
string_is_equal(settings->arrays.input_joypad_driver, "sdl_dingux"))
{
CONFIG_ACTION(
list, list_info,
MENU_ENUM_LABEL_INPUT_HAPTIC_FEEDBACK_SETTINGS,
MENU_ENUM_LABEL_VALUE_INPUT_HAPTIC_FEEDBACK_SETTINGS,
&group_info,
&subgroup_info,
parent_group);
}
CONFIG_ACTION(
list, list_info,
MENU_ENUM_LABEL_INPUT_HAPTIC_FEEDBACK_SETTINGS,
MENU_ENUM_LABEL_VALUE_INPUT_HAPTIC_FEEDBACK_SETTINGS,
&group_info,
&subgroup_info,
parent_group);
CONFIG_ACTION(
list, list_info,

View file

@ -1009,6 +1009,7 @@ enum msg_hash_enums
MENU_LABEL(INPUT_ALL_USERS_CONTROL_MENU),
MENU_LABEL(INPUT_POLL_TYPE_BEHAVIOR),
MENU_LABEL(INPUT_UNIFIED_MENU_CONTROLS),
MENU_LABEL(INPUT_RUMBLE_GAIN),
MENU_LABEL(QUIT_PRESS_TWICE),
MENU_LABEL(QUIT_ON_CLOSE_CONTENT),
@ -1017,10 +1018,6 @@ enum msg_hash_enums
MENU_ENUM_LABEL_VALUE_QUIT_ON_CLOSE_CONTENT_ENABLED,
MENU_ENUM_LABEL_VALUE_QUIT_ON_CLOSE_CONTENT_CLI,
#if defined(DINGUX) && defined(HAVE_LIBSHAKE)
MENU_LABEL(INPUT_DINGUX_RUMBLE_GAIN),
#endif
/* Video */
MENU_LABEL(BRIGHTNESS_CONTROL),
MENU_LABEL(CRT_SWITCH_RESOLUTION),

View file

@ -19196,10 +19196,35 @@ bool input_set_rumble_state(unsigned port,
input_driver_state_t *input_driver_st = &(p_rarch->input_driver_state);
settings_t *settings = p_rarch->configuration_settings;
unsigned joy_idx = settings->uints.input_joypad_index[port];
unsigned rumble_gain = settings->uints.input_rumble_gain;
uint16_t scaled_strength = strength;
/* If gain setting is not suported, do software gain control */
if (!input_driver_st->primary_joypad->set_rumble_gain)
scaled_strength = (rumble_gain * strength) / 100.0;
return input_driver_set_rumble(
input_driver_st,
port, joy_idx, effect, strength);
port, joy_idx, effect, scaled_strength);
}
/**
* Sets the rumble gain. Used by MENU_ENUM_LABEL_INPUT_RUMBLE_GAIN.
*
* @param gain Rumble gain, 0-100 [%]
*
* @return true if the rumble gain has been successfully set
**/
bool input_set_rumble_gain(unsigned gain)
{
struct rarch_state *p_rarch = &rarch_st;
input_driver_state_t *input_driver_st = &(p_rarch->input_driver_state);
settings_t *settings = p_rarch->configuration_settings;
if (input_driver_set_rumble_gain(
input_driver_st, gain, settings->uints.input_max_users))
return true;
else
return false;
}
/**

View file

@ -2046,6 +2046,8 @@ void retroarch_init_task_queue(void);
bool input_set_rumble_state(unsigned port,
enum retro_rumble_effect effect, uint16_t strength);
bool input_set_rumble_gain(unsigned gain);
float input_get_sensor_state(unsigned port, unsigned id);
bool input_set_sensor_state(unsigned port,