mirror of
https://github.com/Fledge68/WiiFlow_Lite.git
synced 2024-11-01 00:55:06 +01:00
- cleaned up libsicksaxis code a little to make it easier for me to understand what's going on.
This commit is contained in:
parent
64cf5a6858
commit
bca9764f4b
BIN
out/boot.dol
BIN
out/boot.dol
Binary file not shown.
Before Width: | Height: | Size: 4.1 MiB After Width: | Height: | Size: 4.1 MiB |
@ -140,6 +140,7 @@ void CMenu::ButtonsPressed()
|
||||
gc_btnsPressed = 0;
|
||||
|
||||
/* ds3 controller */
|
||||
/* libsicksaxis uses a thread to do scan pads so we need to use a delay here to give that thread time to read the controller */
|
||||
if(CheckTime())
|
||||
{
|
||||
ds3_btnsPressed = DS3_ButtonsDown();
|
||||
@ -165,7 +166,7 @@ void CMenu::ButtonsPressed()
|
||||
|
||||
void CMenu::ButtonsHeld()
|
||||
{
|
||||
/* wii, gc, drc, and wupc controllers = no ds3 not sure why */
|
||||
/* wii, gc, drc, and wupc controllers = no ds3 because libsicksaxis does not have a function to check for buttons held */
|
||||
gc_btnsHeld = 0;
|
||||
gc_btnsHeld |= wiidrc_to_pad(WiiDRC_ButtonsHeld());
|
||||
for(int chan = WPAD_MAX_WIIMOTES-1; chan >= 0; chan--)
|
||||
@ -273,7 +274,7 @@ void CMenu::LeftStick()
|
||||
for(int chan = WPAD_MAX_WIIMOTES-1; chan >= 0; chan--)
|
||||
{
|
||||
if(left_stick_mag[chan] > 0.15 || abs(PAD_StickX(chan)) > 20 || abs(PAD_StickY(chan)) > 20 || abs(WUPC_lStickX(chan)) > 160 || abs(WUPC_lStickY(chan)) > 160
|
||||
|| (chan == 0 && (abs(DS3_StickX()) > 20 || abs(DS3_StickY()) > 20)) || (chan == 0 && (abs(WiiDRC_lStickX()) > 20 || abs(WiiDRC_lStickY()) > 20)))
|
||||
|| (chan == 0 && (abs(DS3_LStickX()) > 20 || abs(DS3_LStickY()) > 20)) || (chan == 0 && (abs(WiiDRC_lStickX()) > 20 || abs(WiiDRC_lStickY()) > 20)))
|
||||
{
|
||||
m_show_pointer[chan] = true;
|
||||
if(LEFT_STICK_LEFT)
|
||||
@ -281,7 +282,7 @@ void CMenu::LeftStick()
|
||||
speed = (u8)(left_stick_mag[chan] * 10.00);
|
||||
pSpeed = (u8)(((int)abs(PAD_StickX(chan))/10)|((int)abs(WUPC_lStickX(chan))/80)|((int)abs(WiiDRC_lStickX())/8));
|
||||
if(chan == 0)
|
||||
pSpeed |= (int)abs(DS3_StickX()/10);
|
||||
pSpeed |= (int)abs(DS3_LStickX()/10);
|
||||
if(stickPointer_x[chan] > m_cursor[chan].width()/2)
|
||||
stickPointer_x[chan] = stickPointer_x[chan]-speed-pSpeed;
|
||||
pointerhidedelay[chan] = 150;
|
||||
@ -291,7 +292,7 @@ void CMenu::LeftStick()
|
||||
speed = (u8)(left_stick_mag[chan] * 10.00);
|
||||
pSpeed = (u8)(((int)abs(PAD_StickY(chan))/10)|((int)abs(WUPC_lStickY(chan))/80)|((int)abs(WiiDRC_lStickY())/8));
|
||||
if(chan == 0)
|
||||
pSpeed |= (int)abs(DS3_StickY()/10);
|
||||
pSpeed |= (int)abs(DS3_LStickY()/10);
|
||||
if(stickPointer_y[chan] < (m_vid.height() + (m_cursor[chan].height()/2)))
|
||||
stickPointer_y[chan] = stickPointer_y[chan]+speed+pSpeed;
|
||||
pointerhidedelay[chan] = 150;
|
||||
@ -301,7 +302,7 @@ void CMenu::LeftStick()
|
||||
speed = (u8)(left_stick_mag[chan] * 10.00);
|
||||
pSpeed = (u8)(((int)abs(PAD_StickX(chan))/10)|((int)abs(WUPC_lStickX(chan))/80)|((int)abs(WiiDRC_lStickX())/8));
|
||||
if(chan == 0)
|
||||
pSpeed |= (int)abs(DS3_StickX()/10);
|
||||
pSpeed |= (int)abs(DS3_LStickX()/10);
|
||||
if(stickPointer_x[chan] < (m_vid.width() + (m_cursor[chan].width()/2)))
|
||||
stickPointer_x[chan] = stickPointer_x[chan]+speed+pSpeed;
|
||||
pointerhidedelay[chan] = 150;
|
||||
@ -311,7 +312,7 @@ void CMenu::LeftStick()
|
||||
speed = (u8)(left_stick_mag[chan] * 10.00);
|
||||
pSpeed = (u8)(((int)abs(PAD_StickY(chan))/10)|((int)abs(WUPC_lStickY(chan))/80)|((int)abs(WiiDRC_lStickY())/8));
|
||||
if(chan == 0)
|
||||
pSpeed |= (int)abs(DS3_StickY()/10);
|
||||
pSpeed |= (int)abs(DS3_LStickY()/10);
|
||||
if(stickPointer_y[chan] > m_cursor[chan].height()/2)
|
||||
stickPointer_y[chan] = stickPointer_y[chan]-speed-pSpeed;
|
||||
pointerhidedelay[chan] = 150;
|
||||
@ -496,7 +497,7 @@ bool CMenu::gc_btnRepeat(s64 btn)
|
||||
|
||||
bool CMenu::lStick_Up(void)
|
||||
{
|
||||
if(WiiDRC_lStickY() > 20 || DS3_StickY() < -20)
|
||||
if(WiiDRC_lStickY() > 20 || DS3_LStickY() < -20)
|
||||
return true;
|
||||
for(int chan = WPAD_MAX_WIIMOTES-1; chan >= 0; chan--)
|
||||
{
|
||||
@ -508,7 +509,7 @@ bool CMenu::lStick_Up(void)
|
||||
|
||||
bool CMenu::lStick_Right(void)
|
||||
{
|
||||
if(WiiDRC_lStickX() > 20 || DS3_StickX() > 20)
|
||||
if(WiiDRC_lStickX() > 20 || DS3_LStickX() > 20)
|
||||
return true;
|
||||
for(int chan = WPAD_MAX_WIIMOTES-1; chan >= 0; chan--)
|
||||
{
|
||||
@ -520,7 +521,7 @@ bool CMenu::lStick_Right(void)
|
||||
|
||||
bool CMenu::lStick_Down(void)
|
||||
{
|
||||
if(WiiDRC_lStickY() < -20 || DS3_StickY() > 20)
|
||||
if(WiiDRC_lStickY() < -20 || DS3_LStickY() > 20)
|
||||
return true;
|
||||
for(int chan = WPAD_MAX_WIIMOTES-1; chan >= 0; chan--)
|
||||
{
|
||||
@ -532,7 +533,7 @@ bool CMenu::lStick_Down(void)
|
||||
|
||||
bool CMenu::lStick_Left(void)
|
||||
{
|
||||
if(WiiDRC_lStickX() < -20 || DS3_StickX() < -20)
|
||||
if(WiiDRC_lStickX() < -20 || DS3_LStickX() < -20)
|
||||
return true;
|
||||
for(int chan = WPAD_MAX_WIIMOTES-1; chan >= 0; chan--)
|
||||
{
|
||||
@ -543,6 +544,7 @@ bool CMenu::lStick_Left(void)
|
||||
}
|
||||
|
||||
/* right stick movements are only used in menu_main and menu_game to move the coverflow up, down, left, right just like the d-pad */
|
||||
/* DS3 right stick is not checked */
|
||||
bool CMenu::rStick_Up(void)
|
||||
{
|
||||
if(WiiDRC_rStickY() > 30)
|
||||
|
@ -5,45 +5,41 @@
|
||||
#include <sicksaxis.h>
|
||||
#include "sicksaxis-wrapper.h"
|
||||
|
||||
static DS3 first;
|
||||
static DS3 Controller1;
|
||||
static bool psPressed = false;
|
||||
|
||||
bool DS3_Init()
|
||||
bool DS3_Init()// does not check for and connect controller
|
||||
{
|
||||
USB_Initialize();
|
||||
|
||||
if (ss_init() < 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
ss_initialize(&first);
|
||||
|
||||
ss_init();// add controller to ios heap
|
||||
ss_initialize(&Controller1);// set all values to initial states
|
||||
return true;
|
||||
}
|
||||
|
||||
void DS3_Rumble()
|
||||
{
|
||||
if (first.connected && psPressed)
|
||||
//if (DS3_Connected())
|
||||
if (Controller1.connected && psPressed)
|
||||
{
|
||||
ss_set_rumble(&first, 2, 255, 2, 255);
|
||||
ss_set_rumble(&Controller1, 2, 255, 2, 255);
|
||||
}
|
||||
}
|
||||
|
||||
void DS3_Cleanup()
|
||||
{
|
||||
psPressed = false;
|
||||
ss_close(&first);
|
||||
ss_close(&Controller1);
|
||||
USB_Deinitialize();
|
||||
}
|
||||
|
||||
unsigned int DS3_ButtonsDown()
|
||||
{
|
||||
if (!ss_is_connected(&first) || !psPressed)
|
||||
//if (!DS3_Connected())
|
||||
if (!ss_is_connected(&Controller1) || !psPressed)
|
||||
return 0;
|
||||
|
||||
DS3 *controller;
|
||||
controller = &first;
|
||||
controller = &Controller1;
|
||||
|
||||
unsigned int pressed = 0;
|
||||
|
||||
@ -68,46 +64,48 @@ unsigned int DS3_ButtonsDown()
|
||||
return pressed;
|
||||
}
|
||||
|
||||
bool DS3_Connected()
|
||||
bool DS3_Connected()// not used but could be used in the functions ButtonsDown() and Rumble() above
|
||||
{
|
||||
return first.connected > 0 && psPressed;
|
||||
return Controller1.connected > 0 && psPressed;
|
||||
}
|
||||
|
||||
/* does not scan pads. simply connects with the controller and starts a thread to read the controller. */
|
||||
/* on later calls it simply checks if the PS button on the controller has been pressed and lights up the LED */
|
||||
void DS3_ScanPads()
|
||||
{
|
||||
if (!ss_is_connected(&first))
|
||||
if (!ss_is_connected(&Controller1))
|
||||
{
|
||||
psPressed = false;
|
||||
ss_initialize(&first);
|
||||
if (ss_open(&first) > 0)
|
||||
ss_initialize(&Controller1);
|
||||
if (ss_open(&Controller1) > 0)
|
||||
{
|
||||
ss_start_reading(&first);
|
||||
ss_set_led(&first, 0);
|
||||
ss_start_reading(&Controller1);
|
||||
ss_set_led(&Controller1, 0);
|
||||
}
|
||||
}
|
||||
else if (first.pad.buttons.PS && !psPressed)
|
||||
else if (Controller1.pad.buttons.PS && !psPressed)
|
||||
{
|
||||
psPressed = true;
|
||||
ss_set_led(&first, 1);
|
||||
ss_set_led(&Controller1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
int DS3_StickX()
|
||||
int DS3_LStickX()
|
||||
{
|
||||
return psPressed? first.pad.left_analog.x - 128 : 0;
|
||||
return psPressed? Controller1.pad.left_analog.x - 128 : 0;
|
||||
}
|
||||
|
||||
int DS3_SubStickX()
|
||||
int DS3_RStickX()
|
||||
{
|
||||
return psPressed? first.pad.right_analog.x - 128 : 0;
|
||||
return psPressed? Controller1.pad.right_analog.x - 128 : 0;
|
||||
}
|
||||
|
||||
int DS3_StickY()
|
||||
int DS3_LStickY()
|
||||
{
|
||||
return psPressed? first.pad.left_analog.y - 128 : 0;
|
||||
return psPressed? Controller1.pad.left_analog.y - 128 : 0;
|
||||
}
|
||||
|
||||
int DS3_SubStickY()
|
||||
int DS3_RStickY()
|
||||
{
|
||||
return psPressed? first.pad.right_analog.y - 128 : 0;
|
||||
return psPressed? Controller1.pad.right_analog.y - 128 : 0;
|
||||
}
|
||||
|
@ -39,10 +39,10 @@ void DS3_Rumble();
|
||||
void DS3_Cleanup();
|
||||
unsigned int DS3_ButtonsDown();
|
||||
void DS3_ScanPads();
|
||||
int DS3_StickX();
|
||||
int DS3_SubStickX();
|
||||
int DS3_StickY();
|
||||
int DS3_SubStickY();
|
||||
int DS3_LStickX();
|
||||
int DS3_RStickX();
|
||||
int DS3_LStickY();
|
||||
int DS3_RStickY();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user