diff --git a/Source/Core/InputCommon/Src/ControllerEmu.h b/Source/Core/InputCommon/Src/ControllerEmu.h index b807b9ef7b..8753742f64 100644 --- a/Source/Core/InputCommon/Src/ControllerEmu.h +++ b/Source/Core/InputCommon/Src/ControllerEmu.h @@ -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: diff --git a/Source/Core/InputCommon/Src/ControllerInterface/DInput/DInputJoystick.cpp b/Source/Core/InputCommon/Src/ControllerInterface/DInput/DInputJoystick.cpp index f2a4f5561c..a433dcaa3d 100644 --- a/Source/Core/InputCommon/Src/ControllerInterface/DInput/DInputJoystick.cpp +++ b/Source/Core/InputCommon/Src/ControllerInterface/DInput/DInputJoystick.cpp @@ -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); } diff --git a/Source/Core/InputCommon/Src/InputConfig.cpp b/Source/Core/InputCommon/Src/InputConfig.cpp index a160349ac6..73d52aae84 100644 --- a/Source/Core/InputCommon/Src/InputConfig.cpp +++ b/Source/Core/InputCommon/Src/InputConfig.cpp @@ -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() diff --git a/Source/Core/VideoCommon/Src/NativeVertexWriter.cpp b/Source/Core/VideoCommon/Src/NativeVertexWriter.cpp deleted file mode 100644 index bd418b1ed8..0000000000 --- a/Source/Core/VideoCommon/Src/NativeVertexWriter.cpp +++ /dev/null @@ -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; - -} - diff --git a/Source/Core/VideoCommon/Src/NativeVertexWriter.h b/Source/Core/VideoCommon/Src/NativeVertexWriter.h deleted file mode 100644 index d24af1feea..0000000000 --- a/Source/Core/VideoCommon/Src/NativeVertexWriter.h +++ /dev/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 diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/NativeVertexWriter.h b/Source/Plugins/Plugin_VideoSoftware/Src/NativeVertexWriter.h deleted file mode 100644 index 570d763581..0000000000 --- a/Source/Plugins/Plugin_VideoSoftware/Src/NativeVertexWriter.h +++ /dev/null @@ -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 diff --git a/Source/Plugins/Plugin_WiimoteNew/Plugin_WiimoteNew.vcproj b/Source/Plugins/Plugin_WiimoteNew/Plugin_WiimoteNew.vcproj index 97cf6dd0f6..b581aee9fd 100644 --- a/Source/Plugins/Plugin_WiimoteNew/Plugin_WiimoteNew.vcproj +++ b/Source/Plugins/Plugin_WiimoteNew/Plugin_WiimoteNew.vcproj @@ -1,7 +1,7 @@ + + + + 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 + ); +} + + +} diff --git a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Turntable.h b/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Turntable.h new file mode 100644 index 0000000000..5e2e4e9c16 --- /dev/null +++ b/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/Attachment/Turntable.h @@ -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 +}; + + +} diff --git a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/WiimoteEmu.cpp b/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/WiimoteEmu.cpp index 45088a08b5..9f2851ed02 100644 --- a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/WiimoteEmu.cpp +++ b/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/WiimoteEmu.cpp @@ -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")); diff --git a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/WiimoteHid.h b/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/WiimoteHid.h index f08f885242..5888eee87d 100644 --- a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/WiimoteHid.h +++ b/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteEmu/WiimoteHid.h @@ -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;