summaryrefslogtreecommitdiff
path: root/converter/adb_usb/adb_blargg.h
diff options
context:
space:
mode:
authortmk2013-10-11 10:12:22 +0900
committertmk2013-10-11 10:12:22 +0900
commit59ecced486618161ab18ea9a95dd51e1414fedb8 (patch)
tree7b5bb399740c12618b9ad395a27e84ccde395304 /converter/adb_usb/adb_blargg.h
parent86082f90fa582e3b419dbd77228ff497b2ee56cf (diff)
Add ADB protocol files from blargg's work
- <http://geekhack.org/index.php?topic=14290.msg1070604#msg1070604>
Diffstat (limited to 'converter/adb_usb/adb_blargg.h')
-rw-r--r--converter/adb_usb/adb_blargg.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/converter/adb_usb/adb_blargg.h b/converter/adb_usb/adb_blargg.h
new file mode 100644
index 000000000..2542cb549
--- /dev/null
+++ b/converter/adb_usb/adb_blargg.h
@@ -0,0 +1,38 @@
+// Basic support for ADB keyboard
+
+#ifndef ADB_BLARGG_H
+#define ADB_BLARGG_H
+
+#include <stdint.h>
+#include <stdbool.h>
+
+// Sets up ADB bus. Doesn't send anything to keyboard.
+void adb_host_init( void );
+
+// Receives key press event from keyboard.
+// 0xKKFF: one key changed state
+// 0xKKKK: two keys changed state
+enum { adb_host_nothing = 0 }; // no keys changed state
+enum { adb_host_error = 0xFFFE }; // receive error
+uint16_t adb_host_kbd_recv( void );
+
+// Current state of keyboard modifiers and a few other keys
+// Returns adb_host_nothing if keyboard didn't respond.
+// Returns adb_host_error if error receiving.
+uint16_t adb_host_kbd_modifiers( void );
+
+// Sends command and two bytes of data to keyboard
+void adb_host_listen( uint8_t cmd, uint8_t data_h, uint8_t data_l );
+
+// Sets keyboard LEDs. Note that bits are inverted here, so 1 means off, 0 means on.
+void adb_host_kbd_led( uint8_t led );
+
+// State of power switch (false = pressed), or true if unsupported
+bool adb_host_psw( void );
+
+
+// Legacy support
+#define ADB_POWER 0x7F
+#define ADB_CAPS 0x39
+
+#endif