Add ADB extended keyboard support by blargg@GH.
This offers distinction between left/right modifiers.
This commit is contained in:
parent
887563e89e
commit
80f99bf022
@ -67,6 +67,12 @@ void adb_host_init(void)
|
|||||||
#ifdef ADB_PSW_BIT
|
#ifdef ADB_PSW_BIT
|
||||||
psw_hi();
|
psw_hi();
|
||||||
#endif
|
#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
|
#ifdef ADB_PSW_BIT
|
||||||
@ -98,19 +104,27 @@ uint16_t adb_host_kbd_recv(void)
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
// send state of LEDs
|
void adb_host_listen(uint8_t cmd, uint8_t data_h, uint8_t data_l)
|
||||||
void adb_host_kbd_led(uint8_t led)
|
|
||||||
{
|
{
|
||||||
attention();
|
attention();
|
||||||
send_byte(0x2A); // Addr:Keyboard(0010), Cmd:Listen(10), Register2(10)
|
send_byte(cmd);
|
||||||
place_bit0(); // Stopbit(0)
|
place_bit0(); // Stopbit(0)
|
||||||
_delay_us(200); // Tlt/Stop to Start
|
_delay_us(200); // Tlt/Stop to Start
|
||||||
place_bit1(); // Startbit(1)
|
place_bit1(); // Startbit(1)
|
||||||
send_byte(0); // send upper byte (not used)
|
send_byte(data_h);
|
||||||
send_byte(led&0x07); // send lower byte (bit2: ScrollLock, bit1: CapsLock, bit0: NumLock)
|
send_byte(data_l);
|
||||||
place_bit0(); // Stopbit(0);
|
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()
|
static inline void data_lo()
|
||||||
{
|
{
|
||||||
|
@ -56,6 +56,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||||||
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);
|
||||||
|
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);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user