Commited my new wiimote plugin work so far. Some code was copied from the current wiimote plugin. I have cleaned up most of the functions, but there are still a bunch of unused structs and stuff that I need to clean up.

Moved ControllerInterface to InputCommon. Moved GCPadNew GUI/Config code to a new project, InputPluginCommon. It is used by both GCPadNew and WiimoteNew. I hope that I included everyone's fixes to GCPadNew and ControllerInterface.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5355 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Jordan Woyak
2010-04-13 05:15:38 +00:00
parent 9592da1a9b
commit d8906d2a0c
53 changed files with 4398 additions and 931 deletions

View File

@ -0,0 +1,101 @@
#include "../ControllerInterface.h"
#ifdef CIFACE_USE_OSX
#include "OSX.h"
#include "OSXPrivate.h"
namespace ciface
{
namespace OSX
{
void Init( std::vector<ControllerInterface::Device*>& devices, void* hwnd )
{
// mouse will be added to this, Keyboard class will be turned into KeyboardMouse
// single device for combined keyboard/mouse, this will allow combinations like shift+click more easily
//devices.push_back( new Keyboard( hwnd ) );
}
Keyboard::Keyboard( void *View )
{
memset( &m_state, 0, sizeof(m_state) );
OSX_Init(View);
// This is REALLY dumb right here
// Should REALLY cover the entire UTF-8 Range
for (int a = 0; a < 256; ++a)
inputs.push_back( new Key( (char)a ) );
}
Keyboard::~Keyboard()
{
// might not need this func
}
ControlState Keyboard::GetInputState( const ControllerInterface::Device::Input* const input )
{
return ((Input*)input)->GetState( &m_state );
}
void Keyboard::SetOutputState( const ControllerInterface::Device::Output* const output, const ControlState state )
{
}
bool Keyboard::UpdateInput()
{
memset(m_state.keyboard, 0, 256);
OSX_UpdateKeys(256, m_state.keyboard );
// mouse stuff in here too
return true;
}
bool Keyboard::UpdateOutput()
{
return true;
}
std::string Keyboard::GetName() const
{
return "Keyboard";
//return "Keyboard Mouse"; // change to this later
}
std::string Keyboard::GetSource() const
{
return "OSX";
}
int Keyboard::GetId() const
{
return 0;
}
ControlState Keyboard::Key::GetState( State* const state )
{
for(unsigned int a = 0; a < 256; ++a)
if(state->keyboard[a] == m_index)
return true;
return false;
}
std::string Keyboard::Key::GetName() const
{
char temp[16];
sprintf(temp, "Key:%c", m_index);
return std::string(temp);
}
}
}
#endif

View File

@ -0,0 +1,68 @@
#ifndef _CIFACE_OSX_H_
#define _CIFACE_OSX_H_
#include "../ControllerInterface.h"
namespace ciface
{
namespace OSX
{
void Init( std::vector<ControllerInterface::Device*>& devices, void* hwnd );
class Keyboard : public ControllerInterface::Device
{
friend class ControllerInterface;
friend class ControllerInterface::ControlReference;
protected:
struct State
{
char keyboard[256]; // really dumb
// mouse crap will go here
};
class Input : public ControllerInterface::Device::Input
{
friend class Keyboard;
protected:
Input( const unsigned char index ) : m_index(index) {}
virtual ControlState GetState( State* const js ) = 0;
const unsigned char m_index;
};
class Key : public Input
{
friend class Keyboard;
public:
std::string GetName() const;
protected:
Key( const unsigned char key ) : Input(key) {}
ControlState GetState( State* const js );
};
bool UpdateInput();
bool UpdateOutput();
ControlState GetInputState( const ControllerInterface::Device::Input* const input );
void SetOutputState( const ControllerInterface::Device::Output* const output, const ControlState state );
public:
Keyboard( void* view );
~Keyboard();
std::string GetName() const;
std::string GetSource() const;
int GetId() const;
private:
State m_state;
};
}
}
#endif

View File

@ -0,0 +1,3 @@
void OSX_Init(void *_View);
void OSX_UpdateKeys( int max, char* keys );

View File

@ -0,0 +1,38 @@
#import <AppKit/NSWindow.h>
#import <AppKit/NSView.h>
#import <Cocoa/Cocoa.h>
#include "OSXPrivate.h"
NSWindow* m_Window;
void OSX_Init(void *_View)
{
// _View is really a wxNSView
//m_Window is really a wxNSWindow
NSView *View = (NSView*)_View;
m_Window = [View window];
}
void OSX_UpdateKeys( int max, char* keys )
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSEvent *event = [[NSEvent alloc] init];
/*event = [m_Window nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantPast] inMode:NSDefaultRunLoopMode dequeue:YES ];
if ( event != nil ) {
switch ([event type]) {
case NSKeyDown:
//case NSKeyUp:
//case NSFlagsChanged: // For Command
memcpy(keys, [[event characters] UTF8String], max);
break;
default:
[m_Window sendEvent:event];
break;
}
}*/
[event release];
[pool release];
}