2012-12-20 11:24:49 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
2014-01-01 00:50:59 +00:00
|
|
|
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
2015-01-07 16:46:50 +00:00
|
|
|
* Copyright (C) 2011-2015 - Daniel De Matteis
|
2014-01-08 17:14:50 +00:00
|
|
|
*
|
2012-12-20 11:24:49 +00:00
|
|
|
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
|
|
|
* of the GNU General Public License as published by the Free Software Found-
|
|
|
|
* ation, either version 3 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE. See the GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with RetroArch.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2015-01-29 19:33:27 +00:00
|
|
|
#include <stdlib.h>
|
2015-06-14 14:53:09 +00:00
|
|
|
#include <stddef.h>
|
2015-01-29 19:33:27 +00:00
|
|
|
#include <string.h>
|
2015-06-14 14:53:09 +00:00
|
|
|
#include <math.h>
|
|
|
|
|
2014-10-21 05:58:58 +00:00
|
|
|
#include <compat/posix_string.h>
|
2014-10-21 22:23:06 +00:00
|
|
|
#include <file/file_path.h>
|
2015-09-01 09:59:27 +00:00
|
|
|
#include <retro_assert.h>
|
2015-03-19 03:28:40 +00:00
|
|
|
#include <string/string_list.h>
|
2015-07-11 05:51:34 +00:00
|
|
|
#include <file/config_file.h>
|
2015-07-11 06:14:39 +00:00
|
|
|
#include <formats/image.h>
|
2014-10-26 01:18:56 +00:00
|
|
|
#include <clamping.h>
|
2015-06-14 14:53:09 +00:00
|
|
|
#include <rhash.h>
|
|
|
|
|
2015-09-06 12:59:20 +00:00
|
|
|
#include "input_overlay.h"
|
2015-11-28 15:13:16 +00:00
|
|
|
#include "input_keyboard.h"
|
2015-09-06 12:59:20 +00:00
|
|
|
|
2015-07-08 23:10:30 +00:00
|
|
|
#include "../configuration.h"
|
2015-11-23 11:03:38 +00:00
|
|
|
#include "../verbosity.h"
|
2015-11-23 17:15:19 +00:00
|
|
|
#include "../tasks/tasks.h"
|
2015-06-14 14:53:09 +00:00
|
|
|
|
2015-07-11 06:07:14 +00:00
|
|
|
struct input_overlay
|
|
|
|
{
|
|
|
|
void *iface_data;
|
|
|
|
const video_overlay_interface_t *iface;
|
|
|
|
bool enable;
|
|
|
|
|
|
|
|
bool blocked;
|
2015-07-11 21:45:23 +00:00
|
|
|
bool alive;
|
2015-07-11 06:07:14 +00:00
|
|
|
|
|
|
|
struct overlay *overlays;
|
|
|
|
const struct overlay *active;
|
|
|
|
size_t index;
|
|
|
|
size_t size;
|
|
|
|
|
|
|
|
unsigned next_index;
|
|
|
|
enum overlay_status state;
|
|
|
|
};
|
|
|
|
|
2015-09-06 01:25:57 +00:00
|
|
|
typedef struct input_overlay_state
|
|
|
|
{
|
|
|
|
/* This is a bitmask of (1 << key_bind_id). */
|
|
|
|
uint64_t buttons;
|
|
|
|
/* Left X, Left Y, Right X, Right Y */
|
|
|
|
int16_t analog[4];
|
|
|
|
|
|
|
|
uint32_t keys[RETROK_LAST / 32 + 1];
|
|
|
|
} input_overlay_state_t;
|
|
|
|
|
2015-07-08 23:10:30 +00:00
|
|
|
static input_overlay_t *overlay_ptr;
|
2015-07-11 20:45:02 +00:00
|
|
|
static input_overlay_state_t overlay_st_ptr;
|
2015-07-08 23:10:30 +00:00
|
|
|
|
2015-07-12 05:22:52 +00:00
|
|
|
static input_overlay_state_t *input_overlay_get_state_ptr(void)
|
2015-07-08 23:10:30 +00:00
|
|
|
{
|
2015-07-11 20:45:02 +00:00
|
|
|
return &overlay_st_ptr;
|
2015-07-08 23:10:30 +00:00
|
|
|
}
|
|
|
|
|
2015-07-11 21:45:23 +00:00
|
|
|
bool input_overlay_data_is_active(void)
|
2015-07-08 23:10:30 +00:00
|
|
|
{
|
2015-08-06 03:14:12 +00:00
|
|
|
input_overlay_t *overlay = overlay_ptr;
|
2015-07-08 23:10:30 +00:00
|
|
|
if (!overlay)
|
|
|
|
return false;
|
|
|
|
|
2015-07-11 21:45:23 +00:00
|
|
|
if (overlay->alive)
|
2015-07-08 23:10:30 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-01-18 08:25:48 +00:00
|
|
|
/**
|
|
|
|
* input_overlay_scale:
|
|
|
|
* @ol : Overlay handle.
|
|
|
|
* @scale : Scaling factor.
|
|
|
|
*
|
|
|
|
* Scales overlay and all its associated descriptors
|
|
|
|
* by a given scaling factor (@scale).
|
|
|
|
**/
|
|
|
|
static void input_overlay_scale(struct overlay *ol, float scale)
|
2013-02-03 22:35:55 +00:00
|
|
|
{
|
2013-10-22 13:08:17 +00:00
|
|
|
size_t i;
|
2015-01-14 22:15:24 +00:00
|
|
|
|
2015-02-15 06:01:32 +00:00
|
|
|
if (!ol)
|
|
|
|
return;
|
|
|
|
|
2015-01-18 08:25:48 +00:00
|
|
|
if (ol->block_scale)
|
2013-10-16 14:59:24 +00:00
|
|
|
scale = 1.0f;
|
|
|
|
|
2015-01-18 08:25:48 +00:00
|
|
|
ol->scale = scale;
|
|
|
|
ol->mod_w = ol->w * scale;
|
|
|
|
ol->mod_h = ol->h * scale;
|
|
|
|
ol->mod_x = ol->center_x +
|
|
|
|
(ol->x - ol->center_x) * scale;
|
|
|
|
ol->mod_y = ol->center_y +
|
|
|
|
(ol->y - ol->center_y) * scale;
|
2013-10-16 14:59:24 +00:00
|
|
|
|
2015-01-18 08:25:48 +00:00
|
|
|
for (i = 0; i < ol->size; i++)
|
2013-02-03 22:35:55 +00:00
|
|
|
{
|
2015-01-14 22:15:24 +00:00
|
|
|
float scale_w, scale_h, adj_center_x, adj_center_y;
|
2015-01-18 08:25:48 +00:00
|
|
|
struct overlay_desc *desc = &ol->descs[i];
|
2013-10-21 12:26:42 +00:00
|
|
|
|
2015-01-18 08:25:48 +00:00
|
|
|
if (!desc)
|
|
|
|
continue;
|
|
|
|
|
2015-07-11 23:33:14 +00:00
|
|
|
scale_w = ol->mod_w * desc->range_x;
|
|
|
|
scale_h = ol->mod_h * desc->range_y;
|
2013-10-21 12:26:42 +00:00
|
|
|
|
2015-07-11 23:33:14 +00:00
|
|
|
desc->mod_w = 2.0f * scale_w;
|
|
|
|
desc->mod_h = 2.0f * scale_h;
|
2013-10-21 12:26:42 +00:00
|
|
|
|
2015-01-18 08:25:48 +00:00
|
|
|
adj_center_x = ol->mod_x + desc->x * ol->mod_w;
|
|
|
|
adj_center_y = ol->mod_y + desc->y * ol->mod_h;
|
2015-07-11 23:33:14 +00:00
|
|
|
desc->mod_x = adj_center_x - scale_w;
|
|
|
|
desc->mod_y = adj_center_y - scale_h;
|
2013-02-03 22:35:55 +00:00
|
|
|
}
|
2013-10-16 14:59:24 +00:00
|
|
|
}
|
|
|
|
|
2015-07-12 05:22:52 +00:00
|
|
|
static void input_overlay_set_vertex_geom(void)
|
2013-10-16 14:59:24 +00:00
|
|
|
{
|
2013-10-22 13:08:17 +00:00
|
|
|
size_t i;
|
2015-08-06 03:14:12 +00:00
|
|
|
input_overlay_t *ol = overlay_ptr;
|
2015-01-09 23:21:27 +00:00
|
|
|
|
2015-02-15 06:01:32 +00:00
|
|
|
if (!ol)
|
|
|
|
return;
|
2013-12-31 18:03:58 +00:00
|
|
|
if (ol->active->image.pixels)
|
2013-10-16 14:59:24 +00:00
|
|
|
ol->iface->vertex_geom(ol->iface_data, 0,
|
2014-09-02 14:50:28 +00:00
|
|
|
ol->active->mod_x, ol->active->mod_y,
|
|
|
|
ol->active->mod_w, ol->active->mod_h);
|
2013-10-16 14:59:24 +00:00
|
|
|
|
2013-10-22 13:08:17 +00:00
|
|
|
for (i = 0; i < ol->active->size; i++)
|
2013-02-03 22:35:55 +00:00
|
|
|
{
|
2013-10-16 14:59:24 +00:00
|
|
|
struct overlay_desc *desc = &ol->active->descs[i];
|
2015-01-09 23:21:27 +00:00
|
|
|
|
|
|
|
if (!desc)
|
|
|
|
continue;
|
|
|
|
|
2015-01-14 22:15:24 +00:00
|
|
|
if (!desc->image.pixels)
|
|
|
|
continue;
|
|
|
|
|
2015-07-11 23:33:14 +00:00
|
|
|
if (ol->iface && ol->iface->vertex_geom)
|
|
|
|
ol->iface->vertex_geom(ol->iface_data, desc->image_index,
|
|
|
|
desc->mod_x, desc->mod_y, desc->mod_w, desc->mod_h);
|
2013-02-03 22:35:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-09 23:59:05 +00:00
|
|
|
/**
|
|
|
|
* input_overlay_set_scale_factor:
|
|
|
|
* @ol : Overlay handle.
|
|
|
|
* @scale : Factor of scale to apply.
|
|
|
|
*
|
|
|
|
* Scales the overlay by a factor of scale.
|
|
|
|
**/
|
2015-07-12 05:22:52 +00:00
|
|
|
void input_overlay_set_scale_factor(float scale)
|
2013-02-03 22:35:55 +00:00
|
|
|
{
|
2013-10-22 13:08:17 +00:00
|
|
|
size_t i;
|
2015-08-06 03:14:12 +00:00
|
|
|
input_overlay_t *ol = overlay_ptr;
|
2014-09-28 15:52:15 +00:00
|
|
|
|
|
|
|
if (!ol)
|
|
|
|
return;
|
|
|
|
|
2013-10-22 13:08:17 +00:00
|
|
|
for (i = 0; i < ol->size; i++)
|
2013-02-03 22:35:55 +00:00
|
|
|
input_overlay_scale(&ol->overlays[i], scale);
|
|
|
|
|
2015-07-12 05:22:52 +00:00
|
|
|
input_overlay_set_vertex_geom();
|
2013-02-03 22:35:55 +00:00
|
|
|
}
|
|
|
|
|
2015-11-25 01:17:38 +00:00
|
|
|
void input_overlay_free_overlay(struct overlay *overlay)
|
2012-12-22 12:27:00 +00:00
|
|
|
{
|
2013-10-22 13:08:17 +00:00
|
|
|
size_t i;
|
2014-05-10 18:26:58 +00:00
|
|
|
|
2014-09-15 12:17:16 +00:00
|
|
|
if (!overlay)
|
|
|
|
return;
|
|
|
|
|
2014-05-28 19:14:11 +00:00
|
|
|
for (i = 0; i < overlay->size; i++)
|
2014-06-17 15:44:48 +00:00
|
|
|
texture_image_free(&overlay->descs[i].image);
|
2014-05-10 18:26:58 +00:00
|
|
|
|
2015-07-11 20:07:05 +00:00
|
|
|
if (overlay->load_images)
|
|
|
|
free(overlay->load_images);
|
|
|
|
overlay->load_images = NULL;
|
|
|
|
if (overlay->descs)
|
|
|
|
free(overlay->descs);
|
|
|
|
overlay->descs = NULL;
|
2014-06-17 15:44:48 +00:00
|
|
|
texture_image_free(&overlay->image);
|
2012-12-22 12:27:00 +00:00
|
|
|
}
|
|
|
|
|
2015-11-23 20:02:36 +00:00
|
|
|
static void input_overlay_free_overlays(input_overlay_t *ol)
|
2012-12-22 12:27:00 +00:00
|
|
|
{
|
2013-10-22 13:08:17 +00:00
|
|
|
size_t i;
|
2014-09-15 12:17:16 +00:00
|
|
|
|
|
|
|
if (!ol)
|
|
|
|
return;
|
|
|
|
|
2013-10-22 13:08:17 +00:00
|
|
|
for (i = 0; i < ol->size; i++)
|
2012-12-22 12:27:00 +00:00
|
|
|
input_overlay_free_overlay(&ol->overlays[i]);
|
2014-09-15 12:17:16 +00:00
|
|
|
|
2015-07-11 23:33:14 +00:00
|
|
|
if (ol->overlays)
|
|
|
|
free(ol->overlays);
|
|
|
|
ol->overlays = NULL;
|
2012-12-22 12:27:00 +00:00
|
|
|
}
|
|
|
|
|
2015-07-12 05:22:52 +00:00
|
|
|
static void input_overlay_load_active(float opacity)
|
2015-02-27 01:26:15 +00:00
|
|
|
{
|
2015-08-06 03:14:12 +00:00
|
|
|
input_overlay_t *ol = overlay_ptr;
|
2015-02-27 01:26:15 +00:00
|
|
|
if (!ol)
|
|
|
|
return;
|
|
|
|
|
2015-07-11 23:33:14 +00:00
|
|
|
if (ol->iface && ol->iface->load)
|
|
|
|
ol->iface->load(ol->iface_data, ol->active->load_images,
|
|
|
|
ol->active->load_images_size);
|
2015-02-27 01:26:15 +00:00
|
|
|
|
2015-07-12 05:22:52 +00:00
|
|
|
input_overlay_set_alpha_mod(opacity);
|
|
|
|
input_overlay_set_vertex_geom();
|
2015-07-11 23:33:14 +00:00
|
|
|
|
|
|
|
if (ol->iface && ol->iface->full_screen)
|
|
|
|
ol->iface->full_screen(ol->iface_data, ol->active->full_screen);
|
2015-02-27 01:26:15 +00:00
|
|
|
}
|
|
|
|
|
2015-07-12 05:32:51 +00:00
|
|
|
/**
|
|
|
|
* input_overlay_enable:
|
|
|
|
* @enable : Enable or disable the overlay
|
|
|
|
*
|
|
|
|
* Enable or disable the overlay.
|
|
|
|
**/
|
|
|
|
static void input_overlay_enable(bool enable)
|
|
|
|
{
|
2015-08-06 03:14:12 +00:00
|
|
|
input_overlay_t *ol = overlay_ptr;
|
2015-07-12 05:32:51 +00:00
|
|
|
if (!ol)
|
|
|
|
return;
|
|
|
|
ol->enable = enable;
|
|
|
|
|
|
|
|
if (ol->iface && ol->iface->enable)
|
|
|
|
ol->iface->enable(ol->iface_data, enable);
|
|
|
|
}
|
|
|
|
|
2015-01-09 23:59:05 +00:00
|
|
|
/**
|
|
|
|
* inside_hitbox:
|
|
|
|
* @desc : Overlay descriptor handle.
|
|
|
|
* @x : X coordinate value.
|
|
|
|
* @y : Y coordinate value.
|
|
|
|
*
|
|
|
|
* Check whether the given @x and @y coordinates of the overlay
|
|
|
|
* descriptor @desc is inside the overlay descriptor's hitbox.
|
|
|
|
*
|
|
|
|
* Returns: true (1) if X, Y coordinates are inside a hitbox, otherwise false (0).
|
|
|
|
**/
|
2012-12-22 12:27:00 +00:00
|
|
|
static bool inside_hitbox(const struct overlay_desc *desc, float x, float y)
|
2012-12-20 11:24:49 +00:00
|
|
|
{
|
2015-02-15 06:01:32 +00:00
|
|
|
if (!desc)
|
|
|
|
return false;
|
|
|
|
|
2012-12-22 12:27:00 +00:00
|
|
|
switch (desc->hitbox)
|
|
|
|
{
|
|
|
|
case OVERLAY_HITBOX_RADIAL:
|
|
|
|
{
|
2014-09-02 14:50:28 +00:00
|
|
|
/* Ellipsis. */
|
2015-01-14 22:15:24 +00:00
|
|
|
float x_dist = (x - desc->x) / desc->range_x_mod;
|
|
|
|
float y_dist = (y - desc->y) / desc->range_y_mod;
|
2012-12-22 12:27:00 +00:00
|
|
|
float sq_dist = x_dist * x_dist + y_dist * y_dist;
|
2015-01-14 22:15:24 +00:00
|
|
|
return (sq_dist <= 1.0f);
|
2012-12-22 12:27:00 +00:00
|
|
|
}
|
2014-01-08 17:14:50 +00:00
|
|
|
|
2012-12-22 12:27:00 +00:00
|
|
|
case OVERLAY_HITBOX_RECT:
|
2013-10-21 10:42:47 +00:00
|
|
|
return (fabs(x - desc->x) <= desc->range_x_mod) &&
|
|
|
|
(fabs(y - desc->y) <= desc->range_y_mod);
|
2012-12-22 12:27:00 +00:00
|
|
|
}
|
2014-09-15 05:03:54 +00:00
|
|
|
|
|
|
|
return false;
|
2012-12-22 12:27:00 +00:00
|
|
|
}
|
2012-12-20 11:24:49 +00:00
|
|
|
|
2015-01-09 23:59:05 +00:00
|
|
|
/**
|
|
|
|
* input_overlay_poll:
|
|
|
|
* @out : Polled output data.
|
|
|
|
* @norm_x : Normalized X coordinate.
|
|
|
|
* @norm_y : Normalized Y coordinate.
|
|
|
|
*
|
|
|
|
* Polls input overlay.
|
|
|
|
*
|
|
|
|
* @norm_x and @norm_y are the result of
|
|
|
|
* input_translate_coord_viewport().
|
|
|
|
**/
|
2015-07-12 05:28:28 +00:00
|
|
|
static void input_overlay_poll(input_overlay_state_t *out,
|
2014-09-02 14:50:28 +00:00
|
|
|
int16_t norm_x, int16_t norm_y)
|
2012-12-20 11:24:49 +00:00
|
|
|
{
|
2013-10-22 13:08:17 +00:00
|
|
|
size_t i;
|
2015-01-09 23:21:27 +00:00
|
|
|
float x, y;
|
2015-08-06 03:14:12 +00:00
|
|
|
input_overlay_t *ol = overlay_ptr;
|
2015-01-09 23:21:27 +00:00
|
|
|
|
2013-09-05 22:19:07 +00:00
|
|
|
memset(out, 0, sizeof(*out));
|
|
|
|
|
2012-12-20 14:37:04 +00:00
|
|
|
if (!ol->enable)
|
2013-02-17 14:00:38 +00:00
|
|
|
{
|
|
|
|
ol->blocked = false;
|
2013-09-05 22:19:07 +00:00
|
|
|
return;
|
2013-02-17 14:00:38 +00:00
|
|
|
}
|
2012-12-20 14:37:04 +00:00
|
|
|
|
2014-09-02 14:50:28 +00:00
|
|
|
/* norm_x and norm_y is in [-0x7fff, 0x7fff] range,
|
|
|
|
* like RETRO_DEVICE_POINTER. */
|
2015-01-09 23:21:27 +00:00
|
|
|
x = (float)(norm_x + 0x7fff) / 0xffff;
|
|
|
|
y = (float)(norm_y + 0x7fff) / 0xffff;
|
2012-12-20 11:24:49 +00:00
|
|
|
|
2013-05-17 22:18:24 +00:00
|
|
|
x -= ol->active->mod_x;
|
|
|
|
y -= ol->active->mod_y;
|
|
|
|
x /= ol->active->mod_w;
|
|
|
|
y /= ol->active->mod_h;
|
2012-12-22 15:09:15 +00:00
|
|
|
|
2013-10-22 13:08:17 +00:00
|
|
|
for (i = 0; i < ol->active->size; i++)
|
2012-12-20 11:24:49 +00:00
|
|
|
{
|
2015-01-18 08:25:48 +00:00
|
|
|
float x_dist, y_dist;
|
2013-10-21 10:42:47 +00:00
|
|
|
struct overlay_desc *desc = &ol->active->descs[i];
|
2015-01-09 23:21:27 +00:00
|
|
|
|
2015-02-15 06:01:32 +00:00
|
|
|
if (!desc)
|
|
|
|
continue;
|
2013-10-21 10:42:47 +00:00
|
|
|
if (!inside_hitbox(desc, x, y))
|
2013-09-05 15:38:00 +00:00
|
|
|
continue;
|
|
|
|
|
2013-12-27 01:37:52 +00:00
|
|
|
desc->updated = true;
|
2015-03-22 07:14:36 +00:00
|
|
|
x_dist = x - desc->x;
|
|
|
|
y_dist = y - desc->y;
|
2015-01-18 08:25:48 +00:00
|
|
|
|
2015-07-11 23:33:14 +00:00
|
|
|
switch (desc->type)
|
2013-02-23 21:57:39 +00:00
|
|
|
{
|
2015-07-11 23:33:14 +00:00
|
|
|
case OVERLAY_TYPE_BUTTONS:
|
|
|
|
{
|
|
|
|
uint64_t mask = desc->key_mask;
|
2015-01-09 23:21:27 +00:00
|
|
|
|
2015-07-11 23:33:14 +00:00
|
|
|
out->buttons |= mask;
|
2013-02-23 21:57:39 +00:00
|
|
|
|
2015-07-11 23:33:14 +00:00
|
|
|
if (mask & (UINT64_C(1) << RARCH_OVERLAY_NEXT))
|
|
|
|
ol->next_index = desc->next_index;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case OVERLAY_TYPE_KEYBOARD:
|
|
|
|
if (desc->key_mask < RETROK_LAST)
|
|
|
|
OVERLAY_SET_KEY(out, desc->key_mask);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
float x_val = x_dist / desc->range_x;
|
|
|
|
float y_val = y_dist / desc->range_y;
|
|
|
|
float x_val_sat = x_val / desc->analog_saturate_pct;
|
|
|
|
float y_val_sat = y_val / desc->analog_saturate_pct;
|
2013-09-05 22:52:17 +00:00
|
|
|
|
2015-07-11 23:33:14 +00:00
|
|
|
unsigned int base = (desc->type == OVERLAY_TYPE_ANALOG_RIGHT) ? 2 : 0;
|
2015-01-14 22:15:24 +00:00
|
|
|
|
2015-07-11 23:33:14 +00:00
|
|
|
out->analog[base + 0] = clamp_float(x_val_sat, -1.0f, 1.0f) * 32767.0f;
|
|
|
|
out->analog[base + 1] = clamp_float(y_val_sat, -1.0f, 1.0f) * 32767.0f;
|
|
|
|
}
|
|
|
|
break;
|
2013-12-31 16:15:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (desc->movable)
|
|
|
|
{
|
2014-10-26 01:18:56 +00:00
|
|
|
desc->delta_x = clamp_float(x_dist, -desc->range_x, desc->range_x)
|
2014-09-02 14:50:28 +00:00
|
|
|
* ol->active->mod_w;
|
2014-10-26 01:18:56 +00:00
|
|
|
desc->delta_y = clamp_float(y_dist, -desc->range_y, desc->range_y)
|
2014-09-02 14:50:28 +00:00
|
|
|
* ol->active->mod_h;
|
2013-09-05 15:38:00 +00:00
|
|
|
}
|
2012-12-20 11:24:49 +00:00
|
|
|
}
|
|
|
|
|
2013-09-05 22:19:07 +00:00
|
|
|
if (!out->buttons)
|
2013-02-17 14:00:38 +00:00
|
|
|
ol->blocked = false;
|
|
|
|
else if (ol->blocked)
|
2013-09-05 22:19:07 +00:00
|
|
|
memset(out, 0, sizeof(*out));
|
2012-12-20 11:24:49 +00:00
|
|
|
}
|
|
|
|
|
2015-01-18 08:25:48 +00:00
|
|
|
/**
|
|
|
|
* input_overlay_update_desc_geom:
|
|
|
|
* @ol : overlay handle.
|
|
|
|
* @desc : overlay descriptors handle.
|
|
|
|
*
|
|
|
|
* Update input overlay descriptors' vertex geometry.
|
|
|
|
**/
|
2014-09-02 14:50:28 +00:00
|
|
|
static void input_overlay_update_desc_geom(input_overlay_t *ol,
|
|
|
|
struct overlay_desc *desc)
|
2013-12-31 16:15:28 +00:00
|
|
|
{
|
2015-02-15 06:01:32 +00:00
|
|
|
if (!desc || !desc->image.pixels)
|
2015-01-18 08:25:48 +00:00
|
|
|
return;
|
|
|
|
if (!desc->movable)
|
|
|
|
return;
|
2013-12-31 16:15:28 +00:00
|
|
|
|
2015-07-11 23:33:14 +00:00
|
|
|
if (ol->iface && ol->iface->vertex_geom)
|
|
|
|
ol->iface->vertex_geom(ol->iface_data, desc->image_index,
|
|
|
|
desc->mod_x + desc->delta_x, desc->mod_y + desc->delta_y,
|
|
|
|
desc->mod_w, desc->mod_h);
|
2015-01-18 08:25:48 +00:00
|
|
|
|
|
|
|
desc->delta_x = 0.0f;
|
|
|
|
desc->delta_y = 0.0f;
|
2013-12-31 16:15:28 +00:00
|
|
|
}
|
|
|
|
|
2015-01-09 23:59:05 +00:00
|
|
|
/**
|
|
|
|
* input_overlay_post_poll:
|
|
|
|
*
|
|
|
|
* Called after all the input_overlay_poll() calls to
|
|
|
|
* update the range modifiers for pressed/unpressed regions
|
|
|
|
* and alpha mods.
|
|
|
|
**/
|
2015-09-06 12:59:20 +00:00
|
|
|
static void input_overlay_post_poll(float opacity)
|
2013-12-27 01:37:52 +00:00
|
|
|
{
|
|
|
|
size_t i;
|
2015-08-06 03:14:12 +00:00
|
|
|
input_overlay_t *ol = overlay_ptr;
|
2013-12-27 01:37:52 +00:00
|
|
|
|
2015-02-15 05:57:02 +00:00
|
|
|
if (!ol)
|
|
|
|
return;
|
|
|
|
|
2015-07-12 05:22:52 +00:00
|
|
|
input_overlay_set_alpha_mod(opacity);
|
2013-12-27 02:39:07 +00:00
|
|
|
|
2013-12-27 01:37:52 +00:00
|
|
|
for (i = 0; i < ol->active->size; i++)
|
|
|
|
{
|
|
|
|
struct overlay_desc *desc = &ol->active->descs[i];
|
|
|
|
|
2015-01-09 23:21:27 +00:00
|
|
|
if (!desc)
|
|
|
|
continue;
|
|
|
|
|
2015-01-14 22:15:24 +00:00
|
|
|
desc->range_x_mod = desc->range_x;
|
|
|
|
desc->range_y_mod = desc->range_y;
|
|
|
|
|
2013-12-27 01:37:52 +00:00
|
|
|
if (desc->updated)
|
|
|
|
{
|
2014-09-02 14:50:28 +00:00
|
|
|
/* If pressed this frame, change the hitbox. */
|
2015-01-14 22:15:24 +00:00
|
|
|
desc->range_x_mod *= desc->range_mod;
|
|
|
|
desc->range_y_mod *= desc->range_mod;
|
2013-12-27 02:39:07 +00:00
|
|
|
|
2013-12-31 18:03:58 +00:00
|
|
|
if (desc->image.pixels)
|
2015-07-11 23:33:14 +00:00
|
|
|
{
|
|
|
|
if (ol->iface && ol->iface->set_alpha)
|
|
|
|
ol->iface->set_alpha(ol->iface_data, desc->image_index,
|
|
|
|
desc->alpha_mod * opacity);
|
|
|
|
}
|
2013-12-27 01:37:52 +00:00
|
|
|
}
|
|
|
|
|
2013-12-31 16:15:28 +00:00
|
|
|
input_overlay_update_desc_geom(ol, desc);
|
2013-12-27 01:37:52 +00:00
|
|
|
desc->updated = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-09 23:59:05 +00:00
|
|
|
/**
|
|
|
|
* input_overlay_poll_clear:
|
|
|
|
* @ol : overlay handle
|
|
|
|
*
|
|
|
|
* Call when there is nothing to poll. Allows overlay to
|
|
|
|
* clear certain state.
|
|
|
|
**/
|
2015-09-06 12:59:20 +00:00
|
|
|
static void input_overlay_poll_clear(float opacity)
|
2013-02-17 14:00:38 +00:00
|
|
|
{
|
2013-10-22 13:08:17 +00:00
|
|
|
size_t i;
|
2015-08-06 03:14:12 +00:00
|
|
|
input_overlay_t *ol = overlay_ptr;
|
2015-01-09 23:21:27 +00:00
|
|
|
|
2015-02-15 06:01:32 +00:00
|
|
|
if (!ol)
|
|
|
|
return;
|
|
|
|
|
2013-02-17 14:00:38 +00:00
|
|
|
ol->blocked = false;
|
2015-01-29 21:54:42 +00:00
|
|
|
|
2015-07-12 05:22:52 +00:00
|
|
|
input_overlay_set_alpha_mod(opacity);
|
2013-10-21 10:42:47 +00:00
|
|
|
|
2013-10-22 13:08:17 +00:00
|
|
|
for (i = 0; i < ol->active->size; i++)
|
2013-10-21 10:42:47 +00:00
|
|
|
{
|
|
|
|
struct overlay_desc *desc = &ol->active->descs[i];
|
2015-01-09 23:21:27 +00:00
|
|
|
|
|
|
|
if (!desc)
|
|
|
|
continue;
|
|
|
|
|
2013-10-21 10:42:47 +00:00
|
|
|
desc->range_x_mod = desc->range_x;
|
|
|
|
desc->range_y_mod = desc->range_y;
|
2013-12-27 01:37:52 +00:00
|
|
|
desc->updated = false;
|
2013-12-31 16:15:28 +00:00
|
|
|
|
|
|
|
desc->delta_x = 0.0f;
|
|
|
|
desc->delta_y = 0.0f;
|
|
|
|
input_overlay_update_desc_geom(ol, desc);
|
2013-10-21 10:42:47 +00:00
|
|
|
}
|
2013-02-17 14:00:38 +00:00
|
|
|
}
|
|
|
|
|
2015-01-09 23:59:05 +00:00
|
|
|
/**
|
|
|
|
* input_overlay_next:
|
|
|
|
* @ol : Overlay handle.
|
|
|
|
*
|
|
|
|
* Switch to the next available overlay
|
|
|
|
* screen.
|
|
|
|
**/
|
2015-07-12 05:22:52 +00:00
|
|
|
void input_overlay_next(float opacity)
|
2012-12-20 11:24:49 +00:00
|
|
|
{
|
2015-08-06 03:14:12 +00:00
|
|
|
input_overlay_t *ol = overlay_ptr;
|
2014-10-03 12:53:04 +00:00
|
|
|
if (!ol)
|
|
|
|
return;
|
|
|
|
|
2015-07-12 05:22:52 +00:00
|
|
|
ol->index = ol->next_index;
|
|
|
|
ol->active = &ol->overlays[ol->index];
|
2012-12-22 12:27:00 +00:00
|
|
|
|
2015-07-12 05:22:52 +00:00
|
|
|
input_overlay_load_active(opacity);
|
2013-10-16 14:59:24 +00:00
|
|
|
|
2015-07-12 05:22:52 +00:00
|
|
|
ol->blocked = true;
|
2013-02-24 11:52:48 +00:00
|
|
|
ol->next_index = (ol->index + 1) % ol->size;
|
2013-01-11 15:23:04 +00:00
|
|
|
}
|
|
|
|
|
2015-01-09 23:59:05 +00:00
|
|
|
/**
|
|
|
|
* input_overlay_full_screen:
|
|
|
|
*
|
|
|
|
* Checks if the overlay is fullscreen.
|
|
|
|
*
|
|
|
|
* Returns: true (1) if overlay is fullscreen, otherwise false (0).
|
|
|
|
**/
|
2015-09-06 12:59:20 +00:00
|
|
|
static bool input_overlay_full_screen(void)
|
2013-01-11 15:23:04 +00:00
|
|
|
{
|
2015-08-06 03:14:12 +00:00
|
|
|
input_overlay_t *ol = overlay_ptr;
|
2014-07-25 17:52:44 +00:00
|
|
|
if (!ol)
|
|
|
|
return false;
|
2013-01-11 15:23:04 +00:00
|
|
|
return ol->active->full_screen;
|
2012-12-20 11:24:49 +00:00
|
|
|
}
|
|
|
|
|
2015-01-09 23:59:05 +00:00
|
|
|
/**
|
|
|
|
* input_overlay_free:
|
|
|
|
* @ol : Overlay handle.
|
|
|
|
*
|
|
|
|
* Frees overlay handle.
|
|
|
|
**/
|
2015-07-12 05:12:33 +00:00
|
|
|
void input_overlay_free(void)
|
2012-12-20 11:24:49 +00:00
|
|
|
{
|
2015-08-06 03:14:12 +00:00
|
|
|
input_overlay_t *ol = overlay_ptr;
|
2012-12-20 11:24:49 +00:00
|
|
|
if (!ol)
|
|
|
|
return;
|
2015-11-23 20:02:36 +00:00
|
|
|
overlay_ptr = NULL;
|
2012-12-20 11:24:49 +00:00
|
|
|
|
2015-11-23 20:02:36 +00:00
|
|
|
input_overlay_free_overlays(ol);
|
2012-12-22 12:27:00 +00:00
|
|
|
|
2015-07-11 23:33:14 +00:00
|
|
|
if (ol->iface && ol->iface->enable)
|
2012-12-20 11:24:49 +00:00
|
|
|
ol->iface->enable(ol->iface_data, false);
|
|
|
|
|
|
|
|
free(ol);
|
2015-07-08 23:10:30 +00:00
|
|
|
}
|
|
|
|
|
2015-11-23 19:56:46 +00:00
|
|
|
/* task_data = overlay_task_data_t* */
|
2015-11-23 17:15:19 +00:00
|
|
|
static void input_overlay_loaded(void *task_data, void *user_data, const char *err)
|
2015-07-08 23:10:30 +00:00
|
|
|
{
|
2015-11-23 17:15:19 +00:00
|
|
|
overlay_task_data_t *data = (overlay_task_data_t*)task_data;
|
|
|
|
settings_t *settings = config_get_ptr();
|
2015-11-23 20:02:36 +00:00
|
|
|
input_overlay_t *ol;
|
2015-11-23 19:56:46 +00:00
|
|
|
driver_t *driver = driver_get_ptr();
|
|
|
|
|
2015-11-25 01:17:38 +00:00
|
|
|
if (err)
|
|
|
|
return;
|
|
|
|
|
2015-11-23 20:40:57 +00:00
|
|
|
/* We can't display when the menu is up */
|
|
|
|
if (settings->input.overlay_hide_in_menu && menu_driver_alive())
|
|
|
|
{
|
|
|
|
if (!driver->osk_enable && settings->input.overlay_enable)
|
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
for (i = 0; i < data->size; i++)
|
|
|
|
input_overlay_free_overlay(&data->overlays[i]);
|
|
|
|
|
|
|
|
free(data->overlays);
|
|
|
|
free(data);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-23 20:02:36 +00:00
|
|
|
ol = (input_overlay_t*)calloc(1, sizeof(*ol));
|
2015-11-23 17:15:19 +00:00
|
|
|
ol->overlays = data->overlays;
|
|
|
|
ol->size = data->size;
|
|
|
|
ol->active = data->active;
|
2015-07-08 23:10:30 +00:00
|
|
|
|
2015-11-23 17:15:19 +00:00
|
|
|
if (!video_driver_overlay_interface(&ol->iface))
|
2015-07-08 23:10:30 +00:00
|
|
|
{
|
2015-11-23 17:15:19 +00:00
|
|
|
RARCH_ERR("Overlay interface is not present in video driver.\n");
|
|
|
|
goto error;
|
2015-07-08 23:10:30 +00:00
|
|
|
}
|
|
|
|
|
2015-11-23 17:15:19 +00:00
|
|
|
ol->iface_data = video_driver_get_ptr(true);
|
|
|
|
|
|
|
|
if (!ol->iface)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
overlay_ptr = ol;
|
|
|
|
|
|
|
|
input_overlay_load_active(settings->input.overlay_opacity);
|
2015-11-23 20:02:36 +00:00
|
|
|
input_overlay_enable(driver->osk_enable ? settings->osk.enable : settings->input.overlay_enable);
|
2015-11-23 19:56:46 +00:00
|
|
|
input_overlay_set_scale_factor(settings->input.overlay_scale);
|
|
|
|
|
|
|
|
ol->next_index = (ol->index + 1) % ol->size;
|
|
|
|
ol->state = OVERLAY_STATUS_NONE;
|
|
|
|
ol->alive = true;
|
2015-07-08 23:10:30 +00:00
|
|
|
|
2015-11-23 20:40:57 +00:00
|
|
|
free(data);
|
2015-11-23 17:15:19 +00:00
|
|
|
return;
|
|
|
|
error:
|
|
|
|
input_overlay_free();
|
2015-11-23 20:40:57 +00:00
|
|
|
free(data);
|
2015-11-23 17:15:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void input_overlay_init(void)
|
|
|
|
{
|
2015-11-23 20:02:36 +00:00
|
|
|
input_overlay_free();
|
2015-11-23 17:15:19 +00:00
|
|
|
rarch_task_push_overlay_load_default(input_overlay_loaded, NULL);
|
2015-07-08 23:10:30 +00:00
|
|
|
}
|
|
|
|
|
2015-01-09 23:59:05 +00:00
|
|
|
/**
|
|
|
|
* input_overlay_set_alpha_mod:
|
|
|
|
* @ol : Overlay handle.
|
|
|
|
* @mod : New modulating factor to apply.
|
|
|
|
*
|
|
|
|
* Sets a modulating factor for alpha channel. Default is 1.0.
|
|
|
|
* The alpha factor is applied for all overlays.
|
|
|
|
**/
|
2015-07-12 05:22:52 +00:00
|
|
|
void input_overlay_set_alpha_mod(float mod)
|
2013-01-29 20:51:15 +00:00
|
|
|
{
|
2013-10-22 13:08:17 +00:00
|
|
|
unsigned i;
|
2015-08-06 03:14:12 +00:00
|
|
|
input_overlay_t *ol = overlay_ptr;
|
2014-09-28 15:52:15 +00:00
|
|
|
|
|
|
|
if (!ol)
|
|
|
|
return;
|
|
|
|
|
2013-10-22 13:08:17 +00:00
|
|
|
for (i = 0; i < ol->active->load_images_size; i++)
|
2015-01-29 19:33:27 +00:00
|
|
|
ol->iface->set_alpha(ol->iface_data, i, mod);
|
2013-01-29 20:51:15 +00:00
|
|
|
}
|
2015-07-11 06:07:14 +00:00
|
|
|
|
2015-07-12 05:03:39 +00:00
|
|
|
bool input_overlay_is_alive(void)
|
2015-07-11 06:07:14 +00:00
|
|
|
{
|
2015-08-06 03:14:12 +00:00
|
|
|
input_overlay_t *ol = overlay_ptr;
|
2015-07-11 06:07:14 +00:00
|
|
|
if (!ol)
|
|
|
|
return false;
|
2015-07-11 21:45:23 +00:00
|
|
|
return ol->alive;
|
2015-07-11 06:07:14 +00:00
|
|
|
}
|
|
|
|
|
2015-07-12 05:12:33 +00:00
|
|
|
enum overlay_status input_overlay_status(void)
|
2015-07-11 06:07:14 +00:00
|
|
|
{
|
2015-08-06 03:14:12 +00:00
|
|
|
input_overlay_t *ol = overlay_ptr;
|
2015-07-11 06:07:14 +00:00
|
|
|
if (!ol)
|
|
|
|
return OVERLAY_STATUS_NONE;
|
|
|
|
return ol->state;
|
|
|
|
}
|
2015-07-12 04:47:39 +00:00
|
|
|
|
2015-07-12 05:42:14 +00:00
|
|
|
bool input_overlay_key_pressed(int key)
|
|
|
|
{
|
|
|
|
input_overlay_state_t *ol_state = input_overlay_get_state_ptr();
|
|
|
|
|
|
|
|
if (!ol_state)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return (ol_state->buttons & (UINT64_C(1) << key));
|
|
|
|
}
|
|
|
|
|
2015-07-12 04:47:39 +00:00
|
|
|
/*
|
|
|
|
* input_poll_overlay:
|
|
|
|
*
|
|
|
|
* Poll pressed buttons/keys on currently active overlay.
|
|
|
|
**/
|
|
|
|
void input_poll_overlay(float opacity)
|
|
|
|
{
|
|
|
|
input_overlay_state_t old_key_state;
|
|
|
|
unsigned i, j, device;
|
|
|
|
uint16_t key_mod = 0;
|
|
|
|
bool polled = false;
|
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
|
input_overlay_state_t *ol_state = input_overlay_get_state_ptr();
|
|
|
|
|
2015-07-12 05:03:39 +00:00
|
|
|
if (!input_overlay_is_alive() || !ol_state)
|
2015-07-12 04:47:39 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
memcpy(old_key_state.keys, ol_state->keys,
|
|
|
|
sizeof(ol_state->keys));
|
|
|
|
memset(ol_state, 0, sizeof(*ol_state));
|
|
|
|
|
2015-07-12 05:28:28 +00:00
|
|
|
device = input_overlay_full_screen() ?
|
2015-07-12 04:47:39 +00:00
|
|
|
RARCH_DEVICE_POINTER_SCREEN : RETRO_DEVICE_POINTER;
|
|
|
|
|
|
|
|
for (i = 0;
|
|
|
|
input_driver_state(NULL, 0, device, i,
|
|
|
|
RETRO_DEVICE_ID_POINTER_PRESSED);
|
|
|
|
i++)
|
|
|
|
{
|
|
|
|
input_overlay_state_t polled_data;
|
|
|
|
int16_t x = input_driver_state(NULL, 0,
|
|
|
|
device, i, RETRO_DEVICE_ID_POINTER_X);
|
|
|
|
int16_t y = input_driver_state(NULL, 0,
|
|
|
|
device, i, RETRO_DEVICE_ID_POINTER_Y);
|
|
|
|
|
2015-07-12 05:28:28 +00:00
|
|
|
input_overlay_poll(&polled_data, x, y);
|
2015-07-12 04:47:39 +00:00
|
|
|
|
|
|
|
ol_state->buttons |= polled_data.buttons;
|
|
|
|
|
|
|
|
for (j = 0; j < ARRAY_SIZE(ol_state->keys); j++)
|
|
|
|
ol_state->keys[j] |= polled_data.keys[j];
|
|
|
|
|
|
|
|
/* Fingers pressed later take prio 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;
|
|
|
|
|
2015-07-12 05:42:14 +00:00
|
|
|
if (input_overlay_key_pressed(bind_plus))
|
2015-07-12 04:47:39 +00:00
|
|
|
ol_state->analog[j] += 0x7fff;
|
2015-07-12 05:42:14 +00:00
|
|
|
if (input_overlay_key_pressed(bind_minus))
|
2015-07-12 04:47:39 +00:00
|
|
|
ol_state->analog[j] -= 0x7fff;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check for analog_dpad_mode.
|
|
|
|
* Map analogs to d-pad buttons when configured. */
|
|
|
|
switch (settings->input.analog_dpad_mode[0])
|
|
|
|
{
|
|
|
|
case ANALOG_DPAD_LSTICK:
|
|
|
|
case ANALOG_DPAD_RSTICK:
|
|
|
|
{
|
|
|
|
float analog_x, analog_y;
|
|
|
|
unsigned analog_base = 2;
|
|
|
|
|
|
|
|
if (settings->input.analog_dpad_mode[0] == 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 <= -settings->input.axis_threshold)
|
|
|
|
ol_state->buttons |= (1UL << RETRO_DEVICE_ID_JOYPAD_LEFT);
|
|
|
|
if (analog_x >= settings->input.axis_threshold)
|
|
|
|
ol_state->buttons |= (1UL << RETRO_DEVICE_ID_JOYPAD_RIGHT);
|
|
|
|
if (analog_y <= -settings->input.axis_threshold)
|
|
|
|
ol_state->buttons |= (1UL << RETRO_DEVICE_ID_JOYPAD_UP);
|
|
|
|
if (analog_y >= settings->input.axis_threshold)
|
|
|
|
ol_state->buttons |= (1UL << RETRO_DEVICE_ID_JOYPAD_DOWN);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (polled)
|
2015-07-12 05:28:28 +00:00
|
|
|
input_overlay_post_poll(opacity);
|
2015-07-12 04:47:39 +00:00
|
|
|
else
|
2015-07-12 05:28:28 +00:00
|
|
|
input_overlay_poll_clear(opacity);
|
2015-07-12 04:47:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void input_state_overlay(int16_t *ret, unsigned port, unsigned device, unsigned idx,
|
|
|
|
unsigned id)
|
|
|
|
{
|
|
|
|
input_overlay_state_t *ol_state = input_overlay_get_state_ptr();
|
|
|
|
|
|
|
|
if (!ol_state)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (port != 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
switch (device)
|
|
|
|
{
|
|
|
|
case RETRO_DEVICE_JOYPAD:
|
2015-07-12 05:42:14 +00:00
|
|
|
if (input_overlay_key_pressed(id))
|
2015-07-12 04:47:39 +00:00
|
|
|
*ret |= 1;
|
|
|
|
break;
|
|
|
|
case RETRO_DEVICE_KEYBOARD:
|
|
|
|
if (id < RETROK_LAST)
|
|
|
|
{
|
|
|
|
if (OVERLAY_GET_KEY(ol_state, id))
|
|
|
|
*ret |= 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case RETRO_DEVICE_ANALOG:
|
|
|
|
{
|
|
|
|
unsigned base = 0;
|
|
|
|
|
|
|
|
if (idx == RETRO_DEVICE_INDEX_ANALOG_RIGHT)
|
|
|
|
base = 2;
|
|
|
|
if (id == RETRO_DEVICE_ID_ANALOG_Y)
|
|
|
|
base += 1;
|
|
|
|
if (ol_state && ol_state->analog[base])
|
|
|
|
*ret = ol_state->analog[base];
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2015-07-12 04:54:35 +00:00
|
|
|
|