Merge remote-tracking branch 'tmk/master'
This commit is contained in:
commit
076d60a412
15 changed files with 4613 additions and 4166 deletions
|
|
@ -79,7 +79,7 @@ ACTIONMAP_ENABLE ?= no # Use 16bit actionmap instead of 8bit keymap
|
|||
KEYMAP_SECTION_ENABLE ?= yes # fixed address keymap for keymap editor
|
||||
|
||||
# ADB Mice need acceleration for todays much bigger screens.
|
||||
ADB_MOUSE_MAXACC ?= 8
|
||||
ADB_MOUSE_MAXACC ?= 1
|
||||
OPT_DEFS += -DADB_MOUSE_MAXACC=$(ADB_MOUSE_MAXACC)
|
||||
|
||||
# Enable scroll wheel functionality using the y-axis of the mouse
|
||||
|
|
@ -94,7 +94,7 @@ OPT_DEFS += -DADB_MOUSE_MAXACC=$(ADB_MOUSE_MAXACC)
|
|||
# left click -> |1 2| <- right click
|
||||
# |________|
|
||||
#
|
||||
ADB_MOUSE_SCROLL_BUTTON ?= 4 # Assign the button (1-8) (0 to disable)
|
||||
ADB_MOUSE_SCROLL_BUTTON ?= 0 # Assign the button (1-8) (0 to disable)
|
||||
ADB_MOUSE_SCROLL_SPEED ?= 10 # 1 (fastest) to 127 (slowest)
|
||||
|
||||
# Optimize size but this may cause error "relocation truncated to fit"
|
||||
|
|
|
|||
|
|
@ -1,29 +1,30 @@
|
|||
ADB to USB keyboard converter
|
||||
=============================
|
||||
This firmware converts Apple ADB keyboard/mouse protocol to USB, you can use it to plug old ADB keyboard/mouse into modern computer. It works on prebuilt TMK ADB-USB Converter or generic dev board with USB AVR MCU(ATMega32U4/2) like Teensy2.0.
|
||||
This firmware converts Apple ADB keyboard/mouse protocol to USB and you can use old ADB keyboard/mouse on modern computer. It works on TMK ADB-USB converter or AVR microcontroller(ATMega32U4/2).
|
||||
|
||||
Discuss about this here: http://geekhack.org/showwiki.php?title=Island:14290
|
||||
Discussion and info: https://geekhack.org/index.php?topic=14290.0
|
||||
|
||||
Prebuilt TMK ADB-USB converter is available here: https://geekhack.org/index.php?topic=72052.0
|
||||
TMK ADB-USB converter: https://geekhack.org/index.php?topic=72052.0
|
||||
|
||||
|
||||
|
||||
README FIRST
|
||||
------------
|
||||
https://github.com/tmk/tmk_keyboard
|
||||
https://github.com/tmk/tmk_keyboard/tree/master/converter/adb_usb
|
||||
Infos
|
||||
-----
|
||||
Wiki: https://github.com/tmk/tmk_keyboard/wiki
|
||||
|
||||
Also check these when you are in trouble.
|
||||
ADB protocol: https://github.com/tmk/tmk_keyboard/wiki/Apple-Desktop-Bus
|
||||
|
||||
Issues: https://github.com/tmk/tmk_keyboard/issues?q=is%3Aissue+ADB
|
||||
|
||||
Firmware Code: https://github.com/tmk/tmk_keyboard/tree/master/converter/adb_usb
|
||||
|
||||
https://github.com/tmk/tmk_keyboard/wiki
|
||||
https://github.com/tmk/tmk_keyboard/issues
|
||||
|
||||
|
||||
Wiring
|
||||
------
|
||||
If you build this yourself you have to solder some wires.
|
||||
Connect ADB pins to controller just by 3 lines(Vcc, GND, Data) at least. By default Data line uses port PD0.
|
||||
This is not needed but you can connect PSW to PD1 optionally.
|
||||
Connect DATA, VCC and GND to microcontroller. Use port **PD0** for DATA. PSW is not used.
|
||||
|
||||
You can change the port with `ADB_PORT`, `ADB_PIN`, `ADB_DDR`, `ADB_DATA_BIT` in `config.h`.
|
||||
|
||||
ADB female socket from the front:
|
||||
|
||||
|
|
@ -33,10 +34,11 @@ ADB female socket from the front:
|
|||
- === - 3: VCC
|
||||
`-___-' 4: GND
|
||||
|
||||
This converter uses AVR's internal pull-up, but it seems to be too weak, in particular when you want to use a long or coiled cable. The external pull-up resistor(1K-10K Ohm) on Data is strongly recommended.(It is almost must!)
|
||||
https://github.com/tmk/tmk_keyboard/wiki/FAQ#pull-up-resistor
|
||||
|
||||
Pull-up resister:
|
||||
### Pull-up resister:
|
||||
The external **1k Ohm** pull-up resistor on DATA is **required**.
|
||||
|
||||
AVR microcontroller's internal pull-up is too weak for ADB in particular when you want to use a long coiled cable or daisy-chain devices.
|
||||
|
||||
Keyboard AVR MCU
|
||||
,------.
|
||||
|
|
@ -48,18 +50,14 @@ Pull-up resister:
|
|||
| |
|
||||
GND------------|GND |
|
||||
`------'
|
||||
R: 1K Ohm resistor
|
||||
R: 1k Ohm resistor
|
||||
|
||||
https://github.com/tmk/tmk_keyboard/wiki/Apple-Desktop-Bus#pull-up-resistor
|
||||
|
||||
Define following macros for ADB connection in config.h if you use other than port PD0.
|
||||
|
||||
ADB_PORT, ADB_PIN, ADB_DDR, ADB_DATA_BIT
|
||||
|
||||
|
||||
Build firmware and Program microcontroller
|
||||
------------------------------------------
|
||||
See [doc/build.md](../../tmk_core/doc/build.md).
|
||||
|
||||
To build firmware and program TMK ADB-USB Converter run these commands:
|
||||
|
||||
$ make -f Makefile clean
|
||||
|
|
@ -70,50 +68,50 @@ You can select keymap name with optional `KEYMAP=` ('plain' is default name). Pu
|
|||
|
||||
Use **Makefile.rev1** for old TMK Converter rev.1 and Teensy2.0 instead of **Makefile**.
|
||||
|
||||
https://github.com/tmk/tmk_keyboard/wiki#build-firmware
|
||||
|
||||
|
||||
Keymap
|
||||
------
|
||||
You can change keymap by editing code of unimap_plain.c directly, or copy it to your own keymap file like unimap_yourname.c and edit the file.
|
||||
How to define the keymap is probably obvious. You can find key symbols in common/keycode.h. And see [doc/keymap.md](../../tmk_core/doc/keymap.md) for more detail.
|
||||
|
||||
|
||||
Magic command
|
||||
-------------
|
||||
To get help message in hid_listen press `h` holding Magic key. Magic key is `Power key`.
|
||||
Debug
|
||||
-----
|
||||
Use hid_listen command line tool to see debug outputs.
|
||||
|
||||
https://github.com/tmk/tmk_keyboard/wiki#debug
|
||||
|
||||
|
||||
Locking CapsLock
|
||||
----------------
|
||||
Many of old ADB keyboards have mechanical push-lock switch for Capslock key and this converter supports the locking Capslock key by default. Use keycode `LCAP` instead of `CAPS` in your keymap in short. See README in top directory for more detail.
|
||||
https://github.com/tmk/tmk_keyboard/blob/master/README.md#mechanical-locking-support
|
||||
|
||||
If you want to remap Capslock key you will have to remove locking pin or just replace with normal momentary switch. Some keyboards like Apple Adujstable keyboard use firmware-base locking with momentary switch for Capslock and remapping it won't be useful in most cases.
|
||||
|
||||
|
||||
Notes for keyboard
|
||||
------------------
|
||||
Not-extended ADB keyboards have no discrimination between right modifier and left one,
|
||||
you will always see left control even if you press right control key.
|
||||
Apple Extended Keyboard and Apple Extended Keyboard II can discriminate both side
|
||||
modifiers except for GUI key(Windows/Command).
|
||||
Apple Standard keyboard(M0116) can't discriminate between right and left modifiers
|
||||
while Apple Extended keyboard(M0115/M3501) can discriminate them except for Command key.
|
||||
|
||||
And most of ADB keyboards have no diodes in its matrix so they are not NKRO unfortunately,
|
||||
though ADB protocol itself supports it. See tmk_core/protocol/adb.c for more info.
|
||||
|
||||
|
||||
Notes for mouse
|
||||
---------------
|
||||
ADB mouse support was added by @mek-apelsin on Apr,2015.
|
||||
https://github.com/tmk/tmk_keyboard/pull/207
|
||||
All one-button mouses should be supported and others will work as one-button mouse even if not supported.
|
||||
|
||||
All one-button mouses should be supported.
|
||||
Mouse protocols(handler ID) below are curretnly supported.
|
||||
|
||||
As of 2019 June, the converter can handle multi-button mice and trackball up to eight buttons if the pointing device supports Apple Extended Mouse protocol. But some devices use their own specific protocol unfortunately and they will work as one-button mouse unless device specific code is added.
|
||||
- Apple Classic Mouse protocol (1, 2)
|
||||
- Apple Extended Mouse protocol (4)
|
||||
- Kensington Turbo Mouse 5 #64210 and Thinking Mouse (0x32)
|
||||
- Macally 2-button Mouse (0x42)
|
||||
- Logitech MouseMan/TrackMan Proprietary protocol (0x4C*)
|
||||
- Logitech MouseMan/TrackMan Extended protocol (0x4D*)
|
||||
- Micrspeed MacTrac (0x2F, 0x5F) - Not confirmed
|
||||
- Contour Design Countour Mouse (0x66) - Not confirmed
|
||||
- Mouse Systems A3 Mouse/Trackball (0x03) - Not confirmed
|
||||
- CH Products Tracball Pro/DT225 (0x42) - Not confirmed
|
||||
|
||||
Kensington Turbo Mouse 5(#64210) is supported now.
|
||||
https://github.com/tmk/tmk_keyboard/issues/274#issuecomment-504726633
|
||||
https://github.com/tmk/tmk_keyboard/wiki/Apple-Desktop-Bus#mouse
|
||||
|
||||
EOF
|
||||
|
||||
|
||||
Locking CapsLock
|
||||
----------------
|
||||
Many of old ADB keyboards have mechanical push-lock switch for Capslock and some like Apple Adujstable keyboard use firmware-base locking with momentary switch for Capslock.
|
||||
|
||||
The converter supports the locking Capslock key. Use keycode `LCAP` instead of `CAPS` in your keymap.
|
||||
|
||||
https://github.com/tmk/tmk_keyboard/wiki/FAQ-Keymap#mechanical-lock-switch-support
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -40,7 +40,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#define LOCKING_RESYNC_ENABLE
|
||||
|
||||
// Mouse Extended Report
|
||||
#define MOUSE_EXT_REPORT
|
||||
//#define MOUSE_EXT_REPORT
|
||||
|
||||
// Second button in Apple Classic Mouse protocol is ignored as Mac OS9 and OSX does.
|
||||
// Without this some of 2-button mouses are unusable.
|
||||
// https://github.com/tmk/tmk_keyboard/issues/724
|
||||
#define ADB_MOUSE_2ND_BUTTON_QUIRK
|
||||
|
||||
// Scan unsupported devices with register0 when SRQ is asserted
|
||||
#define ADB_SRQ_SCAN_REG0
|
||||
|
||||
|
||||
/* ADB port setting */
|
||||
|
|
@ -48,7 +56,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#define ADB_PIN PIND
|
||||
#define ADB_DDR DDRD
|
||||
#define ADB_DATA_BIT 0
|
||||
//#define ADB_PSW_BIT 1 // optional
|
||||
#define ADB_PSW_BIT 1
|
||||
|
||||
/* key combination for command */
|
||||
#ifndef __ASSEMBLER__
|
||||
|
|
|
|||
|
|
@ -38,11 +38,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
static bool has_media_keys = false;
|
||||
static bool is_iso_layout = false;
|
||||
|
||||
#if ADB_MOUSE_ENABLE
|
||||
#define dmprintf(fmt, ...) do { /* if (debug_mouse) */ xprintf("M:" fmt, ##__VA_ARGS__); } while (0)
|
||||
static uint16_t mouse_cpi = 100;
|
||||
static void mouse_init(void);
|
||||
#endif
|
||||
|
||||
// matrix state buffer(1:on, 0:off)
|
||||
static matrix_row_t matrix[MATRIX_ROWS];
|
||||
|
|
@ -68,18 +63,17 @@ static void keyboard_init(void)
|
|||
|
||||
// Check if there is keyboard at default address
|
||||
reg3 = adb_host_talk(ADB_ADDR_KEYBOARD, ADB_REG_3);
|
||||
if (!reg3) return;
|
||||
if (reg3) {
|
||||
xprintf("K:found: addr:" xstr(ADB_ADDR_KEYBOARD) " reg3:%04X\n", reg3);
|
||||
xprintf("K:found: reg3:%04X\n", reg3);
|
||||
adb_host_listen(ADB_ADDR_KEYBOARD, ADB_REG_3, ((reg3 >> 8) & 0xF0) | ADB_ADDR_KBD_TMP, 0xFE);
|
||||
}
|
||||
|
||||
// Check if there is device to setup at temporary address
|
||||
reg3 = adb_host_talk(ADB_ADDR_KBD_TMP, ADB_REG_3);
|
||||
if (!reg3) {
|
||||
xprintf("K:fail: move\n");
|
||||
return;
|
||||
}
|
||||
xprintf("K:TMP: reg3:%04X\n", reg3);
|
||||
|
||||
// Determine ISO keyboard by handler id
|
||||
// http://lxr.free-electrons.com/source/drivers/macintosh/adbhid.c?v=4.4#L815
|
||||
|
|
@ -94,6 +88,7 @@ static void keyboard_init(void)
|
|||
is_iso_layout = false;
|
||||
break;
|
||||
}
|
||||
xprintf("K:ISO: %s\n", (is_iso_layout ? "yes" : "no"));
|
||||
|
||||
// Adjustable keyboard media keys: address=0x07 and handlerID=0x02
|
||||
has_media_keys = (0x02 == (adb_host_talk(ADB_ADDR_APPLIANCE, ADB_REG_3) & 0xff));
|
||||
|
|
@ -112,11 +107,14 @@ static void keyboard_init(void)
|
|||
|
||||
// Move to keyboard polling address
|
||||
adb_host_listen(ADB_ADDR_KBD_TMP, ADB_REG_3, ((reg3 >> 8) & 0xF0) | ADB_ADDR_KBD_POLL, 0xFE);
|
||||
if (adb_host_talk(ADB_ADDR_KBD_TMP, ADB_REG_3)) {
|
||||
xprintf("K:fail: move\n");
|
||||
reg3 = adb_host_talk(ADB_ADDR_KBD_TMP, ADB_REG_3);
|
||||
if (reg3) {
|
||||
xprintf("K:POL: fail reg3:%04X\n", reg3);
|
||||
} else {
|
||||
xprintf("K:POL: done\n");
|
||||
}
|
||||
xprintf("K:setup: addr:" xstr(ADB_ADDR_KBD_POLL) " reg3:%04X, ISO:%s\n",
|
||||
reg3, (is_iso_layout ? "yes" : "no"));
|
||||
|
||||
device_scan();
|
||||
}
|
||||
|
||||
void matrix_init(void)
|
||||
|
|
@ -153,15 +151,18 @@ void matrix_init(void)
|
|||
}
|
||||
|
||||
#ifdef ADB_MOUSE_ENABLE
|
||||
static uint16_t mouse_cpi = 100;
|
||||
static uint8_t mouse_handler;
|
||||
|
||||
static void mouse_init(void)
|
||||
{
|
||||
uint16_t reg3;
|
||||
uint8_t mouse_handler;
|
||||
|
||||
again:
|
||||
// Check if there is mouse device at default address 3
|
||||
reg3 = adb_host_talk(ADB_ADDR_MOUSE, ADB_REG_3);
|
||||
if (reg3) {
|
||||
xprintf("M:found: reg3:%04X\n", reg3);
|
||||
// Move device to tmp address
|
||||
// Collision detection can fail sometimes in fact when two devices are connected on startup
|
||||
// and the devices can be moved to tmp address at same time in the result. In that case
|
||||
|
|
@ -173,36 +174,62 @@ again:
|
|||
}
|
||||
|
||||
// Check if there is mouse device to setup at temporary address 15
|
||||
mouse_handler = (reg3 = adb_host_talk(ADB_ADDR_MOUSE_TMP, ADB_REG_3)) & 0xFF;
|
||||
reg3 = adb_host_talk(ADB_ADDR_MOUSE_TMP, ADB_REG_3);
|
||||
if (!reg3) {
|
||||
return;
|
||||
}
|
||||
dmprintf("TMP: reg3:%04X\n", reg3);
|
||||
xprintf("M:TMP: reg3:%04X\n", reg3);
|
||||
mouse_handler = reg3 & 0xFF;
|
||||
|
||||
|
||||
if (mouse_handler == ADB_HANDLER_MICROSPEED_MACTRAC ||
|
||||
mouse_handler == ADB_HANDLER_MICROSPEED_UNKNOWN ||
|
||||
mouse_handler == ADB_HANDLER_CONTOUR_MOUSE ||
|
||||
mouse_handler == ADB_HANDLER_CHPRODUCTS_PRO) {
|
||||
// https://github.com/NetBSD/src/blob/netbsd-9/sys/arch/macppc/dev/ams.c#L226-L255
|
||||
// https://github.com/torvalds/linux/blob/v5.17/drivers/macintosh/adbhid.c#L1007-L1018
|
||||
// https://github.com/torvalds/linux/blob/v5.17/drivers/macintosh/adbhid.c#L1204-L1239
|
||||
uint8_t cmd[] = { 0x00, // alt speed max
|
||||
0x00, // speed max
|
||||
0x10, // ext protocol enabled
|
||||
0x07 }; // buttons without locking
|
||||
//adb_host_flush(ADB_ADDR_MOUSE_TMP);
|
||||
adb_host_listen_buf(ADB_ADDR_MOUSE_TMP, ADB_REG_1, cmd, sizeof(cmd));
|
||||
}
|
||||
|
||||
// Try to escalate into extended/classic2 protocol
|
||||
if (mouse_handler == ADB_HANDLER_CLASSIC1_MOUSE || mouse_handler == ADB_HANDLER_CLASSIC2_MOUSE) {
|
||||
adb_host_flush(ADB_ADDR_MOUSE_TMP);
|
||||
adb_host_listen(ADB_ADDR_MOUSE_TMP, ADB_REG_3, (reg3 >> 8), ADB_HANDLER_EXTENDED_MOUSE);
|
||||
mouse_handler = (reg3 = adb_host_talk(ADB_ADDR_MOUSE_TMP, ADB_REG_3)) & 0xFF;
|
||||
|
||||
if (mouse_handler != ADB_HANDLER_EXTENDED_MOUSE) {
|
||||
adb_host_flush(ADB_ADDR_MOUSE_TMP);
|
||||
adb_host_listen(ADB_ADDR_MOUSE_TMP, ADB_REG_3, (reg3 >> 8), ADB_HANDLER_MOUSESYSTEMS_A3);
|
||||
mouse_handler = (reg3 = adb_host_talk(ADB_ADDR_MOUSE_TMP, ADB_REG_3)) & 0xFF;
|
||||
|
||||
if (mouse_handler == ADB_HANDLER_MOUSESYSTEMS_A3) {
|
||||
adb_host_listen(ADB_ADDR_MOUSE_TMP, ADB_REG_2, 0x00, 0x07);
|
||||
}
|
||||
}
|
||||
|
||||
if (mouse_handler == ADB_HANDLER_CLASSIC1_MOUSE) {
|
||||
adb_host_flush(ADB_ADDR_MOUSE_TMP);
|
||||
adb_host_listen(ADB_ADDR_MOUSE_TMP, ADB_REG_3, (reg3 >> 8), ADB_HANDLER_CLASSIC2_MOUSE);
|
||||
mouse_handler = (reg3 = adb_host_talk(ADB_ADDR_MOUSE_TMP, ADB_REG_3)) & 0xFF;
|
||||
}
|
||||
dmprintf("EXT: reg3:%04X\n", reg3);
|
||||
xprintf("M:EXT: reg3:%04X\n", reg3);
|
||||
}
|
||||
|
||||
// Classic Protocol 100cpi
|
||||
if (mouse_handler == ADB_HANDLER_CLASSIC1_MOUSE) {
|
||||
dmprintf("Classic 100cpi\n");
|
||||
xprintf("M:Classic 100cpi\n");
|
||||
mouse_cpi = 100;
|
||||
}
|
||||
|
||||
// Classic Protocol 200cpi
|
||||
if (mouse_handler == ADB_HANDLER_CLASSIC2_MOUSE) {
|
||||
dmprintf("Classic 200cpi\n");
|
||||
xprintf("M:Classic 200cpi\n");
|
||||
mouse_cpi = 200;
|
||||
}
|
||||
|
||||
|
|
@ -224,13 +251,13 @@ again:
|
|||
}
|
||||
|
||||
if (len) {
|
||||
dmprintf("EXT: [%02X %02X %02X %02X %02X %02X %02X %02X] cpi=%d\n",
|
||||
buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7], mouse_cpi);
|
||||
xprintf("M:EXT: [%02X %02X %02X %02X %02X %02X %02X %02X] cpi=%d btn=%d len=%d\n",
|
||||
buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7], mouse_cpi, buf[7], len);
|
||||
}
|
||||
|
||||
// Kensington Turbo Mouse 5: default device
|
||||
if (buf[0] == 0x4B && buf[1] == 0x4D && buf[2] == 0x4C && buf[3] == 0x31) {
|
||||
dmprintf("TM5: found\n");
|
||||
xprintf("M:TM5: found\n");
|
||||
// Move it to addr0 to remove this device and get new device with handle id 50 on addr 3
|
||||
// and the new device on address 3 should be handled with command sequence later.
|
||||
//
|
||||
|
|
@ -242,8 +269,35 @@ again:
|
|||
adb_host_flush(ADB_ADDR_MOUSE_TMP);
|
||||
adb_host_listen(ADB_ADDR_MOUSE_TMP, ADB_REG_3, ((reg3 >> 8) & 0xF0) | ADB_ADDR_0, 0xFE);
|
||||
goto again;
|
||||
} else if (buf[0] == 0x4B && buf[1] == 0x4F && buf[2] == 0x49 && buf[3] == 0x54) {
|
||||
// https://elixir.bootlin.com/linux/v5.17/source/drivers/macintosh/adbhid.c#L1068
|
||||
adb_host_flush(ADB_ADDR_MOUSE_TMP);
|
||||
adb_host_listen(ADB_ADDR_MOUSE_TMP, ADB_REG_3, (reg3 >> 8), ADB_HANDLER_MACALLY2_MOUSE);
|
||||
mouse_handler = (reg3 = adb_host_talk(ADB_ADDR_MOUSE_TMP, ADB_REG_3)) & 0xFF;
|
||||
xprintf("M: reg3:%04X\n", reg3);
|
||||
xprintf("M:Macally2: found: %02X\n", mouse_handler);
|
||||
} else if (buf[0] == 0x9A && (buf[1] == 0x20 || buf[1] == 0x21)) {
|
||||
if (buf[1] == 0x20) {
|
||||
xprintf("M:MouseMan\n");
|
||||
} else {
|
||||
dmprintf("Unknown\n");
|
||||
xprintf("M:TrackMan\n");
|
||||
}
|
||||
// https://elixir.bootlin.com/linux/v5.17/source/drivers/macintosh/adbhid.c#L1047
|
||||
adb_host_listen(ADB_ADDR_MOUSE_TMP, ADB_REG_1, 0x00, 0x81);
|
||||
adb_host_listen(ADB_ADDR_MOUSE_TMP, ADB_REG_1, 0x01, 0x81);
|
||||
adb_host_listen(ADB_ADDR_MOUSE_TMP, ADB_REG_1, 0x02, 0x81);
|
||||
adb_host_listen(ADB_ADDR_MOUSE_TMP, ADB_REG_1, 0x03, 0x38);
|
||||
// set pseudo handler for Logitech
|
||||
mouse_handler = ADB_HANDLER_LOGITECH;
|
||||
} else if (buf[0] == 0x4C && buf[1] == 0x54) {
|
||||
// Logitech Extended
|
||||
// MouseMan - FCCID:DZLMAH32 'LT01'
|
||||
// MouseMan Cordless - FCCID:DZLMRC33T 'LTW1'
|
||||
xprintf("M:Logitech-Ext\n");
|
||||
// set pseudo handler
|
||||
mouse_handler = ADB_HANDLER_LOGITECH_EXT;
|
||||
} else {
|
||||
xprintf("M:Extended\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -303,9 +357,9 @@ again:
|
|||
adb_host_flush(ADB_ADDR_MOUSE_POLL);
|
||||
reg3 = adb_host_talk(ADB_ADDR_MOUSE_TMP, ADB_REG_3);
|
||||
if (reg3) {
|
||||
dmprintf("POL: fail reg3:%04X\n", reg3);
|
||||
xprintf("M:POL: fail reg3:%04X\n", reg3);
|
||||
} else {
|
||||
dmprintf("POL: done\n");
|
||||
xprintf("M:POL: done\n");
|
||||
}
|
||||
|
||||
device_scan();
|
||||
|
|
@ -338,55 +392,153 @@ void adb_mouse_task(void)
|
|||
mouse_init();
|
||||
}
|
||||
|
||||
// Extended Mouse Protocol data can be 2-5 bytes
|
||||
// https://developer.apple.com/library/archive/technotes/hw/hw_01.html#Extended
|
||||
//
|
||||
// Byte 0: b00 y06 y05 y04 y03 y02 y01 y00
|
||||
// Byte 1: b01 x06 x05 x04 x03 x02 x01 x00
|
||||
// Byte 2: b02 y09 y08 y07 b03 x09 x08 x07
|
||||
// Byte 3: b04 y12 y11 y10 b05 x12 x11 x10
|
||||
// Byte 4: b06 y15 y14 y13 b07 x15 x14 x13
|
||||
//
|
||||
// b--: Button state.(0: on, 1: off)
|
||||
// x--: X axis movement.
|
||||
// y--: Y axis movement.
|
||||
len = adb_host_talk_buf(ADB_ADDR_MOUSE_POLL, ADB_REG_0, buf, sizeof(buf));
|
||||
if (!len && adb_service_request()) len = adb_host_talk_buf(ADB_ADDR_MOUSE, ADB_REG_0, buf, sizeof(buf));
|
||||
|
||||
// If nothing received reset mouse acceleration, and quit.
|
||||
if (len < 2) {
|
||||
mouseacc = 1;
|
||||
return;
|
||||
};
|
||||
dmprintf("[%02X %02X %02X %02X %02X]\n", buf[0], buf[1], buf[2], buf[3], buf[4]);
|
||||
|
||||
// Store off-buttons and 0-movements in unused bytes
|
||||
xprintf("M:[ ");
|
||||
for (uint8_t i = 0; i < len; i++)
|
||||
xprintf("%02X ", buf[i]);
|
||||
xprintf("] mh:%02X\n", mouse_handler);
|
||||
|
||||
bool xneg = false;
|
||||
bool yneg = false;
|
||||
if (len == 2) {
|
||||
if (mouse_handler == ADB_HANDLER_LOGITECH) {
|
||||
// Logitech:
|
||||
// Byte0: bbb y06 y05 y04 y03 y02 y01 y00
|
||||
// Byte1: 1 x06 x05 x04 x03 x02 x01 x00
|
||||
// Byte2: 0 0 0 0 0 BL BM BR
|
||||
// Bx: button state(1:pressed, 1:released)
|
||||
// bbb: 0 when either BL, BR or BM is pressed
|
||||
if (buf[0] & 0x40) yneg = true;
|
||||
if (buf[1] & 0x40) xneg = true;
|
||||
} else {
|
||||
if (buf[2] & 0x04) buf[0] &= 0x7F; else buf[0] |= 0x80;
|
||||
if (buf[2] & 0x01) buf[1] &= 0x7F; else buf[1] |= 0x80;
|
||||
if (buf[2] & 0x02) buf[2] = 0x08; else buf[2] = 0x88;
|
||||
if (yneg) buf[2] |= 0x70;
|
||||
if (xneg) buf[2] |= 0x07;
|
||||
len = 3;
|
||||
} else if (mouse_handler == ADB_HANDLER_LOGITECH_EXT) {
|
||||
// Logitech Extended:
|
||||
// Byte0: b00 y06 y05 y04 y03 y02 y01 y00
|
||||
// Byte1: b02 x06 x05 x04 x03 x02 x01 x00
|
||||
// Byte2: b01 y09 y08 y07 b03 x09 x08 x07
|
||||
// L=b00, R=b01, M=b02
|
||||
uint8_t tmp = buf[2];
|
||||
if (buf[1] & 0x80) buf[2] |= 0x80; else buf[2] &= 0x7F;
|
||||
if (tmp & 0x80) buf[1] |= 0x80; else buf[1] &= 0x7F;
|
||||
if (buf[len - 1] & 0x40) yneg = true;
|
||||
if (buf[len - 1] & 0x04) xneg = true;
|
||||
} else if (mouse_handler == ADB_HANDLER_MACALLY2_MOUSE && len == 4) {
|
||||
// Macally 2-button mouse:
|
||||
// Byte0: b00 y06 y05 y04 y03 y02 y01 y00
|
||||
// Byte1: b01 x06 x05 x04 x03 x02 x01 x00
|
||||
// Byte2: 1 0 0 0 1 0 0 0
|
||||
// Byte3: 1 0 0 0 1 0 0 0
|
||||
// b--: button state(0:pressed, 1:released)
|
||||
if (buf[0] & 0x40) yneg = true;
|
||||
if (buf[1] & 0x40) xneg = true;
|
||||
// Ignore Byte2 and 3
|
||||
len = 2;
|
||||
} else if (mouse_handler == ADB_HANDLER_MICROSPEED_MACTRAC ||
|
||||
mouse_handler == ADB_HANDLER_MICROSPEED_UNKNOWN ||
|
||||
mouse_handler == ADB_HANDLER_CONTOUR_MOUSE) {
|
||||
// Microspeed:
|
||||
// Byte0: ??? y06 y05 y04 y03 y02 y01 y00
|
||||
// Byte1: ??? x06 x05 x04 x03 x02 x01 x00
|
||||
// Byte2: ??? ??? ??? ??? ??? bM bR bL
|
||||
// Contour Mouse:
|
||||
// Byte0: bbb y06 y05 y04 y03 y02 y01 y00
|
||||
// Byte1: 1 x06 x05 x04 x03 x02 x01 x00
|
||||
// Byte2: 0 0 0 0 1 bM bR bL
|
||||
// Byte3: 0 0 0 0 1 bM bR bL
|
||||
// b--: button state(0:pressed, 1:released)
|
||||
if (buf[0] & 0x40) yneg = true;
|
||||
if (buf[1] & 0x40) xneg = true;
|
||||
buf[0] = ((buf[2] & 1) << 7) | (buf[0] & 0x7F);
|
||||
buf[1] = ((buf[2] & 2) << 6) | (buf[1] & 0x7F) ;
|
||||
buf[2] = ((buf[2] & 4) << 5) | (buf[2] & 8) | (yneg ? 0x70 : 0x00) | (xneg ? 0x07 : 0x00);
|
||||
len = 3;
|
||||
} else if (mouse_handler == ADB_HANDLER_CHPRODUCTS_PRO) {
|
||||
// CH Products Trackball Pro:
|
||||
// Byte0: ??? y06 y05 y04 y03 y02 y01 y00
|
||||
// Byte1: ??? x06 x05 x04 x03 x02 x01 x00
|
||||
// Byte2: ??? ??? ??? ??? bL0 bL1 bR bM
|
||||
// b--: button state(0:pressed, 1:released)
|
||||
// L=(bL0 & bL1)
|
||||
if (buf[0] & 0x40) yneg = true;
|
||||
if (buf[1] & 0x40) xneg = true;
|
||||
buf[0] = (((buf[2] & 4) << 5) & ((buf[2] & 8) << 4)) | (buf[0] & 0x7F);
|
||||
buf[1] = ((buf[2] & 2) << 6) | (buf[1] & 0x7F) ;
|
||||
buf[2] = ((buf[2] & 1) << 7) | (yneg ? 0x70 : 0x00) | (xneg ? 0x0F : 0x08);
|
||||
len = 3;
|
||||
} else if (mouse_handler == ADB_HANDLER_MOUSESYSTEMS_A3) {
|
||||
// Mouse Systems A3: 3-button mouse/trackball:
|
||||
// Byte0: ??? y06 y05 y04 y03 y02 y01 y00
|
||||
// Byte1: ??? x06 x05 x04 x03 x02 x01 x00
|
||||
// Byte2: ??? ??? ??? ??? ??? bR bM bL
|
||||
// b--: button state(0:pressed, 1:released)
|
||||
if (buf[0] & 0x40) yneg = true;
|
||||
if (buf[1] & 0x40) xneg = true;
|
||||
buf[0] = ((buf[2] & 1) << 7) | (buf[0] & 0x7F);
|
||||
buf[1] = ((buf[2] & 4) << 5) | (buf[1] & 0x7F) ;
|
||||
buf[2] = ((buf[2] & 2) << 6) | (yneg ? 0x70 : 0x00) | (xneg ? 0x0F : 0x08);
|
||||
len = 3;
|
||||
} else if (mouse_handler == ADB_HANDLER_EXTENDED_MOUSE ||
|
||||
mouse_handler == ADB_HANDLER_TURBO_MOUSE) {
|
||||
// Apple Extended Mouse:
|
||||
// Byte0: b00 y06 y05 y04 y03 y02 y01 y00
|
||||
// Byte1: b01 x06 x05 x04 x03 x02 x01 x00
|
||||
// Byte2: b02 y09 y08 y07 b03 x09 x08 x07
|
||||
// Byte3: b04 y12 y11 y10 b05 x12 x11 x10
|
||||
// Byte4: b06 y15 y14 y13 b07 x15 x14 x13
|
||||
// b--: button state(0:pressed, 1:released)
|
||||
// Data can be 2-5 bytes.
|
||||
// L=b00, R=b01, M=b02
|
||||
if (buf[len - 1] & 0x40) yneg = true;
|
||||
if (buf[len - 1] & 0x04) xneg = true;
|
||||
} else {
|
||||
// Apple Classic Mouse and Unknown devices:
|
||||
// Byte0: b00 y06 y05 y04 y03 y02 y01 y00
|
||||
// Byte1: b01 x06 x05 x04 x03 x02 x01 x00
|
||||
if (buf[0] & 0x40) yneg = true;
|
||||
if (buf[1] & 0x40) xneg = true;
|
||||
len = 2;
|
||||
|
||||
#ifdef ADB_MOUSE_2ND_BUTTON_QUIRK
|
||||
// Ignore b01('optional second button') as OSX/MacOS9 does.
|
||||
// Some mouses misuse the bit and make it unusable.
|
||||
// https://github.com/tmk/tmk_keyboard/issues/724
|
||||
buf[1] |= 0x80;
|
||||
#endif
|
||||
}
|
||||
|
||||
// Make unused buf bytes compatible with Extended Mouse Protocol
|
||||
for (int8_t i = len; i < sizeof(buf); i++) {
|
||||
buf[i] = 0x88;
|
||||
if (yneg) buf[i] |= 0x70;
|
||||
if (xneg) buf[i] |= 0x07;
|
||||
}
|
||||
|
||||
// 8 buttons at max
|
||||
// TODO: Fix HID report descriptor for mouse to support button6-8
|
||||
xprintf("M:[ ");
|
||||
for (uint8_t i = 0; i < sizeof(buf); i++)
|
||||
xprintf("%02X ", buf[i]);
|
||||
xprintf("]\n");
|
||||
|
||||
uint8_t buttons = 0;
|
||||
if (!(buf[4] & 0x08)) buttons |= MOUSE_BTN8;
|
||||
if (!(buf[4] & 0x80)) buttons |= MOUSE_BTN7;
|
||||
if (!(buf[3] & 0x08)) buttons |= MOUSE_BTN6;
|
||||
if (!(buf[3] & 0x80)) buttons |= MOUSE_BTN5;
|
||||
if (!(buf[2] & 0x08)) buttons |= MOUSE_BTN4;
|
||||
if (!(buf[2] & 0x80)) buttons |= MOUSE_BTN3;
|
||||
if (!(buf[1] & 0x80)) buttons |= MOUSE_BTN2;
|
||||
if (!(buf[0] & 0x80)) buttons |= MOUSE_BTN1;
|
||||
if (!(buf[2] & 0x80)) buttons |= MOUSE_BTN3; // Middle
|
||||
if (!(buf[1] & 0x80)) buttons |= MOUSE_BTN2; // Right
|
||||
if (!(buf[0] & 0x80)) buttons |= MOUSE_BTN1; // Left
|
||||
|
||||
// check if the scroll enable button is pressed
|
||||
bool scroll_enable = (bool)(buttons & scroll_button_mask);
|
||||
|
|
@ -423,7 +575,7 @@ void adb_mouse_task(void)
|
|||
mouse_report.y = y;
|
||||
}
|
||||
|
||||
dmprintf("[B:%02X X:%d(%d) Y:%d(%d) V:%d A:%d]\n", mouse_report.buttons, mouse_report.x, xx, mouse_report.y, yy, mouse_report.v, mouseacc);
|
||||
xprintf("M:[B:%02X X:%d(%d) Y:%d(%d) V:%d A:%d]\n", mouse_report.buttons, mouse_report.x, xx, mouse_report.y, yy, mouse_report.v, mouseacc);
|
||||
|
||||
// Send result by usb.
|
||||
host_mouse_send(&mouse_report);
|
||||
|
|
@ -466,8 +618,25 @@ uint8_t matrix_scan(void)
|
|||
tick_ms = timer_read();
|
||||
|
||||
codes = adb_host_kbd_recv(ADB_ADDR_KBD_POLL);
|
||||
if (!codes && adb_service_request()) codes = adb_host_kbd_recv(ADB_ADDR_KEYBOARD);
|
||||
if (codes) xprintf("%04X ", codes);
|
||||
|
||||
// Check PSW pin
|
||||
static bool psw_state = false;
|
||||
if (codes == 0) {
|
||||
if (!psw_state) {
|
||||
if (!adb_host_psw()) {
|
||||
codes = 0x7F7F; // power key press
|
||||
psw_state = true;
|
||||
}
|
||||
} else {
|
||||
if (adb_host_psw()) {
|
||||
codes = 0xFFFF; // power key release
|
||||
psw_state = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Adjustable keybaord media keys
|
||||
if (codes == 0 && has_media_keys &&
|
||||
(codes = adb_host_kbd_recv(ADB_ADDR_APPLIANCE))) {
|
||||
|
|
@ -609,3 +778,37 @@ void led_set(uint8_t usb_led)
|
|||
{
|
||||
adb_host_kbd_led(ADB_ADDR_KBD_POLL, ~usb_led);
|
||||
}
|
||||
|
||||
#ifdef ADB_SRQ_SCAN_REG0
|
||||
void hook_main_loop(void)
|
||||
{
|
||||
// Scan unsupported devices when Service Request(SRQ) is asserted
|
||||
uint8_t len;
|
||||
uint8_t buf[16];
|
||||
static uint8_t addr = 0;
|
||||
if (!adb_service_request()) return;
|
||||
for (addr = addr % 16; addr < 16; addr++) {
|
||||
if (addr == ADB_ADDR_KEYBOARD ||
|
||||
addr == ADB_ADDR_KBD_POLL ||
|
||||
addr == ADB_ADDR_KBD_TMP ||
|
||||
#ifdef ADB_MOUSE_ENABLE
|
||||
addr == ADB_ADDR_MOUSE ||
|
||||
addr == ADB_ADDR_MOUSE_POLL ||
|
||||
addr == ADB_ADDR_MOUSE_TMP ||
|
||||
#endif
|
||||
addr == ADB_ADDR_APPLIANCE) {
|
||||
continue;
|
||||
}
|
||||
len = adb_host_talk_buf(addr, ADB_REG_0, buf, sizeof(buf));
|
||||
if (len) {
|
||||
xprintf("addr%d reg0: [ ", addr);
|
||||
for (uint8_t i = 0; i < len; i++) {
|
||||
xprintf("%02X ", buf[i]);
|
||||
}
|
||||
xprintf("]\n");
|
||||
break;
|
||||
}
|
||||
if (!adb_service_request()) return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -350,7 +350,7 @@ uint8_t IBMPCConverter::process_interface(void)
|
|||
// https://github.com/tmk/tmk_keyboard/wiki/IBM-PC-AT-Keyboard-Protocol#ibm-5576-scan-codes-set
|
||||
xprintf("OK ");
|
||||
} else {
|
||||
xprintf("NG ");
|
||||
xprintf("NG \nTelevideo: ");
|
||||
if (0xAB91 == keyboard_id) {
|
||||
// This must be a Televideo DEC keyboard, which piggybacks on the same keyboard_id as IBM 5576-003
|
||||
// This keyboard normally starts up using code set 1, but we request code set 2 here:
|
||||
|
|
|
|||
|
|
@ -1,45 +1,70 @@
|
|||
NeXT non-ADB Keyboard Converter
|
||||
-------------------------------
|
||||
===============================
|
||||
With this converter you can use NeXT keyboard(non-ADB) on modern computer.
|
||||
|
||||
See this for details.
|
||||
https://github.com/tmk/tmk_keyboard/wiki/NeXT
|
||||
|
||||
|
||||
Wiring
|
||||
------
|
||||
Connections to ATmega32U2/U4
|
||||
|
||||
FROM(Pin3): PD0
|
||||
TO(Pin2): PD1
|
||||
PSW(Pin4): PD4
|
||||
GND(Pin5): GND
|
||||
VCC(Pin1): VCC
|
||||
|
||||
|
||||
|
||||
Pinouts
|
||||
-------
|
||||
Socket on converter from front:
|
||||
|
||||
_____
|
||||
GND / 5 4 \ PSW
|
||||
FROM | 3 2 | TO
|
||||
| 1 | VCC
|
||||
`-----'
|
||||
FROM: keyboard to computer
|
||||
TO: computer to keyboard
|
||||
PSW: Power key
|
||||
|
||||
|
||||
Cable connector inside keyboard case:
|
||||
|
||||
+-----+
|
||||
|Black|\
|
||||
|Green|-\
|
||||
|Yello|--\-------- to computer via Mini-Din 5a Connector
|
||||
|Yello|--\-------- to computer via Mini-Din 5 plug
|
||||
|Orang|--/--------
|
||||
|Red |-/
|
||||
|Brown|/
|
||||
+-----+
|
||||
Black: FG
|
||||
Green: GND
|
||||
Yellow: PSW(Power key)
|
||||
Orange: FROM Keyboard
|
||||
Red: TO Keyboard
|
||||
Brown: VCC
|
||||
|
||||
Black - Ground to outer metal part of Mini Din 5a connector (not used)
|
||||
Green - Ground
|
||||
Yellow - Power button signal
|
||||
Orange - Keyboard Out
|
||||
Red - Keyboard In
|
||||
Brown - Vcc
|
||||
|
||||
ATmega32u4 connections (pinout provided for Arduino Pro Micro):
|
||||
|
||||
Keyboard out (orange) : PD0 (pin 3)
|
||||
Keyboard in (red) : PD1 (pin 2)
|
||||
Power Button (yellow) : PD4 (pin 4)
|
||||
Ground (black) : GND
|
||||
Vcc (brown) : VCC
|
||||
Protocol
|
||||
--------
|
||||
See this for NeXT keyboard protocol.
|
||||
|
||||
See attached next_timings.jpg file for a detailed illustration of NeXT keyboard protocol timings.
|
||||
- https://github.com/tmk/tmk_keyboard/wiki/NeXT#next-keyboard-protocol
|
||||
|
||||
Power button signal line is normally high when the keyboard is powered/initialized. It is pulled to ground when pressed. The converter automatically translates this to a "normal" keypress with code 0x5A. This connection is technically optional, the only side effect of not making this connection is the power key will do nothing.
|
||||
|
||||
Converter is based heavily on Ladyada's original "USB NeXT Keyboard with Arduino Micro" tutorial (http://learn.adafruit.com/usb-next-keyboard-with-arduino-micro/overview). If you build this converter, show Adafruit some love and do it using an Arduino Micro (http://www.adafruit.com/products/1315) or their ATmega 32u4 Breakout Board (http://www.adafruit.com/products/296). Arduino Micro should work fine using the Arduino Pro Micro configuration above, same pins numbers and everything.
|
||||
|
||||
TODO:
|
||||
Notes
|
||||
-----
|
||||
LEDs indicates Caps Lock state in current implementation.
|
||||
|
||||
I believe it might be possible to run the keyboard off of 3V; during testing I observed that the keyboard could sometimes function even without Vcc connected as long as the ground connection was good and the Keyboard In line was connected. If that works it should be easy to do a Bluetooth conversion and run the keyboard right off of a LiPo battery without a boost circuit
|
||||
|
||||
Utilize second LED as status indicator for good initialization; also try to make hot plugging much more robust.
|
||||
|
||||
Figure a better use for the Power button. Too easy to hit it by mistake to use for Suspend or Power Off - maybe move cap to different part of the board and consider that
|
||||
|
||||
Figure out a better use for the lock LEDs. Right now they just light up when you press shift. Lame. Maybe implement proper Caps/Num/Scroll Locks
|
||||
|
||||
Original Project
|
||||
----------------
|
||||
Converter is based heavily on Ladyada's original "USB NeXT Keyboard with Arduino Micro" tutorial (http://learn.adafruit.com/usb-next-keyboard-with-arduino-micro/overview). If you build this converter, show Adafruit some love and do it using an Arduino Micro (http://www.adafruit.com/products/1315) or their ATmega 32u4 Breakout Board (http://www.adafruit.com/products/296). Arduino Micro should work fine using the Arduino Pro Micro configuration above, same pins numbers and everything.
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
Binary file not shown.
|
Before Width: | Height: | Size: 398 KiB |
|
|
@ -104,6 +104,12 @@ void adb_mouse_task(void) {
|
|||
}
|
||||
#endif
|
||||
|
||||
static bool adb_srq = false;
|
||||
bool adb_service_request(void)
|
||||
{
|
||||
return adb_srq;
|
||||
}
|
||||
|
||||
// This sends Talk command to read data from register and returns length of the data.
|
||||
uint8_t adb_host_talk_buf(uint8_t addr, uint8_t reg, uint8_t *buf, uint8_t len)
|
||||
{
|
||||
|
|
@ -157,6 +163,7 @@ uint8_t adb_host_talk_buf(uint8_t addr, uint8_t reg, uint8_t *buf, uint8_t len)
|
|||
// portion of the stop bit of any command or data transaction. The device must lengthen
|
||||
// the stop by a minimum of 140 J.lS beyond its normal duration, as shown in Figure 8-15."
|
||||
// http://ww1.microchip.com/downloads/en/AppNotes/00591b.pdf
|
||||
if (!data_in()) { adb_srq = true; } else { adb_srq = false; }
|
||||
if (!wait_data_hi(500)) { // Service Request(310us Adjustable Keyboard): just ignored
|
||||
xprintf("R");
|
||||
sei();
|
||||
|
|
@ -227,7 +234,8 @@ void adb_host_listen_buf(uint8_t addr, uint8_t reg, uint8_t *buf, uint8_t len)
|
|||
attention();
|
||||
send_byte((addr<<4) | ADB_CMD_LISTEN | reg);
|
||||
place_bit0(); // Stopbit(0)
|
||||
// TODO: Service Request
|
||||
if (!data_in()) { adb_srq = true; } else { adb_srq = false; }
|
||||
wait_data_hi(500); // Service Request
|
||||
_delay_us(200); // Tlt/Stop to Start
|
||||
place_bit1(); // Startbit(1)
|
||||
for (int8_t i = 0; i < len; i++) {
|
||||
|
|
@ -277,7 +285,9 @@ void adb_host_kbd_led(uint8_t addr, uint8_t led)
|
|||
// Listen Register2
|
||||
// upper byte: not used
|
||||
// lower byte: bit2=ScrollLock, bit1=CapsLock, bit0=NumLock
|
||||
adb_host_listen(addr, 2, 0, led & 0x07);
|
||||
uint16_t reg2 = adb_host_talk(addr, 2);
|
||||
_delay_us(400);
|
||||
adb_host_listen(addr, 2, reg2 >> 8, (reg2 & 0xF8) | (led & 0x07));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -95,6 +95,15 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#define ADB_HANDLER_CLASSIC2_MOUSE 0x02
|
||||
#define ADB_HANDLER_EXTENDED_MOUSE 0x04
|
||||
#define ADB_HANDLER_TURBO_MOUSE 0x32
|
||||
#define ADB_HANDLER_MACALLY2_MOUSE 0x42
|
||||
#define ADB_HANDLER_MICROSPEED_MACTRAC 0x2F
|
||||
#define ADB_HANDLER_MICROSPEED_UNKNOWN 0x5F
|
||||
#define ADB_HANDLER_CONTOUR_MOUSE 0x66
|
||||
#define ADB_HANDLER_CHPRODUCTS_PRO 0x42
|
||||
#define ADB_HANDLER_MOUSESYSTEMS_A3 0x03
|
||||
// pseudo handler
|
||||
#define ADB_HANDLER_LOGITECH 0x4C
|
||||
#define ADB_HANDLER_LOGITECH_EXT 0x4D
|
||||
|
||||
|
||||
// ADB host
|
||||
|
|
@ -112,6 +121,7 @@ void adb_host_kbd_led(uint8_t addr, uint8_t led);
|
|||
void adb_mouse_task(void);
|
||||
void adb_mouse_init(void);
|
||||
uint8_t adb_mouse_buttons(void);
|
||||
bool adb_service_request(void);
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ typedef struct
|
|||
#define MOUSE_EPSIZE 8
|
||||
#endif
|
||||
|
||||
#define CONSOLE_EPSIZE 64
|
||||
#define CONSOLE_EPSIZE 32
|
||||
#define NKRO_EPSIZE 32
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -59,16 +59,10 @@ static inline void query(void);
|
|||
static inline void reset(void);
|
||||
static inline uint32_t response(void);
|
||||
|
||||
/* The keyboard sends signal with 50us pulse width on OUT line
|
||||
* while it seems to miss the 50us pulse on In line.
|
||||
* next_kbd_set_leds() often fails to sync LED status with 50us
|
||||
* but it works well with 51us(+1us) on TMK converter(ATMeaga32u2) at least.
|
||||
* TODO: test on Teensy and Pro Micro configuration
|
||||
*/
|
||||
#define out_hi_delay(intervals) do { out_hi(); _delay_us((NEXT_KBD_TIMING+1) * intervals); } while (0);
|
||||
#define out_lo_delay(intervals) do { out_lo(); _delay_us((NEXT_KBD_TIMING+1) * intervals); } while (0);
|
||||
#define query_delay(intervals) do { query(); _delay_us((NEXT_KBD_TIMING+1) * intervals); } while (0);
|
||||
#define reset_delay(intervals) do { reset(); _delay_us((NEXT_KBD_TIMING+1) * intervals); } while (0);
|
||||
#define out_hi_delay(intervals) do { out_hi(); _delay_us((NEXT_KBD_TIMING) * intervals); } while (0);
|
||||
#define out_lo_delay(intervals) do { out_lo(); _delay_us((NEXT_KBD_TIMING) * intervals); } while (0);
|
||||
#define query_delay(intervals) do { query(); _delay_us((NEXT_KBD_TIMING) * intervals); } while (0);
|
||||
#define reset_delay(intervals) do { reset(); _delay_us((NEXT_KBD_TIMING) * intervals); } while (0);
|
||||
|
||||
void next_kbd_init(void)
|
||||
{
|
||||
|
|
@ -144,34 +138,14 @@ static inline uint32_t response(void)
|
|||
sei();
|
||||
return 0;
|
||||
}
|
||||
_delay_us(NEXT_KBD_TIMING / 2);
|
||||
_delay_us(NEXT_KBD_TIMING / 2 - 1);
|
||||
for (; i < 22; i++)
|
||||
{
|
||||
if (NEXT_KBD_READ)
|
||||
{
|
||||
data |= ((uint32_t) 1 << i);
|
||||
/* Note:
|
||||
* My testing with the ATmega32u4 showed that there might
|
||||
* something wrong with the timing here; by the end of the
|
||||
* second data byte some of the modifiers can get bumped out
|
||||
* to the next bit over if we just cycle through the data
|
||||
* based on the expected interval. There is a bit (i = 10)
|
||||
* in the middle of the data that is always on followed by
|
||||
* one that is always off - so we'll use that to reset our
|
||||
* timing in case we've gotten ahead of the keyboard;
|
||||
*/
|
||||
if (i == 10)
|
||||
{
|
||||
i++;
|
||||
while (NEXT_KBD_READ) ;
|
||||
_delay_us(NEXT_KBD_TIMING / 2);
|
||||
}
|
||||
} else {
|
||||
/* redundant - but I don't want to remove if it might screw
|
||||
* up the timing
|
||||
*/
|
||||
data |= ((uint32_t) 0 << i);
|
||||
data |= (uint32_t)1 << 22;
|
||||
}
|
||||
data >>= 1;
|
||||
_delay_us(NEXT_KBD_TIMING);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -51,7 +51,9 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#define NEXT_KBD_H
|
||||
|
||||
#define NEXT_KBD_KMBUS_IDLE 0x300600
|
||||
#define NEXT_KBD_TIMING 50
|
||||
|
||||
// https://github.com/tmk/tmk_keyboard/issues/704
|
||||
#define NEXT_KBD_TIMING 52
|
||||
|
||||
extern uint8_t next_kbd_error;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue