Re: [cc65-devel] Keyboard and joystick reading problem
cc65 - a freeware C compiler for 6502 based systems
Brought to you by:
gpz
|
From: Marc 'B. R. <ma...@ri...> - 2016-06-16 23:30:31
|
On 16/06/16 06:46, Janne Peräaho wrote:
> I can read the keyboard with kbhit() and cgetc() functions but as soon
> as I call read_joy() function to read the joystick status, the keyboard
> reading part stops to work: I receive multiple key presses and wrong
> characters.
>
> The read_joy() function returns valid status information, except it
> doesn't register fire button.
Although the conflict of at least one joystick port with the keyboard
might be normal (as on a C64), there seems to be something wrong with
the driver for the plus4. The following program shows odd behaviour on
VICE's xplus4:
#include <stdint.h>
#include <conio.h>
#include <joystick.h>
#ifdef __PLUS4__
#define JOY_DRIVER (plus4_stdjoy_joy)
#endif
#ifdef __C64__
#define JOY_DRIVER (c64_stdjoy_joy)
#endif
extern void JOY_DRIVER[];
int main(void) {
uint8_t joystick_count;
uint8_t i, mask;
uint8_t joy_state;
if (joy_install(JOY_DRIVER) != JOY_ERR_OK) {
return 1;
}
joystick_count = joy_count();
clrscr();
for (;;) {
gotoxy(0, 0);
cprintf("key: ");
if (kbhit()) {
cprintf("%3u", cgetc());
}
cputs("\r\n");
for (i = 0; i < joystick_count; ++i) {
joy_state = joy_read(i);
cprintf("joy #%u: ", i + 1);
for (mask = 128; mask; mask >>= 1) {
cputc((joy_state & mask) ? '1' : '0');
}
cputs("\r\n");
}
}
}
It shows two joysticks but both react simultaneously with a joystick in
port #1 for the directions and not at all with a joystick in port #2.
Button presses on a joystick aren't recognized at all in both ports.
The same program compiled for C64 works fine on VICE's x64 and a real
bread box.
Ciao,
Marc 'BlackJack' Rintsch
--
Incorrect documentation is often worse than no documentation.
-- Bertrand Meyer
|