Split up sensor code into its own file

This commit is contained in:
twinaphex 2015-01-18 19:28:51 +01:00
parent e9d2d966cd
commit be3ac6eccd
7 changed files with 88 additions and 44 deletions

View File

@ -121,6 +121,7 @@ OBJ += frontend/frontend.o \
input/input_joypad.o \
input/input_common.o \
input/input_keymaps.o \
input/input_sensor.o \
input/keyboard_line.o \
input/input_overlay.o \
patch.o \

View File

@ -281,34 +281,6 @@ bool driver_set_rumble_state(unsigned port,
return false;
}
/**
* driver_set_sensor_state:
* @port : User number.
* @effect : Sensor action.
* @rate : Sensor rate update.
*
* Sets the sensor state.
* Used by RETRO_ENVIRONMENT_GET_SENSOR_INTERFACE.
**/
bool driver_set_sensor_state(unsigned port,
enum retro_sensor_action action, unsigned rate)
{
if (driver.input && driver.input_data &&
driver.input->set_sensor_state)
return driver.input->set_sensor_state(driver.input_data,
port, action, rate);
return false;
}
float driver_sensor_get_input(unsigned port, unsigned id)
{
if (driver.input && driver.input_data &&
driver.input->get_sensor_input)
return driver.input->get_sensor_input(driver.input_data,
port, id);
return 0.0f;
}
/**
* driver_get_current_framebuffer:
*

View File

@ -394,20 +394,6 @@ retro_proc_address_t driver_get_proc_address(const char *sym);
bool driver_set_rumble_state(unsigned port,
enum retro_rumble_effect effect, uint16_t strength);
/**
* driver_set_sensor_state:
* @port : User number.
* @effect : Sensor action.
* @rate : Sensor rate update.
*
* Sets the sensor state.
* Used by RETRO_ENVIRONMENT_GET_SENSOR_INTERFACE.
**/
bool driver_set_sensor_state(unsigned port,
enum retro_sensor_action action, unsigned rate);
float driver_sensor_get_input(unsigned port, unsigned action);
/**
* driver_update_system_av_info:
* @info : pointer to new A/V info

View File

@ -32,6 +32,8 @@
#include "dynamic_dummy.h"
#include "retroarch.h"
#include "input/input_sensor.h"
#ifdef NEED_DYNAMIC
#ifdef _WIN32
#include <windows.h>
@ -1031,8 +1033,8 @@ bool rarch_environment_cb(unsigned cmd, void *data)
(struct retro_sensor_interface*)data;
RARCH_LOG("Environ GET_SENSOR_INTERFACE.\n");
iface->set_sensor_state = driver_set_sensor_state;
iface->get_sensor_input = driver_sensor_get_input;
iface->set_sensor_state = input_sensor_set_state;
iface->get_sensor_input = input_sensor_get_input;
break;
}

View File

@ -292,6 +292,7 @@ INPUT
#include "../input/input_joypad.c"
#include "../input/input_common.c"
#include "../input/input_keymaps.c"
#include "../input/input_sensor.c"
#include "../input/keyboard_line.c"
#ifdef HAVE_OVERLAY

46
input/input_sensor.c Normal file
View File

@ -0,0 +1,46 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2015 - Daniel De Matteis
*
* 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/>.
*/
#include "input_sensor.h"
#include "../driver.h"
/**
* input_sensor_set_state:
* @port : User number.
* @effect : Sensor action.
* @rate : Sensor rate update.
*
* Sets the sensor state.
* Used by RETRO_ENVIRONMENT_GET_SENSOR_INTERFACE.
**/
bool input_sensor_set_state(unsigned port,
enum retro_sensor_action action, unsigned rate)
{
if (driver.input && driver.input_data &&
driver.input->set_sensor_state)
return driver.input->set_sensor_state(driver.input_data,
port, action, rate);
return false;
}
float input_sensor_get_input(unsigned port, unsigned id)
{
if (driver.input && driver.input_data &&
driver.input->get_sensor_input)
return driver.input->get_sensor_input(driver.input_data,
port, id);
return 0.0f;
}

36
input/input_sensor.h Normal file
View File

@ -0,0 +1,36 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2015 - Daniel De Matteis
*
* 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/>.
*/
#ifndef __INPUT_SENSOR_H
#define __INPUT_SENSOR_H
#include "../libretro.h"
/**
* input_sensor_set_state:
* @port : User number.
* @effect : Sensor action.
* @rate : Sensor rate update.
*
* Sets the sensor state.
* Used by RETRO_ENVIRONMENT_GET_SENSOR_INTERFACE.
**/
bool input_sensor_set_state(unsigned port,
enum retro_sensor_action action, unsigned rate);
float input_sensor_get_input(unsigned port, unsigned id);
#endif