2014-03-02 04:24:57 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
|
|
|
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
2015-01-07 16:46:50 +00:00
|
|
|
* Copyright (C) 2011-2015 - Daniel De Matteis
|
2014-04-13 10:12:12 +00:00
|
|
|
*
|
2014-03-02 04:24:57 +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/>.
|
|
|
|
*/
|
2014-03-02 10:45:41 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "../../config.h"
|
|
|
|
#endif
|
|
|
|
|
2014-03-02 04:24:57 +00:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2015-06-05 15:56:51 +00:00
|
|
|
|
2015-01-11 05:24:44 +00:00
|
|
|
#include "menu_input.h"
|
2015-01-10 03:53:37 +00:00
|
|
|
#include "menu.h"
|
2015-09-26 23:10:15 +00:00
|
|
|
#include "menu_animation.h"
|
2015-06-13 14:47:51 +00:00
|
|
|
#include "menu_display.h"
|
2015-05-11 09:48:43 +00:00
|
|
|
#include "menu_entry.h"
|
2015-02-14 00:51:28 +00:00
|
|
|
#include "menu_setting.h"
|
2014-10-28 20:49:50 +00:00
|
|
|
#include "menu_shader.h"
|
2015-02-11 21:15:13 +00:00
|
|
|
#include "menu_navigation.h"
|
2015-06-13 17:12:10 +00:00
|
|
|
#include "menu_hash.h"
|
|
|
|
|
2015-06-14 17:43:04 +00:00
|
|
|
#include "../general.h"
|
2015-01-19 18:00:26 +00:00
|
|
|
#include "../cheats.h"
|
2014-10-28 18:54:23 +00:00
|
|
|
#include "../performance.h"
|
2015-01-10 19:10:45 +00:00
|
|
|
#include "../input/input_joypad.h"
|
2015-01-19 17:16:34 +00:00
|
|
|
#include "../input/input_remapping.h"
|
2015-06-13 20:57:55 +00:00
|
|
|
#include "../input/input_common.h"
|
|
|
|
|
2015-11-01 21:57:13 +00:00
|
|
|
enum menu_mouse_action
|
|
|
|
{
|
|
|
|
MOUSE_ACTION_NONE = 0,
|
|
|
|
MOUSE_ACTION_BUTTON_L,
|
|
|
|
MOUSE_ACTION_BUTTON_L_TOGGLE,
|
|
|
|
MOUSE_ACTION_BUTTON_L_SET_NAVIGATION,
|
|
|
|
MOUSE_ACTION_BUTTON_R,
|
|
|
|
MOUSE_ACTION_WHEEL_UP,
|
|
|
|
MOUSE_ACTION_WHEEL_DOWN
|
|
|
|
};
|
|
|
|
|
2015-11-01 21:42:26 +00:00
|
|
|
struct menu_bind_state_port
|
|
|
|
{
|
|
|
|
bool buttons[MENU_MAX_BUTTONS];
|
|
|
|
int16_t axes[MENU_MAX_AXES];
|
|
|
|
uint16_t hats[MENU_MAX_HATS];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct menu_bind_axis_state
|
|
|
|
{
|
|
|
|
/* Default axis state. */
|
|
|
|
int16_t rested_axes[MENU_MAX_AXES];
|
|
|
|
/* Locked axis state. If we configured an axis,
|
|
|
|
* avoid having the same axis state trigger something again right away. */
|
|
|
|
int16_t locked_axes[MENU_MAX_AXES];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct menu_bind_state
|
|
|
|
{
|
|
|
|
struct retro_keybind *target;
|
|
|
|
/* For keyboard binding. */
|
|
|
|
int64_t timeout_end;
|
|
|
|
unsigned begin;
|
|
|
|
unsigned last;
|
|
|
|
unsigned user;
|
|
|
|
struct menu_bind_state_port state[MAX_USERS];
|
|
|
|
struct menu_bind_axis_state axis_state[MAX_USERS];
|
|
|
|
bool skip;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct menu_input_mouse
|
|
|
|
{
|
|
|
|
int16_t x;
|
|
|
|
int16_t y;
|
|
|
|
bool left;
|
|
|
|
bool right;
|
|
|
|
bool oldleft;
|
|
|
|
bool oldright;
|
|
|
|
bool wheelup;
|
|
|
|
bool wheeldown;
|
|
|
|
bool hwheelup;
|
|
|
|
bool hwheeldown;
|
|
|
|
bool scrollup;
|
|
|
|
bool scrolldown;
|
|
|
|
unsigned ptr;
|
|
|
|
uint64_t state;
|
|
|
|
} menu_input_mouse_t;
|
|
|
|
|
|
|
|
typedef struct menu_input
|
|
|
|
{
|
|
|
|
struct menu_bind_state binds;
|
|
|
|
|
|
|
|
menu_input_mouse_t mouse;
|
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
int16_t x;
|
|
|
|
int16_t y;
|
|
|
|
int16_t dx;
|
|
|
|
int16_t dy;
|
|
|
|
int16_t old_x;
|
|
|
|
int16_t old_y;
|
|
|
|
int16_t start_x;
|
|
|
|
int16_t start_y;
|
|
|
|
float accel;
|
|
|
|
float accel0;
|
|
|
|
float accel1;
|
|
|
|
bool pressed[2];
|
|
|
|
bool oldpressed[2];
|
|
|
|
bool dragging;
|
|
|
|
bool back;
|
|
|
|
bool oldback;
|
|
|
|
unsigned ptr;
|
|
|
|
} pointer;
|
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
const char **buffer;
|
|
|
|
const char *label;
|
|
|
|
const char *label_setting;
|
|
|
|
bool display;
|
|
|
|
unsigned type;
|
|
|
|
unsigned idx;
|
|
|
|
} keyboard;
|
|
|
|
|
|
|
|
/* Used for key repeat */
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
float timer;
|
|
|
|
float count;
|
|
|
|
} delay;
|
|
|
|
} menu_input_t;
|
|
|
|
|
2015-11-01 21:43:54 +00:00
|
|
|
static unsigned bind_port;
|
2015-09-24 19:02:28 +00:00
|
|
|
static menu_input_t menu_input_state;
|
|
|
|
|
|
|
|
void menu_input_free(void)
|
|
|
|
{
|
|
|
|
memset(&menu_input_state, 0, sizeof(menu_input_t));
|
|
|
|
}
|
|
|
|
|
2015-11-01 19:47:20 +00:00
|
|
|
static menu_input_t *menu_input_get_ptr(void)
|
2015-09-24 19:02:28 +00:00
|
|
|
{
|
|
|
|
return &menu_input_state;
|
2015-06-13 20:57:55 +00:00
|
|
|
}
|
2015-01-19 07:37:11 +00:00
|
|
|
|
2015-09-24 15:18:17 +00:00
|
|
|
void menu_input_key_event(bool down, unsigned keycode,
|
|
|
|
uint32_t character, uint16_t mod)
|
|
|
|
{
|
|
|
|
(void)down;
|
|
|
|
(void)keycode;
|
|
|
|
(void)mod;
|
|
|
|
|
|
|
|
if (character == '/')
|
|
|
|
menu_entry_action(NULL, 0, MENU_ACTION_SEARCH);
|
|
|
|
}
|
|
|
|
|
2015-09-26 00:55:38 +00:00
|
|
|
static void menu_input_key_end_line(void)
|
|
|
|
{
|
2015-09-28 13:52:42 +00:00
|
|
|
bool keyboard_display = false;
|
2015-09-26 00:55:38 +00:00
|
|
|
driver_t *driver = driver_get_ptr();
|
|
|
|
|
2015-09-28 13:52:42 +00:00
|
|
|
menu_input_ctl(MENU_INPUT_CTL_SET_KEYBOARD_DISPLAY, &keyboard_display);
|
2015-10-03 20:09:12 +00:00
|
|
|
menu_input_ctl(MENU_INPUT_CTL_UNSET_KEYBOARD_LABEL, NULL);
|
|
|
|
menu_input_ctl(MENU_INPUT_CTL_UNSET_KEYBOARD_LABEL_SETTING, NULL);
|
2015-09-26 00:55:38 +00:00
|
|
|
|
|
|
|
/* Avoid triggering states on pressing return. */
|
|
|
|
driver->flushing_input = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void menu_input_search_callback(void *userdata, const char *str)
|
|
|
|
{
|
|
|
|
size_t idx = 0;
|
2015-10-27 09:10:33 +00:00
|
|
|
file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0);
|
2015-09-26 00:55:38 +00:00
|
|
|
|
2015-10-17 15:44:57 +00:00
|
|
|
if (!selection_buf)
|
2015-09-26 00:55:38 +00:00
|
|
|
return;
|
|
|
|
|
2015-10-17 15:44:57 +00:00
|
|
|
if (str && *str && file_list_search(selection_buf, str, &idx))
|
2015-09-26 00:55:38 +00:00
|
|
|
{
|
|
|
|
bool scroll = true;
|
|
|
|
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &idx);
|
|
|
|
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET, &scroll);
|
|
|
|
}
|
|
|
|
|
|
|
|
menu_input_key_end_line();
|
|
|
|
}
|
|
|
|
|
2015-09-26 00:52:05 +00:00
|
|
|
bool menu_input_ctl(enum menu_input_ctl_state state, void *data)
|
2015-09-24 17:47:41 +00:00
|
|
|
{
|
|
|
|
menu_input_t *menu_input = menu_input_get_ptr();
|
2015-09-26 00:55:38 +00:00
|
|
|
menu_handle_t *menu = menu_driver_get_ptr();
|
2015-09-24 17:47:41 +00:00
|
|
|
|
|
|
|
if (!menu_input)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
switch (state)
|
|
|
|
{
|
2015-09-26 00:55:38 +00:00
|
|
|
case MENU_INPUT_CTL_SEARCH_START:
|
|
|
|
menu_input->keyboard.display = true;
|
|
|
|
menu_input->keyboard.label = menu_hash_to_str(MENU_VALUE_SEARCH);
|
|
|
|
menu_input->keyboard.buffer =
|
|
|
|
input_keyboard_start_line(menu, menu_input_search_callback);
|
|
|
|
return true;
|
2015-09-26 00:52:05 +00:00
|
|
|
case MENU_INPUT_CTL_MOUSE_SCROLL_DOWN:
|
2015-09-24 17:47:41 +00:00
|
|
|
{
|
|
|
|
bool *ptr = (bool*)data;
|
|
|
|
*ptr = menu_input->mouse.scrolldown;
|
|
|
|
}
|
|
|
|
return true;
|
2015-09-26 00:52:05 +00:00
|
|
|
case MENU_INPUT_CTL_MOUSE_SCROLL_UP:
|
2015-09-24 17:47:41 +00:00
|
|
|
{
|
|
|
|
bool *ptr = (bool*)data;
|
|
|
|
*ptr = menu_input->mouse.scrollup;
|
2015-09-24 17:51:55 +00:00
|
|
|
}
|
|
|
|
return true;
|
2015-09-26 00:52:05 +00:00
|
|
|
case MENU_INPUT_CTL_MOUSE_PTR:
|
2015-09-24 17:51:55 +00:00
|
|
|
{
|
|
|
|
unsigned *ptr = (unsigned*)data;
|
|
|
|
menu_input->mouse.ptr = *ptr;
|
2015-09-24 17:56:53 +00:00
|
|
|
}
|
|
|
|
return true;
|
2015-09-26 00:52:05 +00:00
|
|
|
case MENU_INPUT_CTL_POINTER_PTR:
|
2015-09-24 17:56:53 +00:00
|
|
|
{
|
|
|
|
unsigned *ptr = (unsigned*)data;
|
|
|
|
menu_input->pointer.ptr = *ptr;
|
2015-09-24 18:08:11 +00:00
|
|
|
}
|
|
|
|
return true;
|
2015-09-26 00:52:05 +00:00
|
|
|
case MENU_INPUT_CTL_POINTER_ACCEL_READ:
|
2015-09-24 18:32:21 +00:00
|
|
|
{
|
2015-09-24 21:33:41 +00:00
|
|
|
float *ptr = (float*)data;
|
2015-09-24 18:32:21 +00:00
|
|
|
*ptr = menu_input->pointer.accel;
|
|
|
|
}
|
|
|
|
return true;
|
2015-09-26 00:52:05 +00:00
|
|
|
case MENU_INPUT_CTL_POINTER_ACCEL_WRITE:
|
2015-09-24 18:32:21 +00:00
|
|
|
{
|
2015-09-24 21:33:41 +00:00
|
|
|
float *ptr = (float*)data;
|
2015-09-24 18:32:21 +00:00
|
|
|
menu_input->pointer.accel = *ptr;
|
|
|
|
}
|
|
|
|
return true;
|
2015-09-26 00:52:05 +00:00
|
|
|
case MENU_INPUT_CTL_POINTER_DRAGGING:
|
2015-09-24 18:32:21 +00:00
|
|
|
{
|
|
|
|
bool *ptr = (bool*)data;
|
|
|
|
*ptr = menu_input->pointer.dragging;
|
|
|
|
}
|
|
|
|
return true;
|
2015-09-26 00:52:05 +00:00
|
|
|
case MENU_INPUT_CTL_KEYBOARD_DISPLAY:
|
2015-09-24 18:08:11 +00:00
|
|
|
{
|
|
|
|
bool *ptr = (bool*)data;
|
|
|
|
*ptr = menu_input->keyboard.display;
|
|
|
|
}
|
|
|
|
return true;
|
2015-09-28 13:52:42 +00:00
|
|
|
case MENU_INPUT_CTL_SET_KEYBOARD_DISPLAY:
|
|
|
|
{
|
|
|
|
bool *ptr = (bool*)data;
|
|
|
|
menu_input->keyboard.display = *ptr;
|
|
|
|
}
|
|
|
|
return true;
|
2015-09-26 00:52:05 +00:00
|
|
|
case MENU_INPUT_CTL_KEYBOARD_BUFF_PTR:
|
2015-09-24 18:08:11 +00:00
|
|
|
{
|
2015-09-24 20:53:03 +00:00
|
|
|
const char **ptr = (const char**)data;
|
|
|
|
*ptr = *menu_input->keyboard.buffer;
|
2015-09-24 18:08:11 +00:00
|
|
|
}
|
|
|
|
return true;
|
2015-09-26 00:52:05 +00:00
|
|
|
case MENU_INPUT_CTL_KEYBOARD_LABEL:
|
2015-09-24 18:08:11 +00:00
|
|
|
{
|
2015-09-24 20:53:03 +00:00
|
|
|
const char **ptr = (const char**)data;
|
|
|
|
*ptr = menu_input->keyboard.label;
|
2015-09-24 17:47:41 +00:00
|
|
|
}
|
|
|
|
return true;
|
2015-09-28 13:52:42 +00:00
|
|
|
case MENU_INPUT_CTL_SET_KEYBOARD_LABEL:
|
|
|
|
{
|
2015-10-03 20:18:43 +00:00
|
|
|
char **ptr = (char**)data;
|
|
|
|
menu_input->keyboard.label = *ptr;
|
2015-09-28 13:52:42 +00:00
|
|
|
}
|
|
|
|
return true;
|
2015-10-03 20:09:12 +00:00
|
|
|
case MENU_INPUT_CTL_UNSET_KEYBOARD_LABEL:
|
2015-10-03 20:09:59 +00:00
|
|
|
menu_input->keyboard.label = NULL;
|
2015-10-03 20:09:12 +00:00
|
|
|
return true;
|
2015-09-28 13:52:42 +00:00
|
|
|
case MENU_INPUT_CTL_KEYBOARD_LABEL_SETTING:
|
|
|
|
{
|
|
|
|
const char **ptr = (const char**)data;
|
|
|
|
*ptr = menu_input->keyboard.label_setting;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
case MENU_INPUT_CTL_SET_KEYBOARD_LABEL_SETTING:
|
|
|
|
{
|
2015-10-03 20:14:35 +00:00
|
|
|
char **ptr = (char**)data;
|
|
|
|
menu_input->keyboard.label_setting = *ptr;
|
2015-09-28 13:52:42 +00:00
|
|
|
}
|
|
|
|
return true;
|
2015-10-03 20:09:12 +00:00
|
|
|
case MENU_INPUT_CTL_UNSET_KEYBOARD_LABEL_SETTING:
|
2015-10-03 20:09:59 +00:00
|
|
|
menu_input->keyboard.label_setting = NULL;
|
2015-10-03 20:09:12 +00:00
|
|
|
return true;
|
2015-09-24 17:47:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-02-13 19:19:20 +00:00
|
|
|
void menu_input_key_start_line(const char *label,
|
2014-12-06 14:47:25 +00:00
|
|
|
const char *label_setting, unsigned type, unsigned idx,
|
|
|
|
input_keyboard_line_complete_t cb)
|
2014-03-02 10:45:41 +00:00
|
|
|
{
|
2015-09-28 13:52:42 +00:00
|
|
|
bool keyboard_display = true;
|
2015-06-13 20:57:55 +00:00
|
|
|
menu_handle_t *menu = menu_driver_get_ptr();
|
|
|
|
menu_input_t *menu_input = menu_input_get_ptr();
|
|
|
|
if (!menu || !menu_input)
|
2014-04-26 00:08:03 +00:00
|
|
|
return;
|
|
|
|
|
2015-09-28 13:52:42 +00:00
|
|
|
menu_input_ctl(MENU_INPUT_CTL_SET_KEYBOARD_DISPLAY, &keyboard_display);
|
|
|
|
menu_input_ctl(MENU_INPUT_CTL_SET_KEYBOARD_LABEL, &label);
|
|
|
|
menu_input_ctl(MENU_INPUT_CTL_SET_KEYBOARD_LABEL_SETTING, &label_setting);
|
|
|
|
|
2015-06-13 20:57:55 +00:00
|
|
|
menu_input->keyboard.type = type;
|
|
|
|
menu_input->keyboard.idx = idx;
|
|
|
|
menu_input->keyboard.buffer = input_keyboard_start_line(menu, cb);
|
2014-03-02 10:45:41 +00:00
|
|
|
}
|
|
|
|
|
2015-01-11 05:42:53 +00:00
|
|
|
void menu_input_st_uint_callback(void *userdata, const char *str)
|
2014-03-02 10:45:41 +00:00
|
|
|
{
|
2014-10-08 22:50:35 +00:00
|
|
|
if (str && *str)
|
2014-08-24 17:00:36 +00:00
|
|
|
{
|
2015-09-28 13:58:24 +00:00
|
|
|
rarch_setting_t *setting = NULL;
|
2015-09-28 13:52:42 +00:00
|
|
|
const char *label = NULL;
|
|
|
|
|
|
|
|
menu_input_ctl(MENU_INPUT_CTL_KEYBOARD_LABEL_SETTING, &label);
|
|
|
|
|
2015-09-28 13:58:24 +00:00
|
|
|
setting = menu_setting_find(label);
|
2015-10-11 15:24:37 +00:00
|
|
|
menu_setting_set_with_string_representation(setting, str);
|
2014-08-24 17:00:36 +00:00
|
|
|
}
|
2015-02-10 22:26:21 +00:00
|
|
|
|
2015-02-13 19:19:20 +00:00
|
|
|
menu_input_key_end_line();
|
2014-03-02 10:45:41 +00:00
|
|
|
}
|
|
|
|
|
2015-03-14 22:21:55 +00:00
|
|
|
void menu_input_st_hex_callback(void *userdata, const char *str)
|
|
|
|
{
|
|
|
|
if (str && *str)
|
|
|
|
{
|
2015-09-28 13:58:24 +00:00
|
|
|
rarch_setting_t *setting = NULL;
|
2015-09-28 13:52:42 +00:00
|
|
|
const char *label = NULL;
|
|
|
|
|
|
|
|
menu_input_ctl(MENU_INPUT_CTL_KEYBOARD_LABEL_SETTING, &label);
|
|
|
|
|
2015-09-28 13:58:24 +00:00
|
|
|
setting = menu_setting_find(label);
|
2015-09-28 13:52:42 +00:00
|
|
|
|
2015-09-28 13:58:24 +00:00
|
|
|
if (setting)
|
2015-09-28 16:44:28 +00:00
|
|
|
{
|
2015-10-11 15:17:05 +00:00
|
|
|
unsigned *ptr = (unsigned*)setting_get_ptr(setting);
|
2015-03-14 22:21:55 +00:00
|
|
|
if (str[0] == '#')
|
|
|
|
str++;
|
2015-10-11 12:23:32 +00:00
|
|
|
*ptr = strtoul(str, NULL, 16);
|
2015-09-28 16:44:28 +00:00
|
|
|
}
|
2015-03-14 22:21:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
menu_input_key_end_line();
|
|
|
|
}
|
|
|
|
|
2015-01-19 07:37:11 +00:00
|
|
|
|
2015-01-11 05:42:53 +00:00
|
|
|
void menu_input_st_string_callback(void *userdata, const char *str)
|
2014-03-02 10:45:41 +00:00
|
|
|
{
|
2014-10-08 22:50:35 +00:00
|
|
|
if (str && *str)
|
2014-08-01 05:00:32 +00:00
|
|
|
{
|
2015-09-28 13:58:24 +00:00
|
|
|
rarch_setting_t *setting = NULL;
|
|
|
|
const char *label = NULL;
|
|
|
|
global_t *global = global_get_ptr();
|
2015-09-28 13:52:42 +00:00
|
|
|
|
|
|
|
menu_input_ctl(MENU_INPUT_CTL_KEYBOARD_LABEL_SETTING, &label);
|
|
|
|
|
2015-09-28 13:58:24 +00:00
|
|
|
setting = menu_setting_find(label);
|
2015-02-10 22:26:21 +00:00
|
|
|
|
2015-09-28 13:58:24 +00:00
|
|
|
if (setting)
|
2015-04-15 07:35:48 +00:00
|
|
|
{
|
2015-10-11 15:24:37 +00:00
|
|
|
menu_setting_set_with_string_representation(setting, str);
|
2015-09-28 13:58:24 +00:00
|
|
|
menu_setting_generic(setting, false);
|
2015-04-15 07:35:48 +00:00
|
|
|
}
|
2014-09-05 23:34:05 +00:00
|
|
|
else
|
2014-10-28 20:49:50 +00:00
|
|
|
{
|
2015-09-28 13:52:42 +00:00
|
|
|
uint32_t hash_label = menu_hash_calculate(label);
|
2015-06-05 15:56:51 +00:00
|
|
|
|
|
|
|
switch (hash_label)
|
|
|
|
{
|
|
|
|
case MENU_LABEL_VIDEO_SHADER_PRESET_SAVE_AS:
|
|
|
|
menu_shader_manager_save_preset(str, false);
|
|
|
|
break;
|
|
|
|
case MENU_LABEL_REMAP_FILE_SAVE_AS:
|
|
|
|
input_remapping_save_file(str);
|
|
|
|
break;
|
|
|
|
case MENU_LABEL_CHEAT_FILE_SAVE_AS:
|
|
|
|
cheat_manager_save(global->cheat, str);
|
|
|
|
break;
|
|
|
|
}
|
2014-10-28 20:49:50 +00:00
|
|
|
}
|
2014-08-01 05:00:32 +00:00
|
|
|
}
|
2015-01-11 05:42:53 +00:00
|
|
|
|
2015-02-13 19:19:20 +00:00
|
|
|
menu_input_key_end_line();
|
2014-03-02 10:45:41 +00:00
|
|
|
}
|
|
|
|
|
2015-01-11 05:42:53 +00:00
|
|
|
void menu_input_st_cheat_callback(void *userdata, const char *str)
|
2014-12-06 14:47:25 +00:00
|
|
|
{
|
2015-06-13 20:57:55 +00:00
|
|
|
global_t *global = global_get_ptr();
|
|
|
|
cheat_manager_t *cheat = global ? global->cheat : NULL;
|
|
|
|
menu_input_t *menu_input = menu_input_get_ptr();
|
2015-02-10 22:26:21 +00:00
|
|
|
|
2015-06-13 20:57:55 +00:00
|
|
|
(void)userdata;
|
|
|
|
|
|
|
|
if (!menu_input || !cheat)
|
2015-02-10 22:26:21 +00:00
|
|
|
return;
|
2015-05-13 01:35:07 +00:00
|
|
|
|
2014-12-06 14:47:25 +00:00
|
|
|
if (cheat && str && *str)
|
|
|
|
{
|
2015-06-13 20:57:55 +00:00
|
|
|
unsigned cheat_index = menu_input->keyboard.type - MENU_SETTINGS_CHEAT_BEGIN;
|
2015-09-06 01:51:08 +00:00
|
|
|
cheat_manager_set_code(cheat, cheat_index, str);
|
2014-12-06 14:47:25 +00:00
|
|
|
}
|
2015-01-11 05:42:53 +00:00
|
|
|
|
2015-02-13 19:19:20 +00:00
|
|
|
menu_input_key_end_line();
|
2014-12-06 14:47:25 +00:00
|
|
|
}
|
|
|
|
|
2015-10-22 17:59:30 +00:00
|
|
|
static void menu_input_key_bind_poll_bind_state(struct menu_bind_state *state, unsigned port,
|
|
|
|
bool timed_out)
|
2014-06-08 17:48:38 +00:00
|
|
|
{
|
2015-07-27 15:24:25 +00:00
|
|
|
unsigned b, a, h;
|
2015-04-14 14:37:59 +00:00
|
|
|
const input_device_driver_t *joypad = input_driver_get_joypad_driver();
|
2014-08-20 14:26:34 +00:00
|
|
|
|
2014-06-08 17:48:38 +00:00
|
|
|
if (!state)
|
|
|
|
return;
|
|
|
|
|
|
|
|
memset(state->state, 0, sizeof(state->state));
|
2015-10-22 17:59:30 +00:00
|
|
|
state->skip = timed_out || input_driver_state(NULL, 0,
|
2014-08-20 14:26:34 +00:00
|
|
|
RETRO_DEVICE_KEYBOARD, 0, RETROK_RETURN);
|
2014-06-08 17:48:38 +00:00
|
|
|
|
|
|
|
if (!joypad)
|
|
|
|
return;
|
|
|
|
|
2014-08-27 13:08:21 +00:00
|
|
|
if (joypad->poll)
|
2014-08-02 22:44:07 +00:00
|
|
|
joypad->poll();
|
|
|
|
|
2015-07-26 23:01:32 +00:00
|
|
|
/* poll only the relevant port */
|
|
|
|
/* for (i = 0; i < settings->input.max_users; i++) */
|
|
|
|
for (b = 0; b < MENU_MAX_BUTTONS; b++)
|
|
|
|
state->state[port].buttons[b] = input_joypad_button_raw(joypad, port, b);
|
2015-01-11 05:34:32 +00:00
|
|
|
|
2015-07-26 23:01:32 +00:00
|
|
|
for (a = 0; a < MENU_MAX_AXES; a++)
|
|
|
|
state->state[port].axes[a] = input_joypad_axis_raw(joypad, port, a);
|
2015-01-11 05:34:32 +00:00
|
|
|
|
2015-07-26 23:01:32 +00:00
|
|
|
for (h = 0; h < MENU_MAX_HATS; h++)
|
|
|
|
{
|
|
|
|
if (input_joypad_hat_raw(joypad, port, HAT_UP_MASK, h))
|
|
|
|
state->state[port].hats[h] |= HAT_UP_MASK;
|
|
|
|
if (input_joypad_hat_raw(joypad, port, HAT_DOWN_MASK, h))
|
|
|
|
state->state[port].hats[h] |= HAT_DOWN_MASK;
|
|
|
|
if (input_joypad_hat_raw(joypad, port, HAT_LEFT_MASK, h))
|
|
|
|
state->state[port].hats[h] |= HAT_LEFT_MASK;
|
|
|
|
if (input_joypad_hat_raw(joypad, port, HAT_RIGHT_MASK, h))
|
|
|
|
state->state[port].hats[h] |= HAT_RIGHT_MASK;
|
2014-06-08 17:48:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-12 14:45:48 +00:00
|
|
|
static void menu_input_key_bind_poll_bind_get_rested_axes(
|
|
|
|
struct menu_bind_state *state, unsigned port)
|
2014-06-08 17:48:38 +00:00
|
|
|
{
|
2015-07-27 15:24:25 +00:00
|
|
|
unsigned a;
|
2015-04-14 14:37:59 +00:00
|
|
|
const input_device_driver_t *joypad = input_driver_get_joypad_driver();
|
2014-06-08 17:48:38 +00:00
|
|
|
|
2015-08-18 01:07:23 +00:00
|
|
|
if (!state || !joypad)
|
2014-06-08 17:48:38 +00:00
|
|
|
return;
|
|
|
|
|
2015-07-26 23:01:32 +00:00
|
|
|
/* poll only the relevant port */
|
|
|
|
/*for (i = 0; i < settings->input.max_users; i++)*/
|
|
|
|
for (a = 0; a < MENU_MAX_AXES; a++)
|
|
|
|
state->axis_state[port].rested_axes[a] =
|
|
|
|
input_joypad_axis_raw(joypad, port, a);
|
2014-06-08 17:48:38 +00:00
|
|
|
}
|
|
|
|
|
2015-10-12 14:45:48 +00:00
|
|
|
static bool menu_input_key_bind_poll_find_trigger_pad(struct menu_bind_state *state,
|
2014-09-03 03:10:34 +00:00
|
|
|
struct menu_bind_state *new_state, unsigned p)
|
2014-06-08 17:48:38 +00:00
|
|
|
{
|
|
|
|
unsigned a, b, h;
|
2014-09-03 03:10:34 +00:00
|
|
|
const struct menu_bind_state_port *n = (const struct menu_bind_state_port*)
|
|
|
|
&new_state->state[p];
|
|
|
|
const struct menu_bind_state_port *o = (const struct menu_bind_state_port*)
|
|
|
|
&state->state[p];
|
2014-06-08 17:48:38 +00:00
|
|
|
|
2014-06-09 23:42:26 +00:00
|
|
|
for (b = 0; b < MENU_MAX_BUTTONS; b++)
|
2014-06-08 17:48:38 +00:00
|
|
|
{
|
2015-01-11 05:34:32 +00:00
|
|
|
bool iterate = n->buttons[b] && !o->buttons[b];
|
|
|
|
|
|
|
|
if (!iterate)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
state->target->joykey = b;
|
|
|
|
state->target->joyaxis = AXIS_NONE;
|
|
|
|
return true;
|
2014-06-08 17:48:38 +00:00
|
|
|
}
|
|
|
|
|
2014-08-20 14:26:34 +00:00
|
|
|
/* Axes are a bit tricky ... */
|
2014-06-09 23:42:26 +00:00
|
|
|
for (a = 0; a < MENU_MAX_AXES; a++)
|
2014-06-08 17:48:38 +00:00
|
|
|
{
|
2015-05-13 01:35:07 +00:00
|
|
|
int locked_distance = abs(n->axes[a] -
|
2014-09-03 03:10:34 +00:00
|
|
|
new_state->axis_state[p].locked_axes[a]);
|
2015-05-13 01:35:07 +00:00
|
|
|
int rested_distance = abs(n->axes[a] -
|
2014-09-03 03:10:34 +00:00
|
|
|
new_state->axis_state[p].rested_axes[a]);
|
2014-06-08 17:48:38 +00:00
|
|
|
|
|
|
|
if (abs(n->axes[a]) >= 20000 &&
|
|
|
|
locked_distance >= 20000 &&
|
2014-08-20 14:26:34 +00:00
|
|
|
rested_distance >= 20000)
|
2014-06-08 17:48:38 +00:00
|
|
|
{
|
2014-08-20 14:26:34 +00:00
|
|
|
/* Take care of case where axis rests on +/- 0x7fff
|
2014-09-02 14:03:17 +00:00
|
|
|
* (e.g. 360 controller on Linux) */
|
2014-06-08 17:48:38 +00:00
|
|
|
state->target->joyaxis = n->axes[a] > 0 ? AXIS_POS(a) : AXIS_NEG(a);
|
|
|
|
state->target->joykey = NO_BTN;
|
|
|
|
|
2014-08-20 14:26:34 +00:00
|
|
|
/* Lock the current axis */
|
2014-06-08 17:48:38 +00:00
|
|
|
new_state->axis_state[p].locked_axes[a] = n->axes[a] > 0 ? 0x7fff : -0x7fff;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-08-20 14:26:34 +00:00
|
|
|
if (locked_distance >= 20000) /* Unlock the axis. */
|
2014-06-08 17:48:38 +00:00
|
|
|
new_state->axis_state[p].locked_axes[a] = 0;
|
|
|
|
}
|
|
|
|
|
2014-06-09 23:42:26 +00:00
|
|
|
for (h = 0; h < MENU_MAX_HATS; h++)
|
2014-06-08 17:48:38 +00:00
|
|
|
{
|
2015-06-13 00:40:01 +00:00
|
|
|
uint16_t trigged = n->hats[h] & (~o->hats[h]);
|
2014-06-08 17:48:38 +00:00
|
|
|
uint16_t sane_trigger = 0;
|
2014-08-20 14:26:34 +00:00
|
|
|
|
2014-06-08 17:48:38 +00:00
|
|
|
if (trigged & HAT_UP_MASK)
|
|
|
|
sane_trigger = HAT_UP_MASK;
|
|
|
|
else if (trigged & HAT_DOWN_MASK)
|
|
|
|
sane_trigger = HAT_DOWN_MASK;
|
|
|
|
else if (trigged & HAT_LEFT_MASK)
|
|
|
|
sane_trigger = HAT_LEFT_MASK;
|
|
|
|
else if (trigged & HAT_RIGHT_MASK)
|
|
|
|
sane_trigger = HAT_RIGHT_MASK;
|
|
|
|
|
|
|
|
if (sane_trigger)
|
|
|
|
{
|
|
|
|
state->target->joykey = HAT_MAP(h, sane_trigger);
|
|
|
|
state->target->joyaxis = AXIS_NONE;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-10-12 14:45:48 +00:00
|
|
|
static bool menu_input_key_bind_poll_find_trigger(struct menu_bind_state *state,
|
2014-08-20 14:26:34 +00:00
|
|
|
struct menu_bind_state *new_state)
|
2014-06-08 17:48:38 +00:00
|
|
|
{
|
|
|
|
unsigned i;
|
2015-03-20 19:43:22 +00:00
|
|
|
settings_t *settings = config_get_ptr();
|
2014-06-08 17:48:38 +00:00
|
|
|
|
|
|
|
if (!state || !new_state)
|
|
|
|
return false;
|
|
|
|
|
2015-03-20 19:43:22 +00:00
|
|
|
for (i = 0; i < settings->input.max_users; i++)
|
2014-06-08 17:48:38 +00:00
|
|
|
{
|
2015-10-12 14:45:48 +00:00
|
|
|
if (!menu_input_key_bind_poll_find_trigger_pad(state, new_state, i))
|
2015-01-11 05:34:32 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
/* Update the joypad mapping automatically.
|
|
|
|
* More friendly that way. */
|
2015-09-06 21:43:27 +00:00
|
|
|
#if 0
|
|
|
|
settings->input.joypad_map[state->user] = i;
|
|
|
|
#endif
|
2015-01-11 05:34:32 +00:00
|
|
|
return true;
|
2014-06-08 17:48:38 +00:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-10-12 14:45:48 +00:00
|
|
|
static bool menu_input_key_bind_custom_bind_keyboard_cb(void *data, unsigned code)
|
2014-06-08 17:48:38 +00:00
|
|
|
{
|
2015-06-13 20:57:55 +00:00
|
|
|
menu_input_t *menu_input = menu_input_get_ptr();
|
2014-06-08 17:48:38 +00:00
|
|
|
|
2015-06-13 20:57:55 +00:00
|
|
|
if (!menu_input)
|
2014-06-08 17:48:38 +00:00
|
|
|
return false;
|
|
|
|
|
2015-06-13 20:57:55 +00:00
|
|
|
menu_input->binds.target->key = (enum retro_key)code;
|
|
|
|
menu_input->binds.begin++;
|
|
|
|
menu_input->binds.target++;
|
2015-09-20 08:02:47 +00:00
|
|
|
menu_input->binds.timeout_end = retro_get_time_usec() +
|
2014-08-20 14:26:34 +00:00
|
|
|
MENU_KEYBOARD_BIND_TIMEOUT_SECONDS * 1000000;
|
|
|
|
|
2015-06-13 20:57:55 +00:00
|
|
|
return (menu_input->binds.begin <= menu_input->binds.last);
|
2014-06-08 17:48:38 +00:00
|
|
|
}
|
|
|
|
|
2015-10-12 14:45:48 +00:00
|
|
|
static int menu_input_key_bind_set_mode_common(rarch_setting_t *setting,
|
2015-04-14 12:04:24 +00:00
|
|
|
enum menu_input_bind_mode type)
|
2015-04-14 11:40:20 +00:00
|
|
|
{
|
2015-09-25 14:12:11 +00:00
|
|
|
size_t selection;
|
2015-10-11 12:23:32 +00:00
|
|
|
unsigned index_offset, bind_type;
|
2015-05-18 18:53:23 +00:00
|
|
|
menu_displaylist_info_t info = {0};
|
2015-04-14 12:04:24 +00:00
|
|
|
struct retro_keybind *keybind = NULL;
|
2015-10-17 15:44:57 +00:00
|
|
|
file_list_t *menu_stack = NULL;
|
2015-06-13 00:40:01 +00:00
|
|
|
settings_t *settings = config_get_ptr();
|
2015-06-13 20:57:55 +00:00
|
|
|
menu_input_t *menu_input = menu_input_get_ptr();
|
2015-04-14 11:40:20 +00:00
|
|
|
|
2015-05-17 20:56:41 +00:00
|
|
|
if (!setting)
|
2015-04-14 11:40:20 +00:00
|
|
|
return -1;
|
|
|
|
|
2015-10-11 15:24:37 +00:00
|
|
|
index_offset = menu_setting_get_index_offset(setting);
|
2015-10-27 09:33:19 +00:00
|
|
|
menu_stack = menu_entries_get_menu_stack_ptr(0);
|
2015-10-11 12:23:32 +00:00
|
|
|
|
2015-09-25 14:12:11 +00:00
|
|
|
menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection);
|
|
|
|
|
2015-04-14 12:04:24 +00:00
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case MENU_INPUT_BIND_NONE:
|
|
|
|
return -1;
|
|
|
|
case MENU_INPUT_BIND_SINGLE:
|
2015-10-17 15:44:57 +00:00
|
|
|
keybind = (struct retro_keybind*)setting_get_ptr(setting);
|
2015-04-14 12:04:24 +00:00
|
|
|
|
|
|
|
if (!keybind)
|
|
|
|
return -1;
|
|
|
|
|
2015-10-11 12:23:32 +00:00
|
|
|
bind_type = menu_setting_get_bind_type(setting);
|
|
|
|
|
|
|
|
menu_input->binds.begin = bind_type;
|
|
|
|
menu_input->binds.last = bind_type;
|
2015-06-13 20:57:55 +00:00
|
|
|
menu_input->binds.target = keybind;
|
2015-10-11 12:23:32 +00:00
|
|
|
menu_input->binds.user = index_offset;
|
2015-05-18 18:53:23 +00:00
|
|
|
|
2015-10-17 15:44:57 +00:00
|
|
|
info.list = menu_stack;
|
|
|
|
info.type = MENU_SETTINGS_CUSTOM_BIND_KEYBOARD;
|
|
|
|
info.directory_ptr = selection;
|
2015-06-18 18:38:02 +00:00
|
|
|
strlcpy(info.label,
|
|
|
|
menu_hash_to_str(MENU_LABEL_CUSTOM_BIND), sizeof(info.label));
|
2015-05-18 18:53:23 +00:00
|
|
|
|
2015-10-21 23:38:41 +00:00
|
|
|
if (menu_displaylist_push_list(&info, DISPLAYLIST_INFO) == 0)
|
|
|
|
menu_displaylist_push_list_process(&info);
|
2015-04-14 12:04:24 +00:00
|
|
|
break;
|
|
|
|
case MENU_INPUT_BIND_ALL:
|
2015-06-13 20:57:55 +00:00
|
|
|
menu_input->binds.target = &settings->input.binds
|
2015-10-11 12:23:32 +00:00
|
|
|
[index_offset][0];
|
2015-06-13 20:57:55 +00:00
|
|
|
menu_input->binds.begin = MENU_SETTINGS_BIND_BEGIN;
|
|
|
|
menu_input->binds.last = MENU_SETTINGS_BIND_LAST;
|
2015-05-18 18:53:23 +00:00
|
|
|
|
2015-10-17 15:44:57 +00:00
|
|
|
info.list = menu_stack;
|
|
|
|
info.type = MENU_SETTINGS_CUSTOM_BIND_KEYBOARD;
|
|
|
|
info.directory_ptr = selection;
|
2015-06-18 18:38:02 +00:00
|
|
|
strlcpy(info.label,
|
|
|
|
menu_hash_to_str(MENU_LABEL_CUSTOM_BIND_ALL),
|
|
|
|
sizeof(info.label));
|
2015-05-18 18:53:23 +00:00
|
|
|
|
2015-10-21 23:38:41 +00:00
|
|
|
if (menu_displaylist_push_list(&info, DISPLAYLIST_INFO) == 0)
|
|
|
|
menu_displaylist_push_list_process(&info);
|
2015-04-14 12:04:24 +00:00
|
|
|
break;
|
|
|
|
}
|
2015-10-17 15:44:57 +00:00
|
|
|
|
2015-05-17 20:56:41 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2015-04-14 12:04:24 +00:00
|
|
|
|
2015-10-22 18:21:27 +00:00
|
|
|
int menu_input_key_bind_set_mode(void *data,
|
2015-04-14 12:04:24 +00:00
|
|
|
enum menu_input_bind_mode type)
|
2015-04-14 11:43:24 +00:00
|
|
|
{
|
2015-11-07 13:33:18 +00:00
|
|
|
unsigned index_offset;
|
2015-10-22 17:59:30 +00:00
|
|
|
menu_handle_t *menu = menu_driver_get_ptr();
|
2015-10-22 18:21:27 +00:00
|
|
|
menu_input_t *menu_input = menu_input_get_ptr();
|
2015-04-14 12:04:24 +00:00
|
|
|
rarch_setting_t *setting = (rarch_setting_t*)data;
|
2015-10-22 18:21:27 +00:00
|
|
|
settings_t *settings = config_get_ptr();
|
2015-04-14 11:43:24 +00:00
|
|
|
|
2015-10-22 18:21:27 +00:00
|
|
|
if (!setting)
|
|
|
|
return -1;
|
|
|
|
if (menu_input_key_bind_set_mode_common(setting, type) == -1)
|
2015-04-14 11:43:24 +00:00
|
|
|
return -1;
|
|
|
|
|
2015-11-07 13:33:18 +00:00
|
|
|
index_offset = menu_setting_get_index_offset(setting);
|
|
|
|
bind_port = settings->input.joypad_map[index_offset];
|
2015-09-28 20:03:05 +00:00
|
|
|
|
2015-11-07 13:33:18 +00:00
|
|
|
menu_input_key_bind_poll_bind_get_rested_axes(&menu_input->binds, bind_port);
|
|
|
|
menu_input_key_bind_poll_bind_state(&menu_input->binds, bind_port, false);
|
2015-07-26 23:01:32 +00:00
|
|
|
|
2015-11-07 13:33:18 +00:00
|
|
|
menu_input->binds.timeout_end = retro_get_time_usec() +
|
|
|
|
MENU_KEYBOARD_BIND_TIMEOUT_SECONDS * 1000000;
|
2015-10-22 17:59:30 +00:00
|
|
|
|
2015-10-22 18:21:27 +00:00
|
|
|
input_keyboard_wait_keys(menu,
|
|
|
|
menu_input_key_bind_custom_bind_keyboard_cb);
|
2015-04-14 11:43:24 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-10-12 13:46:21 +00:00
|
|
|
void menu_input_key_bind_set_min_max(unsigned min, unsigned max)
|
|
|
|
{
|
|
|
|
menu_input_t *menu_input = menu_input_get_ptr();
|
|
|
|
|
|
|
|
if (!menu_input)
|
|
|
|
return;
|
|
|
|
|
|
|
|
menu_input->binds.begin = min;
|
|
|
|
menu_input->binds.last = max;
|
|
|
|
}
|
|
|
|
|
2015-10-12 13:41:14 +00:00
|
|
|
int menu_input_key_bind_iterate(char *s, size_t len)
|
2015-05-18 01:37:07 +00:00
|
|
|
{
|
|
|
|
struct menu_bind_state binds;
|
2015-10-22 17:59:30 +00:00
|
|
|
bool timed_out = false;
|
2015-06-13 20:57:55 +00:00
|
|
|
menu_input_t *menu_input = menu_input_get_ptr();
|
2015-06-12 22:09:09 +00:00
|
|
|
driver_t *driver = driver_get_ptr();
|
2015-09-20 08:02:47 +00:00
|
|
|
int64_t current = retro_get_time_usec();
|
2015-08-17 04:40:28 +00:00
|
|
|
int timeout = (menu_input->binds.timeout_end - current) / 1000000;
|
2015-05-18 01:37:07 +00:00
|
|
|
|
2015-10-22 17:59:30 +00:00
|
|
|
if (timeout <= 0)
|
|
|
|
{
|
2015-11-07 13:33:18 +00:00
|
|
|
input_driver_keyboard_mapping_set_block(false);
|
2015-10-22 17:59:30 +00:00
|
|
|
|
|
|
|
menu_input->binds.begin++;
|
|
|
|
menu_input->binds.target++;
|
|
|
|
menu_input->binds.timeout_end = retro_get_time_usec() +
|
|
|
|
MENU_KEYBOARD_BIND_TIMEOUT_SECONDS * 1000000;
|
|
|
|
timed_out = true;
|
|
|
|
}
|
|
|
|
|
2015-11-07 13:33:18 +00:00
|
|
|
snprintf(s, len,
|
|
|
|
"[%s]\npress keyboard or joypad\n(timeout %d %s)",
|
|
|
|
input_config_bind_map[
|
|
|
|
menu_input->binds.begin - MENU_SETTINGS_BIND_BEGIN].desc,
|
|
|
|
timeout,
|
|
|
|
menu_hash_to_str(MENU_VALUE_SECONDS));
|
|
|
|
|
|
|
|
/* binds.begin is updated in keyboard_press callback. */
|
|
|
|
if (menu_input->binds.begin > menu_input->binds.last)
|
2015-08-17 04:40:28 +00:00
|
|
|
{
|
2015-11-07 13:33:18 +00:00
|
|
|
/* Avoid new binds triggering things right away. */
|
|
|
|
driver->flushing_input = true;
|
|
|
|
|
|
|
|
/* We won't be getting any key events, so just cancel early. */
|
|
|
|
if (timed_out)
|
|
|
|
input_keyboard_wait_keys_cancel();
|
|
|
|
|
|
|
|
return 1;
|
2015-08-17 04:40:28 +00:00
|
|
|
}
|
2015-05-18 01:46:15 +00:00
|
|
|
|
2015-06-13 20:57:55 +00:00
|
|
|
binds = menu_input->binds;
|
2015-05-18 01:37:07 +00:00
|
|
|
|
2015-06-19 01:45:23 +00:00
|
|
|
input_driver_keyboard_mapping_set_block(true);
|
2015-10-22 17:59:30 +00:00
|
|
|
menu_input_key_bind_poll_bind_state(&binds, bind_port, timed_out);
|
2015-05-18 01:37:07 +00:00
|
|
|
|
2015-06-13 20:57:55 +00:00
|
|
|
if ((binds.skip && !menu_input->binds.skip) ||
|
2015-10-12 14:45:48 +00:00
|
|
|
menu_input_key_bind_poll_find_trigger(&menu_input->binds, &binds))
|
2015-05-18 01:37:07 +00:00
|
|
|
{
|
2015-06-19 01:45:23 +00:00
|
|
|
input_driver_keyboard_mapping_set_block(false);
|
2015-05-18 01:37:07 +00:00
|
|
|
|
|
|
|
/* Avoid new binds triggering things right away. */
|
|
|
|
driver->flushing_input = true;
|
|
|
|
|
|
|
|
binds.begin++;
|
|
|
|
|
|
|
|
if (binds.begin > binds.last)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
binds.target++;
|
2015-10-22 17:59:30 +00:00
|
|
|
binds.timeout_end = retro_get_time_usec() +
|
|
|
|
MENU_KEYBOARD_BIND_TIMEOUT_SECONDS * 1000000;
|
2015-05-18 01:37:07 +00:00
|
|
|
}
|
2015-06-13 20:57:55 +00:00
|
|
|
menu_input->binds = binds;
|
2015-05-18 01:37:07 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-03-31 12:38:05 +00:00
|
|
|
static int menu_input_mouse(unsigned *action)
|
|
|
|
{
|
2015-06-13 00:40:01 +00:00
|
|
|
video_viewport_t vp;
|
2015-03-31 12:38:05 +00:00
|
|
|
const struct retro_keybind *binds[MAX_USERS];
|
2015-06-13 20:57:55 +00:00
|
|
|
menu_input_t *menu_input = menu_input_get_ptr();
|
2015-03-31 12:38:05 +00:00
|
|
|
|
|
|
|
if (!video_driver_viewport_info(&vp))
|
|
|
|
return -1;
|
|
|
|
|
2015-06-13 20:57:55 +00:00
|
|
|
if (menu_input->mouse.hwheeldown)
|
2015-03-31 12:38:05 +00:00
|
|
|
{
|
|
|
|
*action = MENU_ACTION_LEFT;
|
2015-06-13 20:57:55 +00:00
|
|
|
menu_input->mouse.hwheeldown = false;
|
2015-03-31 12:38:05 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-06-13 20:57:55 +00:00
|
|
|
if (menu_input->mouse.hwheelup)
|
2015-03-31 12:38:05 +00:00
|
|
|
{
|
|
|
|
*action = MENU_ACTION_RIGHT;
|
2015-06-13 20:57:55 +00:00
|
|
|
menu_input->mouse.hwheelup = false;
|
2015-03-31 12:38:05 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-06-13 20:57:55 +00:00
|
|
|
menu_input->mouse.left = input_driver_state(binds, 0, RETRO_DEVICE_MOUSE,
|
2015-03-31 12:38:05 +00:00
|
|
|
0, RETRO_DEVICE_ID_MOUSE_LEFT);
|
2015-06-13 20:57:55 +00:00
|
|
|
menu_input->mouse.right = input_driver_state(binds, 0, RETRO_DEVICE_MOUSE,
|
2015-03-31 12:38:05 +00:00
|
|
|
0, RETRO_DEVICE_ID_MOUSE_RIGHT);
|
2015-06-13 20:57:55 +00:00
|
|
|
menu_input->mouse.wheelup = input_driver_state(binds, 0, RETRO_DEVICE_MOUSE,
|
2015-03-31 12:38:05 +00:00
|
|
|
0, RETRO_DEVICE_ID_MOUSE_WHEELUP);
|
2015-06-13 20:57:55 +00:00
|
|
|
menu_input->mouse.wheeldown = input_driver_state(binds, 0, RETRO_DEVICE_MOUSE,
|
2015-03-31 12:38:05 +00:00
|
|
|
0, RETRO_DEVICE_ID_MOUSE_WHEELDOWN);
|
2015-06-13 20:57:55 +00:00
|
|
|
menu_input->mouse.hwheelup = input_driver_state(binds, 0, RETRO_DEVICE_MOUSE,
|
2015-03-31 12:38:05 +00:00
|
|
|
0, RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELUP);
|
2015-06-13 20:57:55 +00:00
|
|
|
menu_input->mouse.hwheeldown = input_driver_state(binds, 0, RETRO_DEVICE_MOUSE,
|
2015-03-31 12:38:05 +00:00
|
|
|
0, RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELDOWN);
|
2015-10-11 06:48:36 +00:00
|
|
|
menu_input->mouse.x = input_driver_state(binds, 0, RARCH_DEVICE_MOUSE_SCREEN,
|
2015-10-08 08:07:30 +00:00
|
|
|
0, RETRO_DEVICE_ID_MOUSE_X);
|
2015-10-11 06:48:36 +00:00
|
|
|
menu_input->mouse.y = input_driver_state(binds, 0, RARCH_DEVICE_MOUSE_SCREEN,
|
2015-10-08 08:07:30 +00:00
|
|
|
0, RETRO_DEVICE_ID_MOUSE_Y);
|
|
|
|
|
2015-03-31 12:38:05 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int menu_input_pointer(unsigned *action)
|
|
|
|
{
|
2015-09-25 18:52:03 +00:00
|
|
|
unsigned fb_width, fb_height;
|
2015-04-04 19:26:11 +00:00
|
|
|
int pointer_device, pointer_x, pointer_y;
|
2015-06-13 00:40:01 +00:00
|
|
|
const struct retro_keybind *binds[MAX_USERS] = {NULL};
|
2015-06-13 20:57:55 +00:00
|
|
|
menu_input_t *menu_input = menu_input_get_ptr();
|
2015-06-13 00:40:01 +00:00
|
|
|
driver_t *driver = driver_get_ptr();
|
2015-03-31 12:38:05 +00:00
|
|
|
|
2015-09-25 18:52:03 +00:00
|
|
|
menu_display_ctl(MENU_DISPLAY_CTL_WIDTH, &fb_width);
|
|
|
|
menu_display_ctl(MENU_DISPLAY_CTL_HEIGHT, &fb_height);
|
|
|
|
|
2015-03-31 12:38:05 +00:00
|
|
|
pointer_device = driver->menu_ctx->set_texture?
|
|
|
|
RETRO_DEVICE_POINTER : RARCH_DEVICE_POINTER_SCREEN;
|
|
|
|
|
2015-06-13 20:57:55 +00:00
|
|
|
menu_input->pointer.pressed[0] = input_driver_state(binds, 0, pointer_device,
|
2015-03-31 12:38:05 +00:00
|
|
|
0, RETRO_DEVICE_ID_POINTER_PRESSED);
|
2015-06-13 20:57:55 +00:00
|
|
|
menu_input->pointer.pressed[1] = input_driver_state(binds, 0, pointer_device,
|
2015-03-31 12:38:05 +00:00
|
|
|
1, RETRO_DEVICE_ID_POINTER_PRESSED);
|
2015-06-13 20:57:55 +00:00
|
|
|
menu_input->pointer.back = input_driver_state(binds, 0, pointer_device,
|
2015-03-31 12:38:05 +00:00
|
|
|
0, RARCH_DEVICE_ID_POINTER_BACK);
|
|
|
|
|
|
|
|
pointer_x = input_driver_state(binds, 0, pointer_device, 0, RETRO_DEVICE_ID_POINTER_X);
|
|
|
|
pointer_y = input_driver_state(binds, 0, pointer_device, 0, RETRO_DEVICE_ID_POINTER_Y);
|
|
|
|
|
2015-09-25 18:52:03 +00:00
|
|
|
menu_input->pointer.x = ((pointer_x + 0x7fff) * (int)fb_width) / 0xFFFF;
|
|
|
|
menu_input->pointer.y = ((pointer_y + 0x7fff) * (int)fb_height) / 0xFFFF;
|
2015-03-31 12:38:05 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-05-11 10:03:02 +00:00
|
|
|
static int menu_input_mouse_frame(
|
|
|
|
menu_file_list_cbs_t *cbs, menu_entry_t *entry,
|
2015-11-01 19:50:06 +00:00
|
|
|
uint64_t input_mouse, unsigned action)
|
2015-05-11 09:36:15 +00:00
|
|
|
{
|
2015-11-01 19:50:06 +00:00
|
|
|
int ret = 0;
|
2015-09-25 14:12:11 +00:00
|
|
|
size_t selection;
|
2015-06-13 20:57:55 +00:00
|
|
|
menu_input_t *menu_input = menu_input_get_ptr();
|
2015-09-25 14:12:11 +00:00
|
|
|
|
|
|
|
menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection);
|
2015-05-11 09:36:15 +00:00
|
|
|
|
2015-05-11 10:03:02 +00:00
|
|
|
if (BIT64_GET(input_mouse, MOUSE_ACTION_BUTTON_L))
|
|
|
|
{
|
2015-11-01 19:50:06 +00:00
|
|
|
ret = menu_driver_pointer_tap(menu_input->mouse.x, menu_input->mouse.y,
|
|
|
|
menu_input->mouse.ptr, cbs, entry, action);
|
2015-05-11 10:03:02 +00:00
|
|
|
}
|
|
|
|
|
2015-05-11 09:36:15 +00:00
|
|
|
if (BIT64_GET(input_mouse, MOUSE_ACTION_BUTTON_R))
|
2015-09-25 14:12:11 +00:00
|
|
|
{
|
2015-10-27 09:29:50 +00:00
|
|
|
menu_entries_pop_stack(&selection, 0);
|
2015-09-25 14:12:11 +00:00
|
|
|
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &selection);
|
|
|
|
}
|
2015-05-11 09:36:15 +00:00
|
|
|
|
|
|
|
if (BIT64_GET(input_mouse, MOUSE_ACTION_WHEEL_DOWN))
|
2015-09-25 12:35:51 +00:00
|
|
|
{
|
|
|
|
unsigned increment_by = 1;
|
|
|
|
menu_navigation_ctl(MENU_NAVIGATION_CTL_INCREMENT, &increment_by);
|
|
|
|
}
|
2015-05-11 09:36:15 +00:00
|
|
|
|
|
|
|
if (BIT64_GET(input_mouse, MOUSE_ACTION_WHEEL_UP))
|
2015-09-25 12:32:04 +00:00
|
|
|
{
|
|
|
|
unsigned decrement_by = 1;
|
|
|
|
menu_navigation_ctl(MENU_NAVIGATION_CTL_DECREMENT, &decrement_by);
|
|
|
|
}
|
2015-05-11 10:03:02 +00:00
|
|
|
|
2015-11-01 19:50:06 +00:00
|
|
|
return ret;
|
2015-05-11 09:36:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int menu_input_mouse_post_iterate(uint64_t *input_mouse,
|
2015-06-01 13:25:46 +00:00
|
|
|
menu_file_list_cbs_t *cbs, unsigned action)
|
2015-04-14 05:38:04 +00:00
|
|
|
{
|
2015-09-25 14:12:11 +00:00
|
|
|
size_t selection;
|
2015-09-25 19:52:04 +00:00
|
|
|
unsigned header_height;
|
2015-06-13 20:57:55 +00:00
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
|
menu_input_t *menu_input = menu_input_get_ptr();
|
2015-04-14 05:38:04 +00:00
|
|
|
|
2015-05-11 20:43:16 +00:00
|
|
|
*input_mouse = MOUSE_ACTION_NONE;
|
|
|
|
|
2015-09-25 14:12:11 +00:00
|
|
|
menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection);
|
|
|
|
|
2015-04-14 14:35:14 +00:00
|
|
|
if (!settings->menu.mouse.enable
|
|
|
|
#ifdef HAVE_OVERLAY
|
2015-07-12 05:03:39 +00:00
|
|
|
|| (settings->input.overlay_enable && input_overlay_is_alive())
|
2015-04-14 14:35:14 +00:00
|
|
|
#endif
|
|
|
|
)
|
2015-04-14 05:38:04 +00:00
|
|
|
{
|
2015-06-13 20:57:55 +00:00
|
|
|
menu_input->mouse.wheeldown = false;
|
|
|
|
menu_input->mouse.wheelup = false;
|
|
|
|
menu_input->mouse.oldleft = false;
|
|
|
|
menu_input->mouse.oldright = false;
|
2015-04-14 05:38:04 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-10-23 07:30:46 +00:00
|
|
|
if (menu_input_mouse_state(MENU_MOUSE_LEFT_BUTTON))
|
2015-04-14 05:38:04 +00:00
|
|
|
{
|
2015-06-13 20:57:55 +00:00
|
|
|
if (!menu_input->mouse.oldleft)
|
2015-04-14 05:38:04 +00:00
|
|
|
{
|
2015-09-25 19:52:04 +00:00
|
|
|
menu_display_ctl(MENU_DISPLAY_CTL_HEADER_HEIGHT, &header_height);
|
|
|
|
|
2015-05-11 10:03:02 +00:00
|
|
|
BIT64_SET(*input_mouse, MOUSE_ACTION_BUTTON_L);
|
|
|
|
|
2015-06-13 20:57:55 +00:00
|
|
|
menu_input->mouse.oldleft = true;
|
2015-04-14 05:38:04 +00:00
|
|
|
|
2015-09-25 19:52:04 +00:00
|
|
|
if ((unsigned)menu_input->mouse.y < header_height)
|
2015-04-20 13:15:55 +00:00
|
|
|
{
|
2015-10-27 09:29:50 +00:00
|
|
|
menu_entries_pop_stack(&selection, 0);
|
2015-09-25 14:12:11 +00:00
|
|
|
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &selection);
|
2015-04-20 13:15:55 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2015-09-25 14:12:11 +00:00
|
|
|
if ((menu_input->mouse.ptr == selection) && cbs && cbs->action_select)
|
2015-05-11 10:03:02 +00:00
|
|
|
{
|
|
|
|
BIT64_SET(*input_mouse, MOUSE_ACTION_BUTTON_L_TOGGLE);
|
|
|
|
}
|
2015-10-17 17:21:18 +00:00
|
|
|
else if (menu_input->mouse.ptr <= (menu_entries_get_size() - 1))
|
2015-05-11 20:36:12 +00:00
|
|
|
{
|
|
|
|
BIT64_SET(*input_mouse, MOUSE_ACTION_BUTTON_L_SET_NAVIGATION);
|
|
|
|
}
|
2015-04-14 05:38:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2015-06-13 20:57:55 +00:00
|
|
|
menu_input->mouse.oldleft = false;
|
2015-04-14 05:38:04 +00:00
|
|
|
|
2015-10-23 07:30:46 +00:00
|
|
|
if (menu_input_mouse_state(MENU_MOUSE_RIGHT_BUTTON))
|
2015-04-14 05:38:04 +00:00
|
|
|
{
|
2015-06-13 20:57:55 +00:00
|
|
|
if (!menu_input->mouse.oldright)
|
2015-04-14 05:38:04 +00:00
|
|
|
{
|
2015-06-13 20:57:55 +00:00
|
|
|
menu_input->mouse.oldright = true;
|
2015-05-11 09:36:15 +00:00
|
|
|
BIT64_SET(*input_mouse, MOUSE_ACTION_BUTTON_R);
|
2015-04-14 05:38:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2015-06-13 20:57:55 +00:00
|
|
|
menu_input->mouse.oldright = false;
|
2015-04-14 05:38:04 +00:00
|
|
|
|
2015-06-13 20:57:55 +00:00
|
|
|
if (menu_input->mouse.wheeldown)
|
2015-05-11 09:36:15 +00:00
|
|
|
{
|
|
|
|
BIT64_SET(*input_mouse, MOUSE_ACTION_WHEEL_DOWN);
|
|
|
|
}
|
2015-04-14 05:38:04 +00:00
|
|
|
|
2015-06-13 20:57:55 +00:00
|
|
|
if (menu_input->mouse.wheelup)
|
2015-05-11 09:36:15 +00:00
|
|
|
{
|
|
|
|
BIT64_SET(*input_mouse, MOUSE_ACTION_WHEEL_UP);
|
|
|
|
}
|
2015-04-14 05:38:04 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-09-24 15:18:17 +00:00
|
|
|
int16_t menu_input_pointer_state(enum menu_input_pointer_state state)
|
|
|
|
{
|
|
|
|
menu_input_t *menu = menu_input_get_ptr();
|
|
|
|
|
|
|
|
if (!menu)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
switch (state)
|
|
|
|
{
|
|
|
|
case MENU_POINTER_X_AXIS:
|
|
|
|
return menu->pointer.x;
|
|
|
|
case MENU_POINTER_Y_AXIS:
|
|
|
|
return menu->pointer.y;
|
2015-09-24 18:32:21 +00:00
|
|
|
case MENU_POINTER_DELTA_X_AXIS:
|
|
|
|
return menu->pointer.dx;
|
|
|
|
case MENU_POINTER_DELTA_Y_AXIS:
|
|
|
|
return menu->pointer.dy;
|
2015-10-25 03:04:46 +00:00
|
|
|
case MENU_POINTER_PRESSED:
|
|
|
|
return menu->pointer.pressed[0];
|
2015-09-24 15:18:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-10-24 01:19:06 +00:00
|
|
|
bool menu_input_mouse_check_hitbox(int x1, int y1, int x2, int y2)
|
|
|
|
{
|
|
|
|
int16_t mouse_x = menu_input_mouse_state(MENU_MOUSE_X_AXIS);
|
|
|
|
int16_t mouse_y = menu_input_mouse_state(MENU_MOUSE_Y_AXIS);
|
|
|
|
|
|
|
|
return ((mouse_x >= x1) && (mouse_x <= x2) && (mouse_y >= y1) && (mouse_y <= y2));
|
|
|
|
}
|
|
|
|
|
2015-09-24 15:29:46 +00:00
|
|
|
int16_t menu_input_mouse_state(enum menu_input_mouse_state state)
|
|
|
|
{
|
|
|
|
menu_input_t *menu = menu_input_get_ptr();
|
|
|
|
|
|
|
|
if (!menu)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
switch (state)
|
|
|
|
{
|
|
|
|
case MENU_MOUSE_X_AXIS:
|
|
|
|
return menu->mouse.x;
|
|
|
|
case MENU_MOUSE_Y_AXIS:
|
|
|
|
return menu->mouse.y;
|
2015-10-23 07:30:46 +00:00
|
|
|
case MENU_MOUSE_LEFT_BUTTON:
|
|
|
|
return menu->mouse.left;
|
|
|
|
case MENU_MOUSE_RIGHT_BUTTON:
|
|
|
|
return menu->mouse.right;
|
2015-10-24 01:13:40 +00:00
|
|
|
case MENU_MOUSE_WHEEL_UP:
|
|
|
|
return menu->mouse.wheelup;
|
|
|
|
case MENU_MOUSE_WHEEL_DOWN:
|
|
|
|
return menu->mouse.wheeldown;
|
2015-09-24 15:29:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-04-14 05:38:04 +00:00
|
|
|
static int menu_input_pointer_post_iterate(menu_file_list_cbs_t *cbs,
|
2015-05-11 09:50:55 +00:00
|
|
|
menu_entry_t *entry, unsigned action)
|
2015-04-14 05:38:04 +00:00
|
|
|
{
|
2015-09-25 20:08:20 +00:00
|
|
|
unsigned header_height;
|
2015-09-25 14:12:11 +00:00
|
|
|
size_t selection;
|
2015-06-13 20:57:55 +00:00
|
|
|
int ret = 0;
|
|
|
|
menu_input_t *menu_input = menu_input_get_ptr();
|
|
|
|
settings_t *settings = config_get_ptr();
|
2015-04-14 05:38:04 +00:00
|
|
|
|
2015-06-15 17:20:48 +00:00
|
|
|
if (!menu_input)
|
2015-04-14 05:38:04 +00:00
|
|
|
return -1;
|
2015-09-25 14:12:11 +00:00
|
|
|
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
|
|
|
|
return -1;
|
2015-09-25 20:08:20 +00:00
|
|
|
menu_display_ctl(MENU_DISPLAY_CTL_HEADER_HEIGHT, &header_height);
|
2015-04-14 05:38:04 +00:00
|
|
|
|
2015-04-19 10:58:36 +00:00
|
|
|
if (!settings->menu.pointer.enable
|
|
|
|
#ifdef HAVE_OVERLAY
|
2015-07-12 05:03:39 +00:00
|
|
|
|| (settings->input.overlay_enable && input_overlay_is_alive())
|
2015-04-19 10:58:36 +00:00
|
|
|
#endif
|
|
|
|
)
|
2015-04-14 05:38:04 +00:00
|
|
|
return 0;
|
|
|
|
|
2015-06-13 20:57:55 +00:00
|
|
|
if (menu_input->pointer.pressed[0])
|
2015-04-14 05:38:04 +00:00
|
|
|
{
|
2015-09-24 15:18:17 +00:00
|
|
|
int16_t pointer_x = menu_input_pointer_state(MENU_POINTER_X_AXIS);
|
|
|
|
int16_t pointer_y = menu_input_pointer_state(MENU_POINTER_Y_AXIS);
|
|
|
|
|
2015-07-15 04:28:54 +00:00
|
|
|
if (!menu_input->pointer.oldpressed[0])
|
2015-04-14 05:38:04 +00:00
|
|
|
{
|
2015-09-24 15:18:17 +00:00
|
|
|
menu_input->pointer.accel = 0;
|
|
|
|
menu_input->pointer.accel0 = 0;
|
|
|
|
menu_input->pointer.accel1 = 0;
|
|
|
|
menu_input->pointer.start_x = pointer_x;
|
|
|
|
menu_input->pointer.start_y = pointer_y;
|
|
|
|
menu_input->pointer.old_x = pointer_x;
|
|
|
|
menu_input->pointer.old_y = pointer_y;
|
2015-06-13 20:57:55 +00:00
|
|
|
menu_input->pointer.oldpressed[0] = true;
|
2015-04-04 19:26:11 +00:00
|
|
|
}
|
2015-09-24 15:18:17 +00:00
|
|
|
else if (abs(pointer_x - menu_input->pointer.start_x) > 3
|
|
|
|
|| abs(pointer_y - menu_input->pointer.start_y) > 3)
|
2015-04-04 19:26:11 +00:00
|
|
|
{
|
2015-09-25 21:37:02 +00:00
|
|
|
float s, delta_time;
|
2015-09-24 15:18:17 +00:00
|
|
|
menu_input->pointer.dragging = true;
|
|
|
|
menu_input->pointer.dx = pointer_x - menu_input->pointer.old_x;
|
|
|
|
menu_input->pointer.dy = pointer_y - menu_input->pointer.old_y;
|
|
|
|
menu_input->pointer.old_x = pointer_x;
|
|
|
|
menu_input->pointer.old_y = pointer_y;
|
2015-07-15 01:04:44 +00:00
|
|
|
|
2015-09-25 21:37:02 +00:00
|
|
|
menu_animation_ctl(MENU_ANIMATION_CTL_DELTA_TIME, &delta_time);
|
|
|
|
|
|
|
|
s = menu_input->pointer.dy / delta_time * 1000000.0;
|
2015-07-15 01:04:44 +00:00
|
|
|
menu_input->pointer.accel = (menu_input->pointer.accel0 + menu_input->pointer.accel1 + s) / 3;
|
|
|
|
menu_input->pointer.accel0 = menu_input->pointer.accel1;
|
|
|
|
menu_input->pointer.accel1 = menu_input->pointer.accel;
|
2015-04-04 19:26:11 +00:00
|
|
|
}
|
2015-04-14 05:38:04 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-06-13 20:57:55 +00:00
|
|
|
if (menu_input->pointer.oldpressed[0])
|
2015-04-14 05:38:04 +00:00
|
|
|
{
|
2015-06-13 20:57:55 +00:00
|
|
|
if (!menu_input->pointer.dragging)
|
2015-11-01 19:44:04 +00:00
|
|
|
ret = menu_driver_pointer_tap(menu_input->pointer.start_x,
|
|
|
|
menu_input->pointer.start_y, menu_input->pointer.ptr, cbs, entry, action);
|
2015-06-13 20:57:55 +00:00
|
|
|
|
|
|
|
menu_input->pointer.oldpressed[0] = false;
|
|
|
|
menu_input->pointer.start_x = 0;
|
|
|
|
menu_input->pointer.start_y = 0;
|
|
|
|
menu_input->pointer.old_x = 0;
|
|
|
|
menu_input->pointer.old_y = 0;
|
|
|
|
menu_input->pointer.dx = 0;
|
|
|
|
menu_input->pointer.dy = 0;
|
|
|
|
menu_input->pointer.dragging = false;
|
2015-04-14 05:38:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-13 20:57:55 +00:00
|
|
|
if (menu_input->pointer.back)
|
2015-04-14 05:38:04 +00:00
|
|
|
{
|
2015-06-13 20:57:55 +00:00
|
|
|
if (!menu_input->pointer.oldback)
|
2015-04-14 05:38:04 +00:00
|
|
|
{
|
2015-06-13 20:57:55 +00:00
|
|
|
menu_input->pointer.oldback = true;
|
2015-10-27 09:29:50 +00:00
|
|
|
menu_entries_pop_stack(&selection, 0);
|
2015-09-25 14:12:11 +00:00
|
|
|
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &selection);
|
2015-04-14 05:38:04 +00:00
|
|
|
}
|
|
|
|
}
|
2015-06-13 20:57:55 +00:00
|
|
|
menu_input->pointer.oldback = menu_input->pointer.back;
|
2015-04-14 05:38:04 +00:00
|
|
|
|
2015-04-04 19:26:11 +00:00
|
|
|
return ret;
|
2015-04-14 05:38:04 +00:00
|
|
|
}
|
|
|
|
|
2015-09-24 18:56:54 +00:00
|
|
|
|
2015-05-11 09:48:43 +00:00
|
|
|
void menu_input_post_iterate(int *ret, unsigned action)
|
2015-04-14 05:38:04 +00:00
|
|
|
{
|
2015-09-25 12:57:37 +00:00
|
|
|
size_t selection;
|
2015-10-17 15:44:57 +00:00
|
|
|
menu_file_list_cbs_t *cbs = NULL;
|
|
|
|
menu_entry_t entry = {{0}};
|
|
|
|
menu_input_t *menu_input = menu_input_get_ptr();
|
|
|
|
settings_t *settings = config_get_ptr();
|
2015-10-27 09:10:33 +00:00
|
|
|
file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0);
|
2015-05-11 09:48:43 +00:00
|
|
|
|
2015-09-25 12:57:37 +00:00
|
|
|
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
|
|
|
|
return;
|
|
|
|
|
2015-10-17 15:44:57 +00:00
|
|
|
if (selection_buf)
|
2015-10-19 14:32:51 +00:00
|
|
|
cbs = menu_entries_get_actiondata_at_offset(selection_buf, selection);
|
2015-09-25 12:57:37 +00:00
|
|
|
|
2015-10-27 09:10:33 +00:00
|
|
|
menu_entry_get(&entry, 0, selection, NULL, false);
|
2015-04-04 19:26:11 +00:00
|
|
|
|
2015-09-24 12:17:03 +00:00
|
|
|
if (settings->menu.mouse.enable)
|
2015-11-01 19:35:43 +00:00
|
|
|
*ret = menu_input_mouse_post_iterate (&menu_input->mouse.state, cbs, action);
|
|
|
|
|
2015-11-01 19:50:06 +00:00
|
|
|
*ret = menu_input_mouse_frame(cbs, &entry, menu_input->mouse.state, action);
|
2015-05-11 09:36:15 +00:00
|
|
|
|
2015-09-24 12:17:03 +00:00
|
|
|
if (settings->menu.pointer.enable)
|
2015-05-11 09:50:55 +00:00
|
|
|
*ret |= menu_input_pointer_post_iterate(cbs, &entry, action);
|
2015-04-14 05:38:04 +00:00
|
|
|
}
|
|
|
|
|
2015-10-24 01:56:28 +00:00
|
|
|
static unsigned menu_input_frame_pointer(unsigned *data)
|
2015-10-23 07:15:05 +00:00
|
|
|
{
|
2015-10-24 01:56:28 +00:00
|
|
|
unsigned ret = *data;
|
2015-10-23 07:15:05 +00:00
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
|
menu_input_t *menu_input = menu_input_get_ptr();
|
|
|
|
bool mouse_enabled = settings->menu.mouse.enable;
|
|
|
|
#ifdef HAVE_OVERLAY
|
|
|
|
if (!mouse_enabled)
|
|
|
|
mouse_enabled = !(settings->input.overlay_enable && input_overlay_is_alive());
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (mouse_enabled)
|
|
|
|
menu_input_mouse(&ret);
|
|
|
|
else
|
|
|
|
memset(&menu_input->mouse, 0, sizeof(menu_input->mouse));
|
|
|
|
|
|
|
|
if (settings->menu.pointer.enable)
|
|
|
|
menu_input_pointer(&ret);
|
|
|
|
else
|
|
|
|
memset(&menu_input->pointer, 0, sizeof(menu_input->pointer));
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-11-07 19:44:40 +00:00
|
|
|
unsigned menu_input_frame_retropad(retro_input_t input, retro_input_t trigger_input)
|
2015-01-10 05:33:05 +00:00
|
|
|
{
|
2015-09-25 21:37:02 +00:00
|
|
|
float delta_time;
|
2015-09-28 04:10:42 +00:00
|
|
|
unsigned ret = MENU_ACTION_NOOP;
|
2015-06-13 00:40:01 +00:00
|
|
|
static bool initial_held = true;
|
|
|
|
static bool first_held = false;
|
2015-01-27 00:29:33 +00:00
|
|
|
static const retro_input_t input_repeat =
|
2015-06-26 14:21:10 +00:00
|
|
|
(1UL << RETRO_DEVICE_ID_JOYPAD_UP)
|
|
|
|
| (1UL << RETRO_DEVICE_ID_JOYPAD_DOWN)
|
|
|
|
| (1UL << RETRO_DEVICE_ID_JOYPAD_LEFT)
|
|
|
|
| (1UL << RETRO_DEVICE_ID_JOYPAD_RIGHT)
|
|
|
|
| (1UL << RETRO_DEVICE_ID_JOYPAD_L)
|
2015-07-14 10:49:54 +00:00
|
|
|
| (1UL << RETRO_DEVICE_ID_JOYPAD_R);
|
2015-09-25 16:37:36 +00:00
|
|
|
bool set_scroll = false;
|
|
|
|
size_t new_scroll_accel = 0;
|
|
|
|
menu_input_t *menu_input = menu_input_get_ptr();
|
|
|
|
driver_t *driver = driver_get_ptr();
|
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
|
|
|
|
|
if (!driver || !menu_input)
|
2015-02-13 19:19:20 +00:00
|
|
|
return 0;
|
2015-01-27 00:29:33 +00:00
|
|
|
|
2015-03-18 18:40:00 +00:00
|
|
|
driver->retro_ctx.poll_cb();
|
2015-01-27 00:29:33 +00:00
|
|
|
|
|
|
|
/* don't run anything first frame, only capture held inputs
|
|
|
|
* for old_input_state. */
|
|
|
|
|
|
|
|
if (input & input_repeat)
|
|
|
|
{
|
|
|
|
if (!first_held)
|
|
|
|
{
|
|
|
|
first_held = true;
|
2015-06-15 00:24:51 +00:00
|
|
|
menu_input->delay.timer = initial_held ? 12 : 6;
|
|
|
|
menu_input->delay.count = 0;
|
2015-01-27 00:29:33 +00:00
|
|
|
}
|
|
|
|
|
2015-06-15 00:24:51 +00:00
|
|
|
if (menu_input->delay.count >= menu_input->delay.timer)
|
2015-01-27 00:29:33 +00:00
|
|
|
{
|
2015-09-25 16:37:36 +00:00
|
|
|
set_scroll = true;
|
|
|
|
first_held = false;
|
2015-01-27 00:29:33 +00:00
|
|
|
trigger_input |= input & input_repeat;
|
2015-09-25 16:37:36 +00:00
|
|
|
|
|
|
|
menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SCROLL_ACCEL,
|
|
|
|
&new_scroll_accel);
|
|
|
|
|
|
|
|
new_scroll_accel = min(new_scroll_accel + 1, 64);
|
2015-01-27 00:29:33 +00:00
|
|
|
}
|
|
|
|
|
2015-09-25 16:37:36 +00:00
|
|
|
initial_held = false;
|
2015-01-27 00:29:33 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-09-25 16:37:36 +00:00
|
|
|
set_scroll = true;
|
|
|
|
first_held = false;
|
2015-01-27 00:29:33 +00:00
|
|
|
initial_held = true;
|
|
|
|
}
|
|
|
|
|
2015-09-25 16:37:36 +00:00
|
|
|
if (set_scroll)
|
|
|
|
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SCROLL_ACCEL,
|
|
|
|
&new_scroll_accel);
|
|
|
|
|
2015-09-25 21:37:02 +00:00
|
|
|
menu_animation_ctl(MENU_ANIMATION_CTL_DELTA_TIME, &delta_time);
|
|
|
|
|
|
|
|
menu_input->delay.count += delta_time / IDEAL_DT;
|
2015-01-27 00:29:33 +00:00
|
|
|
|
2015-06-19 02:37:48 +00:00
|
|
|
if (menu_input->keyboard.display)
|
|
|
|
{
|
2015-06-26 16:35:35 +00:00
|
|
|
/* send return key to close keyboard input window */
|
2015-07-12 05:53:46 +00:00
|
|
|
if (trigger_input & (UINT64_C(1) << settings->menu_cancel_btn))
|
2015-06-19 02:37:48 +00:00
|
|
|
input_keyboard_event(true, '\n', '\n', 0, RETRO_DEVICE_KEYBOARD);
|
|
|
|
|
2015-01-27 00:29:33 +00:00
|
|
|
trigger_input = 0;
|
2015-06-19 02:37:48 +00:00
|
|
|
}
|
|
|
|
|
2015-07-12 05:53:46 +00:00
|
|
|
if (trigger_input & (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_UP))
|
2015-03-31 12:38:05 +00:00
|
|
|
ret = MENU_ACTION_UP;
|
2015-07-12 05:53:46 +00:00
|
|
|
else if (trigger_input & (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_DOWN))
|
2015-03-31 12:38:05 +00:00
|
|
|
ret = MENU_ACTION_DOWN;
|
2015-07-12 05:53:46 +00:00
|
|
|
else if (trigger_input & (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_LEFT))
|
2015-03-31 12:38:05 +00:00
|
|
|
ret = MENU_ACTION_LEFT;
|
2015-07-12 05:53:46 +00:00
|
|
|
else if (trigger_input & (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_RIGHT))
|
2015-03-31 12:38:05 +00:00
|
|
|
ret = MENU_ACTION_RIGHT;
|
2015-07-12 05:53:46 +00:00
|
|
|
else if (trigger_input & (UINT64_C(1) << settings->menu_scroll_up_btn))
|
2015-03-31 12:38:05 +00:00
|
|
|
ret = MENU_ACTION_SCROLL_UP;
|
2015-07-12 05:53:46 +00:00
|
|
|
else if (trigger_input & (UINT64_C(1) << settings->menu_scroll_down_btn))
|
2015-03-31 12:38:05 +00:00
|
|
|
ret = MENU_ACTION_SCROLL_DOWN;
|
2015-07-12 05:53:46 +00:00
|
|
|
else if (trigger_input & (UINT64_C(1) << settings->menu_cancel_btn))
|
2015-03-31 12:38:05 +00:00
|
|
|
ret = MENU_ACTION_CANCEL;
|
2015-07-12 05:53:46 +00:00
|
|
|
else if (trigger_input & (UINT64_C(1) << settings->menu_ok_btn))
|
2015-03-31 12:38:05 +00:00
|
|
|
ret = MENU_ACTION_OK;
|
2015-07-12 05:53:46 +00:00
|
|
|
else if (trigger_input & (UINT64_C(1) << settings->menu_search_btn))
|
2015-03-31 12:38:05 +00:00
|
|
|
ret = MENU_ACTION_SEARCH;
|
2015-07-12 05:53:46 +00:00
|
|
|
else if (trigger_input & (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_Y))
|
2015-05-25 23:10:27 +00:00
|
|
|
ret = MENU_ACTION_SCAN;
|
2015-07-12 05:53:46 +00:00
|
|
|
else if (trigger_input & (UINT64_C(1) << settings->menu_default_btn))
|
2015-03-31 12:38:05 +00:00
|
|
|
ret = MENU_ACTION_START;
|
2015-07-12 05:53:46 +00:00
|
|
|
else if (trigger_input & (UINT64_C(1) << settings->menu_info_btn))
|
2015-06-01 05:21:00 +00:00
|
|
|
ret = MENU_ACTION_INFO;
|
2015-07-12 05:53:46 +00:00
|
|
|
else if (trigger_input & (UINT64_C(1) << RARCH_MENU_TOGGLE))
|
2015-03-31 12:38:05 +00:00
|
|
|
ret = MENU_ACTION_TOGGLE;
|
2015-10-22 17:34:25 +00:00
|
|
|
|
2015-10-24 01:56:28 +00:00
|
|
|
return menu_input_frame_pointer(&ret);
|
2015-01-10 05:33:05 +00:00
|
|
|
}
|