forked from zmkfirmware/zmk
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request zmkfirmware#269 from joelspadin/endpoint-selection
feat: only send HID reports to one endpoint
- Loading branch information
Showing
19 changed files
with
451 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/ { | ||
behaviors { | ||
out: behavior_outputs { | ||
compatible = "zmk,behavior-outputs"; | ||
label = "OUTPUTS"; | ||
#binding-cells = <1>; | ||
}; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# | ||
# Copyright (c) 2020, The ZMK Contributors | ||
# SPDX-License-Identifier: MIT | ||
# | ||
|
||
description: Output Selection Behavior | ||
|
||
compatible: "zmk,behavior-outputs" | ||
|
||
include: one_param.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* | ||
* Copyright (c) 2020 The ZMK Contributors | ||
* | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
#define OUT_TOG 0 | ||
#define OUT_USB 1 | ||
#define OUT_BLE 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Copyright (c) 2020 The ZMK Contributors | ||
* | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <zephyr.h> | ||
#include <usb/usb_device.h> | ||
|
||
#include <zmk/event-manager.h> | ||
#include <zmk/usb.h> | ||
|
||
struct usb_conn_state_changed { | ||
struct zmk_event_header header; | ||
enum zmk_usb_conn_state conn_state; | ||
}; | ||
|
||
ZMK_EVENT_DECLARE(usb_conn_state_changed); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright (c) 2020 The ZMK Contributors | ||
* | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
#define DT_DRV_COMPAT zmk_behavior_outputs | ||
|
||
#include <device.h> | ||
#include <devicetree.h> | ||
#include <drivers/behavior.h> | ||
|
||
#include <dt-bindings/zmk/outputs.h> | ||
|
||
#include <zmk/behavior.h> | ||
#include <zmk/endpoints.h> | ||
|
||
#include <logging/log.h> | ||
LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); | ||
|
||
static int on_keymap_binding_pressed(struct zmk_behavior_binding *binding, | ||
struct zmk_behavior_binding_event event) { | ||
switch (binding->param1) { | ||
case OUT_TOG: | ||
return zmk_endpoints_toggle(); | ||
case OUT_USB: | ||
return zmk_endpoints_select(ZMK_ENDPOINT_USB); | ||
case OUT_BLE: | ||
return zmk_endpoints_select(ZMK_ENDPOINT_BLE); | ||
default: | ||
LOG_ERR("Unknown output command: %d", binding->param1); | ||
} | ||
|
||
return -ENOTSUP; | ||
} | ||
|
||
static int behavior_out_init(struct device *dev) { return 0; } | ||
|
||
static const struct behavior_driver_api behavior_outputs_driver_api = { | ||
.binding_pressed = on_keymap_binding_pressed, | ||
}; | ||
|
||
DEVICE_AND_API_INIT(behavior_out, DT_INST_LABEL(0), behavior_out_init, NULL, NULL, APPLICATION, | ||
CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &behavior_outputs_driver_api); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.