mirror of
https://github.com/demik/quack.git
synced 2024-11-21 14:32:12 +00:00
added support for MacAlly Joystick (thanks tashtari@68kmla !)
This commit is contained in:
parent
53b675040e
commit
9e2e5847fc
@ -1,3 +1,6 @@
|
||||
## v1.4.8
|
||||
- added support for MacAlly Joystick
|
||||
|
||||
## v1.4.7
|
||||
- new feature: half click on right BT click (similar to some ADB devices)
|
||||
- workarounds for v1.4.6 green led regression
|
||||
|
45
main/adb.c
45
main/adb.c
@ -50,12 +50,13 @@ extern QueueHandle_t q_qx, q_qy;
|
||||
|
||||
/* static defines */
|
||||
static void adb_handle_button(bool action);
|
||||
static void adb_rmt_reset(void);
|
||||
static void adb_rmt_reset(void);
|
||||
static bool adb_rx_isone(rmt_item32_t cell);
|
||||
static bool adb_rx_isstop(rmt_item32_t cell);
|
||||
static bool adb_rx_iszero(rmt_item32_t cell);
|
||||
static uint16_t IRAM_ATTR adb_rx_mouse();
|
||||
static void adb_rx_setup(void);
|
||||
static void adb_scan_macaj(void);
|
||||
static void adb_tx_as(void);
|
||||
static void adb_tx_one(void);
|
||||
static void adb_tx_setup(void);
|
||||
@ -181,12 +182,17 @@ void adb_probe(void) {
|
||||
|
||||
/* Accept all known handlers */
|
||||
if (((register3 & ADB_H_ALL) == ADB_H_C100) || ((register3 & ADB_H_ALL) == ADB_H_C200) ||
|
||||
((register3 & ADB_H_ALL) == ADB_H_MTRC) || ((register3 & ADB_H_ALL) == ADB_H_KSGT)) {
|
||||
((register3 & ADB_H_ALL) == ADB_H_MTRC) || ((register3 & ADB_H_ALL) == ADB_H_KSGT) ||
|
||||
((register3 & ADB_H_ALL) == ADB_H_MACJ)) {
|
||||
ESP_LOGI(TAG, "… detected mouse at $3");
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
/* try to find other misc devices */
|
||||
if (!register3)
|
||||
adb_scan_macaj();
|
||||
|
||||
vTaskDelay(500 / portTICK_PERIOD_MS);
|
||||
}
|
||||
|
||||
@ -206,6 +212,9 @@ void adb_probe(void) {
|
||||
case ADB_H_C200:
|
||||
ESP_LOGD(TAG, "Mouse running at 200cpi");
|
||||
break;
|
||||
case ADB_H_MACJ:
|
||||
ESP_LOGD(TAG, "MacAlly Joystick running at default cpi");
|
||||
break;
|
||||
case ADB_H_MTRC:
|
||||
ESP_LOGD(TAG, "MacTRAC running at default cpi");
|
||||
break;
|
||||
@ -239,6 +248,38 @@ static void adb_rmt_reset() {
|
||||
adb_tx_reset();
|
||||
}
|
||||
|
||||
/*
|
||||
* MacAlly Joystick uses address $5 instead of the classic $3
|
||||
* First check that it's in mouse mode emulation then switch it to $3
|
||||
* We should then be able to use the base code path
|
||||
*
|
||||
* https://github.com/lampmerchant/tashnotes/blob/main/macintosh/adb/protocols/macally_joystick.md
|
||||
*/
|
||||
|
||||
static void adb_scan_macaj() {
|
||||
uint16_t register1;
|
||||
|
||||
/* the joystick will not move if we don't don't talk to register 3 first */
|
||||
vTaskDelay(7 / portTICK_PERIOD_MS);
|
||||
adb_tx_cmd(ADB_MACAJ|ADB_TALK|ADB_REG3);
|
||||
adb_rx_mouse();
|
||||
vTaskDelay(7 / portTICK_PERIOD_MS);
|
||||
adb_tx_cmd(ADB_MACAJ|ADB_TALK|ADB_REG1);
|
||||
register1 = adb_rx_mouse();
|
||||
|
||||
if (register1 == 0xAAAA) {
|
||||
ESP_LOGD(TAG, "MacAlly Joystick in joystick mode detected, switching modes");
|
||||
adb_tx_listen(ADB_MACAJ|ADB_LISTEN|ADB_REG1, 0xAAAA);
|
||||
vTaskDelay(7 / portTICK_PERIOD_MS);
|
||||
adb_tx_cmd(ADB_MACAJ|ADB_TALK|ADB_REG1);
|
||||
register1 = adb_rx_mouse();
|
||||
}
|
||||
if (register1 == 0x5555) {
|
||||
ESP_LOGD(TAG, "MacAlly Joystick in mouse mode detected, moving it to $3");
|
||||
adb_tx_listen(ADB_MACAJ|ADB_LISTEN|ADB_REG3, (ADB_MOUSE<<4)|ADB_H_MOVE);
|
||||
}
|
||||
}
|
||||
|
||||
void adb_task_host(void *pvParameters) {
|
||||
/* Classic Apple Mouse Protocol is 16 bits long */
|
||||
uint16_t data;
|
||||
|
@ -57,10 +57,13 @@ void adb_tx_reset(void);
|
||||
#define ADB_LISTEN 0x8
|
||||
#define ADB_FLUSH 0x1
|
||||
#define ADB_REG0 0x0
|
||||
#define ADB_REG1 0x1
|
||||
#define ADB_REG2 0x2
|
||||
#define ADB_REG3 0x3
|
||||
|
||||
/* Device addresses */
|
||||
#define ADB_MOUSE (3<<4) // main device
|
||||
#define ADB_MACAJ (5<<4) // lost MacAlly Joystick
|
||||
#define ADB_KML1 (8<<4) // disabled Kensington device
|
||||
#define ADB_TMP (9<<4) // temporary device
|
||||
|
||||
@ -72,6 +75,7 @@ void adb_tx_reset(void);
|
||||
#define ADB_H_ERR 0x00 // Handler 0 (Self init error)
|
||||
#define ADB_H_C100 0x01 // Handler 1 (Classic @ 100cpi)
|
||||
#define ADB_H_C200 0x02 // Handler 2 (Classic @ 200cpi)
|
||||
#define ADB_H_MACJ 0x03 // Handler for MacAlly Joystick
|
||||
#define ADB_H_MTRC 0x2f // Handler for MacTRAC 2.0
|
||||
#define ADB_H_KSGT 0x32 // Handler for Kensington devices
|
||||
#define ADB_H_MOVE 0xfe // Move to another address
|
||||
|
Loading…
Reference in New Issue
Block a user