mirror of
https://github.com/OpenEmu/OpenEmu-SDK.git
synced 2025-11-01 10:15:12 +00:00
Replace NSData+OESystem with DataProtocol+HexString from OpenEmuKit
This commit is contained in:
@@ -17,8 +17,7 @@
|
||||
0166211320D8522700D0368A /* OETouchbarHIDDeviceHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 0166211120D8522700D0368A /* OETouchbarHIDDeviceHandler.m */; };
|
||||
01A9FD2523187747007CD1E7 /* OESwitchProControllerHIDDeviceHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = 01A9FD2323187747007CD1E7 /* OESwitchProControllerHIDDeviceHandler.h */; };
|
||||
01A9FD2623187747007CD1E7 /* OESwitchProControllerHIDDeviceHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 01A9FD2423187747007CD1E7 /* OESwitchProControllerHIDDeviceHandler.m */; };
|
||||
01AFC70C2364E327005EEB08 /* NSData+OESystem.h in Headers */ = {isa = PBXBuildFile; fileRef = 01AFC70A2364E327005EEB08 /* NSData+OESystem.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
01AFC70D2364E327005EEB08 /* NSData+OESystem.m in Sources */ = {isa = PBXBuildFile; fileRef = 01AFC70B2364E327005EEB08 /* NSData+OESystem.m */; };
|
||||
01AFC70D2364E327005EEB08 /* DataProtocol+HexString.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01AFC70B2364E327005EEB08 /* DataProtocol+HexString.swift */; };
|
||||
01C0F4372327184F00311409 /* OEDeviceManager_Internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 01C0F436232717C700311409 /* OEDeviceManager_Internal.h */; };
|
||||
01F306FB20AA1C64005C8F18 /* NSUserDefaults+OpenEmuSDK.h in Headers */ = {isa = PBXBuildFile; fileRef = 01F306F920AA1C64005C8F18 /* NSUserDefaults+OpenEmuSDK.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
01F306FC20AA1C64005C8F18 /* NSUserDefaults+OpenEmuSDK.m in Sources */ = {isa = PBXBuildFile; fileRef = 01F306FA20AA1C64005C8F18 /* NSUserDefaults+OpenEmuSDK.m */; };
|
||||
@@ -144,8 +143,7 @@
|
||||
0166211120D8522700D0368A /* OETouchbarHIDDeviceHandler.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OETouchbarHIDDeviceHandler.m; sourceTree = "<group>"; };
|
||||
01A9FD2323187747007CD1E7 /* OESwitchProControllerHIDDeviceHandler.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OESwitchProControllerHIDDeviceHandler.h; sourceTree = "<group>"; };
|
||||
01A9FD2423187747007CD1E7 /* OESwitchProControllerHIDDeviceHandler.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OESwitchProControllerHIDDeviceHandler.m; sourceTree = "<group>"; };
|
||||
01AFC70A2364E327005EEB08 /* NSData+OESystem.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSData+OESystem.h"; sourceTree = "<group>"; };
|
||||
01AFC70B2364E327005EEB08 /* NSData+OESystem.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSData+OESystem.m"; sourceTree = "<group>"; };
|
||||
01AFC70B2364E327005EEB08 /* DataProtocol+HexString.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "DataProtocol+HexString.swift"; sourceTree = "<group>"; };
|
||||
01C0F436232717C700311409 /* OEDeviceManager_Internal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OEDeviceManager_Internal.h; sourceTree = "<group>"; };
|
||||
01F306F920AA1C64005C8F18 /* NSUserDefaults+OpenEmuSDK.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSUserDefaults+OpenEmuSDK.h"; sourceTree = "<group>"; };
|
||||
01F306FA20AA1C64005C8F18 /* NSUserDefaults+OpenEmuSDK.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSUserDefaults+OpenEmuSDK.m"; sourceTree = "<group>"; };
|
||||
@@ -485,8 +483,7 @@
|
||||
C6605B821D725B0D009C7E91 /* OEM3UFile.h */,
|
||||
C6605B831D725B0D009C7E91 /* OEM3UFile.m */,
|
||||
C6772BDE1710E41C00ED580A /* OELocalizationHelper.swift */,
|
||||
01AFC70A2364E327005EEB08 /* NSData+OESystem.h */,
|
||||
01AFC70B2364E327005EEB08 /* NSData+OESystem.m */,
|
||||
01AFC70B2364E327005EEB08 /* DataProtocol+HexString.swift */,
|
||||
);
|
||||
name = Utilities;
|
||||
sourceTree = "<group>";
|
||||
@@ -521,7 +518,6 @@
|
||||
isa = PBXHeadersBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
01AFC70C2364E327005EEB08 /* NSData+OESystem.h in Headers */,
|
||||
C6772BC41710E28900ED580A /* NSResponder+OEHIDAdditions.h in Headers */,
|
||||
C6772B781710E21900ED580A /* OpenEmuSystem.h in Headers */,
|
||||
C6772B811710E21900ED580A /* OEBindingMap.h in Headers */,
|
||||
@@ -734,7 +730,7 @@
|
||||
C6772B9F1710E25300ED580A /* OEPlayerBindings.m in Sources */,
|
||||
C6772BB71710E28900ED580A /* OEDeviceManager.m in Sources */,
|
||||
C6772BB91710E28900ED580A /* OEDeviceHandler.m in Sources */,
|
||||
01AFC70D2364E327005EEB08 /* NSData+OESystem.m in Sources */,
|
||||
01AFC70D2364E327005EEB08 /* DataProtocol+HexString.swift in Sources */,
|
||||
C6772BBB1710E28900ED580A /* OEHIDDeviceHandler.m in Sources */,
|
||||
C6772BBD1710E28900ED580A /* OEMultiHIDDeviceHandler.m in Sources */,
|
||||
C6772BBF1710E28900ED580A /* OEWiimoteHIDDeviceHandler.m in Sources */,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2019, OpenEmu Team
|
||||
// Copyright (c) 2021, OpenEmu Team
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
@@ -22,22 +22,36 @@
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#import "NSData+OESystem.h"
|
||||
#import <Foundation/Foundation.h>
|
||||
import Foundation
|
||||
|
||||
private let charA = UInt8(ascii: "a")
|
||||
private let char0 = UInt8(ascii: "0")
|
||||
|
||||
@implementation NSData (OESystem)
|
||||
|
||||
|
||||
- (NSString *)oe_hexStringRepresentation
|
||||
{
|
||||
NSMutableString *res = [NSMutableString string];
|
||||
const uint8_t *bytes = self.bytes;
|
||||
for (NSUInteger i = 0; i < self.length; i++, bytes++) {
|
||||
[res appendFormat:@"%02X", *bytes];
|
||||
}
|
||||
return [res copy];
|
||||
private func itoh(_ value: UInt8) -> UInt8 {
|
||||
assert(value <= 0xF)
|
||||
return (value > 9) ? (charA + value - 10) : (char0 + value)
|
||||
}
|
||||
|
||||
public extension DataProtocol {
|
||||
/// Returns a hexadecimal encoding of the receiver.
|
||||
var hexString: String {
|
||||
let hexLen = self.count * 2
|
||||
let ptr = UnsafeMutablePointer<UInt8>.allocate(capacity: hexLen)
|
||||
var offset = 0
|
||||
|
||||
for i in self {
|
||||
ptr[offset ] = itoh((i >> 4) & 0xF)
|
||||
ptr[offset + 1] = itoh(i & 0xF)
|
||||
offset += 2
|
||||
}
|
||||
|
||||
return String(bytesNoCopy: ptr, length: hexLen, encoding: .utf8, freeWhenDone: true)!
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
public extension NSData {
|
||||
@objc(oe_hexStringRepresentation)
|
||||
var hexString: String {
|
||||
return (self as Data).hexString
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
// Copyright (c) 2019, OpenEmu Team
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * 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.
|
||||
// * Neither the name of the OpenEmu Team nor the
|
||||
// names of its contributors may be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY OpenEmu Team ''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 OpenEmu Team 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.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface NSData (OESystem)
|
||||
|
||||
- (NSString *)oe_hexStringRepresentation;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -31,7 +31,6 @@
|
||||
#import <IOKit/hid/IOHIDLib.h>
|
||||
#import <IOKit/hid/IOHIDUsageTables.h>
|
||||
|
||||
#import <OpenEmuSystem/NSData+OESystem.h>
|
||||
#import <OpenEmuSystem/NSResponder+OEHIDAdditions.h>
|
||||
#import <OpenEmuSystem/OEBindingMap.h>
|
||||
#import <OpenEmuSystem/OEBindingsController.h>
|
||||
|
||||
Reference in New Issue
Block a user