(Apple) Move Apple input files around - rename files

This commit is contained in:
twinaphex 2014-04-26 17:39:46 +02:00
parent 59e5644dd0
commit 1410b6937e
7 changed files with 458 additions and 439 deletions

View File

@ -1,173 +0,0 @@
/*
Taken from https://github.com/depp/keycode, distributed with the following license:
Copyright 2011-2012 Dietrich Epp <depp@zdome.net>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/* This file is automatically generated by keycode.py. */
#ifndef KEYCODE_KEYCODE_H
#define KEYCODE_KEYCODE_H
enum {
KEY_A = 4,
KEY_B = 5,
KEY_C = 6,
KEY_D = 7,
KEY_E = 8,
KEY_F = 9,
KEY_G = 10,
KEY_H = 11,
KEY_I = 12,
KEY_J = 13,
KEY_K = 14,
KEY_L = 15,
KEY_M = 16,
KEY_N = 17,
KEY_O = 18,
KEY_P = 19,
KEY_Q = 20,
KEY_R = 21,
KEY_S = 22,
KEY_T = 23,
KEY_U = 24,
KEY_V = 25,
KEY_W = 26,
KEY_X = 27,
KEY_Y = 28,
KEY_Z = 29,
KEY_1 = 30,
KEY_2 = 31,
KEY_3 = 32,
KEY_4 = 33,
KEY_5 = 34,
KEY_6 = 35,
KEY_7 = 36,
KEY_8 = 37,
KEY_9 = 38,
KEY_0 = 39,
KEY_Enter = 40,
KEY_Escape = 41,
KEY_Delete = 42,
KEY_Tab = 43,
KEY_Space = 44,
KEY_Minus = 45,
KEY_Equals = 46,
KEY_LeftBracket = 47,
KEY_RightBracket = 48,
KEY_Backslash = 49,
KEY_Semicolon = 51,
KEY_Quote = 52,
KEY_Grave = 53,
KEY_Comma = 54,
KEY_Period = 55,
KEY_Slash = 56,
KEY_CapsLock = 57,
KEY_F1 = 58,
KEY_F2 = 59,
KEY_F3 = 60,
KEY_F4 = 61,
KEY_F5 = 62,
KEY_F6 = 63,
KEY_F7 = 64,
KEY_F8 = 65,
KEY_F9 = 66,
KEY_F10 = 67,
KEY_F11 = 68,
KEY_F12 = 69,
KEY_PrintScreen = 70,
KEY_ScrollLock = 71,
KEY_Pause = 72,
KEY_Insert = 73,
KEY_Home = 74,
KEY_PageUp = 75,
KEY_DeleteForward = 76,
KEY_End = 77,
KEY_PageDown = 78,
KEY_Right = 79,
KEY_Left = 80,
KEY_Down = 81,
KEY_Up = 82,
KP_NumLock = 83,
KP_Divide = 84,
KP_Multiply = 85,
KP_Subtract = 86,
KP_Add = 87,
KP_Enter = 88,
KP_1 = 89,
KP_2 = 90,
KP_3 = 91,
KP_4 = 92,
KP_5 = 93,
KP_6 = 94,
KP_7 = 95,
KP_8 = 96,
KP_9 = 97,
KP_0 = 98,
KP_Point = 99,
KEY_NonUSBackslash = 100,
KP_Equals = 103,
KEY_F13 = 104,
KEY_F14 = 105,
KEY_F15 = 106,
KEY_F16 = 107,
KEY_F17 = 108,
KEY_F18 = 109,
KEY_F19 = 110,
KEY_F20 = 111,
KEY_F21 = 112,
KEY_F22 = 113,
KEY_F23 = 114,
KEY_F24 = 115,
KEY_Help = 117,
KEY_Menu = 118,
KEY_LeftControl = 224,
KEY_LeftShift = 225,
KEY_LeftAlt = 226,
KEY_LeftGUI = 227,
KEY_RightControl = 228,
KEY_RightShift = 229,
KEY_RightAlt = 230,
KEY_RightGUI = 231
};
//
#include "../../input/input_common.h" // < For rarch_key_map
struct apple_key_name_map_entry
{
const char* const keyname;
const uint32_t hid_id;
};
extern const struct apple_key_name_map_entry apple_key_name_map[];
extern const struct rarch_key_map apple_key_map_hidusage[];
const char* apple_keycode_hidusage_to_name(uint32_t hid_usage);
#endif

View File

