mirror of
https://github.com/izzy2lost/dolphin.git
synced 2026-06-19 01:16:48 -07:00
New Wiimote Plugin: Added "Upright Wiimote" option. Fixed a nunchuk problem in ZTP and Wii Sports with some Hacks. Some work on emulated Swing and Speaker (disabled). Fixes/Cleanups. ControllerInterface: Fixed an issue when a DInput device reports the same axis more than once. Fixed some old comments.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5422 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@@ -16,7 +16,6 @@
|
||||
#define CIFACE_USE_DIRECTINPUT
|
||||
#endif
|
||||
#if defined(HAVE_X11) && HAVE_X11
|
||||
// Xlib is not tested at all currently, it is like 80% complete at least though
|
||||
#define CIFACE_USE_XLIB
|
||||
#endif
|
||||
#ifndef CIFACE_USE_DIRECTINPUT_JOYSTICK
|
||||
@@ -74,7 +73,7 @@ public:
|
||||
//
|
||||
// Output
|
||||
//
|
||||
// guess wut it is, yup and output
|
||||
// an output on a device
|
||||
//
|
||||
class Output : public Control
|
||||
{
|
||||
@@ -175,7 +174,7 @@ public:
|
||||
// ControlReference
|
||||
//
|
||||
// these are what you create to actually use the inputs, InputReference or OutputReference
|
||||
// they have a vector < struct { device , vector < controls > } >
|
||||
// they have a DeviceQualifier and ControlQualifier used to match 1 or more inputs
|
||||
//
|
||||
// after being binded to devices and controls with ControllerInterface::UpdateReference,
|
||||
// each one can binded to a devices, and 0+ controls the device
|
||||
|
||||
+33
-17
@@ -4,6 +4,11 @@
|
||||
|
||||
#include "DirectInputJoystick.h"
|
||||
|
||||
inline bool operator<(const GUID & lhs, const GUID & rhs)
|
||||
{
|
||||
return memcmp(&lhs, &rhs, sizeof(GUID)) < 0 ? true : false;
|
||||
}
|
||||
|
||||
namespace ciface
|
||||
{
|
||||
namespace DirectInput
|
||||
@@ -231,8 +236,18 @@ Joystick::Joystick( /*const LPCDIDEVICEINSTANCE lpddi, */const LPDIRECTINPUTDEVI
|
||||
}
|
||||
// get up to 6 axes and 2 sliders
|
||||
std::vector<DIDEVICEOBJECTINSTANCE> axes;
|
||||
m_device->EnumObjects( DIEnumDeviceObjectsCallback, (LPVOID)&axes, DIDFT_ABSAXIS );
|
||||
|
||||
unsigned int cur_slider = 0;
|
||||
m_device->EnumObjects( DIEnumDeviceObjectsCallback, (LPVOID)&axes, DIDFT_AXIS );
|
||||
|
||||
// map of axis offsets in joystate dataformat based on axis guidType
|
||||
std::map<GUID,int> types;
|
||||
types[GUID_XAxis] = 0;
|
||||
types[GUID_YAxis] = 1;
|
||||
types[GUID_ZAxis] = 2;
|
||||
types[GUID_RxAxis] = 3;
|
||||
types[GUID_RyAxis] = 4;
|
||||
types[GUID_RzAxis] = 5;
|
||||
|
||||
// going in reverse leaves the list more organized in the end for me :/
|
||||
std::vector<DIDEVICEOBJECTINSTANCE>::const_reverse_iterator i = axes.rbegin(),
|
||||
@@ -254,24 +269,25 @@ Joystick::Joystick( /*const LPCDIDEVICEINSTANCE lpddi, */const LPDIRECTINPUTDEVI
|
||||
if ( DI_OK == m_device->GetProperty( DIPROP_RANGE, &range.diph ) )
|
||||
{
|
||||
int offset = -1;
|
||||
const GUID type = i->guidType;
|
||||
|
||||
// figure out which axis this is
|
||||
if ( type == GUID_XAxis )
|
||||
offset = 0;
|
||||
else if ( type == GUID_YAxis )
|
||||
offset = 1;
|
||||
else if ( type == GUID_ZAxis )
|
||||
offset = 2;
|
||||
else if ( type == GUID_RxAxis )
|
||||
offset = 3;
|
||||
else if ( type == GUID_RyAxis )
|
||||
offset = 4;
|
||||
else if ( type == GUID_RzAxis )
|
||||
offset = 5;
|
||||
else if ( type == GUID_Slider )
|
||||
if ( cur_slider < 2 )
|
||||
if (GUID_Slider ==i->guidType)
|
||||
{
|
||||
// max of 2 sliders / limit of used data format
|
||||
if (cur_slider < 2)
|
||||
offset = 6 + cur_slider++;
|
||||
}
|
||||
else
|
||||
{
|
||||
// don't add duplicate axes, some buggy drivers report the same axis twice
|
||||
const std::map<GUID,int>::iterator f = types.find(i->guidType);
|
||||
if (types.end() != f)
|
||||
{
|
||||
offset = f->second;
|
||||
// remove from the map so it isn't added again
|
||||
types.erase(f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( offset >= 0 )
|
||||
{
|
||||
|
||||
@@ -19,9 +19,9 @@ void GamepadPage::ConfigExtension( wxCommandEvent& event )
|
||||
const std::size_t orig_size = control_groups.size();
|
||||
|
||||
ControlGroupsSizer* const szr = new ControlGroupsSizer( ex->attachments[ex->switch_extension], pnl, this, &control_groups );
|
||||
pnl->SetSizerAndFit( szr );
|
||||
pnl->SetSizerAndFit( szr ); // needed
|
||||
pnl_szr->Add( pnl, 0, wxLEFT, 5 );
|
||||
dlg->SetSizerAndFit( pnl_szr );
|
||||
dlg->SetSizerAndFit( pnl_szr ); // needed
|
||||
|
||||
dlg->Center();
|
||||
|
||||
@@ -131,7 +131,7 @@ ControlDialog::ControlDialog( wxWindow* const parent, ControllerInterface::Contr
|
||||
szr->Add( d_szr, 0, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 5 );
|
||||
szr->Add( control_chooser, 0, wxEXPAND|wxALL, 5 );
|
||||
|
||||
SetSizerAndFit( szr );
|
||||
SetSizerAndFit( szr ); // needed
|
||||
|
||||
}
|
||||
|
||||
@@ -661,6 +661,7 @@ ControlGroupBox::ControlGroupBox( ControllerEmu::ControlGroup* const group, wxWi
|
||||
case GROUP_TYPE_STICK :
|
||||
case GROUP_TYPE_TILT :
|
||||
case GROUP_TYPE_CURSOR :
|
||||
case GROUP_TYPE_FORCE :
|
||||
{
|
||||
wxBitmap bitmap(64, 64);
|
||||
wxMemoryDC dc;
|
||||
@@ -871,7 +872,7 @@ GamepadPage::GamepadPage( wxWindow* parent, const unsigned int pad_num, ConfigDi
|
||||
|
||||
UpdateGUI();
|
||||
|
||||
SetSizerAndFit( mapping );
|
||||
SetSizerAndFit( mapping ); // needed
|
||||
Layout();
|
||||
};
|
||||
|
||||
@@ -911,7 +912,8 @@ ConfigDialog::ConfigDialog( wxWindow* const parent, Plugin& plugin, const std::s
|
||||
szr->Add( m_pad_notebook, 0, wxEXPAND|wxTOP|wxLEFT|wxRIGHT, 5 );
|
||||
szr->Add( btns, 0, wxEXPAND|wxALL, 5 );
|
||||
|
||||
SetSizerAndFit( szr );
|
||||
SetSizerAndFit( szr ); // needed
|
||||
|
||||
// not needed here it seems, but it cant hurt
|
||||
//Layout();
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ void ConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
|
||||
ge = current_page->control_groups.end();
|
||||
for ( ; g != ge; ++g )
|
||||
{
|
||||
|
||||
// if this control group has a bitmap
|
||||
if ( (*g)->static_bitmap )
|
||||
{
|
||||
|
||||
@@ -22,6 +22,20 @@ void ConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
|
||||
// just always update
|
||||
m_plugin.controller_interface.UpdateInput();
|
||||
|
||||
wxMemoryDC dc;
|
||||
wxBitmap bitmap((*g)->static_bitmap->GetBitmap());
|
||||
dc.SelectObject(bitmap);
|
||||
dc.Clear();
|
||||
|
||||
// label for sticks and stuff
|
||||
if (64 == bitmap.GetHeight())
|
||||
{
|
||||
wxFont small_font(6, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD);
|
||||
dc.SetFont(small_font);
|
||||
dc.SetTextForeground(0xC0C0C0);
|
||||
dc.DrawText(wxString::FromAscii((*g)->control_group->name).Upper(), 4, 2);
|
||||
}
|
||||
|
||||
switch ( (*g)->control_group->type )
|
||||
{
|
||||
case GROUP_TYPE_TILT :
|
||||
@@ -55,12 +69,6 @@ void ConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
|
||||
xx *= 32 - 1; xx += 32;
|
||||
yy *= 32 - 1; yy += 32;
|
||||
|
||||
// setup
|
||||
wxBitmap bitmap(64, 64);
|
||||
wxMemoryDC dc;
|
||||
dc.SelectObject(bitmap);
|
||||
dc.Clear();
|
||||
|
||||
// draw the shit
|
||||
|
||||
// ir cursor forward movement
|
||||
@@ -75,7 +83,10 @@ void ConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
|
||||
dc.SetPen(*wxLIGHT_GREY_PEN);
|
||||
dc.SetBrush(*wxWHITE_BRUSH);
|
||||
if ( GROUP_TYPE_STICK == (*g)->control_group->type )
|
||||
{
|
||||
dc.SetBrush(*wxTRANSPARENT_BRUSH);
|
||||
dc.DrawCircle( 32, 32, 32);
|
||||
}
|
||||
else
|
||||
dc.DrawRectangle( 16, 16, 32, 32 );
|
||||
|
||||
@@ -106,27 +117,70 @@ void ConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
|
||||
//dc.DrawRectangle( x-4, 64-y-1, 8, 2 );
|
||||
}
|
||||
|
||||
// box outline
|
||||
// Windows XP color
|
||||
dc.SetPen(wxPen(_T("#7f9db9")));
|
||||
dc.SetBrush(*wxTRANSPARENT_BRUSH);
|
||||
dc.DrawRectangle(0, 0, 64, 64);
|
||||
}
|
||||
break;
|
||||
case GROUP_TYPE_FORCE :
|
||||
{
|
||||
float raw_dot[3];
|
||||
float adj_dot[3];
|
||||
const float deadzone = 32 * ((*g)->control_group)->settings[0]->value;
|
||||
|
||||
// done drawing
|
||||
dc.SelectObject(wxNullBitmap);
|
||||
// adjusted
|
||||
((ControllerEmu::Force*)(*g)->control_group)->GetState( adj_dot, 32.0, 32-1.5 );
|
||||
|
||||
// raw
|
||||
for ( unsigned int i=0; i<3; ++i )
|
||||
{
|
||||
raw_dot[i] = (*g)->control_group->controls[i*2 + 1]->control_ref->State()
|
||||
- (*g)->control_group->controls[i*2]->control_ref->State();
|
||||
raw_dot[i] *= 32 - 1; raw_dot[i] += 32;
|
||||
}
|
||||
|
||||
// deadzone rect for forward/backward visual
|
||||
dc.SetBrush(*wxLIGHT_GREY_BRUSH);
|
||||
dc.SetPen(*wxLIGHT_GREY_PEN);
|
||||
dc.DrawRectangle( 0, 32 - deadzone, 64, deadzone * 2 );
|
||||
|
||||
// raw forward/background line
|
||||
dc.SetPen(*wxGREY_PEN);
|
||||
dc.SetBrush(*wxGREY_BRUSH);
|
||||
dc.DrawRectangle( 0, raw_dot[2] - 1, 64, 2 );
|
||||
|
||||
// adjusted forward/background line
|
||||
if ( adj_dot[2]!=32 )
|
||||
{
|
||||
dc.SetPen(*wxRED_PEN);
|
||||
dc.SetBrush(*wxRED_BRUSH);
|
||||
dc.DrawRectangle( 0, adj_dot[2] - 1, 64, 2 );
|
||||
}
|
||||
|
||||
// a rectangle, for looks i guess
|
||||
dc.SetBrush(*wxWHITE_BRUSH);
|
||||
dc.SetPen(*wxLIGHT_GREY_PEN);
|
||||
dc.DrawRectangle( 16, 16, 32, 32 );
|
||||
|
||||
// deadzone square
|
||||
dc.SetBrush(*wxLIGHT_GREY_BRUSH);
|
||||
dc.DrawRectangle( 32 - deadzone, 32 - deadzone, deadzone * 2, deadzone * 2 );
|
||||
|
||||
// raw dot
|
||||
dc.SetPen(*wxGREY_PEN);
|
||||
dc.SetBrush(*wxGREY_BRUSH);
|
||||
dc.DrawRectangle( raw_dot[1] - 2, raw_dot[0] - 2, 4, 4 );
|
||||
|
||||
// adjusted dot
|
||||
if ( adj_dot[1]!=32 || adj_dot[0]!=32 )
|
||||
{
|
||||
dc.SetPen(*wxRED_PEN);
|
||||
dc.SetBrush(*wxRED_BRUSH);
|
||||
dc.DrawRectangle( adj_dot[1]-2, adj_dot[0]-2, 4, 4 );
|
||||
}
|
||||
|
||||
// set the shit
|
||||
(*g)->static_bitmap->SetBitmap( bitmap );
|
||||
}
|
||||
break;
|
||||
case GROUP_TYPE_BUTTONS :
|
||||
{
|
||||
const unsigned int button_count = ((unsigned int)(*g)->control_group->controls.size());
|
||||
// setup
|
||||
wxBitmap bitmap(12*button_count+1, 12);
|
||||
wxMemoryDC dc;
|
||||
dc.SelectObject(bitmap);
|
||||
dc.Clear();
|
||||
|
||||
// draw the shit
|
||||
dc.SetPen(*wxGREY_PEN);
|
||||
@@ -140,7 +194,6 @@ void ConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
|
||||
|
||||
for ( unsigned int n = 0; n<button_count; ++n )
|
||||
{
|
||||
// TODO: threshold stuff, actually redo this crap with the GetState func
|
||||
if ( buttons & bitmasks[n] )
|
||||
dc.SetBrush( *wxRED_BRUSH );
|
||||
else
|
||||
@@ -152,28 +205,12 @@ void ConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
|
||||
}
|
||||
|
||||
delete bitmasks;
|
||||
|
||||
// box outline
|
||||
// Windows XP color
|
||||
dc.SetPen(wxPen(_T("#7f9db9")));
|
||||
dc.SetBrush(*wxTRANSPARENT_BRUSH);
|
||||
dc.DrawRectangle(0, 0, bitmap.GetWidth(), bitmap.GetHeight());
|
||||
|
||||
// done drawing
|
||||
dc.SelectObject(wxNullBitmap);
|
||||
|
||||
// set the shit
|
||||
(*g)->static_bitmap->SetBitmap( bitmap );
|
||||
|
||||
}
|
||||
break;
|
||||
case GROUP_TYPE_TRIGGERS :
|
||||
{
|
||||
const unsigned int trigger_count = ((unsigned int)((*g)->control_group->controls.size()));
|
||||
// setup
|
||||
wxBitmap bitmap( 64, 12*trigger_count+1);
|
||||
wxMemoryDC dc;
|
||||
dc.SelectObject(bitmap);
|
||||
dc.Clear();
|
||||
|
||||
// draw the shit
|
||||
dc.SetPen(*wxGREY_PEN);
|
||||
@@ -200,26 +237,11 @@ void ConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
|
||||
dc.SetBrush(*wxTRANSPARENT_BRUSH);
|
||||
dc.DrawRectangle(0, 0, deadzone*64, trigger_count*14);
|
||||
|
||||
// box outline
|
||||
// Windows XP color
|
||||
dc.SetPen(wxPen(_T("#7f9db9")));
|
||||
dc.DrawRectangle(0, 0, bitmap.GetWidth(), bitmap.GetHeight());
|
||||
|
||||
// done drawing
|
||||
dc.SelectObject(wxNullBitmap);
|
||||
|
||||
// set the shit
|
||||
(*g)->static_bitmap->SetBitmap( bitmap );
|
||||
}
|
||||
break;
|
||||
case GROUP_TYPE_MIXED_TRIGGERS :
|
||||
{
|
||||
const unsigned int trigger_count = ((unsigned int)((*g)->control_group->controls.size() / 2));
|
||||
// setup
|
||||
wxBitmap bitmap( 64+12+1, 12*trigger_count+1);
|
||||
wxMemoryDC dc;
|
||||
dc.SelectObject(bitmap);
|
||||
dc.Clear();
|
||||
|
||||
// draw the shit
|
||||
dc.SetPen(*wxGREY_PEN);
|
||||
@@ -245,22 +267,21 @@ void ConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
|
||||
dc.SetBrush(*wxTRANSPARENT_BRUSH);
|
||||
dc.DrawRectangle(thresh*64, 0, 128, trigger_count*14);
|
||||
|
||||
// box outline
|
||||
// Windows XP color
|
||||
dc.SetPen(wxPen(_T("#7f9db9")));
|
||||
dc.DrawRectangle(0, 0, bitmap.GetWidth(), bitmap.GetHeight());
|
||||
|
||||
// done drawing
|
||||
dc.SelectObject(wxNullBitmap);
|
||||
|
||||
// set the shit
|
||||
(*g)->static_bitmap->SetBitmap( bitmap );
|
||||
}
|
||||
break;
|
||||
default :
|
||||
break;
|
||||
}
|
||||
|
||||
// box outline
|
||||
// Windows XP color
|
||||
dc.SetPen(wxPen(_T("#7f9db9")));
|
||||
dc.SetBrush(*wxTRANSPARENT_BRUSH);
|
||||
dc.DrawRectangle(0, 0, bitmap.GetWidth(), bitmap.GetHeight());
|
||||
|
||||
dc.SelectObject(wxNullBitmap);
|
||||
(*g)->static_bitmap->SetBitmap(bitmap);
|
||||
|
||||
m_plugin.interface_crit.Leave();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -251,18 +251,15 @@ ControllerEmu::Triggers::Triggers( const char* const _name ) : ControlGroup( _na
|
||||
|
||||
ControllerEmu::Force::Force( const char* const _name ) : ControlGroup( _name, GROUP_TYPE_FORCE )
|
||||
{
|
||||
controls.push_back( new Input( "X-" ) );
|
||||
controls.push_back( new Input( "X+" ) );
|
||||
controls.push_back( new Input( "Y-" ) );
|
||||
controls.push_back( new Input( "Y+" ) );
|
||||
controls.push_back( new Input( "Z-" ) );
|
||||
controls.push_back( new Input( "Z+" ) );
|
||||
}
|
||||
controls.push_back( new Input( "Up" ) );
|
||||
controls.push_back( new Input( "Down" ) );
|
||||
controls.push_back( new Input( "Left" ) );
|
||||
controls.push_back( new Input( "Right" ) );
|
||||
controls.push_back( new Input( "Forward" ) );
|
||||
controls.push_back( new Input( "Backward" ) );
|
||||
controls.push_back( new Input( "Modifier" ) );
|
||||
|
||||
void ControllerEmu::Force::GetState( u8* data, const u8 base, const u8 range )
|
||||
{
|
||||
for ( unsigned int i=0; i<3; ++i,++data )
|
||||
*data = u8( ( controls[i*2+1]->control_ref->State() - controls[i*2]->control_ref->State() ) * range + base );
|
||||
settings.push_back( new Setting("Dead Zone", 0, 1, 50 ) );
|
||||
}
|
||||
|
||||
ControllerEmu::Tilt::Tilt( const char* const _name ) : ControlGroup( _name, GROUP_TYPE_TILT )
|
||||
@@ -287,10 +284,12 @@ ControllerEmu::Cursor::Cursor( const char* const _name, const SWiimoteInitialize
|
||||
{
|
||||
for ( unsigned int i = 0; i < 4; ++i )
|
||||
controls.push_back( new Input( named_directions[i] ) );
|
||||
controls.push_back( new Input( "Forward" ) );
|
||||
controls.push_back( new Input( "Hide" ) );
|
||||
|
||||
settings.push_back( new Setting("Center", 0.5f ) );
|
||||
settings.push_back( new Setting("Width", 0.5f ) );
|
||||
settings.push_back( new Setting("Height", 0.5f ) );
|
||||
settings.push_back( new Setting("Top", 0.5f ) );
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -237,7 +237,20 @@ public:
|
||||
public:
|
||||
Force( const char* const _name );
|
||||
|
||||
void GetState( u8* data, const u8 base, const u8 range );
|
||||
template <typename C, typename R>
|
||||
void GetState( C* axis, const u8 base, const R range )
|
||||
{
|
||||
const float deadzone = settings[0]->value;
|
||||
for ( unsigned int i=0; i<6; i+=2 )
|
||||
{
|
||||
const float state = controls[i+1]->control_ref->State() - controls[i]->control_ref->State();
|
||||
if (abs(state) > deadzone)
|
||||
*axis++ = (C)((state - (deadzone * sign(state))) / (1 - deadzone) * range + base);
|
||||
//*axis++ = state * range + base;
|
||||
else
|
||||
*axis++ = (C)(base);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class Tilt : public ControlGroup
|
||||
@@ -333,9 +346,9 @@ public:
|
||||
// adjust cursor according to settings
|
||||
if (adjusted)
|
||||
{
|
||||
xx *= ( settings[0]->value * 2 );
|
||||
yy *= ( settings[1]->value * 2 );
|
||||
yy += ( settings[2]->value - 0.5f );
|
||||
xx *= ( settings[1]->value * 2 );
|
||||
yy *= ( settings[2]->value * 2 );
|
||||
yy += ( settings[0]->value - 0.5f );
|
||||
}
|
||||
|
||||
*x = xx;
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="SDL.lib xinput.lib comctl32.lib winmm.lib wiiuse.lib rpcrt4.lib wxbase28ud.lib wxmsw28ud_core.lib"
|
||||
AdditionalDependencies="SDL.lib xinput.lib comctl32.lib winmm.lib wiiuse.lib rpcrt4.lib wxbase28ud.lib wxmsw28ud_core.lib openal32.lib"
|
||||
OutputFile="..\..\..\Binary\Win32/Plugins\Plugin_WiimoteNewD.dll"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories="..\..\..\Externals\SDL\win32;..\..\..\Externals\WiiUse\win32;..\..\..\Externals\wxWidgets\lib\vc_lib\Win32"
|
||||
@@ -151,7 +151,7 @@
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="SDL.lib xinput.lib comctl32.lib winmm.lib wiiuse.lib rpcrt4.lib wxbase28ud.lib wxmsw28ud_core.lib"
|
||||
AdditionalDependencies="SDL.lib xinput.lib comctl32.lib winmm.lib wiiuse.lib rpcrt4.lib wxbase28ud.lib wxmsw28ud_core.lib openal32.lib"
|
||||
OutputFile="..\..\..\Binary\x64\Plugins\Plugin_WiimoteNewD.dll"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories="..\..\..\Externals\SDL\x64;..\..\..\Externals\WiiUse\x64;..\..\..\Externals\wxWidgets\lib\vc_lib\x64"
|
||||
@@ -235,10 +235,10 @@
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalOptions="/NODEFAULTLIB:msvcrt.lib"
|
||||
AdditionalDependencies="SDL.lib xinput.lib comctl32.lib winmm.lib wiiuse.lib wxbase28u.lib wxmsw28u_core.lib"
|
||||
AdditionalDependencies="SDL.lib xinput.lib comctl32.lib winmm.lib wxbase28u.lib wxmsw28u_core.lib openal32.lib"
|
||||
OutputFile="..\..\..\Binary\Win32\Plugins\Plugin_WiimoteNew.dll"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories="..\..\..\Externals\SDL\win32;..\..\..\Externals\WiiUse\win32;..\..\..\Externals\wxWidgets\lib\vc_lib\Win32"
|
||||
AdditionalLibraryDirectories="..\..\..\Externals\SDL\win32;..\..\..\Externals\wxWidgets\lib\vc_lib\x64;../../../Externals/OpenAL/Win32/"
|
||||
GenerateManifest="false"
|
||||
GenerateDebugInformation="true"
|
||||
ProgramDatabaseFile="$(PlatformName)\$(ConfigurationName)\$(TargetName).pdb"
|
||||
@@ -320,10 +320,10 @@
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="SDL.lib xinput.lib comctl32.lib winmm.lib wiiuse.lib wxbase28u.lib wxmsw28u_core.lib"
|
||||
AdditionalDependencies="SDL.lib xinput.lib comctl32.lib winmm.lib wxbase28u.lib wxmsw28u_core.lib openal32.lib"
|
||||
OutputFile="..\..\..\Binary\x64\Plugins\Plugin_WiimoteNew.dll"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories="..\..\..\Externals\SDL\x64;..\..\..\Externals\WiiUse\x64;..\..\..\Externals\wxWidgets\lib\vc_lib\x64"
|
||||
AdditionalLibraryDirectories="..\..\..\Externals\SDL\x64;..\..\..\Externals\wxWidgets\lib\vc_lib\x64;../../../Externals/OpenAL/Win64/"
|
||||
GenerateManifest="false"
|
||||
GenerateDebugInformation="true"
|
||||
ProgramDatabaseFile="$(PlatformName)\$(ConfigurationName)\$(TargetName).pdb"
|
||||
@@ -402,7 +402,7 @@
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalOptions="/NODEFAULTLIB:msvcrt.lib"
|
||||
AdditionalDependencies="SDL.lib xinput.lib comctl32.lib winmm.lib wiiuse.lib wxbase28u.lib wxmsw28u_core.lib"
|
||||
AdditionalDependencies="SDL.lib xinput.lib comctl32.lib winmm.lib wiiuse.lib wxbase28u.lib wxmsw28u_core.lib openal32.lib"
|
||||
OutputFile="..\..\..\Binary\Win32\Plugins\Plugin_WiimoteNewDF.dll"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories="..\..\..\Externals\SDL\win32;..\..\..\Externals\WiiUse\win32;..\..\..\Externals\wxWidgets\lib\vc_lib\Win32"
|
||||
@@ -484,7 +484,7 @@
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="SDL.lib xinput.lib comctl32.lib winmm.lib wiiuse.lib wxbase28u.lib wxmsw28u_core.lib"
|
||||
AdditionalDependencies="SDL.lib xinput.lib comctl32.lib winmm.lib wiiuse.lib wxbase28u.lib wxmsw28u_core.lib openal32.lib"
|
||||
OutputFile="..\..\..\Binary\x64\Plugins\Plugin_WiimoteNewDF.dll"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories="..\..\..\Externals\SDL\x64;..\..\..\Externals\WiiUse\x64;..\..\..\Externals\wxWidgets\lib\vc_lib\x64"
|
||||
@@ -540,6 +540,10 @@
|
||||
RelativePath=".\Src\WiimoteEmu\Encryption.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\WiimoteEmu\Speaker.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\WiimoteEmu\WiimoteEmu.cpp"
|
||||
>
|
||||
|
||||
@@ -15,6 +15,7 @@ files = [
|
||||
'WiimoteEmu/Attachment/Guitar.cpp',
|
||||
'WiimoteEmu/EmuSubroutines.cpp',
|
||||
'WiimoteEmu/Encryption.cpp',
|
||||
'WiimoteEmu/Speaker.cpp',
|
||||
'WiimoteNew.cpp',
|
||||
]
|
||||
|
||||
|
||||
@@ -39,9 +39,10 @@ Nunchuk::Nunchuk() : Attachment( "Nunchuk" )
|
||||
// stick
|
||||
groups.push_back( m_stick = new AnalogStick( "Stick" ) );
|
||||
|
||||
// force
|
||||
//groups.push_back( m_tilt = new Tilt( "Tilt" ) );
|
||||
groups.push_back( m_tilt = new Tilt( "Pitch and Roll" ) );
|
||||
// tilt
|
||||
groups.push_back( m_tilt = new Tilt( "Tilt" ) );
|
||||
|
||||
// swing
|
||||
//groups.push_back( m_swing = new Force( "Swing" ) );
|
||||
|
||||
// shake
|
||||
@@ -57,7 +58,7 @@ Nunchuk::Nunchuk() : Attachment( "Nunchuk" )
|
||||
memcpy( ®[0xfa], nunchuck_id, sizeof(nunchuck_id) );
|
||||
|
||||
// this should get set to 0 on disconnect, but it isn't, o well
|
||||
m_shake_step = 0;
|
||||
memset(m_shake_step, 0, sizeof(m_shake_step));
|
||||
}
|
||||
|
||||
void Nunchuk::GetState( u8* const data, const bool focus )
|
||||
@@ -68,43 +69,18 @@ void Nunchuk::GetState( u8* const data, const bool focus )
|
||||
m_stick->GetState( &ncdata->jx, &ncdata->jy, 0x80, focus ? 127 : 0 );
|
||||
|
||||
// tilt
|
||||
float x, y;
|
||||
m_tilt->GetState( &x, &y, 0, focus ? (PI / 2) : 0 ); // 90 degrees
|
||||
EmulateTilt((wm_accel*)&ncdata->ax, m_tilt, (accel_cal*)®[0x20], focus);
|
||||
|
||||
// this isn't doing anything with those low bits in the calib data, o well
|
||||
|
||||
const accel_cal* const cal = (accel_cal*)®[0x20];
|
||||
const u8* const zero_g = &cal->zero_g.x;
|
||||
u8 one_g[3];
|
||||
for ( unsigned int i=0; i<3; ++i )
|
||||
one_g[i] = (&cal->one_g.x)[i] - zero_g[i];
|
||||
|
||||
// this math should be good enough :P
|
||||
ncdata->az = u8(sin( (PI / 2) - std::max( abs(x), abs(y) ) ) * one_g[2] + zero_g[2]);
|
||||
ncdata->ax = u8(sin(x) * -one_g[0] + zero_g[0]);
|
||||
ncdata->ay = u8(sin(y) * one_g[1] + zero_g[1]);
|
||||
|
||||
// shake
|
||||
const unsigned int btns[] = { 0x01, 0x02, 0x04 };
|
||||
unsigned int shake = 0;
|
||||
if (focus)
|
||||
m_shake->GetState( &shake, btns );
|
||||
if (shake)
|
||||
{
|
||||
for ( unsigned int i=0; i<3; ++i )
|
||||
if ( shake & (1 << i) )
|
||||
(&ncdata->ax)[i] = shake_data[m_shake_step];
|
||||
m_shake_step = (m_shake_step + 1) % sizeof(shake_data);
|
||||
}
|
||||
else
|
||||
m_shake_step = 0;
|
||||
|
||||
// buttons
|
||||
if (focus)
|
||||
// shake
|
||||
EmulateShake(&ncdata->ax, m_shake, m_shake_step);
|
||||
// buttons
|
||||
m_buttons->GetState( &ncdata->bt, nunchuk_button_bitmasks );
|
||||
}
|
||||
|
||||
// flip the button bits :/
|
||||
ncdata->bt ^= 0x3;
|
||||
ncdata->bt ^= 0x03;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ private:
|
||||
Buttons* m_buttons;
|
||||
AnalogStick* m_stick;
|
||||
|
||||
unsigned int m_shake_step;
|
||||
unsigned int m_shake_step[3];
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -65,6 +65,11 @@ void Wiimote::ReportMode(const u16 _channelID, wm_report_mode* dr)
|
||||
m_reporting_mode = dr->mode;
|
||||
m_reporting_channel = _channelID;
|
||||
|
||||
// some hax to skip a few Update() cycles to fix a nunchuk prob in ztp and wii sports
|
||||
// skipping 10 seems to work
|
||||
// probably like 1/6th of a second that the user won't have control :/
|
||||
m_skip_update = 10;
|
||||
|
||||
if (0 == dr->all_the_time)
|
||||
PanicAlert("Wiimote: Reporting Always is set to OFF! Everything should be fine, but games never do this.");
|
||||
|
||||
@@ -137,24 +142,21 @@ void Wiimote::HidOutputReport(const u16 _channelID, wm_report* sr)
|
||||
break;
|
||||
|
||||
case WM_WRITE_SPEAKER_DATA : // 0x18
|
||||
#ifdef USE_WIIMOTE_EMU_SPEAKER
|
||||
SpeakerData((wm_speaker_data*)sr->data);
|
||||
#endif
|
||||
// TODO: Does this need an ack?
|
||||
{
|
||||
// testing
|
||||
//wm_speaker_data* const sd = (wm_speaker_data*)sr->data;
|
||||
//unsigned int length = sd->length >> 3;
|
||||
|
||||
//PanicAlert( "WM Speaker Data:\nlength: %d\nformat: 0x%x\nrate: 0x%x\nvolume: 0x%x",
|
||||
//length, m_reg_speaker->format, m_reg_speaker->sample_rate, m_reg_speaker->volume );
|
||||
|
||||
//for (unsigned int i=0; i<length; ++i)
|
||||
// m_speaker_data.push(0);
|
||||
}
|
||||
return; // no ack
|
||||
break;
|
||||
|
||||
case WM_SPEAKER_MUTE : // 0x19
|
||||
//INFO_LOG(WIIMOTE, "WM Speaker Mute: 0x%02x", sr->data[0]);
|
||||
//PanicAlert( "WM Speaker Mute: %d", sr->data[0] & 0x04 );
|
||||
#ifdef USE_WIIMOTE_EMU_SPEAKER
|
||||
// testing
|
||||
if (sr->data[0] ^ 0x04)
|
||||
m_channel_status.step = 0;
|
||||
#endif
|
||||
m_speaker_mute = (sr->data[0] & 0x04) ? 1 : 0;
|
||||
break;
|
||||
|
||||
@@ -240,7 +242,6 @@ void Wiimote::RequestStatus(const u16 _channelID, wm_request_status* rs)
|
||||
void Wiimote::WriteData(const u16 _channelID, wm_write_data* wd)
|
||||
{
|
||||
u32 address = convert24bit(wd->address);
|
||||
//u16 size = convert16bit(rd->size);
|
||||
|
||||
// ignore the 0x010000 bit
|
||||
address &= 0xFEFFFF;
|
||||
@@ -302,13 +303,16 @@ void Wiimote::WriteData(const u16 _channelID, wm_write_data* wd)
|
||||
// that we send it parts of a key, only the last full key will have an effect
|
||||
// I might have f'ed this up
|
||||
if ( address >= 0xa40040 && address <= 0xa4004c )
|
||||
{
|
||||
u8 data[WIIMOTE_REG_EXT_SIZE];
|
||||
m_register.Read( 0xa40000, data, WIIMOTE_REG_EXT_SIZE );
|
||||
wiimote_gen_key( &m_ext_key, data + 0x40 );
|
||||
}
|
||||
wiimote_gen_key(&m_ext_key, m_reg_ext->encryption_key);
|
||||
//else if ( address >= 0xa40020 && address < 0xa40040 )
|
||||
// PanicAlert("Writing to extension calibration data! Extension may misbehave");
|
||||
}
|
||||
break;
|
||||
// ir
|
||||
case 0xB0 :
|
||||
if (5 == m_reg_ir->mode)
|
||||
PanicAlert("IR Full Mode is Unsupported!");
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -386,8 +390,11 @@ void Wiimote::ReadData(const u16 _channelID, wm_read_data* rd)
|
||||
{
|
||||
// Encrypt data read from extension register
|
||||
// Check if encrypted reads is on
|
||||
if ( m_reg_ext[0xf0] == 0xaa )
|
||||
if (0xaa == m_reg_ext->encryption)
|
||||
wiimote_encrypt(&m_ext_key, block, address & 0xffff, (u8)size);
|
||||
|
||||
//if ( address >= 0xa40008 && address < 0xa40020 )
|
||||
// PanicAlert("Reading extension data from register");
|
||||
}
|
||||
break;
|
||||
// motion plus
|
||||
|
||||
@@ -18,11 +18,10 @@
|
||||
|
||||
|
||||
#include "Common.h"
|
||||
#include "pluginspecs_wiimote.h"
|
||||
#include "Encryption.h"
|
||||
|
||||
|
||||
u8 ans_tbl[7][6] = {
|
||||
static const u8 ans_tbl[7][6] = {
|
||||
{0xA8,0x77,0xA6,0xE0,0xF7,0x43},
|
||||
{0x5A,0x35,0x85,0xE2,0x72,0x97},
|
||||
{0x8F,0xB7,0x1A,0x62,0x87,0x38},
|
||||
@@ -32,7 +31,7 @@ u8 ans_tbl[7][6] = {
|
||||
{0x30,0x7E,0x90, 0xE,0x85, 0xA},
|
||||
};
|
||||
|
||||
u8 tsbox[256] = {
|
||||
static const u8 tsbox[256] = {
|
||||
0x70,0x51, 3,0x86,0x40, 0xD,0x4F,0xEB,0x3E,0xCC,0xD1,0x87,0x35,0xBD,0xF5, 0xB,
|
||||
0x5E,0xD0,0xF8,0xF2,0xD5,0xE2,0x6C,0x31, 0xC,0xAD,0xFC,0x21,0xC3,0x78,0xC1, 6,
|
||||
0xC2,0x4C,0x55,0xE6,0x4A,0x34,0x48,0x11,0x1E,0xDA,0xE7,0x1A,0x84,0xA0,0x96,0xA7,
|
||||
@@ -51,7 +50,7 @@ u8 tsbox[256] = {
|
||||
0x8B,0x9B, 8, 0xF,0xDC,0x81,0x18,0x20, 4,0xE4,0x71,0xCF,0xE9,0x2B,0x42,0x58,
|
||||
};
|
||||
|
||||
u8 sboxes[8][256] = {
|
||||
static const u8 sboxes[8][256] = {
|
||||
{
|
||||
1,0xA0,0xA9,0x62,0xD6,0x3F,0x85,0xA7,0xB6,0xD4,0xFA,0x15,0x66,0x17, 9,0xBD,
|
||||
0x5D,0x14,0x34,0x26,0x59,0x72,0x91,0x54, 6,0x4F,0xF8,0xB0,0x5B,0x74,0x93,0x99,
|
||||
@@ -199,18 +198,18 @@ u8 sboxes[8][256] = {
|
||||
};
|
||||
|
||||
|
||||
static inline u8 ror8(u8 a, u8 b) {
|
||||
static inline u8 ror8(const u8 a, const u8 b)
|
||||
{
|
||||
return (a>>b) | ((a<<(8-b))&0xff);
|
||||
}
|
||||
|
||||
|
||||
void genkey(u8 *rand, u8 idx, u8 *key)
|
||||
void genkey(const u8* const rand, const u8 idx, u8* const key)
|
||||
{
|
||||
u8 *ans = ans_tbl[idx];
|
||||
const u8* const ans = ans_tbl[idx];
|
||||
u8 t0[10];
|
||||
int i;
|
||||
|
||||
for(i=0;i<10;i++)
|
||||
for(int i=0; i<10; ++i)
|
||||
t0[i] = tsbox[rand[i]];
|
||||
|
||||
key[0] = ((ror8((ans[0]^t0[5]),(t0[2]%8)) - t0[9]) ^ t0[4]);
|
||||
@@ -222,7 +221,7 @@ void genkey(u8 *rand, u8 idx, u8 *key)
|
||||
}
|
||||
|
||||
|
||||
void gentabs(u8 *rand, u8 *key, u8 idx, u8 *ft, u8 *sb)
|
||||
void gentabs(const u8* const rand, const u8* const key, const u8 idx, u8* const ft, u8* const sb)
|
||||
{
|
||||
ft[0] = sboxes[idx][key[4]] ^ sboxes[(idx+1)%8][rand[3]];
|
||||
ft[1] = sboxes[idx][key[2]] ^ sboxes[(idx+1)%8][rand[5]];
|
||||
@@ -247,25 +246,25 @@ void gentabs(u8 *rand, u8 *key, u8 idx, u8 *ft, u8 *sb)
|
||||
|
||||
|
||||
/* Generate key from the 0x40-0x4c data in g_RegExt */
|
||||
void wiimote_gen_key(wiimote_key *key, u8 *keydata)
|
||||
void wiimote_gen_key(wiimote_key* const key, const u8* const keydata)
|
||||
{
|
||||
u8 rand[10];
|
||||
u8 skey[6];
|
||||
u8 testkey[6];
|
||||
int idx;
|
||||
|
||||
for(int i=0;i<10;i++)
|
||||
for (int i=0; i<10; ++i)
|
||||
rand[9-i] = keydata[i];
|
||||
for(int i=0;i<6;i++)
|
||||
for (int i=0; i<6; ++i)
|
||||
skey[5-i] = keydata[i+10];
|
||||
|
||||
//DEBUG_LOG(WIIMOTE, "rand: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x", rand[0], rand[1], rand[2], rand[3], rand[4], rand[5], rand[6], rand[7], rand[8], rand[9]);
|
||||
//DEBUG_LOG(WIIMOTE, "key: %02x %02x %02x %02x %02x %02x", skey[0], skey[1], skey[2], skey[3], skey[4], skey[5]);
|
||||
|
||||
for(idx = 0; idx < 7; idx++)
|
||||
for(idx = 0; idx < 7; ++idx)
|
||||
{
|
||||
genkey(rand, idx, testkey);
|
||||
if(!memcmp(testkey, skey, 6))
|
||||
if (0 == memcmp(testkey, skey, 6))
|
||||
break;
|
||||
}
|
||||
// default case is idx = 7 which is valid (homebrew uses it for the 0x17 case)
|
||||
@@ -281,16 +280,16 @@ void wiimote_gen_key(wiimote_key *key, u8 *keydata)
|
||||
|
||||
// TODO: is there a reason these can only handle a length of 255?
|
||||
/* Encrypt data */
|
||||
void wiimote_encrypt(wiimote_key *key, u8 *data, int addr, u8 len)
|
||||
void wiimote_encrypt(const wiimote_key* const key, u8* const data, int addr, const u8 len)
|
||||
{
|
||||
for(int i = 0; i < len; i++, addr++)
|
||||
data[i] = (data[i] - key->ft[addr%8]) ^ key->sb[addr%8];
|
||||
for (int i = 0; i < len; ++i, ++addr)
|
||||
data[i] = (data[i] - key->ft[addr % 8]) ^ key->sb[addr % 8];
|
||||
}
|
||||
|
||||
|
||||
/* Decrypt data */
|
||||
void wiimote_decrypt(wiimote_key *key, u8 *data, int addr, u8 len)
|
||||
void wiimote_decrypt(const wiimote_key* const key, u8* const data, int addr, const u8 len)
|
||||
{
|
||||
for(int i = 0; i < len; i++, addr++)
|
||||
data[i] = (data[i] ^ key->sb[addr%8]) + key->ft[addr%8];
|
||||
for (int i = 0; i < len; ++i, ++addr)
|
||||
data[i] = (data[i] ^ key->sb[addr % 8]) + key->ft[addr % 8];
|
||||
}
|
||||
|
||||
@@ -31,10 +31,10 @@ struct wiimote_key
|
||||
};
|
||||
|
||||
|
||||
void wiimote_encrypt(wiimote_key *key, u8 *data, int addr, u8 len);
|
||||
void wiimote_decrypt(wiimote_key *key, u8 *data, int addr, u8 len);
|
||||
void wiimote_encrypt(const wiimote_key* const key, u8* const data, int addr, const u8 len);
|
||||
void wiimote_decrypt(const wiimote_key* const key, u8* const data, int addr, const u8 len);
|
||||
|
||||
void wiimote_gen_key(wiimote_key *key, u8 *keydata);
|
||||
void wiimote_gen_key(wiimote_key* const key, const u8* const keydata);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
|
||||
#include "WiimoteEmu.h"
|
||||
|
||||
#ifdef USE_WIIMOTE_EMU_SPEAKER
|
||||
|
||||
namespace WiimoteEmu
|
||||
{
|
||||
|
||||
void Wiimote::SpeakerData(wm_speaker_data* sd)
|
||||
{
|
||||
SoundBuffer sb;
|
||||
sb.samples = new s16[sd->length * 2];
|
||||
|
||||
s16* s = sb.samples;
|
||||
const u8* const e = sd->data + sd->length;
|
||||
for ( const u8* i = sd->data; i<e; ++i )
|
||||
{
|
||||
*s++ = adpcm_yamaha_expand_nibble( &m_channel_status, *i & 0x0F );
|
||||
*s++ = adpcm_yamaha_expand_nibble( &m_channel_status, *i >> 4 );
|
||||
}
|
||||
|
||||
alGenBuffers(1, &sb.buffer);
|
||||
// TODO make this not always 3000
|
||||
alBufferData(sb.buffer, AL_FORMAT_MONO16, sb.samples, (sd->length * sizeof(short) * 2), 3360);
|
||||
// testing
|
||||
//alBufferData(sb.buffer, AL_FORMAT_MONO16, sb.samples, (sd->length * sizeof(short) * 2), 48000/m_reg_speaker->sample_rate);
|
||||
alSourceQueueBuffers(m_audio_source, 1, &sb.buffer);
|
||||
|
||||
ALint state;
|
||||
alGetSourcei(m_audio_source, AL_SOURCE_STATE, &state);
|
||||
if (AL_PLAYING != state)
|
||||
alSourcePlay(m_audio_source);
|
||||
|
||||
m_audio_buffers.push(sb);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,11 @@
|
||||
#ifndef _CONEMU_WIIMOTE_H_
|
||||
#define _CONEMU_WIIMOTE_H_
|
||||
|
||||
//#define USE_WIIMOTE_EMU_SPEAKER
|
||||
|
||||
// just used to get the OpenAL includes :p
|
||||
//#include <OpenALStream.h>
|
||||
|
||||
#include <ControllerEmu.h>
|
||||
|
||||
#include "WiimoteHid.h"
|
||||
@@ -23,7 +28,14 @@ extern SWiimoteInitialize g_WiimoteInitialize;
|
||||
namespace WiimoteEmu
|
||||
{
|
||||
|
||||
extern const u8 shake_data[8];
|
||||
void EmulateShake( u8* const accel_data
|
||||
, ControllerEmu::Buttons* const buttons_group
|
||||
, unsigned int* const shake_step );
|
||||
|
||||
void EmulateTilt( wm_accel* const accel
|
||||
, ControllerEmu::Tilt* const tilt_group
|
||||
, const accel_cal* const cal
|
||||
, bool focus, bool sideways = false, bool upright = false);
|
||||
|
||||
class Wiimote : public ControllerEmu
|
||||
{
|
||||
@@ -53,6 +65,10 @@ private:
|
||||
void ReadData(const u16 _channelID, wm_read_data* rd);
|
||||
void SendReadDataReply(const u16 _channelID, ReadRequest& _request);
|
||||
|
||||
#ifdef USE_WIIMOTE_EMU_SPEAKER
|
||||
void SpeakerData(wm_speaker_data* sd);
|
||||
#endif
|
||||
|
||||
// control groups
|
||||
Buttons* m_buttons;
|
||||
Buttons* m_dpad;
|
||||
@@ -74,7 +90,11 @@ private:
|
||||
unsigned int m_reporting_mode;
|
||||
unsigned int m_reporting_channel;
|
||||
|
||||
unsigned int m_shake_step;
|
||||
// hax
|
||||
unsigned int m_skip_update;
|
||||
|
||||
unsigned int m_shake_step[3];
|
||||
unsigned int m_swing_step[3];
|
||||
|
||||
wm_status_report m_status;
|
||||
|
||||
@@ -91,18 +111,61 @@ private:
|
||||
// maybe read requests cancel any current requests
|
||||
std::queue< ReadRequest > m_read_requests;
|
||||
|
||||
//std::queue< u8 > m_speaker_data;
|
||||
#ifdef USE_WIIMOTE_EMU_SPEAKER
|
||||
// speaker stuff
|
||||
struct SoundBuffer
|
||||
{
|
||||
s16* samples;
|
||||
ALuint buffer;
|
||||
};
|
||||
std::queue<SoundBuffer> m_audio_buffers;
|
||||
ALuint m_audio_source;
|
||||
ADPCMChannelStatus m_channel_status;
|
||||
#endif
|
||||
|
||||
u8 m_eeprom[WIIMOTE_EEPROM_SIZE];
|
||||
u8* m_reg_ext;
|
||||
u8* m_reg_ir;
|
||||
|
||||
u8* m_reg_motion_plus;
|
||||
struct SpeakerConfig
|
||||
|
||||
struct IrReg
|
||||
{
|
||||
u16 : 16;
|
||||
u8 unknown1[0x33];
|
||||
u8 mode;
|
||||
|
||||
} *m_reg_ir;
|
||||
|
||||
struct ExtensionReg
|
||||
{
|
||||
u8 unknown1[0x08];
|
||||
|
||||
// address 0x08
|
||||
u8 controller_data[0x06];
|
||||
u8 unknown2[0x12];
|
||||
|
||||
// address 0x20
|
||||
u8 calibration[0x10];
|
||||
u8 unknown3[0x10];
|
||||
|
||||
// address 0x40
|
||||
u8 encryption_key[0x10];
|
||||
u8 unknown4[0xA0];
|
||||
|
||||
// address 0xF0
|
||||
u8 encryption;
|
||||
u8 unknown5[0x9];
|
||||
|
||||
// address 0xFA
|
||||
u8 constant_id[6];
|
||||
|
||||
} *m_reg_ext;
|
||||
|
||||
struct SpeakerReg
|
||||
{
|
||||
u16 unknown;
|
||||
u8 format;
|
||||
u16 sample_rate;
|
||||
u8 volume;
|
||||
u8 unk[4];
|
||||
|
||||
} *m_reg_speaker;
|
||||
|
||||
|
||||
@@ -285,7 +285,8 @@ struct wm_report_ext21
|
||||
#define WM_SPEAKER_MUTE 0x19
|
||||
#define WM_WRITE_SPEAKER_DATA 0x18
|
||||
struct wm_speaker_data {
|
||||
u8 length; // shifted left by three bits
|
||||
u8 unknown : 3;
|
||||
u8 length : 5;
|
||||
u8 data[20];
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user