The Corsair User Forums  

Go Back   The Corsair User Forums > Corsair Product Discussion > Corsair Utility Engine (CUE) 1.x and 2.x > CUE 1.x and 2.x SDK

 
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old 11-15-2017, 07:16 AM
ygolohcisp ygolohcisp is offline
Registered User
 
Join Date: Mar 2016
Posts: 27
POST ID # = 926373
ygolohcisp Reputation: 10
Default How to get K95's G key presses through USB without CUE software?

How can I get the K95's G key presses through USB without CUE software?

The K95 shows up as these HID devices:
Code:
ID 1b1c:1b11 \\?\hid#vid_1b1c&pid_1b11&mi_01&col01#8&2dd5e1ac&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030} Corsair K95 RGB Gaming Keyboard
ID 1b1c:1b11 \\?\hid#vid_1b1c&pid_1b11&mi_01&col02#8&2dd5e1ac&0&0001#{4d1e55b2-f16f-11cf-88cb-001111000030} Corsair K95 RGB Gaming Keyboard
ID 1b1c:1b11 \\?\hid#vid_1b1c&pid_1b11&mi_01&col03#8&2dd5e1ac&0&0002#{4d1e55b2-f16f-11cf-88cb-001111000030} Corsair K95 RGB Gaming Keyboard
ID 1b1c:1b11 \\?\hid#vid_1b1c&pid_1b11&mi_01&col04#8&2dd5e1ac&0&0003#{4d1e55b2-f16f-11cf-88cb-001111000030} Corsair K95 RGB Gaming Keyboard
ID 1b1c:1b11 \\?\hid#vid_1b1c&pid_1b11&mi_02#8&9fea3ea&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030} Corsair K95 RGB Gaming Keyboard
ID 1b1c:1b11 \\?\hid#vid_1b1c&pid_1b11&mi_00#8&16125567&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030} Corsair K95 RGB Gaming Keyboard
But when I try to open any one of these for reading, I get an error.

What's the correct way to read from it to get the G key presses? And which of these HID devices is used for them?

I'm already successfully sending the LED data via libusb but now I still need to get G key presses. They are sent via normal HID, right?
  #2  
Old 11-15-2017, 12:51 PM
Darth Affe's Avatar
Darth Affe Darth Affe is offline
//TODO add user title
Darth Affe's PC Specs
 
Join Date: Sep 2015
Location: UTC+1
Posts: 127
POST ID # = 926409
Darth Affe Reputation: 15
Default

