Re: [cc65] Question on 1351 mouse

From: Groepaz <groepaz1gmx.net>
Date: 2010-01-31 07:41:03
On Samstag 30 Januar 2010, you wrote:
> So if I press the left mouse button then "as a side effect" the key
> code 160 is detected by cgetc(). If I on the other hand press
> Shift-Space then "as a side effect" a left mouse button press is
> detected by the mouse driver. Is this the expected behaviour?

it is. on the CIA the keyboard, the joysticks and the mouse are all connected 
to the same i/o port, and thus interfere with each other.

> Does that mean that a program that allows the user to enter text (thus
> reaction on "all" keys) needs to filter out the key 160 to avoid
> garbage entered by mouse button presses? Or do I miss some point
> completely?

yes...no.... :) there are several approaches to solve this, often combined for 
maximum compatibility:

- custom keyboard scanner, which scanns the matrix "both ways", ie once from 
port a to port b, then the other way around. this allows to detect "phantom 
keys", and the mouse button would be one of them.
- if using the kernal keyboard scanner, work around the problem by removing 
the phantom keypresses from the keyboard buffer everytime the mouse driver 
detects a button press
- work around it by not allowing both keyboard and mouse usage at the same 
time. (this is what most programs do regarding joystick and keyboard)

for cc65.... writing a custom keyboard scanner is no option i guess. my 
suggestion would be like this:

- rework the interrupt handler and make it so the kernal keyboard scanner gets 
called first, before any other "user" handlers (ie, the mouse driver). (this 
practically means calling the respective kernal routine manually, and end the 
irq in jmp ea81 instead ea81. or sth :))
- now in the mouse driver, check the button and if pressed, set $c5 (number of 
keys in keyboard buffer) to 0.

(alternative: call mouse driver in irq first, and then at the end of irq, if 
button was pressed, simply skip the keyboard scanner by jumping to ea81 
instead of ea31.)

-- 

http://www.hitmen-console.org    http://magicdisk.untergrund.net
http://www.pokefinder.org        http://ftp.pokefinder.org

She was so wild that when she made French toast she got her tongue caught in 
the toaster. 
<Rodney Dangerfield>

----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Sun Jan 31 07:40:57 2010

This archive was generated by hypermail 2.1.8 : 2010-01-31 07:41:00 CET