@ -1,222 +0,0 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2013-2014 - 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 "keycode.h"
const struct apple_key_name_map_entry apple_key_name_map[] =
{
{ "left", KEY_Left }, { "right", KEY_Right },
{ "up", KEY_Up }, { "down", KEY_Down },
{ "enter", KEY_Enter }, { "kp_enter", KP_Enter },
{ "space", KEY_Space }, { "tab", KEY_Tab },
{ "shift", KEY_LeftShift }, { "rshift", KEY_RightShift },
{ "ctrl", KEY_LeftControl }, { "alt", KEY_LeftAlt },
{ "escape", KEY_Escape }, { "backspace", KEY_DeleteForward },
{ "backquote", KEY_Grave }, { "pause", KEY_Pause },
{ "f1", KEY_F1 }, { "f2", KEY_F2 },
{ "f3", KEY_F3 }, { "f4", KEY_F4 },
{ "f5", KEY_F5 }, { "f6", KEY_F6 },
{ "f7", KEY_F7 }, { "f8", KEY_F8 },
{ "f9", KEY_F9 }, { "f10", KEY_F10 },
{ "f11", KEY_F11 }, { "f12", KEY_F12 },
{ "num0", KEY_0 }, { "num1", KEY_1 },
{ "num2", KEY_2 }, { "num3", KEY_3 },
{ "num4", KEY_4 }, { "num5", KEY_5 },
{ "num6", KEY_6 }, { "num7", KEY_7 },
{ "num8", KEY_8 }, { "num9", KEY_9 },
{ "insert", KEY_Insert }, { "del", KEY_DeleteForward },
{ "home", KEY_Home }, { "end", KEY_End },
{ "pageup", KEY_PageUp }, { "pagedown", KEY_PageDown },
{ "add", KP_Add }, { "subtract", KP_Subtract },
{ "multiply", KP_Multiply }, { "divide", KP_Divide },
{ "keypad0", KP_0 }, { "keypad1", KP_1 },
{ "keypad2", KP_2 }, { "keypad3", KP_3 },
{ "keypad4", KP_4 }, { "keypad5", KP_5 },
{ "keypad6", KP_6 }, { "keypad7", KP_7 },
{ "keypad8", KP_8 }, { "keypad9", KP_9 },
{ "period", KEY_Period }, { "capslock", KEY_CapsLock },
{ "numlock", KP_NumLock }, { "print_screen", KEY_PrintScreen },
{ "scroll_lock", KEY_ScrollLock },
{ "a", KEY_A }, { "b", KEY_B }, { "c", KEY_C }, { "d", KEY_D },
{ "e", KEY_E }, { "f", KEY_F }, { "g", KEY_G }, { "h", KEY_H },
{ "i", KEY_I }, { "j", KEY_J }, { "k", KEY_K }, { "l", KEY_L },
{ "m", KEY_M }, { "n", KEY_N }, { "o", KEY_O }, { "p", KEY_P },
{ "q", KEY_Q }, { "r", KEY_R }, { "s", KEY_S }, { "t", KEY_T },
{ "u", KEY_U }, { "v", KEY_V }, { "w", KEY_W }, { "x", KEY_X },
{ "y", KEY_Y }, { "z", KEY_Z },
{ "nul", 0x00},
};
const struct rarch_key_map apple_key_map_hidusage[] =
{
{ KEY_Delete, RETROK_BACKSPACE },
{ KEY_Tab, RETROK_TAB },
// RETROK_CLEAR },
{ KEY_Enter, RETROK_RETURN },
{ KEY_Pause, RETROK_PAUSE },
{ KEY_Escape, RETROK_ESCAPE },
{ KEY_Space, RETROK_SPACE },
// RETROK_EXCLAIM },
// RETROK_QUOTEDBL },
// RETROK_HASH },
// RETROK_DOLLAR },
// RETROK_AMPERSAND },
{ KEY_Quote, RETROK_QUOTE },
// RETROK_LEFTPAREN },
// RETROK_RIGHTPAREN },
// RETROK_ASTERISK },
// RETROK_PLUS },
{ KEY_Comma, RETROK_COMMA },
{ KEY_Minus, RETROK_MINUS },
{ KEY_Period, RETROK_PERIOD },
{ KEY_Slash, RETROK_SLASH },
{ KEY_0, RETROK_0 },
{ KEY_1, RETROK_1 },
{ KEY_2, RETROK_2 },
{ KEY_3, RETROK_3 },
{ KEY_4, RETROK_4 },
{ KEY_5, RETROK_5 },
{ KEY_6, RETROK_6 },
{ KEY_7, RETROK_7 },
{ KEY_8, RETROK_8 },
{ KEY_9, RETROK_9 },
// RETROK_COLON },
{ KEY_Semicolon, RETROK_SEMICOLON },
// RETROK_LESS },
{ KEY_Equals, RETROK_EQUALS },
// RETROK_GREATER },
// RETROK_QUESTION },
// RETROK_AT },
{ KEY_LeftBracket, RETROK_LEFTBRACKET },
{ KEY_Backslash, RETROK_BACKSLASH },
{ KEY_RightBracket, RETROK_RIGHTBRACKET },
// RETROK_CARET },
// RETROK_UNDERSCORE },
{ KEY_Grave, RETROK_BACKQUOTE },
{ KEY_A, RETROK_a },
{ KEY_B, RETROK_b },
{ KEY_C, RETROK_c },
{ KEY_D, RETROK_d },
{ KEY_E, RETROK_e },
{ KEY_F, RETROK_f },
{ KEY_G, RETROK_g },
{ KEY_H, RETROK_h },
{ KEY_I, RETROK_i },
{ KEY_J, RETROK_j },
{ KEY_K, RETROK_k },
{ KEY_L, RETROK_l },
{ KEY_M, RETROK_m },
{ KEY_N, RETROK_n },
{ KEY_O, RETROK_o },
{ KEY_P, RETROK_p },
{ KEY_Q, RETROK_q },
{ KEY_R, RETROK_r },
{ KEY_S, RETROK_s },
{ KEY_T, RETROK_t },
{ KEY_U, RETROK_u },
{ KEY_V, RETROK_v },
{ KEY_W, RETROK_w },
{ KEY_X, RETROK_x },
{ KEY_Y, RETROK_y },
{ KEY_Z, RETROK_z },
{ KEY_DeleteForward, RETROK_DELETE },
{ KP_0, RETROK_KP0 },
{ KP_1, RETROK_KP1 },
{ KP_2, RETROK_KP2 },
{ KP_3, RETROK_KP3 },
{ KP_4, RETROK_KP4 },
{ KP_5, RETROK_KP5 },
{ KP_6, RETROK_KP6 },
{ KP_7, RETROK_KP7 },
{ KP_8, RETROK_KP8 },
{ KP_9, RETROK_KP9 },
{ KP_Point, RETROK_KP_PERIOD },
{ KP_Divide, RETROK_KP_DIVIDE },
{ KP_Multiply, RETROK_KP_MULTIPLY },
{ KP_Subtract, RETROK_KP_MINUS },
{ KP_Add, RETROK_KP_PLUS },
{ KP_Enter, RETROK_KP_ENTER },
{ KP_Equals, RETROK_KP_EQUALS },
{ KEY_Up, RETROK_UP },
{ KEY_Down, RETROK_DOWN },
{ KEY_Right, RETROK_RIGHT },
{ KEY_Left, RETROK_LEFT },
{ KEY_Insert, RETROK_INSERT },
{ KEY_Home, RETROK_HOME },
{ KEY_End, RETROK_END },
{ KEY_PageUp, RETROK_PAGEUP },
{ KEY_PageDown, RETROK_PAGEDOWN },
{ KEY_F1, RETROK_F1 },
{ KEY_F2, RETROK_F2 },
{ KEY_F3, RETROK_F3 },
{ KEY_F4, RETROK_F4 },
{ KEY_F5, RETROK_F5 },
{ KEY_F6, RETROK_F6 },
{ KEY_F7, RETROK_F7 },
{ KEY_F8, RETROK_F8 },
{ KEY_F9, RETROK_F9 },
{ KEY_F10, RETROK_F10 },
{ KEY_F11, RETROK_F11 },
{ KEY_F12, RETROK_F12 },
{ KEY_F13, RETROK_F13 },
{ KEY_F14, RETROK_F14 },
{ KEY_F15, RETROK_F15 },
// RETROK_NUMLOCK },
{ KEY_CapsLock, RETROK_CAPSLOCK },
// RETROK_SCROLLOCK },
{ KEY_RightShift, RETROK_RSHIFT },
{ KEY_LeftShift, RETROK_LSHIFT },
{ KEY_RightControl, RETROK_RCTRL },
{ KEY_LeftControl, RETROK_LCTRL },
{ KEY_RightAlt, RETROK_RALT },
{ KEY_LeftAlt, RETROK_LALT },
{ KEY_RightGUI, RETROK_RMETA },
{ KEY_LeftGUI, RETROK_RMETA },
// RETROK_LSUPER },
// RETROK_RSUPER },
// RETROK_MODE },
// RETROK_COMPOSE },
// RETROK_HELP },
{ KEY_PrintScreen, RETROK_PRINT },
// RETROK_SYSREQ },
// RETROK_BREAK },
{ KEY_Menu, RETROK_MENU },
// RETROK_POWER },
// RETROK_EURO },
// RETROK_UNDO },
{ 0, RETROK_UNKNOWN }
};
const char* apple_keycode_hidusage_to_name(uint32_t hid_usage)
{
for (int i = 0; apple_key_name_map[i].hid_id; i ++)
if (apple_key_name_map[i].hid_id == hid_usage)
return apple_key_name_map[i].keyname;
return "nul";
}

