aboutsummaryrefslogtreecommitdiff
path: root/protocol
diff options
context:
space:
mode:
authortmk <nobody@nowhere>2012-12-12 09:45:00 +0900
committertmk <nobody@nowhere>2012-12-12 09:49:59 +0900
commitcf1eb8fbc6789776d3b3457dd5cf4ed84815e8b3 (patch)
treedc2ec05a2b19e60a0550b44085142fd548b5a54f /protocol
parent72dc413a19562b6a67509d4fd6a1cb9c07227d3d (diff)
downloadqmk_firmware-cf1eb8fbc6789776d3b3457dd5cf4ed84815e8b3.tar.gz
qmk_firmware-cf1eb8fbc6789776d3b3457dd5cf4ed84815e8b3.zip
Add ADB extended keyboard support by blargg@GH.
This offers distinction between left/right modifiers.
Diffstat (limited to 'protocol')
-rw-r--r--protocol/adb.c24
-rw-r--r--protocol/adb.h1
2 files changed, 20 insertions, 5 deletions
diff --git a/protocol/adb.c b/protocol/adb.c
index d7105b3a9..9f52f6ce7 100644
--- a/protocol/adb.c
+++ b/protocol/adb.c
@@ -67,6 +67,12 @@ void adb_host_init(void)
67#ifdef ADB_PSW_BIT 67#ifdef ADB_PSW_BIT
68 psw_hi(); 68 psw_hi();
69#endif 69#endif
70
71 // Enable keyboard left/right modifier distinction
72 // Addr:Keyboard(0010), Cmd:Listen(10), Register3(11)
73 // upper byte: reserved bits 0000, device address 0010
74 // lower byte: device handler 00000011
75 adb_host_listen(0x2B,0x02,0x03);
70} 76}
71 77
72#ifdef ADB_PSW_BIT 78#ifdef ADB_PSW_BIT
@@ -98,19 +104,27 @@ uint16_t adb_host_kbd_recv(void)
98 return data; 104 return data;
99} 105}
100 106
101// send state of LEDs 107void adb_host_listen(uint8_t cmd, uint8_t data_h, uint8_t data_l)
102void adb_host_kbd_led(uint8_t led)
103{ 108{
104 attention(); 109 attention();
105 send_byte(0x2A); // Addr:Keyboard(0010), Cmd:Listen(10), Register2(10) 110 send_byte(cmd);
106 place_bit0(); // Stopbit(0) 111 place_bit0(); // Stopbit(0)
107 _delay_us(200); // Tlt/Stop to Start 112 _delay_us(200); // Tlt/Stop to Start
108 place_bit1(); // Startbit(1) 113 place_bit1(); // Startbit(1)
109 send_byte(0); // send upper byte (not used) 114 send_byte(data_h);
110 send_byte(led&0x07); // send lower byte (bit2: ScrollLock, bit1: CapsLock, bit0: NumLock) 115 send_byte(data_l);
111 place_bit0(); // Stopbit(0); 116 place_bit0(); // Stopbit(0);
112} 117}
113 118
119// send state of LEDs
120void adb_host_kbd_led(uint8_t led)
121{
122 // Addr:Keyboard(0010), Cmd:Listen(10), Register2(10)
123 // send upper byte (not used)
124 // send lower byte (bit2: ScrollLock, bit1: CapsLock, bit0:
125 adb_host_listen(0x2A,0,led&0x07);
126}
127
114 128
115static inline void data_lo() 129static inline void data_lo()
116{ 130{
diff --git a/protocol/adb.h b/protocol/adb.h
index 1e4ca4013..bfe598bbf 100644
--- a/protocol/adb.h
+++ b/protocol/adb.h
@@ -56,6 +56,7 @@ POSSIBILITY OF SUCH DAMAGE.
56void adb_host_init(void); 56void adb_host_init(void);
57bool adb_host_psw(void); 57bool adb_host_psw(void);
58uint16_t adb_host_kbd_recv(void); 58uint16_t adb_host_kbd_recv(void);
59void adb_host_listen(uint8_t cmd, uint8_t data_h, uint8_t data_l);
59void adb_host_kbd_led(uint8_t led); 60void adb_host_kbd_led(uint8_t led);
60 61
61#endif 62#endif