Merge branch 'adb_iso_fix'
This commit is contained in:
commit
f43a2df761
@ -56,7 +56,7 @@ SRC = keymap_common.c \
|
|||||||
ifdef KEYMAP
|
ifdef KEYMAP
|
||||||
SRC := keymap_$(KEYMAP).c $(SRC)
|
SRC := keymap_$(KEYMAP).c $(SRC)
|
||||||
else
|
else
|
||||||
SRC := keymap_ansi.c $(SRC)
|
SRC := keymap_plain.c $(SRC)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CONFIG_H = config.h
|
CONFIG_H = config.h
|
||||||
|
@ -33,6 +33,49 @@ extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS];
|
|||||||
extern const uint16_t fn_actions[];
|
extern const uint16_t fn_actions[];
|
||||||
|
|
||||||
|
|
||||||
|
/* Common layout: ANSI+ISO
|
||||||
|
* ,---. ,---------------. ,---------------. ,---------------. ,-----------. ,---.
|
||||||
|
* |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau| |Pwr|
|
||||||
|
* `---' `---------------' `---------------' `---------------' `-----------' `---'
|
||||||
|
* ,-----------------------------------------------------------. ,-----------. ,---------------.
|
||||||
|
* | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backspa| |Ins|Hom|PgU| |NmL| =| /| *|
|
||||||
|
* |-----------------------------------------------------------| |-----------| |---------------|
|
||||||
|
* |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| |Del|End|PgD| | 7| 8| 9| -|
|
||||||
|
* |-----------------------------------------------------------| `-----------' |---------------|
|
||||||
|
* |CapsLo| A| S| D| F| G| H| J| K| L| ;| '|Return | | 4| 5| 6| +|
|
||||||
|
* |-----------------------------------------------------------| ,---. |---------------|
|
||||||
|
* |Shif|\ | Z| X| C| V| B| N| M| ,| ,| /|Shift | |Up | | 1| 2| 3| |
|
||||||
|
* |-----------------------------------------------------------| ,-----------. |-----------|Ent|
|
||||||
|
* |Ctrl |Opt |Cmd | Space | |Opt |Ctrl | |Lef|Dow|Rig| | 0| .| |
|
||||||
|
* `-----------------------------------------------------------' `-----------' `---------------'
|
||||||
|
*/
|
||||||
|
#define KEYMAP( \
|
||||||
|
K35, K7A,K78,K63,K76, K60,K61,K62,K64, K65,K6D,K67,K6F, K69,K6B,K71, K7F, \
|
||||||
|
K32,K12,K13,K14,K15,K17,K16,K1A,K1C,K19,K1D,K1B,K18,K33, K72,K73,K74, K47,K51,K4B,K43, \
|
||||||
|
K30,K0C,K0D,K0E,K0F,K11,K10,K20,K22,K1F,K23,K21,K1E,K2A, K75,K77,K79, K59,K5B,K5C,K4E, \
|
||||||
|
K39,K00,K01,K02,K03,K05,K04,K26,K28,K25,K29,K27, K24, K56,K57,K58,K45, \
|
||||||
|
K38,K0A,K06,K07,K08,K09,K0B,K2D,K2E,K2B,K2F,K2C, K7B, K3E, K53,K54,K55, \
|
||||||
|
K36,K3A,K37, K31, K7C,K7D, K3B,K3D,K3C, K52, K41,K4C \
|
||||||
|
) { \
|
||||||
|
{ KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07 }, \
|
||||||
|
{ KC_##K08, KC_##K09, KC_##K0A, KC_##K0B, KC_##K0C, KC_##K0D, KC_##K0E, KC_##K0F }, \
|
||||||
|
{ KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17 }, \
|
||||||
|
{ KC_##K18, KC_##K19, KC_##K1A, KC_##K1B, KC_##K1C, KC_##K1D, KC_##K1E, KC_##K1F }, \
|
||||||
|
{ KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27 }, \
|
||||||
|
{ KC_##K28, KC_##K29, KC_##K2A, KC_##K2B, KC_##K2C, KC_##K2D, KC_##K2E, KC_##K2F }, \
|
||||||
|
{ KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_PENT, KC_##K35, KC_##K36, KC_##K37 }, \
|
||||||
|
{ KC_##K38, KC_##K39, KC_##K3A, KC_##K3B, KC_##K3C, KC_##K3D, KC_##K3E, KC_NO }, \
|
||||||
|
{ KC_F17, KC_##K41, KC_NO, KC_##K43, KC_F18, KC_##K45, KC_NO, KC_##K47 }, \
|
||||||
|
{ KC_NO, KC_NO, KC_NO, KC_##K4B, KC_##K4C, KC_NO, KC_##K4E, KC_F18 }, \
|
||||||
|
{ KC_F19, KC_##K51, KC_##K52, KC_##K53, KC_##K54, KC_##K55, KC_##K56, KC_##K57 }, \
|
||||||
|
{ KC_##K58, KC_##K59, KC_F20, KC_##K5B, KC_##K5C, KC_INT3, KC_INT1, KC_PCMM }, \
|
||||||
|
{ KC_##K60, KC_##K61, KC_##K62, KC_##K63, KC_##K64, KC_##K65, KC_LANG2, KC_##K67 }, \
|
||||||
|
{ KC_LANG1, KC_##K69, KC_F16, KC_##K6B, KC_NO, KC_##K6D, KC_APP, KC_##K6F }, \
|
||||||
|
{ KC_NO, KC_##K71, KC_##K72, KC_##K73, KC_##K74, KC_##K75, KC_##K76, KC_##K77 }, \
|
||||||
|
{ KC_##K78, KC_##K79, KC_##K7A, KC_##K7B, KC_##K7C, KC_##K7D, KC_NO, KC_##K7F } \
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* M0115 Apple Extended Keyboard ANSI
|
/* M0115 Apple Extended Keyboard ANSI
|
||||||
* ,---. ,---------------. ,---------------. ,---------------. ,-----------. ,---.
|
* ,---. ,---------------. ,---------------. ,---------------. ,-----------. ,---.
|
||||||
* |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau| |Pwr|
|
* |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau| |Pwr|
|
||||||
@ -93,10 +136,10 @@ extern const uint16_t fn_actions[];
|
|||||||
*/
|
*/
|
||||||
#define KEYMAP_EXT_ISO( \
|
#define KEYMAP_EXT_ISO( \
|
||||||
K35, K7A,K78,K63,K76, K60,K61,K62,K64, K65,K6D,K67,K6F, K69,K6B,K71, K7F, \
|
K35, K7A,K78,K63,K76, K60,K61,K62,K64, K65,K6D,K67,K6F, K69,K6B,K71, K7F, \
|
||||||
K0A,K12,K13,K14,K15,K17,K16,K1A,K1C,K19,K1D,K1B,K18,K33, K72,K73,K74, K47,K51,K4B,K43, \
|
K32,K12,K13,K14,K15,K17,K16,K1A,K1C,K19,K1D,K1B,K18,K33, K72,K73,K74, K47,K51,K4B,K43, \
|
||||||
K30,K0C,K0D,K0E,K0F,K11,K10,K20,K22,K1F,K23,K21,K1E,K24, K75,K77,K79, K59,K5B,K5C,K4E, \
|
K30,K0C,K0D,K0E,K0F,K11,K10,K20,K22,K1F,K23,K21,K1E,K24, K75,K77,K79, K59,K5B,K5C,K4E, \
|
||||||
K39,K00,K01,K02,K03,K05,K04,K26,K28,K25,K29,K27,K2A, K56,K57,K58,K45, \
|
K39,K00,K01,K02,K03,K05,K04,K26,K28,K25,K29,K27,K2A, K56,K57,K58,K45, \
|
||||||
K38,K32,K06,K07,K08,K09,K0B,K2D,K2E,K2B,K2F,K2C, K7B, K3E, K53,K54,K55, \
|
K38,K0A,K06,K07,K08,K09,K0B,K2D,K2E,K2B,K2F,K2C, K7B, K3E, K53,K54,K55, \
|
||||||
K36,K3A,K37, K31, K7C,K7D, K3B,K3D,K3C, K52, K41,K4C \
|
K36,K3A,K37, K31, K7C,K7D, K3B,K3D,K3C, K52, K41,K4C \
|
||||||
) { \
|
) { \
|
||||||
{ KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07 }, \
|
{ KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07 }, \
|
||||||
@ -183,16 +226,16 @@ extern const uint16_t fn_actions[];
|
|||||||
K35,K12,K13,K14,K15,K17,K16,K1A,K1C,K19,K1D,K1B,K18,K33, K47,K51,K4B,K43, \
|
K35,K12,K13,K14,K15,K17,K16,K1A,K1C,K19,K1D,K1B,K18,K33, K47,K51,K4B,K43, \
|
||||||
K30,K0C,K0D,K0E,K0F,K11,K10,K20,K22,K1F,K23,K21,K1E, K59,K5B,K5C,K45, \
|
K30,K0C,K0D,K0E,K0F,K11,K10,K20,K22,K1F,K23,K21,K1E, K59,K5B,K5C,K45, \
|
||||||
K39,K00,K01,K02,K03,K05,K04,K26,K28,K25,K29,K27,K2A,K24, K56,K57,K58,K4E, \
|
K39,K00,K01,K02,K03,K05,K04,K26,K28,K25,K29,K27,K2A,K24, K56,K57,K58,K4E, \
|
||||||
K38,K32,K06,K07,K08,K09,K0B,K2D,K2E,K2B,K2F,K2C,K7B,K3E, K53,K54,K55, \
|
K38,K0A,K06,K07,K08,K09,K0B,K2D,K2E,K2B,K2F,K2C,K7B,K3E, K53,K54,K55, \
|
||||||
K36,K3A,K37, K31, K3B,K3C,K3D, K52, K41,K4C \
|
K36,K3A,K37, K31, K3B,K3C,K3D, K52, K41,K4C \
|
||||||
) { \
|
) { \
|
||||||
{ KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07 }, \
|
{ KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07 }, \
|
||||||
{ KC_##K08, KC_##K09, KC_NO, KC_##K0B, KC_##K0C, KC_##K0D, KC_##K0E, KC_##K0F }, \
|
{ KC_##K08, KC_##K09, KC_##K0A KC_##K0B, KC_##K0C, KC_##K0D, KC_##K0E, KC_##K0F }, \
|
||||||
{ KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17 }, \
|
{ KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17 }, \
|
||||||
{ KC_##K18, KC_##K19, KC_##K1A, KC_##K1B, KC_##K1C, KC_##K1D, KC_##K1E, KC_##K1F }, \
|
{ KC_##K18, KC_##K19, KC_##K1A, KC_##K1B, KC_##K1C, KC_##K1D, KC_##K1E, KC_##K1F }, \
|
||||||
{ KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27 }, \
|
{ KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27 }, \
|
||||||
{ KC_##K28, KC_##K29, KC_##K2A, KC_##K2B, KC_##K2C, KC_##K2D, KC_##K2E, KC_##K2F }, \
|
{ KC_##K28, KC_##K29, KC_##K2A, KC_##K2B, KC_##K2C, KC_##K2D, KC_##K2E, KC_##K2F }, \
|
||||||
{ KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_NO, KC_##K35, KC_##K36, KC_##K37 }, \
|
{ KC_##K30, KC_##K31, KC_NO, KC_##K33, KC_NO, KC_##K35, KC_##K36, KC_##K37 }, \
|
||||||
{ KC_##K38, KC_##K39, KC_##K3A, KC_##K3B, KC_##K3C, KC_##K3D, KC_##K3E, KC_NO }, \
|
{ KC_##K38, KC_##K39, KC_##K3A, KC_##K3B, KC_##K3C, KC_##K3D, KC_##K3E, KC_NO }, \
|
||||||
{ KC_NO, KC_##K41, KC_NO, KC_##K43, KC_NO, KC_##K45, KC_NO, KC_##K47 }, \
|
{ KC_NO, KC_##K41, KC_NO, KC_##K43, KC_NO, KC_##K45, KC_NO, KC_##K47 }, \
|
||||||
{ KC_NO, KC_NO, KC_NO, KC_##K4B, KC_##K4C, KC_NO, KC_##K4E, KC_NO }, \
|
{ KC_NO, KC_NO, KC_NO, KC_##K4B, KC_##K4C, KC_NO, KC_##K4E, KC_NO }, \
|
||||||
|
42
converter/adb_usb/keymap_plain.c
Normal file
42
converter/adb_usb/keymap_plain.c
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
#include "keymap_common.h"
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ,---. ,---------------. ,---------------. ,---------------. ,-----------. ,---.
|
||||||
|
* |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau| |Pwr|
|
||||||
|
* `---' `---------------' `---------------' `---------------' `-----------' `---'
|
||||||
|
* ,-----------------------------------------------------------. ,-----------. ,---------------.
|
||||||
|
* | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backspa| |Ins|Hom|PgU| |NmL| =| /| *|
|
||||||
|
* |-----------------------------------------------------------| |-----------| |---------------|
|
||||||
|
* |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| |Del|End|PgD| | 7| 8| 9| -|
|
||||||
|
* |-----------------------------------------------------------| `-----------' |---------------|
|
||||||
|
* |CapsLo| A| S| D| F| G| H| J| K| L| ;| '|Return | | 4| 5| 6| +|
|
||||||
|
* |-----------------------------------------------------------| ,---. |---------------|
|
||||||
|
* |Shif|\ | Z| X| C| V| B| N| M| ,| ,| /|Shift | |Up | | 1| 2| 3| |
|
||||||
|
* |-----------------------------------------------------------| ,-----------. |-----------|Ent|
|
||||||
|
* |Ctrl |Opt |Cmd | Space | |Opt |Ctrl | |Lef|Dow|Rig| | 0| .| |
|
||||||
|
* `-----------------------------------------------------------' `-----------' `---------------'
|
||||||
|
*/
|
||||||
|
const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||||
|
[0] = KEYMAP(
|
||||||
|
ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,PAUS, NO,
|
||||||
|
FN0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, INS, HOME,PGUP, NLCK,EQL, PSLS,PAST,
|
||||||
|
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,FN1, DEL, END, PGDN, P7, P8, P9, PMNS,
|
||||||
|
LCAP,A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT, P4, P5, P6, PPLS,
|
||||||
|
LSFT,NUBS,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RSFT, UP, P1, P2, P3,
|
||||||
|
LCTL,LALT,LGUI, SPC, RALT,RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT
|
||||||
|
),
|
||||||
|
[1] = KEYMAP(
|
||||||
|
GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK, NO,
|
||||||
|
FN0, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, INS, HOME,PGUP, NLCK,BTN1,BTN2,BTN3,
|
||||||
|
TAB, Q, W, E, R, T, Y, U, PSCR,SLCK,PAUS,UP, INS, FN1, DEL, END, PGDN, WH_D,MS_U,WH_U,WH_D,
|
||||||
|
LCAP,VOLD,VOLU,MUTE,F, G, H, J, HOME,PGUP,LEFT,RGHT, ENT, MS_L,MS_D,MS_R,WH_U,
|
||||||
|
LSFT,NUBS,Z, X, C, V, B, N, M, END, PGDN,DOWN, RSFT, PGUP, WH_L,MS_D,WH_R,
|
||||||
|
LCTL,LGUI,LALT, SPC, RGUI,RCTL, HOME,PGDN,END, BTN1, BTN2,BTN3
|
||||||
|
),
|
||||||
|
};
|
||||||
|
|
||||||
|
const uint16_t PROGMEM fn_actions[] = {
|
||||||
|
[0] = ACTION_LAYER_TAP_KEY(1, KC_GRV),
|
||||||
|
[1] = ACTION_LAYER_TAP_KEY(1, KC_BSLS),
|
||||||
|
};
|
@ -39,6 +39,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
static bool is_iso_layout = false;
|
||||||
static bool is_modified = false;
|
static bool is_modified = false;
|
||||||
static report_mouse_t mouse_report = {};
|
static report_mouse_t mouse_report = {};
|
||||||
|
|
||||||
@ -72,6 +73,21 @@ void matrix_init(void)
|
|||||||
adb_host_init();
|
adb_host_init();
|
||||||
// wait for keyboard to boot up and receive command
|
// wait for keyboard to boot up and receive command
|
||||||
_delay_ms(1000);
|
_delay_ms(1000);
|
||||||
|
|
||||||
|
// Determine ISO keyboard by handle id
|
||||||
|
// http://lxr.free-electrons.com/source/drivers/macintosh/adbhid.c?v=4.4#L815
|
||||||
|
uint16_t handle_id = adb_host_talk(ADB_ADDR_KEYBOARD, 3);
|
||||||
|
switch (handle_id) {
|
||||||
|
case 0x04: case 0x05: case 0x07: case 0x09: case 0x0D:
|
||||||
|
case 0x11: case 0x14: case 0x19: case 0x1D: case 0xC1:
|
||||||
|
case 0xC4: case 0xC7:
|
||||||
|
is_iso_layout = true;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
is_iso_layout = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// Enable keyboard left/right modifier distinction
|
// Enable keyboard left/right modifier distinction
|
||||||
// Addr:Keyboard(0010), Cmd:Listen(10), Register3(11)
|
// Addr:Keyboard(0010), Cmd:Listen(10), Register3(11)
|
||||||
// upper byte: reserved bits 0000, device address 0010
|
// upper byte: reserved bits 0000, device address 0010
|
||||||
@ -92,6 +108,9 @@ void matrix_init(void)
|
|||||||
_delay_ms(500);
|
_delay_ms(500);
|
||||||
DDRD |= (1<<6); PORTD &= ~(1<<6);
|
DDRD |= (1<<6); PORTD &= ~(1<<6);
|
||||||
|
|
||||||
|
uint16_t handle_id2 = adb_host_talk(ADB_ADDR_KEYBOARD, 3);
|
||||||
|
xprintf("handle_id: %02X -> %02X\n", handle_id&0xff, handle_id2&0xff);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,6 +211,45 @@ uint8_t matrix_scan(void)
|
|||||||
xprintf("adb_host_kbd_recv: ERROR(%d)\n", codes);
|
xprintf("adb_host_kbd_recv: ERROR(%d)\n", codes);
|
||||||
return key1;
|
return key1;
|
||||||
} else {
|
} else {
|
||||||
|
/* Swap codes for ISO keyboard
|
||||||
|
*
|
||||||
|
* ANSI
|
||||||
|
* ,----------- ----------.
|
||||||
|
* | *a| 1| 2 =|Backspa|
|
||||||
|
* |----------- ----------|
|
||||||
|
* |Tab | Q| | ]| *c|
|
||||||
|
* |----------- ----------|
|
||||||
|
* |CapsLo| A| '|Return |
|
||||||
|
* |----------- ----------|
|
||||||
|
* |Shift | Shift |
|
||||||
|
* `----------- ----------'
|
||||||
|
*
|
||||||
|
* ISO
|
||||||
|
* ,----------- ----------.
|
||||||
|
* | *a| 1| 2 =|Backspa|
|
||||||
|
* |----------- ----------|
|
||||||
|
* |Tab | Q| | ]|Retur|
|
||||||
|
* |----------- -----` |
|
||||||
|
* |CapsLo| A| '| *c| |
|
||||||
|
* |----------- ----------|
|
||||||
|
* |Shif| *b| Shift |
|
||||||
|
* `----------- ----------'
|
||||||
|
*
|
||||||
|
* ADB scan code USB usage
|
||||||
|
* ------------- ---------
|
||||||
|
* Key ANSI ISO ANSI ISO
|
||||||
|
* ---------------------------------------------
|
||||||
|
* *a 0x32 0x0A 0x35 0x35
|
||||||
|
* *b ---- 0x32 ---- 0x64
|
||||||
|
* *c 0x2A 0x2A 0x31 0x31(or 0x32)
|
||||||
|
*/
|
||||||
|
if (is_iso_layout) {
|
||||||
|
if (key0 == 0x32) {
|
||||||
|
key0 = 0x0A;
|
||||||
|
} else if (key0 == 0x0A) {
|
||||||
|
key0 = 0x32;
|
||||||
|
}
|
||||||
|
}
|
||||||
register_key(key0);
|
register_key(key0);
|
||||||
if (key1 != 0xFF) // key1 is 0xFF when no second key.
|
if (key1 != 0xFF) // key1 is 0xFF when no second key.
|
||||||
extra_key = key1<<8 | 0xFF; // process in a separate call
|
extra_key = key1<<8 | 0xFF; // process in a separate call
|
||||||
|
@ -60,7 +60,6 @@ static inline void place_bit1(void);
|
|||||||
static inline void send_byte(uint8_t data);
|
static inline void send_byte(uint8_t data);
|
||||||
static inline uint16_t wait_data_lo(uint16_t us);
|
static inline uint16_t wait_data_lo(uint16_t us);
|
||||||
static inline uint16_t wait_data_hi(uint16_t us);
|
static inline uint16_t wait_data_hi(uint16_t us);
|
||||||
static inline uint16_t adb_host_dev_recv(uint8_t device);
|
|
||||||
|
|
||||||
|
|
||||||
void adb_host_init(void)
|
void adb_host_init(void)
|
||||||
@ -87,49 +86,9 @@ bool adb_host_psw(void)
|
|||||||
* <http://geekhack.org/index.php?topic=14290.msg1068919#msg1068919>
|
* <http://geekhack.org/index.php?topic=14290.msg1068919#msg1068919>
|
||||||
* <http://geekhack.org/index.php?topic=14290.msg1070139#msg1070139>
|
* <http://geekhack.org/index.php?topic=14290.msg1070139#msg1070139>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// ADB Bit Cells
|
|
||||||
//
|
|
||||||
// bit cell time: 70-130us
|
|
||||||
// low part of bit0: 60-70% of bit cell
|
|
||||||
// low part of bit1: 30-40% of bit cell
|
|
||||||
//
|
|
||||||
// bit cell time 70us 130us
|
|
||||||
// --------------------------------------------
|
|
||||||
// low part of bit0 42-49 78-91
|
|
||||||
// high part of bit0 21-28 39-52
|
|
||||||
// low part of bit1 21-28 39-52
|
|
||||||
// high part of bit1 42-49 78-91
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// bit0:
|
|
||||||
// 70us bit cell:
|
|
||||||
// ____________~~~~~~
|
|
||||||
// 42-49 21-28
|
|
||||||
//
|
|
||||||
// 130us bit cell:
|
|
||||||
// ____________~~~~~~
|
|
||||||
// 78-91 39-52
|
|
||||||
//
|
|
||||||
// bit1:
|
|
||||||
// 70us bit cell:
|
|
||||||
// ______~~~~~~~~~~~~
|
|
||||||
// 21-28 42-49
|
|
||||||
//
|
|
||||||
// 130us bit cell:
|
|
||||||
// ______~~~~~~~~~~~~
|
|
||||||
// 39-52 78-91
|
|
||||||
//
|
|
||||||
// [from Apple IIgs Hardware Reference Second Edition]
|
|
||||||
|
|
||||||
enum {
|
|
||||||
ADDR_KEYB = 0x20,
|
|
||||||
ADDR_MOUSE = 0x30
|
|
||||||
};
|
|
||||||
|
|
||||||
uint16_t adb_host_kbd_recv(void)
|
uint16_t adb_host_kbd_recv(void)
|
||||||
{
|
{
|
||||||
return adb_host_dev_recv(ADDR_KEYB);
|
return adb_host_talk(ADB_ADDR_KEYBOARD, ADB_REG_0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ADB_MOUSE_ENABLE
|
#ifdef ADB_MOUSE_ENABLE
|
||||||
@ -139,16 +98,16 @@ void adb_mouse_init(void) {
|
|||||||
|
|
||||||
uint16_t adb_host_mouse_recv(void)
|
uint16_t adb_host_mouse_recv(void)
|
||||||
{
|
{
|
||||||
return adb_host_dev_recv(ADDR_MOUSE);
|
return adb_host_talk(ADB_ADDR_MOUSE, ADB_REG_0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static inline uint16_t adb_host_dev_recv(uint8_t device)
|
uint16_t adb_host_talk(uint8_t addr, uint8_t reg)
|
||||||
{
|
{
|
||||||
uint16_t data = 0;
|
uint16_t data = 0;
|
||||||
cli();
|
cli();
|
||||||
attention();
|
attention();
|
||||||
send_byte(device|0x0C); // Addr:Keyboard(0010)/Mouse(0011), Cmd:Talk(11), Register0(00)
|
send_byte((addr<<4) | (ADB_CMD_TALK<<2) | reg);
|
||||||
place_bit0(); // Stopbit(0)
|
place_bit0(); // Stopbit(0)
|
||||||
if (!wait_data_hi(500)) { // Service Request(310us Adjustable Keyboard): just ignored
|
if (!wait_data_hi(500)) { // Service Request(310us Adjustable Keyboard): just ignored
|
||||||
sei();
|
sei();
|
||||||
@ -474,5 +433,46 @@ Keyboard LEDs & state of keys(Register2)
|
|||||||
| +----------------------------- Delete
|
| +----------------------------- Delete
|
||||||
+------------------------------- Reserved
|
+------------------------------- Reserved
|
||||||
|
|
||||||
|
ADB Bit Cells
|
||||||
|
bit cell time: 70-130us
|
||||||
|
low part of bit0: 60-70% of bit cell
|
||||||
|
low part of bit1: 30-40% of bit cell
|
||||||
|
|
||||||
|
bit cell time 70us 130us
|
||||||
|
--------------------------------------------
|
||||||
|
low part of bit0 42-49 78-91
|
||||||
|
high part of bit0 21-28 39-52
|
||||||
|
low part of bit1 21-28 39-52
|
||||||
|
high part of bit1 42-49 78-91
|
||||||
|
|
||||||
|
|
||||||
|
bit0:
|
||||||
|
70us bit cell:
|
||||||
|
____________~~~~~~
|
||||||
|
42-49 21-28
|
||||||
|
|
||||||
|
130us bit cell:
|
||||||
|
____________~~~~~~
|
||||||
|
78-91 39-52
|
||||||
|
|
||||||
|
bit1:
|
||||||
|
70us bit cell:
|
||||||
|
______~~~~~~~~~~~~
|
||||||
|
21-28 42-49
|
||||||
|
|
||||||
|
130us bit cell:
|
||||||
|
______~~~~~~~~~~~~
|
||||||
|
39-52 78-91
|
||||||
|
|
||||||
|
[from Apple IIgs Hardware Reference Second Edition]
|
||||||
|
|
||||||
|
Keyboard Handle ID
|
||||||
|
Apple Standard Keyboard M0116: 0x01
|
||||||
|
Apple Extended Keyboard M0115: 0x02
|
||||||
|
Apple Extended Keyboard II M3501: 0x02
|
||||||
|
Apple Adjustable Keybaord: 0x10
|
||||||
|
|
||||||
|
http://lxr.free-electrons.com/source/drivers/macintosh/adbhid.c?v=4.4#L802
|
||||||
|
|
||||||
END_OF_ADB
|
END_OF_ADB
|
||||||
*/
|
*/
|
||||||
|
@ -52,11 +52,29 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#define ADB_CAPS 0x39
|
#define ADB_CAPS 0x39
|
||||||
|
|
||||||
|
|
||||||
|
/* ADB commands */
|
||||||
|
#define ADB_ADDR_KEYBOARD 2
|
||||||
|
#define ADB_ADDR_MOUSE 3
|
||||||
|
#define ADB_CMD_LISTEN 2
|
||||||
|
#define ADB_CMD_TALK 3
|
||||||
|
#define ADB_REG_0 0
|
||||||
|
#define ADB_REG_1 1
|
||||||
|
#define ADB_REG_2 2
|
||||||
|
#define ADB_REG_3 3
|
||||||
|
|
||||||
|
/* ADB keyboard handle id */
|
||||||
|
#define ADB_HANDLE_M0116 0x01
|
||||||
|
#define ADB_HANDLE_M0115 0x02
|
||||||
|
#define ADB_HANDLE_M3501 0x02
|
||||||
|
#define ADB_HANDLE_M1242 0x10
|
||||||
|
|
||||||
|
|
||||||
// ADB host
|
// ADB host
|
||||||
void adb_host_init(void);
|
void adb_host_init(void);
|
||||||
bool adb_host_psw(void);
|
bool adb_host_psw(void);
|
||||||
uint16_t adb_host_kbd_recv(void);
|
uint16_t adb_host_kbd_recv(void);
|
||||||
uint16_t adb_host_mouse_recv(void);
|
uint16_t adb_host_mouse_recv(void);
|
||||||
|
uint16_t adb_host_talk(uint8_t addr, uint8_t reg);
|
||||||
void adb_host_listen(uint8_t cmd, uint8_t data_h, uint8_t data_l);
|
void adb_host_listen(uint8_t cmd, uint8_t data_h, uint8_t data_l);
|
||||||
void adb_host_kbd_led(uint8_t led);
|
void adb_host_kbd_led(uint8_t led);
|
||||||
void adb_mouse_task(void);
|
void adb_mouse_task(void);
|
||||||
|
Loading…
Reference in New Issue
Block a user