[comp.sys.mac.programmer] Extended Keyboard lights

nf0i+@andrew.cmu.edu (Norman William Franke, III) (03/28/89)

I am trying to write a program to turn on the "num lock" & "scroll lock"
lights on the ADB Extended keyboard. So I'm guessing they are stored somewhere
in the registers.  I wrote this little program in LightSpeed Pascal to try to
read register 3 (device id). But it seems to crash the system sometimes and I
have no idea why.  Can someone please tell me what I'm doing wrong? And what
bits Apple stores the data for the lights in what register?  Thanks a lot.

program ADB;
 uses
  OSIntf;

 const
  addr = 2;

 var
  err, rootCommand, command: integer;
  info: ADBDataBlock;
  datastr, buffer: str255;

 procedure nothing;
 begin
 end;

begin
 err := GetADBInfo(info, addr);
 datastr := '..';
 buffer := '..';
 rootCommand := addr * 16 + 12;
 command := rootCommand + 3;
 with info do
  err := ADBOp(@datastr, @nothing, @buffer, command);
 writeln(ord(buffer[1]), ord(buffer[2]));
end.


Norman Franke
nf0i+@andrew.cmu.edu

MAC.ROMOS@applelink.apple.com (Eric Ulevik) (03/28/89)

In article <4Y=dhMy00WB_0A11Bk@andrew.cmu.edu> nf0i+@andrew.cmu.edu 
(Norman William Franke, III) writes:
> I am trying to write a program to turn on the "num lock" & "scroll lock"
> lights on the ADB Extended keyboard.

The bits to turn the lights on and off are the low 3 bits of 
register 2. You should 'talk r2' to get the value of register 2, change 
the low 3 bits to what you desire, and finally 'listen r2' to set the 
value of register 2.

>  procedure nothing;
>  begin
>  end;
> 
> begin
>  [...]
>   err := ADBOp(@datastr, @nothing, @buffer, command);
>  writeln(ord(buffer[1]), ord(buffer[2]));
> end.

ADB will call 'nothing' when the command completes. This may happen after 
ADBOp() returns. In your case, it may happen after the program has 
completed - when the procedure is no longer there. You should pass 'nil' 
as a completion routine pointer if you want nothing to happen.

This information is in Macintosh Technical Note #206.

Eric Ulevik
email: MAC.ROMOS@applelink.apple.com
-- These writings are mine, not Apple's. That's the way I like it. --

stores@unix.SRI.COM (Matt Mora) (03/29/89)

In article <4Y=dhMy00WB_0A11Bk@andrew.cmu.edu> nf0i+@andrew.cmu.edu (Norman William Franke, III) writes:
>I am trying to write a program to turn on the "num lock" & "scroll lock"
>lights on the ADB Extended keyboard. So I'm guessing they are stored somewhere
>Norman Franke
>nf0i+@andrew.cmu.edu

In The March Issue of MACTutor Dave Kelly & Dave Smith wrote
anArticle on how to make the adb led's blink.
its a good article. I would post the procedures
 but i think they are copyrighted.


-- 
___________________________________________________________
Matthew Mora
SRI International                            stores@SRI.COM
___________________________________________________________