~ubuntu-branches/ubuntu/raring/vice/raring

« back to all changes in this revision

Viewing changes to src/arch/unix/macosx/joy.h

  • Committer: Bazaar Package Importer
  • Author(s): Laszlo Boszormenyi (GCS)
  • Date: 2009-03-31 00:37:15 UTC
  • mfrom: (1.2.2 upstream)
  • mto: This revision was merged to the branch mainline in revision 17.
  • Revision ID: james.westby@ubuntu.com-20090331003715-mzclchtl0dp7fcl0
Tags: upstream-2.1.dfsg
ImportĀ upstreamĀ versionĀ 2.1.dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * joy.h - Joystick support for Mac OS X.
 
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
#ifndef _JOY_H
 
28
#define _JOY_H
 
29
 
 
30
#define JOYDEV_NONE         0
 
31
#define JOYDEV_NUMPAD       1
 
32
#define JOYDEV_KEYSET1      2
 
33
#define JOYDEV_KEYSET2      3
 
34
#define JOYDEV_HID_0        4
 
35
#define JOYDEV_HID_1        5
 
36
 
 
37
/* obsolete fallbacks for X11/Gtk */
 
38
#define JOYDEV_ANALOG_0     4
 
39
#define JOYDEV_ANALOG_1     5
 
40
#define JOYDEV_ANALOG_2     6
 
41
#define JOYDEV_ANALOG_3     7
 
42
#define JOYDEV_ANALOG_4     8
 
43
#define JOYDEV_ANALOG_5     9
 
44
 
 
45
#define JOYSTICK_DESCRIPTOR_MAX_BUTTONS  32
 
46
#define JOYSTICK_DESCRIPTOR_MAX_AXIS     6
 
47
 
 
48
#define HID_FIRE        0
 
49
#define HID_ALT_FIRE    1
 
50
#define HID_LEFT        2
 
51
#define HID_RIGHT       3
 
52
#define HID_UP          4
 
53
#define HID_DOWN        5
 
54
#define HID_NUM_BUTTONS 6
 
55
 
 
56
/* virtual joystick mapping */ 
 
57
extern int joystick_port_map[2];
 
58
 
 
59
#ifdef HAS_JOYSTICK
 
60
 
 
61
#ifndef JOY_INTERNAL
 
62
typedef void * pRecDevice;
 
63
typedef void * pRecElement;
 
64
#else
 
65
/* NOTE: We use the HID Utilites Library provided by Apple for free
 
66
 
 
67
   http://developer.apple.com/samplecode/HID_Utilities_Source/index.html
 
68
 
 
69
   Make sure to install this (static) library first!
 
70
*/
 
71
#include <Carbon/Carbon.h>
 
72
#include <IOKit/hid/IOHIDKeys.h>
 
73
#include <IOKit/hid/IOHIDUsageTables.h>
 
74
#include "HID_Utilities_External.h"
 
75
#endif
 
76
 
 
77
/* axis map */
 
78
struct axis_map
 
79
{
 
80
  const char *name;
 
81
  int tag;
 
82
};
 
83
typedef struct axis_map axis_map_t;
 
84
 
 
85
extern axis_map_t joy_axis_map[];
 
86
 
 
87
/* calibration data for an axis */
 
88
struct calibration
 
89
{
 
90
  int  min_threshold;
 
91
  int  max_threshold;
 
92
};
 
93
typedef struct calibration calibration_t;
 
94
 
 
95
/* describe a joystick HID device */
 
96
struct joystick_descriptor 
 
97
{
 
98
  /* resources/settings for joystick */
 
99
  char         *device_name;      /* device name: vid:pid:num */
 
100
  
 
101
  char         *x_axis_name;      /* set x axis */
 
102
  char         *y_axis_name;      /* sety y axis */
 
103
    
 
104
  char         *button_mapping;   /* set button mapping */
 
105
  int          x_threshold;
 
106
  int          y_threshold;
 
107
  
 
108
  /* filled in from HID utils after setup */
 
109
  pRecDevice   device;
 
110
  
 
111
  pRecElement  x_axis;
 
112
  pRecElement  y_axis;
 
113
  
 
114
  pRecElement  mapped_buttons[HID_NUM_BUTTONS];
 
115
  
 
116
  /* fill list of all buttons and axis */
 
117
  int          num_buttons;
 
118
  pRecElement  buttons[JOYSTICK_DESCRIPTOR_MAX_BUTTONS];
 
119
  int          num_axis;
 
120
  pRecElement  axis[JOYSTICK_DESCRIPTOR_MAX_AXIS];
 
121
  
 
122
  /* calibration */
 
123
  calibration_t x_calib;
 
124
  calibration_t y_calib;
 
125
};
 
126
typedef struct joystick_descriptor joystick_descriptor_t;
 
127
 
 
128
/* access HID joystick A,B */
 
129
extern joystick_descriptor_t joy_a;
 
130
extern joystick_descriptor_t joy_b;
 
131
 
 
132
/* functions */
 
133
extern int joy_arch_init(void);
 
134
extern void joystick_close(void);
 
135
extern void joystick(void);
 
136
 
 
137
/* reload device list */
 
138
extern void reload_device_list(void);
 
139
/* build device list */
 
140
extern int build_device_list(pRecDevice **devices);
 
141
/* get serial of device */
 
142
extern int get_device_serial(pRecDevice last_device);
 
143
 
 
144
/* detect axis */
 
145
extern int detect_axis(joystick_descriptor_t *joy,int x_axis);
 
146
/* detect button */
 
147
extern int detect_button(joystick_descriptor_t *joy);
 
148
/* find axis name */
 
149
extern const char *find_axis_name(int tag);
 
150
 
 
151
#endif
 
152
 
 
153
#endif
 
154