Skip to content

Commit 97a2cea

Browse files
author
Hrvoje Cavrak
committed
DeskHop v0.64 (Bugfixes)
- Caps lock / Num lock didn't correctly remember output B state - Windows relative mouse was jumping from secondary to primary - Fixed NKRO keyboards without report ID - IMPORTANT: moved config shortcut to LEFT CTRL + RIGHT SHIFT + C + O because users had issues with keyboards unable to send both shifts. Sorry for changing this.
1 parent a249aa5 commit 97a2cea

File tree

8 files changed

+77
-25
lines changed

8 files changed

+77
-25
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cmake_minimum_required(VERSION 3.6)
22

33
set(VERSION_MAJOR 00)
4-
set(VERSION_MINOR 156)
4+
set(VERSION_MINOR 157)
55

66
set(PICO_SDK_FETCH_FROM_GIT off)
77
set(PICO_BOARD=pico)

src/handlers.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,12 @@ void handle_mouse_zoom_msg(uart_packet_t *packet, device_t *state) {
172172

173173
/* Process request to update keyboard LEDs */
174174
void handle_set_report_msg(uart_packet_t *packet, device_t *state) {
175-
state->keyboard_leds[BOARD_ROLE] = packet->data[0];
176-
restore_leds(state);
175+
/* We got this via serial, so it's stored to the opposite of our board role */
176+
state->keyboard_leds[OTHER_ROLE] = packet->data[0];
177+
178+
/* If we have a keyboard we can control leds on, restore state if active */
179+
if (global_state.keyboard_connected && !CURRENT_BOARD_IS_ACTIVE_OUTPUT)
180+
restore_leds(state);
177181
}
178182

179183
/* Process request to block mouse from switching, update internal state */

src/hid_report.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,6 @@ int32_t _extract_kbd_nkro(uint8_t *raw_report, int len, hid_interface_t *iface,
275275

276276
int32_t extract_kbd_data(
277277
uint8_t *raw_report, int len, uint8_t itf, hid_interface_t *iface, hid_keyboard_report_t *report) {
278-
int report_id = raw_report[0];
279278

280279
/* Clear the report to start fresh */
281280
memset(report, 0, KBD_REPORT_LENGTH);
@@ -285,9 +284,7 @@ int32_t extract_kbd_data(
285284
return _extract_kbd_boot(raw_report, len, report);
286285

287286
/* NKRO is a special case */
288-
if (report_id > 0
289-
&& report_id == iface->keyboard.nkro.report_id
290-
&& iface->keyboard.is_nkro)
287+
if (iface->keyboard.is_nkro)
291288
return _extract_kbd_nkro(raw_report, len, iface, report);
292289

293290
/* If we're getting 8 bytes of report, it's safe to assume standard modifier + reserved + keys */

src/include/main.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949

5050
#define ABSOLUTE 0
5151
#define RELATIVE 1
52+
#define TOUCH 2
5253

5354
#define MOUSE_BOOT_REPORT_LEN 4
5455
#define MOUSE_ZOOM_SCALING_FACTOR 2
@@ -76,6 +77,7 @@
7677
#define SERIAL_RX_PIN (global_state.board_role == OUTPUT_A ? BOARD_A_RX : BOARD_B_RX)
7778

7879
#define BOARD_ROLE (global_state.board_role)
80+
#define OTHER_ROLE (BOARD_ROLE == OUTPUT_A ? OUTPUT_B : OUTPUT_A)
7981

8082
/********* Serial port definitions **********/
8183
#define SERIAL_UART uart0
@@ -351,7 +353,7 @@ typedef struct TU_ATTR_PACKED {
351353
multiple desktops (Windows/MacOS) */
352354
typedef struct {
353355
uint8_t tip_pressure;
354-
uint8_t buttons; // Buttons
356+
uint8_t buttons; // Digitizer buttons
355357
uint16_t x; // X coordinate (0-32767)
356358
uint16_t y; // Y coordinate (0-32767)
357359
} touch_report_t;
@@ -423,6 +425,7 @@ typedef struct {
423425
bool onboard_led_state; // True when LED is ON
424426
bool relative_mouse; // True when relative mouse mode is used
425427
bool config_mode_active; // True when config mode is active
428+
bool digitizer_active; // True when digitizer Win/Mac workaround is active
426429

427430
/* Onboard LED blinky (provide feedback when e.g. mouse connected) */
428431
int32_t blinks_left; // How many blink transitions are left

src/include/usb_descriptors.h

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
#define REPORT_ID_SYSTEM 4
3333

3434
// Interface 1
35-
#define REPORT_ID_RELMOUSE 5
35+
#define REPORT_ID_RELMOUSE 5
36+
#define REPORT_ID_DIGITIZER 7
3637

3738
// Interface 2
3839
#define REPORT_ID_VENDOR 6
@@ -173,7 +174,7 @@ HID_COLLECTION_END \
173174
HID_REPORT_SIZE ( 3 ) ,\
174175
HID_INPUT ( HID_CONSTANT ) ,\
175176
HID_USAGE_PAGE ( HID_USAGE_PAGE_DESKTOP ) ,\
176-
/* X, Y position [-127, 127] */ \
177+
/* X, Y position [-32767, 32767] */ \
177178
HID_USAGE ( HID_USAGE_DESKTOP_X ) ,\
178179
HID_USAGE ( HID_USAGE_DESKTOP_Y ) ,\
179180
HID_LOGICAL_MIN_N ( 0x8000, 2 ) ,\
@@ -195,4 +196,52 @@ HID_COLLECTION_END \
195196
HID_COLLECTION_END , \
196197
HID_COLLECTION_END \
197198

199+
#define HID_USAGE_DIGITIZER 0x01
200+
201+
#define TUD_HID_REPORT_DESC_DIGITIZER_PEN(...) \
202+
HID_USAGE_PAGE ( HID_USAGE_PAGE_DIGITIZER ) ,\
203+
HID_USAGE ( HID_USAGE_DIGITIZER ) ,\
204+
HID_COLLECTION ( HID_COLLECTION_APPLICATION ) ,\
205+
/* Report ID if any */\
206+
__VA_ARGS__ \
207+
HID_USAGE ( HID_USAGE_DIGITIZER ) ,\
208+
HID_COLLECTION ( HID_COLLECTION_PHYSICAL ) ,\
209+
HID_USAGE_PAGE ( HID_USAGE_PAGE_DIGITIZER ) ,\
210+
/* Tip Pressure */\
211+
HID_USAGE ( 0x30 ) ,\
212+
HID_LOGICAL_MIN ( 0x00 ) ,\
213+
HID_LOGICAL_MAX ( 0xff ) ,\
214+
HID_REPORT_COUNT( 1 ) ,\
215+
HID_REPORT_SIZE ( 8 ) ,\
216+
HID_INPUT ( HID_DATA | HID_VARIABLE | HID_ABSOLUTE ) ,\
217+
\
218+
HID_REPORT_COUNT( 5 ) ,\
219+
HID_REPORT_SIZE ( 1 ) ,\
220+
/* In range */\
221+
HID_USAGE ( 0x32 ) ,\
222+
/* Tip switch */\
223+
HID_USAGE ( 0x42 ) ,\
224+
/* Eraser */\
225+
HID_USAGE ( 0x45 ) ,\
226+
/* Barrel switch */\
227+
HID_USAGE ( 0x44 ) ,\
228+
/* Invert */\
229+
HID_USAGE ( 0x3c ) ,\
230+
HID_INPUT ( HID_DATA | HID_VARIABLE | HID_ABSOLUTE ) ,\
231+
\
232+
HID_REPORT_COUNT( 3 ) ,\
233+
HID_REPORT_SIZE ( 1 ) ,\
234+
HID_INPUT ( HID_CONSTANT ) ,\
235+
/* X and Y coordinates */\
236+
HID_USAGE_PAGE ( HID_USAGE_PAGE_DESKTOP ) ,\
237+
HID_USAGE ( HID_USAGE_DESKTOP_X ) ,\
238+
HID_USAGE ( HID_USAGE_DESKTOP_Y ) ,\
239+
HID_LOGICAL_MIN ( 0 ) ,\
240+
HID_LOGICAL_MAX_N ( 32767, 2 ) ,\
241+
HID_REPORT_SIZE ( 16 ) ,\
242+
HID_REPORT_COUNT ( 2 ) ,\
243+
HID_INPUT ( HID_DATA | HID_VARIABLE | HID_ABSOLUTE) ,\
244+
HID_COLLECTION_END ,\
245+
HID_COLLECTION_END
246+
198247
#endif /* USB_DESCRIPTORS_H_ */

src/keyboard.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ hotkey_combo_t hotkeys[] = {
5252
.action_handler = &screenlock_hotkey_handler},
5353

5454
/* Toggle gaming mode */
55-
{.modifier = KEYBOARD_MODIFIER_LEFTSHIFT | KEYBOARD_MODIFIER_RIGHTSHIFT,
55+
{.modifier = KEYBOARD_MODIFIER_LEFTCTRL | KEYBOARD_MODIFIER_RIGHTSHIFT,
5656
.keys = {HID_KEY_G},
5757
.key_count = 1,
5858
.acknowledge = true,
@@ -73,7 +73,7 @@ hotkey_combo_t hotkeys[] = {
7373
.action_handler = &screen_border_hotkey_handler},
7474

7575
/* Switch to configuration mode */
76-
{.modifier = KEYBOARD_MODIFIER_RIGHTSHIFT | KEYBOARD_MODIFIER_LEFTSHIFT,
76+
{.modifier = KEYBOARD_MODIFIER_LEFTCTRL | KEYBOARD_MODIFIER_RIGHTSHIFT,
7777
.keys = {HID_KEY_C, HID_KEY_O},
7878
.key_count = 2,
7979
.acknowledge = true,

src/mouse.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,6 @@ void update_mouse_position(device_t *state, mouse_values_t *values) {
6464
output_t *current = &state->config.output[state->active_output];
6565
uint8_t reduce_speed = 0;
6666

67-
/* If relative mouse mode is active, just pass mouse movements and update nothing */
68-
if (state->relative_mouse)
69-
return;
70-
7167
/* Check if we are configured to move slowly */
7268
if (state->mouse_zoom)
7369
reduce_speed = MOUSE_ZOOM_SCALING_FACTOR;
@@ -299,7 +295,7 @@ void process_mouse_queue_task(device_t *state) {
299295
if (!tud_hid_n_ready(ITF_NUM_HID))
300296
return;
301297

302-
/* ... try sending it to the host, if it's successful */
298+
/* Try sending it to the host, if it's successful */
303299
bool succeeded = tud_mouse_report(report.mode, report.buttons, report.x, report.y, report.wheel);
304300

305301
/* ... then we can remove it from the queue */

src/usb.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,14 @@ void tud_hid_set_report_cb(uint8_t instance,
7979
leds |= KEYBOARD_LED_CAPSLOCK;
8080
}
8181

82-
global_state.keyboard_leds[global_state.active_output] = leds;
82+
global_state.keyboard_leds[BOARD_ROLE] = leds;
8383

84-
/* If the board doesn't have the keyboard hooked up directly, we need to relay this information
85-
to the other one that has (and LEDs you can turn on). */
86-
if (global_state.keyboard_connected)
84+
/* If the board has a keyboard connected directly, restore those leds. */
85+
if (global_state.keyboard_connected && CURRENT_BOARD_IS_ACTIVE_OUTPUT)
8786
restore_leds(&global_state);
88-
else
89-
send_value(leds, KBD_SET_REPORT_MSG);
87+
88+
/* Always send to the other one, so it is aware of the change */
89+
send_value(leds, KBD_SET_REPORT_MSG);
9090
}
9191

9292
/* Invoked when device is mounted */
@@ -194,8 +194,11 @@ void tuh_hid_report_received_cb(uint8_t dev_addr, uint8_t instance, uint8_t cons
194194
if (instance >= MAX_INTERFACES)
195195
return;
196196

197-
if (iface->uses_report_id) {
198-
uint8_t report_id = report[0];
197+
if (itf_protocol == HID_ITF_PROTOCOL_NONE) {
198+
uint8_t report_id = 0;
199+
200+
if (iface->uses_report_id)
201+
report_id = report[0];
199202

200203
if (report_id < MAX_REPORTS) {
201204
process_report_f receiver = iface->report_handler[report_id];

0 commit comments

Comments
 (0)