mirror of
https://github.com/libretro/RetroArch
synced 2025-03-01 16:13:40 +00:00
(iOS) Add disabled draft of SixAxis support.
This commit is contained in:
parent
95259d4b86
commit
e3b4cb9a2d
@ -44,9 +44,15 @@ static bool btstackOpen;
|
||||
static bool btOK;
|
||||
|
||||
static BTDevice* discoveredDevice;
|
||||
static bd_addr_t address;
|
||||
static uint32_t handle[2];
|
||||
static uint32_t remote_cid[2];
|
||||
static uint32_t local_cid[2];
|
||||
uint8_t psdata_buffer[512];
|
||||
|
||||
void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size)
|
||||
{
|
||||
#if 1 // WiiMote
|
||||
bd_addr_t event_addr;
|
||||
|
||||
switch (packet_type)
|
||||
@ -232,10 +238,72 @@ void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint
|
||||
break;
|
||||
}
|
||||
}
|
||||
#else // SixAxis
|
||||
switch (packet_type)
|
||||
{
|
||||
// Connection
|
||||
case HCI_EVENT_PACKET:
|
||||
{
|
||||
switch (packet[0])
|
||||
{
|
||||
// Bluetooth is active, search for remote
|
||||
case BTSTACK_EVENT_STATE:
|
||||
{
|
||||
if (packet[2] == HCI_STATE_WORKING)
|
||||
bt_send_cmd_ptr(l2cap_register_service_ptr, 0x11, 672);
|
||||
break;
|
||||
}
|
||||
|
||||
case L2CAP_EVENT_SERVICE_REGISTERED:
|
||||
{
|
||||
if (READ_BT_16(packet, 3) == 0x11)
|
||||
bt_send_cmd_ptr(l2cap_register_service_ptr, 0x13, 672);
|
||||
break;
|
||||
}
|
||||
|
||||
case L2CAP_EVENT_INCOMING_CONNECTION:
|
||||
{
|
||||
const uint32_t psm = READ_BT_16(packet, 10);
|
||||
const bool second = (psm == 0x11) ? 0 : 1;
|
||||
|
||||
handle[second] = READ_BT_16(packet, 8);
|
||||
local_cid[second] = READ_BT_16(packet, 12);
|
||||
remote_cid[second] = READ_BT_16(packet, 14);
|
||||
|
||||
bt_flip_addr_ptr(address, &packet[2]);
|
||||
bt_send_cmd_ptr(l2cap_accept_connection_ptr, local_cid[second]);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case L2CAP_EVENT_CHANNEL_OPENED:
|
||||
{
|
||||
if (READ_BT_16(packet, 11) == PSM_HID_INTERRUPT)
|
||||
{
|
||||
uint8_t data[] = {0x53, 0xF4, 0x42, 0x03, 0x00, 0x00};
|
||||
bt_send_l2cap_ptr(local_cid[0], data, 6);
|
||||
set_ps3_data(0);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case L2CAP_DATA_PACKET:
|
||||
{
|
||||
if (packet[0] == 0xA1)
|
||||
memcpy(psdata_buffer, packet, size);
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
@implementation WiiMoteHelper
|
||||
+ (BOOL)haveBluetooth
|
||||
{
|
||||
|
@ -47,6 +47,8 @@ static struct
|
||||
GRAB(hci_write_authentication_enable),
|
||||
GRAB(hci_write_inquiry_mode),
|
||||
GRAB(l2cap_create_channel),
|
||||
GRAB(l2cap_register_service),
|
||||
GRAB(l2cap_accept_connection),
|
||||
{0, 0}
|
||||
};
|
||||
|
||||
|
@ -46,5 +46,7 @@ BTDIMPORT const hci_cmd_t* hci_remote_name_request_cancel_ptr;
|
||||
BTDIMPORT const hci_cmd_t* hci_write_authentication_enable_ptr;
|
||||
BTDIMPORT const hci_cmd_t* hci_write_inquiry_mode_ptr;
|
||||
BTDIMPORT const hci_cmd_t* l2cap_create_channel_ptr;
|
||||
BTDIMPORT const hci_cmd_t* l2cap_register_service_ptr;
|
||||
BTDIMPORT const hci_cmd_t* l2cap_accept_connection_ptr;
|
||||
|
||||
#endif
|
||||
|
@ -61,6 +61,11 @@ static void ios_joypad_poll(void)
|
||||
g_buttons[i] |= (joys[i].exp.type == EXP_CLASSIC) ? (joys[i].exp.classic.btns << 16) : 0;
|
||||
}
|
||||
}
|
||||
|
||||
// HACK: SixAxis
|
||||
extern uint8_t psdata_buffer[512];
|
||||
if (myosd_num_of_joys == 0)
|
||||
g_buttons[0] = psdata_buffer[3] | (psdata_buffer[4] << 8);
|
||||
}
|
||||
|
||||
const rarch_joypad_driver_t ios_joypad = {
|
||||
|
@ -151,6 +151,19 @@ static const struct
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// SixAxis
|
||||
extern uint8_t psdata_buffer[512];
|
||||
uint32_t buttons = psdata_buffer[3] | (psdata_buffer[4] << 8);
|
||||
for (int i = 0; i != 32; i ++)
|
||||
{
|
||||
if (buttons & (1 << i))
|
||||
{
|
||||
_value.msubValues[1] = [NSString stringWithFormat:@"%d", i];
|
||||
[self finish];
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
Loading…
x
Reference in New Issue
Block a user