~ubuntu-branches/ubuntu/trusty/vice/trusty-proposed

1.1.5 by Laszlo Boszormenyi (GCS)
Import upstream version 1.22
1
/*
2
 * mousedrv.m - MacVICE mouse driver
3
 *
4
 * Written by
5
 *  Christian Vogelgsang <chris@vogelgsang.org>
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 "mousedrv.h"
28
#include "vicemachine.h"
29
30
// mouse.c
31
extern int _mouse_enabled;
32
static int ptr_x=0,ptr_y=0;
33
static int hw_x=0,hw_y=0;
34
35
int mousedrv_resources_init(void)
36
{
37
    return 0;
38
}
39
40
int mousedrv_cmdline_options_init(void)
41
{
42
    return 0;
43
}
44
45
void mousedrv_init(void)
46
{
47
}
48
49
void mousedrv_mouse_changed(void)
50
{
51
    [[theVICEMachine machineNotifier] postToggleMouseNotification:_mouse_enabled];
52
}
53
54
#define MAX_DELTA  16
55
56
BYTE mousedrv_get_x(void)
57
{
58
    int dx = ptr_x - hw_x;
59
    if(dx < -MAX_DELTA)
60
        dx = -MAX_DELTA;
61
    else if(dx > MAX_DELTA)
62
        dx = MAX_DELTA;
63
    hw_x += dx;
64
    return (BYTE)((hw_x&0x3f) << 1);
65
}
66
67
BYTE mousedrv_get_y(void)
68
{
69
    int dy = ptr_y - hw_y;
70
    if(dy < -MAX_DELTA)
71
        dy = -MAX_DELTA;
72
    else if(dy > MAX_DELTA)
73
        dy = MAX_DELTA;
74
    hw_y += dy;
75
    return (BYTE)((hw_y&0x3f) << 1);
76
}
77
78
void mouse_move(int x, int y)
79
{
80
    ptr_x = x;
81
    ptr_y = y;
82
}