"NO NO I SWEAR it's REALLY EASY BECAUSE ... "
( it ISN'T )
"Have you EVER done THIS THING in particular ?" .. " .. erm .. NO .. but I HEARD that there's that lib .. "
( yes there's, it's "super crapola 0 documented" and does not do what I want plus it's from 2015 and apparently untouched ) ...
So .. that was more or less some conversation between me and my bro .. "that got me in getting my hands very dirty with something I kinda sworn I would have never touched" BUT I tought that "for this particular thing MAYBE it COULD be OK - cause 'everyone says it's so OK for' " ...
Must be said "I had already something better", some Cypress MCU/thing .. except that in that case "I cannot find a single worked sample about it" and "sure how hard it can be ?" .. .. REAL HARD if you don't know anything about it ..
So I have those Keyboard "too nice to be thrown away" .. and "too old to be of too much use" .. so .. hum .. "MAYBE I could add some <something> and be able to interface it via USB" ( I know NOTHING about USB , well I KNEW NOTHING until 4 days ago .. )
So my BRO SWEARS "use this is going to be so easy" .. made me buy for the increbile cheap sum of 7 quids or so an Arduino Pro Micro ..
Then made me install VS Code + PlattformIO which to be said "it's quite a thing considerting all the shit it does" ...
Then "flash a led" .. oh yes so trivial .. except that the "PRO MICRO" doesn't really have any "default LED" so takes a bit different effort ..
Then ok "read/write serial port", with NO interrupts .. really trivial .. ok .. we know that ..
So "how do you configure this as an HID device" .. ERM .. HUM .. ERM ... "I am not sure" .. "I heard there's this bootloader" ..
"What the heck does that bootloader ?" .. "I dunno"
"Who wrote it ?" .. "I dunno" ..
"Where's the source of it ?" .. "I have no idea ?"
"WHAT DOES IT REALLY AND HOW ?" .. "NO FUCKING IDEA" ..
So after MUCH reading the "So easy" turns out "NOT SO EASY AT ALL" and the "I don't want to read those 2000 pages of USB documentation" .. turns out "OK but you have to read at least 200 to get an idea about what's going on .. "
"That lib" .. "Is made using another much more complex lib" and it's not done for what I need ..
"Those numbers coming from thin air" that there are NOT those NOR these .. turns out they are defined in the "USB 1.1 HID specifications" ...
"That ()$*(£)$*" descriptor" .. "could not you made it more confusing that that and/or add some comments about" ...
"That other shit" .. turns out "kinda stolen from some Android sources" ...
So after MUCH searching/reading turns out that "OH it's SO SIMPLE there's LOT of stuff out there" .. "there's lot of stuff SO BADLY or NOTHING at all documented out there that you don't really know why it does what it does and how it does it" ..
SOME people "know the thing" but heck "they don't know how to explain it well" .. mind you "I could be one of them" ...
So after much stuff ( 2 days messing at late night ) studying deboucing algorithms and papers and stuff .. there's ONE THING I CANNOT FIND around.
I remember reading it "in some old Z80 coding book", probably, but can't find online it again ...
Does anyone rings a bell the "rows inversion and/or columns inversion" algorithm when scanning a keyboard matrix ?
IIRC has something to do with avoiding ( or trying to avoid ) the "ghost key" problem, I cannot remember how it works but I know it has something to do with first driving the rows as "outputs" and reading the columsn as "input" then reversing the thing but I cannot remember what else then has to be done and why it works ...
"Where I lost my head" in 2 nights and such it's been around this sort of shit, that hopefully I got it right, I still have to "validate" it and add an "USAGE PAGE OUTPUT" thing for the kb LEDs .. ( don't try to understand it, it's semi-voodoo, in essence it describes a data packet but how it gets 'in the right place with the correct meaning' I am not sure yet .. ) ..
Code: Select all
USAGE_PAGE, GENERIC_DESKTOP_CONTROLS,
USAGE, GENERIC_DEVICE_CONTROLS, // KEYBOARD_KEYPAD,
COLLECTION, COLLECTION_APPLICATION,
REPORT_ID, THE_REPORT_ID,
USAGE_PAGE, KEYBOARD_KEYPAD,
// this appear to say there are 8 bits of size '1' but with possible
// logical value 0 or 1
USAGE_MINIMUM, KEY_LEFTCTRL,
USAGE_MAXIMUM, KEY_RIGHTMETA,
LOGICAL_MINIMUM, 0x00,
LOGICAL_MAXIMUM, 0x01,
REPORT_SIZE, 0x01,
REPORT_COUNT, 0x08,
INPUT, 0x02, // INPUT (Data,Var,Abs)
REPORT_COUNT, 0x01, // This seems to be the reserved byte
REPORT_SIZE, 0x08, // 1 byte, 8 bits, constant var, absolute value
INPUT, 0x03, // INPUT (Cnst,Var,Abs)
REPORT_COUNT,0x06, // 6 bytes report
REPORT_SIZE, 0x08, // 8 bits
LOGICAL_MINIMUM, KEY_NONE,
LOGICAL_MAXIMUM, KEY_F24,
USAGE_PAGE, KEYBOARD_KEYPAD,
USAGE_MINIMUM, KEY_NONE,
USAGE_MAXIMUM, KEY_F24,
INPUT, 0x00, // INPUT (Data,Ary,Abs)
END_COLLECTION
Anyway if anyone remembers how that "rows inversions" works ...

