操作割り当ての確認
デバイスの物理ボタン/タッチ操作と、割り当てられたデバイス機能の対応を読み取ります。
前提条件
- デバイスが接続済みで、使用可能な状態であること。
- デバイスが
DevicePhysicalOperationsAPIに対応していること。
API Reference
フレームワーク
AIBuds.xcframework
インポート
- Swift
- Objective-C
import AIBuds#import <AIBuds/AIBuds-Swift.h>
#import <AIBuds/AIBuds.h>プロトコル
割り当ては DevicePhysicalOperationsAPI のプロパティとして公開されます。
- Swift
- Objective-C
/// The protocol for device physical operations API.
protocol DevicePhysicalOperationsAPI: DeviceAPI {
/// Physical operations with functions mapping
/// - Returns: A dictionary mapping physical operation identifiers to function identifiers.
///
/// The dictionary is structured as follows:
/// - Keys: Physical operation identifiers. Defined in ``DeviceOperation``.
/// - Values: Function identifiers. Defined in ``DeviceFunction``.
var physicalOperationsMapping: [NSNumber: NSNumber]? { get }
}/// The protocol for device physical operations API.
@protocol AIBudsDevicePhysicalOperationsAPI <AIBudsDeviceAPI>
/// Physical operations with functions mapping
/// - Returns: A dictionary mapping physical operation identifiers to function identifiers.
///
/// The dictionary is structured as follows:
/// - Keys: Physical operation identifiers. Defined in ``DeviceOperation``.
/// - Values: Function identifiers. Defined in ``DeviceFunction``.
@property(nonatomic, readonly, copy)
NSDictionary<NSNumber *, NSNumber *> *_Nullable physicalOperationsMapping;
@endプロパティ
| プロパティ | 型 | 説明 |
|---|---|---|
physicalOperationsMapping | [NSNumber: NSNumber]? | 各 DeviceOperation の raw value と DeviceFunction の raw value の対応。 |
戻り値
これは読み取り専用のオプションプロパティであり、非同期のクエリメソッドではありません。
使用例
- Swift
- Objective-C
import AIBuds
guard let device = device as? DevicePhysicalOperationsAPI else {
print("Device does not support physical-operation mapping")
return
}
guard let mapping = device.physicalOperationsMapping else {
print("Mapping is unavailable")
return
}
for (operationValue, functionValue) in mapping {
let operation = DeviceOperation(rawValue: operationValue.intValue)
let function = DeviceFunction(rawValue: functionValue.intValue)
print("\(String(describing: operation)) → \(String(describing: function))")
}#import <AIBuds/AIBuds-Swift.h>
#import <AIBuds/AIBuds.h>
id<AIBudsDevicePhysicalOperationsAPI> device = (id<AIBudsDevicePhysicalOperationsAPI>)self.device;
if (![device conformsToProtocol:@protocol(AIBudsDevicePhysicalOperationsAPI)]) {
NSLog(@"Device does not support physical-operation mapping");
return;
}
[device.physicalOperationsMapping
enumerateKeysAndObjectsUsingBlock:^(NSNumber *operation, NSNumber *function, BOOL *stop) {
NSLog(@"Operation %@ → function %@", operation, function);
}];エラー処理
このプロパティに完了ハンドラーはありません。プロトコル非対応、nil の割り当て、既知の列挙値へ変換できない raw value を処理してください。
ベストプラクティス
- 列挙型の raw value として扱う:キーと値を
DeviceOperationとDeviceFunctionから変換します。 - 未登録の操作を推測しない:割り当てにない操作は対応済みとして文書化されていません。
- 割り当て後に UI を更新:デバイスがプロパティを更新する場合は、割り当て成功後に再取得します。
注意事項
- SDK Demo はこのプロパティを直接読み取り、操作の raw value 順に並べて表示します。
- このプロパティは
ResultコールバックやKeyMappingモデルを使用しません。