(Cocoa) Start renaming input_apple to input_cocoa

This commit is contained in:
twinaphex 2015-04-19 17:58:15 +02:00
parent 8c528bb79a
commit 8702141d90
14 changed files with 100 additions and 101 deletions

View File

@ -17,7 +17,7 @@
#include <string.h>
#import "../common/RetroArch_Apple.h"
#include "../../input/drivers/apple_input.h"
#include "../../input/drivers/cocoa_input.h"
#include "../../frontend/frontend.h"
#include "../../menu/menu.h"
#include "../../retroarch.h"
@ -42,11 +42,11 @@ void apple_rarch_exited(void)
- (void)sendEvent:(NSEvent *)event
{
NSEventType event_type;
apple_input_data_t *apple = NULL;
cocoa_input_data_t *apple = NULL;
driver_t *driver = driver_get_ptr();
[super sendEvent:event];
apple = (apple_input_data_t*)driver->input_data;
apple = (cocoa_input_data_t*)driver->input_data;
event_type = event.type;
if (!apple)
@ -195,7 +195,7 @@ static void poll_iteration(void)
{
NSEvent *event = NULL;
driver_t *driver = driver_get_ptr();
apple_input_data_t *apple = (apple_input_data_t*)driver->input_data;
cocoa_input_data_t *apple = (cocoa_input_data_t*)driver->input_data;
if (!apple)
return;

View File

@ -17,7 +17,7 @@
#import "../common/RetroArch_Apple.h"
#include <retro_miscellaneous.h>
#include "../../settings.h"
#include "../../input/drivers/apple_input.h"
#include "../../input/drivers/cocoa_input.h"
#include "../../driver.h"
#include "../../input/input_common.h"
@ -76,11 +76,11 @@ static void* const associated_name_tag = (void*)&associated_name_tag;
if (self.setting->index)
idx = self.setting->index - 1;
if ((value = apple_input_find_any_key()))
if ((value = cocoa_input_find_any_key()))
BINDFOR(*[self setting]).key = input_keymaps_translate_keysym_to_rk(value);
else if ((value = apple_input_find_any_button(idx)) >= 0)
else if ((value = cocoa_input_find_any_button(idx)) >= 0)
BINDFOR(*[self setting]).joykey = value;
else if ((value = apple_input_find_any_axis(idx)))
else if ((value = cocoa_input_find_any_axis(idx)))
BINDFOR(*[self setting]).joyaxis = (value > 0) ? AXIS_POS(value - 1) : AXIS_NEG(abs(value) - 1);
else
return;

View File

@ -17,7 +17,7 @@
#include "../common/RetroArch_Apple.h"
#include "../../input/input_common.h"
#include "../../input/input_keymaps.h"
#include "../../input/drivers/apple_input.h"
#include "../../input/drivers/cocoa_input.h"
#include <file/file_path.h>
#include <retro_miscellaneous.h>
#include "menu.h"
@ -543,7 +543,7 @@ static void RunActionSheet(const char* title, const struct string_list* items, U
[self.bindTimer invalidate];
self.bindTimer = nil;
apple_input_reset_icade_buttons();
cocoa_input_reset_icade_buttons();
}
- (void)alertView:(UIAlertView*)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
@ -566,11 +566,11 @@ static void RunActionSheet(const char* title, const struct string_list* items, U
if (self.setting->index)
idx = self.setting->index - 1;
if ((value = apple_input_find_any_key()))
if ((value = cocoa_input_find_any_key()))
BINDFOR(*self.setting).key = input_keymaps_translate_keysym_to_rk(value);
else if ((value = apple_input_find_any_button(idx)) >= 0)
else if ((value = cocoa_input_find_any_button(idx)) >= 0)
BINDFOR(*self.setting).joykey = value;
else if ((value = apple_input_find_any_axis(idx)))
else if ((value = cocoa_input_find_any_axis(idx)))
BINDFOR(*self.setting).joyaxis = (value > 0) ? AXIS_POS(value - 1) : AXIS_NEG(abs(value) - 1);
else
return;

View File

@ -17,7 +17,7 @@
#include <string.h>
#include "../common/RetroArch_Apple.h"
#include "../../input/drivers/apple_input.h"
#include "../../input/drivers/cocoa_input.h"
#include "../../settings.h"
#ifdef HAVE_MFI
#include "../../input/drivers_hid/mfi_hid.h"
@ -117,7 +117,7 @@ static void handle_touch_event(NSArray* touches)
{
unsigned i;
driver_t *driver = driver_get_ptr();
apple_input_data_t *apple = (apple_input_data_t*)driver->input_data;
cocoa_input_data_t *apple = (cocoa_input_data_t*)driver->input_data;
float scale = cocoagl_gfx_ctx_get_native_scale();
if (!apple)
@ -361,7 +361,7 @@ enum
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
apple_input_reset_icade_buttons();
cocoa_input_reset_icade_buttons();
[self setToolbarHidden:![[viewController toolbarItems] count] animated:YES];
// Workaround to keep frontend settings fresh
@ -444,8 +444,8 @@ enum
is_icade = !(strcmp(apple_frontend_settings.bluetooth_mode, "icade"));
is_btstack = !(strcmp(apple_frontend_settings.bluetooth_mode, "btstack"));
apple_input_enable_small_keyboard(small_keyboard);
apple_input_enable_icade(is_icade);
cocoa_input_enable_small_keyboard(small_keyboard);
cocoa_input_enable_icade(is_icade);
btstack_set_poweron(is_btstack);
}

View File

@ -88,7 +88,7 @@ enum
INPUT_XINPUT,
INPUT_UDEV,
INPUT_LINUXRAW,
INPUT_APPLE,
INPUT_COCOA,
INPUT_QNX,
INPUT_RWEBINPUT,
INPUT_NULL,
@ -245,8 +245,8 @@ enum
#define INPUT_DEFAULT_DRIVER INPUT_X
#elif defined(HAVE_WAYLAND)
#define INPUT_DEFAULT_DRIVER INPUT_WAYLAND
#elif defined(IOS) || defined(OSX)
#define INPUT_DEFAULT_DRIVER INPUT_APPLE
#elif defined(HAVE_COCOA) || defined(HAVE_COCOATOUCH)
#define INPUT_DEFAULT_DRIVER INPUT_COCOA
#elif defined(__QNX__)
#define INPUT_DEFAULT_DRIVER INPUT_QNX
#elif defined(HAVE_SDL)

View File

@ -251,8 +251,8 @@ const char *config_get_default_input(void)
return "linuxraw";
case INPUT_UDEV:
return "udev";
case INPUT_APPLE:
return "apple_input";
case INPUT_COCOA:
return "cocoa";
case INPUT_QNX:
return "qnx_input";
case INPUT_RWEBINPUT:

View File

@ -317,8 +317,8 @@ INPUT
#elif defined(ANDROID)
#include "../input/drivers/android_input.c"
#include "../input/drivers_joypad/android_joypad.c"
#elif defined(__APPLE__)
#include "../input/drivers/apple_input.c"
#elif defined(HAVE_COCOA) || defined(HAVE_COCOATOUCH)
#include "../input/drivers/cocoa_input.c"
#elif defined(__QNX__)
#include "../input/drivers/qnx_input.c"
#include "../input/drivers_joypad/qnx_joypad.c"

View File

@ -20,7 +20,7 @@
#include "../input_common.h"
#include "../input_joypad.h"
#include "../input_keymaps.h"
#include "apple_input.h"
#include "cocoainput.h"
#include "../../general.h"
#include "../../driver.h"
@ -125,18 +125,18 @@ const struct apple_key_name_map_entry apple_key_name_map[] =
{ "nul", 0x00},
};
void apple_input_enable_small_keyboard(bool on)
void cocoa_input_enable_small_keyboard(bool on)
{
driver_t *driver = driver_get_ptr();
apple_input_data_t *apple = (apple_input_data_t*)driver->input_data;
cocoa_input_data_t *apple = (cocoa_input_data_t*)driver->input_data;
if (apple)
apple->small_keyboard_enabled = on;
}
void apple_input_enable_icade(bool on)
void cocoa_input_enable_icade(bool on)
{
driver_t *driver = driver_get_ptr();
apple_input_data_t *apple = (apple_input_data_t*)driver->input_data;
cocoa_input_data_t *apple = (cocoa_input_data_t*)driver->input_data;
if (!apple)
return;
@ -145,20 +145,20 @@ void apple_input_enable_icade(bool on)
apple->icade_buttons = 0;
}
void apple_input_reset_icade_buttons(void)
void cocoa_input_reset_icade_buttons(void)
{
driver_t *driver = driver_get_ptr();
apple_input_data_t *apple = (apple_input_data_t*)driver->input_data;
cocoa_input_data_t *apple = (cocoa_input_data_t*)driver->input_data;
if (apple)
apple->icade_buttons = 0;
}
int32_t apple_input_find_any_key(void)
int32_t cocoa_input_find_any_key(void)
{
unsigned i;
driver_t *driver =driver_get_ptr();
apple_input_data_t *apple = (apple_input_data_t*)driver->input_data;
cocoa_input_data_t *apple = (cocoa_input_data_t*)driver->input_data;
if (!apple)
return 0;
@ -173,11 +173,11 @@ int32_t apple_input_find_any_key(void)
return 0;
}
int32_t apple_input_find_any_button(uint32_t port)
int32_t cocoa_input_find_any_button(uint32_t port)
{
unsigned i, buttons = 0;
driver_t *driver = driver_get_ptr();
apple_input_data_t *apple = (apple_input_data_t*)driver->input_data;
cocoa_input_data_t *apple = (cocoa_input_data_t*)driver->input_data;
if (!apple)
return -1;
@ -197,11 +197,11 @@ int32_t apple_input_find_any_button(uint32_t port)
return -1;
}
int32_t apple_input_find_any_axis(uint32_t port)
int32_t cocoa_input_find_any_axis(uint32_t port)
{
int i;
driver_t *driver = driver_get_ptr();
apple_input_data_t *apple = (apple_input_data_t*)driver->input_data;
cocoa_input_data_t *apple = (cocoa_input_data_t*)driver->input_data;
if (apple && apple->joypad)
apple->joypad->poll();
@ -217,7 +217,7 @@ int32_t apple_input_find_any_axis(uint32_t port)
return 0;
}
static int16_t apple_input_is_pressed(apple_input_data_t *apple, unsigned port_num,
static int16_t cocoa_input_is_pressed(cocoa_input_data_t *apple, unsigned port_num,
const struct retro_keybind *binds, unsigned id)
{
if (id < RARCH_BIND_LIST_END)
@ -229,10 +229,10 @@ static int16_t apple_input_is_pressed(apple_input_data_t *apple, unsigned port_n
return 0;
}
static void *apple_input_init(void)
static void *cocoa_input_init(void)
{
settings_t *settings = config_get_ptr();
apple_input_data_t *apple = (apple_input_data_t*)calloc(1, sizeof(*apple));
cocoa_input_data_t *apple = (cocoa_input_data_t*)calloc(1, sizeof(*apple));
if (!apple)
return NULL;
@ -243,10 +243,10 @@ static void *apple_input_init(void)
return apple;
}
static void apple_input_poll(void *data)
static void cocoa_input_poll(void *data)
{
uint32_t i;
apple_input_data_t *apple = (apple_input_data_t*)data;
cocoa_input_data_t *apple = (cocoa_input_data_t*)data;
if (!apple)
return;
@ -267,7 +267,7 @@ static void apple_input_poll(void *data)
BIT32_SET(apple->buttons[0], apple->icade_buttons);
}
static int16_t apple_mouse_state(apple_input_data_t *apple,
static int16_t cocoa_mouse_state(cocoa_input_data_t *apple,
unsigned id)
{
switch (id)
@ -289,7 +289,7 @@ static int16_t apple_mouse_state(apple_input_data_t *apple,
return 0;
}
static int16_t apple_pointer_state(apple_input_data_t *apple,
static int16_t cocoa_pointer_state(cocoa_input_data_t *apple,
unsigned device, unsigned idx, unsigned id)
{
const bool want_full = (device == RARCH_DEVICE_POINTER_SCREEN);
@ -297,7 +297,7 @@ static int16_t apple_pointer_state(apple_input_data_t *apple,
if (idx < apple->touch_count && (idx < MAX_TOUCHES))
{
int16_t x, y;
const apple_touch_data_t *touch = (const apple_touch_data_t *)
const cocoa_touch_data_t *touch = (const cocoa_touch_data_t *)
&apple->touches[idx];
if (!touch)
@ -326,17 +326,17 @@ static int16_t apple_pointer_state(apple_input_data_t *apple,
return 0;
}
static int16_t apple_keyboard_state(apple_input_data_t *apple, unsigned id)
static int16_t cocoa_keyboard_state(cocoa_input_data_t *apple, unsigned id)
{
unsigned bit = input_keymaps_translate_rk_to_keysym((enum retro_key)id);
return (id < RETROK_LAST) && apple->key_state[bit];
}
static int16_t apple_input_state(void *data,
static int16_t cocoa_input_state(void *data,
const struct retro_keybind **binds, unsigned port,
unsigned device, unsigned idx, unsigned id)
{
apple_input_data_t *apple = (apple_input_data_t*)data;
cocoa_input_data_t *apple = (cocoa_input_data_t*)data;
if (!apple || !apple->joypad)
return 0;
@ -344,36 +344,36 @@ static int16_t apple_input_state(void *data,
switch (device)
{
case RETRO_DEVICE_JOYPAD:
return apple_input_is_pressed(apple, port, binds[port], id) ||
return cocoa_input_is_pressed(apple, port, binds[port], id) ||
input_joypad_pressed(apple->joypad, port, binds[port], id);
case RETRO_DEVICE_ANALOG:
return input_joypad_analog(apple->joypad, port,
idx, id, binds[port]);
case RETRO_DEVICE_KEYBOARD:
return apple_keyboard_state(apple, id);
return cocoa_keyboard_state(apple, id);
case RETRO_DEVICE_MOUSE:
return apple_mouse_state(apple, id);
return cocoa_mouse_state(apple, id);
case RETRO_DEVICE_POINTER:
case RARCH_DEVICE_POINTER_SCREEN:
return apple_pointer_state(apple, device, idx, id);
return cocoa_pointer_state(apple, device, idx, id);
}
return 0;
}
static bool apple_input_bind_button_pressed(void *data, int key)
static bool cocoa_input_bind_button_pressed(void *data, int key)
{
apple_input_data_t *apple = (apple_input_data_t*)data;
cocoa_input_data_t *apple = (cocoa_input_data_t*)data;
settings_t *settings = config_get_ptr();
if (apple && apple->joypad)
return apple_input_is_pressed(apple, 0, settings->input.binds[0], key) ||
return cocoa_input_is_pressed(apple, 0, settings->input.binds[0], key) ||
input_joypad_pressed(apple->joypad, 0, settings->input.binds[0], key);
return false;
}
static void apple_input_free(void *data)
static void cocoa_input_free(void *data)
{
apple_input_data_t *apple = (apple_input_data_t*)data;
cocoa_input_data_t *apple = (cocoa_input_data_t*)data;
if (!apple || !data)
return;
@ -384,10 +384,10 @@ static void apple_input_free(void *data)
free(apple);
}
static bool apple_input_set_rumble(void *data,
static bool cocoa_input_set_rumble(void *data,
unsigned port, enum retro_rumble_effect effect, uint16_t strength)
{
apple_input_data_t *apple = (apple_input_data_t*)data;
cocoa_input_data_t *apple = (cocoa_input_data_t*)data;
if (apple && apple->joypad)
return input_joypad_set_rumble(apple->joypad,
@ -395,7 +395,7 @@ static bool apple_input_set_rumble(void *data,
return false;
}
static uint64_t apple_input_get_capabilities(void *data)
static uint64_t cocoa_input_get_capabilities(void *data)
{
(void)data;
@ -407,33 +407,33 @@ static uint64_t apple_input_get_capabilities(void *data)
(1 << RETRO_DEVICE_ANALOG);
}
static void apple_input_grab_mouse(void *data, bool state)
static void cocoa_input_grab_mouse(void *data, bool state)
{
/* Dummy for now. Might be useful in the future. */
(void)data;
(void)state;
}
static const input_device_driver_t *apple_input_get_joypad_driver(void *data)
static const input_device_driver_t *cocoa_input_get_joypad_driver(void *data)
{
apple_input_data_t *apple = (apple_input_data_t*)data;
cocoa_input_data_t *apple = (cocoa_input_data_t*)data;
if (apple && apple->joypad)
return apple->joypad;
return NULL;
}
input_driver_t input_apple = {
apple_input_init,
apple_input_poll,
apple_input_state,
apple_input_bind_button_pressed,
apple_input_free,
input_driver_t input_cocoa = {
cocoa_input_init,
cocoa_input_poll,
cocoa_input_state,
cocoa_input_bind_button_pressed,
cocoa_input_free,
NULL,
NULL,
apple_input_get_capabilities,
"apple_input",
apple_input_grab_mouse,
apple_input_set_rumble,
apple_input_get_joypad_driver
cocoa_input_get_capabilities,
"cocoa",
cocoa_input_grab_mouse,
cocoa_input_set_rumble,
cocoa_input_get_joypad_driver
};

View File

@ -14,8 +14,8 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __APPLE_RARCH_INPUT_H__
#define __APPLE_RARCH_INPUT_H__
#ifndef __COCOA_INPUT_H__
#define __COCOA_INPUT_H__
#include <stdint.h>
#include "../../general.h"
@ -33,11 +33,11 @@ typedef struct
int16_t screen_x, screen_y;
int16_t fixed_x, fixed_y;
int16_t full_x, full_y;
} apple_touch_data_t;
} cocoa_touch_data_t;
typedef struct
{
apple_touch_data_t touches[MAX_TOUCHES];
cocoa_touch_data_t touches[MAX_TOUCHES];
uint32_t touch_count;
uint32_t mouse_buttons;
@ -58,21 +58,21 @@ typedef struct
uint32_t icade_buttons;
const input_device_driver_t *joypad;
} apple_input_data_t;
} cocoa_input_data_t;
void apple_input_enable_icade(bool on);
void cocoa_input_enable_icade(bool on);
void apple_input_enable_small_keyboard(bool on);
void cocoa_input_enable_small_keyboard(bool on);
void apple_input_reset_icade_buttons(void);
void cocoa_input_reset_icade_buttons(void);
void apple_input_keyboard_event(bool down, unsigned code,
void cocoa_input_keyboard_event(bool down, unsigned code,
uint32_t character, uint32_t mod, unsigned device);
extern int32_t apple_input_find_any_key(void);
extern int32_t cocoa_input_find_any_key(void);
extern int32_t apple_input_find_any_button(uint32_t port);
extern int32_t cocoa_input_find_any_button(uint32_t port);
extern int32_t apple_input_find_any_axis(uint32_t port);
extern int32_t cocoa_input_find_any_axis(uint32_t port);
#endif

View File

@ -17,7 +17,7 @@
#include <IOKit/hid/IOHIDManager.h>
#include <IOKit/hid/IOHIDKeys.h>
#include "../connect/joypad_connection.h"
#include "../drivers/apple_input.h"
#include "../drivers/cocoa_input.h"
#include "../input_hid_driver.h"
typedef struct apple_hid
@ -139,7 +139,7 @@ static void apple_hid_device_input_callback(void *data, IOReturn result,
void* sender, IOHIDValueRef value)
{
driver_t *driver = driver_get_ptr();
apple_input_data_t *apple = (apple_input_data_t*)driver->input_data;
cocoa_input_data_t *apple = (cocoa_input_data_t*)driver->input_data;
struct apple_hid_adapter *adapter = (struct apple_hid_adapter*)data;
IOHIDElementRef element = IOHIDValueGetElement(value);
uint32_t type = IOHIDElementGetType(element);
@ -210,7 +210,7 @@ static void apple_hid_device_input_callback(void *data, IOReturn result,
static void apple_hid_device_remove(void *data, IOReturn result, void* sender)
{
driver_t *driver = driver_get_ptr();
apple_input_data_t *apple = (apple_input_data_t*)driver->input_data;
cocoa_input_data_t *apple = (cocoa_input_data_t*)driver->input_data;
struct apple_hid_adapter *adapter = (struct apple_hid_adapter*)data;
apple_hid_t *hid = driver ? (apple_hid_t*)driver->hid_data : NULL;

View File

@ -17,7 +17,7 @@
#import <GameController/GameController.h>
#include <boolean.h>
#include "mfi_hid.h"
#include "../../input/drivers/apple_input.h"
#include "../../input/drivers/cocoa_input.h"
enum
{
@ -44,7 +44,7 @@ static void apple_gamecontroller_poll(GCController *controller)
{
uint32_t slot, pause;
driver_t *driver = driver_get_ptr();
apple_input_data_t *apple = (apple_input_data_t*)driver->input_data;
cocoa_input_data_t *apple = (cocoa_input_data_t*)driver->input_data;
if (!apple || !controller || controller.playerIndex == MAX_USERS)
return;
@ -105,7 +105,7 @@ void apple_gamecontroller_poll_all(void)
static void apple_gamecontroller_register(GCGamepad *gamepad)
{
driver_t *driver = driver_get_ptr();
apple_input_data_t *apple = (apple_input_data_t*)driver->input_data;
cocoa_input_data_t *apple = (cocoa_input_data_t*)driver->input_data;
gamepad.valueChangedHandler = ^(GCGamepad *updateGamepad, GCControllerElement *element) {
apple_gamecontroller_poll(updateGamepad.controller);
};

View File

@ -19,7 +19,7 @@
#include "../input_common.h"
#include "../input_keymaps.h"
#include "../drivers/apple_input.h"
#include "../drivers/cocoa_input.h"
#include "../../general.h"
#include "../../driver.h"
@ -70,7 +70,7 @@ static bool handle_small_keyboard(unsigned* code, bool down)
{ 0 }
};
driver_t *driver = driver_get_ptr();
apple_input_data_t *apple = (apple_input_data_t*)driver->input_data;
cocoa_input_data_t *apple = (cocoa_input_data_t*)driver->input_data;
unsigned translated_code = 0;
if (!map_initialized)
@ -122,7 +122,7 @@ static void handle_icade_event(unsigned keycode)
{ false, 4 }, { true , 1 }, { false, -1 }, { false, -1 } // C
};
driver_t *driver = driver_get_ptr();
apple_input_data_t *apple = (apple_input_data_t*)driver->input_data;
cocoa_input_data_t *apple = (cocoa_input_data_t*)driver->input_data;
if (apple->icade_enabled && (keycode < 0x20)
&& (icade_map[keycode].button >= 0))
@ -140,7 +140,7 @@ void apple_input_keyboard_event(bool down,
unsigned code, uint32_t character, uint32_t mod, unsigned device)
{
driver_t *driver = driver_get_ptr();
apple_input_data_t *apple = (apple_input_data_t*)driver->input_data;
cocoa_input_data_t *apple = (cocoa_input_data_t*)driver->input_data;
if (!apple)
return;

View File

@ -59,9 +59,8 @@ static const input_driver_t *input_drivers[] = {
#if defined(__linux__) && !defined(ANDROID)
&input_linuxraw,
#endif
#if defined(IOS) || defined(OSX)
/* Don't use __APPLE__ as it breaks basic SDL builds */
&input_apple,
#if defined(HAVE_COCOA) || defined(HAVE_COCOATOUCH)
&input_cocoa,
#endif
#ifdef __QNX__
&input_qnx,

View File

@ -90,7 +90,7 @@ extern input_driver_t input_gx;
extern input_driver_t input_xinput;
extern input_driver_t input_linuxraw;
extern input_driver_t input_udev;
extern input_driver_t input_apple;
extern input_driver_t input_cocoa;
extern input_driver_t input_qnx;
extern input_driver_t input_rwebinput;
extern input_driver_t input_null;