Added button press lightup on overlay.

input_overlay_add_inputs added, still need to implement dpad and analog visuals on overlay. Also still needs to be restructured so input_overlay_post_poll is only called once.
This commit is contained in:
denu8thell 2017-08-07 21:59:05 -05:00
parent b6cd19a83c
commit c882e64653
3 changed files with 67 additions and 4 deletions

View File

@ -413,12 +413,22 @@ void input_poll(void)
return;
#ifdef HAVE_OVERLAY
if (overlay_ptr && input_overlay_is_alive(overlay_ptr))
if (overlay_ptr && input_overlay_is_alive(overlay_ptr)){
input_poll_overlay(
overlay_ptr,
settings->floats.input_overlay_opacity,
settings->uints.input_analog_dpad_mode[0],
input_driver_axis_threshold);
rarch_joypad_info_t joypad_info;
//TODO: Make this work for an arbitrary joypad, set up in the settings
joypad_info.axis_threshold = input_driver_axis_threshold;
joypad_info.joy_idx = settings->uints.input_joypad_map[0];
joypad_info.auto_binds = input_autoconf_binds[joypad_info.joy_idx];
input_overlay_add_inputs(overlay_ptr, &joypad_info, libretro_input_binds, 0,
RETRO_DEVICE_JOYPAD, settings->uints.input_analog_dpad_mode[0]);
}
#endif
#ifdef HAVE_COMMAND

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)
@ -573,6 +572,7 @@ 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;
input_overlay_state_t *ol_state = &ol->overlay_state;
@ -702,7 +702,7 @@ void input_poll_overlay(input_overlay_t *ol, float opacity, unsigned analog_dpad
default:
break;
}
if (polled)
input_overlay_post_poll(ol, opacity);
else
@ -746,3 +746,46 @@ void input_state_overlay(input_overlay_t *ol, int16_t *ret,
}
}
void input_overlay_add_inputs(input_overlay_t *ol, rarch_joypad_info_t *joy_info, const struct retro_keybind **keybinds,
unsigned port, unsigned device, unsigned analog_dpad_mode)
{
int i;
uint64_t mask;
int id;
//Only do joypad stuff for now
if(device == RETRO_DEVICE_JOYPAD){
input_overlay_state_t *ol_state = &ol->overlay_state;
for(i = 0; i < ol->active->size; i++)
{
overlay_desc_t *desc = &(ol->active->descs[i]);
switch(desc->type)
{
case OVERLAY_TYPE_BUTTONS:
//Get the button ID
mask = desc->key_mask;
id = RETRO_DEVICE_ID_JOYPAD_B-1;
while(mask > 0){
id+=1;
mask = mask >> 1;
}
if(current_input->input_state(current_input_data, *joy_info,
keybinds,
port, device, joy_info->joy_idx, id)){
RARCH_LOG_OUTPUT("pressed button %d\n", id);
desc->updated = true;
}
break;
case OVERLAY_TYPE_ANALOG_LEFT:
break;
case OVERLAY_TYPE_ANALOG_RIGHT:
break;
case OVERLAY_TYPE_KEYBOARD:
break;
default:
break;
}
}
}
settings_t *settings = config_get_ptr();
input_overlay_post_poll(ol, settings->floats.input_overlay_opacity);
}

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
@ -242,6 +244,14 @@ void input_poll_overlay(input_overlay_t *ol, float opacity, unsigned analog_dpad
void input_state_overlay(input_overlay_t *ol,
int16_t *ret, unsigned port, unsigned device, unsigned idx,
unsigned id);
/**
* input_overlay_add_inputs:
* @ol : pointer to overlay
*
* Adds inputs from current_input to the overlay, so it's displayed
*/
void input_overlay_add_inputs(input_overlay_t *ol, rarch_joypad_info_t *joy_info, const struct retro_keybind **keybinds,
unsigned port, unsigned device, unsigned analog_dpad_mode);
bool input_overlay_key_pressed(input_overlay_t *ol, int key);