2013-03-03 23:50:38 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
|
|
|
* Copyright (C) 2013 - Jason Fetters
|
|
|
|
*
|
|
|
|
* 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/input_common.h"
|
|
|
|
#include "general.h"
|
|
|
|
|
2013-07-08 19:14:36 +00:00
|
|
|
#ifdef IOS
|
2013-09-05 05:20:56 +00:00
|
|
|
#include "apple/iOS/bluetooth/btdynamic.c"
|
|
|
|
#include "apple/iOS/bluetooth/btpad.c"
|
|
|
|
#include "apple/iOS/bluetooth/btpad_queue.c"
|
2013-07-09 00:57:25 +00:00
|
|
|
#elif defined(OSX)
|
|
|
|
#include "../OSX/hid_pad.c"
|
2013-07-08 19:14:36 +00:00
|
|
|
#endif
|
|
|
|
|
2013-09-11 23:16:47 +00:00
|
|
|
#include "apple/common/hidpad/wiimote.c"
|
|
|
|
#include "apple/common/hidpad/hidpad_ps3.c"
|
|
|
|
#include "apple/common/hidpad/hidpad_wii.c"
|
|
|
|
|
2013-07-08 19:14:36 +00:00
|
|
|
|
|
|
|
static bool apple_joypad_init(void)
|
2013-03-03 23:50:38 +00:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-07-08 19:14:36 +00:00
|
|
|
static bool apple_joypad_query_pad(unsigned pad)
|
2013-03-03 23:50:38 +00:00
|
|
|
{
|
|
|
|
return pad < MAX_PLAYERS;
|
|
|
|
}
|
|
|
|
|
2013-07-08 19:14:36 +00:00
|
|
|
static void apple_joypad_destroy(void)
|
2013-03-03 23:50:38 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-07-08 19:14:36 +00:00
|
|
|
static bool apple_joypad_button(unsigned port, uint16_t joykey)
|
2013-03-03 23:50:38 +00:00
|
|
|
{
|
|
|
|
if (joykey == NO_BTN)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// Check hat.
|
|
|
|
if (GET_HAT_DIR(joykey))
|
|
|
|
return false;
|
|
|
|
else // Check the button
|
2013-06-22 17:09:38 +00:00
|
|
|
return (port < MAX_PADS && joykey < 32) ? (g_polled_input_data.pad_buttons[port] & (1 << joykey)) != 0 : false;
|
2013-03-03 23:50:38 +00:00
|
|
|
}
|
|
|
|
|
2013-07-08 19:14:36 +00:00
|
|
|
static int16_t apple_joypad_axis(unsigned port, uint32_t joyaxis)
|
2013-03-03 23:50:38 +00:00
|
|
|
{
|
2013-08-15 23:28:51 +00:00
|
|
|
if (joyaxis == AXIS_NONE)
|
2013-03-31 02:23:45 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
int16_t val = 0;
|
|
|
|
if (AXIS_NEG_GET(joyaxis) < 4)
|
|
|
|
{
|
2013-07-09 16:40:13 +00:00
|
|
|
val = g_polled_input_data.pad_axis[port][AXIS_NEG_GET(joyaxis)];
|
2013-03-31 02:23:45 +00:00
|
|
|
val = (val < 0) ? val : 0;
|
|
|
|
}
|
|
|
|
else if(AXIS_POS_GET(joyaxis) < 4)
|
|
|
|
{
|
2013-07-09 16:40:13 +00:00
|
|
|
val = g_polled_input_data.pad_axis[port][AXIS_POS_GET(joyaxis)];
|
2013-03-31 02:23:45 +00:00
|
|
|
val = (val > 0) ? val : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return val;
|
2013-03-03 23:50:38 +00:00
|
|
|
}
|
|
|
|
|
2013-07-08 19:14:36 +00:00
|
|
|
static void apple_joypad_poll(void)
|
2013-03-03 23:50:38 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-07-08 19:14:36 +00:00
|
|
|
static const char *apple_joypad_name(unsigned joypad)
|
2013-04-26 22:08:52 +00:00
|
|
|
{
|
|
|
|
(void)joypad;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-07-08 19:14:36 +00:00
|
|
|
const rarch_joypad_driver_t apple_joypad = {
|
|
|
|
apple_joypad_init,
|
|
|
|
apple_joypad_query_pad,
|
|
|
|
apple_joypad_destroy,
|
|
|
|
apple_joypad_button,
|
|
|
|
apple_joypad_axis,
|
|
|
|
apple_joypad_poll,
|
2013-09-25 20:59:05 +00:00
|
|
|
NULL,
|
2013-07-08 19:14:36 +00:00
|
|
|
apple_joypad_name,
|
|
|
|
"apple"
|
2013-03-03 23:50:38 +00:00
|
|
|
};
|
|
|
|
|