View File

@ -310,8 +310,8 @@ INPUT
#include "../android/native/jni/input_autodetect.c"
#include "../android/native/jni/input_android.c"
#elif defined(IOS) || defined(OSX)
#include "../apple/common/apple_input.c"
#include "../apple/common/apple_joypad.c"
#include "../input/apple_input.c"
#include "../input/apple_joypad.c"
#elif defined(__BLACKBERRY_QNX__)
#include "../blackberry-qnx/qnx_input.c"
#elif defined(EMSCRIPTEN)

View File

@ -1,4 +1,5 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2011-2014 - Daniel De Matteis
* Copyright (C) 2013-2014 - Jason Fetters
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
@ -16,13 +17,219 @@
#include <unistd.h>
#include "apple_gamecontroller.h"
#include "../../input/input_common.h"
#include "input_common.h"
#include "apple_input.h"
#include "../../general.h"
#include "../../driver.h"
#include "../general.h"
#include "../driver.h"
#include "keycode.inc"
#include "apple_keycode.h"
const struct apple_key_name_map_entry apple_key_name_map[] =
{
{ "left", KEY_Left }, { "right", KEY_Right },
{ "up", KEY_Up }, { "down", KEY_Down },
{ "enter", KEY_Enter }, { "kp_enter", KP_Enter },
{ "space", KEY_Space }, { "tab", KEY_Tab },
{ "shift", KEY_LeftShift }, { "rshift", KEY_RightShift },
{ "ctrl", KEY_LeftControl }, { "alt", KEY_LeftAlt },
{ "escape", KEY_Escape }, { "backspace", KEY_DeleteForward },
{ "backquote", KEY_Grave }, { "pause", KEY_Pause },
{ "f1", KEY_F1 }, { "f2", KEY_F2 },
{ "f3", KEY_F3 }, { "f4", KEY_F4 },
{ "f5", KEY_F5 }, { "f6", KEY_F6 },
{ "f7", KEY_F7 }, { "f8", KEY_F8 },
{ "f9", KEY_F9 }, { "f10", KEY_F10 },
{ "f11", KEY_F11 }, { "f12", KEY_F12 },
{ "num0", KEY_0 }, { "num1", KEY_1 },
{ "num2", KEY_2 }, { "num3", KEY_3 },
{ "num4", KEY_4 }, { "num5", KEY_5 },
{ "num6", KEY_6 }, { "num7", KEY_7 },
{ "num8", KEY_8 }, { "num9", KEY_9 },
{ "insert", KEY_Insert }, { "del", KEY_DeleteForward },
{ "home", KEY_Home }, { "end", KEY_End },
{ "pageup", KEY_PageUp }, { "pagedown", KEY_PageDown },
{ "add", KP_Add }, { "subtract", KP_Subtract },
{ "multiply", KP_Multiply }, { "divide", KP_Divide },
{ "keypad0", KP_0 }, { "keypad1", KP_1 },
{ "keypad2", KP_2 }, { "keypad3", KP_3 },
{ "keypad4", KP_4 }, { "keypad5", KP_5 },
{ "keypad6", KP_6 }, { "keypad7", KP_7 },
{ "keypad8", KP_8 }, { "keypad9", KP_9 },
{ "period", KEY_Period }, { "capslock", KEY_CapsLock },
{ "numlock", KP_NumLock }, { "print_screen", KEY_PrintScreen },
{ "scroll_lock", KEY_ScrollLock },
{ "a", KEY_A }, { "b", KEY_B }, { "c", KEY_C }, { "d", KEY_D },
{ "e", KEY_E }, { "f", KEY_F }, { "g", KEY_G }, { "h", KEY_H },
{ "i", KEY_I }, { "j", KEY_J }, { "k", KEY_K }, { "l", KEY_L },
{ "m", KEY_M }, { "n", KEY_N }, { "o", KEY_O }, { "p", KEY_P },
{ "q", KEY_Q }, { "r", KEY_R }, { "s", KEY_S }, { "t", KEY_T },
{ "u", KEY_U }, { "v", KEY_V }, { "w", KEY_W }, { "x", KEY_X },
{ "y", KEY_Y }, { "z", KEY_Z },
{ "nul", 0x00},
};
const struct rarch_key_map apple_key_map_hidusage[] =
{
{ KEY_Delete, RETROK_BACKSPACE },
{ KEY_Tab, RETROK_TAB },
// RETROK_CLEAR },
{ KEY_Enter, RETROK_RETURN },
{ KEY_Pause, RETROK_PAUSE },
{ KEY_Escape, RETROK_ESCAPE },
{ KEY_Space, RETROK_SPACE },
// RETROK_EXCLAIM },
// RETROK_QUOTEDBL },
// RETROK_HASH },
// RETROK_DOLLAR },
// RETROK_AMPERSAND },
{ KEY_Quote, RETROK_QUOTE },
// RETROK_LEFTPAREN },
// RETROK_RIGHTPAREN },
// RETROK_ASTERISK },
// RETROK_PLUS },
{ KEY_Comma, RETROK_COMMA },
{ KEY_Minus, RETROK_MINUS },
{ KEY_Period, RETROK_PERIOD },
{ KEY_Slash, RETROK_SLASH },
{ KEY_0, RETROK_0 },
{ KEY_1, RETROK_1 },
{ KEY_2, RETROK_2 },
{ KEY_3, RETROK_3 },
{ KEY_4, RETROK_4 },
{ KEY_5, RETROK_5 },
{ KEY_6, RETROK_6 },
{ KEY_7, RETROK_7 },
{ KEY_8, RETROK_8 },
{ KEY_9, RETROK_9 },
// RETROK_COLON },
{ KEY_Semicolon, RETROK_SEMICOLON },
// RETROK_LESS },
{ KEY_Equals, RETROK_EQUALS },
// RETROK_GREATER },
// RETROK_QUESTION },
// RETROK_AT },
{ KEY_LeftBracket, RETROK_LEFTBRACKET },
{ KEY_Backslash, RETROK_BACKSLASH },
{ KEY_RightBracket, RETROK_RIGHTBRACKET },
// RETROK_CARET },
// RETROK_UNDERSCORE },
{ KEY_Grave, RETROK_BACKQUOTE },
{ KEY_A, RETROK_a },
{ KEY_B, RETROK_b },
{ KEY_C, RETROK_c },
{ KEY_D, RETROK_d },
{ KEY_E, RETROK_e },
{ KEY_F, RETROK_f },
{ KEY_G, RETROK_g },
{ KEY_H, RETROK_h },
{ KEY_I, RETROK_i },
{ KEY_J, RETROK_j },
{ KEY_K, RETROK_k },
{ KEY_L, RETROK_l },
{ KEY_M, RETROK_m },
{ KEY_N, RETROK_n },
{ KEY_O, RETROK_o },
{ KEY_P, RETROK_p },
{ KEY_Q, RETROK_q },
{ KEY_R, RETROK_r },
{ KEY_S, RETROK_s },
{ KEY_T, RETROK_t },
{ KEY_U, RETROK_u },
{ KEY_V, RETROK_v },
{ KEY_W, RETROK_w },
{ KEY_X, RETROK_x },
{ KEY_Y, RETROK_y },
{ KEY_Z, RETROK_z },
{ KEY_DeleteForward, RETROK_DELETE },
{ KP_0, RETROK_KP0 },
{ KP_1, RETROK_KP1 },
{ KP_2, RETROK_KP2 },
{ KP_3, RETROK_KP3 },
{ KP_4, RETROK_KP4 },
{ KP_5, RETROK_KP5 },
{ KP_6, RETROK_KP6 },
{ KP_7, RETROK_KP7 },
{ KP_8, RETROK_KP8 },
{ KP_9, RETROK_KP9 },
{ KP_Point, RETROK_KP_PERIOD },
{ KP_Divide, RETROK_KP_DIVIDE },
{ KP_Multiply, RETROK_KP_MULTIPLY },
{ KP_Subtract, RETROK_KP_MINUS },
{ KP_Add, RETROK_KP_PLUS },
{ KP_Enter, RETROK_KP_ENTER },
{ KP_Equals, RETROK_KP_EQUALS },
{ KEY_Up, RETROK_UP },
{ KEY_Down, RETROK_DOWN },
{ KEY_Right, RETROK_RIGHT },
{ KEY_Left, RETROK_LEFT },
{ KEY_Insert, RETROK_INSERT },
{ KEY_Home, RETROK_HOME },
{ KEY_End, RETROK_END },
{ KEY_PageUp, RETROK_PAGEUP },
{ KEY_PageDown, RETROK_PAGEDOWN },
{ KEY_F1, RETROK_F1 },
{ KEY_F2, RETROK_F2 },
{ KEY_F3, RETROK_F3 },
{ KEY_F4, RETROK_F4 },
{ KEY_F5, RETROK_F5 },
{ KEY_F6, RETROK_F6 },
{ KEY_F7, RETROK_F7 },
{ KEY_F8, RETROK_F8 },
{ KEY_F9, RETROK_F9 },
{ KEY_F10, RETROK_F10 },
{ KEY_F11, RETROK_F11 },
{ KEY_F12, RETROK_F12 },
{ KEY_F13, RETROK_F13 },
{ KEY_F14, RETROK_F14 },
{ KEY_F15, RETROK_F15 },
// RETROK_NUMLOCK },
{ KEY_CapsLock, RETROK_CAPSLOCK },
// RETROK_SCROLLOCK },
{ KEY_RightShift, RETROK_RSHIFT },
{ KEY_LeftShift, RETROK_LSHIFT },
{ KEY_RightControl, RETROK_RCTRL },
{ KEY_LeftControl, RETROK_LCTRL },
{ KEY_RightAlt, RETROK_RALT },
{ KEY_LeftAlt, RETROK_LALT },
{ KEY_RightGUI, RETROK_RMETA },
{ KEY_LeftGUI, RETROK_RMETA },
// RETROK_LSUPER },
// RETROK_RSUPER },
// RETROK_MODE },
// RETROK_COMPOSE },
// RETROK_HELP },
{ KEY_PrintScreen, RETROK_PRINT },
// RETROK_SYSREQ },
// RETROK_BREAK },
{ KEY_Menu, RETROK_MENU },
// RETROK_POWER },
// RETROK_EURO },
// RETROK_UNDO },
{ 0, RETROK_UNKNOWN }
};
const char* apple_keycode_hidusage_to_name(uint32_t hid_usage)
{
for (int i = 0; apple_key_name_map[i].hid_id; i ++)
if (apple_key_name_map[i].hid_id == hid_usage)
return apple_key_name_map[i].keyname;
return "nul";
}
extern void apple_gamecontroller_poll_all(void);
enum input_devices
{
@ -211,10 +418,12 @@ void apple_input_keyboard_event(bool down, unsigned code, uint32_t character, ui
int32_t apple_input_find_any_key(void)
{
unsigned i;
apple_gamecontroller_poll_all();
input_init_keyboard_lut(apple_key_map_hidusage);
for (int i = 0; apple_key_name_map[i].hid_id; i++)
for (i = 0; apple_key_name_map[i].hid_id; i++)
if (g_current_input_data.keys[apple_key_name_map[i].hid_id])
return apple_key_name_map[i].hid_id;
@ -223,13 +432,14 @@ int32_t apple_input_find_any_key(void)
int32_t apple_input_find_any_button(uint32_t port)
{
unsigned i, buttons;
apple_gamecontroller_poll_all();
uint32_t buttons = g_current_input_data.pad_buttons[port] |
((port == 0) ? apple_input_get_icade_buttons() : 0);
buttons = g_current_input_data.pad_buttons[port] |
((port == 0) ? apple_input_get_icade_buttons() : 0);
if (buttons)
for (int i = 0; i != 32; i ++)
for (i = 0; i != 32; i ++)
if (buttons & (1 << i))
return i;
@ -275,6 +485,8 @@ static void *apple_input_init(void)
static void apple_input_poll(void *data)
{
(void)data;
apple_gamecontroller_poll_all();
memcpy(&g_polled_input_data, &g_current_input_data, sizeof(apple_input_data_t));
@ -294,6 +506,8 @@ static void apple_input_poll(void *data)
static int16_t apple_input_state(void *data, const struct retro_keybind **binds, unsigned port, unsigned device, unsigned index, unsigned id)
{
(void)data;
switch (device)
{
case RETRO_DEVICE_JOYPAD:
@ -309,10 +523,14 @@ static int16_t apple_input_state(void *data, const struct retro_keybind **binds,
{
switch (id)
{
case RETRO_DEVICE_ID_MOUSE_X: return g_polled_input_data.mouse_delta[0];
case RETRO_DEVICE_ID_MOUSE_Y: return g_polled_input_data.mouse_delta[1];
case RETRO_DEVICE_ID_MOUSE_LEFT: return g_polled_input_data.mouse_buttons & 1;
case RETRO_DEVICE_ID_MOUSE_RIGHT: return g_polled_input_data.mouse_buttons & 2;
case RETRO_DEVICE_ID_MOUSE_X:
return g_polled_input_data.mouse_delta[0];
case RETRO_DEVICE_ID_MOUSE_Y:
return g_polled_input_data.mouse_delta[1];
case RETRO_DEVICE_ID_MOUSE_LEFT:
return g_polled_input_data.mouse_buttons & 1;
case RETRO_DEVICE_ID_MOUSE_RIGHT:
return g_polled_input_data.mouse_buttons & 2;
}
}
@ -323,15 +541,18 @@ static int16_t apple_input_state(void *data, const struct retro_keybind **binds,
if (index < g_polled_input_data.touch_count && index < MAX_TOUCHES)
{
const apple_touch_data_t* touch = &g_polled_input_data.touches[index];
const apple_touch_data_t *touch = (const apple_touch_data_t *)&g_polled_input_data.touches[index];
int16_t x = want_full ? touch->full_x : touch->fixed_x;
int16_t y = want_full ? touch->full_y : touch->fixed_y;
switch (id)
{
case RETRO_DEVICE_ID_POINTER_PRESSED: return (x != -0x8000) && (y != -0x8000);
case RETRO_DEVICE_ID_POINTER_X: return x;
case RETRO_DEVICE_ID_POINTER_Y: return y;
case RETRO_DEVICE_ID_POINTER_PRESSED:
return (x != -0x8000) && (y != -0x8000);
case RETRO_DEVICE_ID_POINTER_X:
return x;
case RETRO_DEVICE_ID_POINTER_Y:
return y;
}
}
@ -346,6 +567,8 @@ static int16_t apple_input_state(void *data, const struct retro_keybind **binds,
static bool apple_bind_button_pressed(void *data, int key)
{
const struct retro_keybind *binds = g_settings.input.binds[0];
(void)data;
return (key >= 0 && key < RARCH_BIND_LIST_END) ? apple_is_pressed(0, binds, key) : false;
}
@ -426,6 +649,7 @@ static void apple_input_set_keybinds(void *data, unsigned device, unsigned port,
static bool apple_input_set_rumble(void *data, unsigned port, enum retro_rumble_effect effect, uint16_t strength)
{
(void)data;
return input_joypad_set_rumble(g_joydriver, port, effect, strength);
}
@ -433,6 +657,8 @@ static uint64_t apple_input_get_capabilities(void *data)
{
uint64_t caps = 0;
(void)data;
caps |= (1 << RETRO_DEVICE_JOYPAD);
caps |= (1 << RETRO_DEVICE_MOUSE);
caps |= (1 << RETRO_DEVICE_KEYBOARD);

View File

@ -1,4 +1,5 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2011-2014 - Daniel De Matteis
* Copyright (C) 2013-2014 - Jason Fetters
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
@ -16,7 +17,7 @@
#ifndef __APPLE_RARCH_INPUT_H__
#define __APPLE_RARCH_INPUT_H__
#include "../../general.h"
#include "../general.h"
// Input responder
#define MAX_TOUCHES 16
@ -55,7 +56,7 @@ struct apple_pad_interface
// Joypad data
int32_t apple_joypad_connect(const char* name, struct apple_pad_connection* connection);
int32_t apple_joypad_connect_gcapi();
int32_t apple_joypad_connect_gcapi(void);
void apple_joypad_disconnect(uint32_t slot);
void apple_joypad_packet(uint32_t slot, uint8_t* data, uint32_t length);

View File

@ -13,20 +13,20 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "../../input/input_common.h"
#include "../../general.h"
#include "input_common.h"
#include "../general.h"
#ifdef IOS
#include "apple/iOS/bluetooth/btdynamic.c"
#include "apple/iOS/bluetooth/btpad.c"
#include "apple/iOS/bluetooth/btpad_queue.c"
#include "../apple/iOS/bluetooth/btdynamic.c"
#include "../apple/iOS/bluetooth/btpad.c"
#include "../apple/iOS/bluetooth/btpad_queue.c"
#elif defined(OSX)
#include "../OSX/hid_pad.c"
#include "../apple/OSX/hid_pad.c"
#endif
#include "hidpad/wiimote.c"
#include "hidpad/apple_ps3_pad.c"
#include "hidpad/apple_wii_pad.c"
#include "../apple/common/hidpad/wiimote.c"
#include "../apple/common/hidpad/apple_ps3_pad.c"
#include "../apple/common/hidpad/apple_wii_pad.c"
typedef struct
{
@ -39,14 +39,18 @@ typedef struct
static joypad_slot_t slots[MAX_PLAYERS];
static int32_t find_empty_slot()
static int32_t find_empty_slot(void)
{
for (int i = 0; i != MAX_PLAYERS; i ++)
unsigned i;
for (i = 0; i < MAX_PLAYERS; i++)
{
if (!slots[i].used)
{
memset(&slots[i], 0, sizeof(slots[0]));
return i;
}
}
return -1;
}
@ -56,15 +60,22 @@ int32_t apple_joypad_connect(const char* name, struct apple_pad_connection* conn
if (slot >= 0 && slot < MAX_PLAYERS)
{
joypad_slot_t* s = &slots[slot];
unsigned i;
joypad_slot_t* s = (joypad_slot_t*)&slots[slot];
s->used = true;
static const struct { const char* name; struct apple_pad_interface* iface; } pad_map[] = {
static const struct
{
const char* name;
struct apple_pad_interface* iface;
} pad_map[] =
{
{ "Nintendo RVL-CNT-01", &apple_pad_wii },
{ "PLAYSTATION(R)3 Controller", &apple_pad_ps3 },
{ 0, 0} };
{ 0, 0}
};
for (int i = 0; name && pad_map[i].name; i ++)
for (i = 0; name && pad_map[i].name; i++)
if (strstr(name, pad_map[i].name))
{
s->iface = pad_map[i].iface;
@ -75,13 +86,13 @@ int32_t apple_joypad_connect(const char* name, struct apple_pad_connection* conn
return slot;
}
int32_t apple_joypad_connect_gcapi()
int32_t apple_joypad_connect_gcapi(void)
{
int32_t slot = find_empty_slot();
if (slot >= 0 && slot < MAX_PLAYERS)
{
joypad_slot_t* s = &slots[slot];
joypad_slot_t* s = (joypad_slot_t*)&slots[slot];
s->used = true;
s->is_gcapi = true;
}
@ -93,7 +104,7 @@ void apple_joypad_disconnect(uint32_t slot)
{
if (slot < MAX_PLAYERS && slots[slot].used)
{
joypad_slot_t* s = &slots[slot];
joypad_slot_t* s = (joypad_slot_t*)&slots[slot];
if (s->iface && s->data)
s->iface->disconnect(s->data);
@ -106,7 +117,7 @@ void apple_joypad_packet(uint32_t slot, uint8_t* data, uint32_t length)
{
if (slot < MAX_PLAYERS && slots[slot].used)
{
joypad_slot_t* s = &slots[slot];
joypad_slot_t *s = (joypad_slot_t*)&slots[slot];
if (s->iface && s->data)
s->iface->packet_handler(s->data, data, length);
@ -117,6 +128,7 @@ bool apple_joypad_has_interface(uint32_t slot)
{
if (slot < MAX_PLAYERS && slots[slot].used)
return slots[slot].iface ? true : false;
return false;
}
@ -133,7 +145,9 @@ static bool apple_joypad_query_pad(unsigned pad)
static void apple_joypad_destroy(void)
{
for (int i = 0; i != MAX_PLAYERS; i ++)
unsigned i;
for (i = 0; i < MAX_PLAYERS; i ++)
{
if (slots[i].used && slots[i].iface)
{
@ -157,10 +171,13 @@ static bool apple_joypad_button(unsigned port, uint16_t joykey)
static int16_t apple_joypad_axis(unsigned port, uint32_t joyaxis)
{
int16_t val;
if (joyaxis == AXIS_NONE)
return 0;
int16_t val = 0;
val = 0;
if (AXIS_NEG_GET(joyaxis) < 4)
{
val = g_polled_input_data.pad_axis[port][AXIS_NEG_GET(joyaxis)];
@ -190,7 +207,6 @@ static bool apple_joypad_rumble(unsigned pad, enum retro_rumble_effect effect, u
return false;
}
static const char *apple_joypad_name(unsigned joypad)
{
(void)joypad;
@ -208,4 +224,3 @@ const rarch_joypad_driver_t apple_joypad = {
apple_joypad_name,
"apple"
};

172
input/apple_keycode.h Normal file
View File

@ -0,0 +1,172 @@
/*
Taken from https://github.com/depp/keycode, distributed with the following license:
Copyright 2011-2012 Dietrich Epp <depp@zdome.net>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/* This file is automatically generated by keycode.py. */
#ifndef KEYCODE_KEYCODE_H
#define KEYCODE_KEYCODE_H
enum
{
KEY_A = 4,
KEY_B = 5,
KEY_C = 6,
KEY_D = 7,
KEY_E = 8,
KEY_F = 9,
KEY_G = 10,
KEY_H = 11,
KEY_I = 12,
KEY_J = 13,
KEY_K = 14,
KEY_L = 15,
KEY_M = 16,
KEY_N = 17,
KEY_O = 18,
KEY_P = 19,
KEY_Q = 20,
KEY_R = 21,
KEY_S = 22,
KEY_T = 23,
KEY_U = 24,
KEY_V = 25,
KEY_W = 26,
KEY_X = 27,
KEY_Y = 28,
KEY_Z = 29,
KEY_1 = 30,
KEY_2 = 31,
KEY_3 = 32,
KEY_4 = 33,
KEY_5 = 34,
KEY_6 = 35,
KEY_7 = 36,
KEY_8 = 37,
KEY_9 = 38,
KEY_0 = 39,
KEY_Enter = 40,
KEY_Escape = 41,
KEY_Delete = 42,
KEY_Tab = 43,
KEY_Space = 44,
KEY_Minus = 45,
KEY_Equals = 46,
KEY_LeftBracket = 47,
KEY_RightBracket = 48,
KEY_Backslash = 49,
KEY_Semicolon = 51,
KEY_Quote = 52,
KEY_Grave = 53,
KEY_Comma = 54,
KEY_Period = 55,
KEY_Slash = 56,
KEY_CapsLock = 57,
KEY_F1 = 58,
KEY_F2 = 59,
KEY_F3 = 60,
KEY_F4 = 61,
KEY_F5 = 62,
KEY_F6 = 63,
KEY_F7 = 64,
KEY_F8 = 65,
KEY_F9 = 66,
KEY_F10 = 67,
KEY_F11 = 68,
KEY_F12 = 69,
KEY_PrintScreen = 70,
KEY_ScrollLock = 71,
KEY_Pause = 72,
KEY_Insert = 73,
KEY_Home = 74,
KEY_PageUp = 75,
KEY_DeleteForward = 76,
KEY_End = 77,
KEY_PageDown = 78,
KEY_Right = 79,
KEY_Left = 80,
KEY_Down = 81,
KEY_Up = 82,
KP_NumLock = 83,
KP_Divide = 84,
KP_Multiply = 85,
KP_Subtract = 86,
KP_Add = 87,
KP_Enter = 88,
KP_1 = 89,
KP_2 = 90,
KP_3 = 91,
KP_4 = 92,
KP_5 = 93,
KP_6 = 94,
KP_7 = 95,
KP_8 = 96,
KP_9 = 97,
KP_0 = 98,
KP_Point = 99,
KEY_NonUSBackslash = 100,
KP_Equals = 103,
KEY_F13 = 104,
KEY_F14 = 105,
KEY_F15 = 106,
KEY_F16 = 107,
KEY_F17 = 108,
KEY_F18 = 109,
KEY_F19 = 110,
KEY_F20 = 111,
KEY_F21 = 112,
KEY_F22 = 113,
KEY_F23 = 114,
KEY_F24 = 115,
KEY_Help = 117,
KEY_Menu = 118,
KEY_LeftControl = 224,
KEY_LeftShift = 225,
KEY_LeftAlt = 226,
KEY_LeftGUI = 227,
KEY_RightControl = 228,
KEY_RightShift = 229,
KEY_RightAlt = 230,
KEY_RightGUI = 231
};
#include "input_common.h" // < For rarch_key_map
struct apple_key_name_map_entry
{
const char* const keyname;
const uint32_t hid_id;
};
extern const struct apple_key_name_map_entry apple_key_name_map[];
extern const struct rarch_key_map apple_key_map_hidusage[];
const char* apple_keycode_hidusage_to_name(uint32_t hid_usage);
#endif