This commit is contained in:
OBattler
2017-10-24 04:15:32 +02:00
12 changed files with 801 additions and 195 deletions

View File

@@ -8,7 +8,7 @@
#
# Makefile for Win32 (MinGW32) environment.
#
# Version: @(#)Makefile.mingw 1.0.65 2017/10/19
# Version: @(#)Makefile.mingw 1.0.66 2017/10/22
#
# Authors: Miran Grca, <mgrca8@gmail.com>
# Fred N. van Kempen, <decwiz@yahoo.com>
@@ -210,7 +210,7 @@ RFLAGS += -DUSE_VNC
VNCLIB := -L$(VNC_PATH)\LIB
endif
VNCLIB += -lvncserver
VNCOBJ := vnc.o
VNCOBJ := vnc.o vnc_keymap.o
endif
ifeq ($(RDP), y)

View File

@@ -8,7 +8,7 @@
*
* The Emulator's Windows core.
*
* Version: @(#)win.c 1.0.27 2017/10/18
* Version: @(#)win.c 1.0.28 2017/10/22
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
@@ -136,10 +136,10 @@ win_menu_update(void)
static void
releasemouse(void)
{
if (mousecapture) {
if (mouse_capture) {
ClipCursor(&oldclip);
ShowCursor(TRUE);
mousecapture = 0;
mouse_capture = 0;
}
}
@@ -617,12 +617,12 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
break;
case WM_LBUTTONUP:
if (!mousecapture && !video_fullscreen) {
if (!mouse_capture && !video_fullscreen) {
GetClipCursor(&oldclip);
GetWindowRect(hwndRender, &rect);
ClipCursor(&rect);
mousecapture = 1;
mouse_capture = 1;
while (1) {
if (ShowCursor(FALSE) < 0) break;
}
@@ -646,7 +646,7 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
plat_resize(scrnsz_x, scrnsz_y);
if (mousecapture) {
if (mouse_capture) {
GetWindowRect(hwndRender, &rect);
ClipCursor(&rect);
@@ -1098,10 +1098,10 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpszArg, int nFunsterStil)
DispatchMessage(&messages);
}
if (mousecapture && recv_key[0x58] && recv_key[0x42]) {
if (mouse_capture && recv_key[0x58] && recv_key[0x42]) {
ClipCursor(&oldclip);
ShowCursor(TRUE);
mousecapture = 0;
mouse_capture = 0;
}
if (video_fullscreen &&
@@ -1115,7 +1115,7 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpszArg, int nFunsterStil)
timeEndPeriod(1);
if (mousecapture) {
if (mouse_capture) {
ClipCursor(&oldclip);
ShowCursor(TRUE);
}

View File

@@ -8,7 +8,7 @@
*
* Mouse interface to host device.
*
* Version: @(#)win_mouse.cc 1.0.4 2017/10/12
* Version: @(#)win_mouse.cc 1.0.5 2017/10/22
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
@@ -20,80 +20,85 @@
#include <dinput.h>
#include <stdio.h>
#include <stdint.h>
#include "../86Box.h"
#include "../mouse.h"
#include "../plat.h"
#include "../plat_mouse.h"
#include "win.h"
extern "C" int video_fullscreen;
extern "C" void fatal(const char *format, ...);
extern "C" void pclog(const char *format, ...);
extern "C" void mouse_init(void);
extern "C" void mouse_close(void);
extern "C" void mouse_poll_host(void);
extern "C" void mouse_get_mickeys(int *x, int *y, int *z);
int mouse_capture;
static LPDIRECTINPUT8 lpdi;
static LPDIRECTINPUTDEVICE8 lpdi_mouse = NULL;
static DIMOUSESTATE mousestate;
static int mouse_x = 0, mouse_y = 0, mouse_z = 0;
int mouse_buttons = 0;
void mouse_init(void)
void
mouse_init(void)
{
atexit(mouse_close);
atexit(mouse_close);
if (FAILED(DirectInput8Create(hinstance, DIRECTINPUT_VERSION, IID_IDirectInput8A, (void **) &lpdi, NULL)))
fatal("mouse_init : DirectInputCreate failed\n");
if (FAILED(lpdi->CreateDevice(GUID_SysMouse, &lpdi_mouse, NULL)))
fatal("mouse_init : CreateDevice failed\n");
if (FAILED(lpdi_mouse->SetCooperativeLevel(hwndMain, DISCL_FOREGROUND | (video_fullscreen ? DISCL_EXCLUSIVE : DISCL_NONEXCLUSIVE))))
fatal("mouse_init : SetCooperativeLevel failed\n");
if (FAILED(lpdi_mouse->SetDataFormat(&c_dfDIMouse)))
fatal("mouse_init : SetDataFormat failed\n");
mouse_capture = 0;
if (FAILED(DirectInput8Create(hinstance, DIRECTINPUT_VERSION,
IID_IDirectInput8A, (void **) &lpdi, NULL)))
fatal("mouse_init : DirectInputCreate failed\n");
if (FAILED(lpdi->CreateDevice(GUID_SysMouse, &lpdi_mouse, NULL)))
fatal("mouse_init : CreateDevice failed\n");
if (FAILED(lpdi_mouse->SetCooperativeLevel(hwndMain,
DISCL_FOREGROUND | (video_fullscreen ? DISCL_EXCLUSIVE : DISCL_NONEXCLUSIVE))))
fatal("mouse_init : SetCooperativeLevel failed\n");
if (FAILED(lpdi_mouse->SetDataFormat(&c_dfDIMouse)))
fatal("mouse_init : SetDataFormat failed\n");
}
void mouse_close(void)
void
mouse_close(void)
{
if (lpdi_mouse)
{
lpdi_mouse->Release();
lpdi_mouse = NULL;
}
if (lpdi_mouse) {
lpdi_mouse->Release();
lpdi_mouse = NULL;
}
}
void mouse_poll_host(void)
void
mouse_poll_host(void)
{
if (FAILED(lpdi_mouse->GetDeviceState(sizeof(DIMOUSESTATE), (LPVOID)&mousestate)))
{
lpdi_mouse->Acquire();
lpdi_mouse->GetDeviceState(sizeof(DIMOUSESTATE), (LPVOID)&mousestate);
}
mouse_buttons = 0;
if (mousestate.rgbButtons[0] & 0x80)
mouse_buttons |= 1;
if (mousestate.rgbButtons[1] & 0x80)
mouse_buttons |= 2;
if (mousestate.rgbButtons[2] & 0x80)
mouse_buttons |= 4;
mouse_x += mousestate.lX;
mouse_y += mousestate.lY;
mouse_z += mousestate.lZ/120;
if (!mousecapture && !video_fullscreen)
mouse_x = mouse_y = mouse_buttons = 0;
}
static int buttons = 0;
static int x = 0, y = 0, z = 0;
int b;
if (FAILED(lpdi_mouse->GetDeviceState(sizeof(DIMOUSESTATE),
(LPVOID)&mousestate))) {
lpdi_mouse->Acquire();
lpdi_mouse->GetDeviceState(sizeof(DIMOUSESTATE), (LPVOID)&mousestate);
}
void mouse_get_mickeys(int *x, int *y, int *z)
{
*x = mouse_x;
*y = mouse_y;
*z = mouse_z;
mouse_x = mouse_y = mouse_z = 0;
if (mouse_capture || video_fullscreen) {
if (x != mousestate.lX || y != mousestate.lY || z != mousestate.lZ) {
mouse_x += mousestate.lX;
mouse_y += mousestate.lY;
mouse_z += mousestate.lZ/120;
x = mousestate.lX;
y = mousestate.lY;
z = mousestate.lZ/120;
}
b = 0;
if (mousestate.rgbButtons[0] & 0x80) b |= 1;
if (mousestate.rgbButtons[1] & 0x80) b |= 2;
if (mousestate.rgbButtons[2] & 0x80) b |= 4;
if (buttons != b) {
mouse_buttons = b;
buttons = b;
}
}
}

View File

@@ -8,7 +8,7 @@
*
* Platform video API support for Win32.
*
* Version: @(#)win_video.c 1.0.1 2017/10/18
* Version: @(#)win_video.c 1.0.2 2017/10/22
*
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
*
@@ -29,6 +29,7 @@
#include "../86box.h"
#include "../config.h"
#include "../device.h"
#include "../mouse.h"
#include "../video/video.h"
#include "../plat.h"
#include "../plat_mouse.h"
@@ -300,7 +301,7 @@ pclog("PLAT: VID[%d,%d] resizing to %dx%d\n", video_fullscreen, vid_api, x, y);
y + (GetSystemMetrics(SM_CYEDGE) * 2) + (GetSystemMetrics(vid_resize ? SM_CYSIZEFRAME : SM_CYFIXEDFRAME) * 2) + GetSystemMetrics(SM_CYMENUSIZE) + GetSystemMetrics(SM_CYCAPTION) + 17 + sb_borders[1] + 1,
TRUE);
if (mousecapture) {
if (mouse_capture) {
GetWindowRect(hwndRender, &r);
ClipCursor(&r);
}