/*
* This file is part of mpv.
*
* mpv is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* mpv 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with mpv. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdbool.h>
#include <unistd.h>
#include <math.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <fcntl.h>
#include <pthread.h>
#include <assert.h>
#include <libavutil/avstring.h>
#include <libavutil/common.h>
#include "osdep/io.h"
#include "misc/rendezvous.h"
#include "input.h"
#include "keycodes.h"
#include "cmd_list.h"
#include "cmd_parse.h"
#include "osdep/threads.h"
#include "osdep/timer.h"
#include "common/msg.h"
#include "common/global.h"
#include "options/m_config.h"
#include "options/m_option.h"
#include "options/path.h"
#include "mpv_talloc.h"
#include "options/options.h"
#include "misc/bstr.h"
#include "stream/stream.h"
#include "common/common.h"
#if HAVE_COCOA
#include "osdep/macosx_events.h"
#endif
#define input_lock(ictx) pthread_mutex_lock(&ictx->mutex)
#define input_unlock(ictx) pthread_mutex_unlock(&ictx->mutex)
#define MP_MAX_KEY_DOWN 4
struct cmd_bind {
int keys[MP_MAX_KEY_DOWN];
int num_keys;
char *cmd;
char *location; // filename/line number of definition
bool is_builtin;
struct cmd_bind_section *owner;
};
struct cmd_bind_section {
char *owner;
struct cmd_bind *binds;
int num_binds;
char *section;
struct mp_rect mouse_area; // set at runtime, if at all
bool mouse_area_set; // mouse_area is valid and should be tested
struct cmd_bind_section *next;
};
#define MP_MAX_SOURCES 10
#define MAX_ACTIVE_SECTIONS 50
struct active_section {
char *name;
int flags;
};
struct cmd_queue {
struct mp_cmd *first;
};
struct wheel_state {
double dead_zone_accum;
double unit_accum;
};
struct input_ctx {
pthread_mutex_t mutex;
struct mp_log *log;
struct mpv_global *global;
struct m_config_cache *opts_cache;
struct input_opts *opts;
bool using_ar;
bool using_cocoa_media_keys;
// Autorepeat stuff
short ar_state;
int64_t last_ar;
// history of key downs - the newest is in position 0
int key_history[MP_MAX_KEY_DOWN];
// key code of the last key that triggered MP_KEY_STATE_DOWN
int last_key_down;
int64_t last_key_down_time;
struct mp_cmd *current_down_cmd;
int last_doubleclick_key_down;
double last_doubleclick_time;
// Mouse position on the consumer side (as command.c sees it)
int mouse_x, mouse_y;
char *mouse_section; // last section to receive mouse event
// Mouse position on the producer side (as the VO sees it)
// Unlike mouse_x/y, this can be used to resolve mouse click bindings.
int mouse_vo_x, mouse_vo_y;
bool mouse_mangle,
|