mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-23 16:09:47 +00:00
move input_poll_overlay to input_driver.c
This commit is contained in:
parent
ddceb51f89
commit
dbe414e1e1
@ -1783,6 +1783,209 @@ void input_overlay_auto_rotate_(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void input_poll_overlay(
|
||||||
|
bool keyboard_mapping_blocked,
|
||||||
|
settings_t *settings,
|
||||||
|
void *ol_data,
|
||||||
|
enum overlay_visibility *overlay_visibility,
|
||||||
|
float opacity,
|
||||||
|
unsigned analog_dpad_mode,
|
||||||
|
float axis_threshold)
|
||||||
|
{
|
||||||
|
input_overlay_state_t old_key_state;
|
||||||
|
unsigned i, j;
|
||||||
|
input_overlay_t *ol = (input_overlay_t*)ol_data;
|
||||||
|
uint16_t key_mod = 0;
|
||||||
|
bool polled = false;
|
||||||
|
bool button_pressed = false;
|
||||||
|
input_driver_state_t *input_st = input_state_get_ptr();
|
||||||
|
void *input_data = input_st->current_data;
|
||||||
|
input_overlay_state_t *ol_state = &ol->overlay_state;
|
||||||
|
input_driver_t *current_input = input_st->current_driver;
|
||||||
|
enum overlay_show_input_type
|
||||||
|
input_overlay_show_inputs = (enum overlay_show_input_type)
|
||||||
|
settings->uints.input_overlay_show_inputs;
|
||||||
|
unsigned input_overlay_show_inputs_port = settings->uints.input_overlay_show_inputs_port;
|
||||||
|
float touch_scale = (float)settings->uints.input_touch_scale;
|
||||||
|
|
||||||
|
if (!ol_state)
|
||||||
|
return;
|
||||||
|
|
||||||
|
memcpy(old_key_state.keys, ol_state->keys,
|
||||||
|
sizeof(ol_state->keys));
|
||||||
|
memset(ol_state, 0, sizeof(*ol_state));
|
||||||
|
|
||||||
|
if (current_input->input_state)
|
||||||
|
{
|
||||||
|
rarch_joypad_info_t joypad_info;
|
||||||
|
unsigned device = ol->active->full_screen
|
||||||
|
? RARCH_DEVICE_POINTER_SCREEN
|
||||||
|
: RETRO_DEVICE_POINTER;
|
||||||
|
const input_device_driver_t
|
||||||
|
*joypad = input_st->primary_joypad;
|
||||||
|
#ifdef HAVE_MFI
|
||||||
|
const input_device_driver_t
|
||||||
|
*sec_joypad = input_st->secondary_joypad;
|
||||||
|
#else
|
||||||
|
const input_device_driver_t
|
||||||
|
*sec_joypad = NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
joypad_info.joy_idx = 0;
|
||||||
|
joypad_info.auto_binds = NULL;
|
||||||
|
joypad_info.axis_threshold = 0.0f;
|
||||||
|
|
||||||
|
for (i = 0;
|
||||||
|
current_input->input_state(
|
||||||
|
input_data,
|
||||||
|
joypad,
|
||||||
|
sec_joypad,
|
||||||
|
&joypad_info,
|
||||||
|
NULL,
|
||||||
|
keyboard_mapping_blocked,
|
||||||
|
0,
|
||||||
|
device,
|
||||||
|
i,
|
||||||
|
RETRO_DEVICE_ID_POINTER_PRESSED);
|
||||||
|
i++)
|
||||||
|
{
|
||||||
|
input_overlay_state_t polled_data;
|
||||||
|
int16_t x = current_input->input_state(
|
||||||
|
input_data,
|
||||||
|
joypad,
|
||||||
|
sec_joypad,
|
||||||
|
&joypad_info,
|
||||||
|
NULL,
|
||||||
|
keyboard_mapping_blocked,
|
||||||
|
0,
|
||||||
|
device,
|
||||||
|
i,
|
||||||
|
RETRO_DEVICE_ID_POINTER_X);
|
||||||
|
int16_t y = current_input->input_state(
|
||||||
|
input_data,
|
||||||
|
joypad,
|
||||||
|
sec_joypad,
|
||||||
|
&joypad_info,
|
||||||
|
NULL,
|
||||||
|
keyboard_mapping_blocked,
|
||||||
|
0,
|
||||||
|
device,
|
||||||
|
i,
|
||||||
|
RETRO_DEVICE_ID_POINTER_Y);
|
||||||
|
|
||||||
|
memset(&polled_data, 0, sizeof(struct input_overlay_state));
|
||||||
|
|
||||||
|
if (ol->enable)
|
||||||
|
input_overlay_poll(ol, &polled_data, x, y, touch_scale);
|
||||||
|
else
|
||||||
|
ol->blocked = false;
|
||||||
|
|
||||||
|
bits_or_bits(ol_state->buttons.data,
|
||||||
|
polled_data.buttons.data,
|
||||||
|
ARRAY_SIZE(polled_data.buttons.data));
|
||||||
|
|
||||||
|
for (j = 0; j < ARRAY_SIZE(ol_state->keys); j++)
|
||||||
|
ol_state->keys[j] |= polled_data.keys[j];
|
||||||
|
|
||||||
|
/* Fingers pressed later take priority and matched up
|
||||||
|
* with overlay poll priorities. */
|
||||||
|
for (j = 0; j < 4; j++)
|
||||||
|
if (polled_data.analog[j])
|
||||||
|
ol_state->analog[j] = polled_data.analog[j];
|
||||||
|
|
||||||
|
polled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( OVERLAY_GET_KEY(ol_state, RETROK_LSHIFT) ||
|
||||||
|
OVERLAY_GET_KEY(ol_state, RETROK_RSHIFT))
|
||||||
|
key_mod |= RETROKMOD_SHIFT;
|
||||||
|
|
||||||
|
if (OVERLAY_GET_KEY(ol_state, RETROK_LCTRL) ||
|
||||||
|
OVERLAY_GET_KEY(ol_state, RETROK_RCTRL))
|
||||||
|
key_mod |= RETROKMOD_CTRL;
|
||||||
|
|
||||||
|
if ( OVERLAY_GET_KEY(ol_state, RETROK_LALT) ||
|
||||||
|
OVERLAY_GET_KEY(ol_state, RETROK_RALT))
|
||||||
|
key_mod |= RETROKMOD_ALT;
|
||||||
|
|
||||||
|
if ( OVERLAY_GET_KEY(ol_state, RETROK_LMETA) ||
|
||||||
|
OVERLAY_GET_KEY(ol_state, RETROK_RMETA))
|
||||||
|
key_mod |= RETROKMOD_META;
|
||||||
|
|
||||||
|
/* CAPSLOCK SCROLLOCK NUMLOCK */
|
||||||
|
for (i = 0; i < ARRAY_SIZE(ol_state->keys); i++)
|
||||||
|
{
|
||||||
|
if (ol_state->keys[i] != old_key_state.keys[i])
|
||||||
|
{
|
||||||
|
uint32_t orig_bits = old_key_state.keys[i];
|
||||||
|
uint32_t new_bits = ol_state->keys[i];
|
||||||
|
|
||||||
|
for (j = 0; j < 32; j++)
|
||||||
|
if ((orig_bits & (1 << j)) != (new_bits & (1 << j)))
|
||||||
|
input_keyboard_event(new_bits & (1 << j),
|
||||||
|
i * 32 + j, 0, key_mod, RETRO_DEVICE_POINTER);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Map "analog" buttons to analog axes like regular input drivers do. */
|
||||||
|
for (j = 0; j < 4; j++)
|
||||||
|
{
|
||||||
|
unsigned bind_plus = RARCH_ANALOG_LEFT_X_PLUS + 2 * j;
|
||||||
|
unsigned bind_minus = bind_plus + 1;
|
||||||
|
|
||||||
|
if (ol_state->analog[j])
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if ((BIT256_GET(ol->overlay_state.buttons, bind_plus)))
|
||||||
|
ol_state->analog[j] += 0x7fff;
|
||||||
|
if ((BIT256_GET(ol->overlay_state.buttons, bind_minus)))
|
||||||
|
ol_state->analog[j] -= 0x7fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check for analog_dpad_mode.
|
||||||
|
* Map analogs to d-pad buttons when configured. */
|
||||||
|
switch (analog_dpad_mode)
|
||||||
|
{
|
||||||
|
case ANALOG_DPAD_LSTICK:
|
||||||
|
case ANALOG_DPAD_RSTICK:
|
||||||
|
{
|
||||||
|
float analog_x, analog_y;
|
||||||
|
unsigned analog_base = 2;
|
||||||
|
|
||||||
|
if (analog_dpad_mode == ANALOG_DPAD_LSTICK)
|
||||||
|
analog_base = 0;
|
||||||
|
|
||||||
|
analog_x = (float)ol_state->analog[analog_base + 0] / 0x7fff;
|
||||||
|
analog_y = (float)ol_state->analog[analog_base + 1] / 0x7fff;
|
||||||
|
|
||||||
|
if (analog_x <= -axis_threshold)
|
||||||
|
BIT256_SET(ol_state->buttons, RETRO_DEVICE_ID_JOYPAD_LEFT);
|
||||||
|
if (analog_x >= axis_threshold)
|
||||||
|
BIT256_SET(ol_state->buttons, RETRO_DEVICE_ID_JOYPAD_RIGHT);
|
||||||
|
if (analog_y <= -axis_threshold)
|
||||||
|
BIT256_SET(ol_state->buttons, RETRO_DEVICE_ID_JOYPAD_UP);
|
||||||
|
if (analog_y >= axis_threshold)
|
||||||
|
BIT256_SET(ol_state->buttons, RETRO_DEVICE_ID_JOYPAD_DOWN);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (input_overlay_show_inputs != OVERLAY_SHOW_INPUT_NONE)
|
||||||
|
button_pressed = input_overlay_add_inputs(ol,
|
||||||
|
(input_overlay_show_inputs == OVERLAY_SHOW_INPUT_TOUCHED),
|
||||||
|
input_overlay_show_inputs_port);
|
||||||
|
|
||||||
|
if (button_pressed || polled)
|
||||||
|
input_overlay_post_poll(overlay_visibility, ol,
|
||||||
|
button_pressed, opacity);
|
||||||
|
else
|
||||||
|
input_overlay_poll_clear(overlay_visibility, ol, opacity);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -22,16 +22,16 @@
|
|||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include "../config.h"
|
|
||||||
#endif /* HAVE_CONFIG_H */
|
|
||||||
|
|
||||||
#include <boolean.h>
|
#include <boolean.h>
|
||||||
#include <retro_common_api.h>
|
#include <retro_common_api.h>
|
||||||
#include <retro_inline.h>
|
#include <retro_inline.h>
|
||||||
#include <libretro.h>
|
#include <libretro.h>
|
||||||
#include <retro_miscellaneous.h>
|
#include <retro_miscellaneous.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "../config.h"
|
||||||
|
#endif /* HAVE_CONFIG_H */
|
||||||
|
|
||||||
#include "input_defines.h"
|
#include "input_defines.h"
|
||||||
#include "input_types.h"
|
#include "input_types.h"
|
||||||
#ifdef HAVE_OVERLAY
|
#ifdef HAVE_OVERLAY
|
||||||
@ -47,61 +47,6 @@
|
|||||||
|
|
||||||
RETRO_BEGIN_DECLS
|
RETRO_BEGIN_DECLS
|
||||||
|
|
||||||
struct retro_keybind
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Human-readable label for the control.
|
|
||||||
*/
|
|
||||||
char *joykey_label;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Human-readable label for an analog axis.
|
|
||||||
*/
|
|
||||||
char *joyaxis_label;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Joypad axis. Negative and positive axes are both represented by this variable.
|
|
||||||
*/
|
|
||||||
uint32_t joyaxis;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Default joy axis binding value for resetting bind to default.
|
|
||||||
*/
|
|
||||||
uint32_t def_joyaxis;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Used by input_{push,pop}_analog_dpad().
|
|
||||||
*/
|
|
||||||
uint32_t orig_joyaxis;
|
|
||||||
|
|
||||||
enum msg_hash_enums enum_idx;
|
|
||||||
|
|
||||||
enum retro_key key;
|
|
||||||
|
|
||||||
uint16_t id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* What mouse button ID has been mapped to this control.
|
|
||||||
*/
|
|
||||||
uint16_t mbutton;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Joypad key. Joypad POV (hats) are embedded into this key as well.
|
|
||||||
**/
|
|
||||||
uint16_t joykey;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Default key binding value (for resetting bind).
|
|
||||||
*/
|
|
||||||
uint16_t def_joykey;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determines whether or not the binding is valid.
|
|
||||||
*/
|
|
||||||
bool valid;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* line_complete callback (when carriage return is pressed)
|
* line_complete callback (when carriage return is pressed)
|
||||||
*
|
*
|
||||||
@ -871,6 +816,22 @@ const char *joypad_driver_name(unsigned i);
|
|||||||
|
|
||||||
void joypad_driver_reinit(void *data, const char *joypad_driver_name);
|
void joypad_driver_reinit(void *data, const char *joypad_driver_name);
|
||||||
|
|
||||||
|
#ifdef HAVE_OVERLAY
|
||||||
|
/*
|
||||||
|
* input_poll_overlay:
|
||||||
|
*
|
||||||
|
* Poll pressed buttons/keys on currently active overlay.
|
||||||
|
**/
|
||||||
|
void input_poll_overlay(
|
||||||
|
bool keyboard_mapping_blocked,
|
||||||
|
settings_t *settings,
|
||||||
|
void *ol_data,
|
||||||
|
enum overlay_visibility *overlay_visibility,
|
||||||
|
float opacity,
|
||||||
|
unsigned analog_dpad_mode,
|
||||||
|
float axis_threshold);
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(ANDROID)
|
#if defined(ANDROID)
|
||||||
#define DEFAULT_MAX_PADS 8
|
#define DEFAULT_MAX_PADS 8
|
||||||
#define ANDROID_KEYBOARD_PORT DEFAULT_MAX_PADS
|
#define ANDROID_KEYBOARD_PORT DEFAULT_MAX_PADS
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
#include <formats/image.h>
|
#include <formats/image.h>
|
||||||
#include <queues/task_queue.h>
|
#include <queues/task_queue.h>
|
||||||
|
|
||||||
#include "input_driver.h"
|
#include "input_types.h"
|
||||||
|
|
||||||
#define OVERLAY_GET_KEY(state, key) (((state)->keys[(key) / 32] >> ((key) % 32)) & 1)
|
#define OVERLAY_GET_KEY(state, key) (((state)->keys[(key) / 32] >> ((key) % 32)) & 1)
|
||||||
#define OVERLAY_SET_KEY(state, key) (state)->keys[(key) / 32] |= 1 << ((key) % 32)
|
#define OVERLAY_SET_KEY(state, key) (state)->keys[(key) / 32] |= 1 << ((key) % 32)
|
||||||
|
@ -23,6 +23,9 @@
|
|||||||
#include <boolean.h>
|
#include <boolean.h>
|
||||||
#include <retro_common_api.h>
|
#include <retro_common_api.h>
|
||||||
|
|
||||||
|
#include "input_defines.h"
|
||||||
|
#include "input_types.h"
|
||||||
|
|
||||||
typedef struct input_mapper
|
typedef struct input_mapper
|
||||||
{
|
{
|
||||||
/* Left X, Left Y, Right X, Right Y */
|
/* Left X, Left Y, Right X, Right Y */
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
#ifndef __INPUT_TYPES__H
|
#ifndef __INPUT_TYPES__H
|
||||||
#define __INPUT_TYPES__H
|
#define __INPUT_TYPES__H
|
||||||
|
|
||||||
|
#include "../msg_hash.h"
|
||||||
|
|
||||||
enum input_auto_game_focus_type
|
enum input_auto_game_focus_type
|
||||||
{
|
{
|
||||||
AUTO_GAME_FOCUS_OFF = 0,
|
AUTO_GAME_FOCUS_OFF = 0,
|
||||||
@ -25,11 +27,36 @@ enum input_auto_game_focus_type
|
|||||||
AUTO_GAME_FOCUS_LAST
|
AUTO_GAME_FOCUS_LAST
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct rarch_joypad_driver input_device_driver_t;
|
struct retro_keybind
|
||||||
typedef struct input_keyboard_line input_keyboard_line_t;
|
{
|
||||||
typedef struct rarch_joypad_info rarch_joypad_info_t;
|
/* Human-readable label for the control. */
|
||||||
typedef struct input_driver input_driver_t;
|
char *joykey_label;
|
||||||
typedef struct input_keyboard_ctx_wait input_keyboard_ctx_wait_t;
|
/* Human-readable label for an analog axis. */
|
||||||
|
char *joyaxis_label;
|
||||||
|
/*
|
||||||
|
* Joypad axis. Negative and positive axes are both
|
||||||
|
* represented by this variable.
|
||||||
|
*/
|
||||||
|
uint32_t joyaxis;
|
||||||
|
/* Default joy axis binding value for resetting bind to default. */
|
||||||
|
uint32_t def_joyaxis;
|
||||||
|
/* Used by input_{push,pop}_analog_dpad(). */
|
||||||
|
uint32_t orig_joyaxis;
|
||||||
|
|
||||||
|
enum msg_hash_enums enum_idx;
|
||||||
|
|
||||||
|
enum retro_key key;
|
||||||
|
|
||||||
|
uint16_t id;
|
||||||
|
/* What mouse button ID has been mapped to this control. */
|
||||||
|
uint16_t mbutton;
|
||||||
|
/* Joypad key. Joypad POV (hats) are embedded into this key as well. */
|
||||||
|
uint16_t joykey;
|
||||||
|
/* Default key binding value (for resetting bind). */
|
||||||
|
uint16_t def_joykey;
|
||||||
|
/* Determines whether or not the binding is valid. */
|
||||||
|
bool valid;
|
||||||
|
};
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
@ -38,6 +65,12 @@ typedef struct
|
|||||||
uint16_t analog_buttons[16];
|
uint16_t analog_buttons[16];
|
||||||
} input_bits_t;
|
} input_bits_t;
|
||||||
|
|
||||||
|
typedef struct rarch_joypad_driver input_device_driver_t;
|
||||||
|
typedef struct input_keyboard_line input_keyboard_line_t;
|
||||||
|
typedef struct rarch_joypad_info rarch_joypad_info_t;
|
||||||
|
typedef struct input_driver input_driver_t;
|
||||||
|
typedef struct input_keyboard_ctx_wait input_keyboard_ctx_wait_t;
|
||||||
|
|
||||||
typedef struct joypad_connection joypad_connection_t;
|
typedef struct joypad_connection joypad_connection_t;
|
||||||
typedef struct pad_connection_listener_interface pad_connection_listener_t;
|
typedef struct pad_connection_listener_interface pad_connection_listener_t;
|
||||||
|
|
||||||
|
208
retroarch.c
208
retroarch.c
@ -14794,210 +14794,6 @@ void input_overlay_set_visibility(int overlay_idx,
|
|||||||
ol->iface->set_alpha(ol->iface_data, overlay_idx, 0.0);
|
ol->iface->set_alpha(ol->iface_data, overlay_idx, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* input_poll_overlay:
|
|
||||||
*
|
|
||||||
* Poll pressed buttons/keys on currently active overlay.
|
|
||||||
**/
|
|
||||||
static void input_poll_overlay(
|
|
||||||
struct rarch_state *p_rarch,
|
|
||||||
settings_t *settings,
|
|
||||||
input_overlay_t *ol, float opacity,
|
|
||||||
unsigned analog_dpad_mode,
|
|
||||||
float axis_threshold)
|
|
||||||
{
|
|
||||||
input_overlay_state_t old_key_state;
|
|
||||||
unsigned i, j;
|
|
||||||
uint16_t key_mod = 0;
|
|
||||||
bool polled = false;
|
|
||||||
bool button_pressed = false;
|
|
||||||
input_driver_state_t *input_st = input_state_get_ptr();
|
|
||||||
void *input_data = input_st->current_data;
|
|
||||||
input_overlay_state_t *ol_state = &ol->overlay_state;
|
|
||||||
input_driver_t *current_input = input_st->current_driver;
|
|
||||||
enum overlay_show_input_type
|
|
||||||
input_overlay_show_inputs = (enum overlay_show_input_type)
|
|
||||||
settings->uints.input_overlay_show_inputs;
|
|
||||||
unsigned input_overlay_show_inputs_port = settings->uints.input_overlay_show_inputs_port;
|
|
||||||
float touch_scale = (float)settings->uints.input_touch_scale;
|
|
||||||
|
|
||||||
if (!ol_state)
|
|
||||||
return;
|
|
||||||
|
|
||||||
memcpy(old_key_state.keys, ol_state->keys,
|
|
||||||
sizeof(ol_state->keys));
|
|
||||||
memset(ol_state, 0, sizeof(*ol_state));
|
|
||||||
|
|
||||||
if (current_input->input_state)
|
|
||||||
{
|
|
||||||
rarch_joypad_info_t joypad_info;
|
|
||||||
unsigned device = ol->active->full_screen
|
|
||||||
? RARCH_DEVICE_POINTER_SCREEN
|
|
||||||
: RETRO_DEVICE_POINTER;
|
|
||||||
const input_device_driver_t
|
|
||||||
*joypad = input_st->primary_joypad;
|
|
||||||
#ifdef HAVE_MFI
|
|
||||||
const input_device_driver_t
|
|
||||||
*sec_joypad = input_st->secondary_joypad;
|
|
||||||
#else
|
|
||||||
const input_device_driver_t
|
|
||||||
*sec_joypad = NULL;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
joypad_info.joy_idx = 0;
|
|
||||||
joypad_info.auto_binds = NULL;
|
|
||||||
joypad_info.axis_threshold = 0.0f;
|
|
||||||
|
|
||||||
for (i = 0;
|
|
||||||
current_input->input_state(
|
|
||||||
input_data,
|
|
||||||
joypad,
|
|
||||||
sec_joypad,
|
|
||||||
&joypad_info,
|
|
||||||
NULL,
|
|
||||||
p_rarch->keyboard_mapping_blocked,
|
|
||||||
0,
|
|
||||||
device,
|
|
||||||
i,
|
|
||||||
RETRO_DEVICE_ID_POINTER_PRESSED);
|
|
||||||
i++)
|
|
||||||
{
|
|
||||||
input_overlay_state_t polled_data;
|
|
||||||
int16_t x = current_input->input_state(
|
|
||||||
input_data,
|
|
||||||
joypad,
|
|
||||||
sec_joypad,
|
|
||||||
&joypad_info,
|
|
||||||
NULL,
|
|
||||||
p_rarch->keyboard_mapping_blocked,
|
|
||||||
0,
|
|
||||||
device,
|
|
||||||
i,
|
|
||||||
RETRO_DEVICE_ID_POINTER_X);
|
|
||||||
int16_t y = current_input->input_state(
|
|
||||||
input_data,
|
|
||||||
joypad,
|
|
||||||
sec_joypad,
|
|
||||||
&joypad_info,
|
|
||||||
NULL,
|
|
||||||
p_rarch->keyboard_mapping_blocked,
|
|
||||||
0,
|
|
||||||
device,
|
|
||||||
i,
|
|
||||||
RETRO_DEVICE_ID_POINTER_Y);
|
|
||||||
|
|
||||||
memset(&polled_data, 0, sizeof(struct input_overlay_state));
|
|
||||||
|
|
||||||
if (ol->enable)
|
|
||||||
input_overlay_poll(ol, &polled_data, x, y, touch_scale);
|
|
||||||
else
|
|
||||||
ol->blocked = false;
|
|
||||||
|
|
||||||
bits_or_bits(ol_state->buttons.data,
|
|
||||||
polled_data.buttons.data,
|
|
||||||
ARRAY_SIZE(polled_data.buttons.data));
|
|
||||||
|
|
||||||
for (j = 0; j < ARRAY_SIZE(ol_state->keys); j++)
|
|
||||||
ol_state->keys[j] |= polled_data.keys[j];
|
|
||||||
|
|
||||||
/* Fingers pressed later take priority and matched up
|
|
||||||
* with overlay poll priorities. */
|
|
||||||
for (j = 0; j < 4; j++)
|
|
||||||
if (polled_data.analog[j])
|
|
||||||
ol_state->analog[j] = polled_data.analog[j];
|
|
||||||
|
|
||||||
polled = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( OVERLAY_GET_KEY(ol_state, RETROK_LSHIFT) ||
|
|
||||||
OVERLAY_GET_KEY(ol_state, RETROK_RSHIFT))
|
|
||||||
key_mod |= RETROKMOD_SHIFT;
|
|
||||||
|
|
||||||
if (OVERLAY_GET_KEY(ol_state, RETROK_LCTRL) ||
|
|
||||||
OVERLAY_GET_KEY(ol_state, RETROK_RCTRL))
|
|
||||||
key_mod |= RETROKMOD_CTRL;
|
|
||||||
|
|
||||||
if ( OVERLAY_GET_KEY(ol_state, RETROK_LALT) ||
|
|
||||||
OVERLAY_GET_KEY(ol_state, RETROK_RALT))
|
|
||||||
key_mod |= RETROKMOD_ALT;
|
|
||||||
|
|
||||||
if ( OVERLAY_GET_KEY(ol_state, RETROK_LMETA) ||
|
|
||||||
OVERLAY_GET_KEY(ol_state, RETROK_RMETA))
|
|
||||||
key_mod |= RETROKMOD_META;
|
|
||||||
|
|
||||||
/* CAPSLOCK SCROLLOCK NUMLOCK */
|
|
||||||
for (i = 0; i < ARRAY_SIZE(ol_state->keys); i++)
|
|
||||||
{
|
|
||||||
if (ol_state->keys[i] != old_key_state.keys[i])
|
|
||||||
{
|
|
||||||
uint32_t orig_bits = old_key_state.keys[i];
|
|
||||||
uint32_t new_bits = ol_state->keys[i];
|
|
||||||
|
|
||||||
for (j = 0; j < 32; j++)
|
|
||||||
if ((orig_bits & (1 << j)) != (new_bits & (1 << j)))
|
|
||||||
input_keyboard_event(new_bits & (1 << j),
|
|
||||||
i * 32 + j, 0, key_mod, RETRO_DEVICE_POINTER);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Map "analog" buttons to analog axes like regular input drivers do. */
|
|
||||||
for (j = 0; j < 4; j++)
|
|
||||||
{
|
|
||||||
unsigned bind_plus = RARCH_ANALOG_LEFT_X_PLUS + 2 * j;
|
|
||||||
unsigned bind_minus = bind_plus + 1;
|
|
||||||
|
|
||||||
if (ol_state->analog[j])
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if ((BIT256_GET(ol->overlay_state.buttons, bind_plus)))
|
|
||||||
ol_state->analog[j] += 0x7fff;
|
|
||||||
if ((BIT256_GET(ol->overlay_state.buttons, bind_minus)))
|
|
||||||
ol_state->analog[j] -= 0x7fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check for analog_dpad_mode.
|
|
||||||
* Map analogs to d-pad buttons when configured. */
|
|
||||||
switch (analog_dpad_mode)
|
|
||||||
{
|
|
||||||
case ANALOG_DPAD_LSTICK:
|
|
||||||
case ANALOG_DPAD_RSTICK:
|
|
||||||
{
|
|
||||||
float analog_x, analog_y;
|
|
||||||
unsigned analog_base = 2;
|
|
||||||
|
|
||||||
if (analog_dpad_mode == ANALOG_DPAD_LSTICK)
|
|
||||||
analog_base = 0;
|
|
||||||
|
|
||||||
analog_x = (float)ol_state->analog[analog_base + 0] / 0x7fff;
|
|
||||||
analog_y = (float)ol_state->analog[analog_base + 1] / 0x7fff;
|
|
||||||
|
|
||||||
if (analog_x <= -axis_threshold)
|
|
||||||
BIT256_SET(ol_state->buttons, RETRO_DEVICE_ID_JOYPAD_LEFT);
|
|
||||||
if (analog_x >= axis_threshold)
|
|
||||||
BIT256_SET(ol_state->buttons, RETRO_DEVICE_ID_JOYPAD_RIGHT);
|
|
||||||
if (analog_y <= -axis_threshold)
|
|
||||||
BIT256_SET(ol_state->buttons, RETRO_DEVICE_ID_JOYPAD_UP);
|
|
||||||
if (analog_y >= axis_threshold)
|
|
||||||
BIT256_SET(ol_state->buttons, RETRO_DEVICE_ID_JOYPAD_DOWN);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (input_overlay_show_inputs != OVERLAY_SHOW_INPUT_NONE)
|
|
||||||
button_pressed = input_overlay_add_inputs(ol,
|
|
||||||
(input_overlay_show_inputs == OVERLAY_SHOW_INPUT_TOUCHED),
|
|
||||||
input_overlay_show_inputs_port);
|
|
||||||
|
|
||||||
if (button_pressed || polled)
|
|
||||||
input_overlay_post_poll(p_rarch->overlay_visibility, ol, button_pressed, opacity);
|
|
||||||
else
|
|
||||||
input_overlay_poll_clear(p_rarch->overlay_visibility, ol, opacity);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void retroarch_overlay_deinit(struct rarch_state *p_rarch)
|
static void retroarch_overlay_deinit(struct rarch_state *p_rarch)
|
||||||
{
|
{
|
||||||
input_overlay_free(p_rarch->overlay_ptr);
|
input_overlay_free(p_rarch->overlay_ptr);
|
||||||
@ -15199,9 +14995,11 @@ static void input_driver_poll(void)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
input_poll_overlay(p_rarch,
|
input_poll_overlay(
|
||||||
|
p_rarch->keyboard_mapping_blocked,
|
||||||
settings,
|
settings,
|
||||||
p_rarch->overlay_ptr,
|
p_rarch->overlay_ptr,
|
||||||
|
p_rarch->overlay_visibility,
|
||||||
input_overlay_opacity,
|
input_overlay_opacity,
|
||||||
input_analog_dpad_mode,
|
input_analog_dpad_mode,
|
||||||
settings->floats.input_axis_threshold);
|
settings->floats.input_axis_threshold);
|
||||||
|
Loading…
Reference in New Issue
Block a user