TriOS-alt/zubehör/game boulderdash/sourcen/Bellatrix-Code/Keyboard.spin

1 line
55 KiB
Plaintext
Raw Normal View History

2010-11-26 23:58:06 +01:00
<EFBFBD><EFBFBD>''*************************************** ''* PS/2 Keyboard Driver v1.0.1 * ''* Author: Chip Gracey * ''* Copyright (c) 2004 Parallax, Inc. * ''* See end of file for terms of use. * ''*************************************** {-----------------REVISION HISTORY----------------- v1.0.1 - Updated 6/15/2006 to work with Propeller Tool 0.96} VAR long cog long par_tail 'key buffer tail read/write (19 contiguous longs) long par_head 'key buffer head read-only long par_present 'keyboard present read-only long par_states[8] 'key states (256 bits) read-only long par_keys[8] 'key buffer (16 words) read-only (also used to pass initial parameters) PUB start(dpin, cpin) : okay '' Start keyboard driver - starts a cog '' returns false if no cog available '' '' dpin = data signal on PS/2 jack '' cpin = clock signal on PS/2 jack '' '' use 100-ohm resistors between pins and jack '' use 10K-ohm resistors to pull jack-side signals to VDD '' connect jack-power to 5V, jack-gnd to VSS '' '' all lock-keys will be enabled, NumLock will be initially 'on', '' and auto-repeat will be set to 15cps with a delay of .5s okay := startx(dpin, cpin, %0_000_100, %01_01000) PUB startx(dpin, cpin, locks, auto) : okay '' Like start, but allows you to specify lock settings and auto-repeat '' '' locks = lock setup '' bit 6 disallows shift-alphas (case set soley by CapsLock) '' bits 5..3 disallow toggle of NumLock/CapsLock/ScrollLock state '' bits 2..0 specify initial state of NumLock/CapsLock/ScrollLock '' (eg. %0_001_100 = disallow ScrollLock, NumLock initially 'on') '' '' auto = auto-repeat setup '' bits 6..5 specify delay (0=.25s, 1=.5s, 2=.75s, 3=1s) '' bits 4..0 specify repeat rate (0=30cps..31=2cps) '' (eg %01_00000 = .5s delay, 30cps repeat) stop longmove(@par_keys, @dpin, 4) okay := cog := cognew(@entry, @par_tail) + 1 PUB stop ''