additional compile fixes

This commit is contained in:
David Walters 2017-11-28 10:36:16 +00:00
parent c5bdc02d6f
commit f09477d46a
4 changed files with 42 additions and 33 deletions

View File

@ -186,13 +186,14 @@ static bool hidpad_ps4_check_dpad(struct ps4 *rpt, unsigned id)
static void hidpad_ps4_get_buttons(void *data, retro_bits_t* state) static void hidpad_ps4_get_buttons(void *data, retro_bits_t* state)
{ {
uint64_t buttonstate = 0;
struct hidpad_ps4_data *device = (struct hidpad_ps4_data*)data; struct hidpad_ps4_data *device = (struct hidpad_ps4_data*)data;
struct ps4 *rpt = device ? (struct ps4*)&device->data : NULL; struct ps4 *rpt = device ? (struct ps4*)&device->data : NULL;
if (!device || !rpt) if (!device || !rpt)
return; return;
RARCH_INPUT_STATE_CLEAR_PTR( state );
if ( rpt->btn.r3 ) { if ( rpt->btn.r3 ) {
RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_R3 ); RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_R3 );
} }

View File

@ -126,6 +126,8 @@ static void hidpad_wiiupro_get_buttons(void *data, retro_bits_t *state)
if (!device || !rpt) if (!device || !rpt)
return; return;
RARCH_INPUT_STATE_CLEAR_PTR( state );
if ( rpt->btn.r3 ) { if ( rpt->btn.r3 ) {
RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_R3 ); RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_R3 );
} }

View File

