Merge pull request #16 from Crayon2000/vpad_functions

Add more vpad functions
This commit is contained in:
Maschell 2017-09-30 11:03:59 +02:00 committed by GitHub
commit 9e8b695abf
4 changed files with 161 additions and 21 deletions

View File

@ -108,16 +108,29 @@ typedef struct _KPADData
u32 btns_h; u32 btns_h;
u32 btns_d; u32 btns_d;
u32 btns_r; u32 btns_r;
u32 unused_1[5]; f32 acc_x;
f32 acc_y;
f32 acc_z;
f32 acc_value;
f32 acc_speed;
f32 pos_x; f32 pos_x;
f32 pos_y; f32 pos_y;
u32 unused_2[3]; f32 vec_x;
f32 vec_y;
f32 speed;
f32 angle_x; f32 angle_x;
f32 angle_y; f32 angle_y;
u32 unused_3[8]; f32 angle_vec_x;
f32 angle_vec_y;
f32 angle_speed;
f32 dist;
f32 dist_vec;
f32 dist_speed;
f32 acc_vertical_x;
f32 acc_vertical_y;
u8 device_type; u8 device_type;
u8 wpad_error; s8 wpad_error;
u8 pos_valid; s8 pos_valid;
u8 format; u8 format;
union union

View File

