diff --git a/input/common/hid/hid_device_driver.c b/input/common/hid/hid_device_driver.c
index 587f0dc33d..3792e2c737 100644
--- a/input/common/hid/hid_device_driver.c
+++ b/input/common/hid/hid_device_driver.c
@@ -76,7 +76,7 @@ bool hid_init(hid_driver_instance_t *instance,
return false;
RARCH_LOG("[hid]: initializing HID subsystem driver...\n");
- instance->os_driver_data = hid_driver->init(instance);
+ instance->os_driver_data = hid_driver->init();
if(!instance->os_driver_data)
return false;
@@ -122,39 +122,3 @@ void hid_deinit(hid_driver_instance_t *instance)
RARCH_LOG("[hid]: wiping instance data...\n");
memset(instance, 0, sizeof(hid_driver_instance_t));
}
-
-static void hid_device_log_buffer(uint8_t *data, uint32_t len)
-{
-#if 0
- int i, offset;
- int padding = len % 0x0F;
- uint8_t buf[16];
-
- RARCH_LOG("%d bytes read:\n", len);
-
- for(i = 0, offset = 0; i < len; i++)
- {
- buf[offset] = data[i];
- offset++;
- if(offset == 16)
- {
- offset = 0;
- RARCH_LOG("%02x%02x%02x%02x%02x%02x%02x%02x %02x%02x%02x%02x%02x%02x%02x%02x\n",
- buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7],
- buf[8], buf[9], buf[10], buf[11], buf[12], buf[13], buf[14], buf[15]);
- }
- }
-
- if(padding)
- {
- for(i = padding; i < 16; i++)
- buf[i] = 0xff;
-
- RARCH_LOG("%02x%02x%02x%02x%02x%02x%02x%02x %02x%02x%02x%02x%02x%02x%02x%02x\n",
- buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7],
- buf[8], buf[9], buf[10], buf[11], buf[12], buf[13], buf[14], buf[15]);
- }
-
- RARCH_LOG("=================================\n");
- #endif
-}
diff --git a/input/drivers_hid/btstack_hid.c b/input/drivers_hid/btstack_hid.c
index 68f20ea666..1d277484aa 100644
--- a/input/drivers_hid/btstack_hid.c
+++ b/input/drivers_hid/btstack_hid.c
@@ -1439,17 +1439,14 @@ static void btstack_hid_free(const void *data)
free(hid);
}
-static void *btstack_hid_init(joypad_connection_t *connections)
+static void *btstack_hid_init(void)
{
btstack_hid_t *hid = (btstack_hid_t*)calloc(1, sizeof(btstack_hid_t));
if (!hid)
goto error;
- if(connections == NULL)
- connections = pad_connection_init(MAX_USERS);
-
- hid->slots = connections;
+ hid->slots = pad_connection_init(MAX_USERS);
if (!hid->slots)
goto error;
diff --git a/input/drivers_hid/iohidmanager_hid.c b/input/drivers_hid/iohidmanager_hid.c
index ad60d4c969..faaf84eceb 100644
--- a/input/drivers_hid/iohidmanager_hid.c
+++ b/input/drivers_hid/iohidmanager_hid.c
@@ -854,7 +854,7 @@ static int iohidmanager_hid_manager_set_device_matching(
return 0;
}
-static void *iohidmanager_hid_init(joypad_connection_t *connections)
+static void *iohidmanager_hid_init(void)
{
iohidmanager_hid_t *hid_apple = (iohidmanager_hid_t*)
calloc(1, sizeof(*hid_apple));
@@ -862,10 +862,7 @@ static void *iohidmanager_hid_init(joypad_connection_t *connections)
if (!hid_apple)
goto error;
- if (connections == NULL)
- connections = pad_connection_init(MAX_USERS);
-
- hid_apple->slots = connections;
+ hid_apple->slots = pad_connection_init(MAX_USERS);
if (!hid_apple->slots)
goto error;
diff --git a/input/drivers_hid/libusb_hid.c b/input/drivers_hid/libusb_hid.c
index f06adb5366..44580359fa 100644
--- a/input/drivers_hid/libusb_hid.c
+++ b/input/drivers_hid/libusb_hid.c
@@ -546,7 +546,7 @@ static void poll_thread(void *data)
}
}
-static void *libusb_hid_init(joypad_connection_t *connections)
+static void *libusb_hid_init(void)
{
unsigned i, count;
int ret;
@@ -578,10 +578,7 @@ static void *libusb_hid_init(joypad_connection_t *connections)
hid->can_hotplug = 0;
#endif
- if (connections == NULL)
- connections = pad_connection_init(MAX_USERS);
-
- hid->slots = connections;
+ hid->slots = pad_connection_init(MAX_USERS);
if (!hid->slots)
goto error;
diff --git a/input/drivers_hid/null_hid.c b/input/drivers_hid/null_hid.c
index e7cf00b580..125ac54739 100644
--- a/input/drivers_hid/null_hid.c
+++ b/input/drivers_hid/null_hid.c
@@ -76,10 +76,8 @@ static int16_t null_hid_joypad_axis(void *data, unsigned port, uint32_t joyaxis)
return 0;
}
-static void *null_hid_init(hid_driver_instance_t *instance)
+static void *null_hid_init(void)
{
- (void)instance;
-
return (null_hid_t*)calloc(1, sizeof(null_hid_t));
}
diff --git a/input/drivers_hid/wiiusb_hid.c b/input/drivers_hid/wiiusb_hid.c
index 6e3a768bca..397f0a0a64 100644
--- a/input/drivers_hid/wiiusb_hid.c
+++ b/input/drivers_hid/wiiusb_hid.c
@@ -574,15 +574,15 @@ static void wiiusb_hid_free(const void *data)
free(hid);
}
-static void *wiiusb_hid_init(joypad_connection_t *connections)
+static void *wiiusb_hid_init(void)
{
+ joypad_connection_t *connections = NULL;
wiiusb_hid_t *hid = (wiiusb_hid_t*)calloc(1, sizeof(*hid));
if (!hid)
goto error;
- if(connections == NULL)
- connections = pad_connection_init(MAX_USERS);
+ connections = pad_connection_init(MAX_USERS);
if (!connections)
goto error;
diff --git a/input/drivers_joypad/wiiu_joypad.c b/input/drivers_joypad/wiiu_joypad.c
index aa9c3ab277..dc0ab8fe94 100644
--- a/input/drivers_joypad/wiiu_joypad.c
+++ b/input/drivers_joypad/wiiu_joypad.c
@@ -14,7 +14,7 @@
* If not, see .
*/
-#include
+#include "../../wiiu/input/wiiu_input.h"
#include "wiiu_dbg.h"
@@ -40,10 +40,10 @@ static input_device_driver_t *get_driver_for_pad(unsigned pad)
{
if(wpad_driver.query_pad(pad))
return &wpad_driver;
-/*
+
if(kpad_driver.query_pad(pad))
return &kpad_driver;
-*/
+
#ifdef WIIU_HID
return &hidpad_driver;
#else
@@ -135,7 +135,7 @@ static void wiiu_joypad_poll(void)
static const char* wiiu_joypad_name(unsigned pad)
{
if(!wiiu_joypad_query_pad(pad))
- return "Snuffleupagus";
+ return "N/A";
return pad_drivers[pad]->name(pad);
}
diff --git a/input/include/hid_driver.h b/input/include/hid_driver.h
index 1eee8a3f85..619f491688 100644
--- a/input/include/hid_driver.h
+++ b/input/include/hid_driver.h
@@ -35,7 +35,7 @@
struct hid_driver
{
- void *(*init)(hid_driver_instance_t *);
+ void *(*init)(void);
bool (*query_pad)(void *handle, unsigned pad);
void (*free)(const void *handle);
bool (*button)(void *handle, unsigned pad, uint16_t button);
@@ -62,6 +62,8 @@ struct hid_driver
hid_instance.os_driver_data, pad)
#define HID_POLL() hid_instance.os_driver->poll( \
hid_instance.os_driver_data)
+#define HID_MAX_SLOT() hid_instance.max_slot
+#define HID_PAD_CONNECTION_PTR(slot) &(hid_instance.pad_list[(slot)])
diff --git a/input/input_autodetect_builtin.c b/input/input_autodetect_builtin.c
index 75b9f0d3c6..2a237e8831 100644
--- a/input/input_autodetect_builtin.c
+++ b/input/input_autodetect_builtin.c
@@ -29,7 +29,7 @@
#endif
#ifdef WIIU
-#include
+#include
#endif
#define DECL_BTN(btn, bind) "input_" #btn "_btn = " #bind "\n"
diff --git a/wiiu/include/wiiu/pad_driver.h b/wiiu/include/wiiu/pad_driver.h
deleted file mode 100644
index 067bc34d67..0000000000
--- a/wiiu/include/wiiu/pad_driver.h
+++ /dev/null
@@ -1,186 +0,0 @@
-/* RetroArch - A frontend for libretro.
- * Copyright (C) 2014-2017 - Ali Bouhlel
- * Copyright (C) 2011-2017 - Daniel De Matteis
- *
- * RetroArch is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Found-
- * ation, either version 3 of the License, or (at your option) any later version.
- *
- * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with RetroArch.
- * If not, see .
- */
-
-#ifndef __PAD_DRIVER__H
-#define __PAD_DRIVER__H
-
-#ifdef HAVE_CONFIG_H
-#include "../../config.h"
-#endif /* HAVE_CONFIG_H */
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include "../../input/input_driver.h"
-#include "../../input/common/hid/hid_device_driver.h"
-#include "../../tasks/tasks_internal.h"
-#include "../../input/connect/joypad_connection.h"
-#include "../../retroarch.h"
-#include "../../verbosity.h"
-#include "../../command.h"
-#include "../../gfx/video_driver.h"
-
-/**
- * Magic button sequence that triggers an exit. Useful for if the visuals are
- * corrupted, but won't work in the case of a hard lock.
- */
-#define PANIC_BUTTON_MASK (VPAD_BUTTON_R | VPAD_BUTTON_L | VPAD_BUTTON_STICK_R | VPAD_BUTTON_STICK_L)
-
-/**
- * Applies a standard transform to the Wii U gamepad's analog stick.
- * No idea where 0x7ff0 comes from.
- */
-
-#define WIIU_ANALOG_FACTOR 0x7ff0
-#define WIIU_READ_STICK(stick) ((stick) * WIIU_ANALOG_FACTOR)
-
-/**
- * the wiimote driver uses these to delimit which pads correspond to the
- * wiimotes.
- */
-#define PAD_GAMEPAD 0
-#define WIIU_WIIMOTE_CHANNELS 4
-
-/**
- * These are used by the wiimote driver to identify the wiimote configuration
- * attached to the channel.
- */
-/* wiimote with Wii U Pro controller */
-#define WIIMOTE_TYPE_PRO 0x1f
-/* wiimote with Classic Controller */
-#define WIIMOTE_TYPE_CLASSIC 0x02
-/* wiimote with nunchuk */
-#define WIIMOTE_TYPE_NUNCHUK 0x01
-/* wiimote plus (no accessory attached) */
-#define WIIMOTE_TYPE_WIIPLUS 0x00
-/* wiimote not attached on this channel */
-#define WIIMOTE_TYPE_NONE 0xFD
-
-/**
- * These are used to map pad names to controller mappings. You can
- * change these relatively free-form.
- */
-
-#define PAD_NAME_WIIU_GAMEPAD "WiiU Gamepad"
-#define PAD_NAME_WIIU_PRO "WiiU Pro Controller"
-#define PAD_NAME_WIIMOTE "Wiimote Controller"
-#define PAD_NAME_NUNCHUK "Wiimote+Nunchuk Controller"
-#define PAD_NAME_CLASSIC "Classic Controller"
-#define PAD_NAME_HID "HID Controller"
-
-/**
- * The Wii U gamepad and wiimotes have 3 sets of x/y axes. The third
- * is used by the gamepad for the touchpad driver; the wiimotes is
- * currently unimplemented, but could be used for future IR pointer
- * support.
- */
-#define WIIU_DEVICE_INDEX_TOUCHPAD 2
-
-typedef struct _axis_data axis_data;
-
-struct _axis_data {
- int32_t axis;
- bool is_negative;
-};
-
-typedef struct _wiiu_pad_functions wiiu_pad_functions_t;
-
-struct _wiiu_pad_functions {
- int16_t (*get_axis_value)(int32_t axis, int16_t state[3][2], bool is_negative);
- void (*set_axis_value)(int16_t state[3][2], int16_t left_x, int16_t left_y,
- int16_t right_x, int16_t right_y, int16_t touch_x, int16_t touch_y);
- void (*read_axis_data)(uint32_t axis, axis_data *data);
- void (*connect)(unsigned pad, input_device_driver_t *driver);
-};
-
-/**
- * HID driver data structures
- */
-
-typedef struct wiiu_hid {
- /* used to register for HID notifications */
- HIDClient *client;
- /* pointer to HID driver state */
- hid_driver_instance_t *driver;
- /* size of connections list */
- unsigned connections_size;
- /* thread state data for HID polling thread */
- OSThread *polling_thread;
- /* stack space for polling thread */
- void *polling_thread_stack;
- /* watch variable to tell the polling thread to terminate */
- volatile bool polling_thread_quit;
-} wiiu_hid_t;
-
-typedef struct wiiu_adapter wiiu_adapter_t;
-
-struct wiiu_adapter {
- wiiu_adapter_t *next;
- hid_device_t *driver;
- void *driver_handle;
- wiiu_hid_t *hid;
- uint8_t state;
- uint8_t *rx_buffer;
- int32_t rx_size;
- uint8_t *tx_buffer;
- int32_t tx_size;
- uint32_t handle;
- uint8_t interface_index;
-};
-
-typedef struct wiiu_attach wiiu_attach_event;
-
-struct wiiu_attach {
- wiiu_attach_event *next;
- hid_device_t *driver;
- uint32_t type;
- uint32_t handle;
- uint16_t vendor_id;
- uint16_t product_id;
- uint8_t interface_index;
- uint8_t is_keyboard;
- uint8_t is_mouse;
- uint16_t max_packet_size_rx;
- uint16_t max_packet_size_tx;
-};
-
-typedef struct _wiiu_event_list wiiu_event_list;
-typedef struct _wiiu_adapter_list wiiu_adapter_list;
-
-struct _wiiu_event_list {
- OSFastMutex lock;
- wiiu_attach_event *list;
-};
-
-struct _wiiu_adapter_list {
- OSFastMutex lock;
- wiiu_adapter_t *list;
-};
-
-extern wiiu_pad_functions_t pad_functions;
-extern input_device_driver_t wiiu_joypad;
-extern input_device_driver_t wpad_driver;
-extern input_device_driver_t kpad_driver;
-extern input_device_driver_t hidpad_driver;
-extern hid_driver_t wiiu_hid;
-
-#endif /* __PAD_DRIVER__H */
diff --git a/wiiu/include/wiiu/pad_strings.h b/wiiu/include/wiiu/pad_strings.h
new file mode 100644
index 0000000000..e28a9036e6
--- /dev/null
+++ b/wiiu/include/wiiu/pad_strings.h
@@ -0,0 +1,32 @@
+/* RetroArch - A frontend for libretro.
+ * Copyright (C) 2014-2017 - Ali Bouhlel
+ * Copyright (C) 2011-2017 - Daniel De Matteis
+ *
+ * RetroArch is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Found-
+ * ation, either version 3 of the License, or (at your option) any later version.
+ *
+ * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with RetroArch.
+ * If not, see .
+ */
+
+#ifndef __PAD_DRIVER__H
+#define __PAD_DRIVER__H
+
+/**
+ * These are used to map pad names to controller mappings. You can
+ * change these relatively free-form.
+ */
+
+#define PAD_NAME_WIIU_GAMEPAD "WiiU Gamepad"
+#define PAD_NAME_WIIU_PRO "WiiU Pro Controller"
+#define PAD_NAME_WIIMOTE "Wiimote Controller"
+#define PAD_NAME_NUNCHUK "Wiimote+Nunchuk Controller"
+#define PAD_NAME_CLASSIC "Classic Controller"
+#define PAD_NAME_HID "HID Controller"
+
+#endif /* __PAD_DRIVER__H */
diff --git a/wiiu/input/hidpad_driver.c b/wiiu/input/hidpad_driver.c
index 97f05e9d06..896ba4b2d4 100644
--- a/wiiu/input/hidpad_driver.c
+++ b/wiiu/input/hidpad_driver.c
@@ -14,9 +14,8 @@
* If not, see .
*/
-#include
-#include "../../input/include/hid_driver.h"
-#include "../../input/common/hid/hid_device_driver.h"
+#include "wiiu_input.h"
+#include "wiiu_hid.h"
static bool hidpad_init(void *data);
static bool hidpad_query_pad(unsigned pad);
diff --git a/wiiu/input/kpad_driver.c b/wiiu/input/kpad_driver.c
index 51d203cec0..faebe1143e 100644
--- a/wiiu/input/kpad_driver.c
+++ b/wiiu/input/kpad_driver.c
@@ -20,7 +20,7 @@
* controllers.
*/
-#include
+#include "wiiu_input.h"
static bool kpad_init(void *data);
static bool kpad_query_pad(unsigned pad);
diff --git a/wiiu/input/pad_functions.c b/wiiu/input/pad_functions.c
index 132bffa146..ad2c383090 100644
--- a/wiiu/input/pad_functions.c
+++ b/wiiu/input/pad_functions.c
@@ -14,7 +14,7 @@
* If not, see .
*/
-#include
+#include "wiiu_input.h"
enum wiiu_pad_axes {
AXIS_LEFT_ANALOG_X,
diff --git a/wiiu/input/wiiu_hid.c b/wiiu/input/wiiu_hid.c
index 44c2822305..b289f648f4 100644
--- a/wiiu/input/wiiu_hid.c
+++ b/wiiu/input/wiiu_hid.c
@@ -22,10 +22,10 @@ static wiiu_adapter_list adapters;
static bool wiiu_hid_joypad_query(void *data, unsigned slot)
{
wiiu_hid_t *hid = (wiiu_hid_t *)data;
- if (!hid || !hid->driver)
+ if (!hid)
return false;
- return slot < hid->driver->max_slot;
+ return slot < HID_MAX_SLOT();
}
static joypad_connection_t *get_pad(wiiu_hid_t *hid, unsigned slot)
@@ -33,7 +33,7 @@ static joypad_connection_t *get_pad(wiiu_hid_t *hid, unsigned slot)
if(!wiiu_hid_joypad_query(hid, slot))
return NULL;
- joypad_connection_t *result = &(hid->driver->pad_list[slot]);
+ joypad_connection_t *result = HID_PAD_CONNECTION_PTR(slot);
if(!result || !result->connected || !result->iface || !result->data)
return NULL;
@@ -90,7 +90,7 @@ static int16_t wiiu_hid_joypad_axis(void *data, unsigned slot, uint32_t joyaxis)
return pad->iface->get_axis(pad->data, joyaxis);
}
-static void *wiiu_hid_init(hid_driver_instance_t *driver)
+static void *wiiu_hid_init(void)
{
RARCH_LOG("[hid]: initializing HID subsystem\n");
wiiu_hid_t *hid = new_hid();
@@ -99,8 +99,6 @@ static void *wiiu_hid_init(hid_driver_instance_t *driver)
if (!hid || !client)
goto error;
- hid->driver = driver;
-
wiiu_hid_init_lists();
start_polling_thread(hid);
if (!hid->polling_thread)
diff --git a/wiiu/input/wiiu_hid.h b/wiiu/input/wiiu_hid.h
index 59ad898fea..892e1d3151 100644
--- a/wiiu/input/wiiu_hid.h
+++ b/wiiu/input/wiiu_hid.h
@@ -17,8 +17,9 @@
#ifndef __WIIU_HID__H
#define __WIIU_HID__H
-#include
-#include "../../input/include/hid_driver.h"
+#include "wiiu_hid_types.h"
+
+#include "wiiu_input.h"
#define DEVICE_UNUSED 0
#define DEVICE_USED 1
@@ -28,6 +29,70 @@
#define ADAPTER_STATE_READING 2
#define ADAPTER_STATE_DONE 3
+struct wiiu_hid {
+ /* used to register for HID notifications */
+ HIDClient *client;
+ /* thread state data for the HID input polling thread */
+ OSThread *polling_thread;
+ /* stack space for polling thread */
+ void *polling_thread_stack;
+ /* watch variable for telling the polling thread to terminate */
+ volatile bool polling_thread_quit;
+};
+
+/**
+ * Each HID device attached to the WiiU gets its own adapter, which
+ * connects the HID subsystem with the HID device driver.
+ */
+struct wiiu_adapter {
+ wiiu_adapter_t *next;
+ hid_device_t *driver;
+ void *driver_handle;
+ wiiu_hid_t *hid;
+ uint8_t state;
+ uint8_t *rx_buffer;
+ int32_t rx_size;
+ uint8_t *tx_buffer;
+ int32_t tx_size;
+ uint32_t handle;
+ uint8_t interface_index;
+};
+
+/**
+ * When a HID device is connected, the OS generates an attach
+ * event; the attach event handler translate them into these
+ * structures.
+ */
+struct wiiu_attach {
+ wiiu_attach_event *next;
+ hid_device_t *driver;
+ uint32_t type;
+ uint32_t handle;
+ uint16_t vendor_id;
+ uint16_t product_id;
+ uint8_t interface_index;
+ uint8_t is_keyboard;
+ uint8_t is_mouse;
+ uint16_t max_packet_size_rx;
+ uint16_t max_packet_size_tx;
+};
+
+struct _wiiu_event_list {
+ OSFastMutex lock;
+ wiiu_attach_event *list;
+};
+
+struct _wiiu_adapter_list {
+ OSFastMutex lock;
+ wiiu_adapter_t *list;
+};
+
+extern wiiu_pad_functions_t pad_functions;
+extern input_device_driver_t wiiu_joypad;
+extern input_device_driver_t wpad_driver;
+extern input_device_driver_t kpad_driver;
+extern input_device_driver_t hidpad_driver;
+extern hid_driver_t wiiu_hid;
static void *alloc_zeroed(size_t alignment, size_t size);
static OSThread *new_thread(void);
diff --git a/wiiu/input/wiiu_hid_types.h b/wiiu/input/wiiu_hid_types.h
new file mode 100644
index 0000000000..59eaabaddf
--- /dev/null
+++ b/wiiu/input/wiiu_hid_types.h
@@ -0,0 +1,28 @@
+/* RetroArch - A frontend for libretro.
+ * Copyright (C) 2013-2014 - Jason Fetters
+ * Copyright (C) 2011-2017 - Daniel De Matteis
+ *
+ * RetroArch is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Found-
+ * ation, either version 3 of the License, or (at your option) any later version.
+ *
+ * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with RetroArch.
+ * If not, see .
+ */
+
+#ifndef __WIIU_HID_TYPES__H
+#define __WIIU_HID_TYPES__H
+
+typedef struct wiiu_hid wiiu_hid_t;
+typedef struct wiiu_adapter wiiu_adapter_t;
+typedef struct wiiu_attach wiiu_attach_event;
+typedef struct _wiiu_event_list wiiu_event_list;
+typedef struct _wiiu_adapter_list wiiu_adapter_list;
+typedef struct _axis_data axis_data;
+typedef struct _wiiu_pad_functions wiiu_pad_functions_t;
+
+#endif /* __WIIU_HID_TYPES__H */
diff --git a/wiiu/input/wiiu_input.h b/wiiu/input/wiiu_input.h
new file mode 100644
index 0000000000..16509b47f2
--- /dev/null
+++ b/wiiu/input/wiiu_input.h
@@ -0,0 +1,72 @@
+/* RetroArch - A frontend for libretro.
+ * Copyright (C) 2013-2014 - Jason Fetters
+ * Copyright (C) 2011-2017 - Daniel De Matteis
+ *
+ * RetroArch is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Found-
+ * ation, either version 3 of the License, or (at your option) any later version.
+ *
+ * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with RetroArch.
+ * If not, see .
+ */
+
+#ifndef __WIIU_INPUT__H
+#define __WIIU_INPUT__H
+
+#include "wiiu_hid_types.h"
+
+#ifdef HAVE_CONFIG_H
+#include "../../config.h"
+#endif /* HAVE_CONFIG_H */
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "../../input/input_driver.h"
+#include "../../input/common/hid/hid_device_driver.h"
+#include "../../tasks/tasks_internal.h"
+#include "../../input/connect/joypad_connection.h"
+#include "../../retroarch.h"
+#include "../../verbosity.h"
+#include "../../command.h"
+#include "../../gfx/video_driver.h"
+#include "wiiu_hid.h"
+
+#define WIIMOTE_TYPE_WIIPLUS 0x00
+#define WIIMOTE_TYPE_NUNCHUK 0x01
+#define WIIMOTE_TYPE_CLASSIC 0x02
+#define WIIMOTE_TYPE_PRO 0x1f
+#define WIIMOTE_TYPE_NONE 0xfd
+
+#define WIIU_DEVICE_INDEX_TOUCHPAD 2
+
+#define PAD_GAMEPAD 0
+#define WIIU_WIIMOTE_CHANNELS 4
+
+#define WIIU_ANALOG_FACTOR 0x7ff0
+#define WIIU_READ_STICK(stick) ((stick) * WIIU_ANALOG_FACTOR)
+
+struct _axis_data {
+ int32_t axis;
+ bool is_negative;
+};
+
+struct _wiiu_pad_functions {
+ int16_t (*get_axis_value)(int32_t axis, int16_t state[3][2], bool is_negative);
+ void (*set_axis_value)(int16_t state[3][2], int16_t left_x, int16_t left_y,
+ int16_t right_x, int16_t right_y, int16_t touch_x, int16_t touch_y);
+ void (*read_axis_data)(uint32_t axis, axis_data *data);
+ void (*connect)(unsigned pad, input_device_driver_t *driver);
+};
+
+#endif /* __WIIU_INPUT__H */
diff --git a/wiiu/input/wpad_driver.c b/wiiu/input/wpad_driver.c
index 786f883cda..5cac0c5bff 100644
--- a/wiiu/input/wpad_driver.c
+++ b/wiiu/input/wpad_driver.c
@@ -21,7 +21,9 @@
* - For HID controllers, see hid_driver.c
*/
-#include
+#include "wiiu_input.h"
+
+#define PANIC_BUTTON_MASK (VPAD_BUTTON_R | VPAD_BUTTON_L | VPAD_BUTTON_STICK_R | VPAD_BUTTON_STICK_L)
static bool ready = false;
static uint64_t button_state = 0;