mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-15 05:47:56 -07:00
InputCommon(GCPad/WiimoteNew): Fixed issue when inifile didn't exist, defaults were loaded, and input didn't work. Fixed prob in DirectInput(hopefully doesn't break any other gamepads): buffered data wasn't ever being used. WiimoteNew: Hopefully made emulated swinging better(please comment). Added (completely untested) incomplete emulated turntable(DJ Hero) extension support :p. Deleted some files that I meant to delete in my last commit.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6250 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
841583b8f3
commit
aae0fa7909
@ -262,22 +262,10 @@ public:
|
||||
const float state = controls[i+1]->control_ref->State() - controls[i]->control_ref->State();
|
||||
if (fabsf(state) > deadzone)
|
||||
tmpf = ((state - (deadzone * sign(state))) / (1 - deadzone));
|
||||
else
|
||||
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);
|
||||
*axis++ = (C)((tmpf - ax) * range + base);
|
||||
ax = tmpf;
|
||||
}
|
||||
}
|
||||
private:
|
||||
|
@ -206,9 +206,6 @@ Joystick::Joystick( /*const LPCDIDEVICEINSTANCE lpddi, */const LPDIRECTINPUTDEVI
|
||||
, m_index(index)
|
||||
//, m_name(TStringToString(lpddi->tszInstanceName))
|
||||
{
|
||||
// this needs to be done before GetCapabilities() maybe?
|
||||
m_device->Acquire();
|
||||
|
||||
// get joystick caps
|
||||
DIDEVCAPS js_caps;
|
||||
js_caps.dwSize = sizeof(js_caps);
|
||||
@ -270,6 +267,9 @@ Joystick::Joystick( /*const LPCDIDEVICEINSTANCE lpddi, */const LPDIRECTINPUTDEVI
|
||||
}
|
||||
}
|
||||
|
||||
// it seems this needs to be done after SetProperty...
|
||||
m_device->Acquire();
|
||||
|
||||
// TODO: check for DIDC_FORCEFEEDBACK in devcaps?
|
||||
|
||||
// get supported ff effects
|
||||
@ -395,8 +395,6 @@ bool Joystick::UpdateInput()
|
||||
// msdn says if this isn't needed it doesnt do anything
|
||||
m_device->Poll();
|
||||
|
||||
bool need_ = true;
|
||||
|
||||
if (m_buffered)
|
||||
{
|
||||
DIDEVICEOBJECTDATA evtbuf[DATA_BUFFER_SIZE];
|
||||
@ -415,9 +413,7 @@ bool Joystick::UpdateInput()
|
||||
((BYTE*)&m_state_in)[evt->dwOfs] = (BYTE)evt->dwData;
|
||||
}
|
||||
|
||||
// we lost some data, attempt to use GetDeviceState
|
||||
// maybe this isn't the best thing to do
|
||||
// maybe I should clear the input state?
|
||||
// seems like this needs to be done maybe...
|
||||
if (DI_BUFFEROVERFLOW == hr)
|
||||
hr = m_device->GetDeviceState(sizeof(m_state_in), &m_state_in);
|
||||
}
|
||||
|
@ -42,24 +42,26 @@ InputPlugin::~InputPlugin()
|
||||
bool InputPlugin::LoadConfig()
|
||||
{
|
||||
IniFile inifile;
|
||||
if (false == inifile.Load(std::string(File::GetUserPath(D_CONFIG_IDX)) + ini_name + ".ini"))
|
||||
if (inifile.Load(std::string(File::GetUserPath(D_CONFIG_IDX)) + ini_name + ".ini"))
|
||||
{
|
||||
std::vector< ControllerEmu* >::const_iterator
|
||||
i = controllers.begin(),
|
||||
e = controllers.end();
|
||||
for (; i!=e; ++i)
|
||||
{
|
||||
// load settings from ini
|
||||
(*i)->LoadConfig(inifile.GetOrCreateSection((*i)->GetName().c_str()));
|
||||
// update refs
|
||||
(*i)->UpdateReferences(controller_interface);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
controllers[0]->LoadDefaults(controller_interface);
|
||||
controllers[0]->UpdateReferences(controller_interface);
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector< ControllerEmu* >::const_iterator
|
||||
i = controllers.begin(),
|
||||
e = controllers.end();
|
||||
for ( ; i!=e; ++i )
|
||||
{
|
||||
// load settings from ini
|
||||
(*i)->LoadConfig(inifile.GetOrCreateSection((*i)->GetName().c_str()));
|
||||
// update refs
|
||||
(*i)->UpdateReferences(controller_interface);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void InputPlugin::SaveConfig()
|
||||
|
@ -1,28 +0,0 @@
|
||||
// Copyright (C) 2003 Dolphin Project.
|
||||
|
||||
// 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, version 2.0.
|
||||
|
||||
// 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 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#include "Common.h"
|
||||
#include "NativeVertexWriter.h"
|
||||
|
||||
namespace VertexManager
|
||||
{
|
||||
|
||||
u8* s_pCurBufferPointer = NULL;
|
||||
u8* s_pBaseBufferPointer = NULL;
|
||||
|
||||
}
|
||||
|
@ -1,37 +0,0 @@
|
||||
// Copyright (C) 2003 Dolphin Project.
|
||||
|
||||
// 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, version 2.0.
|
||||
|
||||
// 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 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#ifndef _NATIVE_VERTEX_WRITER
|
||||
#define _NATIVE_VERTEX_WRITER
|
||||
|
||||
// TODO: rename
|
||||
namespace VertexManager
|
||||
{
|
||||
|
||||
void AddVertices(int primitive, int numvertices);
|
||||
void AddCompiledVertices(int primitive, int numvertices, u8* Vdata);
|
||||
void Flush(); // flushes the current buffer
|
||||
int GetRemainingSize(); // remaining space in the current buffer.
|
||||
int GetRemainingVertices(int primitive); // remaining number of vertices that can be processed in one AddVertices call
|
||||
|
||||
// TODO: move, rename.
|
||||
extern u8* s_pCurBufferPointer;
|
||||
extern u8* s_pBaseBufferPointer;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -1,30 +0,0 @@
|
||||
// Copyright (C) 2003-2009 Dolphin Project.
|
||||
|
||||
// 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, version 2.0.
|
||||
|
||||
// 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 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#ifndef _NATIVE_VERTEX_WRITER
|
||||
#define _NATIVE_VERTEX_WRITER
|
||||
|
||||
// TODO: rename
|
||||
namespace VertexManager
|
||||
{
|
||||
|
||||
// TODO: move, rename.
|
||||
extern u8* s_pCurBufferPointer;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9,00"
|
||||
Version="9.00"
|
||||
Name="Plugin_WiimoteNew"
|
||||
ProjectGUID="{BB6CE47B-C676-44BB-AE93-2CF59B8C8BD4}"
|
||||
RootNamespace="Plugin_WiimoteNew"
|
||||
@ -608,6 +608,14 @@
|
||||
RelativePath=".\Src\WiimoteEmu\Attachment\Nunchuk.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\WiimoteEmu\Attachment\Turntable.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\WiimoteEmu\Attachment\Turntable.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
|
@ -31,7 +31,6 @@ public:
|
||||
|
||||
private:
|
||||
Buttons* m_buttons;
|
||||
Buttons* m_shake;
|
||||
MixedTriggers* m_triggers;
|
||||
Buttons* m_dpad;
|
||||
AnalogStick* m_left_stick;
|
||||
|
@ -0,0 +1,122 @@
|
||||
#include "Turntable.h"
|
||||
|
||||
|
||||
namespace WiimoteEmu
|
||||
{
|
||||
|
||||
static const u8 turntable_id[] = {0x03, 0x00, 0xa4, 0x20, 0x01, 0x03};
|
||||
|
||||
static const u16 turntable_button_bitmasks[] =
|
||||
{
|
||||
Turntable::BUTTON_L_GREEN,
|
||||
Turntable::BUTTON_L_RED,
|
||||
Turntable::BUTTON_L_BLUE,
|
||||
Turntable::BUTTON_R_GREEN,
|
||||
Turntable::BUTTON_R_RED,
|
||||
Turntable::BUTTON_R_BLUE,
|
||||
Turntable::BUTTON_MINUS,
|
||||
Turntable::BUTTON_PLUS,
|
||||
Turntable::BUTTON_EUPHORIA,
|
||||
};
|
||||
|
||||
static const char* const turntable_button_names[] =
|
||||
{
|
||||
"Green Left", "Red Left", "Blue Left",
|
||||
"Green Right", "Red Right", "Blue Right",
|
||||
"-", "+", "Euphoria",
|
||||
};
|
||||
|
||||
Turntable::Turntable() : Attachment("Turntable")
|
||||
{
|
||||
// buttons
|
||||
// TODO: separate buttons into Left and Right
|
||||
groups.push_back(m_buttons = new Buttons("Buttons"));
|
||||
for (unsigned int i = 0; i < sizeof(turntable_button_names)/sizeof(*turntable_button_names); ++i)
|
||||
m_buttons->controls.push_back(new ControlGroup::Input( turntable_button_names[i]));
|
||||
|
||||
// stick
|
||||
groups.push_back(m_stick = new AnalogStick("Stick"));
|
||||
|
||||
// TODO:
|
||||
groups.push_back(m_effect_dial = new Triggers("Effect"));
|
||||
m_effect_dial->controls.push_back(new ControlGroup::Input("Dial"));
|
||||
|
||||
//m_left_turntable
|
||||
//m_right_turntable
|
||||
//m_crossfade_slider
|
||||
|
||||
// set up register
|
||||
// id
|
||||
memcpy(®[0xfa], turntable_id, sizeof(turntable_id));
|
||||
}
|
||||
|
||||
void Turntable::GetState(u8* const data, const bool focus)
|
||||
{
|
||||
wm_turntable_extension* const ttdata = (wm_turntable_extension*)data;
|
||||
ttdata->bt = 0;
|
||||
|
||||
// stick
|
||||
{
|
||||
u8 x, y;
|
||||
m_stick->GetState(&x, &y, 0x20, focus ? 0x1F /*0x15*/ : 0);
|
||||
|
||||
ttdata->sx = x;
|
||||
ttdata->sy = y;
|
||||
}
|
||||
|
||||
// left table
|
||||
// TODO:
|
||||
{
|
||||
s8 tt = 0;
|
||||
//m_left_turntable->GetState(&tt .....);
|
||||
|
||||
ttdata->ltable1 = tt;
|
||||
ttdata->ltable2 = tt << 5;
|
||||
}
|
||||
|
||||
// right table
|
||||
// TODO:
|
||||
{
|
||||
s8 tt = 0;
|
||||
//m_right_turntable->GetState(&tt .....);
|
||||
|
||||
ttdata->rtable1 = tt;
|
||||
ttdata->rtable2 = tt << 1;
|
||||
ttdata->rtable3 = tt << 3;
|
||||
ttdata->rtable4 = tt << 5;
|
||||
}
|
||||
|
||||
// effect dial
|
||||
{
|
||||
u8 dial = 0;
|
||||
m_effect_dial->GetState(&dial, focus ? 0xF : 0);
|
||||
|
||||
ttdata->dial1 = dial;
|
||||
ttdata->dial2 = dial << 3;
|
||||
}
|
||||
|
||||
// crossfade slider
|
||||
// TODO:
|
||||
{
|
||||
u8 cfs = 0;
|
||||
//m_crossfade_slider->GetState(&cfs .....);
|
||||
|
||||
ttdata->slider = cfs;
|
||||
}
|
||||
|
||||
if (focus)
|
||||
{
|
||||
// buttons
|
||||
m_buttons->GetState(&ttdata->bt, turntable_button_bitmasks);
|
||||
}
|
||||
|
||||
// flip button bits :/
|
||||
ttdata->bt ^= (
|
||||
BUTTON_L_GREEN | BUTTON_L_RED | BUTTON_L_BLUE |
|
||||
BUTTON_R_GREEN | BUTTON_R_RED | BUTTON_R_BLUE |
|
||||
BUTTON_MINUS | BUTTON_PLUS | BUTTON_EUPHORIA
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
#include "Attachment.h"
|
||||
|
||||
namespace WiimoteEmu
|
||||
{
|
||||
|
||||
class Turntable : public Attachment
|
||||
{
|
||||
public:
|
||||
Turntable();
|
||||
void GetState(u8* const data, const bool focus);
|
||||
|
||||
enum
|
||||
{
|
||||
BUTTON_EUPHORIA = 0x1000,
|
||||
|
||||
BUTTON_L_GREEN = 0x0800,
|
||||
BUTTON_L_RED = 0x20,
|
||||
BUTTON_L_BLUE = 0x8000,
|
||||
|
||||
BUTTON_R_GREEN = 0x2000,
|
||||
BUTTON_R_RED = 0x02,
|
||||
BUTTON_R_BLUE = 0x0400,
|
||||
|
||||
BUTTON_MINUS = 0x10,
|
||||
BUTTON_PLUS = 0x04,
|
||||
};
|
||||
|
||||
private:
|
||||
Buttons* m_buttons;
|
||||
MixedTriggers* m_triggers;
|
||||
AnalogStick* m_stick;
|
||||
|
||||
Triggers *m_effect_dial;
|
||||
|
||||
// TODO:
|
||||
//m_left_turntable
|
||||
//m_right_turntable
|
||||
//m_crossfade_slider
|
||||
};
|
||||
|
||||
|
||||
}
|
@ -3,6 +3,7 @@
|
||||
#include "Attachment/Nunchuk.h"
|
||||
#include "Attachment/Guitar.h"
|
||||
#include "Attachment/Drums.h"
|
||||
#include "Attachment/Turntable.h"
|
||||
|
||||
#include "WiimoteEmu.h"
|
||||
#include "WiimoteHid.h"
|
||||
@ -60,10 +61,11 @@ const ReportFeatures reporting_mode_features[] =
|
||||
{ 2, 0, 4, 14, 23 },
|
||||
//0x37: Core Buttons and Accelerometer with 10 IR bytes and 6 Extension Bytes
|
||||
{ 2, 4, 7, 17, 23 },
|
||||
|
||||
// UNSUPPORTED:
|
||||
//0x3d: 21 Extension Bytes
|
||||
{ 0, 0, 0, 2, 23 },
|
||||
//0x3e / 0x3f: Interleaved Core Buttons and Accelerometer with 36 IR bytes
|
||||
// UNSUPPORTED
|
||||
{ 0, 0, 0, 0, 23 },
|
||||
};
|
||||
|
||||
@ -125,7 +127,7 @@ void EmulateSwing(AccelData* const accel
|
||||
, const bool sideways, const bool upright)
|
||||
{
|
||||
float swing[3];
|
||||
swing_group->GetState(swing, 0, 2 * PI);
|
||||
swing_group->GetState(swing, 0, SWING_INTENSITY);
|
||||
|
||||
s8 g_dir[3] = {-1, -1, -1};
|
||||
u8 axis_map[3];
|
||||
@ -143,13 +145,7 @@ void EmulateSwing(AccelData* const accel
|
||||
g_dir[axis_map[0]] *= -1;
|
||||
|
||||
for (unsigned int i=0; i<3; ++i)
|
||||
{
|
||||
if (swing[i])
|
||||
{
|
||||
// sin() should create a nice curve for the swing data
|
||||
(&accel->x)[axis_map[i]] += sin(swing[i]) * SWING_INTENSITY * g_dir[i];
|
||||
}
|
||||
}
|
||||
(&accel->x)[axis_map[i]] += swing[i] * g_dir[i];
|
||||
}
|
||||
|
||||
const u16 button_bitmasks[] =
|
||||
@ -270,6 +266,7 @@ Wiimote::Wiimote( const unsigned int index )
|
||||
m_extension->attachments.push_back(new WiimoteEmu::Classic());
|
||||
m_extension->attachments.push_back(new WiimoteEmu::Guitar());
|
||||
m_extension->attachments.push_back(new WiimoteEmu::Drums());
|
||||
m_extension->attachments.push_back(new WiimoteEmu::Turntable());
|
||||
|
||||
// rumble
|
||||
groups.push_back(m_rumble = new ControlGroup("Rumble"));
|
||||
|
@ -136,6 +136,29 @@ struct wm_drums_extension
|
||||
u16 bt; // buttons
|
||||
};
|
||||
|
||||
struct wm_turntable_extension
|
||||
{
|
||||
u8 sx : 6;
|
||||
u8 rtable3 : 2;
|
||||
|
||||
u8 sy : 6;
|
||||
u8 rtable2 : 2;
|
||||
|
||||
u8 rtable4 : 1;
|
||||
u8 slider : 4;
|
||||
u8 dial2 : 2;
|
||||
u8 rtable1 : 1;
|
||||
|
||||
u8 ltable1 : 5;
|
||||
u8 dial1 : 3;
|
||||
|
||||
union
|
||||
{
|
||||
u16 ltable2 : 1;
|
||||
u16 bt; // buttons
|
||||
};
|
||||
};
|
||||
|
||||
struct wm_report
|
||||
{
|
||||
u8 wm;
|
||||
|
Loading…
Reference in New Issue
Block a user