mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 06:39:46 -06:00
Gecko codes: Added parenthesis where they were needed.(thanks to glennrics and soren) Fixed a copy paste error with write & fill 8bit codes. Also forgot to remove a return false;.(some more codes should work (fixed issue 2968)) New Wiimote Plugin: Added emulated swinging.(seems to work) Changed the emulated calibration data to some nice values. ControllerInterface: moved and constified some stuff.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5980 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -168,7 +168,7 @@ bool RamWriteAndFill()
|
||||
u32 new_addr = code.GetAddress();
|
||||
const u32& data = code.data;
|
||||
|
||||
u16 count = (data >> 16) + 1; // note: +1
|
||||
u32 count = (data >> 16) + 1; // note: +1
|
||||
|
||||
switch (code.subtype)
|
||||
{
|
||||
@ -176,7 +176,7 @@ bool RamWriteAndFill()
|
||||
case DATATYPE_8BIT :
|
||||
while (count--)
|
||||
{
|
||||
Memory::Write_U16((u16)data, new_addr);
|
||||
Memory::Write_U8((u8)data, new_addr);
|
||||
++new_addr;
|
||||
}
|
||||
break;
|
||||
@ -232,7 +232,7 @@ bool RamWriteAndFill()
|
||||
const u8 data_type = current_code->address >> 28;
|
||||
const u32 data_inc = current_code->data; // amount to increment the data
|
||||
const u16 addr_inc = (u16)current_code->address; // amount to increment the address
|
||||
count = (current_code->address >> 16) & 0xFFF + 1; // count is different from the other subtypes, note: +1
|
||||
count = ((current_code->address >> 16) & 0xFFF) + 1; // count is different from the other subtypes, note: +1
|
||||
while (count--)
|
||||
{
|
||||
// switch inside the loop, :/ o well
|
||||
@ -435,7 +435,6 @@ bool FlowControl()
|
||||
// needs -1 cause iterator gets ++ after code runs
|
||||
current_code = codes_start + block[block_num].address - 1;
|
||||
}
|
||||
return false; //
|
||||
break;
|
||||
|
||||
// CST2 : Return
|
||||
|
@ -65,37 +65,35 @@ void GCPad_Init( void* const hwnd )
|
||||
|
||||
void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus)
|
||||
{
|
||||
memset( _pPADStatus, 0, sizeof(*_pPADStatus) );
|
||||
memset(_pPADStatus, 0, sizeof(*_pPADStatus));
|
||||
_pPADStatus->err = PAD_ERR_NONE;
|
||||
// wtf is this?
|
||||
_pPADStatus->button |= PAD_USE_ORIGIN;
|
||||
// wtf is this?
|
||||
_pPADStatus->button = PAD_USE_ORIGIN;
|
||||
|
||||
// try lock
|
||||
if ( false == g_plugin.controls_crit.TryEnter() )
|
||||
if (false == g_plugin.controls_crit.TryEnter())
|
||||
{
|
||||
// if gui has lock (messing with controls), skip this input cycle
|
||||
// center axes and return
|
||||
memset( &_pPADStatus->stickX, 0x80, 4 );
|
||||
memset(&_pPADStatus->stickX, 0x80, 4);
|
||||
return;
|
||||
}
|
||||
|
||||
// if we are on the next input cycle, update output and input
|
||||
// if we can get a lock
|
||||
static int _last_numPAD = 4;
|
||||
if ( _numPAD <= _last_numPAD && g_plugin.interface_crit.TryEnter() )
|
||||
if (_numPAD <= _last_numPAD)
|
||||
{
|
||||
g_plugin.controller_interface.UpdateOutput();
|
||||
g_plugin.controller_interface.UpdateInput();
|
||||
g_plugin.interface_crit.Leave();
|
||||
}
|
||||
_last_numPAD = _numPAD;
|
||||
|
||||
// get input
|
||||
((GCPad*)g_plugin.controllers[ _numPAD ])->GetInput( _pPADStatus );
|
||||
((GCPad*)g_plugin.controllers[_numPAD])->GetInput(_pPADStatus);
|
||||
|
||||
// leave
|
||||
g_plugin.controls_crit.Leave();
|
||||
|
||||
}
|
||||
|
||||
// __________________________________________________________________________________________________
|
||||
|
@ -261,13 +261,15 @@ ControllerEmu::Triggers::Triggers( const char* const _name ) : ControlGroup( _na
|
||||
|
||||
ControllerEmu::Force::Force( const char* const _name ) : ControlGroup( _name, GROUP_TYPE_FORCE )
|
||||
{
|
||||
memset(m_swing, 0, sizeof(m_swing));
|
||||
|
||||
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" ) );
|
||||
//controls.push_back( new Input( "Modifier" ) );
|
||||
|
||||
settings.push_back( new Setting("Dead Zone", 0, 0, 50 ) );
|
||||
}
|
||||
@ -277,8 +279,6 @@ ControllerEmu::Tilt::Tilt( const char* const _name )
|
||||
{
|
||||
memset(m_tilt, 0, sizeof(m_tilt));
|
||||
|
||||
//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( "Backward" ) );
|
||||
controls.push_back( new Input( "Left" ) );
|
||||
|
@ -253,19 +253,35 @@ public:
|
||||
Force( const char* const _name );
|
||||
|
||||
template <typename C, typename R>
|
||||
void GetState( C* axis, const u8 base, const R range )
|
||||
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 )
|
||||
for (unsigned int i=0; i<6; i+=2)
|
||||
{
|
||||
float tmpf = 0;
|
||||
const float state = controls[i+1]->control_ref->State() - controls[i]->control_ref->State();
|
||||
if (fabsf(state) > deadzone)
|
||||
*axis++ = (C)((state - (deadzone * sign(state))) / (1 - deadzone) * range + base);
|
||||
//*axis++ = state * range + base;
|
||||
tmpf = ((state - (deadzone * sign(state))) / (1 - deadzone));
|
||||
else
|
||||
*axis++ = (C)(base);
|
||||
tmpf = 0;
|
||||
|
||||
float &ax = m_swing[i >> 1];
|
||||
|
||||
if (fabs(tmpf) > fabsf(ax))
|
||||
{
|
||||
if (tmpf > ax)
|
||||
ax = std::min(ax + 0.15f, tmpf);
|
||||
else if (tmpf < ax)
|
||||
ax = std::max(ax - 0.15f, tmpf);
|
||||
}
|
||||
else
|
||||
ax = tmpf;
|
||||
|
||||
*axis++ = (C)(ax * range + base);
|
||||
}
|
||||
}
|
||||
private:
|
||||
float m_swing[3];
|
||||
};
|
||||
|
||||
class Tilt : public ControlGroup
|
||||
|
@ -121,8 +121,13 @@ void ControllerInterface::SetHwnd( void* const hwnd )
|
||||
//
|
||||
// update input for all devices, return true if all devices returned successful
|
||||
//
|
||||
bool ControllerInterface::UpdateInput()
|
||||
bool ControllerInterface::UpdateInput(const bool force)
|
||||
{
|
||||
if (force)
|
||||
update_lock.Enter();
|
||||
else if (false == update_lock.TryEnter())
|
||||
return false;
|
||||
|
||||
size_t ok_count = 0;
|
||||
|
||||
std::vector<Device*>::const_iterator
|
||||
@ -137,6 +142,7 @@ bool ControllerInterface::UpdateInput()
|
||||
//(*d)->ClearInputState();
|
||||
}
|
||||
|
||||
update_lock.Leave();
|
||||
return (m_devices.size() == ok_count);
|
||||
}
|
||||
|
||||
@ -145,8 +151,13 @@ bool ControllerInterface::UpdateInput()
|
||||
//
|
||||
// update output for all devices, return true if all devices returned successful
|
||||
//
|
||||
bool ControllerInterface::UpdateOutput()
|
||||
bool ControllerInterface::UpdateOutput(const bool force)
|
||||
{
|
||||
if (force)
|
||||
update_lock.Enter();
|
||||
else if (false == update_lock.TryEnter())
|
||||
return false;
|
||||
|
||||
size_t ok_count = 0;
|
||||
|
||||
std::vector<Device*>::const_iterator
|
||||
@ -155,6 +166,7 @@ bool ControllerInterface::UpdateOutput()
|
||||
for (;d != e; ++d)
|
||||
(*d)->UpdateOutput();
|
||||
|
||||
update_lock.Leave();
|
||||
return (m_devices.size() == ok_count);
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,9 @@
|
||||
#include <sstream>
|
||||
#include <map>
|
||||
#include <algorithm>
|
||||
|
||||
#include "Common.h"
|
||||
#include "Thread.h"
|
||||
|
||||
// enable disable sources
|
||||
#ifdef _WIN32
|
||||
@ -214,12 +216,14 @@ public:
|
||||
bool IsInit() const { return m_is_init; }
|
||||
|
||||
void UpdateReference(ControlReference* control, const DeviceQualifier& default_device) const;
|
||||
bool UpdateInput();
|
||||
bool UpdateOutput();
|
||||
bool UpdateInput(const bool force = false);
|
||||
bool UpdateOutput(const bool force = false);
|
||||
|
||||
const std::vector<Device*>& Devices() const { return m_devices; }
|
||||
Device* FindDevice(const DeviceQualifier& devq) const;
|
||||
|
||||
Common::CriticalSection update_lock;
|
||||
|
||||
private:
|
||||
bool m_is_init;
|
||||
std::vector<Device*> m_devices;
|
||||
|
@ -19,7 +19,7 @@ namespace ciface
|
||||
namespace DInput
|
||||
{
|
||||
|
||||
static struct
|
||||
static const struct
|
||||
{
|
||||
const BYTE code;
|
||||
const char* const name;
|
||||
@ -28,7 +28,7 @@ static struct
|
||||
#include "NamedKeys.h"
|
||||
};
|
||||
|
||||
static struct
|
||||
static const struct
|
||||
{
|
||||
const BYTE code;
|
||||
const char* const name;
|
||||
|
@ -9,7 +9,7 @@ namespace ciface
|
||||
namespace XInput
|
||||
{
|
||||
|
||||
static struct
|
||||
static const struct
|
||||
{
|
||||
const char* const name;
|
||||
const WORD bitmask;
|
||||
|
@ -44,7 +44,7 @@ public:
|
||||
|
||||
std::vector< ControllerEmu* > controllers;
|
||||
|
||||
Common::CriticalSection controls_crit, interface_crit; // lock controls first
|
||||
Common::CriticalSection controls_crit; // critical section for changing any control references
|
||||
ControllerInterface controller_interface;
|
||||
|
||||
const char * const ini_name;
|
||||
|
@ -429,7 +429,7 @@ void GamepadPage::ClearControl( wxCommandEvent& event )
|
||||
{
|
||||
ControlButton* const btn = (ControlButton*)event.GetEventObject();
|
||||
btn->control_reference->expression.clear();
|
||||
//btn->control_reference->device_qualifier = controller->default_device;
|
||||
btn->control_reference->range = 1.0f;
|
||||
|
||||
m_plugin.controls_crit.Enter(); // enter
|
||||
controller->UpdateReferences( m_plugin.controller_interface );
|
||||
|
@ -32,14 +32,11 @@ void InputConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
|
||||
if ( (*g)->static_bitmap )
|
||||
{
|
||||
|
||||
m_plugin.controller_interface.UpdateInput();
|
||||
// don't want game thread updating input when we are using it here
|
||||
if ( false == m_plugin.interface_crit.TryEnter() )
|
||||
if (false == m_plugin.controller_interface.update_lock.TryEnter())
|
||||
return;
|
||||
|
||||
//if ( false == is_game_running )
|
||||
// just always update
|
||||
m_plugin.controller_interface.UpdateInput();
|
||||
|
||||
wxMemoryDC dc;
|
||||
wxBitmap bitmap((*g)->static_bitmap->GetBitmap());
|
||||
dc.SelectObject(bitmap);
|
||||
@ -324,7 +321,7 @@ void InputConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
|
||||
dc.SelectObject(wxNullBitmap);
|
||||
(*g)->static_bitmap->SetBitmap(bitmap);
|
||||
|
||||
m_plugin.interface_crit.Leave();
|
||||
m_plugin.controller_interface.update_lock.Leave();
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user