Some changes for the USB keyboard support.
- Added buffer for maximum 16 key events. - PS/2 keyboard now sets the changed indicators only. - Added support for the yellow status indicator in the win32 gui.
This commit is contained in:
parent
0660b7e313
commit
c644b826f5
@ -162,11 +162,12 @@ static char ipsText[20];
|
||||
#define SIZE_OF_SB_ELEMENT 40
|
||||
#define SIZE_OF_SB_MOUSE_MESSAGE 170
|
||||
#define SIZE_OF_SB_IPS_MESSAGE 90
|
||||
Bit32u SB_Led_Colors[3] = {0x0000FF00, 0x000040FF, 0x0000FFFF};
|
||||
Bit32s SB_Edges[BX_MAX_STATUSITEMS+BX_SB_MAX_TEXT_ELEMENTS+1];
|
||||
char SB_Text[BX_MAX_STATUSITEMS][10];
|
||||
unsigned SB_Text_Elements;
|
||||
bx_bool SB_Active[BX_MAX_STATUSITEMS];
|
||||
bx_bool SB_ActiveW[BX_MAX_STATUSITEMS];
|
||||
Bit8u SB_ActiveColor[BX_MAX_STATUSITEMS];
|
||||
|
||||
// Misc stuff
|
||||
static unsigned dimension_x, dimension_y, current_bpp;
|
||||
@ -204,7 +205,7 @@ sharedThreadInfo stInfo;
|
||||
LRESULT CALLBACK mainWndProc(HWND, UINT, WPARAM, LPARAM);
|
||||
LRESULT CALLBACK simWndProc(HWND, UINT, WPARAM, LPARAM);
|
||||
DWORD WINAPI UIThread(PVOID);
|
||||
void SetStatusText(unsigned Num, const char *Text, bx_bool active, bx_bool w=0);
|
||||
void SetStatusText(unsigned Num, const char *Text, bx_bool active, Bit8u color=0);
|
||||
void terminateEmul(int);
|
||||
void create_vga_font(void);
|
||||
void DrawBitmap(HDC, HBITMAP, int, int, int, int, int, int, Bit8u, Bit8u);
|
||||
@ -1046,7 +1047,7 @@ DWORD WINAPI UIThread(LPVOID)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void SetStatusText(unsigned Num, const char *Text, bx_bool active, bx_bool w)
|
||||
void SetStatusText(unsigned Num, const char *Text, bx_bool active, Bit8u color)
|
||||
{
|
||||
char StatText[MAX_PATH];
|
||||
|
||||
@ -1059,7 +1060,7 @@ void SetStatusText(unsigned Num, const char *Text, bx_bool active, bx_bool w)
|
||||
lstrcpy(StatText+1, Text);
|
||||
lstrcpy(SB_Text[Num-SB_Text_Elements], StatText);
|
||||
SB_Active[Num-SB_Text_Elements] = active;
|
||||
SB_ActiveW[Num-SB_Text_Elements] = w;
|
||||
SB_ActiveColor[Num-SB_Text_Elements] = color;
|
||||
SendMessage(hwndSB, SB_SETTEXT, Num | SBT_OWNERDRAW, (LPARAM)SB_Text[Num-SB_Text_Elements]);
|
||||
}
|
||||
UpdateWindow(hwndSB);
|
||||
@ -1067,7 +1068,11 @@ void SetStatusText(unsigned Num, const char *Text, bx_bool active, bx_bool w)
|
||||
|
||||
void bx_win32_gui_c::statusbar_setitem_specific(int element, bx_bool active, bx_bool w)
|
||||
{
|
||||
SetStatusText(element+SB_Text_Elements, statusitem[element].text, active, w);
|
||||
Bit8u color = 0;
|
||||
if (w) {
|
||||
color = statusitem[element].auto_off ? 1 : 2;
|
||||
}
|
||||
SetStatusText(element+SB_Text_Elements, statusitem[element].text, active, color);
|
||||
}
|
||||
|
||||
LRESULT CALLBACK mainWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
|
||||
@ -1139,10 +1144,7 @@ LRESULT CALLBACK mainWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
|
||||
if (lpdis->hwndItem == hwndSB) {
|
||||
sbtext = (char *)lpdis->itemData;
|
||||
if (SB_Active[lpdis->itemID-SB_Text_Elements]) {
|
||||
if (SB_ActiveW[lpdis->itemID-SB_Text_Elements])
|
||||
SetBkColor(lpdis->hDC, 0x000040FF);
|
||||
else
|
||||
SetBkColor(lpdis->hDC, 0x0000FF00);
|
||||
SetBkColor(lpdis->hDC, SB_Led_Colors[SB_ActiveColor[lpdis->itemID-SB_Text_Elements]]);
|
||||
} else {
|
||||
SetBkMode(lpdis->hDC, TRANSPARENT);
|
||||
SetTextColor(lpdis->hDC, 0x00808080);
|
||||
|
@ -981,7 +981,6 @@ void bx_keyb_c::mouse_enQ(Bit8u mouse_data)
|
||||
|
||||
void bx_keyb_c::kbd_ctrl_to_kbd(Bit8u value)
|
||||
{
|
||||
|
||||
BX_DEBUG(("controller passed byte %02xh to keyboard", value));
|
||||
|
||||
if (BX_KEY_THIS s.kbd_internal_buffer.expecting_typematic) {
|
||||
@ -1001,13 +1000,19 @@ void bx_keyb_c::kbd_ctrl_to_kbd(Bit8u value)
|
||||
}
|
||||
|
||||
if (BX_KEY_THIS s.kbd_internal_buffer.expecting_led_write) {
|
||||
BX_KEY_THIS s.kbd_internal_buffer.expecting_led_write = 0;
|
||||
Bit8u change = value ^ BX_KEY_THIS s.kbd_internal_buffer.led_status;
|
||||
BX_DEBUG(("LED status set to 0x%02x", value));
|
||||
if (change & 0x02) {
|
||||
DEV_kbd_set_indicator(0, BX_KBD_LED_NUM, value & 0x02);
|
||||
}
|
||||
if (change & 0x04) {
|
||||
DEV_kbd_set_indicator(0, BX_KBD_LED_CAPS, value & 0x04);
|
||||
}
|
||||
if (change & 0x01) {
|
||||
DEV_kbd_set_indicator(0, BX_KBD_LED_SCRL, value & 0x01);
|
||||
}
|
||||
BX_KEY_THIS s.kbd_internal_buffer.led_status = value;
|
||||
BX_DEBUG(("LED status set to %02x",
|
||||
(unsigned) BX_KEY_THIS s.kbd_internal_buffer.led_status));
|
||||
DEV_kbd_set_indicator(0, BX_KBD_LED_NUM, value & 0x02);
|
||||
DEV_kbd_set_indicator(0, BX_KBD_LED_CAPS, value & 0x04);
|
||||
DEV_kbd_set_indicator(0, BX_KBD_LED_SCRL, value & 0x01);
|
||||
BX_KEY_THIS s.kbd_internal_buffer.expecting_led_write = 0;
|
||||
kbd_enQ(0xFA); // send ACK %%%
|
||||
return;
|
||||
}
|
||||
|
@ -840,6 +840,13 @@ void usb_hid_device_c::register_state_specific(bx_list_c *parent)
|
||||
BXRS_PARAM_BOOL(list, has_events, s.has_events);
|
||||
if ((d.type == USB_DEV_TYPE_KEYPAD) || (d.type == USB_DEV_TYPE_KEYBOARD)) {
|
||||
new bx_shadow_data_c(list, "key_pad_packet", s.key_pad_packet, 8, 1);
|
||||
BXRS_PARAM_BOOL(list, kbd_count, s.kbd_count);
|
||||
bx_list_c *buffer = new bx_list_c(list, "kbd_buffer", "");
|
||||
char pname[16];
|
||||
for (Bit8u i = 0; i < 16; i++) {
|
||||
sprintf(pname, "%u", i);
|
||||
new bx_shadow_num_c(buffer, pname, &s.kbd_buffer[i], BASE_HEX);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1171,6 +1178,13 @@ int usb_hid_device_c::keyboard_poll(Bit8u *buf, int len, bx_bool force)
|
||||
memcpy(buf, s.key_pad_packet, len);
|
||||
l = 8;
|
||||
s.has_events = 0;
|
||||
if (s.kbd_count > 0) {
|
||||
gen_scancode(s.kbd_buffer[0]);
|
||||
s.kbd_count--;
|
||||
for (Bit8u i = 0; i < s.kbd_count; i++) {
|
||||
s.kbd_buffer[i] = s.kbd_buffer[i + 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return l;
|
||||
@ -1192,6 +1206,14 @@ bx_bool usb_hid_device_c::gen_scancode(Bit32u key)
|
||||
if ((code < 0x53) || (code > 0x63)) {
|
||||
return 0;
|
||||
}
|
||||
} else if (code == 0) {
|
||||
return 1;
|
||||
}
|
||||
if (s.has_events) {
|
||||
if (s.kbd_count < 16) {
|
||||
s.kbd_buffer[s.kbd_count++] = key;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
if (usbkbd_conv[key].modkey) {
|
||||
if (released) {
|
||||
@ -1200,17 +1222,14 @@ bx_bool usb_hid_device_c::gen_scancode(Bit32u key)
|
||||
s.key_pad_packet[0] |= code;
|
||||
}
|
||||
} else {
|
||||
// FIXME
|
||||
if (released) {
|
||||
if (code == s.key_pad_packet[2]) {
|
||||
s.key_pad_packet[2] = 0;
|
||||
s.has_events = 1;
|
||||
}
|
||||
} else {
|
||||
if (code != 0) {
|
||||
s.key_pad_packet[2] = code;
|
||||
s.has_events = 1;
|
||||
}
|
||||
s.key_pad_packet[2] = code;
|
||||
s.has_events = 1;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
|
@ -56,6 +56,8 @@ private:
|
||||
Bit8u idle;
|
||||
Bit8u indicators;
|
||||
bx_bool has_events;
|
||||
Bit8u kbd_count;
|
||||
Bit32u kbd_buffer[16];
|
||||
} s;
|
||||
|
||||
static bx_bool gen_scancode_static(void *dev, Bit32u key);
|
||||
|
Loading…
Reference in New Issue
Block a user