mirror of
https://github.com/qmk/qmk_firmware.git
synced 2025-09-03 12:22:07 +00:00
Compare commits
14 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
1ff526dac0 | ||
![]() |
e17b55e33a | ||
![]() |
f31bf1b202 | ||
![]() |
5f82b0782f | ||
![]() |
2e6959ed87 | ||
![]() |
c482a2944b | ||
![]() |
e182a38e7c | ||
![]() |
fe4581c1a1 | ||
![]() |
ddd055b1e2 | ||
![]() |
f7324ec684 | ||
![]() |
750c7c2bdb | ||
![]() |
4846c8eba0 | ||
![]() |
830bd5460c | ||
![]() |
9f54a26dc0 |
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -16,3 +16,6 @@
|
||||
[submodule "lib/lufa"]
|
||||
path = lib/lufa
|
||||
url = https://github.com/qmk/lufa
|
||||
[submodule "lib/printf"]
|
||||
path = lib/printf
|
||||
url = https://github.com/mpaland/printf.git
|
||||
|
1
Makefile
1
Makefile
@@ -567,6 +567,7 @@ ifndef SKIP_GIT
|
||||
if [ ! -e lib/chibios-contrib ]; then git submodule sync lib/chibios-contrib && git submodule update --depth 50 --init lib/chibios-contrib; fi
|
||||
if [ ! -e lib/ugfx ]; then git submodule sync lib/ugfx && git submodule update --depth 50 --init lib/ugfx; fi
|
||||
if [ ! -e lib/lufa ]; then git submodule sync lib/lufa && git submodule update --depth 50 --init lib/lufa; fi
|
||||
if [ ! -e lib/printf ]; then git submodule sync lib/printf && git submodule update --depth 50 --init lib/printf; fi
|
||||
git submodule status --recursive 2>/dev/null | \
|
||||
while IFS= read -r x; do \
|
||||
case "$$x" in \
|
||||
|
@@ -75,6 +75,7 @@
|
||||
* [Layers](feature_layers.md)
|
||||
* [One Shot Keys](one_shot_keys.md)
|
||||
* [Pointing Device](feature_pointing_device.md)
|
||||
* [Raw HID](feature_rawhid.md)
|
||||
* [Swap Hands](feature_swap_hands.md)
|
||||
* [Tap Dance](feature_tap_dance.md)
|
||||
* [Tap-Hold Configuration](tap_hold.md)
|
||||
|
65
docs/feature_rawhid.md
Normal file
65
docs/feature_rawhid.md
Normal file
@@ -0,0 +1,65 @@
|
||||
# Raw HID
|
||||
|
||||
Raw HID allows for bidirectional communication between QMK and the host computer over an HID interface. This has many potential use cases, such as switching keymaps on the fly or changing RGB LED colors and modes.
|
||||
|
||||
There are two main components to getting raw HID working with your keyboard.
|
||||
|
||||
## Keyboard firmware
|
||||
|
||||
The implementation is fairly straightforward for the firmware.
|
||||
In your `rules.mk` add:
|
||||
|
||||
```make
|
||||
RAW_ENABLE = yes
|
||||
```
|
||||
|
||||
In your `keymap.c` include `"raw_hid.h"` and implement the following:
|
||||
|
||||
```C
|
||||
void raw_hid_receive(uint8_t *data, uint8_t length) {
|
||||
// Your code goes here. data is the packet received from host.
|
||||
}
|
||||
```
|
||||
|
||||
The `"raw_hid.h"` header also declares `void raw_hid_send(uint8_t *data, uint8_t length);` which allows sending packets from keyboard to host. As an example, it can also be used for debugging when building your host application by returning all data back to the host.
|
||||
|
||||
```C
|
||||
void raw_hid_receive(uint8_t *data, uint8_t length) {
|
||||
raw_hid_send(data, length);
|
||||
}
|
||||
```
|
||||
|
||||
`raw_hid_receive` can receive variable size packets from host with maximum length `RAW_EPSIZE`. `raw_hid_send` on the other hand can send packets to host of exactly `RAW_EPSIZE` length, therefore it should be used with data of length `RAW_EPSIZE`.
|
||||
|
||||
Make sure to flash raw enabled firmware before proceeding with working on the host side.
|
||||
|
||||
## Host (Windows/macOS/Linux)
|
||||
|
||||
This is the more complicated part as it will require some digging.
|
||||
|
||||
To connect your host computer to your keyboard with raw HID you need four pieces of information about your keyboard:
|
||||
|
||||
1. Vendor ID
|
||||
2. Product ID
|
||||
3. Usage Page
|
||||
4. Usage
|
||||
|
||||
The first two can easily be found in your keyboard's `config.h` in the keyboard's main directory under `VENDOR_ID` and `PRODUCT_ID`. **Usage Page** is **`0xFF60`** and **Usage** is **`0x0061`**.
|
||||
|
||||
### Building your host
|
||||
|
||||
You can build your host using any language that has an available HID implementation library if you don't wish to make your own. The ones we know of for popular languages are:
|
||||
|
||||
* Node: [node-hid](https://github.com/node-hid/node-hid).
|
||||
* C: [hidapi](https://github.com/libusb/hidapi).
|
||||
* Java: [purejavahidapi](https://github.com/nyholku/purejavahidapi) and [hid4java](https://github.com/gary-rowe/hid4java).
|
||||
* Python: [pyhidapi](https://pypi.org/project/hid/).
|
||||
|
||||
This is not an exhaustive cross-platform list but should get you started. There are no special requirements for using raw HID so any HID library should work.
|
||||
|
||||
Now that you have all four pieces of information required to open HID interface to your keyboard. All you need to do is use your library's available functions to open the device with its ID parameters.
|
||||
|
||||
Note that Vendor ID and Product ID are not actually required to open the device. They are used only to filter to a specific device out of the many HID devices you have plugged in. Many libraries will give you the option to open the device using Product Name or Manufacturer Name instead, `node-hid` being a prime example. This will create issues for devices with builtin USB Hub or any extra HID interfaces where you will have multiple interfaces with the same name or from the same manufacturer. The Vendor ID together with Product ID create a unique designation to a single interface and will not exhibit this problem. Therefore, even if your library doesn't require you to, it is best to use them to avoid issues.
|
||||
Unlike Vendor ID and Product ID though, Usage Page and Usage are necessary for successful communication.
|
||||
|
||||
It should go without saying that regardless of the library you're using, you should always make sure to close the interface when finished. Depending on the operating system and your particular environment there may be issues connecting to it again afterwards with another client or another instance of the same client if it's not explicitly closed.
|
@@ -32,7 +32,7 @@
|
||||
|
||||
// Moved pages
|
||||
'/adding_a_keyboard_to_qmk': '/hardware_keyboard_guidelines',
|
||||
'/build_environment_setup': '/getting_started_build_tools',
|
||||
'/build_environment_setup': '/newbs_getting_started',
|
||||
'/cli_dev_configuration': '/cli_configuration',
|
||||
'/dynamic_macros': '/feature_dynamic_macros',
|
||||
'/feature_common_shortcuts': '/feature_advanced_keycodes',
|
||||
@@ -45,6 +45,7 @@
|
||||
'/tap_dance': '/feature_tap_dance',
|
||||
'/unicode': '/feature_unicode',
|
||||
'/python_development': '/cli_development',
|
||||
'/getting_started_build_tools':'/newbs_getting_started',
|
||||
},
|
||||
basePath: '/',
|
||||
name: 'QMK Firmware',
|
||||
|
163
docs/ja/feature_haptic_feedback.md
Normal file
163
docs/ja/feature_haptic_feedback.md
Normal file
@@ -0,0 +1,163 @@
|
||||
# 触覚フィードバック
|
||||
|
||||
<!---
|
||||
original document: 0.8.123:docs/feature_haptic_feedback.md
|
||||
git diff 0.8.123 HEAD -- docs/feature_haptic_feedback.md | cat
|
||||
-->
|
||||
|
||||
## 触覚フィードバック の rules.mk オプション
|
||||
|
||||
現在のところ、`rules.mk` で触覚フィードバック用に以下のオプションを利用可能です:
|
||||
|
||||
`HAPTIC_ENABLE += DRV2605L`
|
||||
|
||||
`HAPTIC_ENABLE += SOLENOID`
|
||||
|
||||
## サポートされる既知のハードウェア
|
||||
|
||||
| 名前 | 説明 |
|
||||
|--------------------|-------------------------------------------------|
|
||||
| [LV061228B-L65-A](https://www.digikey.com/product-detail/en/jinlong-machinery-electronics-inc/LV061228B-L65-A/1670-1050-ND/7732325) | z-axis 2v LRA |
|
||||
| [Mini Motor Disc](https://www.adafruit.com/product/1201) | small 2-5v ERM |
|
||||
|
||||
## 触覚キーコード
|
||||
|
||||
以下のキーコードは、選択した触覚メカニズムに依存して動作するかどうか決まります。
|
||||
|
||||
| 名前 | 説明 |
|
||||
|-----------|-------------------------------------------------------|
|
||||
| `HPT_ON` | 触覚フィードバックをオン |
|
||||
| `HPT_OFF` | 触覚フィードバックをオフ |
|
||||
| `HPT_TOG` | 触覚フィードバックのオン/オフを切り替え |
|
||||
| `HPT_RST` | 触覚フィードバック設定をデフォルトに戻す |
|
||||
| `HPT_FBK` | キー押下またはリリースまたはその両方でフィードバックを切り替え |
|
||||
| `HPT_BUZ` | ソレノイドの振動のオン/オフを切り替え |
|
||||
| `HPT_MODI` | 次の DRV2605L 波形に移動 |
|
||||
| `HPT_MODD` | 前の DRV2605L 波形に移動 |
|
||||
| `HPT_CONT` | 連続触覚モードのオン/オフを切り替え |
|
||||
| `HPT_CONI` | DRV2605L の連続触覚強度を増加 |
|
||||
| `HPT_COND` | DRV2605L の連続触覚強度を減少 |
|
||||
| `HPT_DWLI` | ソレノイドの滞留時間を増加 |
|
||||
| `HPT_DWLD` | ソレノイドの滞留時間を減少 |
|
||||
|
||||
### ソレノイド
|
||||
|
||||
ほとんどの MCU はソレノイドのコイルを駆動するために必要な電流を供給できないため、最初に MOSFET を介してソレノイドを駆動する回路を構築する必要があります。
|
||||
|
||||
[Adafruit が提供する配線図](https://playground.arduino.cc/uploads/Learning/solenoid_driver.pdf)
|
||||
|
||||
|
||||
| 設定 | デフォルト | 説明 |
|
||||
|--------------------------|---------------|-------------------------------------------------------|
|
||||
| `SOLENOID_PIN` | *定義なし* | ソレノイドが接続されているピンを設定する。 |
|
||||
| `SOLENOID_DEFAULT_DWELL` | `12` ms | ソレノイドのデフォルトの滞留時間を設定する。 |
|
||||
| `SOLENOID_MIN_DWELL` | `4` ms | 滞留時間の下限を設定する。 |
|
||||
| `SOLENOID_MAX_DWELL` | `100` ms | 滞留時間の上限を設定する。 |
|
||||
|
||||
?> 滞留時間とは、「プランジャー」が作動したままになる時間です。滞留時間により、ソレノイドの音が変わります。
|
||||
|
||||
ブートローダ実行中に一部のピンが給電されているかもしれず (例えば、STM32F303 チップ上の A13)、そうすると書き込みプロセスの間ずっとソレノイドがオン状態になることに注意してください。これはソレノイドを加熱し損傷を与えるかもしれません。ソレノイドが接続されているピンがブートローダ/DFU 実行中にソレノイドをオンにしていることが分かった場合は、他のピンを選択してください。
|
||||
|
||||
### DRV2605L
|
||||
|
||||
DRV2605Lは i2c プロトコルで制御され、SDA および SCL ピンに接続する必要があります。これらは使用する MCU によって異なります。
|
||||
|
||||
#### フィードバックモータのセットアップ
|
||||
|
||||
このドライバは2つの異なるフィードバックモータをサポートします。選択したモータに基づいて、`config.h` で以下を設定します。
|
||||
|
||||
##### ERM
|
||||
|
||||
偏心回転質量振動モータ (ERM) は偏りのある重りが取り付けられたモータで、駆動信号が取り付けられると偏りのある重りが回転し、正弦波が振動に変換されます。
|
||||
|
||||
```
|
||||
#define FB_ERM_LRA 0
|
||||
#define FB_BRAKEFACTOR 3 /* For 1x:0, 2x:1, 3x:2, 4x:3, 6x:4, 8x:5, 16x:6, Disable Braking:7 */
|
||||
#define FB_LOOPGAIN 1 /* For Low:0, Medium:1, High:2, Very High:3 */
|
||||
|
||||
/* 特定のモータに最適な設定については、データシートを参照してください。*/
|
||||
#define RATED_VOLTAGE 3
|
||||
#define V_PEAK 5
|
||||
```
|
||||
##### LRA
|
||||
|
||||
線形共振アクチュエータ (LRA、線形バイブレータとしても知られています)は、ERM と異なります。LRA は重りと磁石をバネで吊るしたものとボイスコイルで構成されています。駆動信号が印加されるとされると、重りは単一の軸で振動します (左右または上下)。重りはバネに取り付けられているため、特定の周波数で共振効果があります。この周波数は LRA が最も効率的に動作する箇所です。この周波数の推奨範囲については、モータのデータシートを参照してください。
|
||||
|
||||
```
|
||||
#define FB_ERM_LRA 1
|
||||
#define FB_BRAKEFACTOR 3 /* For 1x:0, 2x:1, 3x:2, 4x:3, 6x:4, 8x:5, 16x:6, Disable Braking:7 */
|
||||
#define FB_LOOPGAIN 1 /* For Low:0, Medium:1, High:2, Very High:3 */
|
||||
|
||||
/* 特定のモータに最適な設定については、データシートを参照してください。*/
|
||||
#define RATED_VOLTAGE 2
|
||||
#define V_PEAK 2.8
|
||||
#define V_RMS 2.0
|
||||
#define V_PEAK 2.1
|
||||
#define F_LRA 205 /* 共振周波数 */
|
||||
```
|
||||
|
||||
#### DRV2605L 波形ライブラリ
|
||||
|
||||
DRV2605L には呼び出して再生できる様々な波形シーケンスのプリロードライブラリが同梱されています。マクロを書く場合、これらの波形は `DRV_pulse(*sequence name or number*)` を使って再生することができます
|
||||
|
||||
データシートの波形シーケンスのリスト
|
||||
|
||||
| seq# | シーケンス名 | seq# | シーケンス名 | seq# | シーケンス名 |
|
||||
|-----|---------------------|-----|-----------------------------------|-----|--------------------------------------|
|
||||
| 1 | strong_click | 43 | lg_dblclick_med_60 | 85 | transition_rampup_med_smooth2 |
|
||||
| 2 | strong_click_60 | 44 | lg_dblsharp_tick | 86 | transition_rampup_short_smooth1 |
|
||||
| 3 | strong_click_30 | 45 | lg_dblsharp_tick_80 | 87 | transition_rampup_short_smooth2 |
|
||||
| 4 | sharp_click | 46 | lg_dblsharp_tick_60 | 88 | transition_rampup_long_sharp1 |
|
||||
| 5 | sharp_click_60 | 47 | buzz | 89 | transition_rampup_long_sharp2 |
|
||||
| 6 | sharp_click_30 | 48 | buzz_80 | 90 | transition_rampup_med_sharp1 |
|
||||
| 7 | soft_bump | 49 | buzz_60 | 91 | transition_rampup_med_sharp2 |
|
||||
| 8 | soft_bump_60 | 50 | buzz_40 | 92 | transition_rampup_short_sharp1 |
|
||||
| 9 | soft_bump_30 | 51 | buzz_20 | 93 | transition_rampup_short_sharp2 |
|
||||
| 10 | dbl_click | 52 | pulsing_strong | 94 | transition_rampdown_long_smooth1_50 |
|
||||
| 11 | dbl_click_60 | 53 | pulsing_strong_80 | 95 | transition_rampdown_long_smooth2_50 |
|
||||
| 12 | trp_click | 54 | pulsing_medium | 96 | transition_rampdown_med_smooth1_50 |
|
||||
| 13 | soft_fuzz | 55 | pulsing_medium_80 | 97 | transition_rampdown_med_smooth2_50 |
|
||||
| 14 | strong_buzz | 56 | pulsing_sharp | 98 | transition_rampdown_short_smooth1_50 |
|
||||
| 15 | alert_750ms | 57 | pulsing_sharp_80 | 99 | transition_rampdown_short_smooth2_50 |
|
||||
| 16 | alert_1000ms | 58 | transition_click | 100 | transition_rampdown_long_sharp1_50 |
|
||||
| 17 | strong_click1 | 59 | transition_click_80 | 101 | transition_rampdown_long_sharp2_50 |
|
||||
| 18 | strong_click2_80 | 60 | transition_click_60 | 102 | transition_rampdown_med_sharp1_50 |
|
||||
| 19 | strong_click3_60 | 61 | transition_click_40 | 103 | transition_rampdown_med_sharp2_50 |
|
||||
| 20 | strong_click4_30 | 62 | transition_click_20 | 104 | transition_rampdown_short_sharp1_50 |
|
||||
| 21 | medium_click1 | 63 | transition_click_10 | 105 | transition_rampdown_short_sharp2_50 |
|
||||
| 22 | medium_click2_80 | 64 | transition_hum | 106 | transition_rampup_long_smooth1_50 |
|
||||
| 23 | medium_click3_60 | 65 | transition_hum_80 | 107 | transition_rampup_long_smooth2_50 |
|
||||
| 24 | sharp_tick1 | 66 | transition_hum_60 | 108 | transition_rampup_med_smooth1_50 |
|
||||
| 25 | sharp_tick2_80 | 67 | transition_hum_40 | 109 | transition_rampup_med_smooth2_50 |
|
||||
| 26 | sharp_tick3_60 | 68 | transition_hum_20 | 110 | transition_rampup_short_smooth1_50 |
|
||||
| 27 | sh_dblclick_str | 69 | transition_hum_10 | 111 | transition_rampup_short_smooth2_50 |
|
||||
| 28 | sh_dblclick_str_80 | 70 | transition_rampdown_long_smooth1 | 112 | transition_rampup_long_sharp1_50 |
|
||||
| 29 | sh_dblclick_str_60 | 71 | transition_rampdown_long_smooth2 | 113 | transition_rampup_long_sharp2_50 |
|
||||
| 30 | sh_dblclick_str_30 | 72 | transition_rampdown_med_smooth1 | 114 | transition_rampup_med_sharp1_50 |
|
||||
| 31 | sh_dblclick_med | 73 | transition_rampdown_med_smooth2 | 115 | transition_rampup_med_sharp2_50 |
|
||||
| 32 | sh_dblclick_med_80 | 74 | transition_rampdown_short_smooth1 | 116 | transition_rampup_short_sharp1_50 |
|
||||
| 33 | sh_dblclick_med_60 | 75 | transition_rampdown_short_smooth2 | 117 | transition_rampup_short_sharp2_50 |
|
||||
| 34 | sh_dblsharp_tick | 76 | transition_rampdown_long_sharp1 | 118 | long_buzz_for_programmatic_stopping |
|
||||
| 35 | sh_dblsharp_tick_80 | 77 | transition_rampdown_long_sharp2 | 119 | smooth_hum1_50 |
|
||||
| 36 | sh_dblsharp_tick_60 | 78 | transition_rampdown_med_sharp1 | 120 | smooth_hum2_40 |
|
||||
| 37 | lg_dblclick_str | 79 | transition_rampdown_med_sharp2 | 121 | smooth_hum3_30 |
|
||||
| 38 | lg_dblclick_str_80 | 80 | transition_rampdown_short_sharp1 | 122 | smooth_hum4_20 |
|
||||
| 39 | lg_dblclick_str_60 | 81 | transition_rampdown_short_sharp2 | 123 | smooth_hum5_10 |
|
||||
| 40 | lg_dblclick_str_30 | 82 | transition_rampup_long_smooth1 | | |
|
||||
| 41 | lg_dblclick_med | 83 | transition_rampup_long_smooth2 | | |
|
||||
| 42 | lg_dblclick_med_80 | 84 | transition_rampup_med_smooth1 | | |
|
||||
### オプションの DRV2605L の定義
|
||||
|
||||
```
|
||||
#define DRV_GREETING *sequence name or number*
|
||||
```
|
||||
触覚フィードバッグが有効な場合、キーボード起動時に特定のシーケンスに合わせて振動します。以下の定義を使って選択することができます:
|
||||
|
||||
```
|
||||
#define DRV_MODE_DEFAULT *sequence name or number*
|
||||
```
|
||||
これにより HPT_RST がアクティブモードとして設定するシーケンスを設定します。未定義の場合、HPT_RST が押された時にモードが 1 に設定されます。
|
||||
|
||||
### DRV2605L 連続触覚モード
|
||||
|
||||
このモードは強さを増減するオプションを使って連続触覚フィードバッグを設定します。
|
27
docs/ja/feature_key_lock.md
Normal file
27
docs/ja/feature_key_lock.md
Normal file
@@ -0,0 +1,27 @@
|
||||
# キーロック
|
||||
|
||||
<!---
|
||||
original document: 0.8.134:docs/feature_key_lock.md
|
||||
git diff 0.8.134 HEAD -- docs/feature_key_lock.md | cat
|
||||
-->
|
||||
|
||||
特定のキーを長時間押すことが必要になる場合があります。キーロックは次に押すキーを押したままにします。もう一度押すと、リリースされます。
|
||||
|
||||
いくつかの文を全て大文字で入力する必要があるとしましょう。`KC_LOCK` を押し、次にシフトを押します。これで、シフトは次にタップするまで押していると見なされます。キーロックを Caps Lock と考えることができますが、さらに強力です。
|
||||
|
||||
## 使用法
|
||||
|
||||
最初に `rules.mk` で `KEY_LOCK_ENABLE = yes` を設定することでキーロックを有効にします。次に、キーマップでキーを選択し、それをキーコード `KC_LOCK` に割り当てます。
|
||||
|
||||
## キーコード
|
||||
|
||||
| キーコード | 説明 |
|
||||
|---------|--------------------------------------------------------------|
|
||||
| `KC_LOCK` | キーが再び押されるまで次のキーを押したままにします。 |
|
||||
|
||||
## 注意事項
|
||||
|
||||
キーロックは、標準アクションキーと[ワンショットモディファイア](ja/one_shot_keys.md)キー (例えば、Shift を `OSM(KC_LSFT)` と定義した場合)のみを押し続けることができます。
|
||||
これは、QMK の特殊機能(ワンショットモディファイアを除く)、または `KC_LPRN` のような shift を押されたキーのバージョンは含みません。[基本的なキーコード](ja/keycodes_basic.md)リストにある場合、押したままにすることができます。
|
||||
|
||||
レイヤーの切り替えは、キーロックを解除しません。
|
@@ -3,9 +3,9 @@
|
||||
#include "config_common.h"
|
||||
|
||||
/* USB Device descriptor parameter */
|
||||
#define VENDOR_ID 0xFEED
|
||||
#define PRODUCT_ID 0xFADE
|
||||
#define DEVICE_VER 0x0001
|
||||
#define VENDOR_ID 0x5058 // "PX"
|
||||
#define PRODUCT_ID 0x4250 // "BP"
|
||||
#define DEVICE_VER 0x1001
|
||||
#define MANUFACTURER Pixlup
|
||||
#define PRODUCT Blackplum Keeb
|
||||
#define DESCRIPTION Blackplum 68 Percent Mechanical Keyboard
|
||||
|
38
keyboards/blackplum/keymaps/via/keymap.c
Normal file
38
keyboards/blackplum/keymaps/via/keymap.c
Normal file
@@ -0,0 +1,38 @@
|
||||
#include QMK_KEYBOARD_H
|
||||
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
[0] = LAYOUT_68_ansi(
|
||||
KC_GESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_INS, KC_PGUP,\
|
||||
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_DEL, KC_PGDOWN,\
|
||||
KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT,\
|
||||
KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP,\
|
||||
KC_LCTL , KC_LGUI , KC_LALT , KC_SPC , KC_RALT , MO(1) , KC_RCTL, KC_LEFT, KC_DOWN, KC_RIGHT
|
||||
),
|
||||
|
||||
[1] = LAYOUT_68_ansi(
|
||||
KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_TRNS, KC_MPLY, KC_HOME,\
|
||||
KC_TRNS, RGB_MOD, RGB_HUI, RGB_SAI, RGB_VAI, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PSCR, KC_SLCK, KC_PAUSE, KC_TRNS, KC_MUTE, KC_END,\
|
||||
KC_TRNS, RGB_TOG, RGB_HUD, RGB_SAD, RGB_VAD, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,\
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_VOLU,\
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, RESET, KC_TRNS, KC_TRNS, KC_TRNS, KC_MPRV, KC_VOLD, KC_MNXT
|
||||
),
|
||||
|
||||
[2] = LAYOUT_68_ansi(
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,\
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,\
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,\
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,\
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS
|
||||
),
|
||||
|
||||
[3] = LAYOUT_68_ansi(
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,\
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,\
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,\
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,\
|
||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS
|
||||
)
|
||||
|
||||
};
|
||||
|
||||
|
2
keyboards/blackplum/keymaps/via/rules.mk
Normal file
2
keyboards/blackplum/keymaps/via/rules.mk
Normal file
@@ -0,0 +1,2 @@
|
||||
VIA_ENABLE = yes
|
||||
LTO_ENABLE = yes
|
@@ -17,8 +17,8 @@ BOOTLOADER = bootloadHID
|
||||
BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration
|
||||
MOUSEKEY_ENABLE = no # Mouse keys
|
||||
EXTRAKEY_ENABLE = yes # Audio control and System control
|
||||
CONSOLE_ENABLE = yes # Console for debug
|
||||
COMMAND_ENABLE = yes # Commands for debug and configuration
|
||||
CONSOLE_ENABLE = no # Console for debug
|
||||
COMMAND_ENABLE = no # Commands for debug and configuration
|
||||
BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality
|
||||
RGBLIGHT_ENABLE = yes # Enable keyboard RGB underglow
|
||||
WS2812_DRIVER = i2c
|
||||
|
60
keyboards/xd002/config.h
Normal file
60
keyboards/xd002/config.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/* Copyright 2020 zvecr<git@zvecr.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.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "config_common.h"
|
||||
|
||||
/* USB Device descriptor parameter */
|
||||
#define VENDOR_ID 0x7844 // "XD"
|
||||
#define PRODUCT_ID 0x0202
|
||||
#define DEVICE_VER 0x0001
|
||||
#define MANUFACTURER XIUDI
|
||||
#define PRODUCT XD002
|
||||
|
||||
/* matrix size */
|
||||
#define MATRIX_ROWS 1
|
||||
#define MATRIX_COLS 2
|
||||
|
||||
/*
|
||||
* Keyboard Matrix Assignments
|
||||
*
|
||||
* On this board we have direct connection: no diodes.
|
||||
*/
|
||||
#define DIRECT_PINS {{ B0, B1 }}
|
||||
|
||||
/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */
|
||||
#define DEBOUNCE 5
|
||||
|
||||
#define RGBLED_NUM 2
|
||||
#define RGB_DI_PIN B2
|
||||
|
||||
// Save as much space as we can...
|
||||
#define LAYER_STATE_8BIT
|
||||
#define NO_ACTION_LAYER
|
||||
#define NO_ACTION_TAPPING
|
||||
#define NO_ACTION_ONESHOT
|
||||
#define NO_RESET
|
||||
|
||||
// usbconfig.h overrides
|
||||
#define USB_CFG_IOPORTNAME B
|
||||
#define USB_CFG_DMINUS_BIT 3
|
||||
#define USB_CFG_DPLUS_BIT 4
|
||||
#define USB_COUNT_SOF 0
|
||||
#define USB_INTR_CFG PCMSK
|
||||
#define USB_INTR_CFG_SET (1<<USB_CFG_DPLUS_BIT)
|
||||
#define USB_INTR_ENABLE_BIT PCIE
|
||||
#define USB_INTR_PENDING_BIT PCIF
|
||||
#define USB_INTR_VECTOR SIG_PIN_CHANGE
|
16
keyboards/xd002/info.json
Normal file
16
keyboards/xd002/info.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"keyboard_name": "xd002",
|
||||
"url": "https://kprepublic.com/products/xd002-xiudi-2-custom-mechanical-keyboard-2-keys-underglow-and-switch-rgb-pcb-programmed-hot-swappable-macro-key-aluminum-case",
|
||||
"maintainer": "zvecr",
|
||||
"width": 2,
|
||||
"height": 1,
|
||||
"layouts": {
|
||||
"LAYOUT": {
|
||||
"key_count": 2,
|
||||
"layout": [
|
||||
{"x":0, "y":0},
|
||||
{"x":1, "y":0}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
7
keyboards/xd002/keymaps/default/keymap.c
Normal file
7
keyboards/xd002/keymaps/default/keymap.c
Normal file
@@ -0,0 +1,7 @@
|
||||
#include QMK_KEYBOARD_H
|
||||
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
[0] = LAYOUT(
|
||||
KC_A, KC_B
|
||||
)
|
||||
};
|
46
keyboards/xd002/keymaps/rgb/keymap.c
Normal file
46
keyboards/xd002/keymaps/rgb/keymap.c
Normal file
@@ -0,0 +1,46 @@
|
||||
#include QMK_KEYBOARD_H
|
||||
|
||||
// Defines the keycodes used by our macros in process_record_user
|
||||
enum custom_keycodes {
|
||||
QMKURL = SAFE_RANGE,
|
||||
};
|
||||
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
[0] = LAYOUT(
|
||||
RGB_HUI, QMKURL
|
||||
)
|
||||
};
|
||||
|
||||
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||
if (record->event.pressed) {
|
||||
switch (keycode) {
|
||||
case QMKURL:
|
||||
// Using SEND_STRING here adds 400bytes ...
|
||||
// SEND_STRING("https://qmk.fm/" SS_TAP(X_ENTER));
|
||||
tap_code(KC_H);
|
||||
tap_code(KC_T);
|
||||
tap_code(KC_T);
|
||||
tap_code(KC_P);
|
||||
tap_code(KC_S);
|
||||
tap_code16(KC_COLON);
|
||||
tap_code(KC_SLASH);
|
||||
tap_code(KC_SLASH);
|
||||
tap_code(KC_Q);
|
||||
tap_code(KC_M);
|
||||
tap_code(KC_K);
|
||||
tap_code(KC_DOT);
|
||||
tap_code(KC_F);
|
||||
tap_code(KC_M);
|
||||
tap_code(KC_SLASH);
|
||||
tap_code(KC_ENTER);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void keyboard_post_init_user(void) {
|
||||
rgblight_enable_noeeprom(); // enables Rgb, without saving settings
|
||||
rgblight_sethsv_noeeprom(180, 255, 255); // sets the color to teal/cyan without saving
|
||||
rgblight_mode_noeeprom(RGBLIGHT_MODE_STATIC_LIGHT); // sets mode to Fast breathing without saving
|
||||
}
|
1
keyboards/xd002/keymaps/rgb/rules.mk
Normal file
1
keyboards/xd002/keymaps/rgb/rules.mk
Normal file
@@ -0,0 +1 @@
|
||||
RGBLIGHT_ENABLE = yes
|
31
keyboards/xd002/keymaps/rgb_lite/keymap.c
Normal file
31
keyboards/xd002/keymaps/rgb_lite/keymap.c
Normal file
@@ -0,0 +1,31 @@
|
||||
#include QMK_KEYBOARD_H
|
||||
#include "rgblite.h"
|
||||
|
||||
// Defines the keycodes used by our macros in process_record_user
|
||||
enum custom_keycodes {
|
||||
QMKURL = SAFE_RANGE,
|
||||
};
|
||||
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
[0] = LAYOUT(
|
||||
RGB_HUI, QMKURL
|
||||
)
|
||||
};
|
||||
|
||||
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||
if (record->event.pressed) {
|
||||
switch (keycode) {
|
||||
case RGB_HUI:
|
||||
rgblight_increase_hue();
|
||||
break;
|
||||
case QMKURL:
|
||||
SEND_STRING("https://qmk.fm/" SS_TAP(X_ENTER));
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void keyboard_post_init_user(void) {
|
||||
rgblight_increase_hue();
|
||||
}
|
26
keyboards/xd002/keymaps/rgb_lite/rgblite.h
Normal file
26
keyboards/xd002/keymaps/rgb_lite/rgblite.h
Normal file
@@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include "ws2812.h"
|
||||
#include "rgblight_list.h"
|
||||
|
||||
static inline void rgblight_setrgb(uint8_t _r, uint8_t _g, uint8_t _b) {
|
||||
LED_TYPE leds[RGBLED_NUM] = {{.r = _r, .g = _g, .b = _b}, {.r = _r, .g = _g, .b = _b}};
|
||||
ws2812_setleds(leds, RGBLED_NUM);
|
||||
}
|
||||
|
||||
static void rgblight_increase_hue(void) {
|
||||
static uint8_t state = 0;
|
||||
|
||||
state = (state + 1) % 3;
|
||||
switch (state) {
|
||||
case 1:
|
||||
rgblight_setrgb_red();
|
||||
break;
|
||||
case 2:
|
||||
rgblight_setrgb_blue();
|
||||
break;
|
||||
default:
|
||||
rgblight_setrgb_green();
|
||||
break;
|
||||
}
|
||||
}
|
1
keyboards/xd002/keymaps/rgb_lite/rules.mk
Normal file
1
keyboards/xd002/keymaps/rgb_lite/rules.mk
Normal file
@@ -0,0 +1 @@
|
||||
SRC += ws2812.c
|
3
keyboards/xd002/keymaps/tap_dance/config.h
Normal file
3
keyboards/xd002/keymaps/tap_dance/config.h
Normal file
@@ -0,0 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#define TAPPING_TERM 500
|
19
keyboards/xd002/keymaps/tap_dance/keymap.c
Normal file
19
keyboards/xd002/keymaps/tap_dance/keymap.c
Normal file
@@ -0,0 +1,19 @@
|
||||
#include QMK_KEYBOARD_H
|
||||
|
||||
enum layers {
|
||||
_BASE = 0,
|
||||
};
|
||||
|
||||
enum {
|
||||
TD_BC = 0
|
||||
};
|
||||
|
||||
qk_tap_dance_action_t tap_dance_actions[] = {
|
||||
[TD_BC] = ACTION_TAP_DANCE_DOUBLE(KC_B, KC_C)
|
||||
};
|
||||
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
[_BASE] = LAYOUT(
|
||||
KC_A, TD(TD_BC)
|
||||
)
|
||||
};
|
1
keyboards/xd002/keymaps/tap_dance/rules.mk
Normal file
1
keyboards/xd002/keymaps/tap_dance/rules.mk
Normal file
@@ -0,0 +1 @@
|
||||
TAP_DANCE_ENABLE = yes
|
7
keyboards/xd002/keymaps/volume/keymap.c
Normal file
7
keyboards/xd002/keymaps/volume/keymap.c
Normal file
@@ -0,0 +1,7 @@
|
||||
#include QMK_KEYBOARD_H
|
||||
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
[0] = LAYOUT(
|
||||
KC_VOLU, KC_VOLD
|
||||
)
|
||||
};
|
1
keyboards/xd002/keymaps/volume/rules.mk
Normal file
1
keyboards/xd002/keymaps/volume/rules.mk
Normal file
@@ -0,0 +1 @@
|
||||
EXTRAKEY_ENABLE = yes
|
49
keyboards/xd002/readme.md
Normal file
49
keyboards/xd002/readme.md
Normal file
@@ -0,0 +1,49 @@
|
||||
# xd002
|
||||
|
||||

|
||||
|
||||
2% Custom mechanical keyboard. ATtiny85 powered, with 2*WS2812 LEDs, and the micronucleus bootloader.
|
||||
|
||||
**Note**: Due to limited firmware space, a _**lot**_ of features have to be disabled to get a functioning QMK based keyboard.
|
||||
|
||||
* Keyboard Maintainer: [zvecr](https://github.com/zvecr)
|
||||
* Hardware Supported: xd002
|
||||
* Hardware Availability: [kprepublic](https://kprepublic.com/products/xd002-xiudi-2-custom-mechanical-keyboard-2-keys-underglow-and-switch-rgb-pcb-programmed-hot-swappable-macro-key-aluminum-case)
|
||||
|
||||
Make example for this keyboard (after setting up your build environment):
|
||||
|
||||
make xd002:default
|
||||
|
||||
See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs).
|
||||
|
||||
## Flashing
|
||||
### Prerequisites
|
||||
|
||||
```bash
|
||||
git clone https://github.com/micronucleus/micronucleus.git
|
||||
cd micronucleus/commandline/
|
||||
sudo make install
|
||||
```
|
||||
|
||||
On Linux, you’ll need proper privileges to access the MCU. You can either use sudo when flashing firmware, or place [these files](https://github.com/micronucleus/micronucleus/blob/master/commandline/49-micronucleus.rules) in /etc/udev/rules.d/. Once added run the following:
|
||||
|
||||
```bash
|
||||
sudo udevadm control --reload-rules
|
||||
sudo udevadm trigger
|
||||
```
|
||||
|
||||
### Instructions
|
||||
|
||||
**Reset Key**: Hold down key nearest to the USB socket while plugging in the keyboard.
|
||||
|
||||
```bash
|
||||
make xd002:default:flash
|
||||
|
||||
# or directly with...
|
||||
micronucleus --run <firmware.hex>
|
||||
```
|
||||
|
||||
### Recovery
|
||||
|
||||
* [Original Firmware](https://github.com/xiudi/Attiny85_vusb_pad_test)
|
||||
* [Bootloader Repair](https://digistump.com/wiki/digispark/tutorials/proisp)
|
34
keyboards/xd002/rules.mk
Normal file
34
keyboards/xd002/rules.mk
Normal file
@@ -0,0 +1,34 @@
|
||||
# MCU name
|
||||
MCU = attiny85
|
||||
|
||||
# Bootloader selection
|
||||
BOOTLOADER = micronucleus
|
||||
OPT_DEFS += -DBOOTLOADER_SIZE=1862
|
||||
PROGRAM_CMD = micronucleus --run $(BUILD_DIR)/$(TARGET).hex
|
||||
|
||||
# Build Options
|
||||
# change yes to no to disable
|
||||
#
|
||||
BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration
|
||||
MOUSEKEY_ENABLE = no # Mouse keys
|
||||
EXTRAKEY_ENABLE = no # Audio control and System control
|
||||
CONSOLE_ENABLE = no # Console for debug
|
||||
COMMAND_ENABLE = no # Commands for debug and configuration
|
||||
# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
|
||||
SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
|
||||
# if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
|
||||
NKRO_ENABLE = no # USB Nkey Rollover
|
||||
BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality on B7 by default
|
||||
RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow
|
||||
MIDI_ENABLE = no # MIDI support
|
||||
UNICODE_ENABLE = no # Unicode
|
||||
BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID
|
||||
AUDIO_ENABLE = no # Audio output on port C6
|
||||
FAUXCLICKY_ENABLE = no # Use buzzer to emulate clicky switches
|
||||
HD44780_ENABLE = no # Enable support for HD44780 based LCDs
|
||||
|
||||
# Save as much space as we can...
|
||||
LTO_ENABLE = yes
|
||||
GRAVE_ESC_ENABLE = no
|
||||
MAGIC_ENABLE = no
|
||||
SPACE_CADET_ENABLE = no
|
16
keyboards/xd002/xd002.c
Normal file
16
keyboards/xd002/xd002.c
Normal file
@@ -0,0 +1,16 @@
|
||||
/* Copyright 2020 zvecr<git@zvecr.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.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "xd002.h"
|
33
keyboards/xd002/xd002.h
Normal file
33
keyboards/xd002/xd002.h
Normal file
@@ -0,0 +1,33 @@
|
||||
/* Copyright 2020 zvecr<git@zvecr.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.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "quantum.h"
|
||||
|
||||
/* This a shortcut to help you visually see your layout.
|
||||
*
|
||||
* The first section contains all of the arguments representing the physical
|
||||
* layout of the board and position of the keys.
|
||||
*
|
||||
* The second converts the arguments into a two-dimensional array which
|
||||
* represents the switch matrix.
|
||||
*/
|
||||
#define LAYOUT( \
|
||||
K01, K02 \
|
||||
) \
|
||||
{ \
|
||||
{ K01, K02 }, \
|
||||
}
|
@@ -1,15 +1,14 @@
|
||||
# XD75 with 7U spacebar for EN-RU gamers
|
||||
* Standard QWERTY made for gamers with a Russian alternative input.
|
||||
* The keys for extra letters in RU alphabet are where they are expected.
|
||||
* Full 2x4 nav cluster.
|
||||
* Volume/mute control are on base layer, Win key is on function layer.
|
||||
* FN_CAPS provides fast F-keys access while gaming. Lefthanded Numpad operation.
|
||||
* NKRO is on (forced).
|
||||
|
||||
Standard QWERTY made for gamers with a Russian alternative input.
|
||||
The keys for extra letters in RU alphabet are where they are expected.
|
||||
Full 2x4 nav cluster.
|
||||
Volume/mute control are on base layer, Win key is on function layer.
|
||||
FN_CAPS provides fast F-keys access while gaming. Lefthanded Numpad operation.
|
||||
NKRO is working (forced).
|
||||
|
||||
## QWERTY
|
||||
|
||||
## Layout
|
||||
```c
|
||||
/* QWERTY
|
||||
* .--------------------------------------------------------------------------------------------------------------------------------------.
|
||||
* | GESC | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = | Del | BACKSP |
|
||||
* |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+-----------------|
|
||||
@@ -21,12 +20,10 @@ NKRO is working (forced).
|
||||
* |--------+--------+--------+--------+--------+-----------------+--------+--------+--------+--------+-----------------+--------+--------|
|
||||
* | LCTRL | Del | ENTER | LALT | SPACE | End | LEFT | DOWN | RIGHT |
|
||||
* '--------------------------------------------------------------------------------------------------------------------------------------'
|
||||
|
||||
*/
|
||||
```
|
||||
|
||||
## FUNCTION
|
||||
|
||||
```c
|
||||
/* FUNCTION
|
||||
* .--------------------------------------------------------------------------------------------------------------------------------------.
|
||||
* | XXXXXXX| F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 | _______| _______|
|
||||
* |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------|
|
||||
@@ -38,10 +35,20 @@ NKRO is working (forced).
|
||||
* |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------|
|
||||
* | _______| P0 | P. | PENT | SPACE | BL_TOGG| RGB TG | RGB RMD| RGB MD |
|
||||
* '--------------------------------------------------------------------------------------------------------------------------------------'
|
||||
*/
|
||||
```
|
||||
|
||||
|
||||
## LEDs ID
|
||||
|
||||
## LEDs
|
||||
Top left LED - Function layer active.
|
||||
Mid left LED - CapsLock active.
|
||||
|
||||
## Compile
|
||||
|
||||
go to qmk top directory.
|
||||
```
|
||||
$ cd qmk_firmware
|
||||
```
|
||||
|
||||
build
|
||||
```
|
||||
$ make xd75:buzzlighter1
|
||||
```
|
1
lib/printf
Submodule
1
lib/printf
Submodule
Submodule lib/printf added at d3b984684b
@@ -27,6 +27,6 @@ BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
|
||||
RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow
|
||||
MIDI_ENABLE = no # MIDI support
|
||||
BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID
|
||||
AUDIO_ENABLE = no # Audio output on port C6
|
||||
AUDIO_ENABLE = no # Audio output
|
||||
FAUXCLICKY_ENABLE = no # Use buzzer to emulate clicky switches
|
||||
HD44780_ENABLE = no # Enable support for HD44780 based LCDs
|
||||
|
@@ -1,3 +1,5 @@
|
||||
PRINTF_PATH = $(LIB_PATH)/printf
|
||||
|
||||
COMMON_DIR = common
|
||||
PLATFORM_COMMON_DIR = $(COMMON_DIR)/$(PLATFORM_KEY)
|
||||
|
||||
@@ -10,6 +12,7 @@ TMK_COMMON_SRC += $(COMMON_DIR)/host.c \
|
||||
$(COMMON_DIR)/action_util.c \
|
||||
$(COMMON_DIR)/print.c \
|
||||
$(COMMON_DIR)/debug.c \
|
||||
$(COMMON_DIR)/sendchar_null.c \
|
||||
$(COMMON_DIR)/util.c \
|
||||
$(COMMON_DIR)/eeconfig.c \
|
||||
$(COMMON_DIR)/report.c \
|
||||
@@ -20,7 +23,12 @@ TMK_COMMON_SRC += $(COMMON_DIR)/host.c \
|
||||
ifeq ($(PLATFORM),AVR)
|
||||
TMK_COMMON_SRC += $(PLATFORM_COMMON_DIR)/xprintf.S
|
||||
else ifeq ($(PLATFORM),CHIBIOS)
|
||||
TMK_COMMON_SRC += $(PLATFORM_COMMON_DIR)/printf.c
|
||||
TMK_COMMON_SRC += $(PRINTF_PATH)/printf.c
|
||||
TMK_COMMON_DEFS += -DPRINTF_DISABLE_SUPPORT_FLOAT
|
||||
TMK_COMMON_DEFS += -DPRINTF_DISABLE_SUPPORT_EXPONENTIAL
|
||||
TMK_COMMON_DEFS += -DPRINTF_DISABLE_SUPPORT_LONG_LONG
|
||||
TMK_COMMON_DEFS += -DPRINTF_DISABLE_SUPPORT_PTRDIFF_T
|
||||
VPATH += $(PRINTF_PATH)
|
||||
else ifeq ($(PLATFORM),ARM_ATSAM)
|
||||
TMK_COMMON_SRC += $(PLATFORM_COMMON_DIR)/printf.c
|
||||
endif
|
||||
|
@@ -1,233 +0,0 @@
|
||||
/*
|
||||
* found at: http://www.sparetimelabs.com/tinyprintf/tinyprintf.php
|
||||
* and: http://www.sparetimelabs.com/printfrevisited/printfrevisited.php
|
||||
*/
|
||||
|
||||
/*
|
||||
File: printf.c
|
||||
|
||||
Copyright (C) 2004 Kustaa Nyholm
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#include "printf.h"
|
||||
|
||||
typedef void (*putcf)(void*, char);
|
||||
static putcf stdout_putf;
|
||||
static void* stdout_putp;
|
||||
|
||||
// this adds cca 400 bytes
|
||||
#define PRINTF_LONG_SUPPORT
|
||||
|
||||
#ifdef PRINTF_LONG_SUPPORT
|
||||
|
||||
static void uli2a(unsigned long int num, unsigned int base, int uc, char* bf) {
|
||||
int n = 0;
|
||||
unsigned int d = 1;
|
||||
while (num / d >= base) d *= base;
|
||||
while (d != 0) {
|
||||
int dgt = num / d;
|
||||
num %= d;
|
||||
d /= base;
|
||||
if (n || dgt > 0 || d == 0) {
|
||||
*bf++ = dgt + (dgt < 10 ? '0' : (uc ? 'A' : 'a') - 10);
|
||||
++n;
|
||||
}
|
||||
}
|
||||
*bf = 0;
|
||||
}
|
||||
|
||||
static void li2a(long num, char* bf) {
|
||||
if (num < 0) {
|
||||
num = -num;
|
||||
*bf++ = '-';
|
||||
}
|
||||
uli2a(num, 10, 0, bf);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static void ui2a(unsigned int num, unsigned int base, int uc, char* bf) {
|
||||
int n = 0;
|
||||
unsigned int d = 1;
|
||||
while (num / d >= base) d *= base;
|
||||
while (d != 0) {
|
||||
int dgt = num / d;
|
||||
num %= d;
|
||||
d /= base;
|
||||
if (n || dgt > 0 || d == 0) {
|
||||
*bf++ = dgt + (dgt < 10 ? '0' : (uc ? 'A' : 'a') - 10);
|
||||
++n;
|
||||
}
|
||||
}
|
||||
*bf = 0;
|
||||
}
|
||||
|
||||
static void i2a(int num, char* bf) {
|
||||
if (num < 0) {
|
||||
num = -num;
|
||||
*bf++ = '-';
|
||||
}
|
||||
ui2a(num, 10, 0, bf);
|
||||
}
|
||||
|
||||
static int a2d(char ch) {
|
||||
if (ch >= '0' && ch <= '9')
|
||||
return ch - '0';
|
||||
else if (ch >= 'a' && ch <= 'f')
|
||||
return ch - 'a' + 10;
|
||||
else if (ch >= 'A' && ch <= 'F')
|
||||
return ch - 'A' + 10;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
static char a2i(char ch, const char** src, int base, int* nump) {
|
||||
const char* p = *src;
|
||||
int num = 0;
|
||||
int digit;
|
||||
while ((digit = a2d(ch)) >= 0) {
|
||||
if (digit > base) break;
|
||||
num = num * base + digit;
|
||||
ch = *p++;
|
||||
}
|
||||
*src = p;
|
||||
*nump = num;
|
||||
return ch;
|
||||
}
|
||||
|
||||
static void putchw(void* putp, putcf putf, int n, char z, char* bf) {
|
||||
char fc = z ? '0' : ' ';
|
||||
char ch;
|
||||
char* p = bf;
|
||||
while (*p++ && n > 0) n--;
|
||||
while (n-- > 0) putf(putp, fc);
|
||||
while ((ch = *bf++)) putf(putp, ch);
|
||||
}
|
||||
|
||||
void tfp_format(void* putp, putcf putf, const char* fmt, va_list va) {
|
||||
// This used to handle max of 12, but binary support jumps this to at least 32
|
||||
char bf[36];
|
||||
|
||||
char ch;
|
||||
|
||||
while ((ch = *(fmt++))) {
|
||||
if (ch != '%')
|
||||
putf(putp, ch);
|
||||
else {
|
||||
char lz = 0;
|
||||
#ifdef PRINTF_LONG_SUPPORT
|
||||
char lng = 0;
|
||||
#endif
|
||||
int w = 0;
|
||||
ch = *(fmt++);
|
||||
if (ch == '0') {
|
||||
ch = *(fmt++);
|
||||
lz = 1;
|
||||
}
|
||||
if (ch >= '0' && ch <= '9') {
|
||||
ch = a2i(ch, &fmt, 10, &w);
|
||||
}
|
||||
#ifdef PRINTF_LONG_SUPPORT
|
||||
if (ch == 'l') {
|
||||
ch = *(fmt++);
|
||||
lng = 1;
|
||||
}
|
||||
#endif
|
||||
switch (ch) {
|
||||
case 0:
|
||||
goto abort;
|
||||
case 'u': {
|
||||
#ifdef PRINTF_LONG_SUPPORT
|
||||
if (lng)
|
||||
uli2a(va_arg(va, unsigned long int), 10, 0, bf);
|
||||
else
|
||||
#endif
|
||||
ui2a(va_arg(va, unsigned int), 10, 0, bf);
|
||||
putchw(putp, putf, w, lz, bf);
|
||||
break;
|
||||
}
|
||||
case 'd': {
|
||||
#ifdef PRINTF_LONG_SUPPORT
|
||||
if (lng)
|
||||
li2a(va_arg(va, unsigned long int), bf);
|
||||
else
|
||||
#endif
|
||||
i2a(va_arg(va, int), bf);
|
||||
putchw(putp, putf, w, lz, bf);
|
||||
break;
|
||||
}
|
||||
case 'x':
|
||||
case 'X':
|
||||
#ifdef PRINTF_LONG_SUPPORT
|
||||
if (lng)
|
||||
uli2a(va_arg(va, unsigned long int), 16, (ch == 'X'), bf);
|
||||
else
|
||||
#endif
|
||||
ui2a(va_arg(va, unsigned int), 16, (ch == 'X'), bf);
|
||||
putchw(putp, putf, w, lz, bf);
|
||||
break;
|
||||
case 'c':
|
||||
putf(putp, (char)(va_arg(va, int)));
|
||||
break;
|
||||
case 's':
|
||||
putchw(putp, putf, w, 0, va_arg(va, char*));
|
||||
break;
|
||||
case 'b':
|
||||
#ifdef PRINTF_LONG_SUPPORT
|
||||
if (lng)
|
||||
uli2a(va_arg(va, unsigned long int), 2, 0, bf);
|
||||
else
|
||||
#endif
|
||||
ui2a(va_arg(va, unsigned int), 2, 0, bf);
|
||||
putchw(putp, putf, w, lz, bf);
|
||||
break;
|
||||
case '%':
|
||||
putf(putp, ch);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
abort:;
|
||||
}
|
||||
|
||||
void init_printf(void* putp, void (*putf)(void*, char)) {
|
||||
stdout_putf = putf;
|
||||
stdout_putp = putp;
|
||||
}
|
||||
|
||||
int tfp_printf(const char* fmt, ...) {
|
||||
va_list va;
|
||||
va_start(va, fmt);
|
||||
tfp_format(stdout_putp, stdout_putf, fmt, va);
|
||||
va_end(va);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void putcp(void* p, char c) { *(*((char**)p))++ = c; }
|
||||
|
||||
int tfp_sprintf(char* s, const char* fmt, ...) {
|
||||
va_list va;
|
||||
va_start(va, fmt);
|
||||
tfp_format(&s, putcp, fmt, va);
|
||||
putcp(&s, 0);
|
||||
va_end(va);
|
||||
|
||||
return 1;
|
||||
}
|
@@ -1,110 +0,0 @@
|
||||
/*
|
||||
* found at: http://www.sparetimelabs.com/tinyprintf/tinyprintf.php
|
||||
* and: http://www.sparetimelabs.com/printfrevisited/printfrevisited.php
|
||||
*/
|
||||
|
||||
/*
|
||||
File: printf.h
|
||||
|
||||
Copyright (C) 2004 Kustaa Nyholm
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
This library is realy just two files: 'printf.h' and 'printf.c'.
|
||||
|
||||
They provide a simple and small (+200 loc) printf functionality to
|
||||
be used in embedded systems.
|
||||
|
||||
I've found them so usefull in debugging that I do not bother with a
|
||||
debugger at all.
|
||||
|
||||
They are distributed in source form, so to use them, just compile them
|
||||
into your project.
|
||||
|
||||
Two printf variants are provided: printf and sprintf.
|
||||
|
||||
The formats supported by this implementation are: 'd' 'u' 'c' 's' 'x' 'X'.
|
||||
|
||||
Zero padding and field width are also supported.
|
||||
|
||||
If the library is compiled with 'PRINTF_SUPPORT_LONG' defined then the
|
||||
long specifier is also
|
||||
supported. Note that this will pull in some long math routines (pun intended!)
|
||||
and thus make your executable noticably longer.
|
||||
|
||||
The memory foot print of course depends on the target cpu, compiler and
|
||||
compiler options, but a rough guestimate (based on a H8S target) is about
|
||||
1.4 kB for code and some twenty 'int's and 'char's, say 60 bytes of stack space.
|
||||
Not too bad. Your milage may vary. By hacking the source code you can
|
||||
get rid of some hunred bytes, I'm sure, but personally I feel the balance of
|
||||
functionality and flexibility versus code size is close to optimal for
|
||||
many embedded systems.
|
||||
|
||||
To use the printf you need to supply your own character output function,
|
||||
something like :
|
||||
|
||||
void putc ( void* p, char c)
|
||||
{
|
||||
while (!SERIAL_PORT_EMPTY) ;
|
||||
SERIAL_PORT_TX_REGISTER = c;
|
||||
}
|
||||
|
||||
Before you can call printf you need to initialize it to use your
|
||||
character output function with something like:
|
||||
|
||||
init_printf(NULL,putc);
|
||||
|
||||
Notice the 'NULL' in 'init_printf' and the parameter 'void* p' in 'putc',
|
||||
the NULL (or any pointer) you pass into the 'init_printf' will eventually be
|
||||
passed to your 'putc' routine. This allows you to pass some storage space (or
|
||||
anything realy) to the character output function, if necessary.
|
||||
This is not often needed but it was implemented like that because it made
|
||||
implementing the sprintf function so neat (look at the source code).
|
||||
|
||||
The code is re-entrant, except for the 'init_printf' function, so it
|
||||
is safe to call it from interupts too, although this may result in mixed output.
|
||||
If you rely on re-entrancy, take care that your 'putc' function is re-entrant!
|
||||
|
||||
The printf and sprintf functions are actually macros that translate to
|
||||
'tfp_printf' and 'tfp_sprintf'. This makes it possible
|
||||
to use them along with 'stdio.h' printf's in a single source file.
|
||||
You just need to undef the names before you include the 'stdio.h'.
|
||||
Note that these are not function like macros, so if you have variables
|
||||
or struct members with these names, things will explode in your face.
|
||||
Without variadic macros this is the best we can do to wrap these
|
||||
fucnction. If it is a problem just give up the macros and use the
|
||||
functions directly or rename them.
|
||||
|
||||
For further details see source code.
|
||||
|
||||
regs Kusti, 23.10.2004
|
||||
*/
|
||||
|
||||
#ifndef __TFP_PRINTF__
|
||||
#define __TFP_PRINTF__
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
void init_printf(void* putp, void (*putf)(void*, char));
|
||||
|
||||
int tfp_printf(const char* fmt, ...);
|
||||
int tfp_sprintf(char* s, const char* fmt, ...);
|
||||
|
||||
void tfp_format(void* putp, void (*putf)(void*, char), const char* fmt, va_list va);
|
||||
|
||||
#define printf tfp_printf
|
||||
#define sprintf tfp_sprintf
|
||||
|
||||
#endif
|
@@ -213,6 +213,13 @@ void keyboard_setup(void) {
|
||||
*/
|
||||
__attribute__((weak)) bool is_keyboard_master(void) { return true; }
|
||||
|
||||
/** \brief should_process_keypress
|
||||
*
|
||||
* Override this function if you have a condition where keypresses processing should change:
|
||||
* - splits where the slave side needs to process for rgb/oled functionality
|
||||
*/
|
||||
__attribute__((weak)) bool should_process_keypress(void) { return is_keyboard_master(); }
|
||||
|
||||
/** \brief keyboard_init
|
||||
*
|
||||
* FIXME: needs doc
|
||||
@@ -292,7 +299,7 @@ void keyboard_task(void) {
|
||||
matrix_scan();
|
||||
#endif
|
||||
|
||||
if (is_keyboard_master()) {
|
||||
if (should_process_keypress()) {
|
||||
for (uint8_t r = 0; r < MATRIX_ROWS; r++) {
|
||||
matrix_row = matrix_get_row(r);
|
||||
matrix_change = matrix_row ^ matrix_prev[r];
|
||||
|
@@ -72,9 +72,7 @@ extern "C"
|
||||
|
||||
# elif defined(PROTOCOL_CHIBIOS) /* PROTOCOL_CHIBIOS */
|
||||
|
||||
# ifndef TERMINAL_ENABLE
|
||||
# include "chibios/printf.h"
|
||||
# endif
|
||||
# include "printf.h" // lib/printf/printf.h
|
||||
|
||||
# ifdef USER_PRINT /* USER_PRINT */
|
||||
|
||||
@@ -89,7 +87,6 @@ extern "C"
|
||||
# define uprintf printf
|
||||
|
||||
# else /* NORMAL PRINT */
|
||||
|
||||
// Create user & normal print defines
|
||||
# define print(s) printf(s)
|
||||
# define println(s) printf(s "\r\n")
|
||||
|
@@ -69,6 +69,8 @@ enum consumer_usages {
|
||||
AL_CALCULATOR = 0x192,
|
||||
AL_LOCAL_BROWSER = 0x194,
|
||||
AL_LOCK = 0x19E,
|
||||
AL_CONTROL_PANEL = 0x19F,
|
||||
AL_ASSISTANT = 0x1CB,
|
||||
// 15.16 Generic GUI Application Controls
|
||||
AC_MINIMIZE = 0x206,
|
||||
AC_SEARCH = 0x221,
|
||||
|
@@ -16,4 +16,4 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "sendchar.h"
|
||||
|
||||
int8_t sendchar(uint8_t c) { return 0; }
|
||||
__attribute__((weak)) int8_t sendchar(uint8_t c) { return 0; }
|
||||
|
@@ -158,9 +158,6 @@ int main(void) {
|
||||
/* Init USB */
|
||||
init_usb_driver(&USB_DRIVER);
|
||||
|
||||
/* init printf */
|
||||
init_printf(NULL, sendchar_pf);
|
||||
|
||||
#ifdef MIDI_ENABLE
|
||||
setup_midi();
|
||||
#endif
|
||||
|
@@ -796,10 +796,7 @@ int8_t sendchar(uint8_t c) {
|
||||
}
|
||||
#endif /* CONSOLE_ENABLE */
|
||||
|
||||
void sendchar_pf(void *p, char c) {
|
||||
(void)p;
|
||||
sendchar((uint8_t)c);
|
||||
}
|
||||
void _putchar(char character) { sendchar(character); }
|
||||
|
||||
#ifdef RAW_ENABLE
|
||||
void raw_hid_send(uint8_t *data, uint8_t length) {
|
||||
|
@@ -87,6 +87,4 @@ void console_flush_output(void);
|
||||
|
||||
#endif /* CONSOLE_ENABLE */
|
||||
|
||||
void sendchar_pf(void *p, char c);
|
||||
|
||||
#endif /* _USB_MAIN_H_ */
|
||||
|
@@ -161,7 +161,9 @@ ISR(IBM4704_INT_VECT) {
|
||||
case STOP:
|
||||
// Data:Low
|
||||
WAIT(data_lo, 100, state);
|
||||
rbuf_enqueue(data);
|
||||
if (!rbuf_enqueue(data)) {
|
||||
print("rbuf: full\n");
|
||||
}
|
||||
ibm4704_error = IBM4704_ERR_NONE;
|
||||
goto DONE;
|
||||
break;
|
||||
|
@@ -801,8 +801,6 @@ ERROR_EXIT:
|
||||
Endpoint_SelectEndpoint(ep);
|
||||
return -1;
|
||||
}
|
||||
#else
|
||||
int8_t sendchar(uint8_t c) { return 0; }
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
|
@@ -9,13 +9,12 @@ SRC += $(VUSB_DIR)/main.c \
|
||||
$(VUSB_DIR)/usbdrv/oddebug.c
|
||||
|
||||
|
||||
ifdef NO_UART
|
||||
SRC += $(COMMON_DIR)/sendchar_null.c
|
||||
else
|
||||
ifneq ($(strip $(CONSOLE_ENABLE)), yes)
|
||||
ifndef NO_UART
|
||||
SRC += $(COMMON_DIR)/sendchar_uart.c \
|
||||
$(COMMON_DIR)/uart.c
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
# Search Path
|
||||
VPATH += $(TMK_PATH)/$(VUSB_DIR)
|
||||
|
@@ -21,12 +21,23 @@
|
||||
#include "uart.h"
|
||||
#include "debug.h"
|
||||
#include "suspend.h"
|
||||
#include "wait.h"
|
||||
#include "sendchar.h"
|
||||
|
||||
#ifdef SLEEP_LED_ENABLE
|
||||
# include "sleep_led.h"
|
||||
#endif
|
||||
|
||||
#define UART_BAUD_RATE 115200
|
||||
|
||||
#ifdef CONSOLE_ENABLE
|
||||
void console_task(void);
|
||||
#endif
|
||||
|
||||
#ifdef RAW_ENABLE
|
||||
void raw_hid_task(void);
|
||||
#endif
|
||||
|
||||
/* This is from main.c of USBaspLoader */
|
||||
static void initForUsbConnectivity(void) {
|
||||
uint8_t i = 0;
|
||||
@@ -39,10 +50,9 @@ static void initForUsbConnectivity(void) {
|
||||
_delay_ms(1);
|
||||
}
|
||||
usbDeviceConnect();
|
||||
sei();
|
||||
}
|
||||
|
||||
void usb_remote_wakeup(void) {
|
||||
static void usb_remote_wakeup(void) {
|
||||
cli();
|
||||
|
||||
int8_t ddr_orig = USBDDR;
|
||||
@@ -59,6 +69,23 @@ void usb_remote_wakeup(void) {
|
||||
sei();
|
||||
}
|
||||
|
||||
/** \brief Setup USB
|
||||
*
|
||||
* FIXME: Needs doc
|
||||
*/
|
||||
static void setup_usb(void) {
|
||||
// debug("initForUsbConnectivity()\n");
|
||||
initForUsbConnectivity();
|
||||
|
||||
// for Console_Task
|
||||
print_set_sendchar(sendchar);
|
||||
}
|
||||
|
||||
/** \brief Main
|
||||
*
|
||||
* FIXME: Needs doc
|
||||
*/
|
||||
int main(void) __attribute__((weak));
|
||||
int main(void) {
|
||||
bool suspended = false;
|
||||
#if USB_COUNT_SOF
|
||||
@@ -76,8 +103,10 @@ int main(void) {
|
||||
keyboard_setup();
|
||||
|
||||
host_set_driver(vusb_driver());
|
||||
debug("initForUsbConnectivity()\n");
|
||||
initForUsbConnectivity();
|
||||
setup_usb();
|
||||
sei();
|
||||
|
||||
wait_ms(50);
|
||||
|
||||
keyboard_init();
|
||||
#ifdef SLEEP_LED_ENABLE
|
||||
@@ -120,18 +149,26 @@ int main(void) {
|
||||
if (!suspended) {
|
||||
usbPoll();
|
||||
|
||||
// TODO: configuration process is incosistent. it sometime fails.
|
||||
// TODO: configuration process is inconsistent. it sometime fails.
|
||||
// To prevent failing to configure NOT scan keyboard during configuration
|
||||
if (usbConfiguration && usbInterruptIsReady()) {
|
||||
keyboard_task();
|
||||
}
|
||||
vusb_transfer_keyboard();
|
||||
|
||||
#ifdef RAW_ENABLE
|
||||
usbPoll();
|
||||
|
||||
if (usbConfiguration && usbInterruptIsReady3()) {
|
||||
raw_hid_task();
|
||||
}
|
||||
#endif
|
||||
#ifdef CONSOLE_ENABLE
|
||||
usbPoll();
|
||||
|
||||
if (usbConfiguration && usbInterruptIsReady3()) {
|
||||
console_task();
|
||||
}
|
||||
#endif
|
||||
} else if (suspend_wakeup_condition()) {
|
||||
usb_remote_wakeup();
|
||||
|
@@ -15,25 +15,50 @@ You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <avr/eeprom.h>
|
||||
#include <avr/wdt.h>
|
||||
#include <util/delay.h>
|
||||
#include <stdint.h>
|
||||
#include "usbdrv.h"
|
||||
#include "usbconfig.h"
|
||||
#include "host.h"
|
||||
#include "report.h"
|
||||
#include "print.h"
|
||||
#include "debug.h"
|
||||
#include "host_driver.h"
|
||||
#include "vusb.h"
|
||||
#include <util/delay.h>
|
||||
#include "print.h"
|
||||
#include "debug.h"
|
||||
|
||||
#ifdef RAW_ENABLE
|
||||
# include "raw_hid.h"
|
||||
#endif
|
||||
|
||||
#if (defined(MOUSE_ENABLE) || defined(EXTRAKEY_ENABLE)) && defined(RAW_ENABLE)
|
||||
# error "Enabling Mousekeys/Extrakeys and Raw HID at the same time is not currently supported on V-USB."
|
||||
#if defined(CONSOLE_ENABLE)
|
||||
# define RBUF_SIZE 128
|
||||
# include "ring_buffer.h"
|
||||
#endif
|
||||
|
||||
#define NEXT_INTERFACE __COUNTER__
|
||||
|
||||
/*
|
||||
* Interface indexes
|
||||
*/
|
||||
enum usb_interfaces {
|
||||
KEYBOARD_INTERFACE = NEXT_INTERFACE,
|
||||
#if (defined(MOUSE_ENABLE) || defined(EXTRAKEY_ENABLE))
|
||||
MOUSE_EXTRA_INTERFACE = NEXT_INTERFACE,
|
||||
#endif
|
||||
#ifdef RAW_ENABLE
|
||||
RAW_INTERFACE = NEXT_INTERFACE,
|
||||
#endif
|
||||
#ifdef CONSOLE_ENABLE
|
||||
CONSOLE_INTERFACE = NEXT_INTERFACE,
|
||||
#endif
|
||||
TOTAL_INTERFACES = NEXT_INTERFACE,
|
||||
};
|
||||
|
||||
#define MAX_INTERFACES 2
|
||||
|
||||
#if (NEXT_INTERFACE - 1) > MAX_INTERFACES
|
||||
# error There are not enough available interfaces to support all functions. Please disable one or more of the following: Mouse Keys, Extra Keys, Raw HID, Console
|
||||
#endif
|
||||
|
||||
static uint8_t vusb_keyboard_leds = 0;
|
||||
@@ -120,7 +145,60 @@ void raw_hid_task(void) {
|
||||
raw_output_received_bytes = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*------------------------------------------------------------------*
|
||||
* Console
|
||||
*------------------------------------------------------------------*/
|
||||
#ifdef CONSOLE_ENABLE
|
||||
# define CONSOLE_BUFFER_SIZE 32
|
||||
# define CONSOLE_EPSIZE 8
|
||||
|
||||
int8_t sendchar(uint8_t c) {
|
||||
rbuf_enqueue(c);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline bool usbSendData3(char *data, uint8_t len) {
|
||||
uint8_t retries = 5;
|
||||
while (!usbInterruptIsReady3()) {
|
||||
if (!(retries--)) {
|
||||
return false;
|
||||
}
|
||||
usbPoll();
|
||||
}
|
||||
|
||||
usbSetInterrupt3((unsigned char *)data, len);
|
||||
return true;
|
||||
}
|
||||
|
||||
void console_task(void) {
|
||||
if (!usbConfiguration) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!rbuf_has_data()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Send in chunks of 8 padded to 32
|
||||
char send_buf[CONSOLE_BUFFER_SIZE] = {0};
|
||||
uint8_t send_buf_count = 0;
|
||||
while (rbuf_has_data() && send_buf_count < CONSOLE_EPSIZE) {
|
||||
send_buf[send_buf_count++] = rbuf_dequeue();
|
||||
}
|
||||
|
||||
char *temp = send_buf;
|
||||
for (uint8_t i = 0; i < 4; i++) {
|
||||
if (!usbSendData3(temp, 8)) {
|
||||
break;
|
||||
}
|
||||
temp += 8;
|
||||
}
|
||||
|
||||
usbSendData3(0, 0);
|
||||
usbPoll();
|
||||
}
|
||||
#endif
|
||||
|
||||
/*------------------------------------------------------------------*
|
||||
@@ -429,7 +507,30 @@ const PROGMEM uchar raw_hid_report[] = {
|
||||
0x95, RAW_BUFFER_SIZE, // Report Count
|
||||
0x75, 0x08, // Report Size (8)
|
||||
0x91, 0x02, // Output (Data, Variable, Absolute)
|
||||
0xC0, // End Collection
|
||||
0xC0 // End Collection
|
||||
};
|
||||
#endif
|
||||
|
||||
#if defined(CONSOLE_ENABLE)
|
||||
const PROGMEM uchar console_hid_report[] = {
|
||||
0x06, 0x31, 0xFF, // Usage Page (Vendor Defined - PJRC Teensy compatible)
|
||||
0x09, 0x74, // Usage (Vendor Defined - PJRC Teensy compatible)
|
||||
0xA1, 0x01, // Collection (Application)
|
||||
// Data to host
|
||||
0x09, 0x75, // Usage (Vendor Defined)
|
||||
0x15, 0x00, // Logical Minimum (0x00)
|
||||
0x26, 0xFF, 0x00, // Logical Maximum (0x00FF)
|
||||
0x95, CONSOLE_BUFFER_SIZE, // Report Count
|
||||
0x75, 0x08, // Report Size (8)
|
||||
0x81, 0x02, // Input (Data, Variable, Absolute)
|
||||
// Data from host
|
||||
0x09, 0x76, // Usage (Vendor Defined)
|
||||
0x15, 0x00, // Logical Minimum (0x00)
|
||||
0x26, 0xFF, 0x00, // Logical Maximum (0x00FF)
|
||||
0x95, CONSOLE_BUFFER_SIZE, // Report Count
|
||||
0x75, 0x08, // Report Size (8)
|
||||
0x91, 0x02, // Output (Data)
|
||||
0xC0 // End Collection
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -511,11 +612,7 @@ const PROGMEM usbConfigurationDescriptor_t usbConfigurationDescriptor = {
|
||||
.bDescriptorType = USBDESCR_CONFIG
|
||||
},
|
||||
.wTotalLength = sizeof(usbConfigurationDescriptor_t),
|
||||
# if defined(MOUSE_ENABLE) || defined(EXTRAKEY_ENABLE) || defined(RAW_ENABLE)
|
||||
.bNumInterfaces = 2,
|
||||
# else
|
||||
.bNumInterfaces = 1,
|
||||
# endif
|
||||
.bNumInterfaces = TOTAL_INTERFACES,
|
||||
.bConfigurationValue = 0x01,
|
||||
.iConfiguration = 0x00,
|
||||
.bmAttributes = (1 << 7) | USBATTR_REMOTEWAKE,
|
||||
@@ -530,7 +627,7 @@ const PROGMEM usbConfigurationDescriptor_t usbConfigurationDescriptor = {
|
||||
.bLength = sizeof(usbInterfaceDescriptor_t),
|
||||
.bDescriptorType = USBDESCR_INTERFACE
|
||||
},
|
||||
.bInterfaceNumber = 0,
|
||||
.bInterfaceNumber = KEYBOARD_INTERFACE,
|
||||
.bAlternateSetting = 0x00,
|
||||
.bNumEndpoints = 1,
|
||||
.bInterfaceClass = 0x03,
|
||||
@@ -569,7 +666,7 @@ const PROGMEM usbConfigurationDescriptor_t usbConfigurationDescriptor = {
|
||||
.bLength = sizeof(usbInterfaceDescriptor_t),
|
||||
.bDescriptorType = USBDESCR_INTERFACE
|
||||
},
|
||||
.bInterfaceNumber = 1,
|
||||
.bInterfaceNumber = MOUSE_EXTRA_INTERFACE,
|
||||
.bAlternateSetting = 0x00,
|
||||
.bNumEndpoints = 1,
|
||||
.bInterfaceClass = 0x03,
|
||||
@@ -597,14 +694,15 @@ const PROGMEM usbConfigurationDescriptor_t usbConfigurationDescriptor = {
|
||||
.bmAttributes = 0x03,
|
||||
.wMaxPacketSize = 8,
|
||||
.bInterval = USB_POLLING_INTERVAL_MS
|
||||
}
|
||||
# elif defined(RAW_ENABLE)
|
||||
},
|
||||
# endif
|
||||
# if defined(RAW_ENABLE)
|
||||
.rawInterface = {
|
||||
.header = {
|
||||
.bLength = sizeof(usbInterfaceDescriptor_t),
|
||||
.bDescriptorType = USBDESCR_INTERFACE
|
||||
},
|
||||
.bInterfaceNumber = 1,
|
||||
.bInterfaceNumber = RAW_INTERFACE,
|
||||
.bAlternateSetting = 0x00,
|
||||
.bNumEndpoints = 2,
|
||||
.bInterfaceClass = 0x03,
|
||||
@@ -642,7 +740,56 @@ const PROGMEM usbConfigurationDescriptor_t usbConfigurationDescriptor = {
|
||||
.bmAttributes = 0x03,
|
||||
.wMaxPacketSize = RAW_EPSIZE,
|
||||
.bInterval = USB_POLLING_INTERVAL_MS
|
||||
}
|
||||
},
|
||||
# endif
|
||||
# if defined(CONSOLE_ENABLE)
|
||||
/*
|
||||
* Console
|
||||
*/
|
||||
.consoleInterface = {
|
||||
.header = {
|
||||
.bLength = sizeof(usbInterfaceDescriptor_t),
|
||||
.bDescriptorType = USBDESCR_INTERFACE
|
||||
},
|
||||
.bInterfaceNumber = CONSOLE_INTERFACE,
|
||||
.bAlternateSetting = 0x00,
|
||||
.bNumEndpoints = 2,
|
||||
.bInterfaceClass = 0x03,
|
||||
.bInterfaceSubClass = 0x00,
|
||||
.bInterfaceProtocol = 0x00,
|
||||
.iInterface = 0x00
|
||||
},
|
||||
.consoleHID = {
|
||||
.header = {
|
||||
.bLength = sizeof(usbHIDDescriptor_t),
|
||||
.bDescriptorType = USBDESCR_HID
|
||||
},
|
||||
.bcdHID = 0x0111,
|
||||
.bCountryCode = 0x00,
|
||||
.bNumDescriptors = 1,
|
||||
.bDescriptorType = USBDESCR_HID_REPORT,
|
||||
.wDescriptorLength = sizeof(console_hid_report)
|
||||
},
|
||||
.consoleINEndpoint = {
|
||||
.header = {
|
||||
.bLength = sizeof(usbEndpointDescriptor_t),
|
||||
.bDescriptorType = USBDESCR_ENDPOINT
|
||||
},
|
||||
.bEndpointAddress = (USBRQ_DIR_DEVICE_TO_HOST | USB_CFG_EP3_NUMBER),
|
||||
.bmAttributes = 0x03,
|
||||
.wMaxPacketSize = CONSOLE_EPSIZE,
|
||||
.bInterval = 0x01
|
||||
},
|
||||
.consoleOUTEndpoint = {
|
||||
.header = {
|
||||
.bLength = sizeof(usbEndpointDescriptor_t),
|
||||
.bDescriptorType = USBDESCR_ENDPOINT
|
||||
},
|
||||
.bEndpointAddress = (USBRQ_DIR_HOST_TO_DEVICE | USB_CFG_EP3_NUMBER),
|
||||
.bmAttributes = 0x03,
|
||||
.wMaxPacketSize = CONSOLE_EPSIZE,
|
||||
.bInterval = 0x01
|
||||
},
|
||||
# endif
|
||||
};
|
||||
|
||||
@@ -690,40 +837,54 @@ USB_PUBLIC usbMsgLen_t usbFunctionDescriptor(struct usbRequest *rq) {
|
||||
break;
|
||||
case USBDESCR_HID:
|
||||
switch (rq->wValue.bytes[0]) {
|
||||
case 0:
|
||||
case KEYBOARD_INTERFACE:
|
||||
usbMsgPtr = (unsigned char *)&usbConfigurationDescriptor.keyboardHID;
|
||||
len = sizeof(usbHIDDescriptor_t);
|
||||
break;
|
||||
#if defined(MOUSE_ENABLE) || defined(EXTRAKEY_ENABLE)
|
||||
case 1:
|
||||
case MOUSE_EXTRA_INTERFACE:
|
||||
usbMsgPtr = (unsigned char *)&usbConfigurationDescriptor.mouseExtraHID;
|
||||
len = sizeof(usbHIDDescriptor_t);
|
||||
break;
|
||||
#elif defined(RAW_ENABLE)
|
||||
case 1:
|
||||
#endif
|
||||
#if defined(RAW_ENABLE)
|
||||
case RAW_INTERFACE:
|
||||
usbMsgPtr = (unsigned char *)&usbConfigurationDescriptor.rawHID;
|
||||
len = sizeof(usbHIDDescriptor_t);
|
||||
break;
|
||||
#endif
|
||||
#if defined(CONSOLE_ENABLE)
|
||||
case CONSOLE_INTERFACE:
|
||||
usbMsgPtr = (unsigned char *)&usbConfigurationDescriptor.consoleHID;
|
||||
len = sizeof(usbHIDDescriptor_t);
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
case USBDESCR_HID_REPORT:
|
||||
/* interface index */
|
||||
switch (rq->wIndex.word) {
|
||||
case 0:
|
||||
case KEYBOARD_INTERFACE:
|
||||
usbMsgPtr = (unsigned char *)keyboard_hid_report;
|
||||
len = sizeof(keyboard_hid_report);
|
||||
break;
|
||||
#if defined(MOUSE_ENABLE) || defined(EXTRAKEY_ENABLE)
|
||||
case 1:
|
||||
case MOUSE_EXTRA_INTERFACE:
|
||||
usbMsgPtr = (unsigned char *)mouse_extra_hid_report;
|
||||
len = sizeof(mouse_extra_hid_report);
|
||||
break;
|
||||
#elif defined(RAW_ENABLE)
|
||||
case 1:
|
||||
#endif
|
||||
#if defined(RAW_ENABLE)
|
||||
case RAW_INTERFACE:
|
||||
usbMsgPtr = (unsigned char *)raw_hid_report;
|
||||
len = sizeof(raw_hid_report);
|
||||
break;
|
||||
#endif
|
||||
#if defined(CONSOLE_ENABLE)
|
||||
case CONSOLE_INTERFACE:
|
||||
usbMsgPtr = (unsigned char *)console_hid_report;
|
||||
len = sizeof(console_hid_report);
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
@@ -93,19 +93,24 @@ typedef struct usbConfigurationDescriptor {
|
||||
usbInterfaceDescriptor_t mouseExtraInterface;
|
||||
usbHIDDescriptor_t mouseExtraHID;
|
||||
usbEndpointDescriptor_t mouseExtraINEndpoint;
|
||||
#elif defined(RAW_ENABLE)
|
||||
#endif
|
||||
|
||||
#if defined(RAW_ENABLE)
|
||||
usbInterfaceDescriptor_t rawInterface;
|
||||
usbHIDDescriptor_t rawHID;
|
||||
usbEndpointDescriptor_t rawINEndpoint;
|
||||
usbEndpointDescriptor_t rawOUTEndpoint;
|
||||
#endif
|
||||
|
||||
#if defined(CONSOLE_ENABLE)
|
||||
usbInterfaceDescriptor_t consoleInterface;
|
||||
usbHIDDescriptor_t consoleHID;
|
||||
usbEndpointDescriptor_t consoleINEndpoint;
|
||||
usbEndpointDescriptor_t consoleOUTEndpoint;
|
||||
#endif
|
||||
} __attribute__((packed)) usbConfigurationDescriptor_t;
|
||||
|
||||
#define USB_STRING_LEN(s) (sizeof(usbDescriptorHeader_t) + ((s) << 1))
|
||||
|
||||
host_driver_t *vusb_driver(void);
|
||||
void vusb_transfer_keyboard(void);
|
||||
|
||||
#ifdef RAW_ENABLE
|
||||
void raw_hid_task(void);
|
||||
#endif
|
||||
|
@@ -3,21 +3,26 @@
|
||||
/*--------------------------------------------------------------------
|
||||
* Ring buffer to store scan codes from keyboard
|
||||
*------------------------------------------------------------------*/
|
||||
#define RBUF_SIZE 32
|
||||
#ifndef RBUF_SIZE
|
||||
# define RBUF_SIZE 32
|
||||
#endif
|
||||
#include <util/atomic.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
static uint8_t rbuf[RBUF_SIZE];
|
||||
static uint8_t rbuf_head = 0;
|
||||
static uint8_t rbuf_tail = 0;
|
||||
static inline void rbuf_enqueue(uint8_t data) {
|
||||
static inline bool rbuf_enqueue(uint8_t data) {
|
||||
bool ret = false;
|
||||
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
|
||||
uint8_t next = (rbuf_head + 1) % RBUF_SIZE;
|
||||
if (next != rbuf_tail) {
|
||||
rbuf[rbuf_head] = data;
|
||||
rbuf_head = next;
|
||||
} else {
|
||||
print("rbuf: full\n");
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
static inline uint8_t rbuf_dequeue(void) {
|
||||
uint8_t val = 0;
|
||||
|
Reference in New Issue
Block a user