SDK下载:https://www.logitechg.com.cn/zh-cn/innovation/developer-lab.html
我是按照文档的第一步先创一个类
然后在Winform的窗体load事件调用了 Start () ,文档写着 usingCallback=true是自动回调 false是配合update()的方法
但是我 usingCallback=true 断点打在GkeySDKCallback() 按我的罗技鼠标根本就没进到GkeySDKCallback()
唯一有的效果就是在LGS驱动里会创建一个配置文件 求大佬康康怎么搞 主要想实现我按我的罗技鼠标 它能给我返回鼠标的key值
[C#] 纯文本查看 复制代码 // Use this for initialization
void Start () {
//Value used to show the two different ways to implement g-keys support in your game
//change it to false to try the non-callback version
usingCallback = true; //or false, depending on your implementation
if (usingCallback){
LogitechGSDK.logiGkeyCB cbInstance = new
LogitechGSDK.logiGkeyCB(this.GkeySDKCallback);
LogitechGSDK.LogiGkeyInitWithoutContext(cbInstance);
}
else
LogitechGSDK.LogiGkeyInitWithoutCallback();
}
// Update is called once per frame
void Update(){
if(!usingCallback){
for (int index = 6; index <= LogitechGSDK.LOGITECH_MAX_MOUSE_BUTTONS; index++) {
if (LogitechGSDK.LogiGkeyIsMouseButtonPressed(index) == 1) {
// Code to handle what happens on gkey pressed on mouse
}
}
for (int index = 1; index <= LogitechGSDK.LOGITECH_MAX_GKEYS; index++) {
for (int mKeyIndex = 1; mKeyIndex <= LogitechGSDK.LOGITECH_MAX_M_STATES;
mKeyIndex++) {
if (LogitechGSDK.LogiGkeyIsKeyboardGkeyPressed(index, mKeyIndex) == 1) {
// Code to handle what happens on gkey pressed on keyboard/headset
}
}
}
}
}
void GkeySDKCallback(LogitechGSDK.GkeyCode gKeyCode, String gKeyOrButtonString, IntPtr
context){
if(gKeyCode.keyDown == 0){
if(gKeyCode.mouse == 1){
// Code to handle what happens on gkey released on mouse
}
else{
// Code to handle what happens on gkey released on keyboard/headset
}
Using the G-key SDK with C#
Page 6
}
else{
if(gKeyCode.mouse == 1){
// Code to handle what happens on gkey pressed on mouse
}
else{
// Code to handle what happens on gkey pressed on keyboard
}
}
void OnDestroy () {
//Free G-Keys SDKs before quitting the game
LogitechGSDK.LogiGkeyShutdown();
} |