Merge pull request #5269 from Denu8thell/overlay_controller_response

Overlay controller response
This commit is contained in:
Twinaphex 2017-08-08 19:41:33 +02:00 committed by GitHub
commit d14fa0c8b9
11 changed files with 168 additions and 4 deletions

View File

@ -1226,6 +1226,7 @@ static struct config_bool_setting *populate_settings_bool(settings_t *settings,
#ifdef HAVE_OVERLAY
SETTING_BOOL("input_overlay_enable", &settings->bools.input_overlay_enable, true, config_overlay_enable_default(), false);
SETTING_BOOL("input_overlay_enable_autopreferred", &settings->bools.input_overlay_enable_autopreferred, true, true, false);
SETTING_BOOL("input_overlay_show_physical_inputs", &settings->bools.input_overlay_show_physical_inputs, true, false, false);
SETTING_BOOL("input_overlay_hide_in_menu", &settings->bools.input_overlay_hide_in_menu, true, overlay_hide_in_menu, false);
#endif
#ifdef HAVE_COMMAND
@ -1373,6 +1374,7 @@ static struct config_uint_setting *populate_settings_uint(settings_t *settings,
#endif
SETTING_UINT("bundle_assets_extract_version_current", &settings->uints.bundle_assets_extract_version_current, true, 0, false);
SETTING_UINT("bundle_assets_extract_last_version", &settings->uints.bundle_assets_extract_last_version, true, 0, false);
SETTING_UINT("input_overlay_show_physical_inputs_port", &settings->uints.input_overlay_show_physical_inputs_port, true, 0, false);
*size = count;

View File

@ -88,6 +88,7 @@ typedef struct settings
bool input_overlay_enable;
bool input_overlay_enable_autopreferred;
bool input_overlay_hide_in_menu;
bool input_overlay_show_physical_inputs;
bool input_descriptor_label_show;
bool input_descriptor_hide_unbound;
bool input_all_users_control_menu;
@ -328,6 +329,8 @@ typedef struct settings
unsigned camera_width;
unsigned camera_height;
unsigned input_overlay_show_physical_inputs_port;
} uints;
struct

View File

@ -24,6 +24,7 @@
#ifdef HAVE_CONFIG_H
#include "../config.h"
#endif
#include "../configuration.h"
#ifdef HAVE_MENU
#include "../menu/menu_driver.h"
@ -31,8 +32,6 @@
#include "../verbosity.h"
#include "../gfx/video_driver.h"
#include "input_driver.h"
#include "input_overlay.h"
#define OVERLAY_GET_KEY(state, key) (((state)->keys[(key) / 32] >> ((key) % 32)) & 1)
@ -69,6 +68,8 @@ struct input_overlay
input_overlay_t *overlay_ptr = NULL;
static bool input_overlay_add_inputs(input_overlay_t *ol,
unsigned port, unsigned analog_dpad_mode);
/**
* input_overlay_scale:
* @ol : Overlay handle.
@ -573,8 +574,10 @@ void input_poll_overlay(input_overlay_t *ol, float opacity, unsigned analog_dpad
rarch_joypad_info_t joypad_info;
input_overlay_state_t old_key_state;
unsigned i, j, device;
settings_t *settings = config_get_ptr();
uint16_t key_mod = 0;
bool polled = false;
bool button_pressed = false;
input_overlay_state_t *ol_state = &ol->overlay_state;
if (!ol_state)
@ -702,8 +705,10 @@ void input_poll_overlay(input_overlay_t *ol, float opacity, unsigned analog_dpad
default:
break;
}
if (polled)
if(settings->bools.input_overlay_show_physical_inputs){
button_pressed = input_overlay_add_inputs(ol, settings->uints.input_overlay_show_physical_inputs_port, analog_dpad_mode);
}
if (button_pressed || polled)
input_overlay_post_poll(ol, opacity);
else
input_overlay_poll_clear(ol, opacity);
@ -745,4 +750,90 @@ void input_state_overlay(input_overlay_t *ol, int16_t *ret,
break;
}
}
/**
* input_overlay_add_inputs:
* @ol : pointer to overlay
* @port : the user to show the inputs of
*
* Adds inputs from current_input to the overlay, so it's displayed
* returns true if an input that is pressed will change the overlay
*/
static bool input_overlay_add_inputs(input_overlay_t *ol,
unsigned port, unsigned analog_dpad_mode)
{
int i;
uint64_t mask;
int id;
bool button_pressed = false;
bool current_button_pressed;
input_overlay_state_t *ol_state = &ol->overlay_state;
if(!ol_state)
return false;
for(i = 0; i < ol->active->size; i++)
{
overlay_desc_t *desc = &(ol->active->descs[i]);
switch(desc->type)
{
case OVERLAY_TYPE_BUTTONS:
mask = desc->key_mask;
id = RETRO_DEVICE_ID_JOYPAD_B;
//Need to check all bits in the mask, multiple ones can be pressed
current_button_pressed = false;
while(mask){
//Get the next button ID
while(mask && (mask & 1) == 0){
id+=1;
mask = mask >> 1;
}
//light up the button if pressed
if(input_state(port, RETRO_DEVICE_JOYPAD, 0, id)){
current_button_pressed = true;
desc->updated = true;
id+=1;
mask = mask >> 1;
}else{
//One of the buttons not pressed
current_button_pressed = false;
desc->updated = false;
break;
}
}
button_pressed = button_pressed || current_button_pressed;
break;
case OVERLAY_TYPE_ANALOG_LEFT:
case OVERLAY_TYPE_ANALOG_RIGHT:
{
float analog_x, analog_y;
float dx, dy;
unsigned int index = (desc->type == OVERLAY_TYPE_ANALOG_RIGHT) ?
RETRO_DEVICE_INDEX_ANALOG_RIGHT : RETRO_DEVICE_INDEX_ANALOG_LEFT;
analog_x = input_state(port, RETRO_DEVICE_ANALOG, index, RETRO_DEVICE_ID_ANALOG_X);
analog_y = input_state(port, RETRO_DEVICE_ANALOG, index, RETRO_DEVICE_ID_ANALOG_Y);
dx = (analog_x/0x8000)*(desc->range_x/2);
dy = (analog_y/0x8000)*(desc->range_y/2);
desc->delta_x = dx;
desc->delta_y = dy;
/*Maybe use some option here instead of 0, only display
changes greater than some magnitude.
*/
if((dx*dx) > 0 || (dy*dy) > 0)
button_pressed = true;
}
break;
case OVERLAY_TYPE_KEYBOARD:
if(input_state(port, RETRO_DEVICE_KEYBOARD, 0, desc->key_mask)){
desc->updated = true;
button_pressed = true;
}
break;
default:
break;
}
}
return button_pressed;
}

View File

@ -24,6 +24,8 @@
#include <retro_miscellaneous.h>
#include <formats/image.h>
#include "input_driver.h"
RETRO_BEGIN_DECLS
#define BOX_RADIAL 0x18df06d2U

View File

@ -479,6 +479,10 @@ MSG_HASH(MENU_ENUM_LABEL_INPUT_OVERLAY_ENABLE,
"input_overlay_enable")
MSG_HASH(MENU_ENUM_LABEL_INPUT_OVERLAY_HIDE_IN_MENU,
"overlay_hide_in_menu")
MSG_HASH(MENU_ENUM_LABEL_INPUT_OVERLAY_SHOW_PHYSICAL_INPUTS,
"overlay_show_physical_inputs")
MSG_HASH(MENU_ENUM_LABEL_INPUT_OVERLAY_SHOW_PHYSICAL_INPUTS_PORT,
"overlay_show_physical_inputs_port")
MSG_HASH(MENU_ENUM_LABEL_INPUT_PLAYER_ANALOG_DPAD_MODE,
"input_player%u_analog_dpad_mode")
MSG_HASH(MENU_ENUM_LABEL_INPUT_POLL_TYPE_BEHAVIOR,

View File

@ -572,6 +572,16 @@ int menu_hash_get_help_us_enum(enum msg_hash_enums msg, char *s, size_t len) {
"Hide the current overlay from appearing \n"
"inside the menu.");
break;
case MENU_ENUM_LABEL_INPUT_OVERLAY_SHOW_PHYSICAL_INPUTS:
snprintf(s, len,
"Show keyboard/controller button presses on \n"
"the onscreen overlay.");
break;
case MENU_ENUM_LABEL_INPUT_OVERLAY_SHOW_PHYSICAL_INPUTS_PORT:
snprintf(s, len,
"Select the port to listen for controller input \n"
"to display on the onscreen overlay.");
break;
case MENU_ENUM_LABEL_OVERLAY_PRESET:
snprintf(s, len,
"Path to input overlay.");

View File

@ -827,6 +827,10 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_OVERLAY_ENABLE,
"Display Overlay")
MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_OVERLAY_HIDE_IN_MENU,
"Hide Overlay In Menu")
MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_OVERLAY_SHOW_PHYSICAL_INPUTS,
"Show Inputs On Overlay")
MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_OVERLAY_SHOW_PHYSICAL_INPUTS_PORT,
"Show Inputs Listen Port")
MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_POLL_TYPE_BEHAVIOR,
"Poll Type Behavior")
MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_POLL_TYPE_BEHAVIOR_EARLY,
@ -2512,6 +2516,10 @@ MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_FONT_SIZE,
"Specify the font size in points.")
MSG_HASH(MENU_ENUM_SUBLABEL_INPUT_OVERLAY_HIDE_IN_MENU,
"Hide the overlay while inside the menu, and show it again when exiting the menu.")
MSG_HASH(MENU_ENUM_SUBLABEL_INPUT_OVERLAY_SHOW_PHYSICAL_INPUTS,
"Show keyboard/controller inputs on the onscreen overlay.")
MSG_HASH(MENU_ENUM_SUBLABEL_INPUT_OVERLAY_SHOW_PHYSICAL_INPUTS_PORT,
"Select the port for the overlay to listen to if Show Inputs On Overlay is enabled.")
MSG_HASH(
MENU_ENUM_SUBLABEL_CONTENT_COLLECTION_LIST,
"Scanned content will appear here."

View File

@ -225,6 +225,8 @@ default_sublabel_macro(action_bind_sublabel_sort_savefiles_enable, MENU_
default_sublabel_macro(action_bind_sublabel_sort_savestates_enable, MENU_ENUM_SUBLABEL_SORT_SAVESTATES_ENABLE)
default_sublabel_macro(action_bind_sublabel_netplay_client_swap_input, MENU_ENUM_SUBLABEL_NETPLAY_CLIENT_SWAP_INPUT)
default_sublabel_macro(action_bind_sublabel_core_updater_buildbot_url, MENU_ENUM_SUBLABEL_CORE_UPDATER_BUILDBOT_URL)
default_sublabel_macro(action_bind_sublabel_input_overlay_show_physical_inputs, MENU_ENUM_SUBLABEL_INPUT_OVERLAY_SHOW_PHYSICAL_INPUTS)
default_sublabel_macro(action_bind_sublabel_input_overlay_show_physical_inputs_port, MENU_ENUM_SUBLABEL_INPUT_OVERLAY_SHOW_PHYSICAL_INPUTS_PORT)
default_sublabel_macro(action_bind_sublabel_core_updater_buildbot_assets_url, MENU_ENUM_SUBLABEL_BUILDBOT_ASSETS_URL)
default_sublabel_macro(action_bind_sublabel_core_updater_auto_extract_archive, MENU_ENUM_SUBLABEL_CORE_UPDATER_AUTO_EXTRACT_ARCHIVE)
default_sublabel_macro(action_bind_sublabel_netplay_refresh_rooms, MENU_ENUM_SUBLABEL_NETPLAY_REFRESH_ROOMS)
@ -949,6 +951,12 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs,
case MENU_ENUM_LABEL_INPUT_OVERLAY_HIDE_IN_MENU:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_input_overlay_hide_in_menu);
break;
case MENU_ENUM_LABEL_INPUT_OVERLAY_SHOW_PHYSICAL_INPUTS:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_input_overlay_show_physical_inputs);
break;
case MENU_ENUM_LABEL_INPUT_OVERLAY_SHOW_PHYSICAL_INPUTS_PORT:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_input_overlay_show_physical_inputs_port);
break;
case MENU_ENUM_LABEL_VIDEO_FONT_SIZE:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_video_font_size);
break;

