mirror of
https://github.com/izzy2lost/dolphin.git
synced 2026-06-19 01:16:48 -07:00
A few changes to the GCPadNew needed to compile in linux, and put GCPadNew back into the linux build. Also changed file properties to eol-style native.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5268 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
+1
-5
@@ -77,16 +77,12 @@ dirs = [
|
||||
'Source/Plugins/Plugin_DSP_HLE/Src',
|
||||
'Source/Plugins/Plugin_DSP_LLE/Src',
|
||||
'Source/Plugins/Plugin_GCPad/Src',
|
||||
'Source/Plugins/Plugin_GCPadNew/Src',
|
||||
'Source/Plugins/Plugin_Wiimote/Src',
|
||||
'Source/Core/DolphinWX/Src',
|
||||
'Source/Core/DebuggerWX/Src',
|
||||
]
|
||||
|
||||
if sys.platform == 'darwin':
|
||||
dirs += [
|
||||
'Source/Plugins/Plugin_GCPadNew/Src'
|
||||
]
|
||||
|
||||
builders = {}
|
||||
if sys.platform == 'darwin':
|
||||
from plistlib import writePlist
|
||||
|
||||
@@ -1,54 +1,54 @@
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
Plugin::Plugin()
|
||||
{
|
||||
// GCPads
|
||||
for ( unsigned int i = 0; i<4; ++i )
|
||||
controllers.push_back( new GCPad( i ) );
|
||||
// Wiimotes / disabled, cause it only the GUI half is done
|
||||
//for ( unsigned int i = 0; i<4; ++i )
|
||||
// controllers.push_back( new Wiimote( i ) );
|
||||
};
|
||||
|
||||
Plugin::~Plugin()
|
||||
{
|
||||
// delete pads
|
||||
std::vector<ControllerEmu*>::const_iterator i = controllers.begin(),
|
||||
e = controllers.end();
|
||||
for ( ; i != e; ++i )
|
||||
delete *i;
|
||||
}
|
||||
|
||||
void Plugin::LoadConfig()
|
||||
{
|
||||
IniFile inifile;
|
||||
|
||||
std::ifstream file;
|
||||
file.open( (std::string(File::GetUserPath(D_CONFIG_IDX)) + CONFIG_FILE_NAME ).c_str() );
|
||||
inifile.Load( file );
|
||||
file.close();
|
||||
|
||||
std::vector< ControllerEmu* >::const_iterator i = controllers.begin(),
|
||||
e = controllers.end();
|
||||
for ( ; i!=e; ++i )
|
||||
(*i)->LoadConfig( inifile[ (*i)->GetName() ] );
|
||||
}
|
||||
|
||||
void Plugin::SaveConfig()
|
||||
{
|
||||
IniFile inifile;
|
||||
|
||||
std::vector< ControllerEmu* >::const_iterator i = controllers.begin(),
|
||||
e = controllers.end();
|
||||
for ( ; i!=e; ++i )
|
||||
(*i)->SaveConfig( inifile[ (*i)->GetName() ] );
|
||||
|
||||
// dont need to save empty values
|
||||
inifile.Clean();
|
||||
|
||||
std::ofstream file;
|
||||
file.open( (std::string(File::GetUserPath(D_CONFIG_IDX)) + CONFIG_FILE_NAME ).c_str() );
|
||||
inifile.Save( file );
|
||||
file.close();
|
||||
}
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
Plugin::Plugin()
|
||||
{
|
||||
// GCPads
|
||||
for ( unsigned int i = 0; i<4; ++i )
|
||||
controllers.push_back( new GCPad( i ) );
|
||||
// Wiimotes / disabled, cause it only the GUI half is done
|
||||
//for ( unsigned int i = 0; i<4; ++i )
|
||||
// controllers.push_back( new Wiimote( i ) );
|
||||
};
|
||||
|
||||
Plugin::~Plugin()
|
||||
{
|
||||
// delete pads
|
||||
std::vector<ControllerEmu*>::const_iterator i = controllers.begin(),
|
||||
e = controllers.end();
|
||||
for ( ; i != e; ++i )
|
||||
delete *i;
|
||||
}
|
||||
|
||||
void Plugin::LoadConfig()
|
||||
{
|
||||
IniFile inifile;
|
||||
|
||||
std::ifstream file;
|
||||
file.open( (std::string(File::GetUserPath(D_CONFIG_IDX)) + CONFIG_FILE_NAME ).c_str() );
|
||||
inifile.Load( file );
|
||||
file.close();
|
||||
|
||||
std::vector< ControllerEmu* >::const_iterator i = controllers.begin(),
|
||||
e = controllers.end();
|
||||
for ( ; i!=e; ++i )
|
||||
(*i)->LoadConfig( inifile[ (*i)->GetName() ] );
|
||||
}
|
||||
|
||||
void Plugin::SaveConfig()
|
||||
{
|
||||
IniFile inifile;
|
||||
|
||||
std::vector< ControllerEmu* >::const_iterator i = controllers.begin(),
|
||||
e = controllers.end();
|
||||
for ( ; i!=e; ++i )
|
||||
(*i)->SaveConfig( inifile[ (*i)->GetName() ] );
|
||||
|
||||
// dont need to save empty values
|
||||
inifile.Clean();
|
||||
|
||||
std::ofstream file;
|
||||
file.open( (std::string(File::GetUserPath(D_CONFIG_IDX)) + CONFIG_FILE_NAME ).c_str() );
|
||||
inifile.Save( file );
|
||||
file.close();
|
||||
}
|
||||
|
||||
@@ -1,36 +1,36 @@
|
||||
#ifndef _CONFIG_H_
|
||||
#define _CONFIG_H_
|
||||
|
||||
#define CONFIG_FILE_NAME "GCPadNew.ini"
|
||||
|
||||
#include "ControllerInterface/ControllerInterface.h"
|
||||
#include "Thread.h"
|
||||
#include "FileUtil.h"
|
||||
#include "IniFile.h"
|
||||
|
||||
#include "ControllerEmu.h"
|
||||
#include "ControllerEmu/GCPad/GCPad.h"
|
||||
#include "ControllerEmu/Wiimote/Wiimote.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
|
||||
class Plugin
|
||||
{
|
||||
public:
|
||||
|
||||
Plugin();
|
||||
~Plugin();
|
||||
|
||||
void LoadConfig();
|
||||
void SaveConfig();
|
||||
|
||||
std::vector< ControllerEmu* > controllers;
|
||||
|
||||
Common::CriticalSection controls_crit, interface_crit; // lock controls first
|
||||
ControllerInterface controller_interface;
|
||||
};
|
||||
|
||||
#endif
|
||||
#ifndef _CONFIG_H_
|
||||
#define _CONFIG_H_
|
||||
|
||||
#define CONFIG_FILE_NAME "GCPadNew.ini"
|
||||
|
||||
#include "ControllerInterface/ControllerInterface.h"
|
||||
#include "Thread.h"
|
||||
#include "FileUtil.h"
|
||||
#include "IniFile.h"
|
||||
|
||||
#include "ControllerEmu.h"
|
||||
#include "ControllerEmu/GCPad/GCPad.h"
|
||||
#include "ControllerEmu/Wiimote/Wiimote.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
|
||||
class Plugin
|
||||
{
|
||||
public:
|
||||
|
||||
Plugin();
|
||||
~Plugin();
|
||||
|
||||
void LoadConfig();
|
||||
void SaveConfig();
|
||||
|
||||
std::vector< ControllerEmu* > controllers;
|
||||
|
||||
Common::CriticalSection controls_crit, interface_crit; // lock controls first
|
||||
ControllerInterface controller_interface;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,166 +1,166 @@
|
||||
#ifndef _CONFIGBOX_H_
|
||||
#define _CONFIGBOX_H_
|
||||
|
||||
#define SLIDER_TICK_COUNT 100
|
||||
#define DETECT_WAIT_TIME 1500
|
||||
#define PREVIEW_UPDATE_TIME 25
|
||||
|
||||
// might have to change this setup for wiimote
|
||||
#define PROFILES_PATH "Profiles/GCPad/"
|
||||
|
||||
#include <wx/wx.h>
|
||||
#include <wx/listbox.h>
|
||||
#include <wx/textctrl.h>
|
||||
#include <wx/button.h>
|
||||
#include <wx/stattext.h>
|
||||
#include <wx/combobox.h>
|
||||
#include <wx/checkbox.h>
|
||||
#include <wx/notebook.h>
|
||||
#include <wx/panel.h>
|
||||
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
#include "ControllerInterface/ControllerInterface.h"
|
||||
#include "Config.h"
|
||||
#include "FileSearch.h"
|
||||
|
||||
class SettingCBox : public wxChoice
|
||||
{
|
||||
public:
|
||||
SettingCBox( wxWindow* const parent, ControlState& _value, int min, int max );
|
||||
|
||||
ControlState& value;
|
||||
};
|
||||
|
||||
class ControlChooser : public wxStaticBoxSizer
|
||||
{
|
||||
public:
|
||||
ControlChooser( wxWindow* const parent, ControllerInterface::ControlReference* const ref, wxWindow* const eventsink );
|
||||
|
||||
void UpdateGUI();
|
||||
|
||||
ControllerInterface::ControlReference* control_reference;
|
||||
|
||||
wxTextCtrl* textctrl;
|
||||
wxListBox* control_lbox;
|
||||
wxChoice* mode_cbox;
|
||||
wxSlider* range_slider;
|
||||
|
||||
private:
|
||||
wxStaticText* m_bound_label;
|
||||
};
|
||||
|
||||
class ControlList : public wxDialog
|
||||
{
|
||||
public:
|
||||
|
||||
ControlList( wxWindow* const parent, ControllerInterface::ControlReference* const ref, ControlChooser* const chooser );
|
||||
|
||||
private:
|
||||
ControlChooser* const m_control_chooser;
|
||||
};
|
||||
|
||||
class ControlDialog : public wxDialog
|
||||
{
|
||||
public:
|
||||
ControlDialog( wxWindow* const parent, ControllerInterface::ControlReference* const ref, const std::vector<ControllerInterface::Device*>& devs );
|
||||
void SelectControl( wxCommandEvent& event );
|
||||
|
||||
ControllerInterface::ControlReference* const control_reference;
|
||||
wxComboBox* device_cbox;
|
||||
ControlChooser* control_chooser;
|
||||
};
|
||||
|
||||
class ControlButton : public wxButton
|
||||
{
|
||||
public:
|
||||
ControlButton( wxWindow* const parent, ControllerInterface::ControlReference* const _ref, const unsigned int width, const std::string& label = "" );
|
||||
|
||||
ControllerInterface::ControlReference* const control_reference;
|
||||
};
|
||||
|
||||
class ControlGroupBox : public wxStaticBoxSizer
|
||||
{
|
||||
public:
|
||||
ControlGroupBox( ControllerEmu::ControlGroup* const group, wxWindow* const parent );
|
||||
|
||||
ControllerEmu::ControlGroup* control_group;
|
||||
wxStaticBitmap* static_bitmap;
|
||||
std::vector< SettingCBox* > options;
|
||||
std::vector< wxButton* > controls;
|
||||
std::vector<ControlButton*> control_buttons;
|
||||
};
|
||||
|
||||
class ConfigDialog;
|
||||
|
||||
class GamepadPage : public wxNotebookPage
|
||||
{
|
||||
friend class ConfigDialog;
|
||||
|
||||
public:
|
||||
GamepadPage( wxWindow* parent, Plugin& plugin, const unsigned int pad_num, ConfigDialog* const config_dialog );
|
||||
|
||||
void UpdateGUI();
|
||||
|
||||
void RefreshDevices( wxCommandEvent& event );
|
||||
|
||||
void LoadProfile( wxCommandEvent& event );
|
||||
void SaveProfile( wxCommandEvent& event );
|
||||
void DeleteProfile( wxCommandEvent& event );
|
||||
|
||||
void ConfigControl( wxCommandEvent& event );
|
||||
void ConfigDetectControl( wxCommandEvent& event );
|
||||
void DetectControl( wxCommandEvent& event );
|
||||
void ClearControl( wxCommandEvent& event );
|
||||
|
||||
void SetDevice( wxCommandEvent& event );
|
||||
void SetControl( wxCommandEvent& event );
|
||||
|
||||
void ClearAll( wxCommandEvent& event );
|
||||
|
||||
void AdjustControlOption( wxCommandEvent& event );
|
||||
void AdjustSetting( wxCommandEvent& event );
|
||||
|
||||
wxComboBox* profile_cbox;
|
||||
wxComboBox* device_cbox;
|
||||
|
||||
std::vector<ControlGroupBox*> control_groups;
|
||||
|
||||
protected:
|
||||
|
||||
ControllerEmu* const controller;
|
||||
|
||||
private:
|
||||
|
||||
ControlDialog* m_control_dialog;
|
||||
Plugin& m_plugin;
|
||||
ConfigDialog* const m_config_dialog;
|
||||
};
|
||||
|
||||
class ConfigDialog : public wxDialog
|
||||
{
|
||||
public:
|
||||
|
||||
ConfigDialog( wxWindow* const parent, Plugin& plugin, const std::string& name, const bool _is_game_running );
|
||||
~ConfigDialog();
|
||||
|
||||
void ClickSave( wxCommandEvent& event );
|
||||
|
||||
void UpdateDeviceComboBox();
|
||||
void UpdateProfileComboBox();
|
||||
|
||||
void UpdateControlReferences();
|
||||
void UpdateBitmaps(wxTimerEvent&);
|
||||
|
||||
const bool is_game_running;
|
||||
|
||||
private:
|
||||
|
||||
wxNotebook* m_pad_notebook;
|
||||
std::vector<GamepadPage*> m_padpages;
|
||||
Plugin& m_plugin;
|
||||
wxTimer* m_update_timer;
|
||||
};
|
||||
|
||||
#endif
|
||||
#ifndef _CONFIGBOX_H_
|
||||
#define _CONFIGBOX_H_
|
||||
|
||||
#define SLIDER_TICK_COUNT 100
|
||||
#define DETECT_WAIT_TIME 1500
|
||||
#define PREVIEW_UPDATE_TIME 25
|
||||
|
||||
// might have to change this setup for wiimote
|
||||
#define PROFILES_PATH "Profiles/GCPad/"
|
||||
|
||||
#include <wx/wx.h>
|
||||
#include <wx/listbox.h>
|
||||
#include <wx/textctrl.h>
|
||||
#include <wx/button.h>
|
||||
#include <wx/stattext.h>
|
||||
#include <wx/combobox.h>
|
||||
#include <wx/checkbox.h>
|
||||
#include <wx/notebook.h>
|
||||
#include <wx/panel.h>
|
||||
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
#include "ControllerInterface/ControllerInterface.h"
|
||||
#include "Config.h"
|
||||
#include "FileSearch.h"
|
||||
|
||||
class SettingCBox : public wxChoice
|
||||
{
|
||||
public:
|
||||
SettingCBox( wxWindow* const parent, ControlState& _value, int min, int max );
|
||||
|
||||
ControlState& value;
|
||||
};
|
||||
|
||||
class ControlChooser : public wxStaticBoxSizer
|
||||
{
|
||||
public:
|
||||
ControlChooser( wxWindow* const parent, ControllerInterface::ControlReference* const ref, wxWindow* const eventsink );
|
||||
|
||||
void UpdateGUI();
|
||||
|
||||
ControllerInterface::ControlReference* control_reference;
|
||||
|
||||
wxTextCtrl* textctrl;
|
||||
wxListBox* control_lbox;
|
||||
wxChoice* mode_cbox;
|
||||
wxSlider* range_slider;
|
||||
|
||||
private:
|
||||
wxStaticText* m_bound_label;
|
||||
};
|
||||
|
||||
class ControlList : public wxDialog
|
||||
{
|
||||
public:
|
||||
|
||||
ControlList( wxWindow* const parent, ControllerInterface::ControlReference* const ref, ControlChooser* const chooser );
|
||||
|
||||
private:
|
||||
ControlChooser* const m_control_chooser;
|
||||
};
|
||||
|
||||
class ControlDialog : public wxDialog
|
||||
{
|
||||
public:
|
||||
ControlDialog( wxWindow* const parent, ControllerInterface::ControlReference* const ref, const std::vector<ControllerInterface::Device*>& devs );
|
||||
void SelectControl( wxCommandEvent& event );
|
||||
|
||||
ControllerInterface::ControlReference* const control_reference;
|
||||
wxComboBox* device_cbox;
|
||||
ControlChooser* control_chooser;
|
||||
};
|
||||
|
||||
class ControlButton : public wxButton
|
||||
{
|
||||
public:
|
||||
ControlButton( wxWindow* const parent, ControllerInterface::ControlReference* const _ref, const unsigned int width, const std::string& label = "" );
|
||||
|
||||
ControllerInterface::ControlReference* const control_reference;
|
||||
};
|
||||
|
||||
class ControlGroupBox : public wxStaticBoxSizer
|
||||
{
|
||||
public:
|
||||
ControlGroupBox( ControllerEmu::ControlGroup* const group, wxWindow* const parent );
|
||||
|
||||
ControllerEmu::ControlGroup* control_group;
|
||||
wxStaticBitmap* static_bitmap;
|
||||
std::vector< SettingCBox* > options;
|
||||
std::vector< wxButton* > controls;
|
||||
std::vector<ControlButton*> control_buttons;
|
||||
};
|
||||
|
||||
class ConfigDialog;
|
||||
|
||||
class GamepadPage : public wxNotebookPage
|
||||
{
|
||||
friend class ConfigDialog;
|
||||
|
||||
public:
|
||||
GamepadPage( wxWindow* parent, Plugin& plugin, const unsigned int pad_num, ConfigDialog* const config_dialog );
|
||||
|
||||
void UpdateGUI();
|
||||
|
||||
void RefreshDevices( wxCommandEvent& event );
|
||||
|
||||
void LoadProfile( wxCommandEvent& event );
|
||||
void SaveProfile( wxCommandEvent& event );
|
||||
void DeleteProfile( wxCommandEvent& event );
|
||||
|
||||
void ConfigControl( wxCommandEvent& event );
|
||||
void ConfigDetectControl( wxCommandEvent& event );
|
||||
void DetectControl( wxCommandEvent& event );
|
||||
void ClearControl( wxCommandEvent& event );
|
||||
|
||||
void SetDevice( wxCommandEvent& event );
|
||||
void SetControl( wxCommandEvent& event );
|
||||
|
||||
void ClearAll( wxCommandEvent& event );
|
||||
|
||||
void AdjustControlOption( wxCommandEvent& event );
|
||||
void AdjustSetting( wxCommandEvent& event );
|
||||
|
||||
wxComboBox* profile_cbox;
|
||||
wxComboBox* device_cbox;
|
||||
|
||||
std::vector<ControlGroupBox*> control_groups;
|
||||
|
||||
protected:
|
||||
|
||||
ControllerEmu* const controller;
|
||||
|
||||
private:
|
||||
|
||||
ControlDialog* m_control_dialog;
|
||||
Plugin& m_plugin;
|
||||
ConfigDialog* const m_config_dialog;
|
||||
};
|
||||
|
||||
class ConfigDialog : public wxDialog
|
||||
{
|
||||
public:
|
||||
|
||||
ConfigDialog( wxWindow* const parent, Plugin& plugin, const std::string& name, const bool _is_game_running );
|
||||
~ConfigDialog();
|
||||
|
||||
void ClickSave( wxCommandEvent& event );
|
||||
|
||||
void UpdateDeviceComboBox();
|
||||
void UpdateProfileComboBox();
|
||||
|
||||
void UpdateControlReferences();
|
||||
void UpdateBitmaps(wxTimerEvent&);
|
||||
|
||||
const bool is_game_running;
|
||||
|
||||
private:
|
||||
|
||||
wxNotebook* m_pad_notebook;
|
||||
std::vector<GamepadPage*> m_padpages;
|
||||
Plugin& m_plugin;
|
||||
wxTimer* m_update_timer;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,186 +1,186 @@
|
||||
|
||||
#include "ConfigDiag.h"
|
||||
|
||||
void ConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
|
||||
{
|
||||
|
||||
GamepadPage* const current_page = (GamepadPage*)m_pad_notebook->GetPage( m_pad_notebook->GetSelection() );
|
||||
|
||||
std::vector< ControlGroupBox* >::iterator g = current_page->control_groups.begin(),
|
||||
ge = current_page->control_groups.end();
|
||||
for ( ; g != ge; ++g )
|
||||
{
|
||||
|
||||
if ( (*g)->static_bitmap )
|
||||
{
|
||||
|
||||
// don't want game thread updating input when we are using it here
|
||||
if ( false == m_plugin.interface_crit.TryEnter() )
|
||||
return;
|
||||
|
||||
if ( false == is_game_running )
|
||||
m_plugin.controller_interface.UpdateInput();
|
||||
|
||||
switch ( (*g)->control_group->type )
|
||||
{
|
||||
case GROUP_TYPE_STICK :
|
||||
{
|
||||
float x, y;
|
||||
float xx, yy;
|
||||
((ControllerEmu::AnalogStick*)(*g)->control_group)->GetState( &x, &y, 32.0, 32-1.5 );
|
||||
|
||||
xx = ((ControllerEmu::AnalogStick*)(*g)->control_group)->controls[3]->control_ref->State();
|
||||
xx -= ((ControllerEmu::AnalogStick*)(*g)->control_group)->controls[2]->control_ref->State();
|
||||
yy = ((ControllerEmu::AnalogStick*)(*g)->control_group)->controls[1]->control_ref->State();
|
||||
yy -= ((ControllerEmu::AnalogStick*)(*g)->control_group)->controls[0]->control_ref->State();
|
||||
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
|
||||
|
||||
// circle for visual aid for diagonal adjustment
|
||||
dc.SetPen(*wxLIGHT_GREY_PEN);
|
||||
dc.SetBrush(*wxTRANSPARENT_BRUSH);
|
||||
dc.DrawCircle( 32, 32, 32);
|
||||
|
||||
// deadzone circle
|
||||
dc.SetBrush(*wxLIGHT_GREY_BRUSH);
|
||||
dc.DrawCircle( 32, 32, ((ControllerEmu::AnalogStick*)(*g)->control_group)->settings[0]->value * 32 );
|
||||
|
||||
// raw dot
|
||||
dc.SetPen(*wxGREY_PEN);
|
||||
dc.SetBrush(*wxGREY_BRUSH);
|
||||
// i like the dot better than the cross i think
|
||||
dc.DrawRectangle( xx - 2, yy - 2, 4, 4 );
|
||||
//dc.DrawRectangle( xx-1, 64-yy-4, 2, 8 );
|
||||
//dc.DrawRectangle( xx-4, 64-yy-1, 8, 2 );
|
||||
|
||||
// adjusted dot
|
||||
if ( x!=32 || y!=32 )
|
||||
{
|
||||
dc.SetPen(*wxRED_PEN);
|
||||
dc.SetBrush(*wxRED_BRUSH);
|
||||
dc.DrawRectangle( x-2, 64-y-2, 4, 4 );
|
||||
// i like the dot better than the cross i think
|
||||
//dc.DrawRectangle( x-1, 64-y-4, 2, 8 );
|
||||
//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);
|
||||
|
||||
// done drawing
|
||||
dc.SelectObject(wxNullBitmap);
|
||||
|
||||
// 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);
|
||||
|
||||
unsigned int * const bitmasks = new unsigned int[ button_count ];
|
||||
for ( unsigned int n = 0; n<button_count; ++n )
|
||||
bitmasks[n] = ( 1 << n );
|
||||
|
||||
unsigned int buttons = 0;
|
||||
((ControllerEmu::Buttons*)(*g)->control_group)->GetState( &buttons, bitmasks );
|
||||
|
||||
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
|
||||
{
|
||||
unsigned char amt = 255 - (*g)->control_group->controls[n]->control_ref->State() * 128;
|
||||
dc.SetBrush( wxBrush( wxColor( amt, amt, amt ) ) );
|
||||
}
|
||||
dc.DrawRectangle(n*12, 0, 14, 12);
|
||||
}
|
||||
|
||||
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_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);
|
||||
ControlState thresh = (*g)->control_group->settings[0]->value;
|
||||
|
||||
for ( unsigned int n = 0; n < trigger_count; ++n )
|
||||
{
|
||||
dc.SetBrush(*wxRED_BRUSH);
|
||||
ControlState trig_d = (*g)->control_group->controls[n]->control_ref->State();
|
||||
|
||||
ControlState trig_a = trig_d > thresh ? 1
|
||||
: (*g)->control_group->controls[n+trigger_count]->control_ref->State();
|
||||
|
||||
dc.DrawRectangle(0, n*12, 64+20, 14);
|
||||
if ( trig_d <= thresh )
|
||||
dc.SetBrush(*wxWHITE_BRUSH);
|
||||
dc.DrawRectangle(trig_a*64, n*12, 64+20, 14);
|
||||
dc.DrawRectangle(64, n*12, 32, 14);
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
m_plugin.interface_crit.Leave();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#include "ConfigDiag.h"
|
||||
|
||||
void ConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
|
||||
{
|
||||
|
||||
GamepadPage* const current_page = (GamepadPage*)m_pad_notebook->GetPage( m_pad_notebook->GetSelection() );
|
||||
|
||||
std::vector< ControlGroupBox* >::iterator g = current_page->control_groups.begin(),
|
||||
ge = current_page->control_groups.end();
|
||||
for ( ; g != ge; ++g )
|
||||
{
|
||||
|
||||
if ( (*g)->static_bitmap )
|
||||
{
|
||||
|
||||
// don't want game thread updating input when we are using it here
|
||||
if ( false == m_plugin.interface_crit.TryEnter() )
|
||||
return;
|
||||
|
||||
if ( false == is_game_running )
|
||||
m_plugin.controller_interface.UpdateInput();
|
||||
|
||||
switch ( (*g)->control_group->type )
|
||||
{
|
||||
case GROUP_TYPE_STICK :
|
||||
{
|
||||
float x, y;
|
||||
float xx, yy;
|
||||
((ControllerEmu::AnalogStick*)(*g)->control_group)->GetState( &x, &y, 32.0, 32-1.5 );
|
||||
|
||||
xx = ((ControllerEmu::AnalogStick*)(*g)->control_group)->controls[3]->control_ref->State();
|
||||
xx -= ((ControllerEmu::AnalogStick*)(*g)->control_group)->controls[2]->control_ref->State();
|
||||
yy = ((ControllerEmu::AnalogStick*)(*g)->control_group)->controls[1]->control_ref->State();
|
||||
yy -= ((ControllerEmu::AnalogStick*)(*g)->control_group)->controls[0]->control_ref->State();
|
||||
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
|
||||
|
||||
// circle for visual aid for diagonal adjustment
|
||||
dc.SetPen(*wxLIGHT_GREY_PEN);
|
||||
dc.SetBrush(*wxTRANSPARENT_BRUSH);
|
||||
dc.DrawCircle( 32, 32, 32);
|
||||
|
||||
// deadzone circle
|
||||
dc.SetBrush(*wxLIGHT_GREY_BRUSH);
|
||||
dc.DrawCircle( 32, 32, ((ControllerEmu::AnalogStick*)(*g)->control_group)->settings[0]->value * 32 );
|
||||
|
||||
// raw dot
|
||||
dc.SetPen(*wxGREY_PEN);
|
||||
dc.SetBrush(*wxGREY_BRUSH);
|
||||
// i like the dot better than the cross i think
|
||||
dc.DrawRectangle( xx - 2, yy - 2, 4, 4 );
|
||||
//dc.DrawRectangle( xx-1, 64-yy-4, 2, 8 );
|
||||
//dc.DrawRectangle( xx-4, 64-yy-1, 8, 2 );
|
||||
|
||||
// adjusted dot
|
||||
if ( x!=32 || y!=32 )
|
||||
{
|
||||
dc.SetPen(*wxRED_PEN);
|
||||
dc.SetBrush(*wxRED_BRUSH);
|
||||
dc.DrawRectangle( x-2, 64-y-2, 4, 4 );
|
||||
// i like the dot better than the cross i think
|
||||
//dc.DrawRectangle( x-1, 64-y-4, 2, 8 );
|
||||
//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);
|
||||
|
||||
// done drawing
|
||||
dc.SelectObject(wxNullBitmap);
|
||||
|
||||
// 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);
|
||||
|
||||
unsigned int * const bitmasks = new unsigned int[ button_count ];
|
||||
for ( unsigned int n = 0; n<button_count; ++n )
|
||||
bitmasks[n] = ( 1 << n );
|
||||
|
||||
unsigned int buttons = 0;
|
||||
((ControllerEmu::Buttons*)(*g)->control_group)->GetState( &buttons, bitmasks );
|
||||
|
||||
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
|
||||
{
|
||||
unsigned char amt = 255 - (*g)->control_group->controls[n]->control_ref->State() * 128;
|
||||
dc.SetBrush( wxBrush( wxColor( amt, amt, amt ) ) );
|
||||
}
|
||||
dc.DrawRectangle(n*12, 0, 14, 12);
|
||||
}
|
||||
|
||||
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_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);
|
||||
ControlState thresh = (*g)->control_group->settings[0]->value;
|
||||
|
||||
for ( unsigned int n = 0; n < trigger_count; ++n )
|
||||
{
|
||||
dc.SetBrush(*wxRED_BRUSH);
|
||||
ControlState trig_d = (*g)->control_group->controls[n]->control_ref->State();
|
||||
|
||||
ControlState trig_a = trig_d > thresh ? 1
|
||||
: (*g)->control_group->controls[n+trigger_count]->control_ref->State();
|
||||
|
||||
dc.DrawRectangle(0, n*12, 64+20, 14);
|
||||
if ( trig_d <= thresh )
|
||||
dc.SetBrush(*wxWHITE_BRUSH);
|
||||
dc.DrawRectangle(trig_a*64, n*12, 64+20, 14);
|
||||
dc.DrawRectangle(64, n*12, 32, 14);
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
m_plugin.interface_crit.Leave();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,138 +1,138 @@
|
||||
#include "ControllerEmu.h"
|
||||
|
||||
#include "ControllerEmu/GCPad/GCPad.h"
|
||||
|
||||
const char modifier[] = "Modifier";
|
||||
|
||||
// TODO: make this use iterators
|
||||
ControllerEmu::~ControllerEmu()
|
||||
{
|
||||
for ( unsigned int g = 0; g<groups.size(); ++g )
|
||||
delete groups[g];
|
||||
}
|
||||
// TODO: make this use iterators
|
||||
ControllerEmu::ControlGroup::~ControlGroup()
|
||||
{
|
||||
for ( unsigned int i = 0; i < controls.size(); ++i )
|
||||
delete controls[i];
|
||||
for ( unsigned int i = 0; i < settings.size(); ++i )
|
||||
delete settings[i];
|
||||
}
|
||||
|
||||
// TODO: make this use iterators
|
||||
void ControllerEmu::UpdateReferences( ControllerInterface& devi )
|
||||
{
|
||||
for ( unsigned int g = 0; g<groups.size(); ++g )
|
||||
for ( unsigned int i = 0; i < groups[g]->controls.size(); ++i )
|
||||
devi.UpdateReference( groups[g]->controls[i]->control_ref );
|
||||
}
|
||||
|
||||
void ControllerEmu::UpdateDefaultDevice()
|
||||
{
|
||||
std::vector<ControlGroup*>::const_iterator i = groups.begin(),
|
||||
e = groups.end();
|
||||
for ( ; i!=e; ++i )
|
||||
{
|
||||
std::vector<ControlGroup::Control*>::const_iterator ci = (*i)->controls.begin(),
|
||||
ce = (*i)->controls.end();
|
||||
for ( ; ci!=ce; ++ci )
|
||||
(*ci)->control_ref->device_qualifier = default_device;
|
||||
}
|
||||
}
|
||||
|
||||
void ControllerEmu::LoadConfig( IniFile::Section& sec )
|
||||
{
|
||||
const std::string default_dev = sec[ "Device" ];
|
||||
default_device.FromString( default_dev );
|
||||
|
||||
std::vector<ControlGroup*>::const_iterator i = groups.begin(),
|
||||
e = groups.end();
|
||||
for ( ; i!=e; ++i )
|
||||
{
|
||||
std::string group( (*i)->name ); group += "/";
|
||||
|
||||
// settings
|
||||
std::vector<ControlGroup::Setting*>::const_iterator si = (*i)->settings.begin(),
|
||||
se = (*i)->settings.end();
|
||||
for ( ; si!=se; ++si )
|
||||
(*si)->value = sec.Get(group+(*si)->name, (*si)->default_value*100) / 100;
|
||||
|
||||
// controls
|
||||
std::vector<ControlGroup::Control*>::const_iterator ci = (*i)->controls.begin(),
|
||||
ce = (*i)->controls.end();
|
||||
for ( ; ci!=ce; ++ci )
|
||||
{
|
||||
// control and dev qualifier
|
||||
(*ci)->control_ref->control_qualifier.name = sec[group + (*ci)->name];
|
||||
(*ci)->control_ref->device_qualifier.FromString( sec.Get( group+(*ci)->name+"/Device", default_dev ) );
|
||||
|
||||
// range
|
||||
(*ci)->control_ref->range = sec.Get( group+(*ci)->name+"/Range", 100.0f ) / 100;
|
||||
|
||||
// input mode
|
||||
if ( (*ci)->control_ref->is_input )
|
||||
((ControllerInterface::InputReference*)((*ci)->control_ref))->mode
|
||||
= sec.Get( group+(*ci)->name+"/Mode", 0 );
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ControllerEmu::SaveConfig( IniFile::Section& sec )
|
||||
{
|
||||
const std::string default_dev = default_device.ToString();
|
||||
sec[ " Device" ] = default_dev;
|
||||
|
||||
std::vector<ControlGroup*>::const_iterator i = groups.begin(),
|
||||
e = groups.end();
|
||||
for ( ; i!=e; ++i )
|
||||
{
|
||||
std::string group( (*i)->name ); group += "/";
|
||||
|
||||
// settings
|
||||
std::vector<ControlGroup::Setting*>::const_iterator si = (*i)->settings.begin(),
|
||||
se = (*i)->settings.end();
|
||||
for ( ; si!=se; ++si )
|
||||
sec.Set( group+(*si)->name, (*si)->value*100, (*si)->default_value*100 );
|
||||
|
||||
// controls
|
||||
std::vector<ControlGroup::Control*>::const_iterator ci = (*i)->controls.begin(),
|
||||
ce = (*i)->controls.end();
|
||||
for ( ; ci!=ce; ++ci )
|
||||
{
|
||||
// control and dev qualifier
|
||||
sec[group + (*ci)->name] = (*ci)->control_ref->control_qualifier.name;
|
||||
sec.Set( group+(*ci)->name+"/Device", (*ci)->control_ref->device_qualifier.ToString(), default_dev );
|
||||
|
||||
// range
|
||||
sec.Set( group+(*ci)->name+"/Range", (*ci)->control_ref->range*100, 100 );
|
||||
|
||||
// input mode
|
||||
if ( (*ci)->control_ref->is_input )
|
||||
sec.Set( group+(*ci)->name+"/Mode",
|
||||
((ControllerInterface::InputReference*)((*ci)->control_ref))->mode, (unsigned int)0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ControllerEmu::AnalogStick::AnalogStick( const char* const _name ) : ControlGroup( _name, GROUP_TYPE_STICK )
|
||||
{
|
||||
for ( unsigned int i = 0; i < 4; ++i )
|
||||
controls.push_back( new Input( named_directions[i] ) );
|
||||
|
||||
controls.push_back( new Input( modifier ) );
|
||||
|
||||
settings.push_back( new Setting("Dead Zone", 0 ) );
|
||||
settings.push_back( new Setting("Square Stick", 0 ) );
|
||||
|
||||
}
|
||||
|
||||
ControllerEmu::Buttons::Buttons( const char* const _name ) : ControlGroup( _name, GROUP_TYPE_BUTTONS )
|
||||
{
|
||||
settings.push_back( new Setting("Threshold", 0.5f ) );
|
||||
}
|
||||
|
||||
ControllerEmu::MixedTriggers::MixedTriggers( const char* const _name ) : ControlGroup( _name, GROUP_TYPE_MIXED_TRIGGERS )
|
||||
{
|
||||
settings.push_back( new Setting("Threshold", 0.9f ) );
|
||||
}
|
||||
#include "ControllerEmu.h"
|
||||
|
||||
#include "ControllerEmu/GCPad/GCPad.h"
|
||||
|
||||
const char modifier[] = "Modifier";
|
||||
|
||||
// TODO: make this use iterators
|
||||
ControllerEmu::~ControllerEmu()
|
||||
{
|
||||
for ( unsigned int g = 0; g<groups.size(); ++g )
|
||||
delete groups[g];
|
||||
}
|
||||
// TODO: make this use iterators
|
||||
ControllerEmu::ControlGroup::~ControlGroup()
|
||||
{
|
||||
for ( unsigned int i = 0; i < controls.size(); ++i )
|
||||
delete controls[i];
|
||||
for ( unsigned int i = 0; i < settings.size(); ++i )
|
||||
delete settings[i];
|
||||
}
|
||||
|
||||
// TODO: make this use iterators
|
||||
void ControllerEmu::UpdateReferences( ControllerInterface& devi )
|
||||
{
|
||||
for ( unsigned int g = 0; g<groups.size(); ++g )
|
||||
for ( unsigned int i = 0; i < groups[g]->controls.size(); ++i )
|
||||
devi.UpdateReference( groups[g]->controls[i]->control_ref );
|
||||
}
|
||||
|
||||
void ControllerEmu::UpdateDefaultDevice()
|
||||
{
|
||||
std::vector<ControlGroup*>::const_iterator i = groups.begin(),
|
||||
e = groups.end();
|
||||
for ( ; i!=e; ++i )
|
||||
{
|
||||
std::vector<ControlGroup::Control*>::const_iterator ci = (*i)->controls.begin(),
|
||||
ce = (*i)->controls.end();
|
||||
for ( ; ci!=ce; ++ci )
|
||||
(*ci)->control_ref->device_qualifier = default_device;
|
||||
}
|
||||
}
|
||||
|
||||
void ControllerEmu::LoadConfig( IniFile::Section& sec )
|
||||
{
|
||||
const std::string default_dev = sec[ "Device" ];
|
||||
default_device.FromString( default_dev );
|
||||
|
||||
std::vector<ControlGroup*>::const_iterator i = groups.begin(),
|
||||
e = groups.end();
|
||||
for ( ; i!=e; ++i )
|
||||
{
|
||||
std::string group( (*i)->name ); group += "/";
|
||||
|
||||
// settings
|
||||
std::vector<ControlGroup::Setting*>::const_iterator si = (*i)->settings.begin(),
|
||||
se = (*i)->settings.end();
|
||||
for ( ; si!=se; ++si )
|
||||
(*si)->value = sec.Get(group+(*si)->name, (*si)->default_value*100) / 100;
|
||||
|
||||
// controls
|
||||
std::vector<ControlGroup::Control*>::const_iterator ci = (*i)->controls.begin(),
|
||||
ce = (*i)->controls.end();
|
||||
for ( ; ci!=ce; ++ci )
|
||||
{
|
||||
// control and dev qualifier
|
||||
(*ci)->control_ref->control_qualifier.name = sec[group + (*ci)->name];
|
||||
(*ci)->control_ref->device_qualifier.FromString( sec.Get( group+(*ci)->name+"/Device", default_dev ) );
|
||||
|
||||
// range
|
||||
(*ci)->control_ref->range = sec.Get( group+(*ci)->name+"/Range", 100.0f ) / 100;
|
||||
|
||||
// input mode
|
||||
if ( (*ci)->control_ref->is_input )
|
||||
((ControllerInterface::InputReference*)((*ci)->control_ref))->mode
|
||||
= sec.Get( group+(*ci)->name+"/Mode", 0 );
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ControllerEmu::SaveConfig( IniFile::Section& sec )
|
||||
{
|
||||
const std::string default_dev = default_device.ToString();
|
||||
sec[ " Device" ] = default_dev;
|
||||
|
||||
std::vector<ControlGroup*>::const_iterator i = groups.begin(),
|
||||
e = groups.end();
|
||||
for ( ; i!=e; ++i )
|
||||
{
|
||||
std::string group( (*i)->name ); group += "/";
|
||||
|
||||
// settings
|
||||
std::vector<ControlGroup::Setting*>::const_iterator si = (*i)->settings.begin(),
|
||||
se = (*i)->settings.end();
|
||||
for ( ; si!=se; ++si )
|
||||
sec.Set( group+(*si)->name, (*si)->value*100, (*si)->default_value*100 );
|
||||
|
||||
// controls
|
||||
std::vector<ControlGroup::Control*>::const_iterator ci = (*i)->controls.begin(),
|
||||
ce = (*i)->controls.end();
|
||||
for ( ; ci!=ce; ++ci )
|
||||
{
|
||||
// control and dev qualifier
|
||||
sec[group + (*ci)->name] = (*ci)->control_ref->control_qualifier.name;
|
||||
sec.Set( group+(*ci)->name+"/Device", (*ci)->control_ref->device_qualifier.ToString(), default_dev );
|
||||
|
||||
// range
|
||||
sec.Set( group+(*ci)->name+"/Range", (*ci)->control_ref->range*100, 100 );
|
||||
|
||||
// input mode
|
||||
if ( (*ci)->control_ref->is_input )
|
||||
sec.Set( group+(*ci)->name+"/Mode",
|
||||
((ControllerInterface::InputReference*)((*ci)->control_ref))->mode, (unsigned int)0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ControllerEmu::AnalogStick::AnalogStick( const char* const _name ) : ControlGroup( _name, GROUP_TYPE_STICK )
|
||||
{
|
||||
for ( unsigned int i = 0; i < 4; ++i )
|
||||
controls.push_back( new Input( named_directions[i] ) );
|
||||
|
||||
controls.push_back( new Input( modifier ) );
|
||||
|
||||
settings.push_back( new Setting("Dead Zone", 0 ) );
|
||||
settings.push_back( new Setting("Square Stick", 0 ) );
|
||||
|
||||
}
|
||||
|
||||
ControllerEmu::Buttons::Buttons( const char* const _name ) : ControlGroup( _name, GROUP_TYPE_BUTTONS )
|
||||
{
|
||||
settings.push_back( new Setting("Threshold", 0.5f ) );
|
||||
}
|
||||
|
||||
ControllerEmu::MixedTriggers::MixedTriggers( const char* const _name ) : ControlGroup( _name, GROUP_TYPE_MIXED_TRIGGERS )
|
||||
{
|
||||
settings.push_back( new Setting("Threshold", 0.9f ) );
|
||||
}
|
||||
|
||||
@@ -1,226 +1,226 @@
|
||||
#ifndef _CONTROLLEREMU_H_
|
||||
#define _CONTROLLEREMU_H_
|
||||
|
||||
// windows crap
|
||||
#define NOMINMAX
|
||||
|
||||
#include "pluginspecs_pad.h"
|
||||
#include "pluginspecs_wiimote.h"
|
||||
//#include <CommonTypes.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "ControllerInterface/ControllerInterface.h"
|
||||
#include "IniFile.h"
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
|
||||
#define sign(x) ((x)?(x)<0?-1:1:0)
|
||||
|
||||
enum
|
||||
{
|
||||
GROUP_TYPE_OTHER
|
||||
,GROUP_TYPE_STICK
|
||||
,GROUP_TYPE_MIXED_TRIGGERS
|
||||
,GROUP_TYPE_BUTTONS
|
||||
};
|
||||
|
||||
const char * const named_directions[] =
|
||||
{
|
||||
"Up",
|
||||
"Down",
|
||||
"Left",
|
||||
"Right"
|
||||
};
|
||||
|
||||
class ControllerEmu
|
||||
{
|
||||
public:
|
||||
|
||||
class ControlGroup
|
||||
{
|
||||
public:
|
||||
|
||||
class Control
|
||||
{
|
||||
protected:
|
||||
Control( ControllerInterface::ControlReference* const _ref, const char * const _name )
|
||||
: control_ref(_ref), name(_name){}
|
||||
public:
|
||||
|
||||
|
||||
//virtual std::string GetName() const = 0;
|
||||
|
||||
ControllerInterface::ControlReference* const control_ref;
|
||||
const char * const name;
|
||||
|
||||
};
|
||||
|
||||
class Input : public Control
|
||||
{
|
||||
public:
|
||||
|
||||
Input( const char * const _name )
|
||||
: Control( new ControllerInterface::InputReference, _name ) {}
|
||||
|
||||
};
|
||||
|
||||
class Output : public Control
|
||||
{
|
||||
public:
|
||||
|
||||
Output( const char * const _name )
|
||||
: Control( new ControllerInterface::OutputReference, _name ) {}
|
||||
|
||||
};
|
||||
|
||||
class Setting
|
||||
{
|
||||
public:
|
||||
|
||||
Setting(const char* const _name, const float def_value ) : name(_name), value(def_value), default_value(def_value) {}
|
||||
|
||||
const char* const name;
|
||||
ControlState value;
|
||||
const ControlState default_value;
|
||||
};
|
||||
|
||||
ControlGroup( const char* const _name, const unsigned int _type = GROUP_TYPE_OTHER ) : name(_name), type(_type) {}
|
||||
virtual ~ControlGroup();
|
||||
|
||||
//ControlGroup( const ControlGroup& ctrl );
|
||||
|
||||
//const unsigned int type;
|
||||
const char* const name;
|
||||
const unsigned int type;
|
||||
|
||||
std::vector< Control* > controls;
|
||||
std::vector< Setting* > settings;
|
||||
|
||||
};
|
||||
|
||||
class AnalogStick : public ControlGroup
|
||||
{
|
||||
public:
|
||||
|
||||
template <typename C>
|
||||
void GetState( C* const x, C* const y, const unsigned int base, const unsigned int range )
|
||||
{
|
||||
// this is all a mess
|
||||
|
||||
ControlState yy = controls[0]->control_ref->State() - controls[1]->control_ref->State();
|
||||
ControlState xx = controls[3]->control_ref->State() - controls[2]->control_ref->State();
|
||||
|
||||
ControlState deadzone = settings[0]->value;
|
||||
ControlState square = settings[1]->value;
|
||||
ControlState m = controls[4]->control_ref->State();
|
||||
|
||||
// modifier code
|
||||
if ( m )
|
||||
{
|
||||
yy = (abs(yy)>deadzone) * sign(yy) * m;
|
||||
xx = (abs(xx)>deadzone) * sign(xx) * m;
|
||||
}
|
||||
|
||||
// deadzone / square stick code
|
||||
if ( deadzone || square )
|
||||
{
|
||||
// this section might be all wrong, but its working good enough, i think
|
||||
|
||||
ControlState ang = atan2( yy, xx );
|
||||
ControlState ang_sin = sin(ang);
|
||||
ControlState ang_cos = cos(ang);
|
||||
|
||||
// the amt a full square stick would have at current angle
|
||||
ControlState square_full = std::min( 1/abs(ang_sin), 1/abs(ang_cos) );
|
||||
|
||||
// the amt a full stick would have that was ( user setting squareness) at current angle
|
||||
// i think this is more like a pointed circle rather than a rounded square like it should be
|
||||
ControlState stick_full = ( 1 + ( square_full - 1 ) * square );
|
||||
|
||||
ControlState dist = sqrt(xx*xx + yy*yy);
|
||||
|
||||
// dead zone code
|
||||
dist = std::max( 0.0f, dist - deadzone * stick_full );
|
||||
dist /= ( 1 - deadzone );
|
||||
|
||||
// square stick code
|
||||
ControlState amt = ( dist ) / stick_full;
|
||||
dist -= ((square_full - 1) * amt * square);
|
||||
|
||||
yy = std::max( -1.0f, std::min( 1.0f, ang_sin * dist ) );
|
||||
xx = std::max( -1.0f, std::min( 1.0f, ang_cos * dist ) );
|
||||
}
|
||||
|
||||
*y = C( yy * range + base );
|
||||
*x = C( xx * range + base );
|
||||
}
|
||||
|
||||
AnalogStick( const char* const _name );
|
||||
|
||||
};
|
||||
|
||||
class Buttons : public ControlGroup
|
||||
{
|
||||
public:
|
||||
Buttons( const char* const _name );
|
||||
|
||||
template <typename C>
|
||||
void GetState( C* const buttons, const C* bitmasks )
|
||||
{
|
||||
std::vector<Control*>::iterator i = controls.begin(),
|
||||
e = controls.end();
|
||||
for ( ; i!=e; ++i, ++bitmasks )
|
||||
if ( (*i)->control_ref->State() > settings[0]->value ) // threshold
|
||||
*buttons |= *bitmasks;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class MixedTriggers : public ControlGroup
|
||||
{
|
||||
public:
|
||||
|
||||
template <typename C, typename S>
|
||||
void GetState( C* const digital, const C* bitmasks, S* analog, const unsigned int range )
|
||||
{
|
||||
const unsigned int trig_count = ((unsigned int) (controls.size() / 2));
|
||||
for ( unsigned int i=0; i<trig_count; ++i,++bitmasks,++analog )
|
||||
{
|
||||
if ( controls[i]->control_ref->State() > settings[0]->value ) //threshold
|
||||
{
|
||||
*analog = range;
|
||||
*digital |= *bitmasks;
|
||||
}
|
||||
else
|
||||
*analog = S(controls[i+trig_count]->control_ref->State() * range);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
MixedTriggers( const char* const _name );
|
||||
|
||||
};
|
||||
|
||||
virtual ~ControllerEmu();
|
||||
|
||||
virtual std::string GetName() const = 0;
|
||||
|
||||
void LoadConfig( IniFile::Section& sec );
|
||||
void SaveConfig( IniFile::Section& sec );
|
||||
void UpdateDefaultDevice();
|
||||
|
||||
void UpdateReferences( ControllerInterface& devi );
|
||||
|
||||
std::vector< ControlGroup* > groups;
|
||||
|
||||
|
||||
ControllerInterface::DeviceQualifier default_device;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
#ifndef _CONTROLLEREMU_H_
|
||||
#define _CONTROLLEREMU_H_
|
||||
|
||||
// windows crap
|
||||
#define NOMINMAX
|
||||
|
||||
#include "pluginspecs_pad.h"
|
||||
#include "pluginspecs_wiimote.h"
|
||||
//#include <CommonTypes.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "ControllerInterface/ControllerInterface.h"
|
||||
#include "IniFile.h"
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
|
||||
#define sign(x) ((x)?(x)<0?-1:1:0)
|
||||
|
||||
enum
|
||||
{
|
||||
GROUP_TYPE_OTHER
|
||||
,GROUP_TYPE_STICK
|
||||
,GROUP_TYPE_MIXED_TRIGGERS
|
||||
,GROUP_TYPE_BUTTONS
|
||||
};
|
||||
|
||||
const char * const named_directions[] =
|
||||
{
|
||||
"Up",
|
||||
"Down",
|
||||
"Left",
|
||||
"Right"
|
||||
};
|
||||
|
||||
class ControllerEmu
|
||||
{
|
||||
public:
|
||||
|
||||
class ControlGroup
|
||||
{
|
||||
public:
|
||||
|
||||
class Control
|
||||
{
|
||||
protected:
|
||||
Control( ControllerInterface::ControlReference* const _ref, const char * const _name )
|
||||
: control_ref(_ref), name(_name){}
|
||||
public:
|
||||
|
||||
|
||||
//virtual std::string GetName() const = 0;
|
||||
|
||||
ControllerInterface::ControlReference* const control_ref;
|
||||
const char * const name;
|
||||
|
||||
};
|
||||
|
||||
class Input : public Control
|
||||
{
|
||||
public:
|
||||
|
||||
Input( const char * const _name )
|
||||
: Control( new ControllerInterface::InputReference, _name ) {}
|
||||
|
||||
};
|
||||
|
||||
class Output : public Control
|
||||
{
|
||||
public:
|
||||
|
||||
Output( const char * const _name )
|
||||
: Control( new ControllerInterface::OutputReference, _name ) {}
|
||||
|
||||
};
|
||||
|
||||
class Setting
|
||||
{
|
||||
public:
|
||||
|
||||
Setting(const char* const _name, const float def_value ) : name(_name), value(def_value), default_value(def_value) {}
|
||||
|
||||
const char* const name;
|
||||
ControlState value;
|
||||
const ControlState default_value;
|
||||
};
|
||||
|
||||
ControlGroup( const char* const _name, const unsigned int _type = GROUP_TYPE_OTHER ) : name(_name), type(_type) {}
|
||||
virtual ~ControlGroup();
|
||||
|
||||
//ControlGroup( const ControlGroup& ctrl );
|
||||
|
||||
//const unsigned int type;
|
||||
const char* const name;
|
||||
const unsigned int type;
|
||||
|
||||
std::vector< Control* > controls;
|
||||
std::vector< Setting* > settings;
|
||||
|
||||
};
|
||||
|
||||
class AnalogStick : public ControlGroup
|
||||
{
|
||||
public:
|
||||
|
||||
template <typename C>
|
||||
void GetState( C* const x, C* const y, const unsigned int base, const unsigned int range )
|
||||
{
|
||||
// this is all a mess
|
||||
|
||||
ControlState yy = controls[0]->control_ref->State() - controls[1]->control_ref->State();
|
||||
ControlState xx = controls[3]->control_ref->State() - controls[2]->control_ref->State();
|
||||
|
||||
ControlState deadzone = settings[0]->value;
|
||||
ControlState square = settings[1]->value;
|
||||
ControlState m = controls[4]->control_ref->State();
|
||||
|
||||
// modifier code
|
||||
if ( m )
|
||||
{
|
||||
yy = (abs(yy)>deadzone) * sign(yy) * m;
|
||||
xx = (abs(xx)>deadzone) * sign(xx) * m;
|
||||
}
|
||||
|
||||
// deadzone / square stick code
|
||||
if ( deadzone || square )
|
||||
{
|
||||
// this section might be all wrong, but its working good enough, i think
|
||||
|
||||
ControlState ang = atan2( yy, xx );
|
||||
ControlState ang_sin = sin(ang);
|
||||
ControlState ang_cos = cos(ang);
|
||||
|
||||
// the amt a full square stick would have at current angle
|
||||
ControlState square_full = std::min( 1/abs(ang_sin), 1/abs(ang_cos) );
|
||||
|
||||
// the amt a full stick would have that was ( user setting squareness) at current angle
|
||||
// i think this is more like a pointed circle rather than a rounded square like it should be
|
||||
ControlState stick_full = ( 1 + ( square_full - 1 ) * square );
|
||||
|
||||
ControlState dist = sqrt(xx*xx + yy*yy);
|
||||
|
||||
// dead zone code
|
||||
dist = std::max( 0.0f, dist - deadzone * stick_full );
|
||||
dist /= ( 1 - deadzone );
|
||||
|
||||
// square stick code
|
||||
ControlState amt = ( dist ) / stick_full;
|
||||
dist -= ((square_full - 1) * amt * square);
|
||||
|
||||
yy = std::max( -1.0f, std::min( 1.0f, ang_sin * dist ) );
|
||||
xx = std::max( -1.0f, std::min( 1.0f, ang_cos * dist ) );
|
||||
}
|
||||
|
||||
*y = C( yy * range + base );
|
||||
*x = C( xx * range + base );
|
||||
}
|
||||
|
||||
AnalogStick( const char* const _name );
|
||||
|
||||
};
|
||||
|
||||
class Buttons : public ControlGroup
|
||||
{
|
||||
public:
|
||||
Buttons( const char* const _name );
|
||||
|
||||
template <typename C>
|
||||
void GetState( C* const buttons, const C* bitmasks )
|
||||
{
|
||||
std::vector<Control*>::iterator i = controls.begin(),
|
||||
e = controls.end();
|
||||
for ( ; i!=e; ++i, ++bitmasks )
|
||||
if ( (*i)->control_ref->State() > settings[0]->value ) // threshold
|
||||
*buttons |= *bitmasks;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class MixedTriggers : public ControlGroup
|
||||
{
|
||||
public:
|
||||
|
||||
template <typename C, typename S>
|
||||
void GetState( C* const digital, const C* bitmasks, S* analog, const unsigned int range )
|
||||
{
|
||||
const unsigned int trig_count = ((unsigned int) (controls.size() / 2));
|
||||
for ( unsigned int i=0; i<trig_count; ++i,++bitmasks,++analog )
|
||||
{
|
||||
if ( controls[i]->control_ref->State() > settings[0]->value ) //threshold
|
||||
{
|
||||
*analog = range;
|
||||
*digital |= *bitmasks;
|
||||
}
|
||||
else
|
||||
*analog = S(controls[i+trig_count]->control_ref->State() * range);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
MixedTriggers( const char* const _name );
|
||||
|
||||
};
|
||||
|
||||
virtual ~ControllerEmu();
|
||||
|
||||
virtual std::string GetName() const = 0;
|
||||
|
||||
void LoadConfig( IniFile::Section& sec );
|
||||
void SaveConfig( IniFile::Section& sec );
|
||||
void UpdateDefaultDevice();
|
||||
|
||||
void UpdateReferences( ControllerInterface& devi );
|
||||
|
||||
std::vector< ControlGroup* > groups;
|
||||
|
||||
|
||||
ControllerInterface::DeviceQualifier default_device;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,97 +1,97 @@
|
||||
|
||||
#include "GCPad.h"
|
||||
|
||||
// this is all temporary, but sticking with the padspecs ...for now
|
||||
const u16 button_bitmasks[] =
|
||||
{
|
||||
PAD_BUTTON_A,
|
||||
PAD_BUTTON_B,
|
||||
PAD_BUTTON_X,
|
||||
PAD_BUTTON_Y,
|
||||
PAD_TRIGGER_Z,
|
||||
PAD_BUTTON_START
|
||||
};
|
||||
|
||||
const u16 trigger_bitmasks[] =
|
||||
{
|
||||
PAD_TRIGGER_L,
|
||||
PAD_TRIGGER_R,
|
||||
};
|
||||
|
||||
const u16 dpad_bitmasks[] =
|
||||
{
|
||||
PAD_BUTTON_UP, PAD_BUTTON_DOWN, PAD_BUTTON_LEFT, PAD_BUTTON_RIGHT
|
||||
};
|
||||
|
||||
const char* const named_buttons[] =
|
||||
{
|
||||
"A",
|
||||
"B",
|
||||
"X",
|
||||
"Y",
|
||||
"Z",
|
||||
"Start",
|
||||
};
|
||||
|
||||
const char* const named_triggers[] =
|
||||
{
|
||||
"L", "R", "L-Analog", "R-Analog"
|
||||
};
|
||||
|
||||
GCPad::GCPad( const unsigned int index ) : m_index(index)
|
||||
{
|
||||
|
||||
// buttons
|
||||
groups.push_back( m_buttons = new Buttons( "Buttons" ) );
|
||||
for ( unsigned int i=0; i < sizeof(named_buttons)/sizeof(*named_buttons); ++i )
|
||||
m_buttons->controls.push_back( new ControlGroup::Input( named_buttons[i] ) );
|
||||
|
||||
// sticks
|
||||
groups.push_back( m_main_stick = new AnalogStick( "Main Stick" ) );
|
||||
groups.push_back( m_c_stick = new AnalogStick( "C-Stick" ) );
|
||||
|
||||
// triggers
|
||||
groups.push_back( m_triggers = new MixedTriggers( "Triggers" ) );
|
||||
for ( unsigned int i=0; i < sizeof(named_triggers)/sizeof(*named_triggers); ++i )
|
||||
m_triggers->controls.push_back( new ControlGroup::Input( named_triggers[i] ) );
|
||||
|
||||
// dpad
|
||||
groups.push_back( m_dpad = new Buttons( "D-Pad" ) );
|
||||
for ( unsigned int i=0; i < 4; ++i )
|
||||
m_dpad->controls.push_back( new ControlGroup::Input( named_directions[i] ) );
|
||||
|
||||
// rumble
|
||||
groups.push_back( m_rumble = new ControlGroup( "Rumble" ) );
|
||||
m_rumble->controls.push_back( new ControlGroup::Output( "Motor" ) );
|
||||
|
||||
}
|
||||
|
||||
std::string GCPad::GetName() const
|
||||
{
|
||||
return std::string("GCPad") + char('1'+m_index);
|
||||
}
|
||||
|
||||
void GCPad::GetInput( SPADStatus* const pad )
|
||||
{
|
||||
std::vector< ControlGroup::Control* >::iterator i,e;
|
||||
|
||||
// buttons
|
||||
m_buttons->GetState( &pad->button, button_bitmasks );
|
||||
|
||||
// TODO: set analog A/B to full or w/e
|
||||
|
||||
// dpad
|
||||
m_dpad->GetState( &pad->button, dpad_bitmasks );
|
||||
|
||||
// sticks
|
||||
m_main_stick->GetState( &pad->stickX, &pad->stickY, 0x80, 127 );
|
||||
m_c_stick->GetState( &pad->substickX, &pad->substickY, 0x80, 127 );
|
||||
|
||||
// triggers
|
||||
m_triggers->GetState( &pad->button, trigger_bitmasks, &pad->triggerLeft, 0xFF );
|
||||
}
|
||||
|
||||
void GCPad::SetOutput( const bool on )
|
||||
{
|
||||
m_rumble->controls[0]->control_ref->State( on );
|
||||
}
|
||||
|
||||
#include "GCPad.h"
|
||||
|
||||
// this is all temporary, but sticking with the padspecs ...for now
|
||||
const u16 button_bitmasks[] =
|
||||
{
|
||||
PAD_BUTTON_A,
|
||||
PAD_BUTTON_B,
|
||||
PAD_BUTTON_X,
|
||||
PAD_BUTTON_Y,
|
||||
PAD_TRIGGER_Z,
|
||||
PAD_BUTTON_START
|
||||
};
|
||||
|
||||
const u16 trigger_bitmasks[] =
|
||||
{
|
||||
PAD_TRIGGER_L,
|
||||
PAD_TRIGGER_R,
|
||||
};
|
||||
|
||||
const u16 dpad_bitmasks[] =
|
||||
{
|
||||
PAD_BUTTON_UP, PAD_BUTTON_DOWN, PAD_BUTTON_LEFT, PAD_BUTTON_RIGHT
|
||||
};
|
||||
|
||||
const char* const named_buttons[] =
|
||||
{
|
||||
"A",
|
||||
"B",
|
||||
"X",
|
||||
"Y",
|
||||
"Z",
|
||||
"Start",
|
||||
};
|
||||
|
||||
const char* const named_triggers[] =
|
||||
{
|
||||
"L", "R", "L-Analog", "R-Analog"
|
||||
};
|
||||
|
||||
GCPad::GCPad( const unsigned int index ) : m_index(index)
|
||||
{
|
||||
|
||||
// buttons
|
||||
groups.push_back( m_buttons = new Buttons( "Buttons" ) );
|
||||
for ( unsigned int i=0; i < sizeof(named_buttons)/sizeof(*named_buttons); ++i )
|
||||
m_buttons->controls.push_back( new ControlGroup::Input( named_buttons[i] ) );
|
||||
|
||||
// sticks
|
||||
groups.push_back( m_main_stick = new AnalogStick( "Main Stick" ) );
|
||||
groups.push_back( m_c_stick = new AnalogStick( "C-Stick" ) );
|
||||
|
||||
// triggers
|
||||
groups.push_back( m_triggers = new MixedTriggers( "Triggers" ) );
|
||||
for ( unsigned int i=0; i < sizeof(named_triggers)/sizeof(*named_triggers); ++i )
|
||||
m_triggers->controls.push_back( new ControlGroup::Input( named_triggers[i] ) );
|
||||
|
||||
// dpad
|
||||
groups.push_back( m_dpad = new Buttons( "D-Pad" ) );
|
||||
for ( unsigned int i=0; i < 4; ++i )
|
||||
m_dpad->controls.push_back( new ControlGroup::Input( named_directions[i] ) );
|
||||
|
||||
// rumble
|
||||
groups.push_back( m_rumble = new ControlGroup( "Rumble" ) );
|
||||
m_rumble->controls.push_back( new ControlGroup::Output( "Motor" ) );
|
||||
|
||||
}
|
||||
|
||||
std::string GCPad::GetName() const
|
||||
{
|
||||
return std::string("GCPad") + char('1'+m_index);
|
||||
}
|
||||
|
||||
void GCPad::GetInput( SPADStatus* const pad )
|
||||
{
|
||||
std::vector< ControlGroup::Control* >::iterator i,e;
|
||||
|
||||
// buttons
|
||||
m_buttons->GetState( &pad->button, button_bitmasks );
|
||||
|
||||
// TODO: set analog A/B to full or w/e
|
||||
|
||||
// dpad
|
||||
m_dpad->GetState( &pad->button, dpad_bitmasks );
|
||||
|
||||
// sticks
|
||||
m_main_stick->GetState( &pad->stickX, &pad->stickY, 0x80, 127 );
|
||||
m_c_stick->GetState( &pad->substickX, &pad->substickY, 0x80, 127 );
|
||||
|
||||
// triggers
|
||||
m_triggers->GetState( &pad->button, trigger_bitmasks, &pad->triggerLeft, 0xFF );
|
||||
}
|
||||
|
||||
void GCPad::SetOutput( const bool on )
|
||||
{
|
||||
m_rumble->controls[0]->control_ref->State( on );
|
||||
}
|
||||
|
||||
@@ -1,31 +1,31 @@
|
||||
#ifndef _CONEMU_GCPAD_H_
|
||||
#define _CONEMU_GCPAD_H_
|
||||
|
||||
#include "../../ControllerEmu.h"
|
||||
|
||||
class GCPad : public ControllerEmu
|
||||
{
|
||||
public:
|
||||
|
||||
GCPad( const unsigned int index );
|
||||
void GetInput( SPADStatus* const pad );
|
||||
void SetOutput( const bool on );
|
||||
|
||||
std::string GetName() const;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
Buttons* m_buttons;
|
||||
AnalogStick* m_main_stick;
|
||||
AnalogStick* m_c_stick;
|
||||
Buttons* m_dpad;
|
||||
MixedTriggers* m_triggers;
|
||||
ControlGroup* m_rumble;
|
||||
|
||||
const unsigned int m_index;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
#ifndef _CONEMU_GCPAD_H_
|
||||
#define _CONEMU_GCPAD_H_
|
||||
|
||||
#include "../../ControllerEmu.h"
|
||||
|
||||
class GCPad : public ControllerEmu
|
||||
{
|
||||
public:
|
||||
|
||||
GCPad( const unsigned int index );
|
||||
void GetInput( SPADStatus* const pad );
|
||||
void SetOutput( const bool on );
|
||||
|
||||
std::string GetName() const;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
Buttons* m_buttons;
|
||||
AnalogStick* m_main_stick;
|
||||
AnalogStick* m_c_stick;
|
||||
Buttons* m_dpad;
|
||||
MixedTriggers* m_triggers;
|
||||
ControlGroup* m_rumble;
|
||||
|
||||
const unsigned int m_index;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,46 +1,46 @@
|
||||
#ifndef _CONEMU_WIIMOTE_H_
|
||||
#define _CONEMU_WIIMOTE_H_
|
||||
|
||||
#include "../../ControllerEmu.h"
|
||||
|
||||
#include <queue>
|
||||
|
||||
class HIDReport : public std::queue<u8>
|
||||
{
|
||||
public:
|
||||
template <typename T>
|
||||
HIDReport& operator<<( const T& t )
|
||||
{
|
||||
const u8* const e = ((u8*)&t) + sizeof(t);
|
||||
const u8* i = (u8*)&t;
|
||||
for ( ;i<e; ++i )
|
||||
push(*i);
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
class Wiimote : public ControllerEmu
|
||||
{
|
||||
public:
|
||||
|
||||
Wiimote( const unsigned int index );
|
||||
void Cycle();
|
||||
Wiimote& operator<<( HIDReport& );
|
||||
|
||||
std::string GetName() const;
|
||||
|
||||
private:
|
||||
|
||||
Buttons* m_buttons;
|
||||
Buttons* m_dpad;
|
||||
ControlGroup* m_rumble;
|
||||
// TODO: add forces
|
||||
// TODO: add ir
|
||||
|
||||
const unsigned int m_index;
|
||||
unsigned int m_report_mode;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
#ifndef _CONEMU_WIIMOTE_H_
|
||||
#define _CONEMU_WIIMOTE_H_
|
||||
|
||||
#include "../../ControllerEmu.h"
|
||||
|
||||
#include <queue>
|
||||
|
||||
class HIDReport : public std::queue<u8>
|
||||
{
|
||||
public:
|
||||
template <typename T>
|
||||
HIDReport& operator<<( const T& t )
|
||||
{
|
||||
const u8* const e = ((u8*)&t) + sizeof(t);
|
||||
const u8* i = (u8*)&t;
|
||||
for ( ;i<e; ++i )
|
||||
push(*i);
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
class Wiimote : public ControllerEmu
|
||||
{
|
||||
public:
|
||||
|
||||
Wiimote( const unsigned int index );
|
||||
void Cycle();
|
||||
Wiimote& operator<<( HIDReport& );
|
||||
|
||||
std::string GetName() const;
|
||||
|
||||
private:
|
||||
|
||||
Buttons* m_buttons;
|
||||
Buttons* m_dpad;
|
||||
ControlGroup* m_rumble;
|
||||
// TODO: add forces
|
||||
// TODO: add ir
|
||||
|
||||
const unsigned int m_index;
|
||||
unsigned int m_report_mode;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,249 +1,249 @@
|
||||
#ifndef _DEVICEINTERFACE_H_
|
||||
#define _DEVICEINTERFACE_H_
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <map>
|
||||
#include <algorithm>
|
||||
|
||||
// enable disable sources
|
||||
#ifdef _WIN32
|
||||
#define CIFACE_USE_XINPUT
|
||||
#define CIFACE_USE_DIRECTINPUT_JOYSTICK
|
||||
#define CIFACE_USE_DIRECTINPUT_KBM
|
||||
#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
|
||||
#define CIFACE_USE_SDL
|
||||
#endif
|
||||
|
||||
// idk in case i wanted to change it to double or somethin, idk what's best
|
||||
typedef float ControlState;
|
||||
|
||||
//
|
||||
// ControllerInterface
|
||||
//
|
||||
// some crazy shit i made to control different device inputs and outputs
|
||||
// from lots of different sources, hopefully more easily
|
||||
//
|
||||
class ControllerInterface
|
||||
{
|
||||
public:
|
||||
|
||||
//
|
||||
// Device
|
||||
//
|
||||
// Pretty obviously, a device class
|
||||
//
|
||||
class Device
|
||||
{
|
||||
public:
|
||||
|
||||
//
|
||||
// Control
|
||||
//
|
||||
// control includes inputs and outputs
|
||||
//
|
||||
class Control // input or output
|
||||
{
|
||||
public:
|
||||
virtual std::string GetName() const = 0;
|
||||
};
|
||||
|
||||
//
|
||||
// Input
|
||||
//
|
||||
// an input on a device
|
||||
//
|
||||
class Input : public Control
|
||||
{
|
||||
public:
|
||||
virtual ~Input() {}
|
||||
};
|
||||
|
||||
//
|
||||
// Output
|
||||
//
|
||||
// guess wut it is, yup and output
|
||||
//
|
||||
class Output : public Control
|
||||
{
|
||||
public:
|
||||
virtual ~Output() {}
|
||||
};
|
||||
|
||||
virtual ~Device();
|
||||
|
||||
virtual std::string GetName() const = 0;
|
||||
virtual int GetId() const = 0;
|
||||
virtual std::string GetSource() const = 0;
|
||||
|
||||
virtual ControlState GetInputState( const Input* const input ) = 0;
|
||||
virtual void SetOutputState( const Output* const output, const ControlState state ) = 0;
|
||||
|
||||
virtual bool UpdateInput() = 0;
|
||||
virtual bool UpdateOutput() = 0;
|
||||
|
||||
virtual void ClearInputState();
|
||||
|
||||
const std::vector< Input* >& Inputs();
|
||||
const std::vector< Output* >& Outputs();
|
||||
|
||||
protected:
|
||||
std::vector<Input*> inputs;
|
||||
std::vector<Output*> outputs;
|
||||
|
||||
};
|
||||
|
||||
//
|
||||
// DeviceQualifier
|
||||
//
|
||||
// device qualifier used to match devices
|
||||
// currently has ( source, id, name ) properties which match a device
|
||||
//
|
||||
class DeviceQualifier
|
||||
{
|
||||
public:
|
||||
DeviceQualifier() : id(-1){}
|
||||
DeviceQualifier( const std::string& _source, const int _id, const std::string& _name )
|
||||
: source(_source), id(_id), name(_name) {}
|
||||
bool operator==(const Device* const dev) const;
|
||||
void FromDevice(const Device* const dev);
|
||||
void FromString(const std::string& str);
|
||||
std::string ToString() const;
|
||||
|
||||
std::string source;
|
||||
int id;
|
||||
std::string name;
|
||||
};
|
||||
|
||||
//
|
||||
// ControlQualifier
|
||||
//
|
||||
// control qualifier includes input and output qualifiers
|
||||
// used to match controls on devices, only has name property
|
||||
// |input1|input2| form as well, || matches anything, might change this to * or something
|
||||
//
|
||||
class ControlQualifier
|
||||
{
|
||||
public:
|
||||
ControlQualifier() {};
|
||||
ControlQualifier( const std::string& _name ) : name(_name) {}
|
||||
virtual bool operator==(const Device::Control* const in) const;
|
||||
void FromControl(const Device::Control* const in);
|
||||
|
||||
std::string name;
|
||||
};
|
||||
|
||||
//
|
||||
// InputQualifier
|
||||
//
|
||||
// ControlQualifier for inputs
|
||||
//
|
||||
class InputQualifier : public ControlQualifier
|
||||
{
|
||||
public:
|
||||
InputQualifier() {};
|
||||
InputQualifier( const std::string& _name ) : ControlQualifier(_name) {}
|
||||
};
|
||||
|
||||
//
|
||||
// OutputQualifier
|
||||
//
|
||||
// ControlQualifier for outputs
|
||||
//
|
||||
class OutputQualifier : public ControlQualifier
|
||||
{
|
||||
public:
|
||||
OutputQualifier() {};
|
||||
OutputQualifier( const std::string& _name ) : ControlQualifier(_name) {}
|
||||
};
|
||||
|
||||
//
|
||||
// ControlReference
|
||||
//
|
||||
// these are what you create to actually use the inputs, InputReference or OutputReference
|
||||
// they have a vector < struct { device , vector < controls > } >
|
||||
//
|
||||
// after being binded to devices and controls with ControllerInterface::UpdateReference,
|
||||
// each one can binded to a devices, and 0+ controls the device
|
||||
// ControlReference can update its own controls when you change its control qualifier
|
||||
// using ControlReference::UpdateControls but when you change its device qualifer
|
||||
// you must use ControllerInterface::UpdateReference
|
||||
//
|
||||
class ControlReference
|
||||
{
|
||||
public:
|
||||
ControlReference( const bool _is_input ) : range(1), is_input(_is_input), device(NULL) {}
|
||||
|
||||
virtual ControlState State( const ControlState state = 0 ) = 0;
|
||||
virtual bool Detect( const unsigned int ms, const unsigned int count = 1 ) = 0;
|
||||
virtual void UpdateControls() = 0;
|
||||
|
||||
ControlState range;
|
||||
|
||||
DeviceQualifier device_qualifier;
|
||||
ControlQualifier control_qualifier;
|
||||
|
||||
const bool is_input;
|
||||
Device* device;
|
||||
|
||||
std::vector<Device::Control*> controls;
|
||||
|
||||
};
|
||||
|
||||
//
|
||||
// InputReference
|
||||
//
|
||||
// control reference for inputs
|
||||
//
|
||||
class InputReference : public ControlReference
|
||||
{
|
||||
public:
|
||||
InputReference() : ControlReference( true ) {}
|
||||
ControlState State( const ControlState state );
|
||||
bool Detect( const unsigned int ms, const unsigned int count );
|
||||
void UpdateControls();
|
||||
|
||||
unsigned int mode;
|
||||
};
|
||||
|
||||
//
|
||||
// OutputReference
|
||||
//
|
||||
// control reference for outputs
|
||||
//
|
||||
class OutputReference : public ControlReference
|
||||
{
|
||||
public:
|
||||
OutputReference() : ControlReference( false ) {}
|
||||
ControlState State( const ControlState state );
|
||||
bool Detect( const unsigned int ms, const unsigned int count );
|
||||
void UpdateControls();
|
||||
};
|
||||
|
||||
ControllerInterface() : m_is_init(false) {}
|
||||
|
||||
void SetHwnd( void* const hwnd );
|
||||
void Init();
|
||||
void DeInit();
|
||||
bool IsInit();
|
||||
|
||||
void UpdateReference( ControlReference* control );
|
||||
bool UpdateInput();
|
||||
bool UpdateOutput();
|
||||
|
||||
const std::vector<Device*>& Devices();
|
||||
|
||||
private:
|
||||
bool m_is_init;
|
||||
std::vector<Device*> m_devices;
|
||||
void* m_hwnd;
|
||||
};
|
||||
|
||||
#endif
|
||||
#ifndef _DEVICEINTERFACE_H_
|
||||
#define _DEVICEINTERFACE_H_
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <map>
|
||||
#include <algorithm>
|
||||
|
||||
// enable disable sources
|
||||
#ifdef _WIN32
|
||||
#define CIFACE_USE_XINPUT
|
||||
#define CIFACE_USE_DIRECTINPUT_JOYSTICK
|
||||
#define CIFACE_USE_DIRECTINPUT_KBM
|
||||
#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
|
||||
#define CIFACE_USE_SDL
|
||||
#endif
|
||||
|
||||
// idk in case i wanted to change it to double or somethin, idk what's best
|
||||
typedef float ControlState;
|
||||
|
||||
//
|
||||
// ControllerInterface
|
||||
//
|
||||
// some crazy shit i made to control different device inputs and outputs
|
||||
// from lots of different sources, hopefully more easily
|
||||
//
|
||||
class ControllerInterface
|
||||
{
|
||||
public:
|
||||
|
||||
//
|
||||
// Device
|
||||
//
|
||||
// Pretty obviously, a device class
|
||||
//
|
||||
class Device
|
||||
{
|
||||
public:
|
||||
|
||||
//
|
||||
// Control
|
||||
//
|
||||
// control includes inputs and outputs
|
||||
//
|
||||
class Control // input or output
|
||||
{
|
||||
public:
|
||||
virtual std::string GetName() const = 0;
|
||||
};
|
||||
|
||||
//
|
||||
// Input
|
||||
//
|
||||
// an input on a device
|
||||
//
|
||||
class Input : public Control
|
||||
{
|
||||
public:
|
||||
virtual ~Input() {}
|
||||
};
|
||||
|
||||
//
|
||||
// Output
|
||||
//
|
||||
// guess wut it is, yup and output
|
||||
//
|
||||
class Output : public Control
|
||||
{
|
||||
public:
|
||||
virtual ~Output() {}
|
||||
};
|
||||
|
||||
virtual ~Device();
|
||||
|
||||
virtual std::string GetName() const = 0;
|
||||
virtual int GetId() const = 0;
|
||||
virtual std::string GetSource() const = 0;
|
||||
|
||||
virtual ControlState GetInputState( const Input* const input ) = 0;
|
||||
virtual void SetOutputState( const Output* const output, const ControlState state ) = 0;
|
||||
|
||||
virtual bool UpdateInput() = 0;
|
||||
virtual bool UpdateOutput() = 0;
|
||||
|
||||
virtual void ClearInputState();
|
||||
|
||||
const std::vector< Input* >& Inputs();
|
||||
const std::vector< Output* >& Outputs();
|
||||
|
||||
protected:
|
||||
std::vector<Input*> inputs;
|
||||
std::vector<Output*> outputs;
|
||||
|
||||
};
|
||||
|
||||
//
|
||||
// DeviceQualifier
|
||||
//
|
||||
// device qualifier used to match devices
|
||||
// currently has ( source, id, name ) properties which match a device
|
||||
//
|
||||
class DeviceQualifier
|
||||
{
|
||||
public:
|
||||
DeviceQualifier() : id(-1){}
|
||||
DeviceQualifier( const std::string& _source, const int _id, const std::string& _name )
|
||||
: source(_source), id(_id), name(_name) {}
|
||||
bool operator==(const Device* const dev) const;
|
||||
void FromDevice(const Device* const dev);
|
||||
void FromString(const std::string& str);
|
||||
std::string ToString() const;
|
||||
|
||||
std::string source;
|
||||
int id;
|
||||
std::string name;
|
||||
};
|
||||
|
||||
//
|
||||
// ControlQualifier
|
||||
//
|
||||
// control qualifier includes input and output qualifiers
|
||||
// used to match controls on devices, only has name property
|
||||
// |input1|input2| form as well, || matches anything, might change this to * or something
|
||||
//
|
||||
class ControlQualifier
|
||||
{
|
||||
public:
|
||||
ControlQualifier() {};
|
||||
ControlQualifier( const std::string& _name ) : name(_name) {}
|
||||
virtual bool operator==(const Device::Control* const in) const;
|
||||
void FromControl(const Device::Control* const in);
|
||||
|
||||
std::string name;
|
||||
};
|
||||
|
||||
//
|
||||
// InputQualifier
|
||||
//
|
||||
// ControlQualifier for inputs
|
||||
//
|
||||
class InputQualifier : public ControlQualifier
|
||||
{
|
||||
public:
|
||||
InputQualifier() {};
|
||||
InputQualifier( const std::string& _name ) : ControlQualifier(_name) {}
|
||||
};
|
||||
|
||||
//
|
||||
// OutputQualifier
|
||||
//
|
||||
// ControlQualifier for outputs
|
||||
//
|
||||
class OutputQualifier : public ControlQualifier
|
||||
{
|
||||
public:
|
||||
OutputQualifier() {};
|
||||
OutputQualifier( const std::string& _name ) : ControlQualifier(_name) {}
|
||||
};
|
||||
|
||||
//
|
||||
// ControlReference
|
||||
//
|
||||
// these are what you create to actually use the inputs, InputReference or OutputReference
|
||||
// they have a vector < struct { device , vector < controls > } >
|
||||
//
|
||||
// after being binded to devices and controls with ControllerInterface::UpdateReference,
|
||||
// each one can binded to a devices, and 0+ controls the device
|
||||
// ControlReference can update its own controls when you change its control qualifier
|
||||
// using ControlReference::UpdateControls but when you change its device qualifer
|
||||
// you must use ControllerInterface::UpdateReference
|
||||
//
|
||||
class ControlReference
|
||||
{
|
||||
public:
|
||||
ControlReference( const bool _is_input ) : range(1), is_input(_is_input), device(NULL) {}
|
||||
|
||||
virtual ControlState State( const ControlState state = 0 ) = 0;
|
||||
virtual bool Detect( const unsigned int ms, const unsigned int count = 1 ) = 0;
|
||||
virtual void UpdateControls() = 0;
|
||||
|
||||
ControlState range;
|
||||
|
||||
DeviceQualifier device_qualifier;
|
||||
ControlQualifier control_qualifier;
|
||||
|
||||
const bool is_input;
|
||||
Device* device;
|
||||
|
||||
std::vector<Device::Control*> controls;
|
||||
|
||||
};
|
||||
|
||||
//
|
||||
// InputReference
|
||||
//
|
||||
// control reference for inputs
|
||||
//
|
||||
class InputReference : public ControlReference
|
||||
{
|
||||
public:
|
||||
InputReference() : ControlReference( true ) {}
|
||||
ControlState State( const ControlState state );
|
||||
bool Detect( const unsigned int ms, const unsigned int count );
|
||||
void UpdateControls();
|
||||
|
||||
unsigned int mode;
|
||||
};
|
||||
|
||||
//
|
||||
// OutputReference
|
||||
//
|
||||
// control reference for outputs
|
||||
//
|
||||
class OutputReference : public ControlReference
|
||||
{
|
||||
public:
|
||||
OutputReference() : ControlReference( false ) {}
|
||||
ControlState State( const ControlState state );
|
||||
bool Detect( const unsigned int ms, const unsigned int count );
|
||||
void UpdateControls();
|
||||
};
|
||||
|
||||
ControllerInterface() : m_is_init(false) {}
|
||||
|
||||
void SetHwnd( void* const hwnd );
|
||||
void Init();
|
||||
void DeInit();
|
||||
bool IsInit();
|
||||
|
||||
void UpdateReference( ControlReference* control );
|
||||
bool UpdateInput();
|
||||
bool UpdateOutput();
|
||||
|
||||
const std::vector<Device*>& Devices();
|
||||
|
||||
private:
|
||||
bool m_is_init;
|
||||
std::vector<Device*> m_devices;
|
||||
void* m_hwnd;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
+35
-35
@@ -1,35 +1,35 @@
|
||||
#include "../ControllerInterface.h"
|
||||
|
||||
#ifdef CIFACE_USE_DIRECTINPUT
|
||||
|
||||
#include "DirectInput.h"
|
||||
|
||||
#pragma comment(lib, "Dinput8.lib")
|
||||
#pragma comment(lib, "dxguid.lib")
|
||||
|
||||
namespace ciface
|
||||
{
|
||||
namespace DirectInput
|
||||
{
|
||||
|
||||
void Init( std::vector<ControllerInterface::Device*>& devices/*, HWND hwnd*/ )
|
||||
{
|
||||
IDirectInput8* idi8;
|
||||
if ( DI_OK != DirectInput8Create( GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8, (LPVOID*)&idi8, NULL ) )
|
||||
return;
|
||||
|
||||
#ifdef CIFACE_USE_DIRECTINPUT_KBM
|
||||
InitKeyboardMouse( idi8, devices );
|
||||
#endif
|
||||
#ifdef CIFACE_USE_DIRECTINPUT_JOYSTICK
|
||||
InitJoystick( idi8, devices/*, hwnd*/ );
|
||||
#endif
|
||||
|
||||
idi8->Release();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#include "../ControllerInterface.h"
|
||||
|
||||
#ifdef CIFACE_USE_DIRECTINPUT
|
||||
|
||||
#include "DirectInput.h"
|
||||
|
||||
#pragma comment(lib, "Dinput8.lib")
|
||||
#pragma comment(lib, "dxguid.lib")
|
||||
|
||||
namespace ciface
|
||||
{
|
||||
namespace DirectInput
|
||||
{
|
||||
|
||||
void Init( std::vector<ControllerInterface::Device*>& devices/*, HWND hwnd*/ )
|
||||
{
|
||||
IDirectInput8* idi8;
|
||||
if ( DI_OK != DirectInput8Create( GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8, (LPVOID*)&idi8, NULL ) )
|
||||
return;
|
||||
|
||||
#ifdef CIFACE_USE_DIRECTINPUT_KBM
|
||||
InitKeyboardMouse( idi8, devices );
|
||||
#endif
|
||||
#ifdef CIFACE_USE_DIRECTINPUT_JOYSTICK
|
||||
InitJoystick( idi8, devices/*, hwnd*/ );
|
||||
#endif
|
||||
|
||||
idi8->Release();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
#ifndef _CIFACE_DIRECTINPUT_H_
|
||||
#define _CIFACE_DIRECTINPUT_H_
|
||||
|
||||
#include "../ControllerInterface.h"
|
||||
|
||||
#define DIRECTINPUT_VERSION 0x0800
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define NOMINMAX
|
||||
#include <Windows.h>
|
||||
#include <dinput.h>
|
||||
|
||||
#ifdef CIFACE_USE_DIRECTINPUT_JOYSTICK
|
||||
#include "DirectInputJoystick.h"
|
||||
#endif
|
||||
#ifdef CIFACE_USE_DIRECTINPUT_KBM
|
||||
#include "DirectInputKeyboardMouse.h"
|
||||
#endif
|
||||
|
||||
namespace ciface
|
||||
{
|
||||
namespace DirectInput
|
||||
{
|
||||
|
||||
void Init( std::vector<ControllerInterface::Device*>& devices/*, HWND hwnd*/ );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifndef _CIFACE_DIRECTINPUT_H_
|
||||
#define _CIFACE_DIRECTINPUT_H_
|
||||
|
||||
#include "../ControllerInterface.h"
|
||||
|
||||
#define DIRECTINPUT_VERSION 0x0800
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define NOMINMAX
|
||||
#include <Windows.h>
|
||||
#include <dinput.h>
|
||||
|
||||
#ifdef CIFACE_USE_DIRECTINPUT_JOYSTICK
|
||||
#include "DirectInputJoystick.h"
|
||||
#endif
|
||||
#ifdef CIFACE_USE_DIRECTINPUT_KBM
|
||||
#include "DirectInputKeyboardMouse.h"
|
||||
#endif
|
||||
|
||||
namespace ciface
|
||||
{
|
||||
namespace DirectInput
|
||||
{
|
||||
|
||||
void Init( std::vector<ControllerInterface::Device*>& devices/*, HWND hwnd*/ );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+507
-507
File diff suppressed because it is too large
Load Diff
+137
-137
@@ -1,137 +1,137 @@
|
||||
#ifndef _CIFACE_DIRECTINPUT_JOYSTICK_H_
|
||||
#define _CIFACE_DIRECTINPUT_JOYSTICK_H_
|
||||
|
||||
#include "../ControllerInterface.h"
|
||||
|
||||
#define DIRECTINPUT_VERSION 0x0800
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define NOMINMAX
|
||||
#include <Windows.h>
|
||||
#include <dinput.h>
|
||||
|
||||
#ifdef CIFACE_USE_XINPUT
|
||||
// this takes so long, idk if it should be enabled :(
|
||||
#define NO_DUPLICATE_DINPUT_XINPUT
|
||||
#include <wbemidl.h>
|
||||
#include <oleauto.h>
|
||||
#endif
|
||||
|
||||
namespace ciface
|
||||
{
|
||||
namespace DirectInput
|
||||
{
|
||||
|
||||
void InitJoystick( IDirectInput8* const idi8, std::vector<ControllerInterface::Device*>& devices/*, HWND hwnd*/ );
|
||||
|
||||
class Joystick : public ControllerInterface::Device
|
||||
{
|
||||
friend class ControllerInterface;
|
||||
friend class ControllerInterface::ControlReference;
|
||||
|
||||
protected:
|
||||
|
||||
struct EffectState
|
||||
{
|
||||
EffectState( LPDIRECTINPUTEFFECT eff ) : changed(0), iface(eff) {}
|
||||
LPDIRECTINPUTEFFECT iface;
|
||||
ControlState magnitude;
|
||||
bool changed;
|
||||
};
|
||||
|
||||
class Input : public ControllerInterface::Device::Input
|
||||
{
|
||||
friend class Joystick;
|
||||
protected:
|
||||
virtual ControlState GetState( const DIJOYSTATE* const joystate ) = 0;
|
||||
};
|
||||
|
||||
// can probably eliminate this base class
|
||||
class Output : public ControllerInterface::Device::Output
|
||||
{
|
||||
friend class Joystick;
|
||||
protected:
|
||||
virtual void SetState( const ControlState state, EffectState* const joystate ) = 0;
|
||||
};
|
||||
|
||||
class Button : public Input
|
||||
{
|
||||
friend class Joystick;
|
||||
public:
|
||||
std::string GetName() const;
|
||||
protected:
|
||||
Button( const unsigned int index ) : m_index(index) {}
|
||||
ControlState GetState( const DIJOYSTATE* const joystate );
|
||||
private:
|
||||
const unsigned int m_index;
|
||||
};
|
||||
|
||||
class Axis : public Input
|
||||
{
|
||||
friend class Joystick;
|
||||
public:
|
||||
std::string GetName() const;
|
||||
protected:
|
||||
Axis( const unsigned int index, const LONG base, const LONG range ) : m_index(index), m_base(base), m_range(range) {}
|
||||
ControlState GetState( const DIJOYSTATE* const joystate );
|
||||
private:
|
||||
const unsigned int m_index;
|
||||
const LONG m_base;
|
||||
const LONG m_range;
|
||||
};
|
||||
|
||||
class Hat : public Input
|
||||
{
|
||||
friend class Joystick;
|
||||
public:
|
||||
std::string GetName() const;
|
||||
protected:
|
||||
Hat( const unsigned int index, const unsigned int direction ) : m_index(index), m_direction(direction) {}
|
||||
ControlState GetState( const DIJOYSTATE* const joystate );
|
||||
private:
|
||||
const unsigned int m_index;
|
||||
const unsigned int m_direction;
|
||||
};
|
||||
|
||||
class Force : public Output
|
||||
{
|
||||
friend class Joystick;
|
||||
public:
|
||||
std::string GetName() const;
|
||||
protected:
|
||||
Force( const unsigned int index ) : m_index(index) {}
|
||||
void SetState( const ControlState state, EffectState* const joystate );
|
||||
private:
|
||||
const unsigned int m_index;
|
||||
};
|
||||
|
||||
bool UpdateInput();
|
||||
bool UpdateOutput();
|
||||
|
||||
ControlState GetInputState( const ControllerInterface::Device::Input* const input );
|
||||
void SetOutputState( const ControllerInterface::Device::Output* const input, const ControlState state );
|
||||
|
||||
void ClearInputState();
|
||||
|
||||
public:
|
||||
Joystick( /*const LPCDIDEVICEINSTANCE lpddi, */const LPDIRECTINPUTDEVICE8 device, const unsigned int index );
|
||||
~Joystick();
|
||||
|
||||
std::string GetName() const;
|
||||
int GetId() const;
|
||||
std::string GetSource() const;
|
||||
|
||||
private:
|
||||
const LPDIRECTINPUTDEVICE8 m_device;
|
||||
const unsigned int m_index;
|
||||
//const std::string m_name;
|
||||
|
||||
DIJOYSTATE m_state_in;
|
||||
std::vector<EffectState> m_state_out;
|
||||
|
||||
bool m_must_poll;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifndef _CIFACE_DIRECTINPUT_JOYSTICK_H_
|
||||
#define _CIFACE_DIRECTINPUT_JOYSTICK_H_
|
||||
|
||||
#include "../ControllerInterface.h"
|
||||
|
||||
#define DIRECTINPUT_VERSION 0x0800
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define NOMINMAX
|
||||
#include <Windows.h>
|
||||
#include <dinput.h>
|
||||
|
||||
#ifdef CIFACE_USE_XINPUT
|
||||
// this takes so long, idk if it should be enabled :(
|
||||
#define NO_DUPLICATE_DINPUT_XINPUT
|
||||
#include <wbemidl.h>
|
||||
#include <oleauto.h>
|
||||
#endif
|
||||
|
||||
namespace ciface
|
||||
{
|
||||
namespace DirectInput
|
||||
{
|
||||
|
||||
void InitJoystick( IDirectInput8* const idi8, std::vector<ControllerInterface::Device*>& devices/*, HWND hwnd*/ );
|
||||
|
||||
class Joystick : public ControllerInterface::Device
|
||||
{
|
||||
friend class ControllerInterface;
|
||||
friend class ControllerInterface::ControlReference;
|
||||
|
||||
protected:
|
||||
|
||||
struct EffectState
|
||||
{
|
||||
EffectState( LPDIRECTINPUTEFFECT eff ) : changed(0), iface(eff) {}
|
||||
LPDIRECTINPUTEFFECT iface;
|
||||
ControlState magnitude;
|
||||
bool changed;
|
||||
};
|
||||
|
||||
class Input : public ControllerInterface::Device::Input
|
||||
{
|
||||
friend class Joystick;
|
||||
protected:
|
||||
virtual ControlState GetState( const DIJOYSTATE* const joystate ) = 0;
|
||||
};
|
||||
|
||||
// can probably eliminate this base class
|
||||
class Output : public ControllerInterface::Device::Output
|
||||
{
|
||||
friend class Joystick;
|
||||
protected:
|
||||
virtual void SetState( const ControlState state, EffectState* const joystate ) = 0;
|
||||
};
|
||||
|
||||
class Button : public Input
|
||||
{
|
||||
friend class Joystick;
|
||||
public:
|
||||
std::string GetName() const;
|
||||
protected:
|
||||
Button( const unsigned int index ) : m_index(index) {}
|
||||
ControlState GetState( const DIJOYSTATE* const joystate );
|
||||
private:
|
||||
const unsigned int m_index;
|
||||
};
|
||||
|
||||
class Axis : public Input
|
||||
{
|
||||
friend class Joystick;
|
||||
public:
|
||||
std::string GetName() const;
|
||||
protected:
|
||||
Axis( const unsigned int index, const LONG base, const LONG range ) : m_index(index), m_base(base), m_range(range) {}
|
||||
ControlState GetState( const DIJOYSTATE* const joystate );
|
||||
private:
|
||||
const unsigned int m_index;
|
||||
const LONG m_base;
|
||||
const LONG m_range;
|
||||
};
|
||||
|
||||
class Hat : public Input
|
||||
{
|
||||
friend class Joystick;
|
||||
public:
|
||||
std::string GetName() const;
|
||||
protected:
|
||||
Hat( const unsigned int index, const unsigned int direction ) : m_index(index), m_direction(direction) {}
|
||||
ControlState GetState( const DIJOYSTATE* const joystate );
|
||||
private:
|
||||
const unsigned int m_index;
|
||||
const unsigned int m_direction;
|
||||
};
|
||||
|
||||
class Force : public Output
|
||||
{
|
||||
friend class Joystick;
|
||||
public:
|
||||
std::string GetName() const;
|
||||
protected:
|
||||
Force( const unsigned int index ) : m_index(index) {}
|
||||
void SetState( const ControlState state, EffectState* const joystate );
|
||||
private:
|
||||
const unsigned int m_index;
|
||||
};
|
||||
|
||||
bool UpdateInput();
|
||||
bool UpdateOutput();
|
||||
|
||||
ControlState GetInputState( const ControllerInterface::Device::Input* const input );
|
||||
void SetOutputState( const ControllerInterface::Device::Output* const input, const ControlState state );
|
||||
|
||||
void ClearInputState();
|
||||
|
||||
public:
|
||||
Joystick( /*const LPCDIDEVICEINSTANCE lpddi, */const LPDIRECTINPUTDEVICE8 device, const unsigned int index );
|
||||
~Joystick();
|
||||
|
||||
std::string GetName() const;
|
||||
int GetId() const;
|
||||
std::string GetSource() const;
|
||||
|
||||
private:
|
||||
const LPDIRECTINPUTDEVICE8 m_device;
|
||||
const unsigned int m_index;
|
||||
//const std::string m_name;
|
||||
|
||||
DIJOYSTATE m_state_in;
|
||||
std::vector<EffectState> m_state_out;
|
||||
|
||||
bool m_must_poll;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+269
-269
File diff suppressed because it is too large
Load Diff
+125
-125
@@ -1,125 +1,125 @@
|
||||
#ifndef _CIFACE_DIRECTINPUT_KBM_H_
|
||||
#define _CIFACE_DIRECTINPUT_KBM_H_
|
||||
|
||||
#include "../ControllerInterface.h"
|
||||
|
||||
#define DIRECTINPUT_VERSION 0x0800
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define NOMINMAX
|
||||
#include <Windows.h>
|
||||
#include <dinput.h>
|
||||
|
||||
#include <wx/stopwatch.h>
|
||||
#include <wx/utils.h>
|
||||
|
||||
namespace ciface
|
||||
{
|
||||
namespace DirectInput
|
||||
{
|
||||
|
||||
void InitKeyboardMouse( IDirectInput8* const idi8, std::vector<ControllerInterface::Device*>& devices );
|
||||
|
||||
class KeyboardMouse : public ControllerInterface::Device
|
||||
{
|
||||
friend class ControllerInterface;
|
||||
friend class ControllerInterface::ControlReference;
|
||||
|
||||
protected:
|
||||
|
||||
struct State
|
||||
{
|
||||
BYTE keyboard[256];
|
||||
DIMOUSESTATE2 mouse;
|
||||
};
|
||||
|
||||
class Input : public ControllerInterface::Device::Input
|
||||
{
|
||||
friend class KeyboardMouse;
|
||||
protected:
|
||||
virtual ControlState GetState( const State* const boardstate ) = 0;
|
||||
};
|
||||
|
||||
class Output : public ControllerInterface::Device::Output
|
||||
{
|
||||
friend class KeyboardMouse;
|
||||
protected:
|
||||
virtual void SetState( const ControlState state, unsigned char* const state_out ) = 0;
|
||||
};
|
||||
|
||||
class Key : public Input
|
||||
{
|
||||
friend class KeyboardMouse;
|
||||
public:
|
||||
std::string GetName() const;
|
||||
protected:
|
||||
Key( const unsigned int index ) : m_index(index) {}
|
||||
ControlState GetState( const State* const state );
|
||||
private:
|
||||
const unsigned int m_index;
|
||||
};
|
||||
|
||||
class Button : public Input
|
||||
{
|
||||
friend class KeyboardMouse;
|
||||
public:
|
||||
std::string GetName() const;
|
||||
protected:
|
||||
Button( const unsigned int index ) : m_index(index) {}
|
||||
ControlState GetState( const State* const state );
|
||||
private:
|
||||
const unsigned int m_index;
|
||||
};
|
||||
|
||||
class Axis : public Input
|
||||
{
|
||||
friend class KeyboardMouse;
|
||||
public:
|
||||
std::string GetName() const;
|
||||
protected:
|
||||
Axis( const unsigned int index, const LONG range ) : m_index(index), m_range(range) {}
|
||||
ControlState GetState( const State* const state );
|
||||
private:
|
||||
const unsigned int m_index;
|
||||
const LONG m_range;
|
||||
};
|
||||
|
||||
class Light : public Output
|
||||
{
|
||||
friend class KeyboardMouse;
|
||||
public:
|
||||
std::string GetName() const;
|
||||
protected:
|
||||
Light( const unsigned int index ) : m_index(index) {}
|
||||
void SetState( const ControlState state, unsigned char* const state_out );
|
||||
private:
|
||||
const unsigned int m_index;
|
||||
};
|
||||
|
||||
bool UpdateInput();
|
||||
bool UpdateOutput();
|
||||
|
||||
ControlState GetInputState( const ControllerInterface::Device::Input* const input );
|
||||
void SetOutputState( const ControllerInterface::Device::Output* const input, const ControlState state );
|
||||
|
||||
public:
|
||||
KeyboardMouse( const LPDIRECTINPUTDEVICE8 kb_device, const LPDIRECTINPUTDEVICE8 mo_device );
|
||||
~KeyboardMouse();
|
||||
|
||||
std::string GetName() const;
|
||||
int GetId() const;
|
||||
std::string GetSource() const;
|
||||
|
||||
private:
|
||||
const LPDIRECTINPUTDEVICE8 m_kb_device;
|
||||
const LPDIRECTINPUTDEVICE8 m_mo_device;
|
||||
|
||||
wxLongLong m_last_update;
|
||||
State m_state_in;
|
||||
unsigned char m_state_out[3]; // NUM CAPS SCROLL
|
||||
bool m_current_state_out[3]; // NUM CAPS SCROLL
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifndef _CIFACE_DIRECTINPUT_KBM_H_
|
||||
#define _CIFACE_DIRECTINPUT_KBM_H_
|
||||
|
||||
#include "../ControllerInterface.h"
|
||||
|
||||
#define DIRECTINPUT_VERSION 0x0800
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define NOMINMAX
|
||||
#include <Windows.h>
|
||||
#include <dinput.h>
|
||||
|
||||
#include <wx/stopwatch.h>
|
||||
#include <wx/utils.h>
|
||||
|
||||
namespace ciface
|
||||
{
|
||||
namespace DirectInput
|
||||
{
|
||||
|
||||
void InitKeyboardMouse( IDirectInput8* const idi8, std::vector<ControllerInterface::Device*>& devices );
|
||||
|
||||
class KeyboardMouse : public ControllerInterface::Device
|
||||
{
|
||||
friend class ControllerInterface;
|
||||
friend class ControllerInterface::ControlReference;
|
||||
|
||||
protected:
|
||||
|
||||
struct State
|
||||
{
|
||||
BYTE keyboard[256];
|
||||
DIMOUSESTATE2 mouse;
|
||||
};
|
||||
|
||||
class Input : public ControllerInterface::Device::Input
|
||||
{
|
||||
friend class KeyboardMouse;
|
||||
protected:
|
||||
virtual ControlState GetState( const State* const boardstate ) = 0;
|
||||
};
|
||||
|
||||
class Output : public ControllerInterface::Device::Output
|
||||
{
|
||||
friend class KeyboardMouse;
|
||||
protected:
|
||||
virtual void SetState( const ControlState state, unsigned char* const state_out ) = 0;
|
||||
};
|
||||
|
||||
class Key : public Input
|
||||
{
|
||||
friend class KeyboardMouse;
|
||||
public:
|
||||
std::string GetName() const;
|
||||
protected:
|
||||
Key( const unsigned int index ) : m_index(index) {}
|
||||
ControlState GetState( const State* const state );
|
||||
private:
|
||||
const unsigned int m_index;
|
||||
};
|
||||
|
||||
class Button : public Input
|
||||
{
|
||||
friend class KeyboardMouse;
|
||||
public:
|
||||
std::string GetName() const;
|
||||
protected:
|
||||
Button( const unsigned int index ) : m_index(index) {}
|
||||
ControlState GetState( const State* const state );
|
||||
private:
|
||||
const unsigned int m_index;
|
||||
};
|
||||
|
||||
class Axis : public Input
|
||||
{
|
||||
friend class KeyboardMouse;
|
||||
public:
|
||||
std::string GetName() const;
|
||||
protected:
|
||||
Axis( const unsigned int index, const LONG range ) : m_index(index), m_range(range) {}
|
||||
ControlState GetState( const State* const state );
|
||||
private:
|
||||
const unsigned int m_index;
|
||||
const LONG m_range;
|
||||
};
|
||||
|
||||
class Light : public Output
|
||||
{
|
||||
friend class KeyboardMouse;
|
||||
public:
|
||||
std::string GetName() const;
|
||||
protected:
|
||||
Light( const unsigned int index ) : m_index(index) {}
|
||||
void SetState( const ControlState state, unsigned char* const state_out );
|
||||
private:
|
||||
const unsigned int m_index;
|
||||
};
|
||||
|
||||
bool UpdateInput();
|
||||
bool UpdateOutput();
|
||||
|
||||
ControlState GetInputState( const ControllerInterface::Device::Input* const input );
|
||||
void SetOutputState( const ControllerInterface::Device::Output* const input, const ControlState state );
|
||||
|
||||
public:
|
||||
KeyboardMouse( const LPDIRECTINPUTDEVICE8 kb_device, const LPDIRECTINPUTDEVICE8 mo_device );
|
||||
~KeyboardMouse();
|
||||
|
||||
std::string GetName() const;
|
||||
int GetId() const;
|
||||
std::string GetSource() const;
|
||||
|
||||
private:
|
||||
const LPDIRECTINPUTDEVICE8 m_kb_device;
|
||||
const LPDIRECTINPUTDEVICE8 m_mo_device;
|
||||
|
||||
wxLongLong m_last_update;
|
||||
State m_state_in;
|
||||
unsigned char m_state_out[3]; // NUM CAPS SCROLL
|
||||
bool m_current_state_out[3]; // NUM CAPS SCROLL
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user