~ubuntu-branches/ubuntu/dapper/vice/dapper

« back to all changes in this revision

Viewing changes to src/arch/unix/mouse.h

  • Committer: Bazaar Package Importer
  • Author(s): Zed Pobre
  • Date: 2004-08-26 13:35:51 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040826133551-gcje8j31q5cqgdq2
Tags: 1.14-3
Apply patch from Spiro Trikaliotis <vice@trikaliotis.net> to fix a
problem that some users were experiencing with a floating point
exception on startup related to the fullscreen option being enabled
during compile.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * mouse.h - Mouse handling for Unix-Systems.
3
 
 *
4
 
 * Written by
5
 
 *  Oliver Schaertel <orschaer@forwiss.uni-erlangen.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., 675 Mass Ave, Cambridge, MA 02139, USA.
23
 
 *
24
 
 */
25
 
 
26
 
#ifndef _MOUSE_H
27
 
#define _MOUSE_H
28
 
 
29
 
 
30
 
#include "types.h"
31
 
 
32
 
extern int mouse_resources_init(void);
33
 
extern int mouse_cmdline_options_init(void);
34
 
extern int mouse_init(void);
35
 
extern void mouse_button(int bnumber, int state);
36
 
 
37
 
 
38
 
extern int _mouse_enabled;
39
 
extern int mouse_x, mouse_y;
40
 
extern int mouse_accel;
41
 
 
42
 
/* ------------------------------------------------------------------------- */
43
 
 
44
 
inline static BYTE mouse_get_x(void)
45
 
{
46
 
    static int last_mouse_x=0; 
47
 
 
48
 
    if(last_mouse_x - mouse_x > 16) {
49
 
      last_mouse_x -= 16;
50
 
      return (BYTE) ((last_mouse_x * mouse_accel) >> 1) & 0x7e;
51
 
    }
52
 
    if(last_mouse_x - mouse_x < -16) {
53
 
      last_mouse_x += 16;
54
 
      return (BYTE) ((last_mouse_x * mouse_accel) >> 1) & 0x7e;
55
 
    }
56
 
    last_mouse_x = mouse_x;
57
 
    return (BYTE) ((last_mouse_x * mouse_accel) >> 1) & 0x7e;
58
 
}
59
 
 
60
 
inline static BYTE mouse_get_y(void)
61
 
{
62
 
    static int last_mouse_y=0; 
63
 
 
64
 
    if(last_mouse_y - mouse_y > 16) {
65
 
      last_mouse_y -= 16;
66
 
      return (BYTE) ((last_mouse_y * mouse_accel) >> 1) & 0x7e;
67
 
    } 
68
 
    if(last_mouse_y - mouse_y < -16) {
69
 
      last_mouse_y += 16;
70
 
      return (BYTE) ((last_mouse_y * mouse_accel) >> 1) & 0x7e;
71
 
    }
72
 
    last_mouse_y = mouse_y;
73
 
    return (BYTE) ((last_mouse_y * mouse_accel) >> 1) & 0x7e;
74
 
}
75
 
 
76
 
inline static void mouse_move(int x, int y)
77
 
{
78
 
 
79
 
    if (! _mouse_enabled) return;
80
 
 
81
 
    mouse_x = x;
82
 
    mouse_y = 256 - y;
83
 
}
84
 
 
85
 
#endif