Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified binaries/deskhop.uf2
Binary file not shown.
2 changes: 1 addition & 1 deletion src/handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ void handle_wipe_config_msg(uart_packet_t *packet, device_t *state) {

/* Process consumer control message, TODO: use queue instead of sending directly */
void handle_consumer_control_msg(uart_packet_t *packet, device_t *state) {
tud_hid_n_report(0, REPORT_ID_CONSUMER, &packet->data[0], CONSUMER_CONTROL_LENGTH);
tud_hid_n_report(ITF_NUM_HID, REPORT_ID_CONSUMER, &packet->data[0], CONSUMER_CONTROL_LENGTH);
}

/* Process request to store config to flash */
Expand Down
7 changes: 4 additions & 3 deletions src/include/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,10 @@ enum screensaver_mode_e {
};

#define ITF_NUM_HID 0
#define ITF_NUM_HID_REL_M 1
#define ITF_NUM_HID_VENDOR 1
#define ITF_NUM_MSC 2
#define ITF_NUM_HID_KBD 1
#define ITF_NUM_HID_REL_M 2
#define ITF_NUM_HID_VENDOR 2
#define ITF_NUM_MSC 3

typedef struct {
int top; // When jumping from a smaller to a bigger screen, go to THIS top height
Expand Down
12 changes: 7 additions & 5 deletions src/include/usb_descriptors.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,17 @@
#define USB_DESCRIPTORS_H_

// Interface 0
#define REPORT_ID_KEYBOARD 1
#define REPORT_ID_MOUSE 2
#define REPORT_ID_CONSUMER 3
#define REPORT_ID_SYSTEM 4
#define REPORT_ID_MOUSE 1
#define REPORT_ID_CONSUMER 2
#define REPORT_ID_SYSTEM 3

// Interface 1
#define REPORT_ID_RELMOUSE 5
#define REPORT_ID_KEYBOARD 0

// Interface 2
#define REPORT_ID_RELMOUSE 5

// Interface 3
#define REPORT_ID_VENDOR 6


Expand Down
2 changes: 1 addition & 1 deletion src/include/user_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
*
* */

#define HOTKEY_TOGGLE HID_KEY_F24
#define HOTKEY_TOGGLE HID_KEY_CAPS_LOCK

/**================================================== *
* ============== Mouse Speed Factor ============== *
Expand Down
8 changes: 4 additions & 4 deletions src/keyboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,11 @@ void process_kbd_queue_task(device_t *state) {
tud_remote_wakeup();

/* If it's not ok to send yet, we'll try on the next pass */
if (!tud_hid_n_ready(ITF_NUM_HID))
if (!tud_hid_n_ready(ITF_NUM_HID_KBD))
return;

/* ... try sending it to the host, if it's successful */
bool succeeded = tud_hid_keyboard_report(REPORT_ID_KEYBOARD, report.modifier, report.keycode);
bool succeeded = tud_hid_n_keyboard_report(ITF_NUM_HID_KBD, REPORT_ID_KEYBOARD, report.modifier, report.keycode);

/* ... then we can remove it from the queue. Race conditions shouldn't happen [tm] */
if (succeeded)
Expand Down Expand Up @@ -185,7 +185,7 @@ void send_key(hid_keyboard_report_t *report, device_t *state) {
/* Decide if consumer control reports go local or to the other board */
void send_consumer_control(uint8_t *raw_report, device_t *state) {
if (CURRENT_BOARD_IS_ACTIVE_OUTPUT) {
tud_hid_n_report(0, REPORT_ID_CONSUMER, raw_report, CONSUMER_CONTROL_LENGTH);
tud_hid_n_report(ITF_NUM_HID, REPORT_ID_CONSUMER, raw_report, CONSUMER_CONTROL_LENGTH);
state->last_activity[BOARD_ROLE] = time_us_64();
} else {
queue_packet((uint8_t *)raw_report, CONSUMER_CONTROL_MSG, CONSUMER_CONTROL_LENGTH);
Expand All @@ -195,7 +195,7 @@ void send_consumer_control(uint8_t *raw_report, device_t *state) {
/* Decide if consumer control reports go local or to the other board */
void send_system_control(uint8_t *raw_report, device_t *state) {
if (CURRENT_BOARD_IS_ACTIVE_OUTPUT) {
tud_hid_n_report(0, REPORT_ID_SYSTEM, raw_report, SYSTEM_CONTROL_LENGTH);
tud_hid_n_report(ITF_NUM_HID, REPORT_ID_SYSTEM, raw_report, SYSTEM_CONTROL_LENGTH);
state->last_activity[BOARD_ROLE] = time_us_64();
} else {
queue_packet((uint8_t *)raw_report, SYSTEM_CONTROL_MSG, SYSTEM_CONTROL_LENGTH);
Expand Down
64 changes: 43 additions & 21 deletions src/usb_descriptors.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,13 @@ uint8_t const *tud_descriptor_device_cb(void) {

// Relative mouse is used to overcome limitations of multiple desktops on MacOS and Windows

uint8_t const desc_hid_report[] = {TUD_HID_REPORT_DESC_KEYBOARD(HID_REPORT_ID(REPORT_ID_KEYBOARD)),
TUD_HID_REPORT_DESC_ABS_MOUSE(HID_REPORT_ID(REPORT_ID_MOUSE)),
uint8_t const desc_hid_report[] = {TUD_HID_REPORT_DESC_ABS_MOUSE(HID_REPORT_ID(REPORT_ID_MOUSE)),
TUD_HID_REPORT_DESC_CONSUMER_CTRL(HID_REPORT_ID(REPORT_ID_CONSUMER)),
TUD_HID_REPORT_DESC_SYSTEM_CONTROL(HID_REPORT_ID(REPORT_ID_SYSTEM))
};

uint8_t const desc_hid_report_keyboard[] = {TUD_HID_REPORT_DESC_KEYBOARD(HID_REPORT_ID(REPORT_ID_KEYBOARD))};

uint8_t const desc_hid_report_relmouse[] = {TUD_HID_REPORT_DESC_MOUSE(HID_REPORT_ID(REPORT_ID_RELMOUSE))};

uint8_t const desc_hid_report_vendor[] = {TUD_HID_REPORT_DESC_VENDOR_CTRL(HID_REPORT_ID(REPORT_ID_VENDOR))};
Expand All @@ -74,6 +75,8 @@ uint8_t const *tud_hid_descriptor_report_cb(uint8_t instance) {
switch(instance) {
case ITF_NUM_HID:
return desc_hid_report;
case ITF_NUM_HID_KBD:
return desc_hid_report_keyboard;
case ITF_NUM_HID_REL_M:
return desc_hid_report_relmouse;
default:
Expand Down Expand Up @@ -104,11 +107,12 @@ char const *string_desc_arr[] = {
"Hrvoje Cavrak", // 1: Manufacturer
"DeskHop Switch", // 2: Product
"0", // 3: Serials, should use chip ID
"DeskHop Helper", // 4: Mouse Helper Interface
"DeskHop Config", // 5: Vendor Interface
"DeskHop Disk", // 6: Disk Interface
"DeskHop Mouse", // 4: Mouse Interface
"DeskHop Keyboard", // 5: Keyboard Interface
"DeskHop Config", // 6: Vendor Interface
"DeskHop Disk", // 7: Disk Interface
#ifdef DH_DEBUG
"DeskHop Debug", // 7: Debug Interface
"DeskHop Debug", // 8: Debug Interface
#endif
};

Expand All @@ -119,6 +123,7 @@ enum {
STRID_PRODUCT,
STRID_SERIAL,
STRID_MOUSE,
STRID_KEYBOARD,
STRID_VENDOR,
STRID_DISK,
STRID_DEBUG,
Expand Down Expand Up @@ -168,30 +173,31 @@ uint16_t const *tud_descriptor_string_cb(uint8_t index, uint16_t langid) {
//--------------------------------------------------------------------+

#define EPNUM_HID 0x81
#define EPNUM_HID_REL_M 0x82
#define EPNUM_HID_VENDOR 0x83
#define EPNUM_HID_KBD 0x82
#define EPNUM_HID_REL_M 0x83
#define EPNUM_HID_VENDOR 0x84

#define EPNUM_MSC_OUT 0x04
#define EPNUM_MSC_IN 0x84
#define EPNUM_MSC_OUT 0x05
#define EPNUM_MSC_IN 0x85

#ifndef DH_DEBUG

#define ITF_NUM_TOTAL 2
#define ITF_NUM_TOTAL_CONFIG 3
#define CONFIG_TOTAL_LEN (TUD_CONFIG_DESC_LEN + 2 * TUD_HID_DESC_LEN)
#define CONFIG_TOTAL_LEN_CFG (TUD_CONFIG_DESC_LEN + 2 * TUD_HID_DESC_LEN + TUD_MSC_DESC_LEN)
#define ITF_NUM_TOTAL 3
#define ITF_NUM_TOTAL_CONFIG 4
#define CONFIG_TOTAL_LEN (TUD_CONFIG_DESC_LEN + 3 * TUD_HID_DESC_LEN)
#define CONFIG_TOTAL_LEN_CFG (TUD_CONFIG_DESC_LEN + 3 * TUD_HID_DESC_LEN + TUD_MSC_DESC_LEN)

#else
#define ITF_NUM_CDC 3
#define ITF_NUM_TOTAL 3
#define ITF_NUM_TOTAL_CONFIG 4
#define ITF_NUM_TOTAL 4
#define ITF_NUM_TOTAL_CONFIG 5

#define CONFIG_TOTAL_LEN (TUD_CONFIG_DESC_LEN + 2 * TUD_HID_DESC_LEN + TUD_CDC_DESC_LEN)
#define CONFIG_TOTAL_LEN_CFG (TUD_CONFIG_DESC_LEN + 2 * TUD_HID_DESC_LEN + TUD_MSC_DESC_LEN + TUD_CDC_DESC_LEN)
#define CONFIG_TOTAL_LEN (TUD_CONFIG_DESC_LEN + 3 * TUD_HID_DESC_LEN + TUD_CDC_DESC_LEN)
#define CONFIG_TOTAL_LEN_CFG (TUD_CONFIG_DESC_LEN + 3 * TUD_HID_DESC_LEN + TUD_MSC_DESC_LEN + TUD_CDC_DESC_LEN)

#define EPNUM_CDC_NOTIF 0x85
#define EPNUM_CDC_OUT 0x06
#define EPNUM_CDC_IN 0x86
#define EPNUM_CDC_NOTIF 0x86
#define EPNUM_CDC_OUT 0x07
#define EPNUM_CDC_IN 0x87

#endif

Expand All @@ -209,6 +215,14 @@ uint8_t const desc_configuration[] = {
CFG_TUD_HID_EP_BUFSIZE,
1),

TUD_HID_DESCRIPTOR(ITF_NUM_HID_KBD,
STRID_KEYBOARD,
HID_ITF_PROTOCOL_NONE,
sizeof(desc_hid_report_keyboard),
EPNUM_HID_KBD,
CFG_TUD_HID_EP_BUFSIZE,
1),

TUD_HID_DESCRIPTOR(ITF_NUM_HID_REL_M,
STRID_MOUSE,
HID_ITF_PROTOCOL_NONE,
Expand Down Expand Up @@ -236,6 +250,14 @@ uint8_t const desc_configuration_config[] = {
CFG_TUD_HID_EP_BUFSIZE,
1),

TUD_HID_DESCRIPTOR(ITF_NUM_HID_KBD,
STRID_KEYBOARD,
HID_ITF_PROTOCOL_NONE,
sizeof(desc_hid_report_keyboard),
EPNUM_HID_KBD,
CFG_TUD_HID_EP_BUFSIZE,
1),

TUD_HID_DESCRIPTOR(ITF_NUM_HID_VENDOR,
STRID_VENDOR,
HID_ITF_PROTOCOL_NONE,
Expand Down