diff --git a/Makefile.common b/Makefile.common index ceb563462e..2ed45788c8 100644 --- a/Makefile.common +++ b/Makefile.common @@ -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 \ diff --git a/driver.c b/driver.c index 229e8c49a9..7351eb32d8 100644 --- a/driver.c +++ b/driver.c @@ -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: * diff --git a/driver.h b/driver.h index c84385b401..4fb89459c5 100644 --- a/driver.h +++ b/driver.h @@ -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 diff --git a/dynamic.c b/dynamic.c index 74d3a7bc04..93dead24d3 100644 --- a/dynamic.c +++ b/dynamic.c @@ -32,6 +32,8 @@ #include "dynamic_dummy.h" #include "retroarch.h" +#include "input/input_sensor.h" + #ifdef NEED_DYNAMIC #ifdef _WIN32 #include @@ -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; } diff --git a/griffin/griffin.c b/griffin/griffin.c index b15dbfbd20..a16e75a6da 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -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 diff --git a/input/input_sensor.c b/input/input_sensor.c new file mode 100644 index 0000000000..910f0305e4 --- /dev/null +++ b/input/input_sensor.c @@ -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 . + */ + +#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; +} diff --git a/input/input_sensor.h b/input/input_sensor.h new file mode 100644 index 0000000000..344538ab32 --- /dev/null +++ b/input/input_sensor.h @@ -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 . + */ + +#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