@ -28,16 +28,56 @@ u32 vpad_handle __attribute__((section(".data"))) = 0;
u32 vpadbase_handle __attribute__((section(".data"))) = 0; u32 vpadbase_handle __attribute__((section(".data"))) = 0;
EXPORT_DECL(void, VPADInit, void); EXPORT_DECL(void, VPADInit, void);
EXPORT_DECL(void, VPADShutdown, void);
EXPORT_DECL(s32, VPADRead, s32 chan, VPADData *buffer, u32 buffer_size, s32 *error); EXPORT_DECL(s32, VPADRead, s32 chan, VPADData *buffer, u32 buffer_size, s32 *error);
EXPORT_DECL(void, VPADSetAccParam, s32 chan, f32 play_radius, f32 sensitivity);
EXPORT_DECL(void, VPADGetAccParam, s32 chan, f32 *play_radius, f32 *sensitivity);
EXPORT_DECL(void, VPADSetBtnRepeat, s32 chan, f32 delay_sec, f32 pulse_sec);
EXPORT_DECL(void, VPADEnableStickCrossClamp, s32 chan);
EXPORT_DECL(void, VPADDisableStickCrossClamp, s32 chan);
EXPORT_DECL(void, VPADSetLStickClampThreshold, s32 chan, s32 max, s32 min);
EXPORT_DECL(void, VPADSetRStickClampThreshold, s32 chan, s32 max, s32 min);
EXPORT_DECL(void, VPADGetLStickClampThreshold, s32 chan, s32* max, s32* min);
EXPORT_DECL(void, VPADGetRStickClampThreshold, s32 chan, s32* max, s32* min);
EXPORT_DECL(void, VPADSetStickOrigin, s32 chan);
EXPORT_DECL(void, VPADSetGyroAngle, s32 chan, f32 ax, f32 ay, f32 az);
EXPORT_DECL(void, VPADSetGyroDirection, s32 chan, VPADDir *dir);
EXPORT_DECL(void, VPADSetGyroDirectionMag, s32 chan, f32 mag);
EXPORT_DECL(void, VPADSetGyroMagnification, s32 chan, f32 pitch, f32 yaw, f32 roll);
EXPORT_DECL(void, VPADEnableGyroZeroPlay, s32 chan);
EXPORT_DECL(void, VPADEnableGyroDirRevise, s32 chan);
EXPORT_DECL(void, VPADEnableGyroAccRevise, s32 chan);
EXPORT_DECL(void, VPADDisableGyroZeroPlay, s32 chan);
EXPORT_DECL(void, VPADDisableGyroDirRevise, s32 chan);
EXPORT_DECL(void, VPADDisableGyroAccRevise, s32 chan);
EXPORT_DECL(f32, VPADIsEnableGyroZeroPlay, s32 chan);
EXPORT_DECL(f32, VPADIsEnableGyroZeroDrift, s32 chan);
EXPORT_DECL(f32, VPADIsEnableGyroDirRevise, s32 chan);
EXPORT_DECL(f32, VPADIsEnableGyroAccRevise, s32 chan);
EXPORT_DECL(void, VPADSetGyroZeroPlayParam, s32 chan, f32 radius);
EXPORT_DECL(void, VPADSetGyroDirReviseParam, s32 chan, f32 revis_pw);
EXPORT_DECL(void, VPADSetGyroAccReviseParam, s32 chan, f32 revise_pw, f32 revise_range);
EXPORT_DECL(void, VPADSetGyroDirReviseBase, s32 chan, VPADDir *base);
EXPORT_DECL(void, VPADGetGyroZeroPlayParam, s32 chan, f32 *radius);
EXPORT_DECL(void, VPADGetGyroDirReviseParam, s32 chan, f32 *revise_pw);
EXPORT_DECL(void, VPADGetGyroAccReviseParam, s32 chan, f32 *revise_pw, f32 *revise_range);
EXPORT_DECL(void, VPADInitGyroZeroPlayParam, s32 chan);
EXPORT_DECL(void, VPADInitGyroDirReviseParam, s32 chan);
EXPORT_DECL(void, VPADInitGyroAccReviseParam, s32 chan);
EXPORT_DECL(void, VPADInitGyroZeroDriftMode, s32 chan);
EXPORT_DECL(void, VPADSetGyroZeroDriftMode, s32 chan, VPADGyroZeroDriftMode mode);
EXPORT_DECL(void, VPADGetGyroZeroDriftMode, s32 chan, VPADGyroZeroDriftMode *mode);
EXPORT_DECL(s16, VPADCalcTPCalibrationParam, VPADTPCalibrationParam* param, u16 rawX1, u16 rawY1, u16 x1, u16 y1, u16 rawX2, u16 rawY2, u16 x2, u16 y2); EXPORT_DECL(s16, VPADCalcTPCalibrationParam, VPADTPCalibrationParam* param, u16 rawX1, u16 rawY1, u16 x1, u16 y1, u16 rawX2, u16 rawY2, u16 x2, u16 y2);
EXPORT_DECL(void, VPADSetTPCalibrationParam, s32 chan, const VPADTPCalibrationParam param); EXPORT_DECL(void, VPADSetTPCalibrationParam, s32 chan, const VPADTPCalibrationParam param);
EXPORT_DECL(void, VPADGetTPCalibrationParam, s32 chan, VPADTPCalibrationParam* param); EXPORT_DECL(void, VPADGetTPCalibrationParam, s32 chan, VPADTPCalibrationParam* param);
EXPORT_DECL(void, VPADGetTPCalibratedPoint, s32 chan, VPADTPData *disp, const VPADTPData *raw); EXPORT_DECL(void, VPADGetTPCalibratedPoint, s32 chan, VPADTPData *disp, const VPADTPData *raw);
EXPORT_DECL(void, VPADGetTPCalibratedPointEx, s32 chan, VPADTPResolution tpReso, VPADTPData *disp, const VPADTPData *raw); EXPORT_DECL(void, VPADGetTPCalibratedPointEx, s32 chan, VPADTPResolution tpReso, VPADTPData *disp, const VPADTPData *raw);
EXPORT_DECL(s32, VPADGetLcdMode, s32 padnum, s32 *lcdmode);
EXPORT_DECL(s32, VPADSetLcdMode, s32 padnum, s32 lcdmode); EXPORT_DECL(s32, VPADSetLcdMode, s32 padnum, s32 lcdmode);
EXPORT_DECL(s32, VPADBASEGetMotorOnRemainingCount, s32 padnum); EXPORT_DECL(s32, VPADGetLcdMode, s32 padnum, s32 *lcdmode);
EXPORT_DECL(s32, VPADBASESetMotorOnRemainingCount, s32 padnum, s32 counter); EXPORT_DECL(s32, VPADBASEGetMotorOnRemainingCount, s32 lcdmode);
EXPORT_DECL(s32, VPADBASESetMotorOnRemainingCount, s32 lcdmode, s32 counter);
EXPORT_DECL(void, VPADBASESetSensorBarSetting, s32 chan, s8 setting);
EXPORT_DECL(void, VPADBASEGetSensorBarSetting, s32 chan, s8 *setting);
void InitAcquireVPad(void) void InitAcquireVPad(void)
{ {
@ -52,14 +92,54 @@ void InitVPadFunctionPointers(void)
InitAcquireVPad(); InitAcquireVPad();
OS_FIND_EXPORT(vpad_handle, VPADInit); OS_FIND_EXPORT(vpad_handle, VPADInit);
OS_FIND_EXPORT(vpad_handle, VPADShutdown);
OS_FIND_EXPORT(vpad_handle, VPADRead); OS_FIND_EXPORT(vpad_handle, VPADRead);
OS_FIND_EXPORT(vpad_handle, VPADSetAccParam);
OS_FIND_EXPORT(vpad_handle, VPADGetAccParam);
OS_FIND_EXPORT(vpad_handle, VPADSetBtnRepeat);
OS_FIND_EXPORT(vpad_handle, VPADEnableStickCrossClamp);
OS_FIND_EXPORT(vpad_handle, VPADDisableStickCrossClamp);
OS_FIND_EXPORT(vpad_handle, VPADSetLStickClampThreshold);
OS_FIND_EXPORT(vpad_handle, VPADSetRStickClampThreshold);
OS_FIND_EXPORT(vpad_handle, VPADGetLStickClampThreshold);
OS_FIND_EXPORT(vpad_handle, VPADGetRStickClampThreshold);
OS_FIND_EXPORT(vpad_handle, VPADSetStickOrigin);
OS_FIND_EXPORT(vpad_handle, VPADSetGyroAngle);
OS_FIND_EXPORT(vpad_handle, VPADSetGyroDirection);
OS_FIND_EXPORT(vpad_handle, VPADSetGyroDirectionMag);
OS_FIND_EXPORT(vpad_handle, VPADSetGyroMagnification);
OS_FIND_EXPORT(vpad_handle, VPADEnableGyroZeroPlay);
OS_FIND_EXPORT(vpad_handle, VPADEnableGyroDirRevise);
OS_FIND_EXPORT(vpad_handle, VPADEnableGyroAccRevise);
OS_FIND_EXPORT(vpad_handle, VPADDisableGyroZeroPlay);
OS_FIND_EXPORT(vpad_handle, VPADDisableGyroDirRevise);
OS_FIND_EXPORT(vpad_handle, VPADDisableGyroAccRevise);
OS_FIND_EXPORT(vpad_handle, VPADIsEnableGyroZeroPlay);
OS_FIND_EXPORT(vpad_handle, VPADIsEnableGyroZeroDrift);
OS_FIND_EXPORT(vpad_handle, VPADIsEnableGyroDirRevise);
OS_FIND_EXPORT(vpad_handle, VPADIsEnableGyroAccRevise);
OS_FIND_EXPORT(vpad_handle, VPADSetGyroZeroPlayParam);
OS_FIND_EXPORT(vpad_handle, VPADSetGyroDirReviseParam);
OS_FIND_EXPORT(vpad_handle, VPADSetGyroAccReviseParam);
OS_FIND_EXPORT(vpad_handle, VPADSetGyroDirReviseBase);
OS_FIND_EXPORT(vpad_handle, VPADGetGyroZeroPlayParam);
OS_FIND_EXPORT(vpad_handle, VPADGetGyroDirReviseParam);
OS_FIND_EXPORT(vpad_handle, VPADGetGyroAccReviseParam);
OS_FIND_EXPORT(vpad_handle, VPADInitGyroZeroPlayParam);
OS_FIND_EXPORT(vpad_handle, VPADInitGyroDirReviseParam);
OS_FIND_EXPORT(vpad_handle, VPADInitGyroAccReviseParam);
OS_FIND_EXPORT(vpad_handle, VPADInitGyroZeroDriftMode);
OS_FIND_EXPORT(vpad_handle, VPADSetGyroZeroDriftMode);
OS_FIND_EXPORT(vpad_handle, VPADGetGyroZeroDriftMode);
OS_FIND_EXPORT(vpad_handle, VPADCalcTPCalibrationParam); OS_FIND_EXPORT(vpad_handle, VPADCalcTPCalibrationParam);
OS_FIND_EXPORT(vpad_handle, VPADSetTPCalibrationParam); OS_FIND_EXPORT(vpad_handle, VPADSetTPCalibrationParam);
OS_FIND_EXPORT(vpad_handle, VPADGetTPCalibrationParam); OS_FIND_EXPORT(vpad_handle, VPADGetTPCalibrationParam);
OS_FIND_EXPORT(vpad_handle, VPADGetTPCalibratedPoint); OS_FIND_EXPORT(vpad_handle, VPADGetTPCalibratedPoint);
OS_FIND_EXPORT(vpad_handle, VPADGetTPCalibratedPointEx); OS_FIND_EXPORT(vpad_handle, VPADGetTPCalibratedPointEx);
OS_FIND_EXPORT(vpad_handle, VPADGetLcdMode);
OS_FIND_EXPORT(vpad_handle, VPADSetLcdMode); OS_FIND_EXPORT(vpad_handle, VPADSetLcdMode);
OS_FIND_EXPORT(vpad_handle, VPADGetLcdMode);
OS_FIND_EXPORT(vpadbase_handle, VPADBASEGetMotorOnRemainingCount); OS_FIND_EXPORT(vpadbase_handle, VPADBASEGetMotorOnRemainingCount);
OS_FIND_EXPORT(vpadbase_handle, VPADBASESetMotorOnRemainingCount); OS_FIND_EXPORT(vpadbase_handle, VPADBASESetMotorOnRemainingCount);
OS_FIND_EXPORT(vpadbase_handle, VPADBASESetSensorBarSetting);
OS_FIND_EXPORT(vpadbase_handle, VPADBASEGetSensorBarSetting);
} }

