1997-11-26 09:28:50 +03:00
|
|
|
/* $NetBSD: adbsys.c,v 1.34 1997/11/26 06:28:51 scottr Exp $ */
|
1994-10-26 11:45:48 +03:00
|
|
|
|
1994-07-08 11:55:46 +04:00
|
|
|
/*-
|
1994-12-04 02:33:55 +03:00
|
|
|
* Copyright (C) 1994 Bradley A. Grantham
|
1994-07-08 11:55:46 +04:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
1994-12-04 02:33:55 +03:00
|
|
|
* This product includes software developed by Bradley A. Grantham.
|
|
|
|
* 4. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission.
|
1994-07-08 11:55:46 +04:00
|
|
|
*
|
1994-12-04 02:33:55 +03:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
1994-07-08 11:55:46 +04:00
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
1994-12-04 02:33:55 +03:00
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
1994-07-08 11:55:46 +04:00
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
1997-04-14 20:56:26 +04:00
|
|
|
#include "opt_mrg_adb.h"
|
|
|
|
|
1994-07-08 11:55:46 +04:00
|
|
|
#include <sys/param.h>
|
1996-05-05 10:15:56 +04:00
|
|
|
#include <sys/systm.h>
|
1996-06-21 10:10:56 +04:00
|
|
|
|
|
|
|
#include <machine/cpu.h>
|
1996-03-29 05:06:04 +03:00
|
|
|
#include <machine/viareg.h>
|
1995-04-21 06:47:35 +04:00
|
|
|
|
1997-08-12 02:53:26 +04:00
|
|
|
#include <mac68k/mac68k/macrom.h>
|
|
|
|
#include <mac68k/dev/adbvar.h>
|
1994-07-08 11:55:46 +04:00
|
|
|
|
1996-06-21 10:10:56 +04:00
|
|
|
extern struct mac68k_machine_S mac68k_machine;
|
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
/* from adb.c */
|
1997-01-13 10:01:23 +03:00
|
|
|
void adb_processevent __P((adb_event_t * event));
|
1994-07-08 11:55:46 +04:00
|
|
|
|
1997-01-13 10:01:23 +03:00
|
|
|
extern void adb_jadbproc __P((void));
|
1994-07-08 11:55:46 +04:00
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
void
|
|
|
|
adb_complete(buffer, data_area, adb_command)
|
|
|
|
caddr_t buffer;
|
|
|
|
caddr_t data_area;
|
|
|
|
int adb_command;
|
1994-07-08 11:55:46 +04:00
|
|
|
{
|
1995-04-21 06:47:35 +04:00
|
|
|
adb_event_t event;
|
|
|
|
ADBDataBlock adbdata;
|
|
|
|
int adbaddr;
|
|
|
|
int error;
|
1997-01-13 10:01:23 +03:00
|
|
|
#ifdef MRG_DEBUG
|
|
|
|
register int i;
|
1994-07-08 11:55:46 +04:00
|
|
|
|
1996-10-13 07:21:13 +04:00
|
|
|
printf("adb: transaction completion\n");
|
1994-12-04 02:33:55 +03:00
|
|
|
#endif
|
1994-07-08 11:55:46 +04:00
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
adbaddr = (adb_command & 0xf0) >> 4;
|
1994-12-04 02:33:55 +03:00
|
|
|
error = GetADBInfo(&adbdata, adbaddr);
|
1997-01-13 10:01:23 +03:00
|
|
|
#ifdef MRG_DEBUG
|
1996-10-13 07:21:13 +04:00
|
|
|
printf("adb: GetADBInfo returned %d\n", error);
|
1994-12-04 02:33:55 +03:00
|
|
|
#endif
|
1994-07-08 11:55:46 +04:00
|
|
|
|
1994-12-04 02:33:55 +03:00
|
|
|
event.addr = adbaddr;
|
|
|
|
event.hand_id = adbdata.devType;
|
|
|
|
event.def_addr = adbdata.origADBAddr;
|
1997-01-13 10:01:23 +03:00
|
|
|
event.byte_count = buffer[0];
|
|
|
|
memcpy(event.bytes, buffer + 1, event.byte_count);
|
|
|
|
|
|
|
|
#ifdef MRG_DEBUG
|
1996-10-13 07:21:13 +04:00
|
|
|
printf("adb: from %d at %d (org %d) %d:", event.addr,
|
1994-12-04 02:33:55 +03:00
|
|
|
event.hand_id, event.def_addr, buffer[0]);
|
1995-04-21 06:47:35 +04:00
|
|
|
for (i = 1; i <= buffer[0]; i++)
|
1996-10-13 07:21:13 +04:00
|
|
|
printf(" %x", buffer[i]);
|
|
|
|
printf("\n");
|
1994-12-04 02:33:55 +03:00
|
|
|
#endif
|
1994-07-08 11:55:46 +04:00
|
|
|
|
1994-12-04 02:33:55 +03:00
|
|
|
microtime(&event.timestamp);
|
1994-07-08 11:55:46 +04:00
|
|
|
|
1994-12-04 02:33:55 +03:00
|
|
|
adb_processevent(&event);
|
1994-07-08 11:55:46 +04:00
|
|
|
}
|
|
|
|
|
1997-06-16 10:35:26 +04:00
|
|
|
void
|
|
|
|
adb_msa3_complete(buffer, data_area, adb_command)
|
|
|
|
caddr_t buffer;
|
|
|
|
caddr_t data_area;
|
|
|
|
int adb_command;
|
|
|
|
{
|
|
|
|
adb_event_t event;
|
|
|
|
ADBDataBlock adbdata;
|
|
|
|
int adbaddr;
|
|
|
|
int error;
|
|
|
|
#ifdef MRG_DEBUG
|
|
|
|
register int i;
|
|
|
|
|
|
|
|
printf("adb: transaction completion\n");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
adbaddr = (adb_command & 0xf0) >> 4;
|
|
|
|
error = GetADBInfo(&adbdata, adbaddr);
|
|
|
|
#ifdef MRG_DEBUG
|
|
|
|
printf("adb: GetADBInfo returned %d\n", error);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
event.addr = adbaddr;
|
|
|
|
event.hand_id = ADBMS_MSA3;
|
|
|
|
event.def_addr = adbdata.origADBAddr;
|
|
|
|
event.byte_count = buffer[0];
|
|
|
|
memcpy(event.bytes, buffer + 1, event.byte_count);
|
|
|
|
|
|
|
|
#ifdef MRG_DEBUG
|
|
|
|
printf("adb: from %d at %d (org %d) %d:",
|
|
|
|
event.addr, event.hand_id, event.def_addr, buffer[0]);
|
|
|
|
for (i = 1; i <= buffer[0]; i++)
|
|
|
|
printf(" %x", buffer[i]);
|
|
|
|
printf("\n");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
microtime(&event.timestamp);
|
|
|
|
|
|
|
|
adb_processevent(&event);
|
|
|
|
}
|
|
|
|
|
1997-11-07 10:38:10 +03:00
|
|
|
void
|
|
|
|
adb_mm_nonemp_complete(buffer, data_area, adb_command)
|
|
|
|
caddr_t buffer;
|
|
|
|
caddr_t data_area;
|
|
|
|
int adb_command;
|
|
|
|
{
|
|
|
|
adb_event_t event;
|
|
|
|
ADBDataBlock adbdata;
|
|
|
|
int adbaddr;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
#ifdef MRG_DEBUG
|
|
|
|
register int i;
|
|
|
|
|
|
|
|
printf("adb: transaction completion\n");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
adbaddr = (adb_command & 0xf0) >> 4;
|
|
|
|
error = GetADBInfo(&adbdata, adbaddr);
|
|
|
|
#ifdef MRG_DEBUG
|
|
|
|
printf("adb: GetADBInfo returned %d\n", error);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
printf("adb: from %d at %d (org %d) %d:", event.addr,
|
|
|
|
event.hand_id, event.def_addr, buffer[0]);
|
|
|
|
for (i = 1; i <= buffer[0]; i++)
|
|
|
|
printf(" %x", buffer[i]);
|
|
|
|
printf("\n");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* massage the data to look like EMP data */
|
|
|
|
if ( (buffer[3] & 0x04) == 0x04 )
|
|
|
|
buffer[1]&=0x7f;
|
|
|
|
else
|
|
|
|
buffer[1]|=0x80;
|
|
|
|
if ( (buffer[3] & 0x02) == 0x02 )
|
|
|
|
buffer[2]&=0x7f;
|
|
|
|
else
|
|
|
|
buffer[2]|=0x80;
|
|
|
|
if ( (buffer[3] & 0x01) == 0x01 )
|
|
|
|
buffer[3]=0x00;
|
|
|
|
else
|
|
|
|
buffer[3]=0x80;
|
|
|
|
event.addr = adbaddr;
|
|
|
|
event.hand_id = adbdata.devType;
|
|
|
|
event.def_addr = adbdata.origADBAddr;
|
|
|
|
event.byte_count = buffer[0];
|
|
|
|
memcpy(event.bytes, buffer + 1, event.byte_count);
|
|
|
|
|
|
|
|
#ifdef MRG_DEBUG
|
|
|
|
printf("adb: from %d at %d (org %d) %d:", event.addr,
|
|
|
|
event.hand_id, event.def_addr, buffer[0]);
|
|
|
|
for (i = 1; i <= buffer[0]; i++)
|
|
|
|
printf(" %x", buffer[i]);
|
|
|
|
printf("\n");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
microtime(&event.timestamp);
|
|
|
|
|
|
|
|
adb_processevent(&event);
|
|
|
|
}
|
|
|
|
|
1997-01-13 10:01:23 +03:00
|
|
|
static volatile int extdms_done;
|
1995-09-04 00:59:53 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* initialize extended mouse - probes devices as
|
|
|
|
* described in _Inside Macintosh, Devices_.
|
|
|
|
*/
|
|
|
|
void
|
1997-01-13 10:01:23 +03:00
|
|
|
extdms_init(totaladbs)
|
|
|
|
int totaladbs;
|
1995-09-04 00:59:53 +04:00
|
|
|
{
|
|
|
|
ADBDataBlock adbdata;
|
|
|
|
int adbindex, adbaddr;
|
|
|
|
short cmd;
|
1997-11-07 10:38:10 +03:00
|
|
|
u_char buffer[9];
|
1995-09-04 00:59:53 +04:00
|
|
|
|
|
|
|
for (adbindex = 1; adbindex <= totaladbs; adbindex++) {
|
|
|
|
/* Get the ADB information */
|
|
|
|
adbaddr = GetIndADB(&adbdata, adbindex);
|
|
|
|
if (adbdata.origADBAddr == ADBADDR_MS &&
|
1996-05-05 18:33:55 +04:00
|
|
|
(adbdata.devType == ADBMS_USPEED)) {
|
|
|
|
/* Found MicroSpeed Mouse Deluxe Mac */
|
1996-05-08 17:36:41 +04:00
|
|
|
cmd = ((adbaddr<<4)&0xF0)|0x9; /* listen 1 */
|
1996-05-05 18:33:55 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* To setup the MicroSpeed, it appears that we can
|
|
|
|
* send the following command to the mouse and then
|
|
|
|
* expect data back in the form:
|
|
|
|
* buffer[0] = 4 (bytes)
|
|
|
|
* buffer[1], buffer[2] as std. mouse
|
|
|
|
* buffer[3] = buffer[4] = 0xff when no buttons
|
|
|
|
* are down. When button N down, bit N is clear.
|
1996-05-08 08:00:44 +04:00
|
|
|
* buffer[4]'s locking mask enables a
|
1996-05-05 18:33:55 +04:00
|
|
|
* click to toggle the button down state--sort of
|
|
|
|
* like the "Easy Access" shift/control/etc. keys.
|
1996-05-08 08:00:44 +04:00
|
|
|
* buffer[3]'s alternative speed mask enables using
|
|
|
|
* different speed when the corr. button is down
|
1996-05-05 18:33:55 +04:00
|
|
|
*/
|
|
|
|
buffer[0] = 4;
|
1996-05-08 08:00:44 +04:00
|
|
|
buffer[1] = 0x00; /* Alternative speed */
|
1996-05-05 18:33:55 +04:00
|
|
|
buffer[2] = 0x00; /* speed = maximum */
|
1996-05-08 08:00:44 +04:00
|
|
|
buffer[3] = 0x10; /* enable extended protocol,
|
|
|
|
* lower bits = alt. speed mask
|
|
|
|
* = 0000b
|
|
|
|
*/
|
1996-05-05 18:33:55 +04:00
|
|
|
buffer[4] = 0x07; /* Locking mask = 0000b,
|
1996-05-08 08:00:44 +04:00
|
|
|
* enable buttons = 0111b
|
|
|
|
*/
|
1996-05-05 18:33:55 +04:00
|
|
|
extdms_done = 0;
|
|
|
|
ADBOp((Ptr)buffer, (Ptr)extdms_complete,
|
|
|
|
(Ptr)&extdms_done, cmd);
|
|
|
|
while (!extdms_done)
|
|
|
|
/* busy wait until done */;
|
|
|
|
}
|
|
|
|
if (adbdata.origADBAddr == ADBADDR_MS &&
|
|
|
|
( adbdata.devType == ADBMS_100DPI
|
|
|
|
|| adbdata.devType == ADBMS_200DPI)) {
|
1995-09-04 00:59:53 +04:00
|
|
|
/* found a mouse */
|
|
|
|
cmd = ((adbaddr << 4) & 0xf0) | 0x3;
|
|
|
|
|
|
|
|
extdms_done = 0;
|
|
|
|
cmd = (cmd & 0xf3) | 0x0c; /* talk command */
|
|
|
|
ADBOp((Ptr)buffer, (Ptr)extdms_complete,
|
|
|
|
(Ptr)&extdms_done, cmd);
|
|
|
|
while (!extdms_done)
|
|
|
|
/* busy wait until done */;
|
|
|
|
|
1997-06-16 10:35:26 +04:00
|
|
|
/* Attempt to initialize Extended Mouse Protocol */
|
1995-09-04 00:59:53 +04:00
|
|
|
buffer[2] = '\004'; /* make handler ID 4 */
|
|
|
|
extdms_done = 0;
|
|
|
|
cmd = (cmd & 0xf3) | 0x08; /* listen command */
|
|
|
|
ADBOp((Ptr)buffer, (Ptr)extdms_complete,
|
|
|
|
(Ptr)&extdms_done, cmd);
|
|
|
|
while (!extdms_done)
|
|
|
|
/* busy wait until done */;
|
1997-06-16 10:35:26 +04:00
|
|
|
|
|
|
|
/* Check to see if successful, if not
|
|
|
|
* try to initialize it as other types */
|
|
|
|
cmd = ((adbaddr << 4) & 0xf0) | 0x3;
|
|
|
|
extdms_done = 0;
|
|
|
|
cmd = (cmd & 0xf3) | 0x0c; /* talk command */
|
|
|
|
ADBOp((Ptr)buffer, (Ptr)extdms_complete,
|
|
|
|
(Ptr)&extdms_done, cmd);
|
|
|
|
while (!extdms_done)
|
|
|
|
/* busy wait until done */;
|
|
|
|
|
|
|
|
if (buffer[2] != ADBMS_EXTENDED) {
|
|
|
|
/* Attempt to initialize as an A3 mouse */
|
|
|
|
buffer[2] = 0x03; /* make handler ID 3 */
|
|
|
|
extdms_done = 0;
|
|
|
|
cmd = (cmd & 0xf3) | 0x08; /* listen command */
|
|
|
|
ADBOp((Ptr)buffer, (Ptr)extdms_complete,
|
|
|
|
(Ptr)&extdms_done, cmd);
|
|
|
|
while (!extdms_done)
|
|
|
|
/* busy wait until done */;
|
|
|
|
|
|
|
|
/* Check to see if successful, if not
|
|
|
|
* try to initialize it as other types */
|
|
|
|
cmd = ((adbaddr << 4) & 0xf0) | 0x3;
|
|
|
|
extdms_done = 0;
|
|
|
|
cmd = (cmd & 0xf3) | 0x0c; /* talk command */
|
|
|
|
ADBOp((Ptr)buffer, (Ptr)extdms_complete,
|
|
|
|
(Ptr)&extdms_done, cmd);
|
|
|
|
while (!extdms_done)
|
|
|
|
/* busy wait until done */;
|
|
|
|
|
|
|
|
if (buffer[2] == ADBMS_MSA3) {
|
|
|
|
/* Initialize as above */
|
|
|
|
cmd = ((adbaddr << 4) & 0xF0) | 0xA;
|
|
|
|
/* listen 2 */
|
|
|
|
buffer[0] = 3;
|
|
|
|
buffer[1] = 0x00;
|
|
|
|
/* Irrelevant, buffer has 0x77 */
|
|
|
|
buffer[2] = 0x07;
|
|
|
|
/* enable 3 button mode = 0111b,
|
|
|
|
* speed = normal */
|
|
|
|
extdms_done = 0;
|
|
|
|
ADBOp((Ptr)buffer, (Ptr)extdms_complete,
|
|
|
|
(Ptr)&extdms_done, cmd);
|
|
|
|
while (!extdms_done)
|
|
|
|
/* busy wait until done */;
|
|
|
|
} else {
|
|
|
|
/* No special support for this mouse */
|
|
|
|
}
|
|
|
|
}
|
1995-09-04 00:59:53 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
void
|
|
|
|
adb_init()
|
1994-07-08 11:55:46 +04:00
|
|
|
{
|
1994-12-04 02:33:55 +03:00
|
|
|
ADBDataBlock adbdata;
|
|
|
|
ADBSetInfoBlock adbinfo;
|
1995-04-21 06:47:35 +04:00
|
|
|
int totaladbs;
|
|
|
|
int adbindex, adbaddr;
|
1997-11-07 10:38:10 +03:00
|
|
|
int error, cmd, devtype=0;
|
|
|
|
u_char buffer[9];
|
1997-11-26 09:28:50 +03:00
|
|
|
extern int adb_initted;
|
1994-07-08 11:55:46 +04:00
|
|
|
|
1997-11-07 10:38:10 +03:00
|
|
|
#ifdef MRG_ADB
|
|
|
|
/* Even if serial console only, some models require the
|
|
|
|
* ADB in order to get the date/time and do soft power. */
|
1996-06-21 10:10:56 +04:00
|
|
|
if ((mac68k_machine.serial_console & 0x03)) {
|
1996-10-13 07:21:13 +04:00
|
|
|
printf("adb: using serial console\n");
|
1996-06-21 10:10:56 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
if (!mrg_romready()) {
|
1996-10-13 07:21:13 +04:00
|
|
|
printf("adb: no ROM ADB driver in this kernel for this machine\n");
|
1994-12-04 02:33:55 +03:00
|
|
|
return;
|
|
|
|
}
|
1997-04-08 07:19:04 +04:00
|
|
|
|
1996-10-13 07:21:13 +04:00
|
|
|
printf("adb: bus subsystem\n");
|
1997-01-13 10:01:23 +03:00
|
|
|
#ifdef MRG_DEBUG
|
1996-10-13 07:21:13 +04:00
|
|
|
printf("adb: call mrg_initadbintr\n");
|
1994-12-04 02:33:55 +03:00
|
|
|
#endif
|
1994-07-08 11:55:46 +04:00
|
|
|
|
1994-12-04 02:33:55 +03:00
|
|
|
mrg_initadbintr(); /* Mac ROM Glue okay to do ROM intr */
|
1997-01-13 10:01:23 +03:00
|
|
|
#ifdef MRG_DEBUG
|
1996-10-13 07:21:13 +04:00
|
|
|
printf("adb: returned from mrg_initadbintr\n");
|
1994-12-04 02:33:55 +03:00
|
|
|
#endif
|
1994-07-08 11:55:46 +04:00
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
/* ADBReInit pre/post-processing */
|
1994-12-04 02:33:55 +03:00
|
|
|
JADBProc = adb_jadbproc;
|
1994-07-08 11:55:46 +04:00
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
/* Initialize ADB */
|
1997-01-13 10:01:23 +03:00
|
|
|
#ifdef MRG_DEBUG
|
1996-10-13 07:21:13 +04:00
|
|
|
printf("adb: calling ADBAlternateInit.\n");
|
1994-12-04 02:33:55 +03:00
|
|
|
#endif
|
1994-07-08 11:55:46 +04:00
|
|
|
|
1995-09-03 18:37:16 +04:00
|
|
|
ADBAlternateInit();
|
1997-04-08 07:19:04 +04:00
|
|
|
#else
|
|
|
|
ADBReInit();
|
|
|
|
#endif /* MRG_ADB */
|
1994-07-08 11:55:46 +04:00
|
|
|
|
1997-01-13 10:01:23 +03:00
|
|
|
#ifdef MRG_DEBUG
|
1996-10-13 07:21:13 +04:00
|
|
|
printf("adb: done with ADBReInit\n");
|
1994-12-04 02:33:55 +03:00
|
|
|
#endif
|
1994-07-08 11:55:46 +04:00
|
|
|
|
1994-12-04 02:33:55 +03:00
|
|
|
totaladbs = CountADBs();
|
1997-01-13 10:01:23 +03:00
|
|
|
extdms_init(totaladbs);
|
1995-04-21 06:47:35 +04:00
|
|
|
|
|
|
|
/* for each ADB device */
|
|
|
|
for (adbindex = 1; adbindex <= totaladbs; adbindex++) {
|
|
|
|
/* Get the ADB information */
|
1994-12-04 02:33:55 +03:00
|
|
|
adbaddr = GetIndADB(&adbdata, adbindex);
|
1994-07-08 11:55:46 +04:00
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
/* Print out the glory */
|
1996-10-13 07:21:13 +04:00
|
|
|
printf("adb: ");
|
1995-04-21 06:47:35 +04:00
|
|
|
switch (adbdata.origADBAddr) {
|
1997-08-10 00:21:45 +04:00
|
|
|
case ADBADDR_SECURE:
|
|
|
|
printf("security dongle (%d)", adbdata.devType);
|
|
|
|
break;
|
1996-05-05 18:33:55 +04:00
|
|
|
case ADBADDR_MAP:
|
1995-04-21 06:47:35 +04:00
|
|
|
switch (adbdata.devType) {
|
1996-05-05 18:33:55 +04:00
|
|
|
case ADB_STDKBD:
|
1997-08-08 21:58:48 +04:00
|
|
|
printf("standard keyboard");
|
1995-04-21 06:47:35 +04:00
|
|
|
break;
|
1997-11-05 11:21:47 +03:00
|
|
|
case ADB_ISOKBD:
|
|
|
|
printf("standard keyboard (ISO layout)");
|
|
|
|
break;
|
1997-11-07 10:38:10 +03:00
|
|
|
case ADB_EXTKBD:
|
|
|
|
extdms_done = 0;
|
|
|
|
cmd=(((adbaddr<<4) &0xf0) | 0x0d ); /* talk R1 */
|
|
|
|
ADBOp((Ptr)buffer, (Ptr)extdms_complete,
|
|
|
|
(Ptr)&extdms_done, cmd);
|
|
|
|
while (!extdms_done);
|
|
|
|
/* busy wait until done */
|
|
|
|
if (buffer[1]==0x9a && buffer[2]==0x20 )
|
|
|
|
printf("Mouseman (non-EMP) pseudo keyboard");
|
|
|
|
else
|
|
|
|
printf("extended keyboard");
|
|
|
|
break;
|
1997-08-08 21:58:48 +04:00
|
|
|
case ADB_EXTISOKBD:
|
|
|
|
printf("extended keyboard (ISO layout)");
|
|
|
|
break;
|
|
|
|
case ADB_KBDII:
|
|
|
|
printf("keyboard II");
|
|
|
|
break;
|
|
|
|
case ADB_ISOKBDII:
|
|
|
|
printf("keyboard II (ISO layout)");
|
|
|
|
break;
|
1996-05-05 18:33:55 +04:00
|
|
|
case ADB_PBKBD:
|
1996-10-13 07:21:13 +04:00
|
|
|
printf("PowerBook keyboard");
|
1995-04-21 06:47:35 +04:00
|
|
|
break;
|
1997-08-08 21:58:48 +04:00
|
|
|
case ADB_PBISOKBD:
|
|
|
|
printf("PowerBook keyboard (ISO layout)");
|
|
|
|
break;
|
|
|
|
case ADB_ADJKPD:
|
|
|
|
printf("adjustable keypad");
|
|
|
|
break;
|
|
|
|
case ADB_ADJKBD:
|
|
|
|
printf("adjustable keyboard");
|
|
|
|
break;
|
|
|
|
case ADB_ADJISOKBD:
|
|
|
|
printf("adjustable keyboard (ISO layout)");
|
|
|
|
break;
|
|
|
|
case ADB_ADJJAPKBD:
|
|
|
|
printf("adjustable keyboard (Japanese layout)");
|
|
|
|
break;
|
1997-08-10 00:21:45 +04:00
|
|
|
case ADB_PBEXTISOKBD:
|
|
|
|
printf("PowerBook extended keyboard (ISO layout)");
|
|
|
|
break;
|
|
|
|
case ADB_PBEXTJAPKBD:
|
|
|
|
printf("PowerBook extended keyboard (Japanese layout)");
|
1997-08-08 21:58:48 +04:00
|
|
|
break;
|
1997-08-10 00:21:45 +04:00
|
|
|
case ADB_PBEXTKBD:
|
|
|
|
printf("PowerBook extended keyboard");
|
|
|
|
break;
|
|
|
|
case ADB_DESIGNKBD:
|
|
|
|
printf("extended keyboard");
|
1997-08-08 21:58:48 +04:00
|
|
|
break;
|
1995-04-21 06:47:35 +04:00
|
|
|
default:
|
1996-10-13 07:21:13 +04:00
|
|
|
printf("mapped device (%d)",
|
1995-04-21 06:47:35 +04:00
|
|
|
adbdata.devType);
|
1994-07-08 11:55:46 +04:00
|
|
|
break;
|
1995-04-21 06:47:35 +04:00
|
|
|
}
|
|
|
|
break;
|
1996-05-05 18:33:55 +04:00
|
|
|
case ADBADDR_REL:
|
1995-09-04 00:59:53 +04:00
|
|
|
extdms_done = 0;
|
|
|
|
/* talk register 3 */
|
|
|
|
ADBOp((Ptr)buffer, (Ptr)extdms_complete,
|
|
|
|
(Ptr)&extdms_done, (adbaddr << 4) | 0xf);
|
|
|
|
while (!extdms_done)
|
|
|
|
/* busy-wait until done */;
|
1997-11-07 10:38:10 +03:00
|
|
|
devtype=buffer[2];
|
|
|
|
switch (devtype) {
|
1996-05-05 18:33:55 +04:00
|
|
|
case ADBMS_100DPI:
|
1996-10-13 07:21:13 +04:00
|
|
|
printf("100 dpi mouse");
|
1994-12-04 02:33:55 +03:00
|
|
|
break;
|
1996-05-05 18:33:55 +04:00
|
|
|
case ADBMS_200DPI:
|
1996-10-13 07:21:13 +04:00
|
|
|
printf("200 dpi mouse");
|
1994-12-04 02:33:55 +03:00
|
|
|
break;
|
1997-06-16 10:35:26 +04:00
|
|
|
case ADBMS_MSA3:
|
|
|
|
printf("Mouse Systems A3 mouse, default parameters");
|
|
|
|
break;
|
1996-05-05 18:33:55 +04:00
|
|
|
case ADBMS_USPEED:
|
1996-10-13 07:21:13 +04:00
|
|
|
printf("MicroSpeed mouse, default parameters");
|
1996-05-05 18:33:55 +04:00
|
|
|
break;
|
|
|
|
case ADBMS_EXTENDED:
|
1995-09-04 00:59:53 +04:00
|
|
|
extdms_done = 0;
|
|
|
|
/* talk register 1 */
|
|
|
|
ADBOp((Ptr)buffer, (Ptr)extdms_complete,
|
|
|
|
(Ptr)&extdms_done,
|
|
|
|
(adbaddr << 4) | 0xd);
|
|
|
|
while (!extdms_done)
|
|
|
|
/* busy-wait until done */;
|
1997-11-07 10:38:10 +03:00
|
|
|
if (buffer[1]==0x9a && buffer[2]==0x20 )
|
|
|
|
printf("Mouseman (non-EMP) mouse");
|
|
|
|
else {
|
|
|
|
printf("extended mouse "
|
|
|
|
"<%c%c%c%c> %d-button %d dpi ",
|
|
|
|
buffer[1], buffer[2],
|
|
|
|
buffer[3], buffer[4],
|
|
|
|
(int)buffer[8],
|
|
|
|
(int)*(short *)&buffer[5]);
|
|
|
|
if (buffer[7] == 1)
|
|
|
|
printf("mouse");
|
|
|
|
else if (buffer[7] == 2)
|
|
|
|
printf("trackball");
|
|
|
|
else
|
|
|
|
printf("unknown device");
|
|
|
|
}
|
1995-09-04 00:59:53 +04:00
|
|
|
break;
|
1994-12-04 02:33:55 +03:00
|
|
|
default:
|
1996-10-13 07:21:13 +04:00
|
|
|
printf("relative positioning device (mouse?) (%d)", adbdata.devType);
|
1994-12-04 02:33:55 +03:00
|
|
|
break;
|
1995-04-21 06:47:35 +04:00
|
|
|
}
|
|
|
|
break;
|
1996-05-05 18:33:55 +04:00
|
|
|
case ADBADDR_ABS:
|
1997-10-02 19:12:49 +04:00
|
|
|
switch (adbdata.devType) {
|
|
|
|
case ADB_ARTPAD:
|
|
|
|
printf("WACOM ArtPad II");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
printf("abs. pos. device (tablet?) (%d)",
|
|
|
|
adbdata.devType);
|
|
|
|
break;
|
|
|
|
}
|
1995-04-21 06:47:35 +04:00
|
|
|
break;
|
1997-08-10 00:21:45 +04:00
|
|
|
case ADBADDR_DATATX:
|
|
|
|
printf("data transfer device (modem?) (%d)",
|
1995-04-21 06:47:35 +04:00
|
|
|
adbdata.devType);
|
|
|
|
break;
|
1997-10-02 19:12:49 +04:00
|
|
|
case ADBADDR_MISC:
|
|
|
|
switch (adbdata.devType) {
|
|
|
|
case ADB_POWERKEY:
|
|
|
|
printf("Sophisticated Circuits PowerKey");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
printf("misc. device (remote control?) (%d)",
|
|
|
|
adbdata.devType);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
1997-08-10 00:21:45 +04:00
|
|
|
default:
|
|
|
|
printf("unknown type device, (def %d, handler %d)",
|
|
|
|
adbdata.origADBAddr, adbdata.devType);
|
|
|
|
break;
|
1994-07-08 11:55:46 +04:00
|
|
|
}
|
1996-10-13 07:21:13 +04:00
|
|
|
printf(" at %d\n", adbaddr);
|
1994-12-04 02:33:55 +03:00
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
/* Set completion routine to be MacBSD's */
|
1997-06-16 10:35:26 +04:00
|
|
|
if ((adbdata.origADBAddr == ADBADDR_REL) &&
|
|
|
|
(buffer[0] > 0) && (buffer[2] == ADBMS_MSA3)) {
|
|
|
|
/* Special device handler for the A3 mouse */
|
|
|
|
adbinfo.siServiceRtPtr = (Ptr)adb_msa3_asmcomplete;
|
1997-11-07 10:38:10 +03:00
|
|
|
} else if ( ( adbdata.origADBAddr == ADBADDR_MAP ) &&
|
|
|
|
( adbdata.devType == ADB_EXTKBD ) &&
|
|
|
|
( buffer[1] == 0x9a ) && ( buffer[2]==0x20 ) ) {
|
|
|
|
/* ignore non-EMP Mouseman pseudo keyboard */
|
|
|
|
adbinfo.siServiceRtPtr = (Ptr)0;
|
|
|
|
} else if ( ( adbdata.origADBAddr == ADBADDR_REL ) &&
|
|
|
|
( devtype == ADBMS_EXTENDED ) &&
|
|
|
|
( buffer[1] == 0x9a ) && ( buffer[2]==0x20 ) ) {
|
|
|
|
/* Set up non-EMP Mouseman to put button
|
|
|
|
* bits in 3rd byte instead of sending via
|
|
|
|
* pseudo keyboard device. */
|
|
|
|
extdms_done = 0;
|
|
|
|
/* listen register 1 */
|
|
|
|
buffer[0]=2;
|
|
|
|
buffer[1]=0x00;
|
|
|
|
buffer[2]=0x81;
|
|
|
|
ADBOp((Ptr)buffer, (Ptr)extdms_complete,
|
|
|
|
(Ptr)&extdms_done, (adbaddr << 4) | 0x9);
|
|
|
|
while (!extdms_done)
|
|
|
|
/* busy-wait until done */;
|
|
|
|
extdms_done = 0;
|
|
|
|
/* listen register 1 */
|
|
|
|
buffer[0]=2;
|
|
|
|
buffer[1]=0x01;
|
|
|
|
buffer[2]=0x81;
|
|
|
|
ADBOp((Ptr)buffer, (Ptr)extdms_complete,
|
|
|
|
(Ptr)&extdms_done, (adbaddr << 4) | 0x9);
|
|
|
|
while (!extdms_done)
|
|
|
|
/* busy-wait until done */;
|
|
|
|
extdms_done = 0;
|
|
|
|
/* listen register 1 */
|
|
|
|
buffer[0]=2;
|
|
|
|
buffer[1]=0x02;
|
|
|
|
buffer[2]=0x81;
|
|
|
|
ADBOp((Ptr)buffer, (Ptr)extdms_complete,
|
|
|
|
(Ptr)&extdms_done, (adbaddr << 4) | 0x9);
|
|
|
|
while (!extdms_done)
|
|
|
|
/* busy-wait until done */;
|
|
|
|
extdms_done = 0;
|
|
|
|
/* listen register 1 */
|
|
|
|
buffer[0]=2;
|
|
|
|
buffer[1]=0x03;
|
|
|
|
buffer[2]=0x38;
|
|
|
|
ADBOp((Ptr)buffer, (Ptr)extdms_complete,
|
|
|
|
(Ptr)&extdms_done, (adbaddr << 4) | 0x9);
|
|
|
|
while (!extdms_done)
|
|
|
|
/* busy-wait until done */;
|
|
|
|
/* non-EMP Mouseman has special handler */
|
|
|
|
adbinfo.siServiceRtPtr = (Ptr)adb_mm_nonemp_asmcomplete;
|
1997-06-16 10:35:26 +04:00
|
|
|
} else {
|
|
|
|
/* Default completion routine */
|
|
|
|
adbinfo.siServiceRtPtr = (Ptr)adb_asmcomplete;
|
|
|
|
}
|
1994-12-04 02:33:55 +03:00
|
|
|
adbinfo.siDataAreaAddr = NULL;
|
|
|
|
error = SetADBInfo(&adbinfo, adbaddr);
|
1997-01-13 10:01:23 +03:00
|
|
|
#ifdef MRG_DEBUG
|
1996-10-13 07:21:13 +04:00
|
|
|
printf("returned %d from SetADBInfo\n", error);
|
1994-07-08 11:55:46 +04:00
|
|
|
#endif
|
|
|
|
}
|
1997-11-26 09:28:50 +03:00
|
|
|
|
|
|
|
adb_initted = 1;
|
1994-07-08 11:55:46 +04:00
|
|
|
}
|