1
0
mirror of https://github.com/mist-devel/mist-firmware.git synced 2026-01-11 23:43:04 +00:00

Small ikbd cleanups

This commit is contained in:
harbaum 2013-09-11 08:11:09 +00:00
parent 9fa72e77a7
commit b520e08957
8 changed files with 53 additions and 48 deletions

View File

@ -32,8 +32,9 @@
#define tos_debugf(...) #define tos_debugf(...)
#endif #endif
#if 0 #if 1
// ikbd debug output in red // ikbd debug output in red
#define IKBD_DEBUG
#define ikbd_debugf(a, ...) iprintf("\033[1;31mIKBD: " a "\033[0m\n", ##__VA_ARGS__) #define ikbd_debugf(a, ...) iprintf("\033[1;31mIKBD: " a "\033[0m\n", ##__VA_ARGS__)
#else #else
#define ikbd_debugf(...) #define ikbd_debugf(...)

41
ikbd.c
View File

@ -59,9 +59,9 @@ static struct {
unsigned char mouse_abs_scale_x, mouse_abs_scale_y; unsigned char mouse_abs_scale_x, mouse_abs_scale_y;
unsigned char mouse_abs_buttons; unsigned char mouse_abs_buttons;
unsigned short mouse_pos_x, mouse_pos_y; unsigned short mouse_pos_x, mouse_pos_y;
} ikbd;
// #define IKBD_DEBUG unsigned int tx_cnt; // tx byte counter for debugging
} ikbd;
void ikbd_init() { void ikbd_init() {
// reset ikbd state // reset ikbd state
@ -80,11 +80,14 @@ void ikbd_init() {
ikbd.date_buffer[5] = 0; ikbd.date_buffer[5] = 0;
} }
void ikbd_reset(void) {
ikbd.tx_cnt = 0;
ikbd.state |= IKBD_STATE_WAIT4RESET;
}
static void enqueue(unsigned short b) { static void enqueue(unsigned short b) {
if(((wptr + 1)&(QUEUE_LEN-1)) == rptr) { if(((wptr + 1)&(QUEUE_LEN-1)) == rptr)
// ikbd_debugf("!!!!!!! tx queue overflow !!!!!!!!!");
return; return;
}
tx_queue[wptr] = b; tx_queue[wptr] = b;
wptr = (wptr+1)&(QUEUE_LEN-1); wptr = (wptr+1)&(QUEUE_LEN-1);
@ -307,11 +310,14 @@ void ikbd_handle_input(unsigned char cmd) {
void ikbd_poll(void) { void ikbd_poll(void) {
#ifdef IKBD_DEBUG #ifdef IKBD_DEBUG
static int sent = 0;
static unsigned long xtimer = 0; static unsigned long xtimer = 0;
static int last_cnt = 0;
if(CheckTimer(xtimer)) { if(CheckTimer(xtimer)) {
xtimer = GetTimer(2000); xtimer = GetTimer(2000);
ikbd_debugf("sent %d", sent); if(ikbd.tx_cnt != last_cnt) {
ikbd_debugf("sent bytes: %d", ikbd.tx_cnt);
last_cnt = ikbd.tx_cnt;
}
} }
#endif #endif
@ -365,12 +371,11 @@ void ikbd_poll(void) {
SPI(UIO_IKBD_OUT); SPI(UIO_IKBD_OUT);
SPI(tx_queue[rptr]); SPI(tx_queue[rptr]);
DisableIO(); DisableIO();
ikbd.tx_cnt++;
} }
rptr = (rptr+1)&(QUEUE_LEN-1); rptr = (rptr+1)&(QUEUE_LEN-1);
#ifdef IKBD_DEBUG
sent++;
#endif
} }
void ikbd_joystick(unsigned char joystick, unsigned char map) { void ikbd_joystick(unsigned char joystick, unsigned char map) {
@ -378,9 +383,6 @@ void ikbd_joystick(unsigned char joystick, unsigned char map) {
// is enabled? // is enabled?
if(ikbd.state & IKBD_STATE_JOYSTICK_EVENT_REPORTING) { if(ikbd.state & IKBD_STATE_JOYSTICK_EVENT_REPORTING) {
#ifdef IKBD_DEBUG
ikbd_debugf("joy %d %x", joystick, map);
#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)) {
@ -401,10 +403,6 @@ void ikbd_joystick(unsigned char joystick, unsigned char map) {
} }
} }
} }
#ifdef IKBD_DEBUG
else
ikbd_debugf("no monitor, drop joy %d %x", joystick, map);
#endif
// save state of joystick for interrogation mode // save state of joystick for interrogation mode
ikbd.joystick[joystick] = map; ikbd.joystick[joystick] = map;
@ -462,7 +460,7 @@ void ikbd_mouse(unsigned char b, char x, char y) {
x /= ikbd.mouse_abs_scale_x; x /= ikbd.mouse_abs_scale_x;
y /= ikbd.mouse_abs_scale_y; y /= ikbd.mouse_abs_scale_y;
// ikbd_debugf("abs inc %d %d -> ", x, y); // ikbd_debugf("abs inc %d %d -> ", x, y);
if(x < 0) { if(x < 0) {
x = -x; x = -x;
@ -500,12 +498,13 @@ void ikbd_mouse(unsigned char b, char x, char y) {
// advance the ikbd time by one second // advance the ikbd time by one second
void ikbd_update_time(void) { void ikbd_update_time(void) {
static const char mdays[] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; static const char mdays[] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
short year = 1900 + ikbd.date_buffer[0]; short year = 1900 + ikbd.date_buffer[0];
char is_leap = (!(year % 4) && (year % 100)) || !(year % 400); char is_leap = (!(year % 4) && (year % 100)) || !(year % 400);
ikbd_debugf("time update %u:%02u:%02u %u.%u.%u", // ikbd_debugf("time update %u:%02u:%02u %u.%u.%u",
ikbd.date_buffer[3], ikbd.date_buffer[4], ikbd.date_buffer[5], // ikbd.date_buffer[3], ikbd.date_buffer[4], ikbd.date_buffer[5],
ikbd.date_buffer[2], ikbd.date_buffer[1], year); // ikbd.date_buffer[2], ikbd.date_buffer[1], year);
// advance seconds // advance seconds
ikbd.date_buffer[5]++; ikbd.date_buffer[5]++;

1
ikbd.h
View File

@ -3,6 +3,7 @@
void ikbd_init(void); void ikbd_init(void);
void ikbd_poll(void); void ikbd_poll(void);
void ikbd_reset(void);
void ikbd_joystick(unsigned char joy, unsigned char map); void ikbd_joystick(unsigned char joy, unsigned char map);
void ikbd_mouse(unsigned char buttons, char x, char y); void ikbd_mouse(unsigned char buttons, char x, char y);
void ikbd_keyboard(unsigned char code); void ikbd_keyboard(unsigned char code);

View File

@ -188,11 +188,11 @@ const unsigned short usb2atari[] = {
0x09, // 25: 8 0x09, // 25: 8
0x0a, // 26: 9 0x0a, // 26: 9
0x0b, // 27: 0 0x0b, // 27: 0
0x1c | OSD_LOC, // 28: Return 0x1c, // 28: Return
0x01 | OSD_LOC, // 29: Escape 0x01, // 29: Escape
0x0e | OSD_LOC, // 2a: Backspace 0x0e, // 2a: Backspace
0x0f, // 2b: Tab 0x0f, // 2b: Tab
0x39 | OSD_LOC, // 2c: Space 0x39, // 2c: Space
0x0c, // 2d: - 0x0c, // 2d: -
0x0d, // 2e: = 0x0d, // 2e: =
0x1a, // 2f: [ 0x1a, // 2f: [
@ -222,15 +222,15 @@ const unsigned short usb2atari[] = {
NUM_LOCK_TOGGLE, // 47: Scroll Lock NUM_LOCK_TOGGLE, // 47: Scroll Lock
MISS, // 48: Pause MISS, // 48: Pause
0x52, // 49: Insert 0x52, // 49: Insert
0x47 | OSD_LOC, // 4a: Home 0x47, // 4a: Home
0x62 | OSD_LOC, // 4b: Page Up 0x62, // 4b: Page Up
0x53, // 4c: Delete 0x53, // 4c: Delete
MISS, // 4d: End MISS, // 4d: End
0x61 | OSD_LOC, // 4e: Page Down 0x61, // 4e: Page Down
0x4d, // 4f: Right Arrow 0x4d, // 4f: Right Arrow
0x4b, // 50: Left Arrow 0x4b, // 50: Left Arrow
0x50 | OSD_LOC, // 51: Down Arrow 0x50, // 51: Down Arrow
0x48 | OSD_LOC, // 52: Up Arrow 0x48, // 52: Up Arrow
NUM_LOCK_TOGGLE, // 53: Num Lock NUM_LOCK_TOGGLE, // 53: Num Lock
0x65, // 54: KP / 0x65, // 54: KP /
0x66, // 55: KP * 0x66, // 55: KP *

11
menu.c
View File

@ -189,10 +189,16 @@ void HandleUI(void)
} }
} }
break; break;
case KEY_MENU : case KEY_MENU:
menu = true; menu = true;
break; break;
case KEY_ESC :
// Within the menu the esc key acts as the menu key. problem:
// if the menu is left with a press of ESC, then the follwing
// break code for the ESC key when the key is released will
// reach the core which never saw the make code. Simple solution:
// react on break code instead of make code
case KEY_ESC | KEY_UPSTROKE :
if (menustate != MENU_NONE2) if (menustate != MENU_NONE2)
menu = true; menu = true;
break; break;
@ -2629,7 +2635,6 @@ void ErrorMessage(const char *message, unsigned char code) {
void InfoMessage(char *message) void InfoMessage(char *message)
{ {
OsdWaitVBL();
if (menustate != MENU_INFO) if (menustate != MENU_INFO)
{ {
// OsdClear(); // OsdClear();

12
osd.c
View File

@ -636,18 +636,6 @@ void OsdClear(void)
DisableOsd(); DisableOsd();
} }
void OsdWaitVBL(void)
{
// unsigned long pioa_old = 0;
// unsigned long pioa = 0;
//
// while ((~pioa ^ pioa_old) & INIT_B)
// {
// pioa_old = pioa;
// pioa = *AT91C_PIOA_PDSR;
// }
}
// enable displaying of OSD // enable displaying of OSD
void OsdEnable(unsigned char mode) void OsdEnable(unsigned char mode)
{ {

4
tos.c
View File

@ -626,6 +626,8 @@ void tos_upload(char *name) {
tos_write("Booting ... "); tos_write("Booting ... ");
ikbd_reset();
// let cpu run (release reset) // let cpu run (release reset)
config.system_ctrl &= ~TOS_CONTROL_CPU_RESET; config.system_ctrl &= ~TOS_CONTROL_CPU_RESET;
mist_set_control(config.system_ctrl); mist_set_control(config.system_ctrl);
@ -814,6 +816,8 @@ void tos_eject_all() {
} }
void tos_reset(char cold) { void tos_reset(char cold) {
ikbd_reset();
tos_update_sysctrl(config.system_ctrl | TOS_CONTROL_CPU_RESET); // set reset tos_update_sysctrl(config.system_ctrl | TOS_CONTROL_CPU_RESET); // set reset
if(cold) { if(cold) {

View File

@ -348,9 +348,16 @@ void user_io_osd_key_enable(char on) {
} }
static char key_used_by_osd(unsigned short s) { static char key_used_by_osd(unsigned short s) {
if((s & OSD_LOC) && !(s & 0xff)) return true; // this key is only used in OSD and has no keycode // this key is only used in OSD and has no keycode
if((s & OSD_LOC) && !(s & 0xff)) return true;
// no keys are suppressed if the OSD is inactive
if(!osd_eats_keys) return false; if(!osd_eats_keys) return false;
return ((s & OSD_LOC) != 0);
// in atari mode eat all keys if the OSD is online,
// else none as it's up to the core to forward keys
// to the OSD
return (core_type == CORE_TYPE_MIST);
} }
void user_io_kbd(unsigned char m, unsigned char *k) { void user_io_kbd(unsigned char m, unsigned char *k) {