RetroArch
hid_driver.h
Go to the documentation of this file.
1 /* RetroArch - A frontend for libretro.
2  * Copyright (C) 2010-2014 - Hans-Kristian Arntzen
3  * Copyright (C) 2011-2017 - Daniel De Matteis
4  * Copyright (C) 2016-2017 - Andrés Suárez
5  *
6  * RetroArch is free software: you can redistribute it and/or modify it under the terms
7  * of the GNU General Public License as published by the Free Software Found-
8  * ation, either version 3 of the License, or (at your option) any later version.
9  *
10  * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
11  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  * PURPOSE. See the GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along with RetroArch.
15  * If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef HID_DRIVER_H__
19 #define HID_DRIVER_H__
20 
21 #include "../connect/joypad_connection.h"
22 #include "../input_driver.h"
23 
24 /* what is 1? */
25 #define HID_REPORT_OUTPUT 2
26 #define HID_REPORT_FEATURE 3
27 /* are there more? */
28 
29 /*
30  * This is the interface for the HID subsystem.
31  *
32  * The handle parameter is the pointer returned by init() and stores the implementation
33  * state data for the HID driver.
34  */
35 
36 struct hid_driver
37 {
38  void *(*init)(void);
39  bool (*query_pad)(void *handle, unsigned pad);
40  void (*free)(const void *handle);
41  bool (*button)(void *handle, unsigned pad, uint16_t button);
42  void (*get_buttons)(void *handle, unsigned pad, input_bits_t *state);
43  int16_t (*axis)(void *handle, unsigned pad, uint32_t axis);
44  void (*poll)(void *handle);
45  bool (*set_rumble)(void *handle, unsigned pad, enum retro_rumble_effect effect, uint16_t);
46  const char *(*name)(void *handle, unsigned pad);
47  const char *ident;
48  void (*send_control)(void *handle, uint8_t *buf, size_t size);
49  int32_t (*set_report)(void *handle, uint8_t, uint8_t, void *data, uint32_t size);
50  int32_t (*set_idle)(void *handle, uint8_t amount);
51  int32_t (*set_protocol)(void *handle, uint8_t protocol);
52  int32_t (*read)(void *handle, void *buf, size_t size);
53 };
54 
55 #define HID_GET_BUTTONS(pad, state) hid_instance.os_driver->get_buttons( \
56  hid_instance.os_driver_data, pad, state)
57 #define HID_BUTTON(pad, key) hid_instance.os_driver->button( \
58  hid_instance.os_driver_data, pad, key)
59 #define HID_AXIS(pad, axis) hid_instance.os_driver->axis( \
60  hid_instance.os_driver_data, pad, axis)
61 #define HID_PAD_NAME(pad) \
62  hid_instance.os_driver->name(hid_instance.os_driver_data, pad)
63 #define HID_SET_PROTOCOL(pad, protocol) \
64  hid_instance.os_driver->set_protocol(pad, protocol)
65 #define HID_SET_REPORT(pad, rpttype, rptid, data, len) \
66  hid_instance.os_driver->set_report(pad, rpttype, rptid, data, len)
67 #define HID_SEND_CONTROL(pad, data, len) \
68  hid_instance.os_driver->send_control(pad, data, len)
69 #define HID_POLL() hid_instance.os_driver->poll( \
70  hid_instance.os_driver_data)
71 #define HID_MAX_SLOT() hid_instance.max_slot
72 #define HID_PAD_CONNECTION_PTR(slot) &(hid_instance.pad_list[(slot)])
73 
74 
75 
81  unsigned max_slot;
82 };
83 
84 #endif /* HID_DRIVER_H__ */
int32_t(* read)(void *handle, void *buf, size_t size)
Definition: hid_driver.h:52
int16_t(* axis)(void *handle, unsigned pad, uint32_t axis)
Definition: hid_driver.h:43
const char * ident
Definition: hid_driver.h:47
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:8418
bool(* button)(void *handle, unsigned pad, uint16_t button)
Definition: hid_driver.h:41
void(* send_control)(void *handle, uint8_t *buf, size_t size)
Definition: hid_driver.h:48
GLsizeiptr size
Definition: glext.h:6559
void(* free)(const void *handle)
Definition: hid_driver.h:40
typedef void(__stdcall *PFN_DESTRUCTION_CALLBACK)(void *pData)
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition: glext.h:6303
typedef bool(RETRO_CALLCONV *retro_replace_image_index_t)(unsigned index
Definition: input_types.h:25
joypad_connection_t * pad_list
Definition: hid_driver.h:80
void(* poll)(void *handle)
Definition: hid_driver.h:44
Definition: hid_driver.h:76
void * os_driver_data
Definition: hid_driver.h:78
signed short int16_t
Definition: stdint.h:122
static uint64_t state[MAX_PADS]
Definition: xenon360_input.c:33
bool(* query_pad)(void *handle, unsigned pad)
Definition: hid_driver.h:39
void(* get_buttons)(void *handle, unsigned pad, input_bits_t *state)
Definition: hid_driver.h:42
retro_rumble_effect
Definition: libretro.h:1851
signed int int32_t
Definition: stdint.h:123
Definition: joypad_connection.h:47
Definition: input_driver.h:170
int32_t(* set_report)(void *handle, uint8_t, uint8_t, void *data, uint32_t size)
Definition: hid_driver.h:49
bool(* set_rumble)(void *handle, unsigned pad, enum retro_rumble_effect effect, uint16_t)
Definition: hid_driver.h:45
input_device_driver_t * pad_driver
Definition: hid_driver.h:79
Definition: hid_driver.h:36
hid_driver_t * os_driver
Definition: hid_driver.h:77
int32_t(* set_idle)(void *handle, uint8_t amount)
Definition: hid_driver.h:50
unsigned max_slot
Definition: hid_driver.h:81
unsigned short uint16_t
Definition: stdint.h:125
unsigned char uint8_t
Definition: stdint.h:124
unsigned int uint32_t
Definition: stdint.h:126
int32_t(* set_protocol)(void *handle, uint8_t protocol)
Definition: hid_driver.h:51