View File

@ -75,6 +75,13 @@ typedef enum VPADTPResolution
VPAD_TP_854x480 VPAD_TP_854x480
} VPADTPResolution; } VPADTPResolution;
typedef enum VPADGyroZeroDriftMode
{
VPAD_GYRO_ZERODRIFT_LOOSE,
VPAD_GYRO_ZERODRIFT_STANDARD,
VPAD_GYRO_ZERODRIFT_TIGHT
} VPADGyroZeroDriftMode;
typedef struct typedef struct
{ {
f32 x,y; f32 x,y;
@ -88,7 +95,7 @@ typedef struct
typedef struct typedef struct
{ {
Vec3D X,Y,Z; Vec3D X,Y,Z;
} VPADOrientation; } VPADDir;
typedef struct typedef struct
{ {
@ -121,7 +128,7 @@ typedef struct
VPADTPData tpdata; /* Normal touchscreen data */ VPADTPData tpdata; /* Normal touchscreen data */
VPADTPData tpdata1; /* Modified touchscreen data 1 */ VPADTPData tpdata1; /* Modified touchscreen data 1 */
VPADTPData tpdata2; /* Modified touchscreen data 2 */ VPADTPData tpdata2; /* Modified touchscreen data 2 */
VPADOrientation dir; /* Orientation in three-dimensional space */ VPADDir dir; /* Orientation in three-dimensional space */
BOOL headphone; /* Set to TRUE if headphones are plugged in, FALSE otherwise */ BOOL headphone; /* Set to TRUE if headphones are plugged in, FALSE otherwise */
Vec3D mag; /* Magnetometer data */ Vec3D mag; /* Magnetometer data */
u8 volume; /* 0 to 255 */ u8 volume; /* 0 to 255 */
@ -134,17 +141,57 @@ typedef struct
void InitVPadFunctionPointers(void); void InitVPadFunctionPointers(void);
void InitAcquireVPad(void); void InitAcquireVPad(void);
extern s32 (* VPADRead)(s32 chan, VPADData *buffer, u32 buffer_size, s32 *error);
extern s16 (* VPADCalcTPCalibrationParam) (VPADTPCalibrationParam* param, u16 rawX1, u16 rawY1, u16 x1, u16 y1, u16 rawX2, u16 rawY2, u16 x2, u16 y2);
extern void (* VPADSetTPCalibrationParam) (s32 chan, const VPADTPCalibrationParam param);
extern void (* VPADGetTPCalibrationParam) (s32 chan, VPADTPCalibrationParam* param);
extern void (* VPADGetTPCalibratedPoint) (s32 chan, VPADTPData *disp, const VPADTPData *raw);
extern void (* VPADGetTPCalibratedPointEx) (s32 chan, VPADTPResolution tpReso, VPADTPData *disp, const VPADTPData *raw);
extern s32 (* VPADGetLcdMode)(s32 padnum, s32 *lcdmode);
extern s32 (* VPADSetLcdMode)(s32 padnum, s32 lcdmode);
extern void (* VPADInit)(void); extern void (* VPADInit)(void);
extern void (* VPADShutdown)(void);
extern s32 (* VPADRead)(s32 chan, VPADData *buffer, u32 buffer_size, s32 *error);
extern void (* VPADSetAccParam)(s32 chan, f32 play_radius, f32 sensitivity);
extern void (* VPADGetAccParam)(s32 chan, f32 *play_radius, f32 *sensitivity);
extern void (* VPADSetBtnRepeat)(s32 chan, f32 delay_sec, f32 pulse_sec);
extern void (* VPADEnableStickCrossClamp)(s32 chan);
extern void (* VPADDisableStickCrossClamp)(s32 chan);
extern void (* VPADSetLStickClampThreshold)(s32 chan, s32 max, s32 min);
extern void (* VPADSetRStickClampThreshold)(s32 chan, s32 max, s32 min);
extern void (* VPADGetLStickClampThreshold)(s32 chan, s32* max, s32* min);
extern void (* VPADGetRStickClampThreshold)(s32 chan, s32* max, s32* min);
extern void (* VPADSetStickOrigin)(s32 chan);
extern void (* VPADSetGyroAngle)(s32 chan, f32 ax, f32 ay, f32 az);
extern void (* VPADSetGyroDirection)(s32 chan, VPADDir *dir);
extern void (* VPADSetGyroDirectionMag)(s32 chan, f32 mag);
extern void (* VPADSetGyroMagnification)(s32 chan, f32 pitch, f32 yaw, f32 roll);
extern void (* VPADEnableGyroZeroPlay)(s32 chan);
extern void (* VPADEnableGyroDirRevise)(s32 chan);
extern void (* VPADEnableGyroAccRevise)(s32 chan);
extern void (* VPADDisableGyroZeroPlay)(s32 chan);
extern void (* VPADDisableGyroDirRevise)(s32 chan);
extern void (* VPADDisableGyroAccRevise)(s32 chan);
extern f32 (* VPADIsEnableGyroZeroPlay)(s32 chan);
extern f32 (* VPADIsEnableGyroZeroDrift)(s32 chan);
extern f32 (* VPADIsEnableGyroDirRevise)(s32 chan);
extern f32 (* VPADIsEnableGyroAccRevise)(s32 chan);
extern void (* VPADSetGyroZeroPlayParam)(s32 chan, f32 radius);
extern void (* VPADSetGyroDirReviseParam)(s32 chan, f32 revis_pw);
extern void (* VPADSetGyroAccReviseParam)(s32 chan, f32 revise_pw, f32 revise_range);
extern void (* VPADSetGyroDirReviseBase)(s32 chan, VPADDir *base);
extern void (* VPADGetGyroZeroPlayParam)(s32 chan, f32 *radius);
extern void (* VPADGetGyroDirReviseParam)(s32 chan, f32 *revise_pw);
extern void (* VPADGetGyroAccReviseParam)(s32 chan, f32 *revise_pw, f32 *revise_range);
extern void (* VPADInitGyroZeroPlayParam)(s32 chan);
extern void (* VPADInitGyroDirReviseParam)(s32 chan);
extern void (* VPADInitGyroAccReviseParam)(s32 chan);
extern void (* VPADInitGyroZeroDriftMode)(s32 chan);
extern void (* VPADSetGyroZeroDriftMode)(s32 chan, VPADGyroZeroDriftMode mode);
extern void (* VPADGetGyroZeroDriftMode)(s32 chan, VPADGyroZeroDriftMode *mode);
extern s16 (* VPADCalcTPCalibrationParam)(VPADTPCalibrationParam* param, u16 rawX1, u16 rawY1, u16 x1, u16 y1, u16 rawX2, u16 rawY2, u16 x2, u16 y2);
extern void (* VPADSetTPCalibrationParam)(s32 chan, const VPADTPCalibrationParam param);
extern void (* VPADGetTPCalibrationParam)(s32 chan, VPADTPCalibrationParam* param);
extern void (* VPADGetTPCalibratedPoint)(s32 chan, VPADTPData *disp, const VPADTPData *raw);
extern void (* VPADGetTPCalibratedPointEx)(s32 chan, VPADTPResolution tpReso, VPADTPData *disp, const VPADTPData *raw);
extern s32 (* VPADSetLcdMode)(s32 padnum, s32 lcdmode);
extern s32 (* VPADGetLcdMode)(s32 padnum, s32 *lcdmode);
extern s32 (* VPADBASEGetMotorOnRemainingCount)(s32 lcdmode); extern s32 (* VPADBASEGetMotorOnRemainingCount)(s32 lcdmode);
extern s32 (* VPADBASESetMotorOnRemainingCount)(s32 lcdmode,s32 counter); extern s32 (* VPADBASESetMotorOnRemainingCount)(s32 lcdmode, s32 counter);
extern void (* VPADBASESetSensorBarSetting)(s32 chan, s8 setting);
extern void (* VPADBASEGetSensorBarSetting)(s32 chan, s8 *setting);
#ifdef __cplusplus #ifdef __cplusplus
} }