-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider providing CLK_ defines as dictionary #5
Comments
It'll be better if I just use an For now though, to test if a for key in range(CLK_ESCAPE, CLI_Last + 1):
Corsair.SetLedsColors(1, CorsairLedColor(key, 255, 255, 255)) |
Thanks for replying and apologies in advance for stupid questions. I'm using python 2.7 are enums available here? So will this additionally solve the issue of getting a key's number from a user provided string of it's name? i.e. would this work? 'CLK_A' in CLK.__members__:
# do something
print CLK['CLK_A'] etc. |
Enums are available via backport for any python version below 3.4 It would likely be 'A' in CLK.__members__ or try:
CLK['A']
valid_key = True
except KeyError:
valid_key = False |
Great, that's what I was hoping. |
I've run into a slight problem. CLK and CDC contain names that are not valid Python identifiers (e.g. For example, for the CLK._1
CLK[1]
CLK['1'] for the device capability CDC._None
CDC[None]
CDC['None'] All in all, not really a big deal. Only affects the programmer really, makes it slightly inconvenient. The good news is that I've implemented easier membership testing. Now you can do >>> 'A' in CLK
True instead of the previous methods I showed you. For the weird ones, you can do >>> '1' in CLK
True
>>> '_1' in CLK
True
>>> 'None' in CDC
True
>>> '_None' in CDC
True Unfortunately, you can't use the integer or NoneType values like you can to index. I'll push an update later. |
Oh wow, I just remembered, you can get the key ID from key name with |
GetLedIdForKeyName implements CorsairGetLedIdForKeyName which only takes a char not a string, so I was unsure how to check non-alphanumeric keys. If it's even possible that way. In fact based on the documentation, you can't even look up numbers and punctuation!
|
Ah, that's incredibly dumb. |
I assumed it was just for dealing with keyboards with alternate layouts: AZERTY, dvorak etc. Since it didn't seem to do what I wanted, I ignored it. :) |
I'm taking a bit longer because I'm trying to abstract away the usage of ctypes structures and pointers and trying to give the developer the data directly, instead of letting them fend for their own. I'll have an update pushed out within 30 minutes. |
- Moved all defines to their own Enum, see issue #5 for more details - Abstracted away structures and pointers, now you get easy-to-use namedtuples! - Updated examples to reflect new API.
Done! eb99b58 Note: It breaks pretty much everything, you'll have to redo many parts of your program. Sorry! |
Nice, thank you. |
In the project I am working on, I want the user to be able to choose a key in a configuration file. This has forced me to create a dict so I can reference key names. This is a shame, because it's basically repeating information already in cue_sdk.
This problem could be avoided if cue_sdk already provided the values in a dict. Making it easy to do stuff like:
etc.
Thoughts? I'm not hugely experienced in this area, so maybe there is something I am missing?
The text was updated successfully, but these errors were encountered: