Skip to content

Commit 41a54e4

Browse files
author
Hrvoje Cavrak
committed
Refactoring header files, some cleanup.
1 parent 0ae26eb commit 41a54e4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1154
-793
lines changed

CMakeLists.txt

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

33
## Version Configuration
44
set(VERSION_MAJOR 00)
5-
set(VERSION_MINOR 162)
5+
set(VERSION_MINOR 170)
66

77
## Release Type Selection
88
option(DH_DEBUG "Build a debug version" OFF)

src/constants.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
/*
2+
* This file is part of DeskHop (https://github.com/hrvach/deskhop).
3+
* Copyright (c) 2025 Hrvoje Cavrak
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, version 3.
8+
*
9+
* See the file LICENSE for the full license text.
10+
*/
111
#include "main.h"
212

313
/* CRC32 Lookup Table, Polynomial = 0xEDB88320 */
@@ -35,4 +45,3 @@ const uint32_t crc32_lookup_table[] = {
3545
0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf,
3646
0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
3747
};
38-

src/defaults.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
/*
2+
* This file is part of DeskHop (https://github.com/hrvach/deskhop).
3+
* Copyright (c) 2025 Hrvoje Cavrak
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, version 3.
8+
*
9+
* See the file LICENSE for the full license text.
10+
*/
111
#include "main.h"
212

313
/* Default configuration */
@@ -50,5 +60,5 @@ const config_t default_config = {
5060
.enable_acceleration = ENABLE_ACCELERATION,
5161
.hotkey_toggle = HID_KEY_F24,
5262
.kbd_led_as_indicator = KBD_LED_AS_INDICATOR,
53-
.jump_treshold = 0,
63+
.jump_threshold = 0,
5464
};

src/handlers.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,12 @@
11
/*
22
* This file is part of DeskHop (https://github.com/hrvach/deskhop).
3-
* Copyright (c) 2024 Hrvoje Cavrak
3+
* Copyright (c) 2025 Hrvoje Cavrak
44
*
55
* This program is free software: you can redistribute it and/or modify
66
* it under the terms of the GNU General Public License as published by
77
* the Free Software Foundation, version 3.
88
*
9-
* This program is distributed in the hope that it will be useful, but
10-
* WITHOUT ANY WARRANTY; without even the implied warranty of
11-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12-
* General Public License for more details.
13-
*
14-
* You should have received a copy of the GNU General Public License
15-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
9+
* See the file LICENSE for the full license text.
1610
*/
1711

1812
#include "main.h"

