2
* joy.h - Joystick support for Mac OS X.
5
* Christian Vogelgsang <chris@vogelgsang.org>
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
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
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
45
#define JOYSTICK_DESCRIPTOR_MAX_BUTTONS 32
46
#define JOYSTICK_DESCRIPTOR_MAX_AXIS 6
49
#define HID_ALT_FIRE 1
54
#define HID_NUM_BUTTONS 6
56
/* virtual joystick mapping */
57
extern int joystick_port_map[2];
62
typedef void * pRecDevice;
63
typedef void * pRecElement;
65
/* NOTE: We use the HID Utilites Library provided by Apple for free
67
http://developer.apple.com/samplecode/HID_Utilities_Source/index.html
69
Make sure to install this (static) library first!
71
#include <Carbon/Carbon.h>
72
#include <IOKit/hid/IOHIDKeys.h>
73
#include <IOKit/hid/IOHIDUsageTables.h>
74
#include "HID_Utilities_External.h"
83
typedef struct axis_map axis_map_t;
85
extern axis_map_t joy_axis_map[];
87
/* calibration data for an axis */
93
typedef struct calibration calibration_t;
95
/* describe a joystick HID device */
96
struct joystick_descriptor
98
/* resources/settings for joystick */
99
char *device_name; /* device name: vid:pid:num */
101
char *x_axis_name; /* set x axis */
102
char *y_axis_name; /* sety y axis */
104
char *button_mapping; /* set button mapping */
108
/* filled in from HID utils after setup */
114
pRecElement mapped_buttons[HID_NUM_BUTTONS];
116
/* fill list of all buttons and axis */
118
pRecElement buttons[JOYSTICK_DESCRIPTOR_MAX_BUTTONS];
120
pRecElement axis[JOYSTICK_DESCRIPTOR_MAX_AXIS];
123
calibration_t x_calib;
124
calibration_t y_calib;
126
typedef struct joystick_descriptor joystick_descriptor_t;
128
/* access HID joystick A,B */
129
extern joystick_descriptor_t joy_a;
130
extern joystick_descriptor_t joy_b;
133
extern int joy_arch_init(void);
134
extern void joystick_close(void);
135
extern void joystick(void);
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);
145
extern int detect_axis(joystick_descriptor_t *joy,int x_axis);
147
extern int detect_button(joystick_descriptor_t *joy);
149
extern const char *find_axis_name(int tag);