Cleaning up the "keyboard" module. Also general fixups here and there, and cleanups of earlier cleanups.

This commit is contained in:
waltje
2017-10-24 22:10:21 -04:00
parent 659e07221d
commit 5abd25ba58
17 changed files with 533 additions and 546 deletions

View File

@@ -8,7 +8,7 @@
* *
* Configuration file handler. * Configuration file handler.
* *
* Version: @(#)config.c 1.0.25 2017/10/21 * Version: @(#)config.c 1.0.26 2017/10/24
* *
* Authors: Sarah Walker, * Authors: Sarah Walker,
* Miran Grca, <mgrca8@gmail.com> * Miran Grca, <mgrca8@gmail.com>
@@ -1174,7 +1174,7 @@ save_general(void)
if (vid_resize == 0) if (vid_resize == 0)
config_delete_var(cat, "vid_resize"); config_delete_var(cat, "vid_resize");
va_name = plat_vidapi_name(); va_name = plat_vidapi_name(vid_api);
if (!strcmp(va_name, "default")) { if (!strcmp(va_name, "default")) {
config_delete_var(cat, "vid_renderer"); config_delete_var(cat, "vid_renderer");
} else { } else {

View File

@@ -8,7 +8,7 @@
* *
* Host to guest keyboard interface and keyboard scan code sets. * Host to guest keyboard interface and keyboard scan code sets.
* *
* Version: @(#)keyboard.c 1.0.5 2017/10/16 * Version: @(#)keyboard.c 1.0.6 2017/10/24
* *
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/> * Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com> * Miran Grca, <mgrca8@gmail.com>
@@ -22,20 +22,33 @@
#include <wchar.h> #include <wchar.h>
#include "86box.h" #include "86box.h"
#include "ibm.h" #include "ibm.h"
#include "plat_keyboard.h"
#include "keyboard.h" #include "keyboard.h"
#if 0
int keybsendcallback = 0; int keybsendcallback = 0;
#endif
int64_t keybsenddelay; int64_t keybsenddelay;
/* bit 0 = repeat, bit 1 = makes break code? */
uint8_t keyboard_set3_flags[272];
uint8_t keyboard_set3_all_repeat;
uint8_t keyboard_set3_all_break;
typedef struct void (*keyboard_send)(uint8_t val);
{ void (*keyboard_poll)(void);
int keyboard_scan;
static int recv_key[272]; /* keyboard input buffer */
typedef struct {
int scancodes_make[9]; int scancodes_make[9];
int scancodes_break[9]; int scancodes_break[9];
} scancode; } scancode;
/*272 = 256 + 16 fake interim scancodes for disambiguation purposes.*/ /*272 = 256 + 16 fake interim scancodes for disambiguation purposes.*/
static scancode scancode_set1[272] = static scancode scancode_set1[272] =
{ {
@@ -428,25 +441,28 @@ static int scorder[272] = {0x38, 0xB8, 0x1D, 0x9D, 0xFF, 0x2A, 0x36,0x103, 0x00,
0xEE, 0xEF, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xEE, 0xEF, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD,
0xFE,0x100,0x101,0x102,0x104,0x105,0x106,0x107,0x108,0x109,0x10A,0x10B,0x10C,0x10D,0x10E,0x10F}; 0xFE,0x100,0x101,0x102,0x104,0x105,0x106,0x107,0x108,0x109,0x10A,0x10B,0x10C,0x10D,0x10E,0x10F};
/* bit 0 = repeat, bit 1 = makes break code? */
uint8_t set3_flags[272];
uint8_t set3_all_repeat = 0;
uint8_t set3_all_break = 0;
void (*keyboard_send)(uint8_t val); void
void (*keyboard_poll)(); keyboard_init(void)
int keyboard_scan = 1;
void keyboard_process()
{ {
int c; memset(recv_key, 0x00, sizeof(recv_key));
int d;
scancode *scancodes;
if (AT) keyboard_scan = 1;
{
switch (mode & 3) memset(keyboard_set3_flags, 0x00, sizeof(keyboard_set3_flags));
{ keyboard_set3_all_repeat = 0;
keyboard_set3_all_break = 0;
}
void
keyboard_process(void)
{
scancode *scancodes;
int c, d;
if (AT) {
switch (keyboard_mode & 3) {
case 1: case 1:
default: default:
scancodes = scancode_set1; scancodes = scancode_set1;
@@ -458,71 +474,111 @@ void keyboard_process()
scancodes = scancode_set3; scancodes = scancode_set3;
break; break;
} }
if (mode & 0x20) scancodes = scancode_set1; if (keyboard_mode & 0x20) scancodes = scancode_set1;
} } else {
else
{
scancodes = scancode_xt; scancodes = scancode_xt;
} }
if (!keyboard_scan) return; if (!keyboard_scan) return;
if (TANDY) scancodes = scancode_tandy; if (TANDY) scancodes = scancode_tandy;
for (c = 0; c < 272; c++) for (c = 0; c < 272; c++) {
{
if (recv_key[scorder[c]]) if (recv_key[scorder[c]])
keydelay[scorder[c]]++; keydelay[scorder[c]]++;
else else
keydelay[scorder[c]] = 0; keydelay[scorder[c]] = 0;
} }
for (c = 0; c < 272; c++) for (c = 0; c < 272; c++) {
{ if (recv_key[scorder[c]] != oldkey[scorder[c]]) {
if (recv_key[scorder[c]] != oldkey[scorder[c]])
{
oldkey[scorder[c]] = recv_key[scorder[c]]; oldkey[scorder[c]] = recv_key[scorder[c]];
if ( recv_key[scorder[c]] && scancodes[scorder[c]].scancodes_make[0] == -1) if (recv_key[scorder[c]] &&
continue; scancodes[scorder[c]].scancodes_make[0] == -1) continue;
if (!recv_key[scorder[c]] && scancodes[scorder[c]].scancodes_break[0] == -1)
continue; if (!recv_key[scorder[c]] &&
if (AT && ((mode & 3) == 3)) scancodes[scorder[c]].scancodes_break[0] == -1) continue;
{
if (!set3_all_break && !recv_key[scorder[c]] && !(set3_flags[scancodes[scorder[c]].scancodes_make[0]] & 2)) if (AT && ((keyboard_mode & 3) == 3)) {
continue; if (!keyboard_set3_all_break &&
!recv_key[scorder[c]] &&
!(keyboard_set3_flags[scancodes[scorder[c]].scancodes_make[0]] & 2)) continue;
} }
d = 0; d = 0;
if (recv_key[scorder[c]]) if (recv_key[scorder[c]]) {
{
while (scancodes[scorder[c]].scancodes_make[d] != -1) while (scancodes[scorder[c]].scancodes_make[d] != -1)
keyboard_send(scancodes[scorder[c]].scancodes_make[d++]); keyboard_send(scancodes[scorder[c]].scancodes_make[d++]);
} } else {
else
{
while (scancodes[scorder[c]].scancodes_break[d] != -1) while (scancodes[scorder[c]].scancodes_break[d] != -1)
keyboard_send(scancodes[scorder[c]].scancodes_break[d++]); keyboard_send(scancodes[scorder[c]].scancodes_break[d++]);
} }
} }
} }
for (c = 0; c < 272; c++) for (c = 0; c < 272; c++) {
{ if (AT && ((keyboard_mode & 3) == 3)) {
if (AT && ((mode & 3) == 3)) if (scancodes[scorder[c]].scancodes_make[0] == -1) continue;
{
if (scancodes[scorder[c]].scancodes_make[0] == -1) if (!keyboard_set3_all_repeat &&
continue; !recv_key[scorder[c]] &&
if (!set3_all_repeat && !recv_key[scorder[c]] && !(set3_flags[scancodes[scorder[c]].scancodes_make[0]] & 1)) !(keyboard_set3_flags[scancodes[scorder[c]].scancodes_make[0]] & 1)) continue;
continue;
} }
if (keydelay[scorder[c]] >= 30)
{ if (keydelay[scorder[c]] >= 30) {
keydelay[scorder[c]] -= 10; keydelay[scorder[c]] -= 10;
if (scancodes[scorder[c]].scancodes_make[0] == -1) if (scancodes[scorder[c]].scancodes_make[0] == -1) continue;
continue;
d = 0; d = 0;
while (scancodes[scorder[c]].scancodes_make[d] != -1) while (scancodes[scorder[c]].scancodes_make[d] != -1)
keyboard_send(scancodes[scorder[c]].scancodes_make[d++]); keyboard_send(scancodes[scorder[c]].scancodes_make[d++]);
} }
} }
} }
/* Handle a keystroke event from the UI layer. */
void
keyboard_input(int down, uint16_t scan)
{
int key;
#if 0
pclog("KBD: kbinput %d %04x\n", down, scan);
#endif
if ((scan >> 8) == 0xf0) {
scan &= 0x00ff;
scan |= 0x0100; /* ext key code in disambiguated format */
} else if ((scan >> 8) == 0xe0) {
scan &= 0x00ff;
scan |= 0x0080; /* normal extended key code */
}
/* First key. */
key = (scan >> 8) & 0xff;
if (key > 0)
recv_key[key] = down;
/* Second key. */
key = scan & 0xff;
if (key > 0)
recv_key[key] = down;
}
/* Do we have Control-Alt-PgDn in the keyboard buffer? */
int
keyboard_isfsexit(void)
{
return( (recv_key[0x1D] || recv_key[0x9D]) &&
(recv_key[0x38] || recv_key[0xB8]) &&
(recv_key[0x51] || recv_key[0xD1]) );
}
/* Do we have F8-F12 in the keyboard buffer? */
int
keyboard_ismsexit(void)
{
return( recv_key[0x42] && recv_key[0x58] );
}

View File

@@ -8,10 +8,11 @@
* *
* Host to guest keyboard interface and keyboard scan code sets. * Host to guest keyboard interface and keyboard scan code sets.
* *
* Version: @(#)keyboard.h 1.0.1 2017/08/23 * Version: @(#)keyboard.h 1.0.3 2017/10/24
* *
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/> * Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com> * Miran Grca, <mgrca8@gmail.com>
*
* Copyright 2008-2017 Sarah Walker. * Copyright 2008-2017 Sarah Walker.
* Copyright 2016,2017 Miran Grca. * Copyright 2016,2017 Miran Grca.
*/ */
@@ -19,18 +20,28 @@
# define EMU_KEYBOARD_H # define EMU_KEYBOARD_H
extern int keyboard_scan; #ifdef __cplusplus
extern int pcem_key[272]; extern "C" {
extern uint8_t mode; #endif
extern uint8_t set3_flags[272]; extern uint8_t keyboard_mode;
extern uint8_t set3_all_repeat; extern int keyboard_scan;
extern uint8_t set3_all_break; extern uint8_t keyboard_set3_flags[272];
extern uint8_t keyboard_set3_all_repeat;
extern uint8_t keyboard_set3_all_break;
extern void (*keyboard_send)(uint8_t val); extern void (*keyboard_send)(uint8_t val);
extern void (*keyboard_poll)(void); extern void (*keyboard_poll)(void);
extern void keyboard_init(void);
extern void keyboard_close(void);
extern void keyboard_poll_host(void);
extern void keyboard_process(void); extern void keyboard_process(void);
extern uint16_t keyboard_convert(int ch);
extern void keyboard_input(int down, uint16_t scan);
extern int keyboard_isfsexit(void);
extern int keyboard_ismsexit(void);
#endif /*EMU_KEYBOARD_H*/ #endif /*EMU_KEYBOARD_H*/

View File

@@ -8,7 +8,7 @@
* *
* Intel 8042 (AT keyboard controller) emulation. * Intel 8042 (AT keyboard controller) emulation.
* *
* Version: @(#)keyboard_at.c 1.0.5 2017/10/19 * Version: @(#)keyboard_at.c 1.0.6 2017/10/24
* *
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/> * Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com> * Miran Grca, <mgrca8@gmail.com>
@@ -111,7 +111,7 @@ int first_write = 1;
int dtrans = 0; int dtrans = 0;
/* Bits 0 - 1 = scan code set, bit 6 = translate or not. */ /* Bits 0 - 1 = scan code set, bit 6 = translate or not. */
uint8_t mode = 0x42; uint8_t keyboard_mode = 0x42;
/* Non-translated to translated scan codes. */ /* Non-translated to translated scan codes. */
static uint8_t nont_to_t[256] = { 0xFF, 0x43, 0x41, 0x3F, 0x3D, 0x3B, 0x3C, 0x58, 0x64, 0x44, 0x42, 0x40, 0x3E, 0x0F, 0x29, 0x59, static uint8_t nont_to_t[256] = { 0xFF, 0x43, 0x41, 0x3F, 0x3D, 0x3B, 0x3C, 0x58, 0x64, 0x44, 0x42, 0x40, 0x3E, 0x0F, 0x29, 0x59,
@@ -213,18 +213,18 @@ uint8_t sc_or = 0;
void keyboard_at_adddata_keyboard(uint8_t val) void keyboard_at_adddata_keyboard(uint8_t val)
{ {
/* Modification by OBattler: Allow for scan code translation. */ /* Modification by OBattler: Allow for scan code translation. */
if ((mode & 0x40) && (val == 0xf0) && !(mode & 0x20)) if ((keyboard_mode & 0x40) && (val == 0xf0) && !(keyboard_mode & 0x20))
{ {
sc_or = 0x80; sc_or = 0x80;
return; return;
} }
/* Skip break code if translated make code has bit 7 set. */ /* Skip break code if translated make code has bit 7 set. */
if ((mode & 0x40) && (sc_or == 0x80) && (nont_to_t[val] & 0x80) && !(mode & 0x20)) if ((keyboard_mode & 0x40) && (sc_or == 0x80) && (nont_to_t[val] & 0x80) && !(keyboard_mode & 0x20))
{ {
sc_or = 0; sc_or = 0;
return; return;
} }
key_queue[key_queue_end] = (((mode & 0x40) && !(mode & 0x20)) ? (nont_to_t[val] | sc_or) : val); key_queue[key_queue_end] = (((keyboard_mode & 0x40) && !(keyboard_mode & 0x20)) ? (nont_to_t[val] | sc_or) : val);
key_queue_end = (key_queue_end + 1) & 0xf; key_queue_end = (key_queue_end + 1) & 0xf;
if (sc_or == 0x80) sc_or = 0; if (sc_or == 0x80) sc_or = 0;
return; return;
@@ -290,21 +290,21 @@ write_register:
keyboard_at_log("Mouse interrupt is now %s\n", (val & 0x02) ? "enabled" : "disabled"); keyboard_at_log("Mouse interrupt is now %s\n", (val & 0x02) ? "enabled" : "disabled");
/* Addition by OBattler: Scan code translate ON/OFF. */ /* Addition by OBattler: Scan code translate ON/OFF. */
mode &= 0x93; keyboard_mode &= 0x93;
mode |= (val & MODE_MASK); keyboard_mode |= (val & MODE_MASK);
if (first_write) if (first_write)
{ {
/* A bit of a hack, but it will make the keyboard behave correctly, regardless /* A bit of a hack, but it will make the keyboard behave correctly, regardless
of what the BIOS sets here. */ of what the BIOS sets here. */
mode &= 0xFC; keyboard_mode &= 0xFC;
dtrans = mode & (CCB_TRANSLATE | CCB_PCMODE); dtrans = keyboard_mode & (CCB_TRANSLATE | CCB_PCMODE);
if ((mode & (CCB_TRANSLATE | CCB_PCMODE)) == CCB_TRANSLATE) if ((keyboard_mode & (CCB_TRANSLATE | CCB_PCMODE)) == CCB_TRANSLATE)
{ {
/* Bit 6 on, bit 5 off, the only case in which translation is on, /* Bit 6 on, bit 5 off, the only case in which translation is on,
therefore, set to set 2. */ therefore, set to set 2. */
mode |= 2; keyboard_mode |= 2;
} }
keyboard_at.default_mode = (mode & 3); keyboard_at.default_mode = (keyboard_mode & 3);
first_write = 0; first_write = 0;
/* No else because in all other cases, translation is off, so we need to keep it /* No else because in all other cases, translation is off, so we need to keep it
set to set 0 which the mode &= 0xFC above will set it. */ set to set 0 which the mode &= 0xFC above will set it. */
@@ -338,8 +338,8 @@ write_register:
case 0xcf: /*??? - sent by MegaPC BIOS*/ case 0xcf: /*??? - sent by MegaPC BIOS*/
keyboard_at_log("??? - sent by MegaPC BIOS\n"); keyboard_at_log("??? - sent by MegaPC BIOS\n");
/* To make sure the keyboard works correctly on the MegaPC. */ /* To make sure the keyboard works correctly on the MegaPC. */
mode &= 0xFC; keyboard_mode &= 0xFC;
mode |= 2; keyboard_mode |= 2;
break; break;
case 0xd1: /*Write output port*/ case 0xd1: /*Write output port*/
@@ -392,14 +392,14 @@ bad_command:
case 0xf0: /*Get/set scancode set*/ case 0xf0: /*Get/set scancode set*/
if (val == 0) if (val == 0)
{ {
keyboard_at_adddata_keyboard(mode & 3); keyboard_at_adddata_keyboard(keyboard_mode & 3);
} }
else else
{ {
if (val <= 3) if (val <= 3)
{ {
mode &= 0xFC; keyboard_mode &= 0xFC;
mode |= (val & 3); keyboard_mode |= (val & 3);
} }
keyboard_at_adddata_keyboard(0xfa); keyboard_at_adddata_keyboard(0xfa);
} }
@@ -469,31 +469,31 @@ bad_command:
break; break;
case 0xf6: /*Set defaults*/ case 0xf6: /*Set defaults*/
set3_all_break = 0; keyboard_set3_all_break = 0;
set3_all_repeat = 0; keyboard_set3_all_repeat = 0;
memset(set3_flags, 0, 272); memset(keyboard_set3_flags, 0, 272);
mode = (mode & 0xFC) | keyboard_at.default_mode; keyboard_mode = (keyboard_mode & 0xFC) | keyboard_at.default_mode;
keyboard_at_adddata_keyboard(0xfa); keyboard_at_adddata_keyboard(0xfa);
break; break;
case 0xf7: /*Set all keys to repeat*/ case 0xf7: /*Set all keys to repeat*/
set3_all_break = 1; keyboard_set3_all_break = 1;
keyboard_at_adddata_keyboard(0xfa); keyboard_at_adddata_keyboard(0xfa);
break; break;
case 0xf8: /*Set all keys to give make/break codes*/ case 0xf8: /*Set all keys to give make/break codes*/
set3_all_break = 1; keyboard_set3_all_break = 1;
keyboard_at_adddata_keyboard(0xfa); keyboard_at_adddata_keyboard(0xfa);
break; break;
case 0xf9: /*Set all keys to give make codes only*/ case 0xf9: /*Set all keys to give make codes only*/
set3_all_break = 0; keyboard_set3_all_break = 0;
keyboard_at_adddata_keyboard(0xfa); keyboard_at_adddata_keyboard(0xfa);
break; break;
case 0xfa: /*Set all keys to repeat and give make/break codes*/ case 0xfa: /*Set all keys to repeat and give make/break codes*/
set3_all_repeat = 1; keyboard_set3_all_repeat = 1;
set3_all_break = 1; keyboard_set3_all_break = 1;
keyboard_at_adddata_keyboard(0xfa); keyboard_at_adddata_keyboard(0xfa);
break; break;
@@ -506,8 +506,8 @@ bad_command:
keyboard_at_adddata_keyboard(0xfa); keyboard_at_adddata_keyboard(0xfa);
keyboard_at_adddata_keyboard(0xaa); keyboard_at_adddata_keyboard(0xaa);
/* Set system flag to 1 and scan code set to 2. */ /* Set system flag to 1 and scan code set to 2. */
mode &= 0xFC; keyboard_mode &= 0xFC;
mode |= 2; keyboard_mode |= 2;
break; break;
default: default:
@@ -851,8 +851,8 @@ uint8_t keyboard_at_read(uint16_t port, void *priv)
break; break;
case 0x64: case 0x64:
temp = (keyboard_at.status & 0xFB) | (mode & CCB_SYSTEM); temp = (keyboard_at.status & 0xFB) | (keyboard_mode & CCB_SYSTEM);
/* if (mode & CCB_IGNORELOCK) */ temp |= STAT_LOCK; /* if (keyboard_mode & CCB_IGNORELOCK) */ temp |= STAT_LOCK;
keyboard_at.status &= ~(STAT_RTIMEOUT/* | STAT_TTIMEOUT*/); keyboard_at.status &= ~(STAT_RTIMEOUT/* | STAT_TTIMEOUT*/);
break; break;
} }
@@ -864,7 +864,7 @@ void keyboard_at_reset(void)
keyboard_at.initialised = 0; keyboard_at.initialised = 0;
keyboard_at.status = STAT_LOCK | STAT_CD; keyboard_at.status = STAT_LOCK | STAT_CD;
keyboard_at.mem[0] = 0x31; keyboard_at.mem[0] = 0x31;
mode = 0x02 | dtrans; keyboard_mode = 0x02 | dtrans;
keyboard_at.default_mode = 2; keyboard_at.default_mode = 2;
first_write = 1; first_write = 1;
keyboard_at.wantirq = 0; keyboard_at.wantirq = 0;
@@ -882,7 +882,7 @@ void keyboard_at_reset(void)
sc_or = 0; sc_or = 0;
memset(set3_flags, 0, 272); memset(keyboard_set3_flags, 0, 272);
} }
static void at_refresh(void *p) static void at_refresh(void *p)

View File

@@ -8,7 +8,7 @@
* *
* Main emulator module where most things are controlled. * Main emulator module where most things are controlled.
* *
* Version: @(#)pc.c 1.0.32 2017/10/22 * Version: @(#)pc.c 1.0.33 2017/10/24
* *
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/> * Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com> * Miran Grca, <mgrca8@gmail.com>
@@ -73,7 +73,6 @@
#include "ui.h" #include "ui.h"
#include "plat.h" #include "plat.h"
#include "plat_joystick.h" #include "plat_joystick.h"
#include "plat_keyboard.h"
#include "plat_midi.h" #include "plat_midi.h"
#include "plat_mouse.h" #include "plat_mouse.h"
@@ -114,9 +113,9 @@ int sreadlnum,
segawrites, segawrites,
scycles_lost; scycles_lost;
float mips, flops; float mips, flops;
int cycles_lost = 0; // video int cycles_lost = 0; /* video */
int insc = 0; // cpu int insc = 0; /* cpu */
int emu_fps = 0, fps; // video int emu_fps = 0, fps; /* video */
int framecount; int framecount;
int CPUID; int CPUID;
@@ -125,7 +124,7 @@ int atfullspeed;
int cpuspeed2; int cpuspeed2;
int clockrate; int clockrate;
int gfx_present[GFX_MAX]; // should not be here int gfx_present[GFX_MAX]; /* should not be here */
wchar_t exe_path[1024]; /* path (dir) of executable */ wchar_t exe_path[1024]; /* path (dir) of executable */
wchar_t cfg_path[1024]; /* path (dir) of user data */ wchar_t cfg_path[1024]; /* path (dir) of user data */
@@ -145,6 +144,7 @@ pclog(const char *format, ...)
{ {
#ifndef RELEASE_BUILD #ifndef RELEASE_BUILD
va_list ap; va_list ap;
va_start(ap, format); va_start(ap, format);
vprintf(format, ap); vprintf(format, ap);
va_end(ap); va_end(ap);
@@ -280,7 +280,7 @@ set_screen_size_natural(void)
* Perform initial startup of the PC. * Perform initial startup of the PC.
* *
* This is the platform-indepenent part of the startup, * This is the platform-indepenent part of the startup,
* where we check commandline arguments and loading a * where we check commandline arguments and load a
* configuration file. * configuration file.
*/ */
int int
@@ -520,6 +520,7 @@ again2:
codegen_init(); codegen_init();
#endif #endif
keyboard_init();
mouse_init(); mouse_init();
#ifdef WALTJE #ifdef WALTJE
serial_init(); serial_init();
@@ -774,6 +775,7 @@ pc_close(thread_t *ptr)
config_save(); config_save();
#if 0 #if 0
//FIXME: need to move this to Plat. */
if (mouse_capture) { if (mouse_capture) {
ClipCursor(&oldclip); ClipCursor(&oldclip);
ShowCursor(TRUE); ShowCursor(TRUE);
@@ -831,10 +833,7 @@ pc_thread(void *param)
while (! *quitp) { while (! *quitp) {
/* Update the Stat(u)s window with the current info. */ /* Update the Stat(u)s window with the current info. */
if (status_update_needed) { if (status_update_needed) {
#if 0 ui_status_update();
pclog("Updating STATS window..\n");
// ui_status_update();
#endif
status_update_needed = 0; status_update_needed = 0;
} }
@@ -966,20 +965,10 @@ pc_thread(void *param)
/* If requested, leave full-screen mode. */ /* If requested, leave full-screen mode. */
if (leave_fullscreen_flag) { if (leave_fullscreen_flag) {
#if 1
pclog("Leaving full-screen mode..\n"); pclog("Leaving full-screen mode..\n");
plat_setfullscreen(0); plat_setfullscreen(0);
#else
SendMessage(hwndMain, WM_LEAVEFULLSCREEN, 0, 0);
#endif
leave_fullscreen_flag = 0; leave_fullscreen_flag = 0;
} }
#if 0
/* Do we really need this all the time? */
if (video_fullscreen && infocus)
SetCursorPos(9999, 9999);
#endif
} }
pclog("PC: main thread done.\n"); pclog("PC: main thread done.\n");

View File

@@ -8,7 +8,7 @@
* *
* Define the various platform support functions. * Define the various platform support functions.
* *
* Version: @(#)plat.h 1.0.13 2017/10/22 * Version: @(#)plat.h 1.0.14 2017/10/24
* *
* Authors: Miran Grca, <mgrca8@gmail.com> * Authors: Miran Grca, <mgrca8@gmail.com>
* Fred N. van Kempen, <decwiz@yahoo.com> * Fred N. van Kempen, <decwiz@yahoo.com>
@@ -58,7 +58,7 @@ extern uint32_t plat_get_ticks(void);
extern void plat_delay_ms(uint32_t count); extern void plat_delay_ms(uint32_t count);
extern void plat_pause(int p); extern void plat_pause(int p);
extern int plat_vidapi(char *name); extern int plat_vidapi(char *name);
extern char * plat_vidapi_name(void); extern char *plat_vidapi_name(int api);
extern int plat_setvid(int api); extern int plat_setvid(int api);
extern void plat_setfullscreen(int on); extern void plat_setfullscreen(int on);
extern void plat_resize(int max_x, int max_y); extern void plat_resize(int max_x, int max_y);

View File

@@ -1,22 +0,0 @@
/* Copyright holders: Sarah Walker
see COPYING for more details
*/
#ifdef __cplusplus
extern "C" {
#endif
void keyboard_init();
void keyboard_close();
void keyboard_poll_host();
extern int recv_key[272];
extern int rawinputkey[272];
#ifndef __unix
#define KEY_LCONTROL 0x1d
#define KEY_RCONTROL (0x1d | 0x80)
#define KEY_END (0x4f | 0x80)
#endif
#ifdef __cplusplus
}
#endif

View File

@@ -13,8 +13,6 @@
#include <wchar.h> #include <wchar.h>
#include "ibm.h" #include "ibm.h"
#include "pit.h" #include "pit.h"
#include "plat_keyboard.h"
#include "plat_mouse.h"
PPI ppi; PPI ppi;

View File

@@ -8,7 +8,7 @@
* *
* Define the various UI functions. * Define the various UI functions.
* *
* Version: @(#)ui.h 1.0.5 2017/10/16 * Version: @(#)ui.h 1.0.6 2017/10/24
* *
* Authors: Miran Grca, <mgrca8@gmail.com> * Authors: Miran Grca, <mgrca8@gmail.com>
* Fred N. van Kempen, <decwiz@yahoo.com> * Fred N. van Kempen, <decwiz@yahoo.com>
@@ -53,6 +53,7 @@ extern void ui_check_menu_item(int id, int checked);
#define SB_TEXT 0x60 #define SB_TEXT 0x60
extern wchar_t *ui_window_title(wchar_t *s); extern wchar_t *ui_window_title(wchar_t *s);
extern void ui_status_update(void);
extern int ui_sb_find_part(int tag); extern int ui_sb_find_part(int tag);
extern void ui_sb_update_panes(void); extern void ui_sb_update_panes(void);
extern void ui_sb_update_tip(int meaning); extern void ui_sb_update_tip(int meaning);

View File

@@ -8,7 +8,7 @@
* *
* Implement the VNC remote renderer with LibVNCServer. * Implement the VNC remote renderer with LibVNCServer.
* *
* Version: @(#)vnc.c 1.0.6 2017/10/22 * Version: @(#)vnc.c 1.0.7 2017/10/24
* *
* Authors: Fred N. van Kempen, <decwiz@yahoo.com> * Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Based on raw code by RichardG, <richardg867@gmail.com> * Based on raw code by RichardG, <richardg867@gmail.com>
@@ -26,9 +26,9 @@
#include "86box.h" #include "86box.h"
#include "device.h" #include "device.h"
#include "video/video.h" #include "video/video.h"
#include "keyboard.h"
#include "mouse.h" #include "mouse.h"
#include "plat.h" #include "plat.h"
#include "plat_keyboard.h"
#include "ui.h" #include "ui.h"
#include "vnc.h" #include "vnc.h"

View File

@@ -22,7 +22,7 @@
* NOTE: The values are as defined in the Microsoft document named * NOTE: The values are as defined in the Microsoft document named
* "Keyboard Scan Code Specification", version 1.3a of 2000/03/16. * "Keyboard Scan Code Specification", version 1.3a of 2000/03/16.
* *
* Version: @(#)vnc_keymap.c 1.0.1 2017/10/22 * Version: @(#)vnc_keymap.c 1.0.2 2017/10/24
* *
* Authors: Fred N. van Kempen, <decwiz@yahoo.com> * Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Based on raw code by RichardG, <richardg867@gmail.com> * Based on raw code by RichardG, <richardg867@gmail.com>
@@ -35,8 +35,8 @@
#include <string.h> #include <string.h>
#include <wchar.h> #include <wchar.h>
#include "86box.h" #include "86box.h"
#include "keyboard.h"
#include "plat.h" #include "plat.h"
#include "plat_keyboard.h"
#include "vnc.h" #include "vnc.h"
@@ -183,7 +183,7 @@ static int keysyms_00[] = {
0x2a2b, /* 0x7c (XK_bar) */ 0x2a2b, /* 0x7c (XK_bar) */
0x2a1b, /* 0x7d (XK_braceright) */ 0x2a1b, /* 0x7d (XK_braceright) */
0x2a29, /* 0x7e (XK_asciitilde) */ 0x2a29, /* 0x7e (XK_asciitilde) */
0xe071, /* 0x7f (XK_delete) */ 0x0053, /* 0x7f (XK_delete) */
0x0000, /* 0x80 */ 0x0000, /* 0x80 */
0x0000, 0x0000,
@@ -371,7 +371,7 @@ static int keysyms_ff[] = {
0x0000, /* 0x21 (XK_Kanji; Kanji, Kanji convert) */ 0x0000, /* 0x21 (XK_Kanji; Kanji, Kanji convert) */
0x0000, /* 0x22 (XK_Muhenkan; Cancel Conversion) */ 0x0000, /* 0x22 (XK_Muhenkan; Cancel Conversion) */
0x0000, /* 0x23 (XK_Henkan_Mode; Start/Stop Conversion) */ 0x0000, /* 0x23 (XK_Henkan_Mode; Start/Stop Conversion) */
0x0000, /* 0x24 (#define XK_Romaji; to Romaji) */ 0x0000, /* 0x24 (XK_Romaji; to Romaji) */
0x0000, /* 0x25 (XK_Hiragana; to Hiragana) */ 0x0000, /* 0x25 (XK_Hiragana; to Hiragana) */
0x0000, /* 0x26 (XK_Katakana; to Katakana) */ 0x0000, /* 0x26 (XK_Katakana; to Katakana) */
0x0000, /* 0x27 (XK_Hiragana_Katakana; Hiragana/Katakana toggle) */ 0x0000, /* 0x27 (XK_Hiragana_Katakana; Hiragana/Katakana toggle) */
@@ -421,14 +421,14 @@ static int keysyms_ff[] = {
0x0000, 0x0000,
0x0000, 0x0000,
0x006c, /* 0x50 (XK_Home) */ 0xe047, /* 0x50 (XK_Home) */
0x006b, /* 0x51 (XK_Left) */ 0xe04b, /* 0x51 (XK_Left) */
0x0075, /* 0x52 (XK_Up) */ 0xe048, /* 0x52 (XK_Up) */
0x0074, /* 0x53 (XK_Right) */ 0xe04d, /* 0x53 (XK_Right) */
0x0072, /* 0x54 (XK_Down) */ 0xe050, /* 0x54 (XK_Down) */
0x007d, /* 0x55 (XK_Prior, XK_Page_Up) */ 0xe049, /* 0x55 (XK_Prior, XK_Page_Up) */
0x007a, /* 0x56 (XK_Next, XK_Page_Down) */ 0xe051, /* 0x56 (XK_Next, XK_Page_Down) */
0x0069, /* 0x57 (XK_End) */ 0xe04f, /* 0x57 (XK_End) */
0x0000, /* 0x58 (XK_Begin) */ 0x0000, /* 0x58 (XK_Begin) */
0x0000, 0x0000,
@@ -442,11 +442,11 @@ static int keysyms_ff[] = {
0x0000, /* 0x60 (XK_Select) */ 0x0000, /* 0x60 (XK_Select) */
0x0000, /* 0x61 (XK_Print) */ 0x0000, /* 0x61 (XK_Print) */
0x0000, /* 0x62 (XK_Execute) */ 0x0000, /* 0x62 (XK_Execute) */
0xe070, /* 0x63 (XK_Insert) */ 0xe052, /* 0x63 (XK_Insert) */
0x0000, 0x0000,
0x0000, /* 0x65 (XK_Undo) */ 0x0000, /* 0x65 (XK_Undo) */
0x0000, /* 0x66 (XK_Redo) */ 0x0000, /* 0x66 (XK_Redo) */
0x00dd, /* 0x67 (XK_Menu) */ 0xe05d, /* 0x67 (XK_Menu) */
0x0000, /* 0x68 (XK_Find) */ 0x0000, /* 0x68 (XK_Find) */
0x0000, /* 0x69 (XK_Cancel) */ 0x0000, /* 0x69 (XK_Cancel) */
@@ -475,7 +475,7 @@ static int keysyms_ff[] = {
0x0000, /* 0x7e (XK_Mode_switch,XK_script_switch) */ 0x0000, /* 0x7e (XK_Mode_switch,XK_script_switch) */
0x0045, /* 0x7f (XK_Num_Lock) */ 0x0045, /* 0x7f (XK_Num_Lock) */
0x0000, /* 0x80 (XK_KP_Space) */ 0x0039, /* 0x80 (XK_KP_Space) */
0x0000, 0x0000,
0x0000, 0x0000,
0x0000, 0x0000,
@@ -485,11 +485,11 @@ static int keysyms_ff[] = {
0x0000, 0x0000,
0x0000, /* 0x88 */ 0x0000, /* 0x88 */
0x0000, /* 0x89 (XK_KP_Tab) */ 0x000f, /* 0x89 (XK_KP_Tab) */
0x0000, 0x0000,
0x0000, 0x0000,
0x0000, 0x0000,
0x001c, /* 0x8d (XK_KP_Enter) */ 0xe01c, /* 0x8d (XK_KP_Enter) */
0x0000, 0x0000,
0x0000, 0x0000,
@@ -498,18 +498,18 @@ static int keysyms_ff[] = {
0x0000, /* 0x92 (XK_KP_F2) */ 0x0000, /* 0x92 (XK_KP_F2) */
0x0000, /* 0x93 (XK_KP_F3) */ 0x0000, /* 0x93 (XK_KP_F3) */
0x0000, /* 0x94 (XK_KP_F4) */ 0x0000, /* 0x94 (XK_KP_F4) */
0x006c, /* 0x95 (XK_KP_Home) */ 0x0047, /* 0x95 (XK_KP_Home) */
0x006b, /* 0x96 (XK_KP_Left) */ 0x004b, /* 0x96 (XK_KP_Left) */
0x0075, /* 0x97 (XK_KP_Up) */ 0x0048, /* 0x97 (XK_KP_Up) */
0x0074, /* 0x98 (XK_KP_Right) */ 0x004d, /* 0x98 (XK_KP_Right) */
0x0072, /* 0x99 (XK_KP_Down) */ 0x0050, /* 0x99 (XK_KP_Down) */
0x007d, /* 0x9a (XK_KP_Prior,XK_KP_Page_Up) */ 0x0049, /* 0x9a (XK_KP_Prior,XK_KP_Page_Up) */
0x007a, /* 0x9b (XK_KP_Next,XK_KP_Page_Down) */ 0x0051, /* 0x9b (XK_KP_Next,XK_KP_Page_Down) */
0x0069, /* 0x9c (XK_KP_End) */ 0x004f, /* 0x9c (XK_KP_End) */
0x0000, /* 0x9d (XK_KP_Begin) */ 0x0000, /* 0x9d (XK_KP_Begin) */
0x0000, /* 0x9e (XK_KP_Insert) */ 0x0052, /* 0x9e (XK_KP_Insert) */
0xe071, /* 0x9f (XK_KP_Delete) */ 0x0053, /* 0x9f (XK_KP_Delete) */
0x0000, /* 0xa0 */ 0x0000, /* 0xa0 */
0x0000, 0x0000,
@@ -527,7 +527,7 @@ static int keysyms_ff[] = {
0x0000, /* 0xac (XK_KP_Separator) */ 0x0000, /* 0xac (XK_KP_Separator) */
0x004a, /* 0xad (XK_KP_Subtract) */ 0x004a, /* 0xad (XK_KP_Subtract) */
0x0000, /* 0xae (XK_KP_Decimal) */ 0x0000, /* 0xae (XK_KP_Decimal) */
0x00b5, /* 0xaf (XK_KP_Divide) */ 0x0035, /* 0xaf (XK_KP_Divide) */
0x0052, /* 0xb0 (XK_KP_0) */ 0x0052, /* 0xb0 (XK_KP_0) */
0x004f, /* 0xb1 (XK_KP_1) */ 0x004f, /* 0xb1 (XK_KP_1) */
@@ -543,7 +543,7 @@ static int keysyms_ff[] = {
0x0000, 0x0000,
0x0000, 0x0000,
0x0000, 0x0000,
0x0000, /* 0xbd (XK_KP_Equal) */ 0x000d, /* 0xbd (XK_KP_Equal) */
0x003b, /* 0xbe (XK_F1) */ 0x003b, /* 0xbe (XK_F1) */
0x003c, /* 0xbf (XK_F2) */ 0x003c, /* 0xbf (XK_F2) */
@@ -589,10 +589,10 @@ static int keysyms_ff[] = {
0x001d, /* 0xe3 (XK_Control_L) */ 0x001d, /* 0xe3 (XK_Control_L) */
0xe01d, /* 0xe4 (XK_Control_R) */ 0xe01d, /* 0xe4 (XK_Control_R) */
0x003a, /* 0xe5 (XK_Caps_Lock) */ 0x003a, /* 0xe5 (XK_Caps_Lock) */
0x0000, /* 0xe6 (XK_Shift_Lock) */ 0x003a, /* 0xe6 (XK_Shift_Lock) */
0x0000, /* 0xe7 (XK_Meta_L) */ 0xe05b, /* 0xe7 (XK_Meta_L) */
0x0000, /* 0xe8 (XK_Meta_R) */ 0xe05c, /* 0xe8 (XK_Meta_R) */
0x0038, /* 0xe9 (XK_Alt_L) */ 0x0038, /* 0xe9 (XK_Alt_L) */
0xe038, /* 0xea (XK_Alt_R) */ 0xe038, /* 0xea (XK_Alt_R) */
0x0000, /* 0xeb (XK_Super_L) */ 0x0000, /* 0xeb (XK_Super_L) */
@@ -624,7 +624,7 @@ static int keysyms_ff[] = {
void void
vnc_kbinput(int down, int k) vnc_kbinput(int down, int k)
{ {
int key, scan; uint16_t scan;
#if 0 #if 0
pclog("VNC: kbinput %d %04x\n", down, k); pclog("VNC: kbinput %d %04x\n", down, k);
@@ -652,13 +652,6 @@ vnc_kbinput(int down, int k)
else pclog("VNC: translated to %02x %02x\n", (scan>>8)&0xff, scan&0xff); else pclog("VNC: translated to %02x %02x\n", (scan>>8)&0xff, scan&0xff);
#endif #endif
/* First key. */ /* Send this scancode sequence to the PC keyboard. */
key = (scan >> 8) & 0xff; keyboard_input(down, scan);
if (key > 0)
recv_key[key] = down;
/* Second key. */
key = scan & 0xff;
if (key > 0)
recv_key[key] = down;
} }

View File

@@ -8,7 +8,7 @@
* *
* The Emulator's Windows core. * The Emulator's Windows core.
* *
* Version: @(#)win.c 1.0.28 2017/10/22 * Version: @(#)win.c 1.0.29 2017/10/24
* *
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/> * Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com> * Miran Grca, <mgrca8@gmail.com>
@@ -43,6 +43,7 @@
#include "../device.h" #include "../device.h"
#include "../nvr.h" #include "../nvr.h"
#include "../mouse.h" #include "../mouse.h"
#include "../keyboard.h"
#include "../cdrom/cdrom.h" #include "../cdrom/cdrom.h"
#include "../cdrom/cdrom_image.h" #include "../cdrom/cdrom_image.h"
#include "../cdrom/cdrom_null.h" #include "../cdrom/cdrom_null.h"
@@ -54,7 +55,6 @@
#include "../sound/sound.h" #include "../sound/sound.h"
#define GLOBAL #define GLOBAL
#include "../plat.h" #include "../plat.h"
#include "../plat_keyboard.h"
#include "../plat_mouse.h" #include "../plat_mouse.h"
#include "../plat_midi.h" #include "../plat_midi.h"
#include "../ui.h" #include "../ui.h"
@@ -62,7 +62,7 @@
#include "win_d3d.h" #include "win_d3d.h"
#define TIMER_1SEC 1 #define TIMER_1SEC 1 /* ID of the one-second timer */
typedef struct { typedef struct {
@@ -81,7 +81,6 @@ LCID lang_id; /* current language ID used */
DWORD dwSubLangID; DWORD dwSubLangID;
RECT oldclip; /* mouse rect */ RECT oldclip; /* mouse rect */
int infocus = 1; int infocus = 1;
int recv_key[272]; /* keyboard input buffer */
char openfilestring[260]; char openfilestring[260];
WCHAR wopenfilestring[260]; WCHAR wopenfilestring[260];
@@ -180,7 +179,6 @@ ResetAllMenus(void)
CheckMenuItem(menuMain, IDM_LOG_SERIAL, MF_UNCHECKED); CheckMenuItem(menuMain, IDM_LOG_SERIAL, MF_UNCHECKED);
# endif # endif
# ifdef ENABLE_NIC_LOG # ifdef ENABLE_NIC_LOG
/*FIXME: should be network_setlog(1:0) */
CheckMenuItem(menuMain, IDM_LOG_NIC, MF_UNCHECKED); CheckMenuItem(menuMain, IDM_LOG_NIC, MF_UNCHECKED);
# endif # endif
#endif #endif
@@ -392,9 +390,9 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
#ifdef USE_RDP #ifdef USE_RDP
case IDM_VID_RDP: case IDM_VID_RDP:
#endif #endif
CheckMenuItem(hmenu, IDM_VID_DDRAW + vid_api, MF_UNCHECKED); CheckMenuItem(hmenu, IDM_VID_DDRAW+vid_api, MF_UNCHECKED);
plat_setvid(LOWORD(wParam) - IDM_VID_DDRAW); plat_setvid(LOWORD(wParam) - IDM_VID_DDRAW);
CheckMenuItem(hmenu, IDM_VID_DDRAW + vid_api, MF_CHECKED); CheckMenuItem(hmenu, IDM_VID_DDRAW+vid_api, MF_CHECKED);
config_save(); config_save();
break; break;
@@ -407,9 +405,9 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
case IDM_VID_FS_43: case IDM_VID_FS_43:
case IDM_VID_FS_SQ: case IDM_VID_FS_SQ:
case IDM_VID_FS_INT: case IDM_VID_FS_INT:
CheckMenuItem(hmenu, IDM_VID_FS_FULL + video_fullscreen_scale, MF_UNCHECKED); CheckMenuItem(hmenu, IDM_VID_FS_FULL+video_fullscreen_scale, MF_UNCHECKED);
video_fullscreen_scale = LOWORD(wParam) - IDM_VID_FS_FULL; video_fullscreen_scale = LOWORD(wParam) - IDM_VID_FS_FULL;
CheckMenuItem(hmenu, IDM_VID_FS_FULL + video_fullscreen_scale, MF_CHECKED); CheckMenuItem(hmenu, IDM_VID_FS_FULL+video_fullscreen_scale, MF_CHECKED);
device_force_redraw(); device_force_redraw();
config_save(); config_save();
break; break;
@@ -418,9 +416,9 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
case IDM_VID_SCALE_2X: case IDM_VID_SCALE_2X:
case IDM_VID_SCALE_3X: case IDM_VID_SCALE_3X:
case IDM_VID_SCALE_4X: case IDM_VID_SCALE_4X:
CheckMenuItem(hmenu, IDM_VID_SCALE_1X + scale, MF_UNCHECKED); CheckMenuItem(hmenu, IDM_VID_SCALE_1X+scale, MF_UNCHECKED);
scale = LOWORD(wParam) - IDM_VID_SCALE_1X; scale = LOWORD(wParam) - IDM_VID_SCALE_1X;
CheckMenuItem(hmenu, IDM_VID_SCALE_1X + scale, MF_CHECKED); CheckMenuItem(hmenu, IDM_VID_SCALE_1X+scale, MF_CHECKED);
device_force_redraw(); device_force_redraw();
video_force_resize_set(1); video_force_resize_set(1);
config_save(); config_save();
@@ -451,9 +449,9 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
case IDM_VID_GRAYCT_601: case IDM_VID_GRAYCT_601:
case IDM_VID_GRAYCT_709: case IDM_VID_GRAYCT_709:
case IDM_VID_GRAYCT_AVE: case IDM_VID_GRAYCT_AVE:
CheckMenuItem(hmenu, IDM_VID_GRAYCT_601 + video_graytype, MF_UNCHECKED); CheckMenuItem(hmenu, IDM_VID_GRAYCT_601+video_graytype, MF_UNCHECKED);
video_graytype = LOWORD(wParam) - IDM_VID_GRAYCT_601; video_graytype = LOWORD(wParam) - IDM_VID_GRAYCT_601;
CheckMenuItem(hmenu, IDM_VID_GRAYCT_601 + video_graytype, MF_CHECKED); CheckMenuItem(hmenu, IDM_VID_GRAYCT_601+video_graytype, MF_CHECKED);
device_force_redraw(); device_force_redraw();
config_save(); config_save();
break; break;
@@ -463,9 +461,9 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
case IDM_VID_GRAY_AMBER: case IDM_VID_GRAY_AMBER:
case IDM_VID_GRAY_GREEN: case IDM_VID_GRAY_GREEN:
case IDM_VID_GRAY_WHITE: case IDM_VID_GRAY_WHITE:
CheckMenuItem(hmenu, IDM_VID_GRAY_RGB + video_grayscale, MF_UNCHECKED); CheckMenuItem(hmenu, IDM_VID_GRAY_RGB+video_grayscale, MF_UNCHECKED);
video_grayscale = LOWORD(wParam) - IDM_VID_GRAY_RGB; video_grayscale = LOWORD(wParam) - IDM_VID_GRAY_RGB;
CheckMenuItem(hmenu, IDM_VID_GRAY_RGB + video_grayscale, MF_CHECKED); CheckMenuItem(hmenu, IDM_VID_GRAY_RGB+video_grayscale, MF_CHECKED);
device_force_redraw(); device_force_redraw();
config_save(); config_save();
break; break;
@@ -592,7 +590,7 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
return(0); return(0);
case WM_INPUT: case WM_INPUT:
process_raw_input(lParam, infocus); keyboard_handle(lParam, infocus);
break; break;
case WM_SETFOCUS: case WM_SETFOCUS:
@@ -609,7 +607,6 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
case WM_KILLFOCUS: case WM_KILLFOCUS:
infocus = 0; infocus = 0;
releasemouse(); releasemouse();
memset(recv_key, 0, sizeof(recv_key));
if (video_fullscreen) if (video_fullscreen)
leave_fullscreen_flag = 1; leave_fullscreen_flag = 1;
if (hook_enabled) { if (hook_enabled) {
@@ -1001,7 +998,6 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpszArg, int nFunsterStil)
} }
/* Initialize the input (keyboard, mouse, game) module. */ /* Initialize the input (keyboard, mouse, game) module. */
memset(recv_key, 0x00, sizeof(recv_key));
device.usUsagePage = 0x01; device.usUsagePage = 0x01;
device.usUsage = 0x06; device.usUsage = 0x06;
device.dwFlags = RIDEV_NOHOTKEYS; device.dwFlags = RIDEV_NOHOTKEYS;
@@ -1013,7 +1009,7 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpszArg, int nFunsterStil)
MB_OK | MB_ICONERROR); MB_OK | MB_ICONERROR);
return(4); return(4);
} }
get_registry_key_map(); keyboard_getkeymap();
/* Create the status bar window. */ /* Create the status bar window. */
StatusBarCreate(hwndMain, IDC_STATUS, hinstance); StatusBarCreate(hwndMain, IDC_STATUS, hinstance);
@@ -1038,21 +1034,9 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpszArg, int nFunsterStil)
return(5); return(5);
} }
#if 0
/* Initialize the rendering window, or fullscreen. */ /* Initialize the rendering window, or fullscreen. */
if (start_in_fullscreen) { if (start_in_fullscreen)
startblit();
vid_apis[0][vid_api].close();
video_fullscreen = 1;
vid_apis[1][vid_api].init(hwndRender);
leave_fullscreen_flag = 0;
endblit();
device_force_redraw();
}
#endif
if (start_in_fullscreen) {
plat_setfullscreen(1); plat_setfullscreen(1);
}
/* Set up the current window size. */ /* Set up the current window size. */
plat_resize(scrnsz_x, scrnsz_y); plat_resize(scrnsz_x, scrnsz_y);
@@ -1073,9 +1057,6 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpszArg, int nFunsterStil)
/* Set the PAUSE mode depending on the renderer. */ /* Set the PAUSE mode depending on the renderer. */
plat_pause(0); plat_pause(0);
/* Initialize raw keyboard input buffer. */
memset(recv_key, 0x00, sizeof(recv_key));
/* /*
* Everything has been configured, and all seems to work, * Everything has been configured, and all seems to work,
* so now it is time to start the main thread to do some * so now it is time to start the main thread to do some
@@ -1103,16 +1084,13 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpszArg, int nFunsterStil)
DispatchMessage(&messages); DispatchMessage(&messages);
} }
if (mouse_capture && recv_key[0x58] && recv_key[0x42]) { if (mouse_capture && keyboard_ismsexit()) {
ClipCursor(&oldclip); ClipCursor(&oldclip);
ShowCursor(TRUE); ShowCursor(TRUE);
mouse_capture = 0; mouse_capture = 0;
} }
if (video_fullscreen && if (video_fullscreen && keyboard_isfsexit()) {
(recv_key[0x1D] || recv_key[0x9D]) &&
(recv_key[0x38] || recv_key[0xB8]) &&
(recv_key[0x51] || recv_key[0xD1])) {
/* Signal "exit fullscreen mode". */ /* Signal "exit fullscreen mode". */
plat_setfullscreen(0); plat_setfullscreen(0);
} }

View File

@@ -8,7 +8,7 @@
* *
* Platform support defintions for Win32. * Platform support defintions for Win32.
* *
* Version: @(#)win.h 1.0.7 2017/10/19 * Version: @(#)win.h 1.0.8 2017/10/24
* *
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/> * Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com> * Miran Grca, <mgrca8@gmail.com>
@@ -56,8 +56,6 @@ extern LCID lang_id;
extern HICON hIcon[512]; extern HICON hIcon[512];
extern int status_is_open; extern int status_is_open;
extern int mousecapture;
extern int recv_key[272];
extern char openfilestring[260]; extern char openfilestring[260];
extern WCHAR wopenfilestring[260]; extern WCHAR wopenfilestring[260];
@@ -77,6 +75,11 @@ extern void do_stop(void);
extern void set_language(int id); extern void set_language(int id);
extern int get_vidpause(void); extern int get_vidpause(void);
extern void keyboard_getkeymap(void);
extern void keyboard_handle(LPARAM lParam, int infocus);
extern int fdd_type_to_icon(int type);
#ifdef EMU_DEVICE_H #ifdef EMU_DEVICE_H
extern uint8_t deviceconfig_open(HWND hwnd, device_t *device); extern uint8_t deviceconfig_open(HWND hwnd, device_t *device);
#endif #endif
@@ -90,11 +93,6 @@ extern void win_settings_open(HWND hwnd);
extern void hard_disk_add_open(HWND hwnd, int is_existing); extern void hard_disk_add_open(HWND hwnd, int is_existing);
extern int hard_disk_was_added(void); extern int hard_disk_was_added(void);
extern void get_registry_key_map(void);
extern void process_raw_input(LPARAM lParam, int infocus);
extern int fdd_type_to_icon(int type);
/* Functions in win_about.c: */ /* Functions in win_about.c: */
extern void AboutDialogCreate(HWND hwnd); extern void AboutDialogCreate(HWND hwnd);

View File

@@ -2,6 +2,8 @@
see COPYING for more details see COPYING for more details
*/ */
#include <stdint.h> #include <stdint.h>
#include "../86box.h"
#include "../device.h"
#include "../video/video.h" #include "../video/video.h"
#include "win_ddraw.h" #include "win_ddraw.h"
@@ -17,114 +19,9 @@ static HWND ddraw_hwnd;
static int ddraw_w, ddraw_h; static int ddraw_w, ddraw_h;
extern "C" void fatal(const char *format, ...);
extern "C" void pclog(const char *format, ...);
extern "C" void device_force_redraw(void);
extern "C" int ddraw_fs_init(HWND h);
extern "C" void ddraw_fs_close(void);
extern "C" int ddraw_fs_pause(void);
extern "C" void ddraw_fs_take_screenshot(wchar_t *fn);
extern void ddraw_common_take_screenshot(wchar_t *fn, IDirectDrawSurface7 *pDDSurface); extern void ddraw_common_take_screenshot(wchar_t *fn, IDirectDrawSurface7 *pDDSurface);
static void blit_memtoscreen(int, int, int, int, int, int);
int ddraw_fs_init(HWND h)
{
ddraw_w = GetSystemMetrics(SM_CXSCREEN);
ddraw_h = GetSystemMetrics(SM_CYSCREEN);
cgapal_rebuild();
if (FAILED(DirectDrawCreate(NULL, &lpdd, NULL)))
return 0;
if (FAILED(lpdd->QueryInterface(IID_IDirectDraw7, (LPVOID *)&lpdd7)))
return 0;
lpdd->Release();
lpdd = NULL;
atexit(ddraw_fs_close);
if (FAILED(lpdd7->SetCooperativeLevel(h, DDSCL_SETFOCUSWINDOW |
DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_ALLOWREBOOT)))
return 0;
if (FAILED(lpdd7->SetDisplayMode(ddraw_w, ddraw_h, 32, 0 ,0)))
return 0;
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
ddsd.dwBackBufferCount = 1;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP;
if (FAILED(lpdd7->CreateSurface(&ddsd, &lpdds_pri, NULL)))
return 0;
ddsd.ddsCaps.dwCaps = DDSCAPS_BACKBUFFER;
if (FAILED(lpdds_pri->GetAttachedSurface(&ddsd.ddsCaps, &lpdds_back2)))
return 0;
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
ddsd.dwWidth = 2048;
ddsd.dwHeight = 2048;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY;
if (FAILED(lpdd7->CreateSurface(&ddsd, &lpdds_back, NULL)))
{
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
ddsd.dwWidth = 2048;
ddsd.dwHeight = 2048;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
if (FAILED(lpdd7->CreateSurface(&ddsd, &lpdds_back, NULL)))
return 0;
}
pclog("DDRAW_INIT complete\n");
ddraw_hwnd = h;
video_setblit(blit_memtoscreen);
return 1;
}
void ddraw_fs_close(void)
{
if (lpdds_back2)
{
lpdds_back2->Release();
lpdds_back2 = NULL;
}
if (lpdds_back)
{
lpdds_back->Release();
lpdds_back = NULL;
}
if (lpdds_pri)
{
lpdds_pri->Release();
lpdds_pri = NULL;
}
if (lpdd_clipper)
{
lpdd_clipper->Release();
lpdd_clipper = NULL;
}
if (lpdd7)
{
lpdd7->Release();
lpdd7 = NULL;
}
}
static void ddraw_fs_size(RECT window_rect, RECT *r_dest, int w, int h) static void ddraw_fs_size(RECT window_rect, RECT *r_dest, int w, int h)
{ {
int ratio_w, ratio_h; int ratio_w, ratio_h;
@@ -175,6 +72,7 @@ static void ddraw_fs_size(RECT window_rect, RECT *r_dest, int w, int h)
} }
} }
static void blit_memtoscreen(int x, int y, int y1, int y2, int w, int h) static void blit_memtoscreen(int x, int y, int y1, int y2, int w, int h)
{ {
RECT r_src; RECT r_src;
@@ -247,6 +145,98 @@ static void blit_memtoscreen(int x, int y, int y1, int y2, int w, int h)
} }
int ddraw_fs_init(HWND h)
{
ddraw_w = GetSystemMetrics(SM_CXSCREEN);
ddraw_h = GetSystemMetrics(SM_CYSCREEN);
cgapal_rebuild();
if (FAILED(DirectDrawCreate(NULL, &lpdd, NULL)))
return 0;
if (FAILED(lpdd->QueryInterface(IID_IDirectDraw7, (LPVOID *)&lpdd7)))
return 0;
lpdd->Release();
lpdd = NULL;
atexit(ddraw_fs_close);
if (FAILED(lpdd7->SetCooperativeLevel(h, DDSCL_SETFOCUSWINDOW |
DDSCL_CREATEDEVICEWINDOW | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_ALLOWREBOOT)))
return 0;
if (FAILED(lpdd7->SetDisplayMode(ddraw_w, ddraw_h, 32, 0 ,0)))
return 0;
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
ddsd.dwBackBufferCount = 1;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP;
if (FAILED(lpdd7->CreateSurface(&ddsd, &lpdds_pri, NULL)))
return 0;
ddsd.ddsCaps.dwCaps = DDSCAPS_BACKBUFFER;
if (FAILED(lpdds_pri->GetAttachedSurface(&ddsd.ddsCaps, &lpdds_back2)))
return 0;
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
ddsd.dwWidth = 2048;
ddsd.dwHeight = 2048;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY;
if (FAILED(lpdd7->CreateSurface(&ddsd, &lpdds_back, NULL)))
{
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
ddsd.dwWidth = 2048;
ddsd.dwHeight = 2048;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
if (FAILED(lpdd7->CreateSurface(&ddsd, &lpdds_back, NULL)))
return 0;
}
pclog("DDRAW_INIT complete\n");
ddraw_hwnd = h;
video_setblit(blit_memtoscreen);
return 1;
}
void ddraw_fs_close(void)
{
if (lpdds_back2)
{
lpdds_back2->Release();
lpdds_back2 = NULL;
}
if (lpdds_back)
{
lpdds_back->Release();
lpdds_back = NULL;
}
if (lpdds_pri)
{
lpdds_pri->Release();
lpdds_pri = NULL;
}
if (lpdd_clipper)
{
lpdd_clipper->Release();
lpdd_clipper = NULL;
}
if (lpdd7)
{
lpdd7->Release();
lpdd7 = NULL;
}
}
int int
ddraw_fs_pause(void) ddraw_fs_pause(void)
{ {

View File

@@ -8,11 +8,11 @@
* *
* Windows raw keyboard input handler. * Windows raw keyboard input handler.
* *
* Version: @(#)win_keyboard.c 1.0.3 2017/10/16 * Version: @(#)win_keyboard.c 1.0.4 2017/10/24
* *
* Author: Miran Grca, <mgrca8@gmail.com> * Author: Miran Grca, <mgrca8@gmail.com>
* *
* Copyright 2016-2017 Miran Grca. * Copyright 2016,2017 Miran Grca.
*/ */
#define UNICODE #define UNICODE
#define _WIN32_WINNT 0x0501 #define _WIN32_WINNT 0x0501
@@ -26,23 +26,20 @@
#include <stdlib.h> #include <stdlib.h>
#include "../86box.h" #include "../86box.h"
#include "../device.h" #include "../device.h"
#include "../keyboard.h"
#include "../plat.h" #include "../plat.h"
#include "../plat_keyboard.h"
#include "win.h" #include "win.h"
#ifndef MAPVK_VK_TO_VSC
#define MAPVK_VK_TO_VSC 0
#endif
static uint16_t scancode_map[65536]; static uint16_t scancode_map[65536];
/* This is so we can disambiguate scan codes that would otherwise conflict and get /* This is so we can disambiguate scan codes that would otherwise conflict and get
passed on incorrectly. */ passed on incorrectly. */
UINT16 convert_scan_code(UINT16 scan_code) static UINT16
convert_scan_code(UINT16 scan_code)
{ {
switch (scan_code) switch (scan_code) {
{
case 0xE001: case 0xE001:
return 0xF001; return 0xF001;
case 0xE002: case 0xE002:
@@ -77,7 +74,9 @@ UINT16 convert_scan_code(UINT16 scan_code)
} }
} }
void get_registry_key_map()
void
keyboard_getkeymap(void)
{ {
WCHAR *keyName = L"SYSTEM\\CurrentControlSet\\Control\\Keyboard Layout"; WCHAR *keyName = L"SYSTEM\\CurrentControlSet\\Control\\Keyboard Layout";
WCHAR *valueName = L"Scancode Map"; WCHAR *valueName = L"Scancode Map";
@@ -92,26 +91,24 @@ void get_registry_key_map()
int scancode_mapped; int scancode_mapped;
/* First, prepare the default scan code map list which is 1:1. /* First, prepare the default scan code map list which is 1:1.
Remappings will be inserted directly into it. * Remappings will be inserted directly into it.
65536 bytes so scan codes fit in easily and it's easy to find what each maps too, * 65536 bytes so scan codes fit in easily and it's easy to find
since each array element is a scan code and provides for E0, etc. ones too. */ * what each maps too, since each array element is a scan code
* and provides for E0, etc. ones too.
*/
for (j = 0; j < 65536; j++) for (j = 0; j < 65536; j++)
scancode_map[j] = convert_scan_code(j); scancode_map[j] = convert_scan_code(j);
bufSize = 32768;
/* Get the scan code remappings from: /* Get the scan code remappings from:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout */ HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout */
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, keyName, 0, 1, &hKey) == ERROR_SUCCESS) bufSize = 32768;
{ if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, keyName, 0, 1, &hKey) == ERROR_SUCCESS) {
if(RegQueryValueEx(hKey, valueName, NULL, NULL, buf, &bufSize) == ERROR_SUCCESS) if (RegQueryValueEx(hKey, valueName, NULL, NULL, buf, &bufSize) == ERROR_SUCCESS) {
{
bufEx2 = (UINT32 *) buf; bufEx2 = (UINT32 *) buf;
scMapCount = bufEx2[2]; scMapCount = bufEx2[2];
if ((bufSize != 0) && (scMapCount != 0)) if ((bufSize != 0) && (scMapCount != 0)) {
{
bufEx = (UINT16 *) (buf + 12); bufEx = (UINT16 *) (buf + 12);
for (j = 0; j < scMapCount*2; j += 2) for (j = 0; j < scMapCount*2; j += 2) {
{
/* Each scan code is 32-bit: 16 bits of remapped scan code, /* Each scan code is 32-bit: 16 bits of remapped scan code,
and 16 bits of original scan code. */ and 16 bits of original scan code. */
scancode_unmapped = bufEx[j + 1]; scancode_unmapped = bufEx[j + 1];
@@ -128,78 +125,60 @@ void get_registry_key_map()
} }
} }
void process_raw_input(LPARAM lParam, int infocus)
void
keyboard_handle(LPARAM lParam, int infocus)
{ {
uint32_t ri_size = 0; uint32_t ri_size = 0;
UINT size; UINT size;
RAWINPUT *raw; RAWINPUT *raw;
USHORT scancode; USHORT scancode;
if (!infocus) if (! infocus) return;
{
return;
}
GetRawInputData((HRAWINPUT)lParam, RID_INPUT, NULL, &size, sizeof(RAWINPUTHEADER)); GetRawInputData((HRAWINPUT)lParam, RID_INPUT, NULL,
&size, sizeof(RAWINPUTHEADER));
raw = malloc(size); raw = malloc(size);
if (raw == NULL) return;
if (raw == NULL)
{
return;
}
/* Here we read the raw input data for the keyboard */ /* Here we read the raw input data for the keyboard */
ri_size = GetRawInputData((HRAWINPUT)(lParam), RID_INPUT, raw, &size, sizeof(RAWINPUTHEADER)); ri_size = GetRawInputData((HRAWINPUT)(lParam), RID_INPUT,
raw, &size, sizeof(RAWINPUTHEADER));
if(ri_size != size) if (ri_size != size) return;
{
return;
}
/* If the input is keyboard, we process it */ /* If the input is keyboard, we process it */
if (raw->header.dwType == RIM_TYPEKEYBOARD) if (raw->header.dwType == RIM_TYPEKEYBOARD) {
{
RAWKEYBOARD rawKB = raw->data.keyboard; RAWKEYBOARD rawKB = raw->data.keyboard;
scancode = rawKB.MakeCode; scancode = rawKB.MakeCode;
/* If it's not a scan code that starts with 0xE1 */ /* If it's not a scan code that starts with 0xE1 */
if (!(rawKB.Flags & RI_KEY_E1)) if (!(rawKB.Flags & RI_KEY_E1)) {
{ if (rawKB.Flags & RI_KEY_E0) {
if (rawKB.Flags & RI_KEY_E0)
{
scancode |= (0xE0 << 8); scancode |= (0xE0 << 8);
} }
/* Remap it according to the list from the Registry */ /* Remap it according to the list from the Registry */
scancode = scancode_map[scancode]; scancode = scancode_map[scancode];
if ((scancode >> 8) == 0xF0) if ((scancode >> 8) == 0xF0) {
{ /* Extended key code in disambiguated format */
scancode |= 0x100; /* Extended key code in disambiguated format */ scancode |= 0x100;
} } else if ((scancode >> 8) == 0xE0) {
else if ((scancode >> 8) == 0xE0) /* Normal extended key code */
{ scancode |= 0x80;
scancode |= 0x80; /* Normal extended key code */
} }
/* If it's not 0 (therefore not 0xE1, 0xE2, etc), /* If it's not 0 (therefore not 0xE1, 0xE2, etc),
then pass it on to the rawinputkey array */ send it to the PC keyboard. */
if (!(scancode & 0xf00)) if (!(scancode & 0xf00))
{ keyboard_input(!(rawKB.Flags & RI_KEY_BREAK), scancode & 0x1ff);
recv_key[scancode & 0x1ff] = !(rawKB.Flags & RI_KEY_BREAK); } else {
} if (rawKB.MakeCode == 0x1D) {
}
else
{
if (rawKB.MakeCode == 0x1D)
{
scancode = 0xFF; scancode = 0xFF;
} }
if (!(scancode & 0xf00)) if (!(scancode & 0xf00))
{ keyboard_input(!(rawKB.Flags & RI_KEY_BREAK), scancode & 0x1ff);
recv_key[scancode & 0x1ff] = !(rawKB.Flags & RI_KEY_BREAK);
}
} }
} }

View File

@@ -109,3 +109,11 @@ StatusWindowCreate(HWND hwndParent)
hwndParent, StatusWindowProcedure); hwndParent, StatusWindowProcedure);
ShowWindow(hwnd, SW_SHOW); ShowWindow(hwnd, SW_SHOW);
} }
/* Tell the Status window to update. */
void
ui_status_update(void)
{
SendMessage(hwndStatus, WM_USER, 0, 0);
}

View File

@@ -8,7 +8,7 @@
* *
* Platform video API support for Win32. * Platform video API support for Win32.
* *
* Version: @(#)win_video.c 1.0.2 2017/10/22 * Version: @(#)win_video.c 1.0.3 2017/10/24
* *
* Author: Fred N. van Kempen, <decwiz@yahoo.com> * Author: Fred N. van Kempen, <decwiz@yahoo.com>
* *
@@ -116,24 +116,38 @@ plat_vidapi(char *name)
} }
/* Return the VIDAPI name for the given number. */
char * char *
plat_vidapi_name(void) plat_vidapi_name(int api)
{ {
switch(vid_api) { char *name = "default";
switch(api) {
case 0: case 0:
return("ddraw"); name = "ddraw";
break;
case 1: case 1:
default: #if 0
return("default"); /* Direct3D is default. */ /* Direct3D is default. */
name = "d3d";
#endif
break;
#ifdef USE_VNC #ifdef USE_VNC
case 2: case 2:
return("vnc"); name = "vnc";
break;
#endif #endif
#ifdef USE_RDP #ifdef USE_RDP
case 3: case 3:
return("rdp"); name = "rdp";
break;
#endif #endif
} }
return(name);
} }
@@ -148,9 +162,6 @@ plat_setvid(int api)
/* Close the (old) API. */ /* Close the (old) API. */
vid_apis[0][vid_api].close(); vid_apis[0][vid_api].close();
#ifdef USE_WX
ui_check_menu_item(IDM_View_WX+vid_api, 0);
#endif
vid_api = api; vid_api = api;
if (vid_apis[0][vid_api].local) if (vid_apis[0][vid_api].local)
@@ -159,9 +170,6 @@ plat_setvid(int api)
ShowWindow(hwndRender, SW_HIDE); ShowWindow(hwndRender, SW_HIDE);
/* Initialize the (new) API. */ /* Initialize the (new) API. */
#ifdef USE_WX
ui_check_menu_item(IDM_View_WX+vid_api, 1);
#endif
i = vid_apis[0][vid_api].init((void *)hwndRender); i = vid_apis[0][vid_api].init((void *)hwndRender);
endblit(); endblit();
if (! i) return(0); if (! i) return(0);
@@ -255,7 +263,7 @@ take_screenshot(void)
switch(vid_api) { switch(vid_api) {
case 0: /* ddraw */ case 0: /* ddraw */
wcsftime(path, 128, L"%Y%m%d_%H%M%S.bmp", info); wcsftime(path, 128, L"%Y%m%d_%H%M%S.bmp", info);
plat_append_filename(path, cfg_path, fn, 1024); wcscat(path, fn);
if (video_fullscreen) if (video_fullscreen)
ddraw_fs_take_screenshot(path); ddraw_fs_take_screenshot(path);
else else
@@ -265,7 +273,7 @@ take_screenshot(void)
case 1: /* d3d9 */ case 1: /* d3d9 */
wcsftime(fn, 128, L"%Y%m%d_%H%M%S.png", info); wcsftime(fn, 128, L"%Y%m%d_%H%M%S.png", info);
plat_append_filename(path, cfg_path, fn, 1024); wcscat(path, fn);
if (video_fullscreen) if (video_fullscreen)
d3d_fs_take_screenshot(path); d3d_fs_take_screenshot(path);
else else
@@ -276,7 +284,7 @@ take_screenshot(void)
#ifdef USE_VNC #ifdef USE_VNC
case 2: /* vnc */ case 2: /* vnc */
wcsftime(fn, 128, L"%Y%m%d_%H%M%S.png", info); wcsftime(fn, 128, L"%Y%m%d_%H%M%S.png", info);
plat_append_filename(path, cfg_path, fn, 1024); wcscat(path, fn);
vnc_take_screenshot(path); vnc_take_screenshot(path);
pclog("Screenshot: fn='%ls'\n", path); pclog("Screenshot: fn='%ls'\n", path);
break; break;