From 7c30fe0be98a3028964d437f5c31cc968fbf9755 Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Sun, 15 Sep 2024 23:16:00 -0600 Subject: wip --- tusb_helpers.h.gen | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100755 tusb_helpers.h.gen (limited to 'tusb_helpers.h.gen') diff --git a/tusb_helpers.h.gen b/tusb_helpers.h.gen new file mode 100755 index 0000000..4682166 --- /dev/null +++ b/tusb_helpers.h.gen @@ -0,0 +1,88 @@ +#!/usr/bin/env bash +# -*- Mode: C -*- +set -e +exec >"${0%.gen}" +cat <<'EOT' +/* tusb_helpers.h - Preprocessor macros that I think should be included in TinyUSB + * + * Copyright (c) 2024 Luke T. Shumaker + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + */ + +#ifndef _USB_HELPERS_H_ +#define _USB_HELPERS_H_ + +/* USB 2.0 §9.6.7 "String" says "The list of currently defined USB LANGIDs can be found at + * http://www.usb.org/developers/docs.html.", but that page 404s. + * + * Once upon a time the USB-IF (usb.org) published a "Language Identifiers (LANGIDs)" version 1.0, + * dated 2000-03-29. There is no longer any mention of this on usb.org, but I found a copy at + * http://www.baiheee.com/Documents/090518/090518112619/USB_LANGIDs.pdf + * + * So how does the USB-IF defined LANGIDs these days? + * + * https://www.usb.org/deprecated-links-and-tools says "To get the latest LANGID definitions go to + * https://docs.microsoft.com/en-us/windows/desktop/intl/language-identifier-constants-and-strings. This + * page will change as new LANGIDs are added." That page has no list of LANGIDs, but says "For the + * predefined primary language identifiers with their valid sublanguage identifiers, see + * [\[MS-LCID\]: Windows Language Code Identifier (LCID) + * Reference](https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-lcid/70feba9f-294e-491e-b6eb-565326e84c37f)." + * That page at the time of this writing as a PDF marked as version 16.0, dated 2024-04-24: + * https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-LCID/%5bMS-LCID%5d.pdf + * [MS-LCID] defines an LCID as a 32-bit value consisting of a 16-bit a "Language ID", a 4-bit "Sort + * ID", and 12 reserved bits. + * + * That is to say: The USB-IF has said in essence "USB LANGIDs are defined to be the 'Language ID' + * portion of Microsoft Windows LCIDs (Language Code Identifiers); refer to Microsoft's published + * list of LCID Language IDs for a list of USB LANGIDs." + * + * The scheme for Language IDs is that the least-significant-byte is "primary" ID and the + * most-significant-byte is a "sublanguage" ID within that. With this in mind, Microsoft's choice + * to sort their list of by most-significant-byte was a poor editorial choice. + */ +EOT +[ -f MS-LCID.pdf ] || wget -O MS-LCID.pdf 'https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-LCID/%5bMS-LCID%5d.pdf' +[ -f MS-LCID.txt ] || pdftotext -layout MS-LCID.pdf +