reformatted
This commit is contained in:
@@ -1,2 +1,2 @@
|
|||||||
~/Dokumente/Development/workspace/BaS_gcc/include
|
include
|
||||||
/usr/m68k-elf/include
|
/usr/m68k-elf/include
|
||||||
|
|||||||
@@ -40,7 +40,8 @@ static unsigned char tx_queue[QUEUE_LEN];
|
|||||||
static unsigned char wptr = 0, rptr = 0;
|
static unsigned char wptr = 0, rptr = 0;
|
||||||
|
|
||||||
// structure to keep track of ikbd state
|
// structure to keep track of ikbd state
|
||||||
static struct {
|
static struct
|
||||||
|
{
|
||||||
unsigned char cmd;
|
unsigned char cmd;
|
||||||
unsigned char state;
|
unsigned char state;
|
||||||
unsigned char expect;
|
unsigned char expect;
|
||||||
@@ -55,14 +56,17 @@ static struct {
|
|||||||
|
|
||||||
// #define IKBD_DEBUG
|
// #define IKBD_DEBUG
|
||||||
|
|
||||||
void ikbd_init() {
|
void ikbd_init()
|
||||||
|
{
|
||||||
// reset ikbd state
|
// reset ikbd state
|
||||||
memset(&ikbd, 0, sizeof(ikbd));
|
memset(&ikbd, 0, sizeof(ikbd));
|
||||||
ikbd.state = IKBD_DEFAULT;
|
ikbd.state = IKBD_DEFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void enqueue(unsigned char b) {
|
static void enqueue(unsigned char b)
|
||||||
if(((wptr + 1)&(QUEUE_LEN-1)) == rptr) {
|
{
|
||||||
|
if (((wptr + 1)&(QUEUE_LEN-1)) == rptr)
|
||||||
|
{
|
||||||
xprintf("IKBD: !!!!!!! tx queue overflow !!!!!!!!!\n");
|
xprintf("IKBD: !!!!!!! tx queue overflow !!!!!!!!!\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -72,7 +76,8 @@ static void enqueue(unsigned char b) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// convert internal joystick format into atari ikbd format
|
// convert internal joystick format into atari ikbd format
|
||||||
static unsigned char joystick_map2ikbd(unsigned in) {
|
static unsigned char joystick_map2ikbd(unsigned in)
|
||||||
|
{
|
||||||
unsigned char out = 0;
|
unsigned char out = 0;
|
||||||
|
|
||||||
if (in & JOY_UP) out |= 0x01;
|
if (in & JOY_UP) out |= 0x01;
|
||||||
@@ -85,14 +90,18 @@ static unsigned char joystick_map2ikbd(unsigned in) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// process inout from atari core into ikbd
|
// process inout from atari core into ikbd
|
||||||
void ikbd_handle_input(unsigned char cmd) {
|
void ikbd_handle_input(unsigned char cmd)
|
||||||
|
{
|
||||||
// expecting a second byte for command
|
// expecting a second byte for command
|
||||||
if(ikbd.expect) {
|
if (ikbd.expect)
|
||||||
|
{
|
||||||
ikbd.expect--;
|
ikbd.expect--;
|
||||||
|
|
||||||
// last byte of command received
|
// last byte of command received
|
||||||
if(!ikbd.expect) {
|
if (!ikbd.expect)
|
||||||
switch(ikbd.cmd) {
|
{
|
||||||
|
switch(ikbd.cmd)
|
||||||
|
{
|
||||||
case 0x07: // set mouse button action
|
case 0x07: // set mouse button action
|
||||||
xprintf("IKBD: mouse button action = %x\n", cmd);
|
xprintf("IKBD: mouse button action = %x\n", cmd);
|
||||||
|
|
||||||
@@ -117,7 +126,8 @@ void ikbd_handle_input(unsigned char cmd) {
|
|||||||
|
|
||||||
ikbd.cmd = cmd;
|
ikbd.cmd = cmd;
|
||||||
|
|
||||||
switch(cmd) {
|
switch(cmd)
|
||||||
|
{
|
||||||
case 0x07:
|
case 0x07:
|
||||||
xprintf("IKBD: Set mouse button action");
|
xprintf("IKBD: Set mouse button action");
|
||||||
ikbd.expect = 1;
|
ikbd.expect = 1;
|
||||||
@@ -205,7 +215,8 @@ void ikbd_handle_input(unsigned char cmd) {
|
|||||||
|
|
||||||
void ikbd_poll(void) {
|
void ikbd_poll(void) {
|
||||||
static int mtimer = 0;
|
static int mtimer = 0;
|
||||||
if(CheckTimer(mtimer)) {
|
if (CheckTimer(mtimer))
|
||||||
|
{
|
||||||
mtimer = GetTimer(10);
|
mtimer = GetTimer(10);
|
||||||
|
|
||||||
// check for incoming ikbd data
|
// check for incoming ikbd data
|
||||||
@@ -230,25 +241,30 @@ void ikbd_poll(void) {
|
|||||||
rptr = (rptr + 1) & (QUEUE_LEN - 1);
|
rptr = (rptr + 1) & (QUEUE_LEN - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ikbd_joystick(unsigned char joystick, unsigned char map) {
|
void ikbd_joystick(unsigned char joystick, unsigned char map)
|
||||||
|
{
|
||||||
// todo: suppress events for joystick 0 as long as mouse
|
// todo: suppress events for joystick 0 as long as mouse
|
||||||
// is enabled?
|
// is enabled?
|
||||||
|
|
||||||
if(ikbd.state & IKBD_STATE_JOYSTICK_EVENT_REPORTING) {
|
if (ikbd.state & IKBD_STATE_JOYSTICK_EVENT_REPORTING)
|
||||||
|
{
|
||||||
#ifdef IKBD_DEBUG
|
#ifdef IKBD_DEBUG
|
||||||
xprintf("IKBD: joy %d %x\n", joystick, map);
|
xprintf("IKBD: joy %d %x\n", joystick, map);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// only report joystick data for joystick 0 if the mouse is disabled
|
// only report joystick data for joystick 0 if the mouse is disabled
|
||||||
if((ikbd.state & IKBD_STATE_MOUSE_DISABLED) || (joystick == 1)) {
|
if ((ikbd.state & IKBD_STATE_MOUSE_DISABLED) || (joystick == 1))
|
||||||
|
{
|
||||||
enqueue(0xfe + joystick);
|
enqueue(0xfe + joystick);
|
||||||
enqueue(joystick_map2ikbd(map));
|
enqueue(joystick_map2ikbd(map));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!(ikbd.state & IKBD_STATE_MOUSE_DISABLED)) {
|
if (!(ikbd.state & IKBD_STATE_MOUSE_DISABLED))
|
||||||
|
{
|
||||||
// the fire button also generates a mouse event if
|
// the fire button also generates a mouse event if
|
||||||
// mouse reporting is enabled
|
// mouse reporting is enabled
|
||||||
if((map & JOY_BTN1) != (ikbd.joystick[joystick] & JOY_BTN1)) {
|
if ((map & JOY_BTN1) != (ikbd.joystick[joystick] & JOY_BTN1))
|
||||||
|
{
|
||||||
// generate mouse event (ikbd_joystick_buttons is evaluated inside
|
// generate mouse event (ikbd_joystick_buttons is evaluated inside
|
||||||
// user_io_mouse)
|
// user_io_mouse)
|
||||||
ikbd.joystick[joystick] = map;
|
ikbd.joystick[joystick] = map;
|
||||||
@@ -265,14 +281,16 @@ void ikbd_joystick(unsigned char joystick, unsigned char map) {
|
|||||||
ikbd.joystick[joystick] = map;
|
ikbd.joystick[joystick] = map;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ikbd_keyboard(unsigned char code) {
|
void ikbd_keyboard(unsigned char code)
|
||||||
|
{
|
||||||
#ifdef IKBD_DEBUG
|
#ifdef IKBD_DEBUG
|
||||||
xprintf("IKBD: send keycode %x%s\n", code&0x7f, (code&0x80)?" BREAK":"");
|
xprintf("IKBD: send keycode %x%s\n", code&0x7f, (code&0x80)?" BREAK":"");
|
||||||
#endif
|
#endif
|
||||||
enqueue(code);
|
enqueue(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ikbd_mouse(uint8_t b, int8_t x, int8_t y) {
|
void ikbd_mouse(uint8_t b, int8_t x, int8_t y)
|
||||||
|
{
|
||||||
if (ikbd.state & IKBD_STATE_MOUSE_DISABLED)
|
if (ikbd.state & IKBD_STATE_MOUSE_DISABLED)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -283,9 +301,11 @@ void ikbd_mouse(uint8_t b, int8_t x, int8_t y) {
|
|||||||
|
|
||||||
static unsigned char b_old = 0;
|
static unsigned char b_old = 0;
|
||||||
// monitor state of two mouse buttons
|
// monitor state of two mouse buttons
|
||||||
if(b != b_old) {
|
if (b != b_old)
|
||||||
|
{
|
||||||
// check if mouse buttons are supposed to be treated like keys
|
// check if mouse buttons are supposed to be treated like keys
|
||||||
if(ikbd.state & IKBD_STATE_MOUSE_BUTTON_AS_KEY) {
|
if (ikbd.state & IKBD_STATE_MOUSE_BUTTON_AS_KEY)
|
||||||
|
{
|
||||||
// Mouse buttons act like keys (LEFT=0x74 & RIGHT=0x75)
|
// Mouse buttons act like keys (LEFT=0x74 & RIGHT=0x75)
|
||||||
|
|
||||||
// handle left mouse button
|
// handle left mouse button
|
||||||
@@ -297,15 +317,19 @@ void ikbd_mouse(uint8_t b, int8_t x, int8_t y) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
if(ikbd.state & IKBD_STATE_MOUSE_BUTTON_AS_KEY) {
|
if(ikbd.state & IKBD_STATE_MOUSE_BUTTON_AS_KEY)
|
||||||
|
{
|
||||||
b = 0;
|
b = 0;
|
||||||
// if mouse position is 0/0 quit here
|
// if mouse position is 0/0 quit here
|
||||||
if(!x && !y) return;
|
if(!x && !y) return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(ikbd.state & IKBD_STATE_MOUSE_ABSOLUTE) {
|
if (ikbd.state & IKBD_STATE_MOUSE_ABSOLUTE)
|
||||||
} else {
|
{
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
// atari has mouse button bits swapped
|
// atari has mouse button bits swapped
|
||||||
enqueue(0xf8|((b&1)?2:0)|((b&2)?1:0));
|
enqueue(0xf8|((b&1)?2:0)|((b&2)?1:0));
|
||||||
enqueue(x);
|
enqueue(x);
|
||||||
|
|||||||
Reference in New Issue
Block a user