2
* mouse.c - Common mouse handling
5
* Andreas Boose <viceteam@t-online.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., 59 Temple Place, Suite 330, Boston, MA
35
#include "resources.h"
38
int _mouse_enabled = 0;
40
static int mouse_port;
43
static int set_mouse_enabled(resource_value_t v, void *param)
45
_mouse_enabled = (int)v;
46
mousedrv_mouse_changed();
50
static int set_mouse_port(resource_value_t v, void *param)
54
if ((int)v < 1 || (int)v > 2)
62
static const resource_t resources[] = {
63
{ "Mouse", RES_INTEGER, (resource_value_t)0,
64
(void *)&_mouse_enabled, set_mouse_enabled, NULL },
65
{ "Mouseport", RES_INTEGER, (resource_value_t)1,
66
(void *)&mouse_port, set_mouse_port, NULL },
70
int mouse_resources_init(void)
72
if (resources_register(resources) < 0)
75
return mousedrv_resources_init();
78
static const cmdline_option_t cmdline_options[] = {
79
{ "-mouse", SET_RESOURCE, 1, NULL, NULL,
80
"Mouse", NULL, NULL, N_("Enable emulation of the 1351 proportional mouse") },
81
{ "+mouse", SET_RESOURCE, 0, NULL, NULL,
82
"Mouse", NULL, NULL, N_("Disable emulation of the 1351 proportional mouse") },
83
{ "-mouseport", SET_RESOURCE, 1, NULL, NULL,
84
"Mouseport", NULL, "<value>", "Select the joystick port the mouse is attached to" },
88
int mouse_cmdline_options_init(void)
90
if (cmdline_register_options(cmdline_options) < 0)
93
return mousedrv_cmdline_options_init();
101
void mouse_button_left(int pressed)
104
joystick_set_value_or(mouse_port, 16);
106
joystick_set_value_and(mouse_port, ~16);
110
void mouse_button_right(int pressed)
113
joystick_set_value_or(mouse_port, 1);
115
joystick_set_value_and(mouse_port, ~1);
119
BYTE mouse_get_x(void)
121
return mousedrv_get_x();
124
BYTE mouse_get_y(void)
126
return mousedrv_get_y();