配置steam input遇到的坑,调用steam input API 之前的准备工作

发布时间 2023-07-09 13:20:03作者: zxddesk

配置steam input遇到的坑,调用steam input API 之前的准备工作

 

总共需要3种类型的文件

1.steam_appid.txt

这个文件里面就只有一个id,对应着你正在调试的app,这个文件必须放在你生成的game.exe旁边比如在vc的Debug文件夹中,或者工程的根目录下.

缺这个文件SteamAPI_Init无法调用成功

 

2.controller_xxxxx.vdf, 

这是手柄布局配置文件,由steam客户端配置手柄时产生,其中xxxx指的是控制器类型,比如你配置的是xbox360手柄,文件名称就为controller_xbox360.vdf,

配置文件可以有多个,根据你配置的控制器类型的数量决定,比如可以是

controller_xboxone.vdf

controller_xbox360.vdf

controller_ps4.vdf

controller_steam.vdf

 

要得到配置文件首先要使用一种叫IGA的文件用于设置你游戏中碰到的各种行为动作(Action),比如发子弹,跳,移动,飞行….等等.

有了IGA文件客户端才知道如何配置手柄,

https://partner.steamgames.com/doc/features/steam_controller/iga_examples  IGA文件模板

 

下面是一个IGA文件的例子,这个例子描述呢nes模拟器模拟nes手柄的操作

"In Game Actions"

{

    "actions"

    {

        "GameControls"

        {

            "title"                 "#Set_GameControls"

            "Button"

            {

                "Action_A"          "#Action_A"

                "Action_B"          "#Action_B"

                "Action_Select"     "#Action_Select"

                "Action_Start"      "#Action_Start"

                "Action_Up"         "#Action_Up"

                "Action_Down"       "#Action_Down"

                "Action_Left"       "#Action_Left"

                "Action_Right"      "#Action_Right"

            }

        }

    }

    "localization"

    {

        "english"

        {

           "Set_GameControls"       "General Controls"

           "Action_A"               "nes button A"

           "Action_B"               "nes button B"

           "Action_Select"          "nes button Select"

           "Action_Start"           "nes button Start"

           "Action_Up"              "nes button Up"

           "Action_Down"            "nes button Down"

           "Action_Left"            "nes button Left"

           "Action_Right"           "nes button Right"

        }

    }

}

 

将创建好的IGA文件重命名为game_actions_xxxxxx.vdf (xxxxx为你的App ID),将文件放入,…….steam\controller_config\中,

如果不存在controller_config就创建一个,然后就可以在客服端配置手柄了,这里最好使用app的测试版本调试steaminput,也就是后面跟着Playtest的版本,

因为可以直接从steam界面启动手柄配置

 

 

如果使用正式发布版测试,需要进入steam大屏幕才能配置,切来切去比较麻烦.

手柄布局编辑好之后,点下面这个设置按钮

 

 

然后在win10运行中执行 start steam://dumpcontrollerconfig?appid=X (X为已在steam发行的应用的ID)

这样就可以将你的当前配置文件复制到”我的文档”中

文件名为 config_xxxxx_controller_xxxxx.vdf 这个就是我们需要手柄布局配置文件了.

 

 

 

3.steam_input_manifest.vdf

manifest清单文件很简单,就是在有效的IGA文件基础上改一下

中间加一个"configurations"集合,包含了你使用到的布局配置文件的地址,一般都清单文件和布局配置文件都放在同一个目录中.

"Action Manifest"

{

         "configurations"

         {

                   "controller_xboxone"

                   {

                            "0"

                            {

                                     "path" "xbox_controller.vdf"

                            }

                   }

                   "controller_steamcontroller_gordon"

                   {

                            "0"

                            {

                                     "path" "steam_controller.vdf"

                            }

                            "1"

                            {

                                     "path" "steam_controller_motion_controls.vdf"

                            }

                   }

         }

         "actions"

         {

         }

         "localization"

         {

         }

}

 

这3种文件准备好之后,将steam_appid.txt放入Debug文件夹中或vc工程的根目录

将清单steam_input_manifest.vdf和所有controller_xxxxx.vdf文件放在你的steam游戏根目录下.

然后进入steamwork App管理界面,Application -> Steam input,进行设置

 

 

 

设置完后点保存,然后发布

 

一切准备好后你就可以返回IDE正常的调用steam input API了