~ubuntu-branches/ubuntu/quantal/vice/quantal

« back to all changes in this revision

Viewing changes to src/mouse.c

  • Committer: Bazaar Package Importer
  • Author(s): Zed Pobre
  • Date: 2005-03-27 13:06:04 UTC
  • mfrom: (4 hoary)
  • mto: This revision was merged to the branch mainline in revision 5.
  • Revision ID: james.westby@ubuntu.com-20050327130604-zodmv0i60dbbmcik
Tags: 1.16-3
Apply patch from Andreas Jochens <aj@andaco.de> to correct building on
AMD64 and GCC 4.x (closes: #300936)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * mouse.c - Common mouse handling
 
3
 *
 
4
 * Written by
 
5
 *  Andreas Boose <viceteam@t-online.de>
 
6
 *
 
7
 * This file is part of VICE, the Versatile Commodore Emulator.
 
8
 * See README for copyright notice.
 
9
 *
 
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.
 
14
 *
 
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.
 
19
 *
 
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
 
23
 *  02111-1307  USA.
 
24
 *
 
25
 */
 
26
 
 
27
#include "vice.h"
 
28
 
 
29
#include <stdio.h>
 
30
 
 
31
#include "cmdline.h"
 
32
#include "joystick.h"
 
33
#include "mouse.h"
 
34
#include "mousedrv.h"
 
35
#include "resources.h"
 
36
 
 
37
 
 
38
int _mouse_enabled = 0;
 
39
 
 
40
static int mouse_port;
 
41
 
 
42
 
 
43
static int set_mouse_enabled(resource_value_t v, void *param)
 
44
{
 
45
    _mouse_enabled = (int)v;
 
46
    mousedrv_mouse_changed();
 
47
    return 0;
 
48
}
 
49
 
 
50
static int set_mouse_port(resource_value_t v, void *param)
 
51
{
 
52
    mouse_port = (int)v;
 
53
 
 
54
    if ((int)v < 1 || (int)v > 2)
 
55
        return -1;
 
56
 
 
57
    mouse_port = (int)v;
 
58
 
 
59
    return 0;
 
60
}
 
61
 
 
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 },
 
67
    { NULL }
 
68
};
 
69
 
 
70
int mouse_resources_init(void)
 
71
{
 
72
    if (resources_register(resources) < 0)
 
73
        return -1;
 
74
 
 
75
    return mousedrv_resources_init();
 
76
}
 
77
 
 
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" },
 
85
    { NULL }
 
86
};
 
87
 
 
88
int mouse_cmdline_options_init(void)
 
89
{
 
90
    if (cmdline_register_options(cmdline_options) < 0)
 
91
        return -1;
 
92
 
 
93
    return mousedrv_cmdline_options_init();
 
94
}
 
95
 
 
96
void mouse_init(void)
 
97
{
 
98
    mousedrv_init();
 
99
}
 
100
 
 
101
void mouse_button_left(int pressed)
 
102
{
 
103
    if (pressed) {
 
104
        joystick_set_value_or(mouse_port, 16);
 
105
    } else {
 
106
        joystick_set_value_and(mouse_port, ~16);
 
107
    }
 
108
}
 
109
 
 
110
void mouse_button_right(int pressed)
 
111
{
 
112
    if (pressed) {
 
113
        joystick_set_value_or(mouse_port, 1);
 
114
    } else {
 
115
        joystick_set_value_and(mouse_port, ~1);
 
116
    }
 
117
}
 
118
 
 
119
BYTE mouse_get_x(void)
 
120
{
 
121
    return mousedrv_get_x();
 
122
}
 
123
 
 
124
BYTE mouse_get_y(void)
 
125
{
 
126
    return mousedrv_get_y();
 
127
}
 
128