Some USB keyboard related changes.

- Added HID code for the menu key.
- Added support for the yellow status indicator in the rfb and vncsrv guis.
- Cleaned up status indicator code in SDL, SDL2 and X guis.
This commit is contained in:
Volker Ruppert 2020-12-16 12:24:35 +00:00
parent e6822c81a1
commit 0660b7e313
6 changed files with 44 additions and 51 deletions

View File

@ -148,9 +148,8 @@ static struct _rfbUpdateRegion {
#define BX_RFB_DEF_XDIM 720
#define BX_RFB_DEF_YDIM 480
static unsigned char status_led_green = 0x38;
static Bit8u status_leds[3] = {0x38, 0x07, 0x3f};
static unsigned char status_gray_text = 0xa4;
static unsigned char status_led_red = 0x07;
const unsigned char headerbar_bg = 0xff;
const unsigned char headerbar_fg = 0x00;
@ -193,7 +192,7 @@ void UpdateScreen(unsigned char *newBits, int x, int y, int width, int height,
void SendUpdate(int x, int y, int width, int height, Bit32u encoding);
void rfbSetUpdateRegion(unsigned x0, unsigned y0, unsigned w, unsigned h);
void rfbAddUpdateRegion(unsigned x0, unsigned y0, unsigned w, unsigned h);
void rfbSetStatusText(int element, const char *text, bx_bool active, bx_bool w = 0);
void rfbSetStatusText(int element, const char *text, bx_bool active, Bit8u color = 0);
static Bit32u convertStringToRfbKey(const char *string);
#if BX_SHOW_IPS && defined(WIN32)
DWORD WINAPI rfbShowIPSthread(LPVOID);
@ -642,7 +641,11 @@ void bx_rfb_gui_c::get_capabilities(Bit16u *xres, Bit16u *yres, Bit16u *bpp)
void bx_rfb_gui_c::statusbar_setitem_specific(int element, bx_bool active, bx_bool w)
{
rfbSetStatusText(element+1, statusitem[element].text, active, w);
Bit8u color = 0;
if (w) {
color = statusitem[element].auto_off ? 1 : 2;
}
rfbSetStatusText(element+1, statusitem[element].text, active, color);
}
void bx_rfb_gui_c::set_mouse_mode_absxy(bx_bool mode)
@ -1293,9 +1296,10 @@ void HandleRfbClient(SOCKET sClient)
rfbBGR233Format = 1;
if (PF_EQ(spf.pixelFormat, RGB332Format)) {
rfbBGR233Format = 0;
status_led_green = 0x1c;
status_leds[0] = 0x1c;
status_leds[1] = 0xe0;
status_leds[2] = 0xfc;
status_gray_text = 0x92;
status_led_red = 0xe0;
} else if (!PF_EQ(spf.pixelFormat, BGR233Format)) {
BX_ERROR(("client has wrong pixel format (%d %d %d %d %d %d %d %d %d %d)",
spf.pixelFormat.bitsPerPixel,spf.pixelFormat.depth,spf.pixelFormat.bigEndianFlag,
@ -1648,7 +1652,7 @@ void rfbAddUpdateRegion(unsigned x0, unsigned y0, unsigned w, unsigned h)
}
}
void rfbSetStatusText(int element, const char *text, bx_bool active, bx_bool w)
void rfbSetStatusText(int element, const char *text, bx_bool active, Bit8u color)
{
char *newBits;
unsigned xleft, xsize, i, len;
@ -1662,10 +1666,10 @@ void rfbSetStatusText(int element, const char *text, bx_bool active, bx_bool w)
newBits[((xsize / 8) + 1) * i] = 0;
}
unsigned char fgcolor = active ? headerbar_fg : status_gray_text;
unsigned char bgcolor = 0;
if (element > 0) {
bgcolor = active ? (w ? status_led_red : status_led_green) : headerbar_bg;
Bit8u fgcolor = active ? headerbar_fg : status_gray_text;
Bit8u bgcolor = 0;
if ((element > 0) && active) {
bgcolor = status_leds[color];
} else {
bgcolor = headerbar_bg;
}

View File

@ -69,14 +69,10 @@ IMPLEMENT_GUI_PLUGIN_CODE(sdl)
#define LOG_THIS theGui->
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
const Uint32 status_led_green = 0x00ff0000;
const Uint32 status_led_red = 0x0040ff00;
const Uint32 status_led_yellow = 0x00ffff00;
const Uint32 status_leds[3] = {0x00ff0000, 0x0040ff00, 0x00ffff00};
const Uint32 status_gray_text = 0x80808000;
#else
const Uint32 status_led_green = 0x0000ff00;
const Uint32 status_led_red = 0x00ff4000;
const Uint32 status_led_yellow = 0x00ffff00;
const Uint32 status_leds[3] = {0x0000ff00, 0x00ff4000, 0x00ffff00};
const Uint32 status_gray_text = 0x00808080;
#endif
@ -139,7 +135,7 @@ static void sdl_set_status_text(int element, const char *text, bx_bool active, b
rowsleft = statusbar_height - 2;
fgcolor = active?headerbar_fg:status_gray_text;
if ((element > 0) && active) {
bgcolor = (color==0)?status_led_green:(color==1)?status_led_red:status_led_yellow;
bgcolor = status_leds[color];
} else {
bgcolor = headerbar_bg;
}

View File

@ -69,14 +69,10 @@ IMPLEMENT_GUI_PLUGIN_CODE(sdl2)
#define LOG_THIS theGui->
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
const Uint32 status_led_green = 0x00ff0000;
const Uint32 status_led_red = 0x0040ff00;
const Uint32 status_led_yellow = 0x00ffff00;
const Uint32 status_leds[3] = {0x00ff0000, 0x0040ff00, 0x00ffff00};
const Uint32 status_gray_text = 0x80808000;
#else
const Uint32 status_led_green = 0x0000ff00;
const Uint32 status_led_red = 0x00ff4000;
const Uint32 status_led_yellow = 0x00ffff00;
const Uint32 status_leds[3] = {0x0000ff00, 0x00ff4000, 0x00ffff00};
const Uint32 status_gray_text = 0x00808080;
#endif
@ -149,7 +145,7 @@ static void sdl_set_status_text(int element, const char *text, bx_bool active, B
rowsleft = statusbar_height - 2;
fgcolor = active?headerbar_fg:status_gray_text;
if ((element > 0) && active) {
bgcolor = (color==0)?status_led_green:(color==1)?status_led_red:status_led_yellow;
bgcolor = status_leds[color];
} else {
bgcolor = headerbar_bg;
}

View File

@ -146,15 +146,13 @@ static BX_MUTEX(bKeyboardInUse);
#define BX_RFB_DEF_YDIM 480
#ifdef BX_LITTLE_ENDIAN
const rfbPixel status_led_green = 0x0000ff00;
const rfbPixel status_leds[3] = {0x0000ff00, 0x000040ff, 0x0000ffff};
const rfbPixel status_gray_text = 0x00808080;
const rfbPixel status_led_red = 0x000040ff;
const rfbPixel headerbar_bg = 0x00d0d0d0;
const rfbPixel headerbar_fg = 0x00101010;
#else
const rfbPixel status_led_green = 0x00ff0000;
const rfbPixel status_leds[3] = {0x00ff0000, 0xff400000, 0xffff0000};
const rfbPixel status_gray_text = 0x80808000;
const rfbPixel status_led_red = 0x00ff4000;
const rfbPixel headerbar_bg = 0xd0d0d000;
const rfbPixel headerbar_fg = 0x10101000;
#endif
@ -198,7 +196,7 @@ void DrawChar(int x, int y, int width, int height, int fontx, int fonty,
char *bmap, rfbPixel fg, rfbPixel bg, bx_bool gfxchar);
void UpdateScreen(rfbPixel *newBits, int x, int y, int width, int height);
void SendUpdate(int x, int y, int width, int height);
void vncSetStatusText(int element, const char *text, bx_bool active, bx_bool w = 0);
void vncSetStatusText(int element, const char *text, bx_bool active, Bit8u color = 0);
static Bit32u convertStringToRfbKey(const char *string);
void clientgone(rfbClientPtr cl);
@ -658,7 +656,11 @@ void bx_vncsrv_gui_c::get_capabilities(Bit16u *xres, Bit16u *yres, Bit16u *bpp)
void bx_vncsrv_gui_c::statusbar_setitem_specific(int element, bx_bool active,
bx_bool w)
{
vncSetStatusText(element + 1, statusitem[element].text, active, w);
Bit8u color = 0;
if (w) {
color = statusitem[element].auto_off ? 1 : 2;
}
vncSetStatusText(element + 1, statusitem[element].text, active, color);
}
void bx_vncsrv_gui_c::set_mouse_mode_absxy(bx_bool mode)
@ -1144,7 +1146,7 @@ void SendUpdate(int x, int y, int width, int height)
rfbMarkRectAsModified(theGui->screen, x, y, x + width, y + height);
}
void vncSetStatusText(int element, const char *text, bx_bool active, bx_bool w)
void vncSetStatusText(int element, const char *text, bx_bool active, Bit8u color)
{
char *newBits;
unsigned xleft, xsize, i, len;
@ -1160,8 +1162,8 @@ void vncSetStatusText(int element, const char *text, bx_bool active, bx_bool w)
rfbPixel fgcolor = active ? headerbar_fg : status_gray_text;
rfbPixel bgcolor = 0;
if (element > 0) {
bgcolor = active ? (w ? status_led_red : status_led_green) : headerbar_bg;
if ((element > 0) && active) {
bgcolor = status_leds[color];
} else {
bgcolor = headerbar_bg;
}

View File

@ -162,7 +162,7 @@ static unsigned bx_statusitem_pos[12] = {
0, 200, 240, 280, 320, 360, 400, 440, 480, 520, 560, 600
};
static bx_bool bx_statusitem_active[12];
static long bx_status_led_green, bx_status_led_red, bx_status_led_yellow;
static long bx_status_leds[3];
static long bx_status_graytext;
static char bx_status_info_text[34];
#if BX_SHOW_IPS
@ -413,12 +413,7 @@ void x11_set_status_text(int element, const char *text, bx_bool active,
} else if (element <= BX_MAX_STATUSITEMS) {
bx_statusitem_active[element] = active;
if (active) {
if (color == 1)
XSetForeground(bx_x_display, gc_headerbar, bx_status_led_red);
else if (color == 2)
XSetForeground(bx_x_display, gc_headerbar, bx_status_led_yellow);
else
XSetForeground(bx_x_display, gc_headerbar, bx_status_led_green);
XSetForeground(bx_x_display, gc_headerbar, bx_status_leds[color]);
XFillRectangle(bx_x_display, win, gc_headerbar, xleft, sb_ypos+2, xsize-1, bx_statusbar_y-2);
XSetForeground(bx_x_display, gc_headerbar, black_pixel);
} else {
@ -870,22 +865,22 @@ void bx_x_gui_c::specific_init(int argc, char **argv, unsigned headerbar_y)
for (i=0; i<12; i++) bx_statusitem_active[i] = 0;
switch (imBPP) {
case 16:
bx_status_led_green = 0x07e0;
bx_status_led_red = 0xf900;
bx_status_led_yellow = 0xffe0;
bx_status_leds[0] = 0x07e0;
bx_status_leds[1] = 0xf900;
bx_status_leds[2] = 0xffe0;
bx_status_graytext = 0x8410;
break;
case 24:
case 32:
bx_status_led_green = 0x00ff00;
bx_status_led_red = 0xff4000;
bx_status_led_yellow = 0xffff00;
bx_status_leds[0] = 0x00ff00;
bx_status_leds[1] = 0xff4000;
bx_status_leds[2] = 0xffff00;
bx_status_graytext = 0x808080;
break;
default:
bx_status_led_green = 0;
bx_status_led_red = 0;
bx_status_led_yellow = 0;
bx_status_leds[0] = 0;
bx_status_leds[1] = 0;
bx_status_leds[2] = 0;
bx_status_graytext = 0;
}
sprintf(bx_status_info_text, "%s enables mouse", get_toggle_info());

View File

@ -730,7 +730,7 @@ struct USBKBD usbkbd_conv[BX_KEY_NBKEYS] = {
0x54, 0,
0xe3, 0,
0xe7, 0,
0x00, 0, /* BX_KEY_MENU */
0x65, 0,
0x00, 0, /* BX_KEY_ALT_SYSREQ */
0x00, 0, /* BX_KEY_CTRL_BREAK */
0x00, 0, /* BX_KEY_INT_BACK */