Skip to content
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

Is there an ability to write python scripts for Razer devices? #70

Open
ekng331 opened this issue Oct 13, 2020 · 6 comments
Open

Is there an ability to write python scripts for Razer devices? #70

ekng331 opened this issue Oct 13, 2020 · 6 comments
Labels
help wanted Extra attention is needed

Comments

@ekng331
Copy link

ekng331 commented Oct 13, 2020

In the open razer project, there is an ability to program your keyboard using their api via python scripting. Is this feature available in the mac port as well? Here are the provided examples of the scripts: https://github.com/openrazer/openrazer/tree/master/examples

Thanks in advance!

@1kc
Copy link
Owner

1kc commented Oct 13, 2020

Hi Nanthan, currently you can call the openrazer api in this app with Javascript only. Python scripting is not yet available, but I think it is possible to implement.

Keep in mind the apis in this project are only a subset of openrazer's, as they had to be manually rewriten on Mac.

@ekng331
Copy link
Author

ekng331 commented Oct 13, 2020

Hi, is there any page where I can find the documentation?

@1kc
Copy link
Owner

1kc commented Oct 14, 2020

Its not super well documented but I can point you to the right direction.
At the bottom of https://github.com/1kc/razer-macos/blob/master/src/driver/addon.cc , you will see a list of functions that you can call from Javascript. These functions will in turn call the C driver functions for you.

For example:

import addon from '../driver'
addon.kbdSetModeStatic(new Uint8Array([0xff,0,0]))} // Set entire keyboard to red

We are not at the stage where we can set colours for individual keys yet. Maybe that is something you could look into porting over if you are interested?

@ekng331
Copy link
Author

ekng331 commented Oct 14, 2020

Yes, I am interested. Could you please give some explanation on your porting process and also maybe documentation for the original code?

@1kc
Copy link
Owner

1kc commented Oct 14, 2020

Here is a simple explanation here regarding the porting the driver code, https://github.com/1kc/razer-macos/wiki.

The process goes:

  1. Copying C functions across from https://github.com/openrazer/openrazer/blob/master/driver/razerkbd_driver.c, changing function signatures and variables accordingly. (See existing examples in https://github.com/1kc/razer-macos/blob/master/src/driver/razerkbd_driver.c)
  2. Add C++ wrappers to call these C functions in https://github.com/1kc/razer-macos/blob/master/src/driver/addon.cc, this is a Node Native Addon
  3. Call addon functions in Javascript when user intereacts with the UI (Electron and React, razer-macos/src/main/index.js)

@ekng331
Copy link
Author

ekng331 commented Oct 14, 2020

How do I set everything up to begin?

@dhobi dhobi added the help wanted Extra attention is needed label Mar 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants