2
* mousedrv.c - Mouse handling for OS/2
5
* Thomas Bretz <tbretz@uni-sw.gwdg.de>
7
* This file is part of VICE, the Versatile Commodore Emulator.
8
* See README for copyright notice.
10
* This program is free software; you can redistribute it and/or modify
11
* it under the terms of the GNU General Public License as published by
12
* the Free Software Foundation; either version 2 of the License, or
13
* (at your option) any later version.
15
* This program is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU General Public License for more details.
20
* You should have received a copy of the GNU General Public License
21
* along with this program; if not, write to the Free Software
22
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27
#define INCL_WINPOINTERS
33
#include "resources.h"
36
static int hide_mouseptr;
37
static int visible=TRUE;
38
static SHORT _mouse_x, _mouse_y; // [-32768, 32768]
40
/* ----------------------------------------------------------- */
42
void mousedrv_mouse_changed(void)
44
/* -- FIXME: rash while startup --
46
mouse_button_right(0);
50
static int set_hide_mouseptr(resource_value_t v, void *param)
52
hide_mouseptr = (int) v;
53
if (!hide_mouseptr && !visible && !FullscreenIsNow())
54
{ // do we have to show the ptr again?
55
WinSetCapture(HWND_DESKTOP, NULLHANDLE);
56
WinShowPointer(HWND_DESKTOP, TRUE);
62
static const resource_t resources[] = {
63
{ "HideMousePtr", RES_INTEGER, (resource_value_t)0,
64
(void *)&hide_mouseptr, set_hide_mouseptr, NULL },
68
int mousedrv_resources_init(void)
70
return resources_register(resources);
73
/* ----------------------------------------------------------- */
75
static const cmdline_option_t cmdline_options[] = {
76
{ "-hidemouseptr", SET_RESOURCE, 0, NULL, NULL,
77
"HideMousePtr", (resource_value_t) 1, NULL,
78
"Enable hiding of mouse pointer inside the window" },
79
{ "+hidemouseptr", SET_RESOURCE, 0, NULL, NULL,
80
"HideMousePtr", (resource_value_t) 0, NULL,
81
"Disable hiding of mouse pointer inside the window" },
85
int mousedrv_cmdline_options_init(void)
87
return cmdline_register_options(cmdline_options);
90
void mousedrv_init(void)
94
const int mouse_step = 15;
96
extern int stretch; // video.c
98
inline BYTE mousedrv_get_x(void)
100
static SHORT last_mouse_x=0;
102
const SHORT diff = last_mouse_x - _mouse_x;
105
* The problem is that if you click somewhere and your pointer
106
* is outside the window you would click something at the desktop
109
* APIRET rc=WinQueryPointerPos(HWND_DESKTOP, &ptl);
114
if (diff > mouse_step)
115
last_mouse_x -= mouse_step;
117
if(diff < -mouse_step)
118
last_mouse_x += mouse_step;
120
last_mouse_x = _mouse_x;
122
return ((last_mouse_x/stretch)
129
inline BYTE mousedrv_get_y(void)
131
static SHORT last_mouse_y=0;
133
const SHORT diff = last_mouse_y - _mouse_y;
136
* The problem is that if you click somewhere and your pointer
137
* is outside the window you would click something at the desktop
140
* APIRET rc=WinQueryPointerPos(HWND_DESKTOP, &ptl);
145
if (diff > mouse_step)
146
last_mouse_y -= mouse_step;
148
if(diff < -mouse_step)
149
last_mouse_y += mouse_step;
151
last_mouse_y = _mouse_y;
153
return ((last_mouse_y/stretch)<<1)&0x7e;
156
/* ----------------- OS/2 specific ------------------------- */
158
void mouse_button(HWND hwnd, ULONG msg, MPARAM mp1)
166
_mouse_x = SHORT1FROMMP(mp1);
167
_mouse_y = SHORT2FROMMP(mp1);
170
WinQueryWindowPos(hwnd, &swp);
172
// check whether the pointer is outside or inside the window
175
if (FullscreenIsNow())
178
if (_mouse_x>=0 && _mouse_x<swp.cx &&
179
_mouse_y>=0 && _mouse_y<swp.cy)
182
// FIXME: Don't capture the mouse pointer if it is in front
183
// of a client dialog!
185
if (WinQueryCapture(HWND_DESKTOP)!=hwnd && hide_mouseptr && !FullscreenIsNow())
186
WinSetCapture(HWND_DESKTOP, hwnd);
188
if (visible && /*_mouse_enabled &&*/ hide_mouseptr &&
191
WinShowPointer(HWND_DESKTOP, FALSE);
197
if (WinQueryCapture(HWND_DESKTOP)==hwnd && !FullscreenIsNow())
198
WinSetCapture(HWND_DESKTOP, NULLHANDLE);
200
if (!visible && !FullscreenIsNow())
202
WinShowPointer(HWND_DESKTOP, TRUE);
207
// don't use 'outside'-values which appears one times
208
// if the mouse pointer leaves the window
210
if (_mouse_x<0) _mouse_x=0;
212
if (_mouse_x>=swp.cx)
215
if (_mouse_y<0) _mouse_y=0;
217
if (_mouse_y>=swp.cy)
223
mouse_button_left(1);
226
mouse_button_left(0);
229
mouse_button_right(1);
232
mouse_button_right(0);