Yes, it is possible to read the keys from the hid-device. If you read from the one with "col03" with a buffer size of 64 it should be working.
I tried around with this a while ago and got some working (C#) code here.
  #3  
Old 11-16-2017, 05:57 PM
ygolohcisp ygolohcisp is offline
Registered User
 
Join Date: Mar 2016
Posts: 27
POST ID # = 926589
ygolohcisp Reputation: 10
Default

I tried that but it's not working. I can't open the HID device with this hidapi lib.

Apparently Windows doesn't allow to open keyboards/mice for security reasons:
https://github.com/signal11/hidapi/i...ment-345071855

But isn't your C# program running in userspace, not as a driver in kernel space?
  #4  
Old 11-16-2017, 07:06 PM
ygolohcisp ygolohcisp is offline
Registered User
 
Join Date: Mar 2016
Posts: 27
POST ID # = 926601
ygolohcisp Reputation: 10
Default

I captured these packets with wireshark/UsbPcap when pressing and releasing each G key one after another (G1 to G18).
The key release packets all look the same (not key specific) for some reason, only the keypress packets are key-specific..



So I have to use 0x82 for wIndex, but what should I use for bmRequestType, bRequest and wValue when calling libusb_control_transfer()?
http://libusb.sourceforge.net/api-1....a07f4568d56f38
  #5  
Old 11-17-2017, 06:59 AM
Darth Affe's Avatar
Darth Affe Darth Affe is offline
//TODO add user title
Darth Affe's PC Specs
 
Join Date: Sep 2015
Location: UTC+1
Posts: 127
POST ID # = 926649
Darth Affe Reputation: 15
Default

Quote:
Originally Posted by ygolohcisp View Post
I tried that but it's not working. I can't open the HID device with this hidapi lib.

Apparently Windows doesn't allow to open keyboards/mice for security reasons:
https://github.com/signal11/hidapi/i...ment-345071855

But isn't your C# program running in userspace, not as a driver in kernel space?
Yes it is running in userspace. I've no idea how windows 8 handles such things but for me (win 7) it works fine, and as far as i know on win 10 it works too.


Quote:
Originally Posted by ygolohcisp View Post
The key release packets all look the same (not key specific) for some reason, only the keypress packets are key-specific..
Yes, this is expected. The keyboard always sends data containing isPressed-flags for every key. Therefore after releasing a key (if you only pressed one) it's always 0 only. if you press multiple keys and release one you'll still see the remaining ones as 1.
That's what is parsed here:
https://github.com/DarthAffe/CUE.NET...ceInput.cs#L90


Quote:
Originally Posted by ygolohcisp View Post
So I have to use 0x82 for wIndex, but what should I use for bmRequestType, bRequest and wValue when calling libusb_control_transfer()?
Sorry i can't help with that. I've no idea how that lowlevel usb-libraries work.

Last edited by Darth Affe; 11-17-2017 at 07:03 AM.
  #6  
Old 11-23-2017, 01:24 PM
ygolohcisp ygolohcisp is offline
Registered User
 
Join Date: Mar 2016
Posts: 27
POST ID # = 927471
ygolohcisp Reputation: 10
Default

Thanks for explaining the keypress msgs.

I also tried with the hidapi lib again, but apparently userspace programs on Windows are not allowed (by the OS) to read HID devices that are keyboards or mice, for security reasons:
https://github.com/signal11/hidapi/i...ment-161152387

So how did you get your program to open the keyboard's HID device while running in userspace (without having to override the Corsair HID driver)? :)
  #7  
Old 11-23-2017, 02:40 PM
Darth Affe's Avatar
Darth Affe Darth Affe is offline
//TODO add user title
Darth Affe's PC Specs
 
Join Date: Sep 2015
Location: UTC+1
Posts: 127
POST ID # = 927483
Darth Affe Reputation: 15
Default

Quote:
Originally Posted by ygolohcisp View Post
So how did you get your program to open the keyboard's HID device while running in userspace (without having to override the Corsair HID driver)? :)
I've no idea. Like I said this might be a win 8 issue.
The only thing I can do to help with this is to give you the application I used to test back when I worked with this. I works 100% for me (just tested it again). If it doesn't work for you it's likely a os problem, if it does you're doing something wrong :p

Just run it, open a notepad and press some keys. It should light up the pressed keys on the keyboard. (Don't press keys in the console-window of the application except you want to close it.)
Attached Files
File Type: zip InputTest.zip (218.2 KB, 71 views)
  #8  
Old 12-06-2017, 10:00 AM
ygolohcisp ygolohcisp is offline
Registered User
 
Join Date: Mar 2016
Posts: 27
POST ID # = 929322
ygolohcisp Reputation: 10
Default

For me InputTest.exe crashes at start with an exception, even after I installed .NET and the VC++ redistributable :(
  #9  
Old 12-10-2017, 10:57 PM
hastegag hastegag is offline
Registered User
hastegag's PC Specs
 
Join Date: Dec 2016
Location: Northeast US
Posts: 814
POST ID # = 929994
hastegag Reputation: 20
Default

Quote:
Originally Posted by ygolohcisp View Post
For me InputTest.exe crashes at start with an exception, even after I installed .NET and the VC++ redistributable :(
This has been on my back burner, but I've been dying to try it

just tried it and it works on win10x64, but again as he said, you need to be inside a notepad. I had 2.20.xxx installed with the SDK enabled.

If i was outside of notepad and hit the G keys it does not necessarily work and may crash, but ultimately, i know this is going to be a cool thing...I'm excited to look at how Darth Affe set this up and go from there
  #10  
Old 12-12-2017, 05:25 PM
ygolohcisp ygolohcisp is offline
Registered User
 
Join Date: Mar 2016
Posts: 27
POST ID # = 930261
ygolohcisp Reputation: 10
Default

How did you get it to work instead of throw an exception?

I got the exception right after starting it on the command line.

Before I could even run it, I had to install .Net and VC++ redistributable because of msvcp140.dll, what else is missing?
  #11  
Old 12-13-2017, 06:09 PM
ygolohcisp ygolohcisp is offline
Registered User
 
Join Date: Mar 2016
Posts: 27
POST ID # = 930418
ygolohcisp Reputation: 10
Default

Quote:
Originally Posted by Darth Affe View Post
The only thing I can do to help with this is to give you the application I used to test back when I worked with this. I works 100% for me (just tested it again). If it doesn't work for you it's likely a os problem, if it does you're doing something wrong :p
Could you maybe upload the source of InputTest.exe somewhere so I can translate it into the language I'm using and try if that works? :)
I'd really appreciate it.
  #12  
Old 12-16-2017, 03:14 AM
Darth Affe's Avatar
Darth Affe Darth Affe is offline
//TODO add user title
Darth Affe's PC Specs
 
Join Date: Sep 2015
Location: UTC+1
Posts: 127
POST ID # = 930763
Darth Affe Reputation: 15
Default

Just take the example project in the repo: https://github.com/DarthAffe/CUE.NET.../SimpleDevTest
  #13  
Old 12-16-2017, 06:13 PM
hastegag hastegag is offline
Registered User
hastegag's PC Specs
 
Join Date: Dec 2016
Location: Northeast US
Posts: 814
POST ID # = 930847
hastegag Reputation: 20
Default

Quote:
Originally Posted by ygolohcisp View Post
Could you maybe upload the source of InputTest.exe somewhere so I can translate it into the language I'm using and try if that works? :)
I'd really appreciate it.
hey did you run it with CUE running and FULLY Loaded up? I tried again without cue running, got an exception in the command line. I tried running after running CUE but before loading all the devices and got a different error.

Maybe just try again? I am going to try to take a closer look at what this code does and see if I can extrapolate for my purposes. I really just was looking for a way to fill in the gaps with CUE, like decision making macros on the Gkeys that can in and of themselves test for modifiers being pressed or something else happening at the same time to make them context sensitive/intelligent. Right now I have to often remap these G keys to an autohotkey recognizable key which limits my other possibilities on the keyboard at the same time (there are only so many Fkeys and in photoshop for example you have to sort of reserve fkeys and modifier states for actions - it gets crowded quickly).

I think this would be the fix, bc there is clearly a way to see when the G keys are depressed...and he showed us how so i can go from here.
  #14  
Old 12-17-2017, 04:29 AM
Darth Affe's Avatar
Darth Affe Darth Affe is offline
//TODO add user title
Darth Affe's PC Specs
 
Join Date: Sep 2015
Location: UTC+1
Posts: 127
POST ID # = 930881
Darth Affe Reputation: 15
Default

If you only need the G-keys you can use the original SDK or CUE.NET since there is an event for them for a few weeks now.
  #15  
Old 12-17-2017, 01:04 PM
hastegag hastegag is offline
Registered User
hastegag's PC Specs
 
Join Date: Dec 2016
Location: Northeast US
Posts: 814
POST ID # = 930905
hastegag Reputation: 20
Default

Quote:
Originally Posted by Darth Affe View Post
If you only need the G-keys you can use the original SDK or CUE.NET since there is an event for them for a few weeks now.
I think I will try that. I did download your repository last night for InputTest / SimpleDevTest and got it to compile after some fiddling on Visual Studio 2017, I had to comment out a couple lines and I didn't get too far.

It asked me to use the more modern .net targets which seemed to work finally when i opened the input project before the simple dev test. It wasn't getting where the namespace came from for CUE.Net.Input. The .net4.5 targets lower than version 4.5.2 don't seem to be able to be installed in VS Community '17, but it seems to play ok with the newer version.


In the meantime, while I will definitely look into the Cue.net original SDK, i am going to hotfix this for myself a different route by making 18 executables in AHK that are linked to in CUE on each G key. The script/exe polls for whether a modifier key is pressed at execution and save out the keystate into an ini and i can read that back in with my primary script. Tricky part is telling Script 1 when to update and fire a hotkey. I suppose I could poll every second or so the same ini file for state changes and erase it after each iteration, but that is slow and even on an nvme its probably not a great method. I'm probably going to see if i can just save the keystate in memory someplace and read it back in periodically (which is i am sure less taxing on the system and should be faster).

Obviously this is hacky and not the best approach, I am sure the SDK will prove to be a better method.
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 09:24 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2018, vBulletin Solutions, Inc.