@ -1,7 +1,7 @@
/* RetroArch - A frontend for libretro. /* RetroArch - A frontend for libretro.
* Copyright (C) 2011-2017 - Daniel De Matteis * Copyright (C) 2011-2017 - Daniel De Matteis
* Copyright (C) 2013-2014 - Jason Fetters * Copyright (C) 2013-2014 - Jason Fetters
* *
* RetroArch is free software: you can redistribute it and/or modify it under the terms * 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- * 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. * ation, either version 3 of the License, or (at your option) any later version.
@ -36,13 +36,13 @@ float get_backing_scale_factor(void);
int32_t cocoa_input_find_any_key(void) int32_t cocoa_input_find_any_key(void)
{ {
cocoa_input_data_t *apple = (cocoa_input_data_t*)input_driver_get_data(); cocoa_input_data_t *apple = (cocoa_input_data_t*)input_driver_get_data();
if (!apple) if (!apple)
return 0; return 0;
if (apple->joypad) if (apple->joypad)
apple->joypad->poll(); apple->joypad->poll();
if (apple->sec_joypad) if (apple->sec_joypad)
apple->sec_joypad->poll(); apple->sec_joypad->poll();
@ -50,13 +50,13 @@ int32_t cocoa_input_find_any_key(void)
} }
static int cocoa_input_find_any_button_ret(cocoa_input_data_t *apple, static int cocoa_input_find_any_button_ret(cocoa_input_data_t *apple,
unsigned buttons, unsigned port) retro_bits_t * state, unsigned port)
{ {
unsigned i; unsigned i;
if (buttons) if (state)
for (i = 0; i < 32; i++) for (i = 0; i < 256; i++)
if (buttons & (1 << i)) if (RARCH_INPUT_STATE_BIT_GET_PTR(state,i))
return i; return i;
return -1; return -1;
} }
@ -68,26 +68,32 @@ int32_t cocoa_input_find_any_button(uint32_t port)
if (!apple) if (!apple)
return -1; return -1;
if (apple->joypad) if (apple->joypad)
{ {
apple->joypad->poll(); apple->joypad->poll();
if (apple->joypad->get_buttons) if (apple->joypad->get_buttons)
ret = cocoa_input_find_any_button_ret(apple, (unsigned)apple->joypad->get_buttons(port), port); {
retro_bits_t state;
apple->joypad->get_buttons(port,&state);
ret = cocoa_input_find_any_button_ret(apple, &state, port);
}
} }
if (ret != -1) if (ret != -1)
return ret; return ret;
if (apple->sec_joypad) if (apple->sec_joypad)
{ {
apple->sec_joypad->poll(); apple->sec_joypad->poll();
if (apple->sec_joypad->get_buttons) if (apple->sec_joypad->get_buttons)
{ {
retro_bits_t state;
apple->sec_joypad->poll(); apple->sec_joypad->poll();
ret = cocoa_input_find_any_button_ret(apple, (unsigned)apple->sec_joypad->get_buttons(port), port); apple->sec_joypad->get_buttons(port,&state);
ret = cocoa_input_find_any_button_ret(apple, &state, port);
} }
} }
@ -101,17 +107,17 @@ int32_t cocoa_input_find_any_axis(uint32_t port)
{ {
int i; int i;
cocoa_input_data_t *apple = (cocoa_input_data_t*)input_driver_get_data(); cocoa_input_data_t *apple = (cocoa_input_data_t*)input_driver_get_data();
if (apple && apple->joypad) if (apple && apple->joypad)
apple->joypad->poll(); apple->joypad->poll();
if (apple && apple->sec_joypad) if (apple && apple->sec_joypad)
apple->sec_joypad->poll(); apple->sec_joypad->poll();
for (i = 0; i < 6; i++) for (i = 0; i < 6; i++)
{ {
int16_t value = apple->joypad ? apple->joypad->axis(port, i) : 0; int16_t value = apple->joypad ? apple->joypad->axis(port, i) : 0;
if (abs(value) > 0x4000) if (abs(value) > 0x4000)
return (value < 0) ? -(i + 1) : i + 1; return (value < 0) ? -(i + 1) : i + 1;
@ -130,15 +136,15 @@ static void *cocoa_input_init(const char *joypad_driver)
cocoa_input_data_t *apple = (cocoa_input_data_t*)calloc(1, sizeof(*apple)); cocoa_input_data_t *apple = (cocoa_input_data_t*)calloc(1, sizeof(*apple));
if (!apple) if (!apple)
return NULL; return NULL;
input_keymaps_init_keyboard_lut(rarch_key_map_apple_hid); input_keymaps_init_keyboard_lut(rarch_key_map_apple_hid);
apple->joypad = input_joypad_init_driver(joypad_driver, apple); apple->joypad = input_joypad_init_driver(joypad_driver, apple);
#ifdef HAVE_MFI #ifdef HAVE_MFI
apple->sec_joypad = input_joypad_init_driver("mfi", apple); apple->sec_joypad = input_joypad_init_driver("mfi", apple);
#endif #endif
return apple; return apple;
} }
@ -149,14 +155,14 @@ static void cocoa_input_poll(void *data)
#ifndef IOS #ifndef IOS
float backing_scale_factor = get_backing_scale_factor(); float backing_scale_factor = get_backing_scale_factor();
#endif #endif
if (!apple) if (!apple)
return; return;
for (i = 0; i < apple->touch_count; i++) for (i = 0; i < apple->touch_count; i++)
{ {
struct video_viewport vp; struct video_viewport vp;
vp.x = 0; vp.x = 0;
vp.y = 0; vp.y = 0;
vp.width = 0; vp.width = 0;
@ -249,13 +255,13 @@ static int16_t cocoa_pointer_state(cocoa_input_data_t *apple,
int16_t x, y; int16_t x, y;
const cocoa_touch_data_t *touch = (const cocoa_touch_data_t *) const cocoa_touch_data_t *touch = (const cocoa_touch_data_t *)
&apple->touches[idx]; &apple->touches[idx];
if (!touch) if (!touch)
return 0; return 0;
x = touch->fixed_x; x = touch->fixed_x;
y = touch->fixed_y; y = touch->fixed_y;
if (want_full) if (want_full)
{ {
x = touch->full_x; x = touch->full_x;
@ -328,16 +334,16 @@ static void cocoa_input_free(void *data)
{ {
unsigned i; unsigned i;
cocoa_input_data_t *apple = (cocoa_input_data_t*)data; cocoa_input_data_t *apple = (cocoa_input_data_t*)data;
if (!apple || !data) if (!apple || !data)
return; return;
if (apple->joypad) if (apple->joypad)
apple->joypad->destroy(); apple->joypad->destroy();
if (apple->sec_joypad) if (apple->sec_joypad)
apple->sec_joypad->destroy(); apple->sec_joypad->destroy();
for (i = 0; i < MAX_KEYS; i++) for (i = 0; i < MAX_KEYS; i++)
apple_key_state[i] = 0; apple_key_state[i] = 0;
@ -348,7 +354,7 @@ static bool cocoa_input_set_rumble(void *data,
unsigned port, enum retro_rumble_effect effect, uint16_t strength) unsigned port, enum retro_rumble_effect effect, uint16_t strength)
{ {
cocoa_input_data_t *apple = (cocoa_input_data_t*)data; cocoa_input_data_t *apple = (cocoa_input_data_t*)data;
if (apple && apple->joypad) if (apple && apple->joypad)
return input_joypad_set_rumble(apple->joypad, return input_joypad_set_rumble(apple->joypad,
port, effect, strength); port, effect, strength);
@ -364,7 +370,7 @@ static uint64_t cocoa_input_get_capabilities(void *data)
{ {
(void)data; (void)data;
return return
(1 << RETRO_DEVICE_JOYPAD) | (1 << RETRO_DEVICE_JOYPAD) |
(1 << RETRO_DEVICE_MOUSE) | (1 << RETRO_DEVICE_MOUSE) |
(1 << RETRO_DEVICE_KEYBOARD) | (1 << RETRO_DEVICE_KEYBOARD) |
@ -382,7 +388,7 @@ static void cocoa_input_grab_mouse(void *data, bool state)
static const input_device_driver_t *cocoa_input_get_sec_joypad_driver(void *data) static const input_device_driver_t *cocoa_input_get_sec_joypad_driver(void *data)
{ {
cocoa_input_data_t *apple = (cocoa_input_data_t*)data; cocoa_input_data_t *apple = (cocoa_input_data_t*)data;
if (apple && apple->sec_joypad) if (apple && apple->sec_joypad)
return apple->sec_joypad; return apple->sec_joypad;
return NULL; return NULL;
@ -391,7 +397,7 @@ static const input_device_driver_t *cocoa_input_get_sec_joypad_driver(void *data
static const input_device_driver_t *cocoa_input_get_joypad_driver(void *data) static const input_device_driver_t *cocoa_input_get_joypad_driver(void *data)
{ {
cocoa_input_data_t *apple = (cocoa_input_data_t*)data; cocoa_input_data_t *apple = (cocoa_input_data_t*)data;
if (apple && apple->joypad) if (apple && apple->joypad)
return apple->joypad; return apple->joypad;
return NULL; return NULL;

View File

@ -151,7 +151,7 @@ static bool iohidmanager_hid_joypad_button(void *data,
/* Check the button. */ /* Check the button. */
if ((port < MAX_USERS) && (joykey < 32)) if ((port < MAX_USERS) && (joykey < 32))
return (RARCH_INPUT_STATE_BIT_GET( buttons, joykey )) != 0) return (RARCH_INPUT_STATE_BIT_GET( buttons, joykey ) != 0)
|| ((hid->buttons[port] & (1 << joykey)) != 0); || ((hid->buttons[port] & (1 << joykey)) != 0);
return false; return false;