用于与SteelSeries GameSense 3.8.x交互的库
gamesense的Python项目详细描述
游戏感
用于SteelSeries GameSense 3.8.x+的Python库
安装
这个包有两个不同的版本。一个支持普通的同步函数调用,另一个支持python的异步功能。
要安装同步版本,请运行:
pip install gamesense[sync]
要安装异步版本,请运行:
pip install gamesense[async]
或两者皆有:
pip install gamesense[sync,async]
用法
相对简单易用。
对于同步使用:
importgamesense# Create a GameSense object instance to usegs=gamesense.GameSense("SYNC_GAME","Sync Game")# Before you can register or send events, you must register your gamegs.register_game(icon_color_id=gamesense.GS_ICON_GOLD)# Register an event (different than binding an event, see more info in the SteelSeries docs)gs.register_event("DID_STUFF")# Test out the event by sending the eventgs.send_event("DID_STUFF",{"value":22})
对于异步使用:
importasyncioimportgamesense# For example purposes, need an event loop # Inside normal async functions, you'd just use await on the functions provided on AioGameSenseloop=asyncio.get_event_loop()# Create a GameSense object instance to usegs=gamesense.AioGameSense("ASYNC_GAME","Async Game")# Before you can register or send events, you must register your gameloop.run_until_complete(gs.register_game())# Register an event (different than binding an event, see more info in the SteelSeries docs)loop.run_until_complete(gs.register_event('DID_STUFF'))# Test out the event by sending the eventloop.run_until_complete(gs.send_event("DID_STUFF",{"value":23}))
这两个例子做了相对相同的事情。有关SteelSeries GameSense API的更多信息,请参见:https://github.com/SteelSeries/gamesense-sdk/tree/master/doc/api了解更多信息。绑定处理程序之类的东西应该是可能的,但可能有点复杂。为了使这种功能更容易,欢迎提交。