Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
kirainmoe committed Aug 18, 2019
1 parent 9f76cfe commit 783ec3f
Show file tree
Hide file tree
Showing 18 changed files with 2,718 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,8 @@ typings/

# next.js build output
.next

dist
uncommit

.DS_Store
62 changes: 60 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,60 @@
# STARBEAT
Project: STAR BEAT! - An unofficial control center for Hasee Tongfang laptops on macOS.
# Project: STAR BEAT!

![build](https://img.shields.io/badge/build-passing-brightgreen.svg) ![version](https://img.shields.io/badge/version-1.0.2-9cf.svg) ![built by](https://img.shields.io/badge/built_by-Yume_Maruyama-ff69b4.svg)

基于 Electron 的、为同方模具的神舟笔记本设计的 macOS 版非官方控制中心。

An unofficial control center for Hasee Tongfang laptops on macOS.

# Early Stage

该项目尚处于初期阶段,并非最终体;目前仅支持控制键盘灯,其它功能仍然在开发中。如果你遇到任何问题或者你有什么想法,请提 issue 向我反馈。

This project is on an early stage. There is little feature in this program, including keyboard light controlling. If you meet problems or you have some ideas, please open an issue and tell me.

# Build & Run

程序使用 Electron 打包,所以体积较大。可以在[这里](https://github.com/kirainmoe/STARBEAT/releases)下载到打包好的程序。

The program is powered by Electron. You can download packed binary file in [here](https://github.com/kirainmoe/STARBEAT/releases).

```shell
# install dependencies
npm install

# start development environment
npm start

# pack binary
npm run pack
```

# Supported Devices

为神舟同方机型适配;理论支持所有搭载 ITE 控制芯片 (厂商 ID 0x048d, 设备 ID 0xce00)、ITE 版本为 0.02 的键盘;以下是测试通过的机型:

This program is designed for Hasee God-of-War models, but will theoretically work on those devices with ITE keyboard (vendor id 0x048d, device id 0xce00, ITE revision 0.02). The following are the models that are known to work:

- Z7(m)-KP7/5(G)Z
- Z7(m)-kP7/5EC


# Screenshot

![QQ20190818-235957.png](https://i.loli.net/2019/08/19/buNLSTZCQHep9Dt.png)

![QQ20190819-000025.png](https://i.loli.net/2019/08/19/MKs26o4nXgIFraz.png)

![QQ20190819-000032.png](https://i.loli.net/2019/08/19/tQhoXk6Zxy43RIM.png)

# Other

- Powered by Electron and node-hid, written in Node.js/Javascriipt
- Materialize UI Library
- Thanks to [@rodgomesc](https://github.com/rodgomesc) for his inspiration and help
- Thanks to the testing of KP7EC by QianBiXiangYang
- Logo and project name are inspired from Poppin'Party

# License

Project: STAR BEAT is MIT licensed.
Binary file added app.icns
Binary file not shown.
99 changes: 99 additions & 0 deletions colorUtils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
const initColorUtils = () => {
const hid = require('node-hid');

const vendorId = 0x048d, productId = 0xce00;
const generic = [
[0xff, 0x00, 0x00],
[0xff, 0x5a, 0x00],
[0xff, 0xb4, 0x00],
[0x00, 0xb4, 0x00],
[0x00, 0x00, 0xff],
[0x00, 0xb4, 0xff],
[0xff, 0x00, 0xff]
];
const rainbowColor = [
[0xff, 0x00, 0x00],
[0x00, 0xb4, 0x00],
[0x00, 0x00, 0xff],
[0xff, 0x00, 0xff]
];

const device = new hid.HID(vendorId, productId);

if (!device) {
console.error("No compatible device found!");
return false;
}

const sendGenericPacket = () => {
for (let i = 1; i <= 7; i++)
device.sendFeatureReport([ 0x14, 0x00, i, ...generic[i-1], 0x00, 0x00 ]);
};

const monoColor = (red, green, blue, save, block, brightness) => {
const packet = [0x14, 0x00, 0x01, red, green, blue, 0x00, 0x00],
endPacket = [0x08, 0x02, 0x01, 0x05, brightness, 0x08, 0x00, save ? 0x00 : 0x01];

if (block) { // set specific block
packet[2] = block;
device.sendFeatureReport(packet);
} else {
// keyboard has 4 discrete color areas
for (let i = 1; i <= 4; i++) {
device.sendFeatureReport(packet);
packet[2]++;
}
}
// send ending packet
device.sendFeatureReport(endPacket);
};

const breathing = (save, speed, brightness) => {
const endPacket = [0x08, 0x02, 0x02, speed, brightness, 0x08, 0x00, save ? 0x00 : 0x01];
sendGenericPacket();
device.sendFeatureReport(endPacket);
};

const wave = (save, speed, brightness, direction) => {
const endPacket = [0x08, 0x02, 0x03, speed, brightness, 0x08, direction, save ? 0x00 : 0x01];
sendGenericPacket();
device.sendFeatureReport(endPacket);
};

const rainbow = (save, brightness) => {
for (let i = 1; i <= 4; i++)
device.sendFeatureReport([0x14, 0x00, i, ...rainbowColor[i-1], 0x00, 0x00]);
const endPacket = [0x08, 0x02, 0x05, 0x05, brightness, 0x08, 0x00, save ? 0x00 : 0x01];
device.sendFeatureReport(endPacket);
};

const flash = (save, speed, brightness, direction) => {
const endPacket = [0x08, 0x02, 0x12, speed, brightness, 0x08, direction, save ? 0x00 : 0x01];
sendGenericPacket();
device.sendFeatureReport(endPacket);
};

const mix = (save, speed, brightness) => {
const endPacket = [0x08, 0x02, 0x13, speed, brightness, 0x08, 0x00, save ? 0x00 : 0x01];
sendGenericPacket();
device.sendFeatureReport(endPacket);
};

const disabler = () => {
const endPacket = [0x08, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00];
device.sendFeatureReport(endPacket);
}

return {
monoColor,
breathing,
rainbow,
wave,
flash,
mix,
device,
disabler
};
};

module.exports = initColorUtils;
17 changes: 17 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const { app, BrowserWindow } = require('electron');

const createWindow = () => {
const win = new BrowserWindow({
width: 700,
height: 420,
webPreferences: {
nodeIntegration: true
},
resizable: false
});

win.loadFile('./views/index.html');
// win.webContents.openDevTools();
};

app.on('ready', createWindow);
Loading

0 comments on commit 783ec3f

Please sign in to comment.