2017-03-30 17:53:36 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Copyright (C) 2016,2017 Maschell
|
|
|
|
*
|
|
|
|
* This program 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 Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file ControllerPatcherHID.hpp
|
|
|
|
* @author Maschell
|
|
|
|
* @date 25 Aug 2016
|
|
|
|
* \brief This files contain useful all function for the direct HID Access
|
|
|
|
*
|
|
|
|
* @see https://github.com/Maschell/controller_patcher
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _CONTROLLER_PATCHER_HID_H_
|
|
|
|
#define _CONTROLLER_PATCHER_HID_H_
|
|
|
|
|
|
|
|
#include <vector>
|
2017-05-07 14:44:09 +02:00
|
|
|
|
2017-10-29 09:34:47 +01:00
|
|
|
#include "../ControllerPatcherIncludes.hpp"
|
2017-03-30 17:53:36 +02:00
|
|
|
|
2018-06-17 20:33:39 +02:00
|
|
|
//! Own definitions
|
|
|
|
#define VPAD_BUTTON_TOUCH 0x00080000
|
|
|
|
#define VPAD_MASK_EMULATED_STICKS 0x7F800000
|
|
|
|
#define VPAD_MASK_BUTTONS ~VPAD_MASK_EMULATED_STICKS
|
|
|
|
|
|
|
|
|
2017-03-30 17:53:36 +02:00
|
|
|
#define SWAP16(x) ((x>>8) | ((x&0xFF)<<8))
|
|
|
|
#define SWAP8(x) ((x>>4) | ((x&0xF)<<4))
|
|
|
|
|
|
|
|
class ControllerPatcherHID{
|
|
|
|
friend class ControllerPatcher;
|
|
|
|
friend class ControllerPatcherUtils;
|
|
|
|
public:
|
2017-04-10 11:00:55 +02:00
|
|
|
static s32 externAttachDetachCallback(HIDDevice *p_device, u32 attach);
|
|
|
|
static void externHIDReadCallback(u32 handle, unsigned char *buf, u32 bytes_transfered, my_cb_user * usr);
|
2017-03-30 17:53:36 +02:00
|
|
|
|
|
|
|
private:
|
2018-06-17 20:33:39 +02:00
|
|
|
static CONTROLLER_PATCHER_RESULT_OR_ERROR setVPADControllerData(VPADStatus * buffer,std::vector<HID_Data *>& data);
|
2017-03-30 17:53:36 +02:00
|
|
|
static std::vector<HID_Data *> getHIDDataAll();
|
2017-04-10 17:15:26 +02:00
|
|
|
static CONTROLLER_PATCHER_RESULT_OR_ERROR getHIDData(u32 hidmask, s32 pad, HID_Data ** data);
|
2017-03-30 17:53:36 +02:00
|
|
|
|
|
|
|
/*----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
* Rumble
|
|
|
|
*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
|
|
|
|
|
2017-04-10 11:00:55 +02:00
|
|
|
static void HIDRumble(u32 handle,my_cb_user *usr,u32 pad);
|
2017-03-30 17:53:36 +02:00
|
|
|
|
2017-04-10 11:00:55 +02:00
|
|
|
static void HIDGCRumble(u32 handle,my_cb_user *usr);
|
2017-03-30 17:53:36 +02:00
|
|
|
|
2017-04-10 11:00:55 +02:00
|
|
|
static void HIDDS3Rumble(u32 handle,my_cb_user *usr,s32 rumble);
|
2017-03-30 17:53:36 +02:00
|
|
|
|
|
|
|
/*----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
* HID Callbacks
|
|
|
|
*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
|
2017-04-10 11:00:55 +02:00
|
|
|
static s32 myAttachDetachCallback(HIDClient *p_client, HIDDevice *p_device, u32 attach);
|
2017-03-30 17:53:36 +02:00
|
|
|
|
2017-04-10 11:00:55 +02:00
|
|
|
static void myHIDMouseReadCallback(u32 handle, s32 error, unsigned char *buf, u32 bytes_transfered, void *p_user);
|
|
|
|
static void myHIDReadCallback(u32 handle, s32 error, unsigned char *buf, u32 bytes_transfered, void *p_user);
|
2017-03-30 17:53:36 +02:00
|
|
|
|
2017-04-10 11:00:55 +02:00
|
|
|
static s32 AttachDetachCallback(HIDClient *p_client, HIDDevice *p_device, u32 attach);
|
|
|
|
static void HIDReadCallback(u32 handle, unsigned char *buf, u32 bytes_transfered, my_cb_user * usr);
|
2017-03-30 17:53:36 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* _CONTROLLER_PATCHER_HID_H_ */
|