2013-03-03 23:50:38 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
2014-01-01 00:50:59 +00:00
|
|
|
* Copyright (C) 2013-2014 - Jason Fetters
|
2015-01-07 16:46:50 +00:00
|
|
|
* Copyright (C) 2011-2015 - Daniel De Matteis
|
2013-03-03 23:50:38 +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/>.
|
|
|
|
*/
|
|
|
|
|
2015-01-12 05:28:39 +00:00
|
|
|
#include "../input_autodetect.h"
|
2015-04-01 20:31:43 +00:00
|
|
|
#include "../input_hid_driver.h"
|
2015-12-05 12:22:50 +00:00
|
|
|
#include "../input_driver.h"
|
2014-10-04 14:46:52 +00:00
|
|
|
|
2015-04-01 20:57:15 +00:00
|
|
|
static const hid_driver_t *generic_hid;
|
2015-04-01 18:49:26 +00:00
|
|
|
|
2015-06-03 16:22:54 +00:00
|
|
|
static bool hid_joypad_init(void *data)
|
2015-02-15 03:07:22 +00:00
|
|
|
{
|
2015-04-01 21:33:00 +00:00
|
|
|
generic_hid = input_hid_init_first();
|
2015-04-01 18:49:26 +00:00
|
|
|
if (!generic_hid)
|
2015-02-15 03:07:22 +00:00
|
|
|
return false;
|
2014-10-04 14:46:52 +00:00
|
|
|
|
2015-06-03 16:22:54 +00:00
|
|
|
(void)data;
|
|
|
|
|
2014-10-04 14:46:52 +00:00
|
|
|
return true;
|
2013-03-03 23:50:38 +00:00
|
|
|
}
|
|
|
|
|
2015-04-01 18:00:38 +00:00
|
|
|
static bool hid_joypad_query_pad(unsigned pad)
|
2013-03-03 23:50:38 +00:00
|
|
|
{
|
2015-11-29 20:11:57 +00:00
|
|
|
return generic_hid->query_pad((void*)hid_driver_get_data(), pad);
|
2013-03-03 23:50:38 +00:00
|
|
|
}
|
|
|
|
|
2015-04-01 20:31:43 +00:00
|
|
|
static void hid_joypad_free(void)
|
2013-03-03 23:50:38 +00:00
|
|
|
{
|
2015-11-29 20:11:57 +00:00
|
|
|
generic_hid->free((void*)hid_driver_get_data());
|
2015-04-01 18:49:26 +00:00
|
|
|
generic_hid = NULL;
|
2013-03-03 23:50:38 +00:00
|
|
|
}
|
|
|
|
|
2015-04-01 18:00:38 +00:00
|
|
|
static bool hid_joypad_button(unsigned port, uint16_t joykey)
|
2013-03-03 23:50:38 +00:00
|
|
|
{
|
2015-11-29 20:11:57 +00:00
|
|
|
return generic_hid->button((void*)hid_driver_get_data(), port, joykey);
|
2013-03-03 23:50:38 +00:00
|
|
|
}
|
|
|
|
|
2015-04-01 18:00:38 +00:00
|
|
|
static uint64_t hid_joypad_get_buttons(unsigned port)
|
2015-02-15 00:57:29 +00:00
|
|
|
{
|
2015-11-29 20:11:57 +00:00
|
|
|
return generic_hid->get_buttons((void*)hid_driver_get_data(), port);
|
2015-02-15 00:57:29 +00:00
|
|
|
}
|
|
|
|
|
2015-04-01 18:00:38 +00:00
|
|
|
static int16_t hid_joypad_axis(unsigned port, uint32_t joyaxis)
|
2013-03-03 23:50:38 +00:00
|
|
|
{
|
2015-11-29 20:11:57 +00:00
|
|
|
return generic_hid->axis((void*)hid_driver_get_data(), port, joyaxis);
|
2013-03-03 23:50:38 +00:00
|
|
|
}
|
|
|
|
|
2015-04-01 18:00:38 +00:00
|
|
|
static void hid_joypad_poll(void)
|
2013-03-03 23:50:38 +00:00
|
|
|
{
|
2015-11-29 20:11:57 +00:00
|
|
|
generic_hid->poll((void*)hid_driver_get_data());
|
2013-03-03 23:50:38 +00:00
|
|
|
}
|
|
|
|
|
2015-04-01 18:00:38 +00:00
|
|
|
static bool hid_joypad_rumble(unsigned pad,
|
2014-09-09 16:15:17 +00:00
|
|
|
enum retro_rumble_effect effect, uint16_t strength)
|
2013-10-03 22:04:28 +00:00
|
|
|
{
|
2015-11-29 20:11:57 +00:00
|
|
|
return generic_hid->set_rumble((void*)hid_driver_get_data(), pad, effect, strength);
|
2013-10-03 22:04:28 +00:00
|
|
|
}
|
|
|
|
|
2015-04-01 18:00:38 +00:00
|
|
|
static const char *hid_joypad_name(unsigned pad)
|
2013-04-26 22:08:52 +00:00
|
|
|
{
|
2015-11-29 20:11:57 +00:00
|
|
|
return generic_hid->name((void*)hid_driver_get_data(), pad);
|
2013-04-26 22:08:52 +00:00
|
|
|
}
|
|
|
|
|
2015-04-14 14:37:59 +00:00
|
|
|
input_device_driver_t hid_joypad = {
|
2015-04-01 18:00:38 +00:00
|
|
|
hid_joypad_init,
|
|
|
|
hid_joypad_query_pad,
|
2015-04-01 20:31:43 +00:00
|
|
|
hid_joypad_free,
|
2015-04-01 18:00:38 +00:00
|
|
|
hid_joypad_button,
|
|
|
|
hid_joypad_get_buttons,
|
|
|
|
hid_joypad_axis,
|
|
|
|
hid_joypad_poll,
|
|
|
|
hid_joypad_rumble,
|
|
|
|
hid_joypad_name,
|
|
|
|
"hid"
|
2013-03-03 23:50:38 +00:00
|
|
|
};
|