RetroArch
hid.h
Go to the documentation of this file.
1 /* RetroArch - A frontend for libretro.
2  * Copyright (C) 2013-2014 - Jason Fetters
3  * Copyright (C) 2011-2017 - Daniel De Matteis
4  *
5  * RetroArch is free software: you can redistribute it and/or modify it under the terms
6  * of the GNU General Public License as published by the Free Software Found-
7  * ation, either version 3 of the License, or (at your option) any later version.
8  *
9  * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11  * PURPOSE. See the GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License along with RetroArch.
14  * If not, see <http://www.gnu.org/licenses/>.
15  */
16 
17 #ifndef __WIIU_HID__H
18 #define __WIIU_HID__H
19 
20 #include "hid_types.h"
21 #include "input.h"
22 #include "../../common/hid/hid_device_driver.h"
23 
24 #define DEVICE_UNUSED 0
25 #define DEVICE_USED 1
26 
27 /* Adapter has been detected and needs to be initialized */
28 #define ADAPTER_STATE_NEW 0
29 /* Adapter has been initialized successfully */
30 #define ADAPTER_STATE_READY 1
31 /* The read loop has been started */
32 #define ADAPTER_STATE_READING 2
33 /* The read loop is shutting down */
34 #define ADAPTER_STATE_DONE 3
35 /* The read loop has fully stopped and the adapter can be freed */
36 #define ADAPTER_STATE_GC 4
37 
38 struct wiiu_hid {
39  /* used to register for HID notifications */
41  /* thread state data for the HID input polling thread */
43  /* stack space for polling thread */
45  /* watch variable for telling the polling thread to terminate */
46  volatile bool polling_thread_quit;
47 };
48 
53 struct wiiu_adapter {
65  bool connected;
66 };
67 
73 struct wiiu_attach {
85 };
86 
90 };
91 
95 };
96 
102 extern hid_driver_t wiiu_hid;
103 
104 static void *alloc_zeroed(size_t alignment, size_t size);
105 static OSThread *new_thread(void);
106 static wiiu_hid_t *new_hid(void);
107 static void delete_hid(wiiu_hid_t *hid);
108 static void delete_hidclient(HIDClient *client);
109 static HIDClient *new_hidclient(void);
111 static void delete_adapter(wiiu_adapter_t *adapter);
114 
115 static void wiiu_hid_init_lists(void);
116 static void start_polling_thread(wiiu_hid_t *hid);
117 static void stop_polling_thread(wiiu_hid_t *hid);
118 static int wiiu_hid_polling_thread(int argc, const char **argv);
124 static void synchronized_process_adapters(wiiu_hid_t *hid);
128 static void wiiu_start_read_loop(wiiu_adapter_t *adapter);
130  uint8_t *buffer, uint32_t buffer_size, void *userdata);
131 static void wiiu_hid_polling_thread_cleanup(OSThread *thread, void *stack);
132 
133 #endif /* __WIIU_HID__H */
Definition: hid.h:92
input_device_driver_t wiiu_joypad
Definition: wiiu_joypad.c:121
uint8_t * tx_buffer
Definition: hid.h:61
static wiiu_attach_event * synchronized_get_events_list(void)
bool connected
Definition: hid.h:65
OSFastMutex lock
Definition: hid.h:88
hid_device_t * driver
Definition: hid.h:55
Definition: fastmutex.h:16
uint32_t handle
Definition: hid.h:77
GLsizeiptr size
Definition: glext.h:6559
OSFastMutex lock
Definition: hid.h:93
static void * alloc_zeroed(size_t alignment, size_t size)
Definition: wiiu_hid.c:802
uint8_t * rx_buffer
Definition: hid.h:59
static HIDClient * new_hidclient(void)
wiiu_attach_event * list
Definition: hid.h:89
static wiiu_adapter_t * synchronized_remove_from_adapters_list(uint32_t handle)
void * driver_handle
Definition: hid.h:56
uint8_t interface_index
Definition: hid.h:80
static wiiu_adapter_t * new_adapter(wiiu_attach_event *event)
input_device_driver_t kpad_driver
Definition: kpad_driver.c:260
Definition: hid.h:87
input_device_driver_t hidpad_driver
Definition: hidpad_driver.c:102
uint8_t interface_index
Definition: hid.h:64
static void wiiu_hid_read_loop_callback(uint32_t handle, int32_t error, uint8_t *buffer, uint32_t buffer_size, void *userdata)
input_device_driver_t wpad_driver
Definition: wpad_driver.c:242
uint32_t handle
Definition: hid.h:63
static wiiu_attach_event * new_attach_event(HIDDevice *device)
wiiu_hid_t * hid
Definition: hid.h:57
HIDClient * client
Definition: hid.h:40
Definition: syshid.h:26
uint32_t type
Definition: hid.h:76
wiiu_adapter_t * next
Definition: hid.h:54
static void wiiu_hid_detach(wiiu_hid_t *hid, wiiu_attach_event *event)
static void wiiu_start_read_loop(wiiu_adapter_t *adapter)
Definition: thread.h:137
Definition: input.h:62
static void synchronized_add_to_adapters_list(wiiu_adapter_t *adapter)
Definition: hid.h:73
static void delete_hidclient(HIDClient *client)
static int wiiu_hid_polling_thread(int argc, const char **argv)
hid_driver_t wiiu_hid
Definition: wiiu_hid.c:812
static l_noret error(LoadState *S, const char *why)
Definition: lundump.c:39
OSThread * polling_thread
Definition: hid.h:42
Definition: syshid.h:4
uint8_t is_mouse
Definition: hid.h:82
uint16_t max_packet_size_tx
Definition: hid.h:84
uint16_t max_packet_size_rx
Definition: hid.h:83
signed int int32_t
Definition: stdint.h:123
volatile bool polling_thread_quit
Definition: hid.h:46
uint8_t is_keyboard
Definition: hid.h:81
Definition: input_driver.h:170
static void wiiu_hid_init_lists(void)
static void wiiu_hid_attach(wiiu_hid_t *hid, wiiu_attach_event *event)
Definition: hid.h:53
wiiu_attach_event * next
Definition: hid.h:74
Definition: hid_driver.h:36
static wiiu_hid_t * new_hid(void)
Definition: hid_device_driver.h:27
wiiu_pad_functions_t pad_functions
Definition: pad_functions.c:78
uint16_t product_id
Definition: hid.h:79
static void synchronized_process_adapters(wiiu_hid_t *hid)
hid_device_t * driver
Definition: hid.h:75
uint8_t state
Definition: hid.h:58
static void synchronized_add_event(wiiu_attach_event *event)
int32_t rx_size
Definition: hid.h:60
struct _cl_event * event
Definition: glext.h:8406
static void wiiu_handle_attach_events(wiiu_hid_t *hid, wiiu_attach_event *list)
static void wiiu_hid_polling_thread_cleanup(OSThread *thread, void *stack)
Definition: hid.h:38
static void delete_attach_event(wiiu_attach_event *)
void * polling_thread_stack
Definition: hid.h:44
static void delete_hid(wiiu_hid_t *hid)
Definition: video4linux2.c:51
static void delete_adapter(wiiu_adapter_t *adapter)
static void stop_polling_thread(wiiu_hid_t *hid)
static void start_polling_thread(wiiu_hid_t *hid)
static int32_t wiiu_attach_callback(HIDClient *client, HIDDevice *device, uint32_t attach)
unsigned short uint16_t
Definition: stdint.h:125
struct nk_device device
Definition: nk_common.c:44
static OSThread * new_thread(void)
unsigned char uint8_t
Definition: stdint.h:124
unsigned int uint32_t
Definition: stdint.h:126
int32_t tx_size
Definition: hid.h:62
wiiu_adapter_t * list
Definition: hid.h:94
uint16_t vendor_id
Definition: hid.h:78