1 /** \file joy-osx-hid.h 2 * \brief Joystick support for Mac OS X using USB HID devices - header 3 * 4 * \author Christian Vogelgsang <chris@vogelgsang.org> 5 */ 6 7 /* 8 * This file is part of VICE, the Versatile Commodore Emulator. 9 * See README for copyright notice. 10 * 11 * This program is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation; either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program; if not, write to the Free Software 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 24 * 02111-1307 USA. 25 * 26 */ 27 28 #ifndef VICE_JOY_OSX_HID_H 29 #define VICE_JOY_OSX_HID_H 30 31 #include "vice.h" 32 33 #ifdef HAS_JOYSTICK 34 35 #include "joy-osx-hidlib.h" 36 37 /* axis map: define names of available axis on a HID device */ 38 struct joy_hid_axis_info { 39 const char *name; 40 int usage; 41 }; 42 typedef struct joy_hid_axis_info joy_hid_axis_info_t; 43 44 /* public list of axis names */ 45 joy_hid_axis_info_t joy_hid_axis_infos[]; 46 47 /* describe the HID specific parts of the joystick */ 48 struct joy_hid_descriptor { 49 joy_hid_device_ptr_t device; /* what HID device is mapped to this joy */ 50 51 joy_hid_element_ptr_t mapped_axis[HID_NUM_AXIS]; 52 joy_hid_element_ptr_t mapped_buttons[HID_TOTAL_BUTTONS]; 53 joy_hid_element_ptr_t mapped_hat_switch; 54 55 joy_hid_element_ptr_t all_buttons[JOYSTICK_DESCRIPTOR_MAX_BUTTONS]; 56 joy_hid_element_ptr_t all_axis[JOYSTICK_DESCRIPTOR_MAX_AXIS]; 57 joy_hid_element_ptr_t all_hat_switches[JOYSTICK_DESCRIPTOR_MAX_HAT_SWITCHES]; 58 }; 59 typedef struct joy_hid_descriptor joy_hid_descriptor_t; 60 61 struct joystick_descriptor; 62 63 /* ----- API ----- */ 64 65 int joy_hid_init(void); /* return number of total devices found. <0 error */ 66 void joy_hid_exit(void); 67 int joy_hid_reload(void); /* return number of total device found. <0 error */ 68 const joy_hid_device_array_t *joy_hid_get_devices(void); 69 70 /* device functions */ 71 int joy_hid_map_device(struct joystick_descriptor *joy, joy_hid_device_t *device); 72 void joy_hid_unmap_device(struct joystick_descriptor *joy); 73 74 /* axis functions */ 75 int joy_hid_reset_axis_range(struct joystick_descriptor *joy, int id, int usage, int logical); 76 int joy_hid_assign_axis(struct joystick_descriptor *joy, int id, int usage, int logical); 77 int joy_hid_detect_axis(struct joystick_descriptor *joy, int id, int logical); 78 int joy_hid_read_axis(struct joystick_descriptor *joy,int id,int *value, int logical); 79 int joy_hid_info_axis(struct joystick_descriptor *joy,int id,int *min, int *max, int logical); 80 81 /* button functions */ 82 int joy_hid_assign_button(struct joystick_descriptor *joy, int id, int usage); 83 int joy_hid_detect_button(struct joystick_descriptor *joy); 84 int joy_hid_read_button(struct joystick_descriptor *joy, int id, int *value); 85 86 /* hat switch functions */ 87 int joy_hid_assign_hat_switch(struct joystick_descriptor *joy, int serial); 88 int joy_hid_detect_hat_switch(struct joystick_descriptor *joy); 89 int joy_hid_read_hat_switch(struct joystick_descriptor *joy, int *value); 90 91 /* axis map functions */ 92 const char *joy_hid_get_axis_name(int usage); 93 int joy_hid_get_axis_usage(const char *name); 94 95 #endif 96 #endif 97