/* Copyright 1996 Acorn Computers Ltd * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /************************************************************************/ /* � Acorn Computers Ltd, 1992. */ /* */ /* This file forms part of an unsupported source release of RISC_OSLib. */ /* */ /* It may be freely used to create executable images for saleable */ /* products but cannot be sold in source form or as an object library */ /* without the prior written consent of Acorn Computers Ltd. */ /* */ /* If this file is re-distributed (even if modified) it should retain */ /* this copyright notice. */ /* */ /************************************************************************/ /* * Title: akbd.c * Purpose: Access to Archimedes keyboard under the Wimp. * History: IDJ: 05-Feb-92: prepared for source release */ #include "os.h" #include "trace.h" #include "akbd.h" /* see page 58 of Programmer's Reference Manual, OSBYTE &81 (129) */ #pragma -s1 int akbd_pollsh(void) { int x = -1; int y = 255; (void) os_byte(129, &x, &y); tracef2("PollSh returns %i %i\n", x, y); return(x==255 && y==255); } int akbd_pollctl(void) { int x = -2; int y = 255; (void) os_byte(129, &x, &y); tracef2("PollCtl returns %i %i\n", x, y); return(x==255 && y==255); } int akbd_pollkey(int *keycode /*out*/) { int x = 0; int y = 0; (void) os_byte(129, &x, &y); tracef2("PollKey returns %i %i.\n", x, y); if ((x + y) == 0) { /* it's a function key: 0, followed by the actual code. */ (void) os_byte(129, &x, &y); if (y==0 && x>=128) { /* bona fide function key */ *keycode = 256 + x; } else { /* he's typing ahead with a control-@: sorry boy, you lose the next key. */ *keycode = 0; } return(1); } else { *keycode = x; return(y==0); } } #pragma -s0 /* end */