ADB keyboard LEDs support
This commit is contained in:
parent
40c24dc89a
commit
06db39583f
43
ADB.txt
43
ADB.txt
@ -3,11 +3,14 @@ ADB Protocol
|
|||||||
|
|
||||||
Resources
|
Resources
|
||||||
---------
|
---------
|
||||||
|
ADB - The Untold Story: Space Aliens Ate My Mouse
|
||||||
|
http://developer.apple.com/legacy/mac/library/#technotes/hw/hw_01.html
|
||||||
Apple IIgs Hardware Reference Second Edition [p80(Chapter6 p121)]
|
Apple IIgs Hardware Reference Second Edition [p80(Chapter6 p121)]
|
||||||
ftp://ftp.apple.asimov.net/pub/apple_II/documentation/Apple%20IIgs%20Hardware%20Reference.pdf
|
ftp://ftp.apple.asimov.net/pub/apple_II/documentation/Apple%20IIgs%20Hardware%20Reference.pdf
|
||||||
ADB Keycode
|
ADB Keycode
|
||||||
http://72.0.193.250/Documentation/macppc/adbkeycodes/
|
http://72.0.193.250/Documentation/macppc/adbkeycodes/
|
||||||
http://m0115.web.fc2.com/m0115.jpg
|
http://m0115.web.fc2.com/m0115.jpg
|
||||||
|
[Inside Macintosh volume V, pages 191-192]
|
||||||
ADB Signaling
|
ADB Signaling
|
||||||
http://kbdbabel.sourceforge.net/doc/kbd_signaling_pcxt_ps2_adb.pdf
|
http://kbdbabel.sourceforge.net/doc/kbd_signaling_pcxt_ps2_adb.pdf
|
||||||
ADB Overview & History
|
ADB Overview & History
|
||||||
@ -61,9 +64,9 @@ Commands
|
|||||||
3: mice
|
3: mice
|
||||||
|
|
||||||
Registers:
|
Registers:
|
||||||
0: application(keyobard/mice use to store its data.)
|
0: application(keyobard uses this to store its data.)
|
||||||
1: application
|
1: application
|
||||||
2: application
|
2: application(keyboard uses this for LEDs and state of modifiers)
|
||||||
3: status and command
|
3: status and command
|
||||||
|
|
||||||
|
|
||||||
@ -111,15 +114,17 @@ Communication
|
|||||||
keep low for 300us to request.
|
keep low for 300us to request.
|
||||||
|
|
||||||
|
|
||||||
Keyboard data(register0)
|
Keyboard Data(Register0)
|
||||||
This 16bit data can contains 2 keycodes and 2 released flags.
|
This 16bit data can contains two keycodes and two released flags.
|
||||||
First keycode is palced in upper nibble. When one keyocode is sent,
|
First keycode is palced in upper byte. When one keyocode is sent,
|
||||||
lower nibble is 0xFF.
|
lower byte is 0xFF.
|
||||||
Release flag is 1 when key is released.
|
Release flag is 1 when key is released.
|
||||||
|
|
||||||
15 14 . . . . . 8 7 6 . . . . . 0
|
1514 . . . . . 8 7 6 . . . . . 0
|
||||||
| |keycode1 | |keycode2
|
| | | | | | | | | +-+-+-+-+-+-+- Keycode2
|
||||||
|released(1) |released(1)
|
| | | | | | | | +--------------- Released2(1 when the key is released)
|
||||||
|
| +-+-+-+-+-+-+----------------- Keycode1
|
||||||
|
+------------------------------- Released1(1 when the key is released)
|
||||||
|
|
||||||
Keycodes:
|
Keycodes:
|
||||||
Scancode consists of 7bit keycode and 1bit release flag.
|
Scancode consists of 7bit keycode and 1bit release flag.
|
||||||
@ -131,4 +136,24 @@ Keyboard data(register0)
|
|||||||
the switch has a special scancode 0x7F7F, so you can
|
the switch has a special scancode 0x7F7F, so you can
|
||||||
also read from Data line. It uses 0xFFFF for release scancode.
|
also read from Data line. It uses 0xFFFF for release scancode.
|
||||||
|
|
||||||
|
Keyboard LEDs & state of keys(Register2)
|
||||||
|
This register hold current state of three LEDs and nine keys.
|
||||||
|
The state of LEDs can be changed by sending Listen command.
|
||||||
|
|
||||||
|
1514 . . . . . . 7 6 5 . 3 2 1 0
|
||||||
|
| | | | | | | | | | | | | | | +- LED1(NumLock)
|
||||||
|
| | | | | | | | | | | | | | +--- LED2(CapsLock)
|
||||||
|
| | | | | | | | | | | | | +----- LED3(ScrollLock)
|
||||||
|
| | | | | | | | | | +-+-+------- Reserved
|
||||||
|
| | | | | | | | | +------------- ScrollLock
|
||||||
|
| | | | | | | | +--------------- NumLock
|
||||||
|
| | | | | | | +----------------- Apple/Command
|
||||||
|
| | | | | | +------------------- Option
|
||||||
|
| | | | | +--------------------- Shift
|
||||||
|
| | | | +----------------------- Control
|
||||||
|
| | | +------------------------- Reset/Power
|
||||||
|
| | +--------------------------- CapsLock
|
||||||
|
| +----------------------------- Delete
|
||||||
|
+------------------------------- Reserved
|
||||||
|
|
||||||
END_OF_ADB
|
END_OF_ADB
|
||||||
|
19
adb.c
19
adb.c
@ -42,9 +42,9 @@ uint16_t adb_host_kbd_recv(void)
|
|||||||
{
|
{
|
||||||
uint16_t data = 0;
|
uint16_t data = 0;
|
||||||
attention();
|
attention();
|
||||||
send_byte(0x2C); // Addr:2, Cmd:talk(11), Reg:0(00)
|
send_byte(0x2C); // Addr:Keyboard(0010), Cmd:Talk(11), Register0(00)
|
||||||
place_bit0(); // Stopbit
|
place_bit0(); // Stopbit(0)
|
||||||
if (!wait_data_lo(0xFF)) // Stop to Start(140-260us)
|
if (!wait_data_lo(0xFF)) // Tlt/Stop to Start(140-260us)
|
||||||
return 0; // No data to send
|
return 0; // No data to send
|
||||||
if (!read_bit()) // Startbit(1)
|
if (!read_bit()) // Startbit(1)
|
||||||
return -2;
|
return -2;
|
||||||
@ -55,6 +55,19 @@ uint16_t adb_host_kbd_recv(void)
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// send state of LEDs
|
||||||
|
void adb_host_kbd_led(uint8_t led)
|
||||||
|
{
|
||||||
|
attention();
|
||||||
|
send_byte(0x2A); // Addr:Keyboard(0010), Cmd:Listen(10), Register2(10)
|
||||||
|
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)
|
||||||
|
place_bit0(); // Stopbit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static inline void data_lo()
|
static inline void data_lo()
|
||||||
{
|
{
|
||||||
|
1
adb.h
1
adb.h
@ -14,5 +14,6 @@
|
|||||||
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_kbd_led(uint8_t led);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
ADB to USB keyboard converter
|
ADB to USB keyboard converter
|
||||||
=============================
|
=============================
|
||||||
|
http://geekhack.org/showwiki.php?title=Island:14290
|
||||||
|
|
||||||
This firmware converts ADB keyboard protocol to USB.
|
This firmware converts ADB keyboard protocol to USB.
|
||||||
|
|
||||||
|
|
||||||
Build
|
Build
|
||||||
-----
|
-----
|
||||||
0. Connect ADB keyboard to Teensy by 3 lines(Vcc, GND, Data).
|
0. Connect ADB keyboard to Teensy by 3 lines(Vcc, GND, Data).
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "adb.h"
|
#include "adb.h"
|
||||||
|
#include "usb_keyboard.h"
|
||||||
#include "matrix_skel.h"
|
#include "matrix_skel.h"
|
||||||
|
|
||||||
|
|
||||||
@ -71,8 +72,13 @@ uint8_t matrix_scan(void)
|
|||||||
uint16_t codes;
|
uint16_t codes;
|
||||||
uint8_t key0, key1;
|
uint8_t key0, key1;
|
||||||
|
|
||||||
_matrix_is_modified = false;
|
static uint8_t prev_led = 0;
|
||||||
|
if (prev_led != usb_keyboard_leds) {
|
||||||
|
adb_host_kbd_led(~usb_keyboard_leds);
|
||||||
|
prev_led = usb_keyboard_leds;
|
||||||
|
}
|
||||||
|
|
||||||
|
_matrix_is_modified = false;
|
||||||
codes = adb_host_kbd_recv();
|
codes = adb_host_kbd_recv();
|
||||||
key0 = codes>>8;
|
key0 = codes>>8;
|
||||||
key1 = codes&0xFF;
|
key1 = codes&0xFF;
|
||||||
|
Loading…
Reference in New Issue
Block a user