Skip to content

Commit 1e598fb

Browse files
committed
Initial commit. Based on CUESDK v3.0.301
1 parent 97d002f commit 1e598fb

12 files changed

+1769
-0
lines changed

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 Corsair Memory, Inc.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
cue-sdk-python
2+
==============
3+
4+
This repository is dedicated for a `cuesdk` package on [PyPI](https://pypi.org/)
5+
6+
`cuesdk` package is a `ctypes`-based CUESDK binding for Python 3
7+
8+
You can install the package from PyPI by using `pip`:
9+
10+
```
11+
$ pip install cuesdk
12+
```
13+
14+
or by running the setup script:
15+
16+
```
17+
$ python setup.py install
18+
```

dll/CUESDK.x64_2017.dll

464 KB
Binary file not shown.

dll/CUESDK_2017.dll

371 KB
Binary file not shown.

example/color_pulse.py

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
from cuesdk import CueSdk
2+
import threading
3+
import queue
4+
import time
5+
6+
7+
def read_keys(inputQueue):
8+
while (True):
9+
input_str = input()
10+
inputQueue.put(input_str)
11+
12+
13+
def get_available_leds():
14+
colors = list()
15+
device_count = sdk.get_device_count()
16+
for device_index in range(device_count):
17+
led_positions = sdk.get_led_positions_by_device_index(device_index)
18+
colors.append(list(map(lambda x: [x[0], 0, 0, 0], led_positions)))
19+
return colors
20+
21+
22+
def perform_pulse_effect(wave_duration, led_colors):
23+
time_per_frame = 25
24+
x = 0
25+
cnt = len(led_colors)
26+
dx = time_per_frame / wave_duration
27+
while x < 2:
28+
val = int((1 - pow(x - 1, 2)) * 255)
29+
for di in range(cnt):
30+
for led_color in led_colors[di]:
31+
led_color[2] = val # green
32+
sdk.set_led_colors_buffer_by_device_index(di, led_colors[di])
33+
sdk.set_led_colors_flush_buffer()
34+
time.sleep(time_per_frame / 1000)
35+
x += dx
36+
37+
38+
def main():
39+
global sdk
40+
inputQueue = queue.Queue()
41+
42+
inputThread = threading.Thread(
43+
target=read_keys, args=(inputQueue,), daemon=True)
44+
inputThread.start()
45+
sdk = CueSdk()
46+
connected = sdk.connect()
47+
if not connected:
48+
err = sdk.get_last_error()
49+
print("Handshake failed: %s" % err)
50+
return
51+
52+
wave_duration = 500
53+
colors = get_available_leds()
54+
if (len(colors) == 0):
55+
return
56+
57+
print("Working... Use \"+\" or \"-\" to increase or decrease speed.\n" +
58+
"Press \"q\" to close program...")
59+
while (True):
60+
if (inputQueue.qsize() > 0):
61+
input_str = inputQueue.get()
62+
63+
if input_str == "q" or input_str == "Q":
64+
print("Exiting.")
65+
break
66+
elif input_str == "+":
67+
if wave_duration > 100:
68+
wave_duration -= 100
69+
elif input_str == "-":
70+
if wave_duration < 2000:
71+
wave_duration += 100
72+
73+
perform_pulse_effect(wave_duration, colors)
74+
75+
time.sleep(0.01)
76+
77+
78+
if __name__ == "__main__":
79+
main()

setup.py

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import os
2+
import platform
3+
import re
4+
import sys
5+
from setuptools import setup
6+
7+
8+
def read_version(filename='src/version.py'):
9+
"""Parse a __version__ number from a source file"""
10+
with open(filename) as source:
11+
text = source.read()
12+
match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", text)
13+
if not match:
14+
msg = "Unable to find version number in {}".format(filename)
15+
raise RuntimeError(msg)
16+
version = match.group(1)
17+
return version
18+
19+
20+
arch, exetype = platform.architecture()
21+
system = platform.system().lower()
22+
23+
if not system == 'windows':
24+
msg = "{} system is not supported".format(system)
25+
raise RuntimeError(msg)
26+
27+
data_files = []
28+
lib_x86 = os.path.join('.', 'dll', 'CUESDK_2017.dll')
29+
lib_x64 = os.path.join('.', 'dll', 'CUESDK.x64_2017.dll')
30+
if os.path.exists(lib_x86) and os.path.exists(lib_x64):
31+
install_libdir = os.path.join(sys.prefix, 'DLLs')
32+
data_files.append((install_libdir, [lib_x86]))
33+
data_files.append((install_libdir, [lib_x64]))
34+
35+
setup(
36+
name="cuesdk",
37+
version=read_version(),
38+
packages=['cuesdk'],
39+
package_dir={'cuesdk': 'src'},
40+
data_files=data_files,
41+
zip_safe=False,
42+
author="Corsair Memory, Inc.",
43+
url="https://github.com/CorsairOfficial/cue-sdk-python",
44+
description="Ctypes-based CUE SDK binding for Python",
45+
long_description=open("README.md").read(),
46+
long_description_content_type="text/markdown",
47+
install_requires=[],
48+
platforms=['win'],
49+
python_requires='>=3.3',
50+
classifiers=[
51+
'Development Status :: 4 - Beta',
52+
'Intended Audience :: Developers',
53+
'Intended Audience :: End Users/Desktop',
54+
'License :: OSI Approved :: MIT License',
55+
'Operating System :: Microsoft :: Windows',
56+
'Programming Language :: Python :: 3.3',
57+
'Programming Language :: Python :: 3.4',
58+
'Programming Language :: Python :: 3.5',
59+
'Programming Language :: Python :: 3.6',
60+
'Programming Language :: Python :: 3.7',
61+
'Programming Language :: Python :: 3.8',
62+
'Programming Language :: Python :: Implementation :: CPython',
63+
'Topic :: Games/Entertainment',
64+
'Topic :: System :: Hardware'
65+
]
66+
)
67+
68+
if not data_files:
69+
print("\nWARNING: Could not find %s" % lib_path)

src/__init__.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from .enums import *
2+
from .structs import *
3+
from .api import *

0 commit comments

Comments
 (0)