View File

@ -5007,6 +5007,12 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data)
menu_displaylist_parse_settings_enum(menu, info,
MENU_ENUM_LABEL_INPUT_OVERLAY_HIDE_IN_MENU,
PARSE_ONLY_BOOL, false);
menu_displaylist_parse_settings_enum(menu, info,
MENU_ENUM_LABEL_INPUT_OVERLAY_SHOW_PHYSICAL_INPUTS,
PARSE_ONLY_BOOL, false);
menu_displaylist_parse_settings_enum(menu, info,
MENU_ENUM_LABEL_INPUT_OVERLAY_SHOW_PHYSICAL_INPUTS_PORT,
PARSE_ONLY_UINT, false);
menu_displaylist_parse_settings_enum(menu, info,
MENU_ENUM_LABEL_OVERLAY_PRESET,
PARSE_ONLY_PATH, false);

View File

@ -4891,6 +4891,34 @@ static bool setting_append_list(
);
(*list)[list_info->index - 1].change_handler = overlay_enable_toggle_change_handler;
CONFIG_BOOL(
list, list_info,
&settings->bools.input_overlay_show_physical_inputs,
MENU_ENUM_LABEL_INPUT_OVERLAY_SHOW_PHYSICAL_INPUTS,
MENU_ENUM_LABEL_VALUE_INPUT_OVERLAY_SHOW_PHYSICAL_INPUTS,
false,
MENU_ENUM_LABEL_VALUE_OFF,
MENU_ENUM_LABEL_VALUE_ON,
&group_info,
&subgroup_info,
parent_group,
general_write_handler,
general_read_handler,
SD_FLAG_NONE
);
CONFIG_UINT(
list, list_info,
&settings->uints.input_overlay_show_physical_inputs_port,
MENU_ENUM_LABEL_INPUT_OVERLAY_SHOW_PHYSICAL_INPUTS_PORT,
MENU_ENUM_LABEL_VALUE_INPUT_OVERLAY_SHOW_PHYSICAL_INPUTS_PORT,
0,
&group_info,
&subgroup_info,
parent_group,
general_write_handler,
general_read_handler
);
menu_settings_list_current_add_range(list, list_info, 0, MAX_USERS - 1, 1, true, true);
CONFIG_PATH(
list, list_info,
settings->paths.path_overlay,

View File

@ -598,6 +598,8 @@ enum msg_hash_enums
MENU_LABEL(INPUT_OSK_OVERLAY_ENABLE),
MENU_LABEL(INPUT_MENU_ENUM_TOGGLE_GAMEPAD_COMBO),
MENU_LABEL(INPUT_OVERLAY_HIDE_IN_MENU),
MENU_LABEL(INPUT_OVERLAY_SHOW_PHYSICAL_INPUTS),
MENU_LABEL(INPUT_OVERLAY_SHOW_PHYSICAL_INPUTS_PORT),
MENU_LABEL(INPUT_KEYBOARD_GAMEPAD_MAPPING_TYPE),
MENU_LABEL(INPUT_SMALL_KEYBOARD_ENABLE),
MENU_LABEL(INPUT_TOUCH_ENABLE),