27
28
#include "mousedrv.h"
29
#include "resources.h"
30
#include "translate.h"
28
31
#include "vicemachine.h"
31
34
extern int _mouse_enabled;
32
static int ptr_x=0,ptr_y=0;
33
static int hw_x=0,hw_y=0;
36
static BOOL firstMove;
45
static int set_scale_x(int val, void *param)
50
static int set_scale_y(int val, void *param)
55
static resource_int_t resources_int[] =
57
{ "MouseScaleX", 4, RES_EVENT_NO, NULL,
58
&scaleX, set_scale_x, NULL },
59
{ "MouseScaleY", 4, RES_EVENT_NO, NULL,
60
&scaleY, set_scale_y, NULL },
35
64
int mousedrv_resources_init(void)
66
return resources_register_int(resources_int);
69
static const cmdline_option_t cmdline_options[] = {
70
{ "-mousescalex", SET_RESOURCE, 1,
71
NULL, NULL, "MouseScaleX", NULL,
72
USE_PARAM_STRING, USE_DESCRIPTION_STRING,
73
IDCLS_UNUSED, IDCLS_UNUSED,
74
"<1-8>", T_("Set scaling factor for mouse movement along X") },
75
{ "-mousescaley", SET_RESOURCE, 1,
76
NULL, NULL, "MouseScaleY", NULL,
77
USE_PARAM_STRING, USE_DESCRIPTION_STRING,
78
IDCLS_UNUSED, IDCLS_UNUSED,
79
"<1-8>", T_("Set scaling factor for mouse movement along Y") },
40
83
int mousedrv_cmdline_options_init(void)
85
return cmdline_register_options(cmdline_options);
45
88
void mousedrv_init(void)
49
92
void mousedrv_mouse_changed(void)
51
94
[[theVICEMachine machineNotifier] postToggleMouseNotification:_mouse_enabled];
54
101
#define MAX_DELTA 16
103
// the HW polls the position
56
104
BYTE mousedrv_get_x(void)
58
int dx = ptr_x - hw_x;
61
else if(dx > MAX_DELTA)
64
return (BYTE)((hw_x&0x3f) << 1);
106
int delta = pointerX - emuX;
108
if (delta > MAX_DELTA) {
111
else if (delta < -MAX_DELTA) {
116
return (BYTE)((emuX & 63) << 1) & 0x7e;
67
119
BYTE mousedrv_get_y(void)
69
int dy = ptr_y - hw_y;
72
else if(dy > MAX_DELTA)
75
return (BYTE)((hw_y&0x3f) << 1);
121
int delta = pointerY - emuY;
123
if (delta > MAX_DELTA) {
126
else if (delta < -MAX_DELTA) {
131
return (BYTE)((emuY & 63) << 1) & 0x7e;
78
134
void mouse_move(int x, int y)
136
pointerX = x * scaleX;
137
pointerY = y * scaleY;