Hello community, here is the log from the commit of package razercfg for openSUSE:Factory checked in at 2017-08-10 14:02:01 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/razercfg (Old) and /work/SRC/openSUSE:Factory/.razercfg.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "razercfg" Thu Aug 10 14:02:01 2017 rev:5 rq:504929 version:0.39 Changes: -------- --- /work/SRC/openSUSE:Factory/razercfg/razercfg.changes 2016-11-11 14:35:34.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.razercfg.new/razercfg.changes 2017-08-10 14:11:09.796393437 +0200 @@ -1,0 +2,8 @@ +Tue Jun 20 06:29:13 UTC 2017 - r...@fthiessen.de + +- Update to version 0.39 + * Basic support for Diamondback Chroma + * New maximal DPI: 16'000 + * Some bugfixes for systemd support + +------------------------------------------------------------------- Old: ---- razercfg-0.38.tar.bz2 razercfg-0.38.tar.bz2.asc New: ---- razercfg-0.39.tar.bz2 razercfg-0.39.tar.bz2.asc ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ razercfg.spec ++++++ --- /var/tmp/diff_new_pack.etWPBT/_old 2017-08-10 14:11:10.416306157 +0200 +++ /var/tmp/diff_new_pack.etWPBT/_new 2017-08-10 14:11:10.420305593 +0200 @@ -1,7 +1,7 @@ # # spec file for package razercfg # -# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,7 +17,7 @@ Name: razercfg -Version: 0.38 +Version: 0.39 Release: 0 Summary: A Razer device configuration tool # Icons are http://creativecommons.org/licenses/by/4.0/ ++++++ razercfg-0.38.tar.bz2 -> razercfg-0.39.tar.bz2 ++++++ Binary files old/razercfg-0.38/HACKING.pdf and new/razercfg-0.39/HACKING.pdf differ Binary files old/razercfg-0.38/README.pdf and new/razercfg-0.39/README.pdf differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/razercfg-0.38/debian/changelog new/razercfg-0.39/debian/changelog --- old/razercfg-0.38/debian/changelog 2016-10-30 17:39:48.000000000 +0100 +++ new/razercfg-0.39/debian/changelog 2017-03-28 19:12:05.000000000 +0200 @@ -1,5 +1,5 @@ -razercfg (0.38) UNRELEASED; urgency=medium +razercfg (0.39) UNRELEASED; urgency=medium - * 0.38 + * 0.39 -- Michael Büsch <m...@bues.ch> Tue, 15 Jul 2014 11:25:47 +0200 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/razercfg-0.38/debian/control new/razercfg-0.39/debian/control --- old/razercfg-0.38/debian/control 2016-10-30 17:39:48.000000000 +0100 +++ new/razercfg-0.39/debian/control 2017-03-28 19:12:05.000000000 +0200 @@ -8,11 +8,17 @@ libusb-1.0-0-dev, pkg-config, python3-dev, - dh-python + dh-python, + systemd, + udev, +Standards-Version: 3.9.8 +Vcs-Git: https://git.bues.ch/git/razer.git +Vcs-Browser: https://git.bues.ch/git/razer.git +Homepage: https://bues.ch/h/razercfg Package: razercfg Architecture: any -Depends: ${python3:Depends}, ${shlibs:Depends}, ${misc:Depends} +Depends: ${python3:Depends}, ${shlibs:Depends}, ${misc:Depends}, lsb-base (>= 3.0-6) Suggests: python3-pyside Description: Razer device configuration tool This is a system daemon and Python-powered CLI configuration utility for Razer @@ -20,14 +26,14 @@ Package: qrazercfg Architecture: any -Depends: ${python3:Depends}, ${shlibs:Depends}, ${misc:Depends}, python3-pyside, razercfg +Depends: ${python3:Depends}, ${misc:Depends}, python3-pyside, razercfg Description: Graphical Razer device configuration tool Python- and QT-powered configuration utility for the configuration of Razer devices on Linux systems. Package: qrazercfg-applet Architecture: any -Depends: ${python3:Depends}, ${shlibs:Depends}, ${misc:Depends}, python3-pyside, razercfg, qrazercfg +Depends: ${python3:Depends}, ${misc:Depends}, python3-pyside, razercfg, qrazercfg Description: Graphical Razer device configuration tool - applet Python- and QT-powered configuration utility for the configuration of Razer devices on Linux systems. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/razercfg-0.38/debian/copyright new/razercfg-0.39/debian/copyright --- old/razercfg-0.38/debian/copyright 2016-10-30 17:39:48.000000000 +0100 +++ new/razercfg-0.39/debian/copyright 2017-03-28 19:12:05.000000000 +0200 @@ -0,0 +1,343 @@ +Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: razercfg +Source: https://bues.ch/h/razercfg + +Files: * +Copyright: 2008-2016 Michael Buesch <m...@bues.ch> +License: GPL-2+ + This package is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + . + This package is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + . + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/> + . + On Debian systems, the complete text of the GNU General + Public License version 2 can be found in "/usr/share/common-licenses/GPL-2". + +Files: icons/* +Copyright: 2016 Jan Stümmel +License: CC-BY-4.0 + Creative Commons Attribution 4.0 International Public License + . + By exercising the Licensed Rights (defined below), You accept and agree + to be bound by the terms and conditions of this Creative Commons + Attribution 4.0 International Public License ("Public License"). To the + extent this Public License may be interpreted as a contract, You are + granted the Licensed Rights in consideration of Your acceptance of + these terms and conditions, and the Licensor grants You such rights in + consideration of benefits the Licensor receives from making the + Licensed Material available under these terms and conditions. + . + . + Section 1 -- Definitions. + . + a. Adapted Material means material subject to Copyright and Similar + Rights that is derived from or based upon the Licensed Material + and in which the Licensed Material is translated, altered, + arranged, transformed, or otherwise modified in a manner requiring + permission under the Copyright and Similar Rights held by the + Licensor. For purposes of this Public License, where the Licensed + Material is a musical work, performance, or sound recording, + Adapted Material is always produced where the Licensed Material is + synched in timed relation with a moving image. + . + b. Adapter's License means the license You apply to Your Copyright + and Similar Rights in Your contributions to Adapted Material in + accordance with the terms and conditions of this Public License. + . + c. Copyright and Similar Rights means copyright and/or similar rights + closely related to copyright including, without limitation, + performance, broadcast, sound recording, and Sui Generis Database + Rights, without regard to how the rights are labeled or + categorized. For purposes of this Public License, the rights + specified in Section 2(b)(1)-(2) are not Copyright and Similar + Rights. + . + d. Effective Technological Measures means those measures that, in the + absence of proper authority, may not be circumvented under laws + fulfilling obligations under Article 11 of the WIPO Copyright + Treaty adopted on December 20, 1996, and/or similar international + agreements. + . + e. Exceptions and Limitations means fair use, fair dealing, and/or + any other exception or limitation to Copyright and Similar Rights + that applies to Your use of the Licensed Material. + . + f. Licensed Material means the artistic or literary work, database, + or other material to which the Licensor applied this Public + License. + . + g. Licensed Rights means the rights granted to You subject to the + terms and conditions of this Public License, which are limited to + all Copyright and Similar Rights that apply to Your use of the + Licensed Material and that the Licensor has authority to license. + . + h. Licensor means the individual(s) or entity(ies) granting rights + under this Public License. + . + i. Share means to provide material to the public by any means or + process that requires permission under the Licensed Rights, such + as reproduction, public display, public performance, distribution, + dissemination, communication, or importation, and to make material + available to the public including in ways that members of the + public may access the material from a place and at a time + individually chosen by them. + . + j. Sui Generis Database Rights means rights other than copyright + resulting from Directive 96/9/EC of the European Parliament and of + the Council of 11 March 1996 on the legal protection of databases, + as amended and/or succeeded, as well as other essentially + equivalent rights anywhere in the world. + . + k. You means the individual or entity exercising the Licensed Rights + under this Public License. Your has a corresponding meaning. + . + . + Section 2 -- Scope. + . + a. License grant. + . + 1. Subject to the terms and conditions of this Public License, + the Licensor hereby grants You a worldwide, royalty-free, + non-sublicensable, non-exclusive, irrevocable license to + exercise the Licensed Rights in the Licensed Material to: + . + a. reproduce and Share the Licensed Material, in whole or + in part; and + . + b. produce, reproduce, and Share Adapted Material. + . + 2. Exceptions and Limitations. For the avoidance of doubt, where + Exceptions and Limitations apply to Your use, this Public + License does not apply, and You do not need to comply with + its terms and conditions. + . + 3. Term. The term of this Public License is specified in Section + 6(a). + . + 4. Media and formats; technical modifications allowed. The + Licensor authorizes You to exercise the Licensed Rights in + all media and formats whether now known or hereafter created, + and to make technical modifications necessary to do so. The + Licensor waives and/or agrees not to assert any right or + authority to forbid You from making technical modifications + necessary to exercise the Licensed Rights, including + technical modifications necessary to circumvent Effective + Technological Measures. For purposes of this Public License, + simply making modifications authorized by this Section 2(a) + (4) never produces Adapted Material. + . + 5. Downstream recipients. + . + a. Offer from the Licensor -- Licensed Material. Every + recipient of the Licensed Material automatically + receives an offer from the Licensor to exercise the + Licensed Rights under the terms and conditions of this + Public License. + . + b. No downstream restrictions. You may not offer or impose + any additional or different terms or conditions on, or + apply any Effective Technological Measures to, the + Licensed Material if doing so restricts exercise of the + Licensed Rights by any recipient of the Licensed + Material. + . + 6. No endorsement. Nothing in this Public License constitutes or + may be construed as permission to assert or imply that You + are, or that Your use of the Licensed Material is, connected + with, or sponsored, endorsed, or granted official status by, + the Licensor or others designated to receive attribution as + provided in Section 3(a)(1)(A)(i). + . + b. Other rights. + . + 1. Moral rights, such as the right of integrity, are not + licensed under this Public License, nor are publicity, + privacy, and/or other similar personality rights; however, to + the extent possible, the Licensor waives and/or agrees not to + assert any such rights held by the Licensor to the limited + extent necessary to allow You to exercise the Licensed + Rights, but not otherwise. + . + 2. Patent and trademark rights are not licensed under this + Public License. + . + 3. To the extent possible, the Licensor waives any right to + collect royalties from You for the exercise of the Licensed + Rights, whether directly or through a collecting society + under any voluntary or waivable statutory or compulsory + licensing scheme. In all other cases the Licensor expressly + reserves any right to collect such royalties. + . + . + Section 3 -- License Conditions. + . + Your exercise of the Licensed Rights is expressly made subject to the + following conditions. + . + a. Attribution. + . + 1. If You Share the Licensed Material (including in modified + form), You must: + . + a. retain the following if it is supplied by the Licensor + with the Licensed Material: + . + i. identification of the creator(s) of the Licensed + Material and any others designated to receive + attribution, in any reasonable manner requested by + the Licensor (including by pseudonym if + designated); + . + ii. a copyright notice; + . + iii. a notice that refers to this Public License; + . + iv. a notice that refers to the disclaimer of + warranties; + . + v. a URI or hyperlink to the Licensed Material to the + extent reasonably practicable; + . + b. indicate if You modified the Licensed Material and + retain an indication of any previous modifications; and + . + c. indicate the Licensed Material is licensed under this + Public License, and include the text of, or the URI or + hyperlink to, this Public License. + . + 2. You may satisfy the conditions in Section 3(a)(1) in any + reasonable manner based on the medium, means, and context in + which You Share the Licensed Material. For example, it may be + reasonable to satisfy the conditions by providing a URI or + hyperlink to a resource that includes the required + information. + . + 3. If requested by the Licensor, You must remove any of the + information required by Section 3(a)(1)(A) to the extent + reasonably practicable. + . + 4. If You Share Adapted Material You produce, the Adapter's + License You apply must not prevent recipients of the Adapted + Material from complying with this Public License. + . + . + Section 4 -- Sui Generis Database Rights. + . + Where the Licensed Rights include Sui Generis Database Rights that + apply to Your use of the Licensed Material: + . + a. for the avoidance of doubt, Section 2(a)(1) grants You the right + to extract, reuse, reproduce, and Share all or a substantial + portion of the contents of the database; + . + b. if You include all or a substantial portion of the database + contents in a database in which You have Sui Generis Database + Rights, then the database in which You have Sui Generis Database + Rights (but not its individual contents) is Adapted Material; and + . + c. You must comply with the conditions in Section 3(a) if You Share + all or a substantial portion of the contents of the database. + . + For the avoidance of doubt, this Section 4 supplements and does not + replace Your obligations under this Public License where the Licensed + Rights include other Copyright and Similar Rights. + . + . + Section 5 -- Disclaimer of Warranties and Limitation of Liability. + . + a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE + EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS + AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF + ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, + IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, + WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR + PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS, + ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT + KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT + ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU. + . + b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE + TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, + NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, + INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES, + COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR + USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN + ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR + DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR + IN PART, THIS LIMITATION MAY NOT APPLY TO YOU. + . + c. The disclaimer of warranties and limitation of liability provided + above shall be interpreted in a manner that, to the extent + possible, most closely approximates an absolute disclaimer and + waiver of all liability. + . + . + Section 6 -- Term and Termination. + . + a. This Public License applies for the term of the Copyright and + Similar Rights licensed here. However, if You fail to comply with + this Public License, then Your rights under this Public License + terminate automatically. + . + b. Where Your right to use the Licensed Material has terminated under + Section 6(a), it reinstates: + . + 1. automatically as of the date the violation is cured, provided + it is cured within 30 days of Your discovery of the + violation; or + . + 2. upon express reinstatement by the Licensor. + . + For the avoidance of doubt, this Section 6(b) does not affect any + right the Licensor may have to seek remedies for Your violations + of this Public License. + . + c. For the avoidance of doubt, the Licensor may also offer the + Licensed Material under separate terms or conditions or stop + distributing the Licensed Material at any time; however, doing so + will not terminate this Public License. + . + d. Sections 1, 5, 6, 7, and 8 survive termination of this Public + License. + . + . + Section 7 -- Other Terms and Conditions. + . + a. The Licensor shall not be bound by any additional or different + terms or conditions communicated by You unless expressly agreed. + . + b. Any arrangements, understandings, or agreements regarding the + Licensed Material not stated herein are separate from and + independent of the terms and conditions of this Public License. + . + . + Section 8 -- Interpretation. + . + a. For the avoidance of doubt, this Public License does not, and + shall not be interpreted to, reduce, limit, restrict, or impose + conditions on any use of the Licensed Material that could lawfully + be made without permission under this Public License. + . + b. To the extent possible, if any provision of this Public License is + deemed unenforceable, it shall be automatically reformed to the + minimum extent necessary to make it enforceable. If the provision + cannot be reformed, it shall be severed from this Public License + without affecting the enforceability of the remaining terms and + conditions. + . + c. No term or condition of this Public License will be waived and no + failure to comply consented to unless expressly agreed to by the + Licensor. + . + d. Nothing in this Public License constitutes or may be interpreted + as a limitation upon, or waiver of, any privileges and immunities + that apply to the Licensor or You, including from the legal + processes of any jurisdiction or authority. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/razercfg-0.38/debian/razercfg.install new/razercfg-0.39/debian/razercfg.install --- old/razercfg-0.38/debian/razercfg.install 2016-10-30 17:39:48.000000000 +0100 +++ new/razercfg-0.39/debian/razercfg.install 2017-03-28 19:12:05.000000000 +0200 @@ -6,5 +6,3 @@ usr/bin/razerd /usr/bin usr/bin/razercfg /usr/bin usr/bin/razer-gamewrapper /usr/bin -usr/lib/librazer.so /usr/lib -usr/lib/librazer.so.1 /usr/lib diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/razercfg-0.38/debian/rules new/razercfg-0.39/debian/rules --- old/razercfg-0.38/debian/rules 2016-10-30 17:39:48.000000000 +0100 +++ new/razercfg-0.39/debian/rules 2017-03-28 19:12:05.000000000 +0200 @@ -3,16 +3,19 @@ export LC_ALL=C.UTF-8 export DH_VERBOSE=1 export RAZERCFG_PKG_BUILD=1 -export CFLAGS= CPPFLAGS= CXXFLAGS= LDFLAGS= override_dh_auto_configure: - cmake -DCMAKE_INSTALL_PREFIX=/usr . + dh_auto_configure -- -DLIBRAZER_SHARED=OFF + +override_dh_clean: + dh_clean + rm -rf ui/build ui/pyrazer/__pycache__ ui/setup.py override_dh_install: - dh_install --fail-missing + dh_install --fail-missing --exclude=librazer.a override_dh_installinit: dh_installinit --name=razerd %: - dh $@ --with systemd --with python3 + dh $@ --with systemd --with python3 --buildsystem=cmake diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/razercfg-0.38/librazer/CMakeLists.txt new/razercfg-0.39/librazer/CMakeLists.txt --- old/razercfg-0.38/librazer/CMakeLists.txt 2016-10-30 17:39:48.000000000 +0100 +++ new/razercfg-0.39/librazer/CMakeLists.txt 2017-03-28 19:12:05.000000000 +0200 @@ -1,6 +1,13 @@ include("${razer_SOURCE_DIR}/scripts/cmake.global") -add_library(razer SHARED +option(LIBRAZER_SHARED "Build librazer as a shared library" ON) +if (LIBRAZER_SHARED) + set(SHARED_OR_STATIC "SHARED") +else (LIBRAZER_SHARED) + set(SHARED_OR_STATIC "STATIC") +endif (LIBRAZER_SHARED) + +add_library(razer ${SHARED_OR_STATIC} buttonmapping.c profile_emulation.c librazer.c @@ -19,7 +26,8 @@ hw_naga.c hw_imperator.c hw_taipan.c - hw_mamba_tournament_edition.c) + hw_mamba_tournament_edition.c + hw_diamondback_chroma.c) set_target_properties(razer PROPERTIES COMPILE_FLAGS ${GENERIC_COMPILE_FLAGS} SOVERSION 1) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/razercfg-0.38/librazer/hw_deathadder_chroma.c new/razercfg-0.39/librazer/hw_deathadder_chroma.c --- old/razercfg-0.38/librazer/hw_deathadder_chroma.c 2016-10-30 17:39:48.000000000 +0100 +++ new/razercfg-0.39/librazer/hw_deathadder_chroma.c 2017-03-28 19:12:05.000000000 +0200 @@ -174,7 +174,7 @@ dpimappings[DEATHADDER_CHROMA_DPIMAPPINGS_NUM]; struct razer_axis axes[DEATHADDER_CHROMA_AXES_NUM]; uint16_t fw_version; - char serial[DEATHADDER_CHROMA_REQUEST_SIZE_GET_SERIAL_NO]; + char serial[DEATHADDER_CHROMA_REQUEST_SIZE_GET_SERIAL_NO + 1]; }; static uint8_t deathadder_chroma_checksum(struct deathadder_chroma_command *cmd) @@ -342,6 +342,8 @@ strncpy(drv_data->serial, (const char *)cmd.bvalue, DEATHADDER_CHROMA_REQUEST_SIZE_GET_SERIAL_NO); + drv_data->serial[DEATHADDER_CHROMA_REQUEST_SIZE_GET_SERIAL_NO] = '\0'; + return 0; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/razercfg-0.38/librazer/hw_diamondback_chroma.c new/razercfg-0.39/librazer/hw_diamondback_chroma.c --- old/razercfg-0.38/librazer/hw_diamondback_chroma.c 1970-01-01 01:00:00.000000000 +0100 +++ new/razercfg-0.39/librazer/hw_diamondback_chroma.c 2017-03-28 19:12:05.000000000 +0200 @@ -0,0 +1,881 @@ +/* + * Lowlevel hardware access for the Razer Diamondback Chroma mouse. + * + * Important notice: + * This hardware driver is based on reverse engineering, only. + * + * Copyright (C) 2015 Konrad Zemek <konrad.ze...@gmail.com> + * Copyright (C) 2016 WANG Haoan <wanghaoan.vic...@gmail.com> + * + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + */ + +#include "hw_diamondback_chroma.h" +#include "razer_private.h" + +#include <errno.h> +#include <stdlib.h> +#include <stdio.h> +#include <stdint.h> +#include <string.h> + +static enum razer_mouse_freq diamondback_chroma_freqs_list[] = +{ + RAZER_MOUSE_FREQ_125HZ, + RAZER_MOUSE_FREQ_500HZ, + RAZER_MOUSE_FREQ_1000HZ +}; + +static enum razer_mouse_res diamondback_chroma_resolution_stages_list[] = +{ + RAZER_MOUSE_RES_800DPI, + RAZER_MOUSE_RES_1800DPI, + RAZER_MOUSE_RES_3500DPI, + RAZER_MOUSE_RES_5600DPI, + RAZER_MOUSE_RES_10000DPI, + RAZER_MOUSE_RES_16000DPI +}; + +#define DIAMONDBACK_CHROMA_DEVICE_NAME "Diamondback Chroma" +#define DIAMONDBACK_CHROMA_LED_NAME "Basic" + + +enum diamondback_chroma_led_mode +{ + DIAMONDBACK_CHROMA_LED_MODE_STATIC = 0x06, + DIAMONDBACK_CHROMA_LED_MODE_BREATHING = 0x0301, // 0x0302 is breathing with 2 different colors + DIAMONDBACK_CHROMA_LED_MODE_SPECTRUM = 0x0400, + DIAMONDBACK_CHROMA_LED_MODE_WAVE = 0x0101, // 0x0102 is waving in a opposite direction + DIAMONDBACK_CHROMA_LED_MODE_REACTION = 0x0203, + DIAMONDBACK_CHROMA_LED_MODE_CUSTOMIZED = 0x0500, + DIAMONDBACK_CHROMA_LED_MODE_CUSTOMIZED_COLOR_INFO = 0x050c, // for further implementation +}; + +enum diamondback_chroma_led_state +{ + DIAMONDBACK_CHROMA_LED_STATE_OFF = 0x00, + DIAMONDBACK_CHROMA_LED_STATE_ON = 0xFF, +}; + +//for further implementation +enum diamondback_chroma_led_state_option +{ + DIAMONDBACK_CHROMA_LED_STATE_OPTION_0 = 0x00, + DIAMONDBACK_CHROMA_LED_STATE_OPTION_1 = 0x01, + DIAMONDBACK_CHROMA_LED_STATE_OPTION_2 = 0x02, + DIAMONDBACK_CHROMA_LED_STATE_OPTION_3 = 0x03, +}; + +/* + * The 6th byte of Diamondback Chroma's command seems also to be the size of arguments + * (size of arguments to read in case of read operations). It's not necessarily + * so, since some values are slightly off (i.e. bigger than the apparent size + * of the arguments). But when it's in customized mode, there will be 0x32 which is 50 bytes of information + * Experiments suggest that the value given in the 'size' byte does not matter. + * I chose to go with the values used by the Synapse driver. + */ +enum diamondback_chroma_request_size +{ + DIAMONDBACK_CHROMA_REQUEST_SIZE_INIT = 0x02, + DIAMONDBACK_CHROMA_REQUEST_SIZE_SET_RESOLUTION = 0x07, + DIAMONDBACK_CHROMA_REQUEST_SIZE_GET_FIRMWARE = 0x04, + DIAMONDBACK_CHROMA_REQUEST_SIZE_GET_SERIAL_NO = 0x16, + DIAMONDBACK_CHROMA_REQUEST_SIZE_SET_FREQUENCY = 0x01, + DIAMONDBACK_CHROMA_REQUEST_SIZE_SET_LED_STATE = 0x08, + DIAMONDBACK_CHROMA_REQUEST_SIZE_SET_LED_MODE = 0x08, + DIAMONDBACK_CHROMA_REQUEST_SIZE_SET_LED_COLOR = 0x08, +}; + +enum diamondback_chroma_request +{ + DIAMONDBACK_CHROMA_REQUEST_INIT = 0x0004, + DIAMONDBACK_CHROMA_REQUEST_SET_RESOLUTION = 0x0405, + DIAMONDBACK_CHROMA_REQUEST_GET_FIRMWARE = 0x0087, + DIAMONDBACK_CHROMA_REQUEST_GET_SERIAL_NO = 0x0082, + DIAMONDBACK_CHROMA_REQUEST_SET_FREQUENCY = 0x0005, + DIAMONDBACK_CHROMA_REQUEST_SET_LED_STATE = 0x030a, + DIAMONDBACK_CHROMA_REQUEST_SET_LED_COLOR = 0x030a, + DIAMONDBACK_CHROMA_REQUEST_SET_LED_MODE = 0x030a, + DIAMONDBACK_CHROMA_REQUEST_SET_LED_MODE_CUSTOMIZED = 0x030c, // for further implementation +}; + +enum diamondback_chroma_constants +{ + DIAMONDBACK_CHROMA_MAX_FREQUENCY = RAZER_MOUSE_FREQ_1000HZ, + DIAMONDBACK_CHROMA_MAX_RESOLUTION = RAZER_MOUSE_RES_16000DPI, + DIAMONDBACK_CHROMA_RESOLUTION_STEP = RAZER_MOUSE_RES_100DPI, + + DIAMONDBACK_CHROMA_LED_NUM = 1, + DIAMONDBACK_CHROMA_AXES_NUM = 2, + DIAMONDBACK_CHROMA_SUPPORTED_FREQ_NUM = ARRAY_SIZE(diamondback_chroma_freqs_list), + DIAMONDBACK_CHROMA_DPIMAPPINGS_NUM = ARRAY_SIZE(diamondback_chroma_resolution_stages_list), + + DIAMONDBACK_CHROMA_USB_SETUP_PACKET_VALUE = 0x300, + DIAMONDBACK_CHROMA_SUCCESS_STATUS = 0x02, + DIAMONDBACK_CHROMA_PACKET_SPACING_MS = 35, + + /* + * Experiments suggest that the value in the 'magic' byte of the command + * does not necessarily matter (e.g. the commands work when the 'magic' + * byte equals 0x77). I chose to go with the value used by the Synapse + * driver. + */ + DIAMONDBACK_CHROMA_MAGIC_BYTE = 0xFF, + + /* + * These specific arg0 bytes are used by the Synapse driver for their + * respective commands. Their value may or may not matter (e.g. matters + * in the case of LED commands, doesn't seem to matter for the + * resolution command). + */ + DIAMONDBACK_CHROMA_LED_ARG0 = 0x02, + DIAMONDBACK_CHROMA_INIT_ARG0 = 0x03, + DIAMONDBACK_CHROMA_RESOLUTION_ARG0 = 0x01, +}; + +struct diamondback_chroma_command +{ + uint8_t status; + uint8_t magic; + uint8_t padding0[3]; + uint8_t size; + be16_t request; + + union + { + uint8_t bvalue[80]; + struct + { + uint8_t padding1; + be16_t value[38]; + uint8_t padding2; + }_packed; + }_packed; + + uint8_t checksum; + uint8_t padding3; +}_packed; + +#define DIAMONDBACK_CHROMA_COMMAND_INIT \ + (struct diamondback_chroma_command) \ + { \ + .magic = DIAMONDBACK_CHROMA_MAGIC_BYTE \ + } + +struct diamondback_chroma_rgb_color +{ + uint8_t r; + uint8_t g; + uint8_t b; +}; + +struct diamondback_chroma_led +{ + enum diamondback_chroma_led_mode mode; + enum diamondback_chroma_led_state state; + enum diamondback_chroma_led_state_option option; + struct diamondback_chroma_rgb_color color; +}; + +struct diamondback_chroma_driver_data +{ + struct razer_event_spacing packet_spacing; + struct razer_mouse_profile profile; + struct razer_mouse_dpimapping *current_dpimapping; + enum razer_mouse_freq current_freq; + struct diamondback_chroma_led led; + struct razer_mouse_dpimapping dpimappings[DIAMONDBACK_CHROMA_DPIMAPPINGS_NUM]; + struct razer_axis axes[DIAMONDBACK_CHROMA_AXES_NUM]; + uint16_t fw_version; + char serial[DIAMONDBACK_CHROMA_REQUEST_SIZE_GET_SERIAL_NO + 1]; +}; + +static uint8_t diamondback_chroma_checksum(struct diamondback_chroma_command *cmd) +{ + size_t control_size; + + control_size = sizeof(cmd->size) + sizeof(cmd->request); + return razer_xor8_checksum((uint8_t *)&cmd->size, control_size + cmd->size); +} + +static int diamondback_chroma_translate_frequency(enum razer_mouse_freq freq) +{ + switch (freq) { + case RAZER_MOUSE_FREQ_UNKNOWN: + freq = RAZER_MOUSE_FREQ_500HZ; + /* fallthrough */ + case RAZER_MOUSE_FREQ_125HZ: + case RAZER_MOUSE_FREQ_500HZ: + case RAZER_MOUSE_FREQ_1000HZ: + return DIAMONDBACK_CHROMA_MAX_FREQUENCY / freq; + default: + return -EINVAL; + } +} + +static int diamondback_chroma_usb_action(struct razer_mouse *m, + enum libusb_endpoint_direction direction, + enum libusb_standard_request request, + uint16_t command, + struct diamondback_chroma_command *cmd) +{ + int err; + struct diamondback_chroma_driver_data *drv_data; + + drv_data = m->drv_data; + + razer_event_spacing_enter(&drv_data->packet_spacing); + err = libusb_control_transfer(m->usb_ctx->h, + direction | + LIBUSB_REQUEST_TYPE_CLASS | + LIBUSB_RECIPIENT_INTERFACE, + request, command, 0, + (unsigned char *)cmd, sizeof(*cmd), + RAZER_USB_TIMEOUT); + razer_event_spacing_leave(&drv_data->packet_spacing); + if (err != sizeof(*cmd)) { + razer_error("razer-diamondback-chroma: " + "USB %s 0x%01X 0x%02X failed with %d\n", + direction == LIBUSB_ENDPOINT_IN ? "read" : "write", + request, command, err); + return err; + } + + return 0; +} + +static int diamondback_chroma_send_command(struct razer_mouse *m, + struct diamondback_chroma_command *cmd) +{ + int err; + uint8_t checksum; + + cmd->checksum = diamondback_chroma_checksum(cmd); + err = diamondback_chroma_usb_action(m, LIBUSB_ENDPOINT_OUT, + LIBUSB_REQUEST_SET_CONFIGURATION, + DIAMONDBACK_CHROMA_USB_SETUP_PACKET_VALUE, cmd); + if (err) + return err; + err = diamondback_chroma_usb_action(m, LIBUSB_ENDPOINT_IN, + LIBUSB_REQUEST_CLEAR_FEATURE, + DIAMONDBACK_CHROMA_USB_SETUP_PACKET_VALUE, cmd); + if (err) + return err; + + checksum = diamondback_chroma_checksum (cmd); + if (checksum != cmd->checksum) { + razer_error("razer-diamondback-chroma: " + "Command %02X %04X bad response checksum %02X " + "(expected %02X)\n", + cmd->size, be16_to_cpu(cmd->request), + checksum, cmd->checksum); + return -EBADMSG; + } + + if (cmd->status != DIAMONDBACK_CHROMA_SUCCESS_STATUS) { + razer_error("razer-diamondback-chroma: " + "Command %02X %04X failed with %02X\n", + cmd->size, be16_to_cpu(cmd->request), cmd->status); + } + + return 0; +} + +static int diamondback_chroma_send_init_command(struct razer_mouse *m) +{ + struct diamondback_chroma_command cmd; + + cmd = DIAMONDBACK_CHROMA_COMMAND_INIT; + cmd.size = DIAMONDBACK_CHROMA_REQUEST_SIZE_INIT; + cmd.request = cpu_to_be16(DIAMONDBACK_CHROMA_REQUEST_INIT); + cmd.bvalue[0] = DIAMONDBACK_CHROMA_INIT_ARG0; + + return diamondback_chroma_send_command(m, &cmd); +} + +static int diamondback_chroma_send_set_resolution_command(struct razer_mouse *m) +{ + enum razer_mouse_res res_x, res_y; + struct diamondback_chroma_command cmd; + struct diamondback_chroma_driver_data *drv_data; + + drv_data = m->drv_data; + res_x = drv_data->current_dpimapping->res[RAZER_DIM_X]; + res_y = drv_data->current_dpimapping->res[RAZER_DIM_Y]; + + cmd = DIAMONDBACK_CHROMA_COMMAND_INIT; + cmd.size = DIAMONDBACK_CHROMA_REQUEST_SIZE_SET_RESOLUTION; + cmd.request = cpu_to_be16(DIAMONDBACK_CHROMA_REQUEST_SET_RESOLUTION); + cmd.bvalue[0] = DIAMONDBACK_CHROMA_RESOLUTION_ARG0; + cmd.value[0] = cpu_to_be16(res_x); + cmd.value[1] = cpu_to_be16(res_y); + + return diamondback_chroma_send_command(m, &cmd); +} + +static int diamondback_chroma_send_get_firmware_command(struct razer_mouse *m) +{ + int err; + uint8_t fw_major; + uint16_t fw_minor; + struct diamondback_chroma_command cmd; + struct diamondback_chroma_driver_data *drv_data; + + drv_data = m->drv_data; + + cmd = DIAMONDBACK_CHROMA_COMMAND_INIT; + cmd.size = DIAMONDBACK_CHROMA_REQUEST_SIZE_GET_FIRMWARE; + cmd.request = cpu_to_be16(DIAMONDBACK_CHROMA_REQUEST_GET_FIRMWARE); + + err = diamondback_chroma_send_command(m, &cmd); + if (err) + return err; + + fw_major = cmd.bvalue[0]; + fw_minor = be16_to_cpu(cmd.value[0]); + drv_data->fw_version = (fw_major << 8) | fw_minor; + + return 0; +} + +static int diamondback_chroma_send_get_serial_no_command(struct razer_mouse *m) +{ + int err; + struct diamondback_chroma_command cmd; + struct diamondback_chroma_driver_data *drv_data; + + drv_data = m->drv_data; + + cmd = DIAMONDBACK_CHROMA_COMMAND_INIT; + cmd.size = DIAMONDBACK_CHROMA_REQUEST_SIZE_GET_SERIAL_NO; + cmd.request = cpu_to_be16(DIAMONDBACK_CHROMA_REQUEST_GET_SERIAL_NO); + + err = diamondback_chroma_send_command(m, &cmd); + if (err) + return err; + + strncpy(drv_data->serial, (const char *)cmd.bvalue, + DIAMONDBACK_CHROMA_REQUEST_SIZE_GET_SERIAL_NO); + drv_data->serial[DIAMONDBACK_CHROMA_REQUEST_SIZE_GET_SERIAL_NO] = '\0'; + + return 0; +} + +static int diamondback_chroma_send_set_frequency_command(struct razer_mouse *m) +{ + int tfreq; + struct diamondback_chroma_command cmd; + struct diamondback_chroma_driver_data *drv_data; + + drv_data = m->drv_data; + cmd = DIAMONDBACK_CHROMA_COMMAND_INIT; + + tfreq = diamondback_chroma_translate_frequency(drv_data->current_freq); + if (tfreq < 0) + return tfreq; + + cmd.size = DIAMONDBACK_CHROMA_REQUEST_SIZE_SET_FREQUENCY; + cmd.request = cpu_to_be16(DIAMONDBACK_CHROMA_REQUEST_SET_FREQUENCY); + cmd.bvalue[0] = tfreq; + + return diamondback_chroma_send_command(m, &cmd); +} + +static struct diamondback_chroma_led *diamondback_chroma_get_led(struct diamondback_chroma_driver_data *d) +{ + return &d->led; +} + +static int diamondback_chroma_send_set_led_state_command(struct razer_mouse *m, + struct diamondback_chroma_led *led) +{ + struct diamondback_chroma_command cmd; + + cmd = DIAMONDBACK_CHROMA_COMMAND_INIT; + cmd.size = DIAMONDBACK_CHROMA_REQUEST_SIZE_SET_LED_STATE; + cmd.request = cpu_to_be16(DIAMONDBACK_CHROMA_REQUEST_SET_LED_STATE); + + if (led->mode == DIAMONDBACK_CHROMA_LED_MODE_STATIC) { + cmd.bvalue[0] = led->mode; + cmd.bvalue[1] = led->color.r; + cmd.bvalue[2] = led->color.g; + cmd.bvalue[3] = led->color.b; + } else { + uint16_t tempHex; + uint8_t tempH, tempL; + + tempHex = led->mode; + tempH = (uint8_t)((tempHex & 0xFF00) >> 8); + tempL = (uint8_t)(tempHex & 0x00FF); + cmd.bvalue[0] = tempH; + cmd.bvalue[1] = tempL; + cmd.bvalue[2] = led->color.r; + cmd.bvalue[3] = led->color.g; + cmd.bvalue[4] = led->color.b; + } + cmd.bvalue[0] &= led->state; + cmd.bvalue[1] &= led->state; + + return diamondback_chroma_send_command(m, &cmd); +} + +static int diamondback_chroma_send_set_led_mode_command(struct razer_mouse *m, + struct diamondback_chroma_led *led) +{ + struct diamondback_chroma_command cmd; + + cmd = DIAMONDBACK_CHROMA_COMMAND_INIT; + cmd.size = DIAMONDBACK_CHROMA_REQUEST_SIZE_SET_LED_MODE; + cmd.request = cpu_to_be16(DIAMONDBACK_CHROMA_REQUEST_SET_LED_MODE); + if (led->mode == DIAMONDBACK_CHROMA_LED_MODE_STATIC) { + cmd.bvalue[0] = led->mode; + cmd.bvalue[1] = led->color.r; + cmd.bvalue[2] = led->color.g; + cmd.bvalue[3] = led->color.b; + } else { + uint16_t tempHex; + uint8_t tempH, tempL; + + tempHex = led->mode; + tempH = (uint8_t)((tempHex & 0xFF00) >> 8); + tempL = (uint8_t)(tempHex & 0x00FF); + cmd.bvalue[0] = tempH; + cmd.bvalue[1] = tempL; + cmd.bvalue[2] = led->color.r; + cmd.bvalue[3] = led->color.g; + cmd.bvalue[4] = led->color.b; + } + cmd.bvalue[0] &= led->state; + cmd.bvalue[1] &= led->state; + + return diamondback_chroma_send_command(m, &cmd); +} + +static int diamondback_chroma_send_set_led_color_command(struct razer_mouse *m, + struct diamondback_chroma_led *led) +{ + struct diamondback_chroma_command cmd; + + cmd = DIAMONDBACK_CHROMA_COMMAND_INIT; + cmd.size = DIAMONDBACK_CHROMA_REQUEST_SIZE_SET_LED_COLOR; + cmd.request = cpu_to_be16(DIAMONDBACK_CHROMA_REQUEST_SET_LED_COLOR); + if (led->mode == DIAMONDBACK_CHROMA_LED_MODE_STATIC) { + cmd.bvalue[0] = led->mode; + cmd.bvalue[1] = led->color.r; + cmd.bvalue[2] = led->color.g; + cmd.bvalue[3] = led->color.b; + } else { + uint16_t tempHex; + uint8_t tempH, tempL; + + tempHex = led->mode; + tempH = (uint8_t)((tempHex & 0xFF00) >> 8); + tempL = (uint8_t)(tempHex & 0x00FF); + cmd.bvalue[0] = tempH; + cmd.bvalue[1] = tempL; + cmd.bvalue[2] = led->color.r; + cmd.bvalue[3] = led->color.g; + cmd.bvalue[4] = led->color.b; + } + cmd.bvalue[0] &= led->state; + cmd.bvalue[1] &= led->state; + + return diamondback_chroma_send_command(m, &cmd); +} + +static int diamondback_chroma_get_fw_version(struct razer_mouse *m) +{ + struct diamondback_chroma_driver_data *drv_data; + + drv_data = m->drv_data; + + return drv_data->fw_version; +} + +static struct razer_mouse_profile *diamondback_chroma_get_profiles(struct razer_mouse *m) +{ + struct diamondback_chroma_driver_data *drv_data; + + drv_data = m->drv_data; + + return &drv_data->profile; +} + +static int diamondback_chroma_supported_axes(struct razer_mouse *m, + struct razer_axis **res_ptr) +{ + struct diamondback_chroma_driver_data *drv_data; + + drv_data = m->drv_data; + *res_ptr = drv_data->axes; + + return ARRAY_SIZE(drv_data->axes); +} + +static int diamondback_chroma_supported_dpimappings(struct razer_mouse *m, + struct razer_mouse_dpimapping **res_ptr) +{ + struct diamondback_chroma_driver_data *drv_data; + + drv_data = m->drv_data; + *res_ptr = drv_data->dpimappings; + + return ARRAY_SIZE(drv_data->dpimappings); +} + +static int diamondback_chroma_supported_resolutions(struct razer_mouse *m, + enum razer_mouse_res **res_ptr) +{ + size_t i; + size_t step_number; + + step_number = DIAMONDBACK_CHROMA_MAX_RESOLUTION / DIAMONDBACK_CHROMA_RESOLUTION_STEP; + + *res_ptr = calloc(step_number, sizeof(enum razer_mouse_res)); + if (!*res_ptr) + return -ENOMEM; + for (i = 0; i < step_number; i++) + (*res_ptr)[i] = (i + 1) * DIAMONDBACK_CHROMA_RESOLUTION_STEP; + + return step_number; +} + +static int diamondback_chroma_supported_freqs(struct razer_mouse *m, + enum razer_mouse_freq **res_ptr) +{ + *res_ptr = malloc(sizeof(diamondback_chroma_freqs_list)); + if (!*res_ptr) + return -ENOMEM; + memcpy(*res_ptr, diamondback_chroma_freqs_list, sizeof(diamondback_chroma_freqs_list)); + + return DIAMONDBACK_CHROMA_SUPPORTED_FREQ_NUM; +} + +static enum razer_mouse_freq diamondback_chroma_get_freq(struct razer_mouse_profile *p) +{ + struct diamondback_chroma_driver_data *drv_data; + + drv_data = p->mouse->drv_data; + + return drv_data->current_freq; +} + +static struct razer_mouse_dpimapping *diamondback_chroma_get_dpimapping(struct razer_mouse_profile *p, + struct razer_axis *axis) +{ + struct diamondback_chroma_driver_data *drv_data; + + drv_data = p->mouse->drv_data; + + return drv_data->current_dpimapping; +} + +static int diamondback_chroma_change_dpimapping(struct razer_mouse_dpimapping *d, + enum razer_dimension dim, + enum razer_mouse_res res) +{ + struct diamondback_chroma_driver_data *drv_data; + + if (!(d->dimension_mask & (1 << dim))) + return -EINVAL; + + if (res == RAZER_MOUSE_RES_UNKNOWN) + res = RAZER_MOUSE_RES_1800DPI; + + if (res < RAZER_MOUSE_RES_100DPI || res > RAZER_MOUSE_RES_16000DPI) + return -EINVAL; + + d->res[dim] = res; + + drv_data = d->mouse->drv_data; + if (d == drv_data->current_dpimapping) + return diamondback_chroma_send_set_resolution_command(d->mouse); + + return 0; +} + +static int diamondback_chroma_led_toggle_state(struct razer_led *led, + enum razer_led_state new_state) +{ + struct diamondback_chroma_driver_data *drv_data; + struct diamondback_chroma_led *priv_led; + + drv_data = led->u.mouse->drv_data; + priv_led = diamondback_chroma_get_led(drv_data); + if (!priv_led) + return -EINVAL; + + switch (new_state) { + case RAZER_LED_UNKNOWN: + case RAZER_LED_ON: + priv_led->state = DIAMONDBACK_CHROMA_LED_STATE_ON; + break; + case RAZER_LED_OFF: + priv_led->state = DIAMONDBACK_CHROMA_LED_STATE_OFF; + break; + } + + return diamondback_chroma_send_set_led_state_command(led->u.mouse, priv_led); +} + +static int diamondback_chroma_led_change_color(struct razer_led *led, + const struct razer_rgb_color *new_color) +{ + struct diamondback_chroma_driver_data *drv_data; + struct diamondback_chroma_led *priv_led; + + drv_data = led->u.mouse->drv_data; + priv_led = diamondback_chroma_get_led(drv_data); + + if (!priv_led) + return -EINVAL; + if (priv_led->mode == DIAMONDBACK_CHROMA_LED_MODE_SPECTRUM) + return -EINVAL; + + priv_led->color = (struct diamondback_chroma_rgb_color){ + .r = new_color->r, + .g = new_color->g, + .b = new_color->b, + }; + + return diamondback_chroma_send_set_led_color_command(led->u.mouse, priv_led); +} + +static int diamondback_chroma_set_freq(struct razer_mouse_profile *p, + enum razer_mouse_freq freq) +{ + struct diamondback_chroma_driver_data *drv_data; + + if (freq == RAZER_MOUSE_FREQ_UNKNOWN) + freq = RAZER_MOUSE_FREQ_500HZ; + + if (freq != RAZER_MOUSE_FREQ_125HZ && + freq != RAZER_MOUSE_FREQ_500HZ && + freq != RAZER_MOUSE_FREQ_1000HZ) + return -EINVAL; + + drv_data = p->mouse->drv_data; + drv_data->current_freq = freq; + + return diamondback_chroma_send_set_frequency_command(p->mouse); +} + +static int diamondback_chroma_set_dpimapping(struct razer_mouse_profile *p, + struct razer_axis *axis, + struct razer_mouse_dpimapping *d) +{ + struct diamondback_chroma_driver_data *drv_data; + + if (axis && axis->id > 0) + return -EINVAL; + + drv_data = p->mouse->drv_data; + drv_data->current_dpimapping = &drv_data->dpimappings[d->nr]; + + return diamondback_chroma_send_set_resolution_command(p->mouse); +} + +static int diamondback_chroma_translate_led_mode(enum diamondback_chroma_led_mode mode) +{ + switch (mode) { + case DIAMONDBACK_CHROMA_LED_MODE_STATIC: + return RAZER_LED_MODE_STATIC; + case DIAMONDBACK_CHROMA_LED_MODE_BREATHING: + return RAZER_LED_MODE_BREATHING; + case DIAMONDBACK_CHROMA_LED_MODE_SPECTRUM: + return RAZER_LED_MODE_SPECTRUM; + case DIAMONDBACK_CHROMA_LED_MODE_WAVE: + return RAZER_LED_MODE_WAVE; + case DIAMONDBACK_CHROMA_LED_MODE_REACTION: + return RAZER_LED_MODE_REACTION; + default: + return -EINVAL; + } +} + +static int diamondback_chroma_translate_razer_led_mode(enum razer_led_mode mode) +{ + switch (mode) { + case RAZER_LED_MODE_STATIC: + return DIAMONDBACK_CHROMA_LED_MODE_STATIC; + case RAZER_LED_MODE_BREATHING: + return DIAMONDBACK_CHROMA_LED_MODE_BREATHING; + case RAZER_LED_MODE_SPECTRUM: + return DIAMONDBACK_CHROMA_LED_MODE_SPECTRUM; + case RAZER_LED_MODE_WAVE: + return DIAMONDBACK_CHROMA_LED_MODE_WAVE; + case RAZER_LED_MODE_REACTION: + return DIAMONDBACK_CHROMA_LED_MODE_REACTION; + default: + return -EINVAL; + } +} + +static int diamondback_chroma_led_set_mode(struct razer_led *led, + enum razer_led_mode new_mode) +{ + int err; + struct diamondback_chroma_driver_data *drv_data; + struct diamondback_chroma_led *priv_led; + + drv_data = led->u.mouse->drv_data; + priv_led = diamondback_chroma_get_led(drv_data); + + if (!priv_led) + return -EINVAL; + + err = diamondback_chroma_translate_razer_led_mode(new_mode); + if (err < 0) + return err; + priv_led->mode = err; + + return diamondback_chroma_send_set_led_mode_command(led->u.mouse, priv_led); +} + +static int diamondback_chroma_get_leds(struct razer_mouse *m, + struct razer_led **leds_list) +{ + unsigned int supported_modes; + enum razer_led_state led_state; + struct diamondback_chroma_driver_data *drv_data; + struct razer_led *led; + drv_data = m->drv_data; + + led = zalloc(sizeof(struct razer_led)); + if (!led) + return -ENOMEM; + + supported_modes = (1 << RAZER_LED_MODE_BREATHING) | + (1 << RAZER_LED_MODE_SPECTRUM) | + (1 << RAZER_LED_MODE_STATIC) | + (1 << RAZER_LED_MODE_WAVE) | + (1 << RAZER_LED_MODE_REACTION); + led_state = drv_data->led.state == DIAMONDBACK_CHROMA_LED_STATE_OFF ? + RAZER_LED_OFF : RAZER_LED_ON; + *led = (struct razer_led){ + .name = DIAMONDBACK_CHROMA_LED_NAME, + .state = led_state, + .u.mouse = m, + .toggle_state = diamondback_chroma_led_toggle_state, + .change_color = diamondback_chroma_led_change_color, + .set_mode = diamondback_chroma_led_set_mode, + .color = { + .r = drv_data->led.color.r, + .g = drv_data->led.color.g, + .b = drv_data->led.color.b, + .valid = 1, + }, + .supported_modes_mask = supported_modes, + .mode = diamondback_chroma_translate_led_mode(drv_data->led.mode), + }; + *leds_list = led; + + return DIAMONDBACK_CHROMA_LED_NUM; +} + +int razer_diamondback_chroma_init(struct razer_mouse *m, + struct libusb_device *usbdev) +{ + int err; + size_t i; + struct diamondback_chroma_driver_data *drv_data; + struct diamondback_chroma_led *led; + + BUILD_BUG_ON(sizeof(struct diamondback_chroma_command) != 90); + + drv_data = zalloc(sizeof(*drv_data)); + if (!drv_data) + return -ENOMEM; + + razer_event_spacing_init(&drv_data->packet_spacing, + DIAMONDBACK_CHROMA_PACKET_SPACING_MS); + + for (i = 0; i < DIAMONDBACK_CHROMA_DPIMAPPINGS_NUM; i++) { + drv_data->dpimappings[i] = (struct razer_mouse_dpimapping){ + .nr = i, + .change = diamondback_chroma_change_dpimapping, + .dimension_mask = (1 << RAZER_DIM_X) | + (1 << RAZER_DIM_Y), + .mouse = m, + }; + drv_data->dpimappings[i].res[RAZER_DIM_X] = + diamondback_chroma_resolution_stages_list[i]; + drv_data->dpimappings[i].res[RAZER_DIM_Y] = + diamondback_chroma_resolution_stages_list[i]; + } + drv_data->current_dpimapping = &drv_data->dpimappings[1]; + drv_data->current_freq = RAZER_MOUSE_FREQ_500HZ; + + drv_data->led = (struct diamondback_chroma_led){ + .mode = DIAMONDBACK_CHROMA_LED_MODE_STATIC, + .state = DIAMONDBACK_CHROMA_LED_STATE_ON, + .color = {0x00, 0xFF, 0x00}, + }; + + razer_init_axes(drv_data->axes, "X/Y", + RAZER_AXIS_INDEPENDENT_DPIMAPPING, + "Scroll", 0, NULL, 0); + + m->drv_data = drv_data; + + if ((err = razer_usb_add_used_interface(m->usb_ctx, 0, 0)) || + (err = m->claim(m))) { + free(drv_data); + return err; + } + + led = &drv_data->led; + + if ((err = diamondback_chroma_send_init_command (m)) || + (err = diamondback_chroma_send_set_resolution_command (m)) || + (err = diamondback_chroma_send_get_firmware_command (m)) || + (err = diamondback_chroma_send_get_serial_no_command (m)) || + (err = diamondback_chroma_send_set_frequency_command (m)) || + (err = diamondback_chroma_send_set_led_mode_command (m, led)) || + (err = diamondback_chroma_send_set_led_color_command (m, led))) { + m->release(m); + free(drv_data); + return err; + } + m->release(m); + + drv_data->profile = (struct razer_mouse_profile){ + .mouse = m, + .get_freq = diamondback_chroma_get_freq, + .set_freq = diamondback_chroma_set_freq, + .get_dpimapping = diamondback_chroma_get_dpimapping, + .set_dpimapping = diamondback_chroma_set_dpimapping, + }; + + razer_generic_usb_gen_idstr(usbdev, m->usb_ctx->h, + DIAMONDBACK_CHROMA_DEVICE_NAME, false, + drv_data->serial, m->idstr); + + m->type = RAZER_MOUSETYPE_DIAMONDBACK_CHROMA; + m->get_fw_version = diamondback_chroma_get_fw_version; + m->global_get_leds = diamondback_chroma_get_leds; + m->get_profiles = diamondback_chroma_get_profiles; + m->supported_axes = diamondback_chroma_supported_axes; + m->supported_resolutions = diamondback_chroma_supported_resolutions; + m->supported_freqs = diamondback_chroma_supported_freqs; + m->supported_dpimappings = diamondback_chroma_supported_dpimappings; + + return 0; +} + +void razer_diamondback_chroma_release(struct razer_mouse *m) +{ + struct diamondback_chroma_driver_data *drv_data; + + drv_data = m->drv_data; + free(drv_data); + m->drv_data = NULL; +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/razercfg-0.38/librazer/hw_diamondback_chroma.h new/razercfg-0.39/librazer/hw_diamondback_chroma.h --- old/razercfg-0.38/librazer/hw_diamondback_chroma.h 1970-01-01 01:00:00.000000000 +0100 +++ new/razercfg-0.39/librazer/hw_diamondback_chroma.h 2017-03-28 19:12:05.000000000 +0200 @@ -0,0 +1,11 @@ +#ifndef RAZER_HW_DIAMONDBACK_CHROMA_H_ +#define RAZER_HW_DIAMONDBACK_CHROMA_H_ + +#include "razer_private.h" + +int razer_diamondback_chroma_init(struct razer_mouse *m, + struct libusb_device *usbdev); + +void razer_diamondback_chroma_release(struct razer_mouse *m); + +#endif /* RAZER_HW_DIAMONDBACK_CHROMA_H_ */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/razercfg-0.38/librazer/hw_mamba_tournament_edition.c new/razercfg-0.39/librazer/hw_mamba_tournament_edition.c --- old/razercfg-0.38/librazer/hw_mamba_tournament_edition.c 2016-10-30 17:39:48.000000000 +0100 +++ new/razercfg-0.39/librazer/hw_mamba_tournament_edition.c 2017-03-28 19:12:05.000000000 +0200 @@ -194,7 +194,7 @@ struct razer_mouse_dpimapping dpimappings[MAMBA_TE_DPIMAPPINGS_NUM]; struct razer_axis axes[MAMBA_TE_AXES_NUM]; uint16_t fw_version; - char serial[MAMBA_TE_REQUEST_SIZE_GET_SERIAL_NO]; + char serial[MAMBA_TE_REQUEST_SIZE_GET_SERIAL_NO + 1]; }; static uint8_t mamba_te_checksum(struct mamba_te_command *cmd) @@ -363,6 +363,7 @@ strncpy(drv_data->serial, (const char *)cmd.bvalue, MAMBA_TE_REQUEST_SIZE_GET_SERIAL_NO); + drv_data->serial[MAMBA_TE_REQUEST_SIZE_GET_SERIAL_NO] = '\0'; return 0; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/razercfg-0.38/librazer/librazer.c new/razercfg-0.39/librazer/librazer.c --- old/razercfg-0.38/librazer/librazer.c 2016-10-30 17:39:48.000000000 +0100 +++ new/razercfg-0.39/librazer/librazer.c 2017-03-28 19:12:05.000000000 +0200 @@ -31,6 +31,7 @@ #include "hw_imperator.h" #include "hw_taipan.h" #include "hw_mamba_tournament_edition.h" +#include "hw_diamondback_chroma.h" #include <stdint.h> #include <stdlib.h> @@ -140,6 +141,12 @@ .release = razer_mamba_te_release, }; +static const struct razer_mouse_base_ops razer_diamondback_chroma_base_ops = { + .type = RAZER_MOUSETYPE_DIAMONDBACK_CHROMA, + .init = razer_diamondback_chroma_init, + .release = razer_diamondback_chroma_release, +}; + #define USBVENDOR_ANY 0xFFFF #define USBPRODUCT_ANY 0xFFFF @@ -170,6 +177,7 @@ USB_MOUSE(0x1532, 0x0017, &razer_imperator_base_ops), USB_MOUSE(0x1532, 0x0034, &razer_taipan_base_ops), USB_MOUSE(0x1532, 0x0046, &razer_mamba_te_base_ops), /*mamba tournament edition*/ + USB_MOUSE(0x1532, 0x004C, &razer_diamondback_chroma_base_ops), { 0, }, /* List end */ }; #undef USB_MOUSE diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/razercfg-0.38/librazer/librazer.h new/razercfg-0.39/librazer/librazer.h --- old/razercfg-0.38/librazer/librazer.h 2016-10-30 17:39:48.000000000 +0100 +++ new/razercfg-0.39/librazer/librazer.h 2017-03-28 19:12:05.000000000 +0200 @@ -187,7 +187,13 @@ RAZER_MOUSE_RES_8200DPI = 8200, RAZER_MOUSE_RES_8800DPI = 8800, RAZER_MOUSE_RES_9400DPI = 9400, - RAZER_MOUSE_RES_10000DPI = 10000 + RAZER_MOUSE_RES_10000DPI = 10000, + RAZER_MOUSE_RES_11000DPI = 11000, + RAZER_MOUSE_RES_12000DPI = 12000, + RAZER_MOUSE_RES_13000DPI = 13000, + RAZER_MOUSE_RES_14000DPI = 14000, + RAZER_MOUSE_RES_15000DPI = 15000, + RAZER_MOUSE_RES_16000DPI = 16000, }; /** enum razer_mouse_type @@ -200,6 +206,7 @@ * @RAZER_MOUSETYPE_IMPERATOR: An "Imperator" mouse * @RAZER_MOUSETYPE_TAIPAN: A "Taipan" mouse * @RAZER_MOUSETYPE_MAMBA_TE: A "Mamba Tournament Edition" mouse + * @RAZER_MOUSETYPE_DIAMONDBACK_CHROMA: A "Diamondback Chroma" mouse */ enum razer_mouse_type { @@ -212,6 +219,7 @@ RAZER_MOUSETYPE_IMPERATOR, RAZER_MOUSETYPE_TAIPAN, RAZER_MOUSETYPE_MAMBA_TE, + RAZER_MOUSETYPE_DIAMONDBACK_CHROMA, }; /** struct razer_button_function - A logical button function diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/razercfg-0.38/razer.conf new/razercfg-0.39/razer.conf --- old/razercfg-0.38/razer.conf 2016-10-30 17:39:48.000000000 +0100 +++ new/razercfg-0.39/razer.conf 2017-03-28 19:12:05.000000000 +0200 @@ -131,3 +131,22 @@ # Configure LEDs led=1:GlowPipe:on led=1:Scrollwheel:on + +# Razer Diamondback Chroma mouse +[Mouse:Diamondback*:*:*] + # Config section disabled? + disabled=false + + # Configure first profile + res=1:16000 + # Frequency: 125, 500, 1000 + freq=1:1000 + + # Initial profile selection + profile=1 + + # Configure LEDs + led=1:Basic:on + mode=1:Basic:static + color=1:Basic:0000FF + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/razercfg-0.38/razerd.initscript new/razercfg-0.39/razerd.initscript --- old/razercfg-0.38/razerd.initscript 2016-10-30 17:39:48.000000000 +0100 +++ new/razercfg-0.39/razerd.initscript 2017-03-28 19:12:05.000000000 +0200 @@ -1,8 +1,8 @@ #!/bin/sh ### BEGIN INIT INFO # Provides: razerd -# Required-Start: $local_fs -# Required-Stop: $local_fs +# Required-Start: $local_fs $remote_fs +# Required-Stop: $local_fs $remote_fs # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: razerd daemon diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/razercfg-0.38/razerd.service.template new/razercfg-0.39/razerd.service.template --- old/razercfg-0.38/razerd.service.template 2016-10-30 17:39:48.000000000 +0100 +++ new/razercfg-0.39/razerd.service.template 2017-03-28 19:12:05.000000000 +0200 @@ -4,8 +4,7 @@ After=local-fs.target [Service] -Type=forking -ExecStart=@CMAKE_INSTALL_PREFIX@/bin/razerd -f -B -P /run/razerd/razerd.pid +ExecStart=@CMAKE_INSTALL_PREFIX@/bin/razerd -f [Install] Alias=multi-user.target.wants/razerd.service diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/razercfg-0.38/ui/pyrazer/main.py new/razercfg-0.39/ui/pyrazer/main.py --- old/razercfg-0.38/ui/pyrazer/main.py 2016-10-30 17:39:48.000000000 +0100 +++ new/razercfg-0.39/ui/pyrazer/main.py 2017-03-28 19:12:05.000000000 +0200 @@ -28,7 +28,7 @@ import hashlib import struct -RAZER_VERSION = "0.38" +RAZER_VERSION = "0.39" class RazerEx(Exception):