Add ADB extended keyboard support by blargg@GH.

This offers distinction between left/right modifiers.
pull/12/head
tmk 12 years ago
parent 72dc413a19
commit cf1eb8fbc6

@ -40,7 +40,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
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,K06,K07,K08,K09,K0B,K2D,K2E,K2B,K2F,K2C, K7B, K3E, K53,K54,K55, \
K36,K3A,K37, K31, 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_##K08, KC_##K09, KC_NO, KC_##K0B, KC_##K0C, KC_##K0D, KC_##K0E, KC_##K0F }, \
@ -57,7 +57,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
{ KC_##K60, KC_##K61, KC_##K62, KC_##K63, KC_##K64, KC_##K65, KC_NO, KC_##K67 }, \
{ KC_NO, KC_##K69, KC_NO, KC_##K6B, KC_NO, KC_##K6D, KC_NO, 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_NO, KC_NO, KC_NO, KC_##K7F } \
{ KC_##K78, KC_##K79, KC_##K7A, KC_##K7B, KC_##K7C, KC_##K7D, KC_NO, KC_##K7F } \
}
@ -109,7 +109,7 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, DEL, END, PGDN, P7, P8, P9, PMNS,
CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT, P4, P5, P6, PPLS,
LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RSFT, UP, P1, P2, P3,
LCTL,LGUI,LALT, SPC, LEFT,DOWN,RGHT, P0, PDOT,PENT
LCTL,LGUI,LALT, SPC, RGUI,RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT
),
};

@ -67,6 +67,12 @@ void adb_host_init(void)
#ifdef ADB_PSW_BIT
psw_hi();
#endif
// Enable keyboard left/right modifier distinction
// Addr:Keyboard(0010), Cmd:Listen(10), Register3(11)
// upper byte: reserved bits 0000, device address 0010
// lower byte: device handler 00000011
adb_host_listen(0x2B,0x02,0x03);
}
#ifdef ADB_PSW_BIT
@ -98,19 +104,27 @@ uint16_t adb_host_kbd_recv(void)
return data;
}
// send state of LEDs
void adb_host_kbd_led(uint8_t led)
void adb_host_listen(uint8_t cmd, uint8_t data_h, uint8_t data_l)
{
attention();
send_byte(0x2A); // Addr:Keyboard(0010), Cmd:Listen(10), Register2(10)
send_byte(cmd);
place_bit0(); // Stopbit(0)
_delay_us(200); // Tlt/Stop to Start
place_bit1(); // Startbit(1)
send_byte(0); // send upper byte (not used)
send_byte(led&0x07); // send lower byte (bit2: ScrollLock, bit1: CapsLock, bit0: NumLock)
send_byte(data_h);
send_byte(data_l);
place_bit0(); // Stopbit(0);
}
// send state of LEDs
void adb_host_kbd_led(uint8_t led)
{
// Addr:Keyboard(0010), Cmd:Listen(10), Register2(10)
// send upper byte (not used)
// send lower byte (bit2: ScrollLock, bit1: CapsLock, bit0:
adb_host_listen(0x2A,0,led&0x07);
}
static inline void data_lo()
{

@ -56,6 +56,7 @@ POSSIBILITY OF SUCH DAMAGE.
void adb_host_init(void);
bool adb_host_psw(void);
uint16_t adb_host_kbd_recv(void);
void adb_host_listen(uint8_t cmd, uint8_t data_h, uint8_t data_l);
void adb_host_kbd_led(uint8_t led);
#endif

Loading…
Cancel
Save