mirror of
https://github.com/libretro/RetroArch
synced 2025-04-16 08:43:10 +00:00
(iOS, BTstack) Some cleanup. No more ObjC in the input code.
This commit is contained in:
parent
003c3c1476
commit
d83d941669
@ -246,6 +246,7 @@ INPUT
|
||||
#include "../ios/RetroArch/input/ios_joypad.c"
|
||||
#include "../ios/RetroArch/input/BTStack/btdynamic.c"
|
||||
#include "../ios/RetroArch/input/BTStack/wiimote.c"
|
||||
#include "../ios/RetroArch/input/BTStack/btpad.c"
|
||||
#elif defined(__BLACKBERRY_QNX__)
|
||||
#include "../playbook/qnx_input.c"
|
||||
#endif
|
||||
|
@ -20,8 +20,6 @@
|
||||
963F5AC216CC522F009BBD19 /* RASettingsSubList.m in Sources */ = {isa = PBXBuildFile; fileRef = 963F5ABE16CC522F009BBD19 /* RASettingsSubList.m */; };
|
||||
963F5AC316CC522F009BBD19 /* RASettingsList.m in Sources */ = {isa = PBXBuildFile; fileRef = 963F5ABF16CC522F009BBD19 /* RASettingsList.m */; };
|
||||
963F5AC816CC523B009BBD19 /* RAGameView.m in Sources */ = {isa = PBXBuildFile; fileRef = 963F5AC516CC523B009BBD19 /* RAGameView.m */; };
|
||||
966B9CA216E418B7005B61E1 /* BTDevice.m in Sources */ = {isa = PBXBuildFile; fileRef = 966B9C9116E418B7005B61E1 /* BTDevice.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
|
||||
966B9CA716E418B7005B61E1 /* WiiMoteHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 966B9CA116E418B7005B61E1 /* WiiMoteHelper.m */; };
|
||||
966B9CAE16E41C07005B61E1 /* browser.m in Sources */ = {isa = PBXBuildFile; fileRef = 966B9CAA16E41C07005B61E1 /* browser.m */; };
|
||||
966B9CB016E41C07005B61E1 /* RADirectoryGrid.m in Sources */ = {isa = PBXBuildFile; fileRef = 966B9CAB16E41C07005B61E1 /* RADirectoryGrid.m */; };
|
||||
966B9CB216E41C07005B61E1 /* RADirectoryList.m in Sources */ = {isa = PBXBuildFile; fileRef = 966B9CAC16E41C07005B61E1 /* RADirectoryList.m */; };
|
||||
@ -62,15 +60,13 @@
|
||||
963F5ABE16CC522F009BBD19 /* RASettingsSubList.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RASettingsSubList.m; sourceTree = "<group>"; };
|
||||
963F5ABF16CC522F009BBD19 /* RASettingsList.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RASettingsList.m; sourceTree = "<group>"; };
|
||||
963F5AC516CC523B009BBD19 /* RAGameView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RAGameView.m; sourceTree = "<group>"; };
|
||||
966B9C9016E418B7005B61E1 /* BTDevice.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BTDevice.h; sourceTree = "<group>"; };
|
||||
966B9C9116E418B7005B61E1 /* BTDevice.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BTDevice.m; sourceTree = "<group>"; };
|
||||
966B9C9516E418B7005B61E1 /* btstack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btstack.h; sourceTree = "<group>"; };
|
||||
966B9C9616E418B7005B61E1 /* hci_cmds.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = hci_cmds.h; sourceTree = "<group>"; };
|
||||
966B9C9716E418B7005B61E1 /* linked_list.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = linked_list.h; sourceTree = "<group>"; };
|
||||
966B9C9816E418B7005B61E1 /* run_loop.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = run_loop.h; sourceTree = "<group>"; };
|
||||
966B9C9916E418B7005B61E1 /* sdp_util.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sdp_util.h; sourceTree = "<group>"; };
|
||||
966B9C9A16E418B7005B61E1 /* utils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = utils.h; sourceTree = "<group>"; };
|
||||
966B9CA116E418B7005B61E1 /* WiiMoteHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WiiMoteHelper.m; sourceTree = "<group>"; };
|
||||
966B9CA116E418B7005B61E1 /* btpad.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = btpad.c; sourceTree = "<group>"; };
|
||||
966B9CA916E41C07005B61E1 /* browser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = browser.h; sourceTree = "<group>"; };
|
||||
966B9CAA16E41C07005B61E1 /* browser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = browser.m; sourceTree = "<group>"; };
|
||||
966B9CAB16E41C07005B61E1 /* RADirectoryGrid.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RADirectoryGrid.m; sourceTree = "<group>"; };
|
||||
@ -101,6 +97,13 @@
|
||||
96C19C2616D455BE00FE8D5A /* rarch_wrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = rarch_wrapper.h; sourceTree = "<group>"; };
|
||||
96F9C27516FF5E97002455B3 /* btdynamic.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = btdynamic.c; sourceTree = "<group>"; };
|
||||
96F9C27616FF5E97002455B3 /* btdynamic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btdynamic.h; sourceTree = "<group>"; };
|
||||
96F9C27816FF6511002455B3 /* wiimote.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = wiimote.c; sourceTree = "<group>"; };
|
||||
96F9C27916FF6511002455B3 /* wiimote.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = wiimote.h; sourceTree = "<group>"; };
|
||||
96F9C27B16FF66BC002455B3 /* btpad.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btpad.h; sourceTree = "<group>"; };
|
||||
96F9C27C16FF6892002455B3 /* ios_joypad.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ios_joypad.c; sourceTree = "<group>"; };
|
||||
96F9C27D16FF6892002455B3 /* ios_input.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ios_input.h; sourceTree = "<group>"; };
|
||||
96F9C27E16FF6892002455B3 /* ios_input.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ios_input.c; sourceTree = "<group>"; };
|
||||
96F9C27F16FF6892002455B3 /* keycode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = keycode.h; sourceTree = "<group>"; };
|
||||
D48581DD16F823F9004BEB17 /* griffin.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = griffin.c; path = ../griffin/griffin.c; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
@ -138,6 +141,10 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
966B9C8F16E418B7005B61E1 /* BTStack */,
|
||||
96F9C27C16FF6892002455B3 /* ios_joypad.c */,
|
||||
96F9C27D16FF6892002455B3 /* ios_input.h */,
|
||||
96F9C27E16FF6892002455B3 /* ios_input.c */,
|
||||
96F9C27F16FF6892002455B3 /* keycode.h */,
|
||||
);
|
||||
path = input;
|
||||
sourceTree = "<group>";
|
||||
@ -145,12 +152,13 @@
|
||||
966B9C8F16E418B7005B61E1 /* BTStack */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
966B9C9416E418B7005B61E1 /* btstack */,
|
||||
966B9CA116E418B7005B61E1 /* btpad.c */,
|
||||
96F9C27B16FF66BC002455B3 /* btpad.h */,
|
||||
96F9C27516FF5E97002455B3 /* btdynamic.c */,
|
||||
96F9C27616FF5E97002455B3 /* btdynamic.h */,
|
||||
966B9C9016E418B7005B61E1 /* BTDevice.h */,
|
||||
966B9C9116E418B7005B61E1 /* BTDevice.m */,
|
||||
966B9C9416E418B7005B61E1 /* btstack */,
|
||||
966B9CA116E418B7005B61E1 /* WiiMoteHelper.m */,
|
||||
96F9C27816FF6511002455B3 /* wiimote.c */,
|
||||
96F9C27916FF6511002455B3 /* wiimote.h */,
|
||||
);
|
||||
path = BTStack;
|
||||
sourceTree = "<group>";
|
||||
@ -390,8 +398,6 @@
|
||||
963F5AC316CC522F009BBD19 /* RASettingsList.m in Sources */,
|
||||
963F5AC816CC523B009BBD19 /* RAGameView.m in Sources */,
|
||||
96096DD816D1ABAF00BF4499 /* RAModuleInfoList.m in Sources */,
|
||||
966B9CA216E418B7005B61E1 /* BTDevice.m in Sources */,
|
||||
966B9CA716E418B7005B61E1 /* WiiMoteHelper.m in Sources */,
|
||||
966B9CAE16E41C07005B61E1 /* browser.m in Sources */,
|
||||
966B9CB016E41C07005B61E1 /* RADirectoryGrid.m in Sources */,
|
||||
966B9CB216E41C07005B61E1 /* RADirectoryList.m in Sources */,
|
||||
|
@ -1,92 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2009 by Matthias Ringwald
|
||||
*
|
||||
* 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.
|
||||
* 3. Neither the name of the copyright holders nor the names of
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY MATTHIAS RINGWALD 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 MATTHIAS
|
||||
* RINGWALD 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.
|
||||
*
|
||||
*/
|
||||
|
||||
//
|
||||
// BTDevice.h
|
||||
//
|
||||
// Created by Matthias Ringwald on 3/30/09.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#include "btstack/utils.h"
|
||||
|
||||
#define kCODHID 0x2540
|
||||
#define kCODZeeMote 0x584
|
||||
#define kCODInvalid 0xffff
|
||||
|
||||
typedef enum {
|
||||
kBluetoothDeviceTypeGeneric = 0,
|
||||
kBluetoothDeviceTypeHID,
|
||||
kBluetoothDeviceTypeMobilePhone,
|
||||
kBluetoothDeviceTypeSmartPhone,
|
||||
kBluetoothDeviceTypeZeeMote,
|
||||
} BluetoothDeviceType;
|
||||
|
||||
typedef enum {
|
||||
kBluetoothConnectionNotConnected = 0,
|
||||
kBluetoothConnectionRemoteName,
|
||||
kBluetoothConnectionConnecting,
|
||||
kBluetoothConnectionConnected
|
||||
} BluetoothConnectionState;
|
||||
|
||||
@interface BTDevice : NSObject {
|
||||
|
||||
bd_addr_t _address;
|
||||
|
||||
NSString * name;
|
||||
uint32_t classOfDevice;
|
||||
|
||||
uint8_t pageScanRepetitionMode;
|
||||
uint16_t clockOffset;
|
||||
|
||||
uint8_t rssi;
|
||||
|
||||
// deprecated
|
||||
BluetoothConnectionState connectionState;
|
||||
}
|
||||
|
||||
- (void) setAddress:(bd_addr_t*)addr;
|
||||
- (BOOL) setAddressFromString:(NSString *) addressString;
|
||||
- (bd_addr_t*) address;
|
||||
- (NSString *) toString;
|
||||
- (NSString *) addressString;
|
||||
+ (NSString *) stringForAddress:(bd_addr_t*) address;
|
||||
+ (BOOL) address:(bd_addr_t *) address fromString:(NSString *) addressString;
|
||||
@property (readonly) BluetoothDeviceType deviceType;
|
||||
@property (readonly) NSString * nameOrAddress;
|
||||
@property (nonatomic, copy) NSString * name;
|
||||
@property (nonatomic, assign) uint32_t classOfDevice;
|
||||
@property (nonatomic, assign) uint16_t clockOffset;
|
||||
@property (nonatomic, assign) uint8_t pageScanRepetitionMode;
|
||||
@property (nonatomic, assign) uint8_t rssi;
|
||||
@property (nonatomic, assign) BluetoothConnectionState connectionState;
|
||||
|
||||
@end
|
@ -1,129 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2009 by Matthias Ringwald
|
||||
*
|
||||
* 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.
|
||||
* 3. Neither the name of the copyright holders nor the names of
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY MATTHIAS RINGWALD 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 MATTHIAS
|
||||
* RINGWALD 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.
|
||||
*
|
||||
*/
|
||||
|
||||
//
|
||||
// BTDevice.m
|
||||
//
|
||||
// Created by Matthias Ringwald on 3/30/09.
|
||||
//
|
||||
|
||||
#import "BTDevice.h"
|
||||
|
||||
@implementation BTDevice
|
||||
|
||||
@synthesize name;
|
||||
@synthesize classOfDevice;
|
||||
@synthesize connectionState;
|
||||
@synthesize pageScanRepetitionMode;
|
||||
@synthesize clockOffset;
|
||||
@synthesize rssi;
|
||||
|
||||
- (BTDevice *)init {
|
||||
name = NULL;
|
||||
memset(&_address, 0, 6);
|
||||
classOfDevice = kCODInvalid;
|
||||
connectionState = kBluetoothConnectionNotConnected;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) setAddress:(bd_addr_t*)newAddr{
|
||||
BD_ADDR_COPY( &_address, newAddr);
|
||||
}
|
||||
|
||||
- (BOOL) setAddressFromString:(NSString *) addressString{
|
||||
return [BTDevice address:&_address fromString:addressString];
|
||||
}
|
||||
|
||||
- (bd_addr_t*) address{
|
||||
return &_address;
|
||||
}
|
||||
|
||||
+ (NSString *) stringForAddress:(bd_addr_t*) address {
|
||||
uint8_t *addr = (uint8_t*) *address;
|
||||
return [NSString stringWithFormat:@"%02x:%02x:%02x:%02x:%02x:%02x", addr[0], addr[1], addr[2],
|
||||
addr[3], addr[4], addr[5]];
|
||||
}
|
||||
|
||||
+ (BOOL) address:(bd_addr_t *)address fromString:(NSString *) addressString{
|
||||
// support both : and - or NOTHING as separator
|
||||
addressString = [addressString stringByReplacingOccurrencesOfString:@":" withString:@""];
|
||||
addressString = [addressString stringByReplacingOccurrencesOfString:@"-" withString:@""];
|
||||
if ([addressString length] != 12) return NO;
|
||||
|
||||
unsigned int bd_addr_buffer[BD_ADDR_LEN]; //for sscanf, integer needed
|
||||
// reset result buffer
|
||||
int i;
|
||||
for (i = 0; i < BD_ADDR_LEN; i++) {
|
||||
bd_addr_buffer[i] = 0;
|
||||
}
|
||||
|
||||
// parse
|
||||
int result = sscanf([addressString UTF8String], "%2x%2x%2x%2x%2x%2x", &bd_addr_buffer[0], &bd_addr_buffer[1], &bd_addr_buffer[2],
|
||||
&bd_addr_buffer[3], &bd_addr_buffer[4], &bd_addr_buffer[5]);
|
||||
// store
|
||||
if (result == 6){
|
||||
for (i = 0; i < BD_ADDR_LEN; i++) {
|
||||
(*address)[i] = (uint8_t) bd_addr_buffer[i];
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (NSString *) nameOrAddress{
|
||||
if (name) return name;
|
||||
return [self addressString];
|
||||
}
|
||||
|
||||
- (NSString *) addressString{
|
||||
return [BTDevice stringForAddress:&_address];
|
||||
}
|
||||
|
||||
- (BluetoothDeviceType) deviceType{
|
||||
switch (classOfDevice) {
|
||||
case kCODHID:
|
||||
return kBluetoothDeviceTypeHID;
|
||||
case kCODZeeMote:
|
||||
return kBluetoothDeviceTypeZeeMote;
|
||||
default:
|
||||
return kBluetoothDeviceTypeGeneric;
|
||||
}
|
||||
}
|
||||
- (NSString *) toString{
|
||||
return [NSString stringWithFormat:@"Device addr %@ name %@ COD %x", [BTDevice stringForAddress:&_address], name, classOfDevice];
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
[name release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
@end
|
@ -16,6 +16,7 @@
|
||||
#ifndef __IOS_RARCH_BTDYNAMIC_H__
|
||||
#define __IOS_RARCH_BTDYNAMIC_H__
|
||||
|
||||
#include "boolean.h"
|
||||
#include "btstack/utils.h"
|
||||
#include "btstack/btstack.h"
|
||||
|
||||
|
@ -31,19 +31,50 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "btdynamic.h"
|
||||
#include "btpad.h"
|
||||
#include "wiimote.h"
|
||||
|
||||
#import "BTDevice.h"
|
||||
static enum btpad_device_type_t device_type;
|
||||
static bd_addr_t device_address;
|
||||
static char device_name[256];
|
||||
|
||||
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];
|
||||
// Connection data
|
||||
static uint32_t device_handle[2];
|
||||
static uint32_t device_remote_cid[2];
|
||||
static uint32_t device_local_cid[2];
|
||||
|
||||
// Inquiry data
|
||||
static uint32_t device_page_scan_repetition_mode;
|
||||
static uint32_t device_class;
|
||||
static uint32_t device_clock_offset;
|
||||
|
||||
// Buffers
|
||||
static struct wiimote_t wiimote_buffer;
|
||||
static uint8_t psdata_buffer[512];
|
||||
|
||||
// MAIN THREAD ONLY
|
||||
enum btpad_device_type_t btpad_get_connected_type()
|
||||
{
|
||||
return device_type;
|
||||
}
|
||||
|
||||
uint32_t btpad_get_buttons()
|
||||
{
|
||||
switch (device_type)
|
||||
{
|
||||
case BTPAD_WIIMOTE:
|
||||
return wiimote_buffer.btns | (wiimote_buffer.exp.classic.btns << 16);
|
||||
case BTPAD_PS3:
|
||||
return psdata_buffer[3] | (psdata_buffer[4] << 8);
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// BT THREAD ONLY
|
||||
static void set_ps3_data(unsigned leds)
|
||||
{
|
||||
// TODO: LEDS
|
||||
@ -60,10 +91,9 @@ static void set_ps3_data(unsigned leds)
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
bt_send_l2cap_ptr(local_cid[0], report_buffer, sizeof(report_buffer));
|
||||
bt_send_l2cap_ptr(device_local_cid[0], report_buffer, sizeof(report_buffer));
|
||||
}
|
||||
|
||||
|
||||
void btstack_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size)
|
||||
{
|
||||
#if 1 // WiiMote
|
||||
@ -81,40 +111,36 @@ void btstack_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *pack
|
||||
{
|
||||
if (packet[2] == HCI_STATE_WORKING)
|
||||
bt_send_cmd_ptr(hci_inquiry_ptr, HCI_INQUIRY_LAP, 3, 0);
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
// Identifies devices found during inquiry, does not signal the end of the inquiry.
|
||||
case HCI_EVENT_INQUIRY_RESULT:
|
||||
case HCI_EVENT_INQUIRY_RESULT:
|
||||
{
|
||||
for (int i = 0; i != packet[2]; i ++)
|
||||
for (int i = 0; i != packet[2]; i ++)
|
||||
{
|
||||
if (!discoveredDevice)
|
||||
if (device_type == BTPAD_NONE)
|
||||
{
|
||||
bt_flip_addr_ptr(event_addr, &packet[3 + i * 6]);
|
||||
discoveredDevice = [[BTDevice alloc] init];
|
||||
[discoveredDevice setAddress:&event_addr];
|
||||
}
|
||||
bt_flip_addr_ptr(device_address, &packet[3 + i * 6]);
|
||||
|
||||
// update
|
||||
discoveredDevice.pageScanRepetitionMode = packet [3 + packet[2] * (6) + i*1];
|
||||
discoveredDevice.classOfDevice = READ_BT_24(packet, 3 + packet[2] * (6+1+1+1) + i*3);
|
||||
discoveredDevice.clockOffset = READ_BT_16(packet, 3 + packet[2] * (6+1+1+1+3) + i*2) & 0x7fff;
|
||||
discoveredDevice.rssi = 0;
|
||||
}
|
||||
device_page_scan_repetition_mode = packet [3 + packet[2] * (6) + i*1];
|
||||
device_class = READ_BT_24(packet, 3 + packet[2] * (6+1+1+1) + i*3);
|
||||
device_clock_offset = READ_BT_16(packet, 3 + packet[2] * (6+1+1+1+3) + i*2) & 0x7fff;
|
||||
|
||||
device_type = BTPAD_PENDING;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
// The inquiry has ended
|
||||
case HCI_EVENT_INQUIRY_COMPLETE:
|
||||
{
|
||||
// If we a device, ask for its name
|
||||
if (discoveredDevice)
|
||||
bt_send_cmd_ptr(hci_remote_name_request_ptr, [discoveredDevice address], discoveredDevice.pageScanRepetitionMode,
|
||||
0, discoveredDevice.clockOffset | 0x8000);
|
||||
// Keep looking
|
||||
else
|
||||
if (device_type == BTPAD_PENDING)
|
||||
bt_send_cmd_ptr(hci_remote_name_request_ptr, device_address, device_page_scan_repetition_mode,
|
||||
0, device_clock_offset | 0x8000);
|
||||
else if(device_type == BTPAD_NONE)
|
||||
bt_send_cmd_ptr(hci_inquiry_ptr, HCI_INQUIRY_LAP, 3, 0);
|
||||
|
||||
break;
|
||||
@ -125,18 +151,16 @@ void btstack_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *pack
|
||||
{
|
||||
bt_flip_addr_ptr(event_addr, &packet[3]);
|
||||
|
||||
if (discoveredDevice && BD_ADDR_CMP(event_addr, discoveredDevice.address) == 0)
|
||||
if (device_type == BTPAD_PENDING && BD_ADDR_CMP(event_addr, device_address) == 0)
|
||||
{
|
||||
char cname[249];
|
||||
strncpy(cname, (const char*)&packet[9], 248);
|
||||
cname[248] = 0;
|
||||
strncpy(device_name, (const char*)&packet[9], 248);
|
||||
device_name[248] = 0;
|
||||
|
||||
NSString* name = [NSString stringWithUTF8String:cname];
|
||||
[discoveredDevice setName:name];
|
||||
|
||||
// We found a WiiMote, pair with it
|
||||
if ([name hasPrefix:@"Nintendo RVL-CNT-01"])
|
||||
bt_send_cmd_ptr(l2cap_create_channel_ptr, [discoveredDevice address], PSM_HID_INTERRUPT);
|
||||
if (strncmp(device_name, "Nintendo RVL-CNT-01", 19) == 0)
|
||||
{
|
||||
device_type = BTPAD_WIIMOTE;
|
||||
bt_send_cmd_ptr(l2cap_create_channel_ptr, device_address, PSM_HID_CONTROL);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
@ -147,47 +171,41 @@ void btstack_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *pack
|
||||
{
|
||||
bt_flip_addr_ptr(event_addr, &packet[2]);
|
||||
|
||||
if (discoveredDevice && BD_ADDR_CMP(event_addr, discoveredDevice.address) == 0)
|
||||
{
|
||||
// WiiMote: Use inverse bd_addr as PIN
|
||||
if (discoveredDevice.name && [discoveredDevice.name hasPrefix:@"Nintendo RVL-CNT-01"])
|
||||
bt_send_cmd_ptr(hci_pin_code_request_reply_ptr, event_addr, 6, &packet[2]);
|
||||
}
|
||||
if (device_type == BTPAD_WIIMOTE && BD_ADDR_CMP(event_addr, device_address) == 0)
|
||||
bt_send_cmd_ptr(hci_pin_code_request_reply_ptr, device_address, 6, &packet[2]);
|
||||
break;
|
||||
}
|
||||
|
||||
// WiiMote connections
|
||||
case L2CAP_EVENT_CHANNEL_OPENED:
|
||||
{
|
||||
// data: event (8), len(8), status (8), address(48), handle (16), psm (16), local_cid(16), remote_cid (16)
|
||||
if (packet[2] == 0)
|
||||
bt_flip_addr_ptr(event_addr, &packet[3]);
|
||||
|
||||
if (packet[2] == 0 && device_type > BTPAD_PENDING && BD_ADDR_CMP(event_addr, device_address) == 0)
|
||||
{
|
||||
// inform about new l2cap connection
|
||||
bt_flip_addr_ptr(event_addr, &packet[3]);
|
||||
uint16_t psm = READ_BT_16(packet, 11);
|
||||
uint16_t source_cid = READ_BT_16(packet, 13);
|
||||
uint16_t wiiMoteConHandle = READ_BT_16(packet, 9);
|
||||
const uint16_t psm = READ_BT_16(packet, 11);
|
||||
const unsigned interrupt = (psm == PSM_HID_INTERRUPT) ? 1 : 0;
|
||||
|
||||
device_local_cid[interrupt] = READ_BT_16(packet, 13);
|
||||
device_remote_cid[interrupt] = READ_BT_16(packet, 15);
|
||||
device_handle[interrupt] = READ_BT_16(packet, 9);
|
||||
|
||||
if (psm == 0x13)
|
||||
if (device_type == BTPAD_WIIMOTE && psm == PSM_HID_CONTROL)
|
||||
{
|
||||
// interupt channel openedn succesfully, now open control channel, too.
|
||||
bt_send_cmd_ptr(l2cap_create_channel_ptr, event_addr, 0x11);
|
||||
struct wiimote_t *wm = &joys[myosd_num_of_joys];
|
||||
memset(wm, 0, sizeof(struct wiimote_t));
|
||||
wm->unid = myosd_num_of_joys;
|
||||
wm->i_source_cid = source_cid;
|
||||
memcpy(&wm->addr,&event_addr,BD_ADDR_LEN);
|
||||
wm->exp.type = EXP_NONE;
|
||||
bt_send_cmd_ptr(l2cap_create_channel_ptr, device_address, PSM_HID_INTERRUPT);
|
||||
|
||||
memset(&wiimote_buffer, 0, sizeof(struct wiimote_t));
|
||||
wiimote_buffer.unid = 0;
|
||||
wiimote_buffer.c_source_cid = device_local_cid[0];
|
||||
wiimote_buffer.exp.type = EXP_NONE;
|
||||
wiimote_buffer.wiiMoteConHandle = device_handle[0];
|
||||
memcpy(&wiimote_buffer.addr, &device_address, BD_ADDR_LEN);
|
||||
}
|
||||
else
|
||||
else if (device_type == BTPAD_WIIMOTE && psm == PSM_HID_INTERRUPT)
|
||||
{
|
||||
//inicializamos el wiimote!
|
||||
struct wiimote_t *wm = &joys[myosd_num_of_joys];
|
||||
wm->wiiMoteConHandle = wiiMoteConHandle;
|
||||
wm->c_source_cid = source_cid;
|
||||
wm->state = WIIMOTE_STATE_CONNECTED;
|
||||
myosd_num_of_joys++;
|
||||
wiimote_handshake(wm,-1,NULL,-1);
|
||||
wiimote_buffer.i_source_cid = device_local_cid[1];
|
||||
wiimote_buffer.state = WIIMOTE_STATE_CONNECTED;
|
||||
wiimote_handshake(&wiimote_buffer, -1, NULL, -1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -196,11 +214,7 @@ void btstack_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *pack
|
||||
|
||||
case L2CAP_EVENT_CHANNEL_CLOSED:
|
||||
{
|
||||
// data: event (8), len(8), channel (16)
|
||||
uint16_t source_cid = READ_BT_16(packet, 2);
|
||||
|
||||
bd_addr_t addr;
|
||||
wiimote_remove(source_cid, &addr);
|
||||
device_type = BTPAD_NONE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -209,8 +223,7 @@ void btstack_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *pack
|
||||
// WiiMote handling
|
||||
case L2CAP_DATA_PACKET:
|
||||
{
|
||||
struct wiimote_t *wm = wiimote_get_by_source_cid(channel);
|
||||
if (wm)
|
||||
if (device_type == BTPAD_WIIMOTE)
|
||||
{
|
||||
byte* msg = packet + 2;
|
||||
|
||||
@ -218,33 +231,33 @@ void btstack_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *pack
|
||||
{
|
||||
case WM_RPT_BTN:
|
||||
{
|
||||
wiimote_pressed_buttons(wm, msg);
|
||||
wiimote_pressed_buttons(&wiimote_buffer, msg);
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_RPT_READ:
|
||||
{
|
||||
wiimote_pressed_buttons(wm, msg);
|
||||
wiimote_pressed_buttons(&wiimote_buffer, msg);
|
||||
|
||||
byte len = ((msg[2] & 0xF0) >> 4) + 1;
|
||||
byte *data = (msg + 5);
|
||||
|
||||
wiimote_handshake(wm, WM_RPT_READ, data, len);
|
||||
|
||||
wiimote_handshake(&wiimote_buffer, WM_RPT_READ, data, len);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
case WM_RPT_CTRL_STATUS:
|
||||
{
|
||||
wiimote_pressed_buttons(wm, msg);
|
||||
wiimote_handshake(wm,WM_RPT_CTRL_STATUS,msg,-1);
|
||||
wiimote_pressed_buttons(&wiimote_buffer, msg);
|
||||
wiimote_handshake(&wiimote_buffer,WM_RPT_CTRL_STATUS,msg,-1);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
case WM_RPT_BTN_EXP:
|
||||
{
|
||||
wiimote_pressed_buttons(wm, msg);
|
||||
wiimote_handle_expansion(wm, msg+2);
|
||||
wiimote_pressed_buttons(&wiimote_buffer, msg);
|
||||
wiimote_handle_expansion(&wiimote_buffer, msg+2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -265,7 +278,7 @@ void btstack_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *pack
|
||||
{
|
||||
if (packet[2] == HCI_STATE_WORKING)
|
||||
bt_send_cmd_ptr(l2cap_register_service_ptr, 0x11, 672);
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
case L2CAP_EVENT_SERVICE_REGISTERED:
|
24
ios/RetroArch/input/BTStack/btpad.h
Normal file
24
ios/RetroArch/input/BTStack/btpad.h
Normal file
@ -0,0 +1,24 @@
|
||||
/* 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/>.
|
||||
*/
|
||||
|
||||
#ifndef __IOS_RARCH_BTPAD_H__
|
||||
#define __IOS_RARCH_BTPAD_H__
|
||||
|
||||
enum btpad_device_type_t { BTPAD_NONE, BTPAD_PENDING, BTPAD_WIIMOTE, BTPAD_PS3 };
|
||||
|
||||
enum btpad_device_type_t btpad_get_connected_type();
|
||||
uint32_t btpad_get_buttons();
|
||||
|
||||
#endif
|
@ -49,12 +49,6 @@
|
||||
#include "btstack/btstack.h"
|
||||
#include "wiimote.h"
|
||||
|
||||
int myosd_num_of_joys = 0;
|
||||
struct wiimote_t joys[4];
|
||||
extern int g_pref_wii_DZ_value;
|
||||
#define STICK4WAY (myosd_waysStick == 4 && myosd_inGame)
|
||||
#define STICK2WAY (myosd_waysStick == 2 && myosd_inGame)
|
||||
|
||||
int wiimote_send(struct wiimote_t* wm, byte report_type, byte* msg, int len);
|
||||
int wiimote_read_data(struct wiimote_t* wm, unsigned int addr, unsigned short len);
|
||||
int wiimote_write_data(struct wiimote_t* wm, unsigned int addr, byte* data, byte len);
|
||||
@ -62,77 +56,6 @@ void wiimote_set_leds(struct wiimote_t* wm, int leds);
|
||||
int classic_ctrl_handshake(struct wiimote_t* wm, struct classic_ctrl_t* cc, byte* data, unsigned short len);
|
||||
void classic_ctrl_event(struct classic_ctrl_t* cc, byte* msg);
|
||||
|
||||
int wiimote_remove(uint16_t source_cid, bd_addr_t *addr){
|
||||
|
||||
int i = 0;
|
||||
int unid = -1;
|
||||
int found = 0;
|
||||
for(;i<myosd_num_of_joys;i++)
|
||||
{
|
||||
if(joys[i].c_source_cid==source_cid && !found)
|
||||
{
|
||||
found=1;
|
||||
struct wiimote_t *wm = NULL;
|
||||
wm = &joys[i];
|
||||
#ifdef WIIMOTE_DBG
|
||||
printf("%02x:%02x:%02x:%02x:%02x:%02x\n",wm->addr[0], wm->addr[1], wm->addr[2],wm->addr[3], wm->addr[4], wm->addr[5]);
|
||||
#endif
|
||||
memcpy(addr,&(wm->addr),BD_ADDR_LEN);
|
||||
unid = wm->unid;
|
||||
continue;
|
||||
}
|
||||
if(found)
|
||||
{
|
||||
memcpy(&joys[i-1],&joys[i],sizeof(struct wiimote_t ));
|
||||
joys[i-1].unid = i-1;
|
||||
struct wiimote_t *wm = NULL;
|
||||
wm = &joys[i-1];
|
||||
if(wm->unid==0)
|
||||
wiimote_set_leds(wm, WIIMOTE_LED_1);
|
||||
else if(wm->unid==1)
|
||||
wiimote_set_leds(wm, WIIMOTE_LED_2);
|
||||
else if(wm->unid==2)
|
||||
wiimote_set_leds(wm, WIIMOTE_LED_3);
|
||||
else if(wm->unid==3)
|
||||
wiimote_set_leds(wm, WIIMOTE_LED_4);
|
||||
}
|
||||
}
|
||||
if(found)
|
||||
{
|
||||
myosd_num_of_joys--;
|
||||
#ifdef WIIMOTE_DBG
|
||||
printf("NUM JOYS %d\n",myosd_num_of_joys);
|
||||
#endif
|
||||
return unid;
|
||||
}
|
||||
return unid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Find a wiimote_t structure by its source_cid.
|
||||
*
|
||||
* @param wm Pointer to a wiimote_t structure.
|
||||
* @param wiimotes The number of wiimote_t structures in \a wm.
|
||||
* @param unid The unique identifier to search for.
|
||||
*
|
||||
* @return Pointer to a wiimote_t structure, or NULL if not found.
|
||||
*/
|
||||
|
||||
struct wiimote_t* wiimote_get_by_source_cid(uint16_t source_cid){
|
||||
|
||||
int i = 0;
|
||||
|
||||
for (; i < myosd_num_of_joys; ++i) {
|
||||
#ifdef WIIMOTE_DBG
|
||||
printf("0x%02x 0x%02x\n",joys[i].i_source_cid,source_cid);
|
||||
#endif
|
||||
if (joys[i].i_source_cid == source_cid)
|
||||
return &joys[i];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Request the wiimote controller status.
|
||||
*
|
||||
@ -676,46 +599,16 @@ static void classic_ctrl_pressed_buttons(struct classic_ctrl_t* cc, short now) {
|
||||
* @param y The raw y-axis value.
|
||||
*/
|
||||
void calc_joystick_state(struct joystick_t* js, float x, float y) {
|
||||
float rx, ry, ang;
|
||||
js->rx = 0;
|
||||
js->ry = 0;
|
||||
|
||||
/*
|
||||
* Since the joystick center may not be exactly:
|
||||
* (min + max) / 2
|
||||
* Then the range from the min to the center and the center to the max
|
||||
* may be different.
|
||||
* Because of this, depending on if the current x or y value is greater
|
||||
* or less than the assoicated axis center value, it needs to be interpolated
|
||||
* between the center and the minimum or maxmimum rather than between
|
||||
* the minimum and maximum.
|
||||
*
|
||||
* So we have something like this:
|
||||
* (x min) [-1] ---------*------ [0] (x center) [0] -------- [1] (x max)
|
||||
* Where the * is the current x value.
|
||||
* The range is therefore -1 to 1, 0 being the exact center rather than
|
||||
* the middle of min and max.
|
||||
*/
|
||||
if (x == js->center.x)
|
||||
rx = 0;
|
||||
else if (x >= js->center.x)
|
||||
rx = ((float)(x - js->center.x) / (float)(js->max.x - js->center.x));
|
||||
else
|
||||
rx = ((float)(x - js->min.x) / (float)(js->center.x - js->min.x)) - 1.0f;
|
||||
|
||||
if (y == js->center.y)
|
||||
ry = 0;
|
||||
else if (y >= js->center.y)
|
||||
ry = ((float)(y - js->center.y) / (float)(js->max.y - js->center.y));
|
||||
else
|
||||
ry = ((float)(y - js->min.y) / (float)(js->center.y - js->min.y)) - 1.0f;
|
||||
|
||||
/* calculate the joystick angle and magnitude */
|
||||
ang = RAD_TO_DEGREE(atanf(ry / rx));
|
||||
ang -= 90.0f;
|
||||
if (rx < 0.0f)
|
||||
ang -= 180.0f;
|
||||
js->ang = absf(ang);
|
||||
js->mag = (float) sqrt((rx * rx) + (ry * ry));
|
||||
js->rx = rx;
|
||||
js->ry = ry;
|
||||
if (x > js->center.x)
|
||||
js->rx = ((float)(x - js->center.x) / (float)(js->max.x - js->center.x));
|
||||
else if (x < js->center.x)
|
||||
js->rx = ((float)(x - js->min.x) / (float)(js->center.x - js->min.x)) - 1.0f;
|
||||
|
||||
if (y > js->center.y)
|
||||
js->ry = ((float)(y - js->center.y) / (float)(js->max.y - js->center.y));
|
||||
else if (js->ry < js->center.y)
|
||||
js->ry = ((float)(y - js->min.y) / (float)(js->center.y - js->min.y)) - 1.0f;
|
||||
}
|
||||
|
@ -50,14 +50,8 @@ extern "C" {
|
||||
typedef unsigned char byte;
|
||||
typedef char sbyte;
|
||||
|
||||
#define WIIMOTE_PI 3.14159265
|
||||
|
||||
//#define WIIMOTE_DBG 0
|
||||
|
||||
/* Convert between radians and degrees */
|
||||
#define RAD_TO_DEGREE(r) ((r * 180.0f) / WIIMOTE_PI)
|
||||
#define DEGREE_TO_RAD(d) (d * (WIIMOTE_PI / 180.0f))
|
||||
|
||||
/* Convert to big endian */
|
||||
#define BIG_ENDIAN_LONG(i) (htonl(i))
|
||||
#define BIG_ENDIAN_SHORT(i) (htons(i))
|
||||
@ -202,8 +196,6 @@ extern "C" {
|
||||
struct vec2b_t min; /**< minimum joystick values */
|
||||
struct vec2b_t center; /**< center joystick values */
|
||||
|
||||
float ang; /**< angle the joystick is being held */
|
||||
float mag; /**< magnitude of the joystick (range 0-1) */
|
||||
float rx, ry;
|
||||
} joystick_t;
|
||||
|
||||
@ -272,12 +264,6 @@ extern "C" {
|
||||
|
||||
#define WIIMOTE_IS_CONNECTED(wm) (WIIMOTE_IS_SET(wm, WIIMOTE_STATE_CONNECTED))
|
||||
|
||||
extern struct wiimote_t joys[4];
|
||||
extern int myosd_num_of_joys;
|
||||
|
||||
|
||||
int wiimote_remove(uint16_t source_cid, bd_addr_t *addr);
|
||||
struct wiimote_t* wiimote_get_by_source_cid(uint16_t source_cid);
|
||||
int wiimote_handshake(struct wiimote_t* wm, byte event, byte* data, unsigned short len);
|
||||
void wiimote_status(struct wiimote_t* wm);
|
||||
void wiimote_data_report(struct wiimote_t* wm, byte type);
|
||||
|
@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
#include "input/input_common.h"
|
||||
#include "BTStack/wiimote.h"
|
||||
#include "BTStack/btpad.h"
|
||||
#include "general.h"
|
||||
|
||||
static uint32_t g_buttons[MAX_PLAYERS];
|
||||
@ -52,20 +52,7 @@ static int16_t ios_joypad_axis(unsigned port, uint32_t joyaxis)
|
||||
|
||||
static void ios_joypad_poll(void)
|
||||
{
|
||||
for (int i = 0; i != MAX_PLAYERS; i ++)
|
||||
{
|
||||
g_buttons[i] = 0;
|
||||
if (i < myosd_num_of_joys)
|
||||
{
|
||||
g_buttons[i] = joys[i].btns;
|
||||
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);
|
||||
g_buttons[0] = btpad_get_buttons();
|
||||
}
|
||||
|
||||
const rarch_joypad_driver_t ios_joypad = {
|
||||
|
@ -16,7 +16,7 @@
|
||||
#import "settings.h"
|
||||
#include "../input/ios_input.h"
|
||||
#include "../input/keycode.h"
|
||||
#include "../input/BTStack/wiimote.h"
|
||||
#include "../input/BTStack/btpad.h"
|
||||
|
||||
static const struct
|
||||
{
|
||||
@ -135,26 +135,9 @@ static const struct
|
||||
}
|
||||
|
||||
// WiiMote
|
||||
for (int i = 0; i != myosd_num_of_joys; i ++)
|
||||
{
|
||||
uint32_t buttons = joys[i].btns;
|
||||
buttons |= (joys[i].exp.type == EXP_CLASSIC) ? (joys[i].exp.classic.btns << 16) : 0;
|
||||
uint32_t buttons = btpad_get_buttons();
|
||||
|
||||
for (int j = 0; j != sizeof(buttons) * 8; j ++)
|
||||
{
|
||||
if (buttons & (1 << j))
|
||||
{
|
||||
_value.msubValues[1] = [NSString stringWithFormat:@"%d", j];
|
||||
[self finish];
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// SixAxis
|
||||
extern uint8_t psdata_buffer[512];
|
||||
uint32_t buttons = psdata_buffer[3] | (psdata_buffer[4] << 8);
|
||||
for (int i = 0; i != 32; i ++)
|
||||
for (int i = 0; buttons && i != sizeof(buttons) * 8; i ++)
|
||||
{
|
||||
if (buttons & (1 << i))
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user