GameControllerBinder 1.1.1

GameControllerBinder 1.1.1

GameControllerBinder维护。



  • vladshakhtar

GameControllerBinder

A Swift框架,用于简化iOS应用程序中将游戏控制器输入与UI元素集成的过程。

概述

GameControllerBinder框架简化了将游戏控制器输入绑定到iOS应用程序内部UI元素和动作的过程。此框架支持各种控制器类型,包括PlayStation和Xbox控制器,允许快速设置和配置控制器输入,从而增强iOS设备上的游戏体验。

特性

  • 将动作绑定到游戏控制器按钮和触发器
  • 支持PlayStation和Xbox控制器
  • 与UI元素轻松集成
  • 为按下和释放状态自定义按钮动作

安装

Swift 包管理器

使用 Swift 包管理器将 GameControllerBinder 集成到你的 Xcode 项目中,请将其添加到你的包的依赖项中

dependencies: [
    .package(url: "https://github.com/yourusername/GameControllerBinder.git", from: "1.0.0")
]

CocoaPods

GameControllerBinder 通过 CocoaPods 提供。要安装它,只需将以下行添加到你的 Podfile 中

pod 'GameControllerBinder'

编辑 Podfile 之后,别忘了运行 pod install。

用法

以下是一个使用 GameControllerBinder 将按钮操作绑定到控制器按钮的简单示例

import GameControllerBinder

let binder = GameControllerBinder()

// Bind the 'A' button to perform an action
binder.bindButtonToAction(buttonName: .buttonA) {
    print("Button A was pressed")
}

将控制器的摇杆绑定到 UI 导航

controllerBinder.bindThumbstickToAction(thumbstickName: .rightThumbstick) { [weak self] (xValue, yValue) in
            //code that handles Thumbsticks movements
        }
    

将控制器的按钮绑定到 UIButton

controllerBinder.bindButtonToUIElement(buttonName: .buttonMenu, uiElement: searchButton) {
            self.performSearch()  //You can use also @objc functions or @IBAction functions here
        }

许可

GameControllerBinder 采用 MIT 许可。详情请参见 LICENSE 文件:

https://github.com/vladshakhtar/GameControllerBinder/blob/main/LICENSE