disco_f303vc and Num_lock setting
in progress, use esp32
This commit is contained in:
Vendored
+10
-7
@@ -1,7 +1,10 @@
|
||||
{
|
||||
// See http://go.microsoft.com/fwlink/?LinkId=827846
|
||||
// for the documentation about the extensions.json format
|
||||
"recommendations": [
|
||||
"platformio.platformio-ide"
|
||||
]
|
||||
}
|
||||
{
|
||||
// See http://go.microsoft.com/fwlink/?LinkId=827846
|
||||
// for the documentation about the extensions.json format
|
||||
"recommendations": [
|
||||
"platformio.platformio-ide"
|
||||
],
|
||||
"unwantedRecommendations": [
|
||||
"ms-vscode.cpptools-extension-pack"
|
||||
]
|
||||
}
|
||||
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"stm32-for-vscode.openOCDPath": false,
|
||||
"stm32-for-vscode.armToolchainPath": false
|
||||
}
|
||||
+26
-11
@@ -12,7 +12,6 @@
|
||||
platform = ststm32
|
||||
board = bluepill_f103c8_128k
|
||||
framework = arduino
|
||||
lib_extra_dirs = ~/Documents/Arduino/libraries
|
||||
build_flags =
|
||||
-D PIO_FRAMEWORK_ARDUINO_ENABLE_HID
|
||||
-D USBCON
|
||||
@@ -21,20 +20,37 @@ build_flags =
|
||||
-D USB_MANUFACTURER="STMicroelectronics"
|
||||
-D USB_PRODUCT="Apple Desktop Bus Device"
|
||||
-D HAL_PCD_MODULE_ENABLED
|
||||
-D STM32F1
|
||||
;-D PIO_FRAMEWORK_ARDUINO_ENABLE_CDC
|
||||
;-D PIO_FRAMEWORK_ARDUINO_USB_FULLSPEED_FULLMODE
|
||||
|
||||
upload_flags = -c set CPUTAPID 0x2ba01477 ; Chinese clone, genuine is 0x1ba01477
|
||||
debug_tool = stlink
|
||||
upload_protocol = stlink
|
||||
debug_server =
|
||||
/Users/szymonlopaciuk/.platformio/packages/tool-openocd/bin/openocd
|
||||
-s /Users/szymonlopaciuk/.platformio/packages/tool-openocd/scripts
|
||||
-f interface/stlink-v2.cfg
|
||||
-c "transport select hla_swd"
|
||||
-c "set CPUTAPID 0x2ba01477" ; Chinese clone, genuine is 0x1ba01477
|
||||
-f target/stm32f1x.cfg
|
||||
-c "reset_config none"
|
||||
test_ignore = test_desktop
|
||||
monitor_speed = 115200
|
||||
|
||||
|
||||
[env:stm32f3_discovery]
|
||||
platform = ststm32
|
||||
board = disco_f303vc
|
||||
framework = arduino
|
||||
build_flags =
|
||||
-D PIO_FRAMEWORK_ARDUINO_ENABLE_HID
|
||||
-D USBCON
|
||||
-D USBD_VID=0x0483
|
||||
-D USBD_PID=0x5711
|
||||
-D USB_MANUFACTURER="STMicroelectronics"
|
||||
-D USB_PRODUCT="Apple Desktop Bus Device"
|
||||
-D STM32F3link
|
||||
-D HAL_PCD_MODULE_ENABLED
|
||||
-D USBD_USE_HID_COMPOSITE
|
||||
-D PIO_FRAMEWORK_ARDUINO_ENABLE_HID
|
||||
; -D PIO_FRAMEWORK_ARDUINO_ENABLE_CDC
|
||||
; -D PIO_FRAMEWORK_ARDUINO_USB_FULLSPEED_FULLMODE
|
||||
debug_tool = stlink
|
||||
upload_protocol = stlink
|
||||
monitor_speed = 115200
|
||||
|
||||
|
||||
[env:native]
|
||||
platform = native
|
||||
@@ -42,5 +58,4 @@ build_flags =
|
||||
-D USBCON
|
||||
-D USBD_USE_HID_COMPOSITE
|
||||
-D PIO_FRAMEWORK_ARDUINO_ENABLE_HID
|
||||
-I $PROJECT_DIR/test/test_desktop/include
|
||||
test_build_project_src = true
|
||||
@@ -17,6 +17,7 @@
|
||||
#define ADB_KEY_LEFT_COMMAND 0x37
|
||||
#define ADB_KEY_RIGHT_COMMAND 0x37
|
||||
#define ADB_KEY_CAPS_LOCK 0x39
|
||||
#define ADB_KEY_NUM_LOCK 0x47
|
||||
|
||||
// Convert axis from 7b 2's complement to int8_t
|
||||
#define ADB_MOUSE_CONV_AXIS(x) (int8_t)(x << 1)
|
||||
|
||||
+9
-9
@@ -116,20 +116,20 @@ uint8_t adb_keycode_to_hid[128] = {
|
||||
/* 0x61 = */ KEY_F6,
|
||||
/* 0x62 = */ KEY_F7,
|
||||
/* 0x63 = */ KEY_F3,
|
||||
/* 0x64 = */ KEY_F8,
|
||||
/* 0x65 = */ KEY_F9,
|
||||
/* 0x66 = */ 0,
|
||||
/* 0x67 = */ KEY_VOLUMEDOWN, //KEY_F11,
|
||||
/* 0x64 = */ KEY_MEDIA_PREVIOUSSONG, // F7: Lecture en arrière
|
||||
/* 0x65 = */ KEY_MEDIA_PLAYPAUSE, // F8: Play/Pause
|
||||
/* 0x66 = */ KEY_MEDIA_NEXTSONG, // F9: Lecture suivante
|
||||
/* 0x67 = */ KEY_VOLUMEDOWN,
|
||||
/* 0x68 = */ 0,
|
||||
/* 0x69 = */ KEY_F13,
|
||||
/* 0x69 = */ 0,
|
||||
/* 0x6a = */ 0,
|
||||
/* 0x6b = */ KEY_F14,
|
||||
/* 0x6b = */ 0,
|
||||
/* 0x6c = */ 0,
|
||||
/* 0x6d = */ KEY_MUTE, //KEY_F10,
|
||||
/* 0x6d = */ KEY_MUTE, // F10: Mute
|
||||
/* 0x6e = */ 0,
|
||||
/* 0x6f = */ KEY_VOLUMEUP, //KEY_F12,
|
||||
/* 0x6f = */ KEY_VOLUMEUP, // F12: Volume +
|
||||
/* 0x70 = */ 0,
|
||||
/* 0x71 = */ KEY_F15,
|
||||
/* 0x71 = */ 0,
|
||||
/* 0x72 = */ KEY_HELP, // or KEY_INSERT
|
||||
/* 0x73 = */ KEY_HOME,
|
||||
/* 0x74 = */ KEY_PAGEUP,
|
||||
|
||||
+41
-9
@@ -1,7 +1,15 @@
|
||||
#ifndef UNIT_TEST
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <stm32f1xx_hal_gpio.h>
|
||||
|
||||
#ifdef STM32F1
|
||||
#include <stm32f1xx_hal_gpio.h> // Inclusion pour STM32F1
|
||||
#elif defined(STM32F3)
|
||||
#include <stm32f3xx_hal_gpio.h> // Inclusion pour STM32F3
|
||||
#else
|
||||
#error "Unsupported STM32 series. Please define STM32F1 or STM32F3 in build_flags."
|
||||
#endif
|
||||
|
||||
#include "hid_tables.h"
|
||||
#include "adb_structures.h"
|
||||
#include "hid_keyboard.h"
|
||||
@@ -14,6 +22,9 @@
|
||||
bool apple_extended_detected = false;
|
||||
bool keyboard_present = false, mouse_present = false;
|
||||
|
||||
bool led_caps = false; // Déclaration globale pour Caps Lock
|
||||
bool led_num = true; // Déclaration globale pour Num Lock (actif par défaut)
|
||||
|
||||
#ifdef PIO_FRAMEWORK_ARDUINO_ENABLE_CDC
|
||||
void print16b(uint16_t buff) {
|
||||
uint16_t mask = (1 << 15);
|
||||
@@ -74,12 +85,14 @@ void setup() {
|
||||
adb_device_update_register3(ADB_ADDR_MOUSE, reg3, mask.raw, &error);
|
||||
if (!error) mouse_present = true;
|
||||
|
||||
// Set-up successful, turn of the LED
|
||||
// Set-up successful, turn off the LED
|
||||
digitalWrite(PC13, HIGH);
|
||||
|
||||
// Activer NumLock au démarrage
|
||||
adb_keyboard_write_leds(0, led_caps, led_num); // Mise à jour des LEDs
|
||||
}
|
||||
|
||||
void keyboard_handler() {
|
||||
static bool led_caps = false;
|
||||
static hid_key_report key_report = {0};
|
||||
bool error = false;
|
||||
|
||||
@@ -90,11 +103,17 @@ void keyboard_handler() {
|
||||
|
||||
bool report_changed = hid_keyboard_set_keys_from_adb_register(&key_report, key_press);
|
||||
|
||||
// Handle the `toggle' caps lock key.
|
||||
// Every action reported by an ADB keyboard on the caps lock key
|
||||
// should be interpreted as key down, followed by key released,
|
||||
// unless the keypress was so fast, that it was pressed and depressed
|
||||
// within the same `register'. Then ignore.
|
||||
// Ignorer toutes les touches du pavé numérique si NumLock n'est pas actif
|
||||
if (!led_num) {
|
||||
for (int i = 0; i < KEY_REPORT_KEYS_COUNT; i++) {
|
||||
if ((key_report.keys[i] >= KEY_KPSLASH && key_report.keys[i] <= KEY_KPDOT || key_report.keys[i] == KEY_KPEQUAL)) {
|
||||
key_report.keys[i] = 0; // Supprimer la touche du rapport
|
||||
report_changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Gestion de la touche Caps Lock
|
||||
bool caps_lock_action = key_press.data.key0 == ADB_KEY_CAPS_LOCK ||
|
||||
key_press.data.key1 == ADB_KEY_CAPS_LOCK;
|
||||
|
||||
@@ -110,7 +129,7 @@ void keyboard_handler() {
|
||||
hid_keyboard_send_report(&key_report);
|
||||
|
||||
led_caps = !led_caps;
|
||||
adb_keyboard_write_leds(0, led_caps, 0);
|
||||
adb_keyboard_write_leds(0, led_caps, led_num); // Mise à jour des LEDs
|
||||
|
||||
// Wait a little bit
|
||||
delay(80);
|
||||
@@ -120,6 +139,19 @@ void keyboard_handler() {
|
||||
|
||||
report_changed = true;
|
||||
}
|
||||
|
||||
// Gestion de la touche Num Lock
|
||||
bool num_lock_action = key_press.data.key0 == ADB_KEY_NUM_LOCK && !key_press.data.released0 ||
|
||||
key_press.data.key1 == ADB_KEY_NUM_LOCK && !key_press.data.released1;
|
||||
|
||||
if (num_lock_action) // Changer l'état à chaque appui
|
||||
{
|
||||
led_num = !led_num;
|
||||
adb_keyboard_write_leds(0, led_caps, led_num); // Mise à jour des LEDs
|
||||
|
||||
// Pas besoin d'ajouter ou de retirer NumLock dans le rapport HID,
|
||||
// car il s'agit uniquement d'une bascule de l'état des LEDs.
|
||||
}
|
||||
|
||||
// Send the finished report
|
||||
//if (report_changed)
|
||||
|
||||
Reference in New Issue
Block a user