VNC back to DEV builds (not everybody has the libs) and double-declares vars in win/.

This commit is contained in:
waltje
2017-11-20 00:23:02 -05:00
parent 4484011767
commit 59624c0884
3 changed files with 147 additions and 58 deletions

View File

@@ -32,7 +32,7 @@
* Based on an early driver for MINIX 1.5. * Based on an early driver for MINIX 1.5.
* Based on the 86Box PS/2 mouse driver as a framework. * Based on the 86Box PS/2 mouse driver as a framework.
* *
* Version: @(#)mouse_bus.c 1.0.22 2017/11/01 * Version: @(#)mouse_bus.c 1.0.22 2017/11/15
* *
* Authors: Fred N. van Kempen, <decwiz@yahoo.com> * Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* *
@@ -44,15 +44,15 @@
#include <stdlib.h> #include <stdlib.h>
#include <wchar.h> #include <wchar.h>
#include "86box.h" #include "86box.h"
#include "config.h"
#include "io.h" #include "io.h"
#include "pic.h" #include "pic.h"
#include "timer.h" #include "timer.h"
#include "mouse.h" #include "mouse.h"
#define BUSMOUSE_PORT 0x023c #define BUSMOUSE_PORT 0x023c /* default */
#define BUSMOUSE_PORTLEN 4 #define BUSMOUSE_IRQ 2 /* default (DOS,NT31) */
#define BUSMOUSE_IRQ 5
#define ENABLE_3BTN 1 /* enable 3-button mode */ #define ENABLE_3BTN 1 /* enable 3-button mode */
@@ -60,11 +60,9 @@
/* Our mouse device. */ /* Our mouse device. */
typedef struct mouse_bus { typedef struct mouse_bus {
char *name; /* name of this device */ const char *name; /* name of this device */
int8_t type; /* type of this device */ int8_t type; /* type of this device */
uint8_t flags; /* device flags */ uint8_t flags; /* device flags */
uint16_t port; /* I/O port range start */
uint16_t portlen; /* length of I/O port range */
int8_t irq; /* IRQ channel to use */ int8_t irq; /* IRQ channel to use */
uint8_t r_magic; /* MAGIC register */ uint8_t r_magic; /* MAGIC register */
@@ -72,8 +70,10 @@ typedef struct mouse_bus {
uint8_t r_intr; /* INTSTAT register (RO) */ uint8_t r_intr; /* INTSTAT register (RO) */
uint8_t r_conf; /* CONFIG register */ uint8_t r_conf; /* CONFIG register */
int16_t x, y; /* current mouse status */
uint8_t but; uint8_t but;
int16_t x, y; /* current mouse status */
int64_t timer; /* mouse event timer */
uint8_t (*read)(struct mouse_bus *, uint16_t); uint8_t (*read)(struct mouse_bus *, uint16_t);
void (*write)(struct mouse_bus *, uint16_t, uint8_t); void (*write)(struct mouse_bus *, uint16_t, uint8_t);
@@ -106,7 +106,7 @@ lt_write(mouse_bus_t *ms, uint16_t port, uint8_t val)
{ {
uint8_t b; uint8_t b;
#if 0 #if 1
pclog("BUSMOUSE: lt_write(%d,%02x)\n", port, val); pclog("BUSMOUSE: lt_write(%d,%02x)\n", port, val);
#endif #endif
@@ -115,8 +115,16 @@ lt_write(mouse_bus_t *ms, uint16_t port, uint8_t val)
break; break;
case MOUSE_MAGIC: /* [01] magic data register */ case MOUSE_MAGIC: /* [01] magic data register */
if (val == MAGIC_BYTE1 || val == MAGIC_BYTE2) { switch(val) {
ms->r_magic = val; case MAGIC_BYTE1:
ms->r_ctrl = (CTRL_IDIS);
ms->r_magic = val;
break;
case MAGIC_BYTE2:
ms->r_ctrl = (CTRL_IENB);
ms->r_magic = val;
break;
} }
break; break;
@@ -216,31 +224,39 @@ lt_read(mouse_bus_t *ms, uint16_t port)
case MOUSE_MAGIC: /* [01] magic data register */ case MOUSE_MAGIC: /* [01] magic data register */
/* /*
* Logitech drivers start out by blasting their magic * Drivers write a magic byte to this register, usually
* value (0xA5) into this register, and then read it * this is either 5A (AMI WinBIOS, MS Mouse 2.0-9.1) or
* back to see if that worked. If it did (and we do * A5 (Windows drivers, UNIX/Linux/Minix.)
* support this) the controller is assumed to be a *
* Logitech-protocol one, and not InPort. * It is unclear why there are two values, but the most
* likely explanation is to distinguish two variants of
* the hardware - one locked to a certain IRQ, and one
* that has the DIP switch to set the IRQ value.
*/ */
r = ms->r_magic; r = ms->r_magic;
break; break;
case MOUSE_CTRL: /* [02] control register */ case MOUSE_CTRL: /* [02] control register */
/* /*
* This is the weird stuff mentioned in the file header * This is the weird stuff mentioned in the file header.
* above. Microsoft's "mouse.exe" does some whacky stuff * The Microsoft "mouse" drivers (at least versions 2.0
* to extract the configured IRQ channel from the board. * through 9.1 for DOS) do some whacky things to extract
* the configured IRQ channel from the board.
* *
* First, it reads the current value, and then re-reads * First, it reads the current value, and then re-reads
* it another 10,000 (yes, really) times. It keeps track * it another 10,000 (yes, really) times. It keeps track
* of whether or not the data has changed, most likely * of whether or not the data has changed (to allow for
* to de-bounce reading of a DIP switch for example. This * de-bouncing the value.)
* first value is assumed to be the 2's complement of the *
* actual IRQ value. * Drivers that use 5A then expect the value to be a
* Next, it does this a second time, but now with the * simple bitmask of the DIP switch settings, where bits
* IDIS bit clear (so, interrupts enabled), which is * 0 through 3 mean IRQ2 through IRQ5.
* our cue to return the regular (not complemented) value *
* to them. * Drivers that use A5 expect this first value to be the
* 2's complement of the actual IRQ value. Next, it does
* this a second time, but now with the IDIS bit clear
* (so, interrupts enabled), which is our cue to return
* the regular (not complemented) value to them.
* *
* Since we have to fake the initial value and the settling * Since we have to fake the initial value and the settling
* of the data a bit later on, we first return a bunch of * of the data a bit later on, we first return a bunch of
@@ -248,13 +264,37 @@ lt_read(mouse_bus_t *ms, uint16_t port)
* *
* Yes, this is weird. --FvK * Yes, this is weird. --FvK
*/ */
if (ms->r_intr++ < 250) if (ms->r_magic == MAGIC_BYTE2) {
/* Still settling, return invalid data. */ /*
r = (ms->r_ctrl&CTRL_IDIS)?0xff:0x00; * Drivers using 5A expect a bitmask
else { * of the DIP switch here, where bits
/* OK, all good, return correct data. */ * 0..3 mean IRQ2..IRQ5.
r = (ms->r_ctrl&CTRL_IDIS)?-ms->irq:ms->irq; */
ms->r_intr = 0; switch(ms->irq) {
case 2:
r = 0x01;
break;
case 3:
r = 0x02;
break;
case 4:
r = 0x04;
break;
case 5:
r = 0x08;
break;
}
} else {
if (ms->r_intr++ < 250)
/* Still settling, return invalid data. */
r = (ms->r_ctrl&CTRL_IDIS) ? 0xff : 0x00;
else {
r = (ms->r_ctrl&CTRL_IDIS)?-ms->irq:ms->irq;
ms->r_intr = 0;
}
} }
break; break;
@@ -267,7 +307,7 @@ lt_read(mouse_bus_t *ms, uint16_t port)
} }
#if 0 #if 0
pclog("BUSMOUSE: lt_read(%d): %02x\n", port, r); pclog("BUSMOUSE: lt_read(%d): %02x\n", port);
#endif #endif
return(r); return(r);
@@ -278,12 +318,13 @@ lt_read(mouse_bus_t *ms, uint16_t port)
static void static void
lt_init(mouse_bus_t *ms) lt_init(mouse_bus_t *ms)
{ {
pclog("BUSMOUSE: %s, I/O=%04x, IRQ=%d\n", ms->name, ms->port, ms->irq); pclog("BUSMOUSE: %s, I/O=%04x, IRQ=%d\n",
ms->name, BUSMOUSE_PORT, ms->irq);
/* Initialize registers. */ /* Initialize registers. */
ms->r_magic = 0x00; ms->r_magic = 0x00;
ms->r_conf = 0x91; /* 8255 controller config */ ms->r_conf = 0x00;
ms->r_ctrl = (CTRL_IDIS); ms->r_ctrl= 0x00;
/* Initialize I/O handlers. */ /* Initialize I/O handlers. */
ms->read = lt_read; ms->read = lt_read;
@@ -300,7 +341,7 @@ bm_write(uint16_t port, uint8_t val, void *priv)
{ {
mouse_bus_t *ms = (mouse_bus_t *)priv; mouse_bus_t *ms = (mouse_bus_t *)priv;
ms->write(ms, port-ms->port, val); ms->write(ms, port-BUSMOUSE_PORT, val);
} }
@@ -311,12 +352,26 @@ bm_read(uint16_t port, void *priv)
mouse_bus_t *ms = (mouse_bus_t *)priv; mouse_bus_t *ms = (mouse_bus_t *)priv;
uint8_t r; uint8_t r;
r = ms->read(ms, port-ms->port); r = ms->read(ms, port-BUSMOUSE_PORT);
return(r); return(r);
} }
/* Called at 30hz */
static void
bm_timer(void *priv)
{
mouse_bus_t *ms = (mouse_bus_t *)priv;
ms->timer += ((1000000.0 / 30.0) * TIMER_USEC);
/* All set, generate an interrupt. */
if (! (ms->r_ctrl & CTRL_IDIS))
picint(1 << ms->irq);
}
/* The emulator calls us with an update on the host mouse device. */ /* The emulator calls us with an update on the host mouse device. */
static uint8_t static uint8_t
bm_poll(int x, int y, int z, int b, void *priv) bm_poll(int x, int y, int z, int b, void *priv)
@@ -356,10 +411,11 @@ bm_poll(int x, int y, int z, int b, void *priv)
ms->but = b; ms->but = b;
#if 1
/* All set, generate an interrupt. */ /* All set, generate an interrupt. */
if (! (ms->r_ctrl & CTRL_IDIS)) if (! (ms->r_ctrl & CTRL_IDIS))
picint(1 << ms->irq); picint(1 << ms->irq);
#endif
return(0); return(0);
} }
@@ -371,7 +427,7 @@ bm_close(void *priv)
mouse_bus_t *ms = (mouse_bus_t *)priv; mouse_bus_t *ms = (mouse_bus_t *)priv;
/* Release our I/O range. */ /* Release our I/O range. */
io_removehandler(ms->port, ms->portlen, io_removehandler(BUSMOUSE_PORT, 4,
bm_read, NULL, NULL, bm_write, NULL, NULL, ms); bm_read, NULL, NULL, bm_write, NULL, NULL, ms);
free(ms); free(ms);
@@ -384,17 +440,18 @@ bm_init(mouse_t *info)
{ {
mouse_bus_t *ms; mouse_bus_t *ms;
pclog("BUSMOUSE: initializing as '%s'\n", info->name);
ms = (mouse_bus_t *)malloc(sizeof(mouse_bus_t)); ms = (mouse_bus_t *)malloc(sizeof(mouse_bus_t));
memset(ms, 0x00, sizeof(mouse_bus_t)); memset(ms, 0x00, sizeof(mouse_bus_t));
ms->name = info->name;
ms->type = info->type; ms->type = info->type;
ms->port = BUSMOUSE_PORT;
ms->portlen = BUSMOUSE_PORTLEN; #if NOTYET
#if BUSMOUSE_IRQ ms->irq = device_get_config_int("irq");
ms->irq = BUSMOUSE_IRQ;
#else #else
ms->irq = -1; ms->irq = config_get_int((char *)info->name, "irq", 0);
#endif #endif
if (ms->irq == 0)
ms->irq = BUSMOUSE_IRQ;
switch(ms->type) { switch(ms->type) {
case MOUSE_TYPE_LOGIBUS: case MOUSE_TYPE_LOGIBUS:
@@ -408,14 +465,50 @@ bm_init(mouse_t *info)
ms->flags |= MOUSE_ENABLED; ms->flags |= MOUSE_ENABLED;
/* Request an I/O range. */ /* Request an I/O range. */
io_sethandler(ms->port, ms->portlen, io_sethandler(BUSMOUSE_PORT, 4,
bm_read, NULL, NULL, bm_write, NULL, NULL, ms); bm_read, NULL, NULL, bm_write, NULL, NULL, ms);
#if 0
/* Start the mouse interrupt timer. */
timer_add(bm_timer, &ms->timer, TIMER_ALWAYS_ENABLED, ms);
#endif
/* Return our private data to the I/O layer. */ /* Return our private data to the I/O layer. */
return(ms); return(ms);
} }
#if NOTYET
static device_config_t bm_config[] = {
{
"irq", "IRQ", CONFIG_SELECTION, "", 2, {
{
"IRQ 2", 2
},
{
"IRQ 3", 3
},
{
"IRQ 4", 4
},
{
"IRQ 5", 5
},
{
""
}
},
{
"", "", -1
}
},
{
"", "", -1
}
};
#endif
mouse_t mouse_bus_logitech = { mouse_t mouse_bus_logitech = {
"Logitech Bus Mouse", "Logitech Bus Mouse",
"logibus", "logibus",

View File

@@ -8,7 +8,7 @@
# #
# Makefile for Win32 (MinGW32) environment. # Makefile for Win32 (MinGW32) environment.
# #
# Version: @(#)Makefile.mingw 1.0.79 2017/11/19 # Version: @(#)Makefile.mingw 1.0.80 2017/11/19
# #
# 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>
@@ -50,7 +50,7 @@ ifndef USB
USB := n USB := n
endif endif
ifndef VNC ifndef VNC
VNC := y VNC := n
endif endif
ifndef RDP ifndef RDP
RDP := n RDP := n
@@ -102,6 +102,7 @@ CIRRUS := y
NE1000 := y NE1000 := y
NV_RIVA := y NV_RIVA := y
PAS16 := y PAS16 := y
VNC := y
endif endif
# WxWidgets basic info. Extract using the config program. # WxWidgets basic info. Extract using the config program.

View File

@@ -8,7 +8,7 @@
* *
* user Interface module for WinAPI on Windows. * user Interface module for WinAPI on Windows.
* *
* Version: @(#)win_ui.c 1.0.2 2017/11/18 * Version: @(#)win_ui.c 1.0.3 2017/11/19
* *
* 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,14 +56,10 @@
/* Platform Public data, specific. */ /* Platform Public data, specific. */
HINSTANCE hinstance; /* application instance */
HWND hwndMain, /* application main window */ HWND hwndMain, /* application main window */
hwndRender; /* machine render window */ hwndRender; /* machine render window */
HMENU menuMain; /* application main menu */ HMENU menuMain; /* application main menu */
HANDLE ghMutex;
HICON hIcon[512]; /* icon data loaded from resources */ HICON hIcon[512]; /* icon data loaded from resources */
LCID lang_id; /* current language ID used */
DWORD dwSubLangID;
RECT oldclip; /* mouse rect */ RECT oldclip; /* mouse rect */
int infocus = 1; int infocus = 1;
@@ -72,7 +68,6 @@ WCHAR wopenfilestring[260];
/* Local data. */ /* Local data. */
//static HANDLE thMain;
static wchar_t wTitle[512]; static wchar_t wTitle[512];
static RAWINPUTDEVICE device; static RAWINPUTDEVICE device;
static HHOOK hKeyboardHook; static HHOOK hKeyboardHook;