src/hid_parser.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* This file is part of DeskHop (https://github.com/hrvach/deskhop).
3-
* Copyright (c) 2024 Hrvoje Cavrak
3+
* Copyright (c) 2025 Hrvoje Cavrak
44
*
55
* Based on the TinyUSB HID parser routine and the amazing USB2N64
66
* adapter (https://github.com/pdaxrom/usb2n64-adapter)
@@ -9,15 +9,8 @@
99
* it under the terms of the GNU General Public License as published by
1010
* the Free Software Foundation, version 3.
1111
*
12-
* This program is distributed in the hope that it will be useful, but
13-
* WITHOUT ANY WARRANTY; without even the implied warranty of
14-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15-
* General Public License for more details.
16-
*
17-
* You should have received a copy of the GNU General Public License
18-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
12+
* See the file LICENSE for the full license text.
1913
*/
20-
2114
#include "main.h"
2215

2316
#define IS_BLOCK_END (parser->collection.start == parser->collection.end)

src/hid_report.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,13 @@
11
/*
22
* This file is part of DeskHop (https://github.com/hrvach/deskhop).
3-
* Copyright (c) 2024 Hrvoje Cavrak
3+
* Copyright (c) 2025 Hrvoje Cavrak
44
*
55
* This program is free software: you can redistribute it and/or modify
66
* it under the terms of the GNU General Public License as published by
77
* the Free Software Foundation, version 3.
88
*
9-
* This program is distributed in the hope that it will be useful, but
10-
* WITHOUT ANY WARRANTY; without even the implied warranty of
11-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12-
* General Public License for more details.
13-
*
14-
* You should have received a copy of the GNU General Public License
15-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
9+
* See the file LICENSE for the full license text.
1610
*/
17-
1811
#include "hid_report.h"
1912
#include "main.h"
2013

src/include/config.h

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* This file is part of DeskHop (https://github.com/hrvach/deskhop).
3+
* Copyright (c) 2025 Hrvoje Cavrak
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, version 3.
8+
*
9+
* See the file LICENSE for the full license text.
10+
*/
11+
#pragma once
12+
13+
#include <stdint.h>
14+
#include "structs.h"
15+
#include "misc.h"
16+
#include "screen.h"
17+
18+
#define CURRENT_CONFIG_VERSION 8
19+
20+
/*==============================================================================
21+
* Configuration Data
22+
* Structures and variables related to device configuration.
23+
*==============================================================================*/
24+
25+
extern const config_t default_config;
26+
27+
/*==============================================================================
28+
* Configuration API
29+
* Functions and data structures for accessing and modifying configuration.
30+
*==============================================================================*/
31+
32+
extern const field_map_t api_field_map[];
33+
const field_map_t* get_field_map_entry(uint32_t);
34+
const field_map_t* get_field_map_index(uint32_t);
35+
size_t get_field_map_length(void);
36+
37+
/*==============================================================================
38+
* Configuration Management and Packet Processing
39+
* Functions for loading, saving, wiping, and resetting device configuration.
40+
*==============================================================================*/
41+
42+
void load_config(device_t *);
43+
void queue_cfg_packet(uart_packet_t *, device_t *);
44+
void reset_config_timer(device_t *);
45+
void save_config(device_t *);
46+
bool validate_packet(uart_packet_t *);
47+
void wipe_config(void);

src/include/constants.h

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* This file is part of DeskHop (https://github.com/hrvach/deskhop).
3+
* Copyright (c) 2025 Hrvoje Cavrak
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, version 3.
8+
*
9+
* See the file LICENSE for the full license text.
10+
*/
11+
#pragma once
12+
#include <stdint.h>
13+
14+
/*==============================================================================
15+
* Board and Output Roles
16+
*==============================================================================*/
17+
18+
#define OUTPUT_A 0
19+
#define OUTPUT_B 1
20+
21+
/*==============================================================================
22+
* HID Interface Numbers
23+
*==============================================================================*/
24+
25+
#define ITF_NUM_HID 0
26+
#define ITF_NUM_HID_REL_M 1
27+
#define ITF_NUM_HID_VENDOR 1
28+
#define ITF_NUM_MSC 2
29+
30+
/*==============================================================================
31+
* Mouse Modes
32+
*==============================================================================*/
33+
34+
#define ABSOLUTE 0
35+
#define RELATIVE 1
36+
#define TOUCH 2
37+
38+
/*==============================================================================
39+
* Boolean States
40+
*==============================================================================*/
41+
42+
#define ENABLE 1
43+
#define DISABLE 0
44+
45+
/*==============================================================================
46+
* Numerical Constants
47+
*==============================================================================*/
48+
49+
#define CONFIG_MODE_TIMEOUT 300000000 // 5 minutes into the future
50+
#define JITTER_DISTANCE 2
51+
#define MOUSE_BOOT_REPORT_LEN 4
52+
#define MOUSE_ZOOM_SCALING_FACTOR 2
53+
#define NUM_SCREENS 2
54+
55+
/*==============================================================================
56+
* Utility Macros
57+
*==============================================================================*/
58+
59+
#define _HZ(x) ((uint64_t)((1000000) / (x)))
60+
#define _MS(x) (x * 1000)
61+
#define _SEC(x) (x * 1000000)
62+
#define _TOP() 0
63+
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
64+
#define CURRENT_BOARD_IS_ACTIVE_OUTPUT (global_state.active_output == global_state.board_role)

src/include/dma.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* This file is part of DeskHop (https://github.com/hrvach/deskhop).
3+
* Copyright (c) 2025 Hrvoje Cavrak
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, version 3.
8+
*
9+
* See the file LICENSE for the full license text.
10+
*/
11+
#pragma once
12+
13+
#include <hardware/dma.h>
14+
15+
/*==============================================================================
16+
* DMA Buffer Sizes
17+
*==============================================================================*/
18+
19+
#define DMA_RX_BUFFER_SIZE 1024
20+
#define DMA_TX_BUFFER_SIZE 32
21+
22+
/*==============================================================================
23+
* DMA Buffers
24+
*==============================================================================*/
25+
26+
extern uint8_t uart_rxbuf[DMA_RX_BUFFER_SIZE] __attribute__((aligned(DMA_RX_BUFFER_SIZE)));
27+
extern uint8_t uart_txbuf[DMA_TX_BUFFER_SIZE] __attribute__((aligned(DMA_TX_BUFFER_SIZE)));
28+
29+
/*==============================================================================
30+
* Ring Buffer Macro
31+
*==============================================================================*/
32+
33+
#define NEXT_RING_IDX(x) ((x + 1) & 0x3FF)

src/include/firmware.h

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* This file is part of DeskHop (https://github.com/hrvach/deskhop).
3+
* Copyright (c) 2025 Hrvoje Cavrak
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, version 3.
8+
*
9+
* See the file LICENSE for the full license text.
10+
*/
11+
#pragma once
12+
13+
#include "structs.h"
14+
15+
/*==============================================================================
16+
* Firmware Update Functions
17+
* Functions for managing firmware updates, CRC calculation, and related tasks.
18+
*==============================================================================*/
19+
20+
uint32_t calculate_firmware_crc32(void);
21+
void reboot(void);
22+
void write_flash_page(uint32_t, uint8_t *);
23+
24+
/*==============================================================================
25+
* UART Packet Fetching
26+
* Functions to handle incoming UART packets, especially for firmware updates.
27+
*==============================================================================*/
28+
void fetch_packet(device_t *);
29+
uint32_t get_ptr_delta(uint32_t, device_t *);
30+
bool is_start_of_packet(device_t *);
31+
void request_byte(device_t *, uint32_t);
32+
33+
/*==============================================================================
34+
* Button Interaction
35+
* Functions interacting with the button, e.g. checking if pressed.
36+
*==============================================================================*/
37+
38+
bool is_bootsel_pressed(void);

0 commit comments

Comments
 (0)