2014-09-23 01:03:56 +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
|
|
|
|
* Copyright (C) 2012-2015 - Michael Lelli
|
2014-09-23 01:03:56 +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-10-21 03:05:52 +00:00
|
|
|
#include <boolean.h>
|
2014-09-23 01:03:56 +00:00
|
|
|
#include "libretro.h"
|
2014-10-22 02:27:51 +00:00
|
|
|
#include "dynamic.h"
|
2015-01-13 01:29:08 +00:00
|
|
|
#include "libretro_version_1.h"
|
2014-09-23 01:03:56 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2015-03-15 03:30:46 +00:00
|
|
|
#include <retro_inline.h>
|
2014-09-23 01:03:56 +00:00
|
|
|
#include <ctype.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include "general.h"
|
2015-03-15 01:47:23 +00:00
|
|
|
#include "runloop.h"
|
2015-01-09 16:40:47 +00:00
|
|
|
#include "retroarch.h"
|
2014-09-23 01:03:56 +00:00
|
|
|
#include "performance.h"
|
2014-09-24 07:52:01 +00:00
|
|
|
#include "input/keyboard_line.h"
|
2015-01-12 23:19:46 +00:00
|
|
|
#include "audio/audio_utils.h"
|
2014-10-02 21:43:28 +00:00
|
|
|
#include "retroarch_logger.h"
|
2015-02-10 20:09:41 +00:00
|
|
|
#include "record/record_driver.h"
|
2014-10-02 21:43:28 +00:00
|
|
|
#include "intl/intl.h"
|
2014-09-23 01:03:56 +00:00
|
|
|
|
2014-10-20 19:32:53 +00:00
|
|
|
#ifdef HAVE_NETPLAY
|
|
|
|
#include "netplay.h"
|
|
|
|
#endif
|
|
|
|
|
2015-02-19 15:07:11 +00:00
|
|
|
static bool video_frame_scale(const void *data,
|
2015-02-10 19:06:10 +00:00
|
|
|
unsigned width, unsigned height,
|
|
|
|
size_t pitch)
|
|
|
|
{
|
2015-03-18 18:40:00 +00:00
|
|
|
driver_t *driver = driver_get_ptr();
|
2015-03-21 03:43:18 +00:00
|
|
|
global_t *global = global_get_ptr();
|
2015-03-18 18:40:00 +00:00
|
|
|
|
2015-02-10 19:06:10 +00:00
|
|
|
RARCH_PERFORMANCE_INIT(video_frame_conv);
|
2015-02-10 19:14:39 +00:00
|
|
|
|
|
|
|
if (!data)
|
2015-02-19 15:07:11 +00:00
|
|
|
return false;
|
2015-03-21 03:43:18 +00:00
|
|
|
if (global->system.pix_fmt != RETRO_PIXEL_FORMAT_0RGB1555)
|
2015-02-19 15:11:49 +00:00
|
|
|
return false;
|
2015-02-10 19:14:39 +00:00
|
|
|
if (data == RETRO_HW_FRAME_BUFFER_VALID)
|
2015-02-19 15:07:11 +00:00
|
|
|
return false;
|
2015-02-10 19:14:39 +00:00
|
|
|
|
2015-02-10 19:06:10 +00:00
|
|
|
RARCH_PERFORMANCE_START(video_frame_conv);
|
|
|
|
|
2015-03-18 18:40:00 +00:00
|
|
|
driver->scaler.in_width = width;
|
|
|
|
driver->scaler.in_height = height;
|
|
|
|
driver->scaler.out_width = width;
|
|
|
|
driver->scaler.out_height = height;
|
|
|
|
driver->scaler.in_stride = pitch;
|
|
|
|
driver->scaler.out_stride = width * sizeof(uint16_t);
|
2015-02-10 19:06:10 +00:00
|
|
|
|
2015-03-18 18:40:00 +00:00
|
|
|
scaler_ctx_scale(&driver->scaler, driver->scaler_out, data);
|
2015-02-10 19:06:10 +00:00
|
|
|
|
|
|
|
RARCH_PERFORMANCE_STOP(video_frame_conv);
|
2015-02-19 15:07:11 +00:00
|
|
|
|
|
|
|
return true;
|
2015-02-10 19:06:10 +00:00
|
|
|
}
|
|
|
|
|
2015-02-15 17:32:19 +00:00
|
|
|
static bool video_frame_filter(const void *data,
|
2015-02-10 19:06:10 +00:00
|
|
|
unsigned width, unsigned height,
|
2015-02-15 17:32:19 +00:00
|
|
|
size_t pitch,
|
|
|
|
unsigned *output_width, unsigned *output_height,
|
|
|
|
unsigned *output_pitch)
|
2015-02-10 19:06:10 +00:00
|
|
|
{
|
2015-03-20 18:48:23 +00:00
|
|
|
settings_t *settings = config_get_ptr();
|
2015-03-21 03:43:18 +00:00
|
|
|
global_t *global = global_get_ptr();
|
|
|
|
|
2015-02-10 19:14:39 +00:00
|
|
|
RARCH_PERFORMANCE_INIT(softfilter_process);
|
2015-02-10 19:06:10 +00:00
|
|
|
|
2015-03-21 03:43:18 +00:00
|
|
|
if (!global->filter.filter)
|
2015-02-15 17:32:19 +00:00
|
|
|
return false;
|
2015-02-10 19:14:39 +00:00
|
|
|
if (!data)
|
2015-02-15 17:32:19 +00:00
|
|
|
return false;
|
2015-02-10 19:14:39 +00:00
|
|
|
|
2015-03-21 03:43:18 +00:00
|
|
|
rarch_softfilter_get_output_size(global->filter.filter,
|
2015-02-15 17:32:19 +00:00
|
|
|
output_width, output_height, width, height);
|
2015-02-10 19:06:10 +00:00
|
|
|
|
2015-03-21 03:43:18 +00:00
|
|
|
*output_pitch = (*output_width) * global->filter.out_bpp;
|
2015-02-10 19:06:10 +00:00
|
|
|
|
|
|
|
RARCH_PERFORMANCE_START(softfilter_process);
|
2015-03-21 03:43:18 +00:00
|
|
|
rarch_softfilter_process(global->filter.filter,
|
|
|
|
global->filter.buffer, *output_pitch,
|
2015-02-10 19:06:10 +00:00
|
|
|
data, width, height, pitch);
|
|
|
|
RARCH_PERFORMANCE_STOP(softfilter_process);
|
|
|
|
|
2015-03-20 18:48:23 +00:00
|
|
|
if (settings->video.post_filter_record)
|
2015-03-21 03:43:18 +00:00
|
|
|
recording_dump_frame(global->filter.buffer,
|
2015-02-15 17:32:19 +00:00
|
|
|
*output_width, *output_height, *output_pitch);
|
2015-02-10 19:06:10 +00:00
|
|
|
|
2015-02-15 17:32:19 +00:00
|
|
|
return true;
|
2015-02-10 19:06:10 +00:00
|
|
|
}
|
|
|
|
|
2015-01-07 16:02:47 +00:00
|
|
|
/**
|
|
|
|
* video_frame:
|
|
|
|
* @data : pointer to data of the video frame.
|
|
|
|
* @width : width of the video frame.
|
|
|
|
* @height : height of the video frame.
|
|
|
|
* @pitch : pitch of the video frame.
|
|
|
|
*
|
|
|
|
* Video frame render callback function.
|
|
|
|
**/
|
2014-09-23 01:03:56 +00:00
|
|
|
static void video_frame(const void *data, unsigned width,
|
|
|
|
unsigned height, size_t pitch)
|
|
|
|
{
|
2015-02-15 17:32:19 +00:00
|
|
|
unsigned output_width = 0, output_height = 0, output_pitch = 0;
|
2015-03-22 06:37:25 +00:00
|
|
|
const char *msg = NULL;
|
2015-03-20 18:48:23 +00:00
|
|
|
driver_t *driver = driver_get_ptr();
|
2015-03-21 03:43:18 +00:00
|
|
|
global_t *global = global_get_ptr();
|
2015-03-20 18:48:23 +00:00
|
|
|
settings_t *settings = config_get_ptr();
|
2014-09-23 01:03:56 +00:00
|
|
|
|
2015-03-18 18:40:00 +00:00
|
|
|
if (!driver->video_active)
|
2014-09-23 01:03:56 +00:00
|
|
|
return;
|
|
|
|
|
2015-03-21 03:43:18 +00:00
|
|
|
global->frame_cache.data = data;
|
|
|
|
global->frame_cache.width = width;
|
|
|
|
global->frame_cache.height = height;
|
|
|
|
global->frame_cache.pitch = pitch;
|
2014-09-23 01:03:56 +00:00
|
|
|
|
2015-02-19 15:11:49 +00:00
|
|
|
if (video_frame_scale(data, width, height, pitch))
|
2015-02-19 15:07:11 +00:00
|
|
|
{
|
2015-03-18 18:40:00 +00:00
|
|
|
data = driver->scaler_out;
|
|
|
|
pitch = driver->scaler.out_stride;
|
2015-02-19 15:07:11 +00:00
|
|
|
}
|
2014-09-23 01:03:56 +00:00
|
|
|
|
|
|
|
/* Slightly messy code,
|
|
|
|
* but we really need to do processing before blocking on VSync
|
|
|
|
* for best possible scheduling.
|
|
|
|
*/
|
2015-03-21 03:43:18 +00:00
|
|
|
if ((!global->filter.filter
|
2015-03-20 18:48:23 +00:00
|
|
|
|| !settings->video.post_filter_record || !data
|
2015-03-21 03:43:18 +00:00
|
|
|
|| global->record.gpu_buffer)
|
2014-09-23 01:03:56 +00:00
|
|
|
)
|
2015-02-10 20:09:41 +00:00
|
|
|
recording_dump_frame(data, width, height, pitch);
|
2014-09-23 01:03:56 +00:00
|
|
|
|
2015-03-15 01:47:23 +00:00
|
|
|
msg = rarch_main_msg_queue_pull();
|
2015-03-18 18:40:00 +00:00
|
|
|
driver->current_msg = msg;
|
2014-09-23 01:03:56 +00:00
|
|
|
|
2015-02-15 17:32:19 +00:00
|
|
|
if (video_frame_filter(data, width, height, pitch,
|
|
|
|
&output_width, &output_height, &output_pitch))
|
|
|
|
{
|
2015-03-21 03:43:18 +00:00
|
|
|
data = global->filter.buffer;
|
2015-02-15 17:32:19 +00:00
|
|
|
width = output_width;
|
|
|
|
height = output_height;
|
|
|
|
pitch = output_pitch;
|
|
|
|
}
|
2014-09-23 01:03:56 +00:00
|
|
|
|
2015-03-24 12:27:38 +00:00
|
|
|
if (!video_driver_frame(data, width, height, pitch, msg))
|
|
|
|
driver->video_active = false;
|
2014-09-23 01:03:56 +00:00
|
|
|
}
|
|
|
|
|
2015-01-08 17:39:17 +00:00
|
|
|
/**
|
2015-01-13 01:33:29 +00:00
|
|
|
* retro_flush_audio:
|
2015-01-08 17:39:17 +00:00
|
|
|
* @data : pointer to audio buffer.
|
|
|
|
* @right : amount of samples to write.
|
|
|
|
*
|
|
|
|
* Writes audio samples to audio driver. Will first
|
|
|
|
* perform DSP processing (if enabled) and resampling.
|
|
|
|
*
|
|
|
|
* Returns: true (1) if audio samples were written to the audio
|
|
|
|
* driver, false (0) in case of an error.
|
|
|
|
**/
|
2015-01-13 01:33:29 +00:00
|
|
|
bool retro_flush_audio(const int16_t *data, size_t samples)
|
2014-10-02 21:43:28 +00:00
|
|
|
{
|
|
|
|
const void *output_data = NULL;
|
|
|
|
unsigned output_frames = 0;
|
|
|
|
size_t output_size = sizeof(float);
|
|
|
|
struct resampler_data src_data = {0};
|
|
|
|
struct rarch_dsp_data dsp_data = {0};
|
2015-03-18 05:47:22 +00:00
|
|
|
runloop_t *runloop = rarch_main_get_ptr();
|
2015-03-18 18:40:00 +00:00
|
|
|
driver_t *driver = driver_get_ptr();
|
2015-03-21 03:43:18 +00:00
|
|
|
global_t *global = global_get_ptr();
|
2015-03-20 18:48:23 +00:00
|
|
|
settings_t *settings = config_get_ptr();
|
2014-10-02 21:43:28 +00:00
|
|
|
|
2015-03-18 18:40:00 +00:00
|
|
|
if (driver->recording_data)
|
2014-10-02 21:43:28 +00:00
|
|
|
{
|
|
|
|
struct ffemu_audio_data ffemu_data = {0};
|
|
|
|
ffemu_data.data = data;
|
|
|
|
ffemu_data.frames = samples / 2;
|
|
|
|
|
2015-03-18 18:40:00 +00:00
|
|
|
if (driver->recording && driver->recording->push_audio)
|
|
|
|
driver->recording->push_audio(driver->recording_data, &ffemu_data);
|
2014-10-02 21:43:28 +00:00
|
|
|
}
|
|
|
|
|
2015-03-20 18:48:23 +00:00
|
|
|
if (runloop->is_paused || settings->audio.mute_enable)
|
2014-10-02 21:43:28 +00:00
|
|
|
return true;
|
2015-03-21 03:43:18 +00:00
|
|
|
if (!driver->audio_active || !global->audio_data.data)
|
2014-10-02 21:43:28 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
RARCH_PERFORMANCE_INIT(audio_convert_s16);
|
|
|
|
RARCH_PERFORMANCE_START(audio_convert_s16);
|
2015-03-21 03:43:18 +00:00
|
|
|
audio_convert_s16_to_float(global->audio_data.data, data, samples,
|
|
|
|
global->audio_data.volume_gain);
|
2014-10-02 21:43:28 +00:00
|
|
|
RARCH_PERFORMANCE_STOP(audio_convert_s16);
|
|
|
|
|
2015-03-21 03:43:18 +00:00
|
|
|
src_data.data_in = global->audio_data.data;
|
2015-01-10 18:40:57 +00:00
|
|
|
src_data.input_frames = samples >> 1;
|
|
|
|
|
2015-03-21 03:43:18 +00:00
|
|
|
dsp_data.input = global->audio_data.data;
|
2014-10-02 21:43:28 +00:00
|
|
|
dsp_data.input_frames = samples >> 1;
|
|
|
|
|
2015-03-21 03:43:18 +00:00
|
|
|
if (global->audio_data.dsp)
|
2014-10-02 21:43:28 +00:00
|
|
|
{
|
|
|
|
RARCH_PERFORMANCE_INIT(audio_dsp);
|
|
|
|
RARCH_PERFORMANCE_START(audio_dsp);
|
2015-03-21 03:43:18 +00:00
|
|
|
rarch_dsp_filter_process(global->audio_data.dsp, &dsp_data);
|
2014-10-02 21:43:28 +00:00
|
|
|
RARCH_PERFORMANCE_STOP(audio_dsp);
|
|
|
|
|
2015-01-10 18:40:57 +00:00
|
|
|
if (dsp_data.output)
|
|
|
|
{
|
|
|
|
src_data.data_in = dsp_data.output;
|
|
|
|
src_data.input_frames = dsp_data.output_frames;
|
|
|
|
}
|
|
|
|
}
|
2014-10-02 21:43:28 +00:00
|
|
|
|
2015-03-21 03:43:18 +00:00
|
|
|
src_data.data_out = global->audio_data.outsamples;
|
2014-10-02 21:43:28 +00:00
|
|
|
|
2015-03-21 03:43:18 +00:00
|
|
|
if (global->audio_data.rate_control)
|
2015-02-11 16:36:31 +00:00
|
|
|
audio_driver_readjust_input_rate();
|
2014-10-02 21:43:28 +00:00
|
|
|
|
2015-03-21 03:43:18 +00:00
|
|
|
src_data.ratio = global->audio_data.src_ratio;
|
2015-03-18 05:47:22 +00:00
|
|
|
if (runloop->is_slowmotion)
|
2015-03-20 18:48:23 +00:00
|
|
|
src_data.ratio *= settings->slowmotion_ratio;
|
2014-10-02 21:43:28 +00:00
|
|
|
|
|
|
|
RARCH_PERFORMANCE_INIT(resampler_proc);
|
|
|
|
RARCH_PERFORMANCE_START(resampler_proc);
|
2015-03-18 18:40:00 +00:00
|
|
|
rarch_resampler_process(driver->resampler,
|
|
|
|
driver->resampler_data, &src_data);
|
2014-10-02 21:43:28 +00:00
|
|
|
RARCH_PERFORMANCE_STOP(resampler_proc);
|
|
|
|
|
2015-03-21 03:43:18 +00:00
|
|
|
output_data = global->audio_data.outsamples;
|
2014-10-02 21:43:28 +00:00
|
|
|
output_frames = src_data.output_frames;
|
|
|
|
|
2015-03-21 03:43:18 +00:00
|
|
|
if (!global->audio_data.use_float)
|
2014-10-02 21:43:28 +00:00
|
|
|
{
|
|
|
|
RARCH_PERFORMANCE_INIT(audio_convert_float);
|
|
|
|
RARCH_PERFORMANCE_START(audio_convert_float);
|
2015-03-21 03:43:18 +00:00
|
|
|
audio_convert_float_to_s16(global->audio_data.conv_outsamples,
|
2014-10-02 21:43:28 +00:00
|
|
|
(const float*)output_data, output_frames * 2);
|
|
|
|
RARCH_PERFORMANCE_STOP(audio_convert_float);
|
|
|
|
|
2015-03-21 03:43:18 +00:00
|
|
|
output_data = global->audio_data.conv_outsamples;
|
2014-10-02 21:43:28 +00:00
|
|
|
output_size = sizeof(int16_t);
|
|
|
|
}
|
|
|
|
|
2015-03-23 01:51:46 +00:00
|
|
|
if (audio_driver_write(output_data, output_frames * output_size * 2) < 0)
|
2014-10-02 21:43:28 +00:00
|
|
|
{
|
|
|
|
RARCH_ERR(RETRO_LOG_AUDIO_WRITE_FAILED);
|
2015-01-13 01:33:29 +00:00
|
|
|
|
2015-03-18 18:40:00 +00:00
|
|
|
driver->audio_active = false;
|
2014-10-02 21:43:28 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-01-07 16:02:47 +00:00
|
|
|
/**
|
|
|
|
* audio_sample:
|
|
|
|
* @left : value of the left audio channel.
|
|
|
|
* @right : value of the right audio channel.
|
|
|
|
*
|
|
|
|
* Audio sample render callback function.
|
|
|
|
**/
|
2014-09-23 01:03:56 +00:00
|
|
|
static void audio_sample(int16_t left, int16_t right)
|
|
|
|
{
|
2015-03-21 03:43:18 +00:00
|
|
|
global_t *global = global_get_ptr();
|
|
|
|
|
|
|
|
global->audio_data.conv_outsamples[global->audio_data.data_ptr++] = left;
|
|
|
|
global->audio_data.conv_outsamples[global->audio_data.data_ptr++] = right;
|
2014-09-23 01:03:56 +00:00
|
|
|
|
2015-03-21 03:43:18 +00:00
|
|
|
if (global->audio_data.data_ptr < global->audio_data.chunk_size)
|
2014-09-23 01:03:56 +00:00
|
|
|
return;
|
|
|
|
|
2015-03-21 03:43:18 +00:00
|
|
|
retro_flush_audio(global->audio_data.conv_outsamples, global->audio_data.data_ptr);
|
2014-09-23 01:03:56 +00:00
|
|
|
|
2015-03-21 03:43:18 +00:00
|
|
|
global->audio_data.data_ptr = 0;
|
2014-09-23 01:03:56 +00:00
|
|
|
}
|
|
|
|
|
2015-01-07 16:02:47 +00:00
|
|
|
/**
|
|
|
|
* audio_sample_batch:
|
|
|
|
* @data : pointer to audio buffer.
|
|
|
|
* @frames : amount of audio frames to push.
|
|
|
|
*
|
|
|
|
* Batched audio sample render callback function.
|
|
|
|
*
|
|
|
|
* Returns: amount of frames sampled. Will be equal to @frames
|
|
|
|
* unless @frames exceeds (AUDIO_CHUNK_SIZE_NONBLOCKING / 2).
|
|
|
|
**/
|
2014-09-23 01:03:56 +00:00
|
|
|
static size_t audio_sample_batch(const int16_t *data, size_t frames)
|
|
|
|
{
|
|
|
|
if (frames > (AUDIO_CHUNK_SIZE_NONBLOCKING >> 1))
|
|
|
|
frames = AUDIO_CHUNK_SIZE_NONBLOCKING >> 1;
|
|
|
|
|
2015-01-13 01:33:29 +00:00
|
|
|
retro_flush_audio(data, frames << 1);
|
2015-01-08 17:39:17 +00:00
|
|
|
|
|
|
|
return frames;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* audio_sample_rewind:
|
|
|
|
* @left : value of the left audio channel.
|
|
|
|
* @right : value of the right audio channel.
|
|
|
|
*
|
|
|
|
* Audio sample render callback function (rewind version). This callback
|
|
|
|
* function will be used instead of audio_sample when rewinding is activated.
|
|
|
|
**/
|
|
|
|
static void audio_sample_rewind(int16_t left, int16_t right)
|
|
|
|
{
|
2015-03-21 03:43:18 +00:00
|
|
|
global_t *global = global_get_ptr();
|
|
|
|
|
|
|
|
global->audio_data.rewind_buf[--global->audio_data.rewind_ptr] = right;
|
|
|
|
global->audio_data.rewind_buf[--global->audio_data.rewind_ptr] = left;
|
2015-01-08 17:39:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* audio_sample_batch_rewind:
|
|
|
|
* @data : pointer to audio buffer.
|
|
|
|
* @frames : amount of audio frames to push.
|
|
|
|
*
|
|
|
|
* Batched audio sample render callback function (rewind version). This callback
|
|
|
|
* function will be used instead of audio_sample_batch when rewinding is activated.
|
|
|
|
*
|
|
|
|
* Returns: amount of frames sampled. Will be equal to @frames
|
|
|
|
* unless @frames exceeds (AUDIO_CHUNK_SIZE_NONBLOCKING / 2).
|
|
|
|
**/
|
|
|
|
static size_t audio_sample_batch_rewind(const int16_t *data, size_t frames)
|
|
|
|
{
|
|
|
|
size_t i;
|
2015-03-22 06:37:25 +00:00
|
|
|
size_t samples = frames << 1;
|
2015-03-21 03:43:18 +00:00
|
|
|
global_t *global = global_get_ptr();
|
2015-01-08 17:39:17 +00:00
|
|
|
|
|
|
|
for (i = 0; i < samples; i++)
|
2015-03-21 03:43:18 +00:00
|
|
|
global->audio_data.rewind_buf[--global->audio_data.rewind_ptr] = data[i];
|
2014-09-23 01:03:56 +00:00
|
|
|
|
|
|
|
return frames;
|
|
|
|
}
|
|
|
|
|
2015-01-07 16:02:47 +00:00
|
|
|
/**
|
|
|
|
* input_apply_turbo:
|
|
|
|
* @port : user number
|
|
|
|
* @id : identifier of the key
|
|
|
|
* @res : boolean return value. FIXME/TODO: to be refactored.
|
|
|
|
*
|
|
|
|
* Apply turbo button if activated.
|
|
|
|
*
|
|
|
|
* If turbo button is held, all buttons pressed except
|
2014-09-23 01:03:56 +00:00
|
|
|
* for D-pad will go into a turbo mode. Until the button is
|
2015-01-07 16:02:47 +00:00
|
|
|
* released again, the input state will be modulated by a
|
|
|
|
* periodic pulse defined by the configured duty cycle.
|
|
|
|
*
|
|
|
|
* Returns: 1 (true) if turbo button is enabled for this
|
|
|
|
* key ID, otherwise the value of @res will be returned.
|
|
|
|
*
|
|
|
|
**/
|
2014-09-23 01:03:56 +00:00
|
|
|
static bool input_apply_turbo(unsigned port, unsigned id, bool res)
|
|
|
|
{
|
2015-03-20 18:48:23 +00:00
|
|
|
settings_t *settings = config_get_ptr();
|
2015-03-21 03:43:18 +00:00
|
|
|
global_t *global = global_get_ptr();
|
2015-03-20 18:48:23 +00:00
|
|
|
|
2015-03-21 03:43:18 +00:00
|
|
|
if (res && global->turbo_frame_enable[port])
|
|
|
|
global->turbo_enable[port] |= (1 << id);
|
2014-09-23 01:03:56 +00:00
|
|
|
else if (!res)
|
2015-03-21 03:43:18 +00:00
|
|
|
global->turbo_enable[port] &= ~(1 << id);
|
2014-09-23 01:03:56 +00:00
|
|
|
|
2015-03-21 03:43:18 +00:00
|
|
|
if (global->turbo_enable[port] & (1 << id))
|
|
|
|
return res && ((global->turbo_count % settings->input.turbo_period)
|
2015-03-20 18:48:23 +00:00
|
|
|
< settings->input.turbo_duty_cycle);
|
2014-09-23 01:03:56 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2015-01-07 16:02:47 +00:00
|
|
|
/**
|
|
|
|
* input_state:
|
|
|
|
* @port : user number.
|
|
|
|
* @device : device identifier of user.
|
|
|
|
* @idx : index value of user.
|
|
|
|
* @id : identifier of key pressed by user.
|
|
|
|
*
|
|
|
|
* Input state callback function.
|
|
|
|
*
|
|
|
|
* Returns: Non-zero if the given key (identified by @id) was pressed by the user
|
|
|
|
* (assigned to @port).
|
|
|
|
**/
|
2014-09-23 01:03:56 +00:00
|
|
|
static int16_t input_state(unsigned port, unsigned device,
|
2014-10-20 21:24:01 +00:00
|
|
|
unsigned idx, unsigned id)
|
2014-09-23 01:03:56 +00:00
|
|
|
{
|
2015-03-22 06:37:25 +00:00
|
|
|
int16_t res = 0;
|
2015-03-20 18:48:23 +00:00
|
|
|
settings_t *settings = config_get_ptr();
|
2015-03-20 22:22:41 +00:00
|
|
|
driver_t *driver = driver_get_ptr();
|
2015-03-21 03:43:18 +00:00
|
|
|
global_t *global = global_get_ptr();
|
2015-03-20 22:22:41 +00:00
|
|
|
const struct retro_keybind *libretro_input_binds[MAX_USERS] = {
|
|
|
|
settings->input.binds[0],
|
|
|
|
settings->input.binds[1],
|
|
|
|
settings->input.binds[2],
|
|
|
|
settings->input.binds[3],
|
|
|
|
settings->input.binds[4],
|
|
|
|
settings->input.binds[5],
|
|
|
|
settings->input.binds[6],
|
|
|
|
settings->input.binds[7],
|
|
|
|
settings->input.binds[8],
|
|
|
|
settings->input.binds[9],
|
|
|
|
settings->input.binds[10],
|
|
|
|
settings->input.binds[11],
|
|
|
|
settings->input.binds[12],
|
|
|
|
settings->input.binds[13],
|
|
|
|
settings->input.binds[14],
|
|
|
|
settings->input.binds[15],
|
2014-09-23 01:03:56 +00:00
|
|
|
};
|
|
|
|
|
2015-01-05 21:53:21 +00:00
|
|
|
device &= RETRO_DEVICE_MASK;
|
|
|
|
|
2015-03-21 03:43:18 +00:00
|
|
|
if (global->bsv.movie && global->bsv.movie_playback)
|
2015-01-05 21:53:21 +00:00
|
|
|
{
|
|
|
|
int16_t ret;
|
2015-03-21 03:43:18 +00:00
|
|
|
if (bsv_movie_get_input(global->bsv.movie, &ret))
|
2015-01-05 21:53:21 +00:00
|
|
|
return ret;
|
|
|
|
|
2015-03-21 03:43:18 +00:00
|
|
|
global->bsv.movie_end = true;
|
2015-01-05 21:53:21 +00:00
|
|
|
}
|
|
|
|
|
2015-03-20 18:48:23 +00:00
|
|
|
if (settings->input.remap_binds_enable)
|
2015-01-10 21:38:58 +00:00
|
|
|
{
|
2015-01-10 22:49:47 +00:00
|
|
|
if (id < RARCH_FIRST_CUSTOM_BIND)
|
2015-03-20 18:48:23 +00:00
|
|
|
id = settings->input.remap_ids[port][id];
|
2015-01-10 21:38:58 +00:00
|
|
|
}
|
2015-01-05 21:53:21 +00:00
|
|
|
|
2015-03-18 18:40:00 +00:00
|
|
|
if (!driver->block_libretro_input)
|
2014-12-28 04:57:17 +00:00
|
|
|
{
|
|
|
|
if (((id < RARCH_FIRST_META_KEY) || (device == RETRO_DEVICE_KEYBOARD)))
|
2015-03-23 02:04:05 +00:00
|
|
|
res = input_driver_state(libretro_input_binds, port, device, idx, id);
|
2014-09-23 01:03:56 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_OVERLAY
|
2014-12-28 14:20:01 +00:00
|
|
|
if (port == 0)
|
|
|
|
{
|
|
|
|
switch (device)
|
|
|
|
{
|
|
|
|
case RETRO_DEVICE_JOYPAD:
|
2015-03-18 18:40:00 +00:00
|
|
|
if (driver->overlay_state.buttons & (UINT64_C(1) << id))
|
2015-01-10 18:40:57 +00:00
|
|
|
res |= 1;
|
2014-12-28 14:20:01 +00:00
|
|
|
break;
|
|
|
|
case RETRO_DEVICE_KEYBOARD:
|
|
|
|
if (id < RETROK_LAST)
|
2015-01-10 18:40:57 +00:00
|
|
|
{
|
2015-03-18 18:40:00 +00:00
|
|
|
if (OVERLAY_GET_KEY(&driver->overlay_state, id))
|
2015-01-10 18:40:57 +00:00
|
|
|
res |= 1;
|
|
|
|
}
|
2014-12-28 14:20:01 +00:00
|
|
|
break;
|
|
|
|
case RETRO_DEVICE_ANALOG:
|
|
|
|
{
|
2015-01-10 18:40:57 +00:00
|
|
|
unsigned base = 0;
|
|
|
|
|
|
|
|
if (idx == RETRO_DEVICE_INDEX_ANALOG_RIGHT)
|
|
|
|
base = 2;
|
|
|
|
if (id == RETRO_DEVICE_ID_ANALOG_Y)
|
|
|
|
base += 1;
|
2015-03-18 18:40:00 +00:00
|
|
|
if (driver->overlay_state.analog[base])
|
|
|
|
res = driver->overlay_state.analog[base];
|
2014-12-28 14:20:01 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2014-09-23 01:03:56 +00:00
|
|
|
#endif
|
2014-12-28 14:20:01 +00:00
|
|
|
}
|
2014-09-23 01:03:56 +00:00
|
|
|
|
2014-09-29 15:03:06 +00:00
|
|
|
/* flushing_input will be cleared in rarch_main_iterate. */
|
2015-03-18 18:40:00 +00:00
|
|
|
if (driver->flushing_input)
|
2014-09-29 15:03:06 +00:00
|
|
|
res = 0;
|
2014-09-29 12:55:35 +00:00
|
|
|
|
2014-09-23 01:03:56 +00:00
|
|
|
/* Don't allow turbo for D-pad. */
|
|
|
|
if (device == RETRO_DEVICE_JOYPAD && (id < RETRO_DEVICE_ID_JOYPAD_UP ||
|
|
|
|
id > RETRO_DEVICE_ID_JOYPAD_RIGHT))
|
|
|
|
res = input_apply_turbo(port, id, res);
|
|
|
|
|
2015-03-21 03:43:18 +00:00
|
|
|
if (global->bsv.movie && !global->bsv.movie_playback)
|
|
|
|
bsv_movie_set_input(global->bsv.movie, res);
|
2014-09-23 01:03:56 +00:00
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-24 07:52:01 +00:00
|
|
|
#ifdef HAVE_OVERLAY
|
2015-01-08 17:39:17 +00:00
|
|
|
/*
|
|
|
|
* input_poll_overlay:
|
2015-01-29 19:33:27 +00:00
|
|
|
* @overlay_device : pointer to overlay
|
2015-01-08 17:39:17 +00:00
|
|
|
*
|
|
|
|
* Poll pressed buttons/keys on currently active overlay.
|
|
|
|
**/
|
2015-03-15 03:30:46 +00:00
|
|
|
static INLINE void input_poll_overlay(input_overlay_t *overlay_device, float opacity)
|
2014-09-24 07:52:01 +00:00
|
|
|
{
|
|
|
|
input_overlay_state_t old_key_state;
|
|
|
|
unsigned i, j, device;
|
2015-03-22 06:37:25 +00:00
|
|
|
uint16_t key_mod = 0;
|
|
|
|
bool polled = false;
|
2015-03-20 18:48:23 +00:00
|
|
|
driver_t *driver = driver_get_ptr();
|
|
|
|
settings_t *settings = config_get_ptr();
|
2014-09-24 07:52:01 +00:00
|
|
|
|
2015-02-21 06:29:13 +00:00
|
|
|
if (overlay_device->state != OVERLAY_STATUS_ALIVE)
|
|
|
|
return;
|
|
|
|
|
2015-03-18 18:40:00 +00:00
|
|
|
memcpy(old_key_state.keys, driver->overlay_state.keys,
|
|
|
|
sizeof(driver->overlay_state.keys));
|
|
|
|
memset(&driver->overlay_state, 0, sizeof(driver->overlay_state));
|
2014-09-24 07:52:01 +00:00
|
|
|
|
2015-01-29 19:33:27 +00:00
|
|
|
device = input_overlay_full_screen(overlay_device) ?
|
2014-09-24 07:52:01 +00:00
|
|
|
RARCH_DEVICE_POINTER_SCREEN : RETRO_DEVICE_POINTER;
|
|
|
|
|
|
|
|
for (i = 0;
|
2015-03-23 02:04:05 +00:00
|
|
|
input_driver_state(NULL, 0, device, i, RETRO_DEVICE_ID_POINTER_PRESSED);
|
2014-09-24 07:52:01 +00:00
|
|
|
i++)
|
|
|
|
{
|
2015-01-10 18:40:57 +00:00
|
|
|
input_overlay_state_t polled_data;
|
2015-03-23 02:04:05 +00:00
|
|
|
int16_t x = input_driver_state(NULL, 0,
|
2014-09-24 07:52:01 +00:00
|
|
|
device, i, RETRO_DEVICE_ID_POINTER_X);
|
2015-03-23 02:04:05 +00:00
|
|
|
int16_t y = input_driver_state(NULL, 0,
|
2014-09-24 07:52:01 +00:00
|
|
|
device, i, RETRO_DEVICE_ID_POINTER_Y);
|
|
|
|
|
2015-01-29 19:33:27 +00:00
|
|
|
input_overlay_poll(overlay_device, &polled_data, x, y);
|
2014-09-24 07:52:01 +00:00
|
|
|
|
2015-03-18 18:40:00 +00:00
|
|
|
driver->overlay_state.buttons |= polled_data.buttons;
|
2014-09-24 07:52:01 +00:00
|
|
|
|
2015-03-18 18:40:00 +00:00
|
|
|
for (j = 0; j < ARRAY_SIZE(driver->overlay_state.keys); j++)
|
|
|
|
driver->overlay_state.keys[j] |= polled_data.keys[j];
|
2014-09-24 07:52:01 +00:00
|
|
|
|
|
|
|
/* Fingers pressed later take prio and matched up
|
|
|
|
* with overlay poll priorities. */
|
|
|
|
for (j = 0; j < 4; j++)
|
|
|
|
if (polled_data.analog[j])
|
2015-03-18 18:40:00 +00:00
|
|
|
driver->overlay_state.analog[j] = polled_data.analog[j];
|
2014-09-24 07:52:01 +00:00
|
|
|
|
|
|
|
polled = true;
|
|
|
|
}
|
|
|
|
|
2015-03-18 18:40:00 +00:00
|
|
|
if (OVERLAY_GET_KEY(&driver->overlay_state, RETROK_LSHIFT) ||
|
|
|
|
OVERLAY_GET_KEY(&driver->overlay_state, RETROK_RSHIFT))
|
2015-01-10 18:40:57 +00:00
|
|
|
key_mod |= RETROKMOD_SHIFT;
|
|
|
|
|
2015-03-18 18:40:00 +00:00
|
|
|
if (OVERLAY_GET_KEY(&driver->overlay_state, RETROK_LCTRL) ||
|
|
|
|
OVERLAY_GET_KEY(&driver->overlay_state, RETROK_RCTRL))
|
2015-01-10 18:40:57 +00:00
|
|
|
key_mod |= RETROKMOD_CTRL;
|
|
|
|
|
2015-03-18 18:40:00 +00:00
|
|
|
if (OVERLAY_GET_KEY(&driver->overlay_state, RETROK_LALT) ||
|
|
|
|
OVERLAY_GET_KEY(&driver->overlay_state, RETROK_RALT))
|
2015-01-10 18:40:57 +00:00
|
|
|
key_mod |= RETROKMOD_ALT;
|
|
|
|
|
2015-03-18 18:40:00 +00:00
|
|
|
if (OVERLAY_GET_KEY(&driver->overlay_state, RETROK_LMETA) ||
|
|
|
|
OVERLAY_GET_KEY(&driver->overlay_state, RETROK_RMETA))
|
2015-01-10 18:40:57 +00:00
|
|
|
key_mod |= RETROKMOD_META;
|
2014-09-24 07:52:01 +00:00
|
|
|
|
|
|
|
/* CAPSLOCK SCROLLOCK NUMLOCK */
|
2015-03-18 18:40:00 +00:00
|
|
|
for (i = 0; i < ARRAY_SIZE(driver->overlay_state.keys); i++)
|
2014-09-24 07:52:01 +00:00
|
|
|
{
|
2015-03-18 18:40:00 +00:00
|
|
|
if (driver->overlay_state.keys[i] != old_key_state.keys[i])
|
2014-09-24 07:52:01 +00:00
|
|
|
{
|
|
|
|
uint32_t orig_bits = old_key_state.keys[i];
|
2015-03-18 18:40:00 +00:00
|
|
|
uint32_t new_bits = driver->overlay_state.keys[i];
|
2014-09-24 07:52:01 +00:00
|
|
|
|
|
|
|
for (j = 0; j < 32; j++)
|
|
|
|
if ((orig_bits & (1 << j)) != (new_bits & (1 << j)))
|
2015-01-29 06:03:20 +00:00
|
|
|
input_keyboard_event(new_bits & (1 << j),
|
2015-01-29 22:59:46 +00:00
|
|
|
i * 32 + j, 0, key_mod, RETRO_DEVICE_POINTER);
|
2014-09-24 07:52:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Map "analog" buttons to analog axes like regular input drivers do. */
|
|
|
|
for (j = 0; j < 4; j++)
|
|
|
|
{
|
2015-01-14 22:29:36 +00:00
|
|
|
unsigned bind_plus = RARCH_ANALOG_LEFT_X_PLUS + 2 * j;
|
|
|
|
unsigned bind_minus = bind_plus + 1;
|
2015-01-08 17:39:17 +00:00
|
|
|
|
2015-03-18 18:40:00 +00:00
|
|
|
if (driver->overlay_state.analog[j])
|
2015-01-14 22:29:36 +00:00
|
|
|
continue;
|
|
|
|
|
2015-03-18 18:40:00 +00:00
|
|
|
if (driver->overlay_state.buttons & (1ULL << bind_plus))
|
|
|
|
driver->overlay_state.analog[j] += 0x7fff;
|
|
|
|
if (driver->overlay_state.buttons & (1ULL << bind_minus))
|
|
|
|
driver->overlay_state.analog[j] -= 0x7fff;
|
2014-09-24 07:52:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Check for analog_dpad_mode.
|
|
|
|
* Map analogs to d-pad buttons when configured. */
|
2015-03-20 18:48:23 +00:00
|
|
|
switch (settings->input.analog_dpad_mode[0])
|
2014-09-24 07:52:01 +00:00
|
|
|
{
|
|
|
|
case ANALOG_DPAD_LSTICK:
|
|
|
|
case ANALOG_DPAD_RSTICK:
|
|
|
|
{
|
2015-01-10 18:40:57 +00:00
|
|
|
float analog_x, analog_y;
|
|
|
|
unsigned analog_base = 2;
|
|
|
|
|
2015-03-20 18:48:23 +00:00
|
|
|
if (settings->input.analog_dpad_mode[0] == ANALOG_DPAD_LSTICK)
|
2015-01-10 18:40:57 +00:00
|
|
|
analog_base = 0;
|
|
|
|
|
2015-03-18 18:40:00 +00:00
|
|
|
analog_x = (float)driver->overlay_state.analog[analog_base + 0] / 0x7fff;
|
|
|
|
analog_y = (float)driver->overlay_state.analog[analog_base + 1] / 0x7fff;
|
2015-01-10 18:40:57 +00:00
|
|
|
|
2015-03-20 18:48:23 +00:00
|
|
|
if (analog_x <= -settings->input.axis_threshold)
|
2015-03-18 18:40:00 +00:00
|
|
|
driver->overlay_state.buttons |= (1ULL << RETRO_DEVICE_ID_JOYPAD_LEFT);
|
2015-03-20 18:48:23 +00:00
|
|
|
if (analog_x >= settings->input.axis_threshold)
|
2015-03-18 18:40:00 +00:00
|
|
|
driver->overlay_state.buttons |= (1ULL << RETRO_DEVICE_ID_JOYPAD_RIGHT);
|
2015-03-20 18:48:23 +00:00
|
|
|
if (analog_y <= -settings->input.axis_threshold)
|
2015-03-18 18:40:00 +00:00
|
|
|
driver->overlay_state.buttons |= (1ULL << RETRO_DEVICE_ID_JOYPAD_UP);
|
2015-03-20 18:48:23 +00:00
|
|
|
if (analog_y >= settings->input.axis_threshold)
|
2015-03-18 18:40:00 +00:00
|
|
|
driver->overlay_state.buttons |= (1ULL << RETRO_DEVICE_ID_JOYPAD_DOWN);
|
2014-09-24 07:52:01 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (polled)
|
2015-01-29 19:33:27 +00:00
|
|
|
input_overlay_post_poll(overlay_device, opacity);
|
2014-09-24 07:52:01 +00:00
|
|
|
else
|
2015-01-29 19:33:27 +00:00
|
|
|
input_overlay_poll_clear(overlay_device, opacity);
|
2014-09-24 07:52:01 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-01-08 17:39:17 +00:00
|
|
|
/**
|
|
|
|
* input_poll:
|
|
|
|
*
|
|
|
|
* Input polling callback function.
|
|
|
|
**/
|
2014-09-24 07:52:01 +00:00
|
|
|
static void input_poll(void)
|
|
|
|
{
|
2015-03-20 18:48:23 +00:00
|
|
|
driver_t *driver = driver_get_ptr();
|
|
|
|
settings_t *settings = config_get_ptr();
|
2015-03-18 18:40:00 +00:00
|
|
|
|
2015-03-23 02:17:43 +00:00
|
|
|
input_driver_poll();
|
2014-09-24 07:52:01 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_OVERLAY
|
2015-03-18 18:40:00 +00:00
|
|
|
if (driver->overlay)
|
2015-03-20 18:48:23 +00:00
|
|
|
input_poll_overlay(driver->overlay,
|
|
|
|
settings->input.overlay_opacity);
|
2014-09-24 07:52:01 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_COMMAND
|
2015-03-18 18:40:00 +00:00
|
|
|
if (driver->command)
|
|
|
|
rarch_cmd_poll(driver->command);
|
2014-09-24 07:52:01 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2015-01-08 17:39:17 +00:00
|
|
|
/**
|
|
|
|
* retro_set_default_callbacks:
|
|
|
|
* @data : pointer to retro_callbacks object
|
|
|
|
*
|
|
|
|
* Binds the libretro callbacks to default callback functions.
|
|
|
|
**/
|
2014-09-23 02:42:49 +00:00
|
|
|
void retro_set_default_callbacks(void *data)
|
2014-09-23 01:55:19 +00:00
|
|
|
{
|
2014-09-23 02:42:49 +00:00
|
|
|
struct retro_callbacks *cbs = (struct retro_callbacks*)data;
|
|
|
|
|
|
|
|
if (!cbs)
|
|
|
|
return;
|
|
|
|
|
|
|
|
cbs->frame_cb = video_frame;
|
|
|
|
cbs->sample_cb = audio_sample;
|
2014-09-23 01:55:19 +00:00
|
|
|
cbs->sample_batch_cb = audio_sample_batch;
|
2014-09-23 02:42:49 +00:00
|
|
|
cbs->state_cb = input_state;
|
2014-09-24 07:52:01 +00:00
|
|
|
cbs->poll_cb = input_poll;
|
2014-09-23 01:55:19 +00:00
|
|
|
}
|
|
|
|
|
2015-01-08 17:39:17 +00:00
|
|
|
/**
|
2015-01-08 17:42:27 +00:00
|
|
|
* retro_init_libretro_cbs:
|
2015-01-08 17:39:17 +00:00
|
|
|
* @data : pointer to retro_callbacks object
|
|
|
|
*
|
|
|
|
* Initializes libretro callbacks, and binds the libretro callbacks
|
|
|
|
* to default callback functions.
|
|
|
|
**/
|
2014-09-23 02:42:49 +00:00
|
|
|
void retro_init_libretro_cbs(void *data)
|
2014-09-23 01:03:56 +00:00
|
|
|
{
|
2014-09-23 02:42:49 +00:00
|
|
|
struct retro_callbacks *cbs = (struct retro_callbacks*)data;
|
2015-03-18 18:40:00 +00:00
|
|
|
driver_t *driver = driver_get_ptr();
|
2015-03-21 03:43:18 +00:00
|
|
|
global_t *global = global_get_ptr();
|
2014-09-23 02:42:49 +00:00
|
|
|
|
|
|
|
if (!cbs)
|
|
|
|
return;
|
|
|
|
|
2015-03-18 19:31:01 +00:00
|
|
|
(void)driver;
|
2015-03-21 05:55:34 +00:00
|
|
|
(void)global;
|
2015-03-18 19:31:01 +00:00
|
|
|
|
2014-09-23 01:03:56 +00:00
|
|
|
pretro_set_video_refresh(video_frame);
|
|
|
|
pretro_set_audio_sample(audio_sample);
|
|
|
|
pretro_set_audio_sample_batch(audio_sample_batch);
|
|
|
|
pretro_set_input_state(input_state);
|
2014-09-24 07:52:01 +00:00
|
|
|
pretro_set_input_poll(input_poll);
|
2014-09-23 01:03:56 +00:00
|
|
|
|
2014-09-23 01:55:19 +00:00
|
|
|
retro_set_default_callbacks(cbs);
|
|
|
|
|
2014-09-23 01:03:56 +00:00
|
|
|
#ifdef HAVE_NETPLAY
|
2015-03-18 18:40:00 +00:00
|
|
|
if (!driver->netplay_data)
|
2014-09-23 01:03:56 +00:00
|
|
|
return;
|
|
|
|
|
2015-03-21 03:43:18 +00:00
|
|
|
if (global->netplay_is_spectate)
|
2014-09-23 01:03:56 +00:00
|
|
|
{
|
|
|
|
pretro_set_input_state(
|
2015-03-21 03:43:18 +00:00
|
|
|
(global->netplay_is_client ?
|
2014-09-23 01:03:56 +00:00
|
|
|
input_state_spectate_client : input_state_spectate)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pretro_set_video_refresh(video_frame_net);
|
|
|
|
pretro_set_audio_sample(audio_sample_net);
|
|
|
|
pretro_set_audio_sample_batch(audio_sample_batch_net);
|
|
|
|
pretro_set_input_state(input_state_net);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2015-01-08 17:39:17 +00:00
|
|
|
/**
|
|
|
|
* retro_set_rewind_callbacks:
|
|
|
|
*
|
|
|
|
* Sets the audio sampling callbacks based on whether or not
|
|
|
|
* rewinding is currently activated.
|
|
|
|
**/
|
2014-09-23 01:03:56 +00:00
|
|
|
void retro_set_rewind_callbacks(void)
|
|
|
|
{
|
2015-03-21 03:43:18 +00:00
|
|
|
global_t *global = global_get_ptr();
|
|
|
|
|
|
|
|
if (global->rewind.frame_is_reverse)
|
2014-09-23 01:03:56 +00:00
|
|
|
{
|
|
|
|
pretro_set_audio_sample(audio_sample_rewind);
|
|
|
|
pretro_set_audio_sample_batch(audio_sample_batch_rewind);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pretro_set_audio_sample(audio_sample);
|
|
|
|
pretro_set_audio_sample_batch(audio_sample_batch);
|
|
|
|
}
|
|
|
|
}
|