git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@51 8ced0084-cf51-0410-be5f-012b33b47a6e

This commit is contained in:
fires.gc
2008-07-22 09:02:26 +00:00
parent 52086208ca
commit e8b40c07a3
11 changed files with 2040 additions and 20 deletions
@@ -1,20 +0,0 @@
Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Plugin_nJoy_SDL", "Plugin_nJoy_SDL\Plugin_nJoy_SDL.vcproj", "{521498BE-6089-4780-8223-E67C22F4E068}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{521498BE-6089-4780-8223-E67C22F4E068}.Debug|Win32.ActiveCfg = Debug|Win32
{521498BE-6089-4780-8223-E67C22F4E068}.Debug|Win32.Build.0 = Debug|Win32
{521498BE-6089-4780-8223-E67C22F4E068}.Release|Win32.ActiveCfg = Release|Win32
{521498BE-6089-4780-8223-E67C22F4E068}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,158 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// Dutch (Netherlands) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NLD)
#ifdef _WIN32
LANGUAGE LANG_DUTCH, SUBLANG_DUTCH
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_CONFIG DIALOGEX 0, 0, 411, 282
STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_SYSMENU
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
COMBOBOX IDC_JOYNAME,8,18,317,30,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP
GROUPBOX "Controller:",IDC_STATIC,3,7,405,28
CONTROL 102,IDC_STATIC,"Static",SS_BITMAP | SS_REALSIZEIMAGE | SS_SUNKEN,65,46,281,187
CONTROL "Controller attached",IDC_JOYATTACH,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,330,19,73,10
PUSHBUTTON "",IDC_SHOULDERL,46,50,15,10,0,WS_EX_STATICEDGE
PUSHBUTTON "",IDC_B,350,50,15,10,0,WS_EX_STATICEDGE
PUSHBUTTON "",IDC_SHOULDERR,350,66,15,10,0,WS_EX_STATICEDGE
PUSHBUTTON "",IDC_Z,350,90,15,10,0,WS_EX_STATICEDGE
PUSHBUTTON "",IDC_Y,350,106,15,10,0,WS_EX_STATICEDGE
PUSHBUTTON "",IDC_X,350,150,15,10,0,WS_EX_STATICEDGE
PUSHBUTTON "",IDC_A,350,173,15,10,0,WS_EX_STATICEDGE
PUSHBUTTON "",IDC_SX,351,217,15,10,0,WS_EX_STATICEDGE
PUSHBUTTON "",IDC_START,197,236,15,10,0,WS_EX_STATICEDGE
PUSHBUTTON "",IDC_DPAD,46,183,15,10,0,WS_EX_STATICEDGE
PUSHBUTTON "",IDC_MX,46,135,15,10,0,WS_EX_STATICEDGE
CTEXT "",IDTEXT_SHOULDERL,4,49,40,12,WS_BORDER
CTEXT "",IDTEXT_B,368,49,40,12,WS_BORDER
CTEXT "",IDTEXT_SHOULDERR,368,65,40,12,WS_BORDER
CTEXT "",IDTEXT_Z,368,89,40,12,WS_BORDER
CTEXT "",IDTEXT_Y,368,105,40,12,WS_BORDER
CTEXT "",IDTEXT_X,368,149,40,12,WS_BORDER
CTEXT "",IDTEXT_A,368,172,40,12,WS_BORDER
CTEXT "",IDTEXT_MX,4,134,40,12,WS_BORDER
CTEXT "",IDTEXT_DPAD,4,182,40,12,WS_BORDER
CTEXT "",IDTEXT_START,185,248,40,12,WS_BORDER
CTEXT "",IDTEXT_MY,3,157,40,12,WS_BORDER
LTEXT "X-axis",IDC_STATIC,4,124,20,8
LTEXT "Y-axis",IDC_STATIC,4,147,20,8
CTEXT "",IDTEXT_SX,368,216,40,12,WS_BORDER
CTEXT "",IDTEXT_SY,367,239,40,12,WS_BORDER
LTEXT "X-axis",IDC_STATIC,368,206,20,8
LTEXT "Y-axis",IDC_STATIC,368,229,20,8
PUSHBUTTON "",IDC_SY,351,240,15,10,0,WS_EX_STATICEDGE
PUSHBUTTON "",IDC_MY,46,158,15,10,0,WS_EX_STATICEDGE
GROUPBOX "Extra settings",IDC_STATIC,3,236,95,43
LTEXT "Deadzone",IDC_STATIC,11,248,33,8
LTEXT "Half press",IDC_STATIC,11,263,33,8
COMBOBOX IDC_DEADZONE,45,246,48,30,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_HALFPRESS,45,261,48,30,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP
LTEXT "www.multigesture.net",IDC_STATIC,336,271,72,8
END
IDD_ABOUT DIALOGEX 0, 0, 133, 227
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION
CAPTION "About: nJoy Input Plugin"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "OK",IDOK,75,209,50,14
CONTROL 104,IDC_STATIC,"Static",SS_BITMAP,0,0,133,37
GROUPBOX "Plugin info:",IDC_STATIC,7,39,120,42
GROUPBOX "Special thanks to:",IDC_STATIC,7,84,120,24
GROUPBOX "Greetings to:",IDC_STATIC,7,112,120,95
LTEXT "",IDC_ABOUT_TEXT,13,51,108,24
LTEXT "F|RES and ector.",IDC_STATIC,13,95,108,8
LTEXT "Static",IDC_ABOUT_TEXT2,13,123,111,82
LTEXT "BETA RELEASE",IDC_ABOUT_TEXT3,10,211,62,13
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
BEGIN
IDD_CONFIG, DIALOG
BEGIN
LEFTMARGIN, 3
RIGHTMARGIN, 408
TOPMARGIN, 7
BOTTOMMARGIN, 279
END
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Bitmap
//
IDB_BITMAP1 BITMAP "controller.bmp"
IDB_BITMAP2 BITMAP "njoy.bmp"
#endif // Dutch (Netherlands) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
Binary file not shown.

After

Width:  |  Height:  |  Size: 375 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

@@ -0,0 +1,60 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by Plugin_nJoy_SDL.rc
//
#define IDD_CONFIG 101
#define IDB_BITMAP1 102
#define IDD_ABOUT 103
#define IDB_BITMAP2 104
#define IDC_JOYNAME 1001
#define IDC_JOYATTACH 1002
#define IDC_SHOULDERL 1010
#define IDC_SHOULDERR 1011
#define IDC_A 1012
#define IDC_B 1013
#define IDC_X 1014
#define IDC_Y 1015
#define IDC_Z 1016
#define IDC_START 1017
#define IDC_DPAD 1018
#define IDC_MX 1019
#define IDC_MY 1020
#define IDC_SX 1021
#define IDC_SY 1022
#define IDC_DEADZONE 1023
#define IDC_HALFPRESS 1024
#define IDTEXT_SHOULDERL 2010
#define IDTEXT_SHOULDERR 2011
#define IDTEXT_A 2012
#define IDTEXT_B 2013
#define IDTEXT_X 2014
#define IDTEXT_Y 2015
#define IDTEXT_Z 2016
#define IDTEXT_START 2017
#define IDTEXT_DPAD 2018
#define IDTEXT_MX 2019
#define IDTEXT_MY 2020
#define IDTEXT_SX 2021
#define IDTEXT_SY 2022
#define IDC_ABOUT_TEXT 1032
#define IDC_ABOUT_TEXT2 1033
#define IDC_ABOUT_TEXT3 1034
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 105
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1036
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,67 @@
//////////////////////////////////////////////////////////////////////////////////////////
// Project description
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
// Name: nJoy
// Description: A Dolphin Compatible Input Plugin
//
// Author: Falcon4ever (nJoy@falcon4ever.com)
// Site: www.multigesture.net
// Copyright (C) 2003-2008 Dolphin Project.
//
//////////////////////////////////////////////////////////////////////////////////////////
//
// Licensetype: GNU General Public License (GPL)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
//
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
//
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
//
//////////////////////////////////////////////////////////////////////////////////////////
#include <windows.h> // includes basic windows functionality
#include <Windowsx.h>
#include <stdio.h>
#include <commctrl.h> // includes the common control header
#include "../Res/resource.h" // includes GUI IDs
#pragma comment(lib, "comctl32.lib")
//////////////////////////////////////////////////////////////////////////////////////////
// Config dialog functions
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
int OpenConfig(HINSTANCE hInst, HWND _hParent);
BOOL ControllerTab(HWND hDlg, UINT message, UINT wParam, LONG lParam, int controller);
BOOL APIENTRY ControllerTab1(HWND hDlg, UINT message, UINT wParam, LONG lParam);
BOOL APIENTRY ControllerTab2(HWND hDlg, UINT message, UINT wParam, LONG lParam);
BOOL APIENTRY ControllerTab3(HWND hDlg, UINT message, UINT wParam, LONG lParam);
BOOL APIENTRY ControllerTab4(HWND hDlg, UINT message, UINT wParam, LONG lParam);
bool GetButtons(HWND hDlg, int buttonid, int controller);
bool GetHats(HWND hDlg, int buttonid, int controller);
bool GetAxis(HWND hDlg, int buttonid, int controller);
void GetControllerAll(HWND hDlg, int controller);
void SetControllerAll(HWND hDlg, int controller);
int GetButton(HWND hDlg, int item);
void SetButton(HWND hDlg, int item, int value);
//////////////////////////////////////////////////////////////////////////////////////////
// About dialog functions
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
void OpenAbout(HINSTANCE hInst, HWND _hParent);
BOOL CALLBACK AboutDlg(HWND abouthWnd, UINT message, WPARAM wParam, LPARAM lParam);
+445
View File
@@ -0,0 +1,445 @@
//////////////////////////////////////////////////////////////////////////////////////////
// Project description
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
// Name: nJoy
// Description: A Dolphin Compatible Input Plugin
//
// Author: Falcon4ever (nJoy@falcon4ever.com)
// Site: www.multigesture.net
// Copyright (C) 2003-2008 Dolphin Project.
//
//////////////////////////////////////////////////////////////////////////////////////////
//
// Licensetype: GNU General Public License (GPL)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
//
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
//
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
//
//////////////////////////////////////////////////////////////////////////////////////////
#include "nJoy.h"
//////////////////////////////////////////////////////////////////////////////////////////
// Variables
// ¯¯¯¯¯¯¯¯¯
FILE *pFile;
HINSTANCE nJoy_hInst = NULL;
CONTROLLER_INFO *joyinfo = 0;
CONTROLLER_STATE joystate[4];
CONTROLLER_MAPPING joysticks[4];
bool emulator_running = FALSE;
//////////////////////////////////////////////////////////////////////////////////////////
// DllMain
// ¯¯¯¯¯¯¯
BOOL APIENTRY DllMain( HINSTANCE hinstDLL, // DLL module handle
DWORD dwReason, // reason called
LPVOID lpvReserved) // reserved
{
InitCommonControls();
nJoy_hInst = hinstDLL;
return TRUE;
}
//////////////////////////////////////////////////////////////////////////////////////////
// Input Plugin Functions (from spec's)
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
// Get properties of plugin
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
void GetDllInfo(PLUGIN_INFO* _PluginInfo)
{
_PluginInfo->Version = 0x0100;
_PluginInfo->Type = PLUGIN_TYPE_PAD;
#ifndef _DEBUG
sprintf(_PluginInfo->Name, "nJoy v"INPUT_VERSION " by Falcon4ever");
#else
sprintf(_PluginInfo->Name, "nJoy v"INPUT_VERSION" (Debug) by Falcon4ever");
#endif
}
// Call about dialog
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
void DllAbout(HWND _hParent)
{
OpenAbout(nJoy_hInst, _hParent);
}
// Call config dialog
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
void DllConfig(HWND _hParent)
{
if(SDL_Init(SDL_INIT_JOYSTICK ) < 0)
{
MessageBox(NULL, SDL_GetError(), "Could not initialize SDL!", MB_ICONERROR);
return;
}
LoadConfig();
if(OpenConfig(nJoy_hInst, _hParent))
SaveConfig();
}
// Init PAD (start emulation)
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
void PAD_Initialize(SPADInitialize _PADInitialize)
{
emulator_running = TRUE;
#ifdef _DEBUG
DEBUG_INIT();
#endif
if(SDL_Init(SDL_INIT_JOYSTICK ) < 0)
{
MessageBox(NULL, SDL_GetError(), "Could not initialize SDL!", MB_ICONERROR);
return;
}
LoadConfig(); // Load joystick mapping
if(joysticks[0].enabled)
joystate[0].joy = SDL_JoystickOpen(joysticks[0].ID);
if(joysticks[1].enabled)
joystate[1].joy = SDL_JoystickOpen(joysticks[1].ID);
if(joysticks[2].enabled)
joystate[2].joy = SDL_JoystickOpen(joysticks[2].ID);
if(joysticks[3].enabled)
joystate[3].joy = SDL_JoystickOpen(joysticks[3].ID);
}
// Shutdown PAD (stop emulation)
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
void PAD_Shutdown()
{
if(joysticks[0].enabled)
SDL_JoystickClose(joystate[0].joy);
if(joysticks[1].enabled)
SDL_JoystickClose(joystate[1].joy);
if(joysticks[2].enabled)
SDL_JoystickClose(joystate[2].joy);
if(joysticks[3].enabled)
SDL_JoystickClose(joystate[3].joy);
SDL_Quit();
#ifdef _DEBUG
DEBUG_QUIT();
#endif
delete [] joyinfo;
emulator_running = FALSE;
}
// Set PAD status
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯
void PAD_GetStatus(BYTE _numPAD, SPADStatus* _pPADStatus)
{
if(!joysticks[_numPAD].enabled)
return;
// clear pad status
memset(_pPADStatus, 0, sizeof(SPADStatus));
// get pad status
GetJoyState(_numPAD);
// Reset!
int base = 0x80;
_pPADStatus->stickY = base;
_pPADStatus->stickX = base;
_pPADStatus->substickX = base;
_pPADStatus->substickY = base;
_pPADStatus->button |= PAD_USE_ORIGIN;
// Set analog controllers
// Set Deadzones perhaps out of function
int deadzone = ((float)(128.00/100.00)) * (float)(joysticks[_numPAD].deadzone+1);
int deadzone2 = ((float)(-128.00/100.00)) * (float)(joysticks[_numPAD].deadzone+1);
// Adjust range
// The value returned by SDL_JoystickGetAxis is a signed integer (-32768 to 32768)
// The value used for the gamecube controller is an unsigned char (0 to 255)
int main_stick_x = (joystate[_numPAD].axis[CTL_MAIN_X]>>8);
int main_stick_y = (joystate[_numPAD].axis[CTL_MAIN_Y]>>8);
int sub_stick_x = (joystate[_numPAD].axis[CTL_SUB_X]>>8);
int sub_stick_y = (joystate[_numPAD].axis[CTL_SUB_Y]>>8);
// Quick fix
if(main_stick_x > 127)
main_stick_x = 127;
if(main_stick_y > 127)
main_stick_y = 127;
if(sub_stick_x > 127)
sub_stick_x = 127;
if(sub_stick_y > 127)
sub_stick_y = 127;
if(main_stick_x < -128)
main_stick_x = -128;
if(main_stick_y < -128)
main_stick_y = -128;
if(sub_stick_x < -128)
sub_stick_x = -128;
if(sub_stick_y < -128)
sub_stick_y = -128;
// Send values to Dolpin
if ((main_stick_x < deadzone2) || (main_stick_x > deadzone)) _pPADStatus->stickX += main_stick_x;
if ((main_stick_y < deadzone2) || (main_stick_y > deadzone)) _pPADStatus->stickY -= main_stick_y;
if ((sub_stick_x < deadzone2) || (sub_stick_x > deadzone)) _pPADStatus->substickX += sub_stick_x;
if ((sub_stick_y < deadzone2) || (sub_stick_y > deadzone)) _pPADStatus->substickY -= sub_stick_y;
// Set buttons
if (joystate[_numPAD].buttons[CTL_L_SHOULDER]) _pPADStatus->button|=PAD_TRIGGER_L;
if (joystate[_numPAD].buttons[CTL_R_SHOULDER]) _pPADStatus->button|=PAD_TRIGGER_R;
if (joystate[_numPAD].buttons[CTL_A_BUTTON]) _pPADStatus->button|=PAD_BUTTON_A;
if (joystate[_numPAD].buttons[CTL_B_BUTTON]) _pPADStatus->button|=PAD_BUTTON_B;
if (joystate[_numPAD].buttons[CTL_X_BUTTON]) _pPADStatus->button|=PAD_BUTTON_X;
if (joystate[_numPAD].buttons[CTL_Y_BUTTON]) _pPADStatus->button|=PAD_BUTTON_Y;
if (joystate[_numPAD].buttons[CTL_Z_TRIGGER]) _pPADStatus->button|=PAD_TRIGGER_Z;
if (joystate[_numPAD].buttons[CTL_START]) _pPADStatus->button|=PAD_BUTTON_START;
// Set D-pad
if(joystate[_numPAD].dpad == SDL_HAT_LEFTUP || joystate[_numPAD].dpad == SDL_HAT_UP || joystate[_numPAD].dpad == SDL_HAT_RIGHTUP ) _pPADStatus->button|=PAD_BUTTON_UP;
if(joystate[_numPAD].dpad == SDL_HAT_LEFTUP || joystate[_numPAD].dpad == SDL_HAT_LEFT || joystate[_numPAD].dpad == SDL_HAT_LEFTDOWN ) _pPADStatus->button|=PAD_BUTTON_LEFT;
if(joystate[_numPAD].dpad == SDL_HAT_LEFTDOWN || joystate[_numPAD].dpad == SDL_HAT_DOWN || joystate[_numPAD].dpad == SDL_HAT_RIGHTDOWN ) _pPADStatus->button|=PAD_BUTTON_DOWN;
if(joystate[_numPAD].dpad == SDL_HAT_RIGHTUP || joystate[_numPAD].dpad == SDL_HAT_RIGHT || joystate[_numPAD].dpad == SDL_HAT_RIGHTDOWN ) _pPADStatus->button|=PAD_BUTTON_RIGHT;
_pPADStatus->err = PAD_ERR_NONE;
}
// Set PAD rumble
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯
void PAD_Rumble(BYTE _numPAD, unsigned int _uType, unsigned int _uStrength)
{
// not supported by SDL
}
// Set PAD attached pads
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
unsigned int PAD_GetAttachedPads()
{
unsigned int connected = 0;
LoadConfig();
if(joysticks[0].enabled)
connected |= 1;
if(joysticks[1].enabled)
connected |= 2;
if(joysticks[2].enabled)
connected |= 4;
if(joysticks[3].enabled)
connected |= 8;
return connected;
}
// Savestates
// ¯¯¯¯¯¯¯¯¯¯
unsigned int SaveLoadState(char *ptr, BOOL save)
{
// not used
return 0;
}
//////////////////////////////////////////////////////////////////////////////////////////
// Custom Functions
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
// Request joystick state
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
void GetJoyState(int controller)
{
SDL_JoystickUpdate();
joystate[controller].axis[CTL_MAIN_X] = SDL_JoystickGetAxis(joystate[controller].joy, joysticks[controller].axis[CTL_MAIN_X]);
joystate[controller].axis[CTL_MAIN_Y] = SDL_JoystickGetAxis(joystate[controller].joy, joysticks[controller].axis[CTL_MAIN_Y]);
joystate[controller].axis[CTL_SUB_X] = SDL_JoystickGetAxis(joystate[controller].joy, joysticks[controller].axis[CTL_SUB_X]);
joystate[controller].axis[CTL_SUB_Y] = SDL_JoystickGetAxis(joystate[controller].joy, joysticks[controller].axis[CTL_SUB_Y]);
joystate[controller].buttons[CTL_L_SHOULDER] = SDL_JoystickGetButton(joystate[controller].joy, joysticks[controller].buttons[CTL_L_SHOULDER]);
joystate[controller].buttons[CTL_R_SHOULDER] = SDL_JoystickGetButton(joystate[controller].joy, joysticks[controller].buttons[CTL_R_SHOULDER]);
joystate[controller].buttons[CTL_A_BUTTON] = SDL_JoystickGetButton(joystate[controller].joy, joysticks[controller].buttons[CTL_A_BUTTON]);
joystate[controller].buttons[CTL_B_BUTTON] = SDL_JoystickGetButton(joystate[controller].joy, joysticks[controller].buttons[CTL_B_BUTTON]);
joystate[controller].buttons[CTL_X_BUTTON] = SDL_JoystickGetButton(joystate[controller].joy, joysticks[controller].buttons[CTL_X_BUTTON]);
joystate[controller].buttons[CTL_Y_BUTTON] = SDL_JoystickGetButton(joystate[controller].joy, joysticks[controller].buttons[CTL_Y_BUTTON]);
joystate[controller].buttons[CTL_Z_TRIGGER] = SDL_JoystickGetButton(joystate[controller].joy, joysticks[controller].buttons[CTL_Z_TRIGGER]);
joystate[controller].buttons[CTL_START] = SDL_JoystickGetButton(joystate[controller].joy, joysticks[controller].buttons[CTL_START]);
joystate[controller].dpad = SDL_JoystickGetHat(joystate[controller].joy, joysticks[controller].dpad);
}
// Search attached devices
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
int Search_Devices()
{
// load config
#ifdef _DEBUG
DEBUG_INIT();
#endif
int numjoy = SDL_NumJoysticks();
if(numjoy == 0)
{
MessageBox(NULL, "No Joystick detected!", NULL, MB_ICONWARNING);
return 0;
}
if(joyinfo)
{
delete [] joyinfo;
joyinfo = new CONTROLLER_INFO [numjoy];
}
else
{
joyinfo = new CONTROLLER_INFO [numjoy];
}
#ifdef _DEBUG
fprintf(pFile, "Scanning for devices\n");
fprintf(pFile, "¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯\n");
#endif
for(int i = 0; i < numjoy; i++ )
{
joyinfo[i].joy = SDL_JoystickOpen(i);
joyinfo[i].ID = i;
joyinfo[i].NumAxes = SDL_JoystickNumAxes(joyinfo[i].joy);
joyinfo[i].NumButtons = SDL_JoystickNumButtons(joyinfo[i].joy);
joyinfo[i].NumBalls = SDL_JoystickNumBalls(joyinfo[i].joy);
joyinfo[i].NumHats = SDL_JoystickNumHats(joyinfo[i].joy);
joyinfo[i].Name = SDL_JoystickName(i);
#ifdef _DEBUG
fprintf(pFile, "ID: %d\n", i);
fprintf(pFile, "Name: %s\n", joyinfo[i].Name);
fprintf(pFile, "Buttons: %d\n", joyinfo[i].NumButtons);
fprintf(pFile, "Axes: %d\n", joyinfo[i].NumAxes);
fprintf(pFile, "Hats: %d\n", joyinfo[i].NumHats);
fprintf(pFile, "Balls: %d\n\n", joyinfo[i].NumBalls);
#endif
// Close if opened
if(SDL_JoystickOpened(i))
SDL_JoystickClose(joyinfo[i].joy);
}
return numjoy;
}
// Enable output log
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
void DEBUG_INIT()
{
if(pFile)
return;
char dateStr [9];
_strdate( dateStr);
char timeStr [9];
_strtime( timeStr );
pFile = fopen ("nJoy-debug.txt","wt");
fprintf(pFile, "nJoy v"INPUT_VERSION" Debug\n");
fprintf(pFile, "Date: %s\nTime: %s\n", dateStr, timeStr);
fprintf(pFile, "¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯\n");
}
// Disable output log
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
void DEBUG_QUIT()
{
if(!pFile)
return;
char timeStr [9];
_strtime(timeStr);
fprintf(pFile, "_______________\n");
fprintf(pFile, "Time: %s", timeStr);
fclose(pFile);
}
// Save settings to file
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
void SaveConfig()
{
IniFile file;
file.Load("nJoy");
for (int i=0; i<4; i++)
{
char SectionName[32];
sprintf(SectionName, "PAD%i", i+1);
file.Set(SectionName, "l_shoulder", joysticks[i].buttons[CTL_L_SHOULDER]);
file.Set(SectionName, "r_shoulder", joysticks[i].buttons[CTL_R_SHOULDER]);
file.Set(SectionName, "a_button", joysticks[i].buttons[CTL_A_BUTTON]);
file.Set(SectionName, "b_button", joysticks[i].buttons[CTL_B_BUTTON]);
file.Set(SectionName, "x_button", joysticks[i].buttons[CTL_X_BUTTON]);
file.Set(SectionName, "y_button", joysticks[i].buttons[CTL_Y_BUTTON]);
file.Set(SectionName, "z_trigger", joysticks[i].buttons[CTL_Z_TRIGGER]);
file.Set(SectionName, "start_button", joysticks[i].buttons[CTL_START]);
file.Set(SectionName, "dpad", joysticks[i].dpad);
file.Set(SectionName, "main_x", joysticks[i].axis[CTL_MAIN_X]);
file.Set(SectionName, "main_y", joysticks[i].axis[CTL_MAIN_Y]);
file.Set(SectionName, "sub_x", joysticks[i].axis[CTL_SUB_X]);
file.Set(SectionName, "sub_y", joysticks[i].axis[CTL_SUB_Y]);
file.Set(SectionName, "enabled", joysticks[i].enabled);
file.Set(SectionName, "deadzone", joysticks[i].deadzone);
file.Set(SectionName, "halfpress", joysticks[i].halfpress);
file.Set(SectionName, "joy_id", joysticks[i].ID);
}
file.Save("nJoy");
}
// Load settings from file
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
void LoadConfig()
{
IniFile file;
file.Load("nJoy");
for (int i=0; i<4; i++)
{
char SectionName[32];
sprintf(SectionName, "PAD%i", i+1);
file.Get(SectionName, "l_shoulder", &joysticks[i].buttons[CTL_L_SHOULDER], 4);
file.Get(SectionName, "r_shoulder", &joysticks[i].buttons[CTL_R_SHOULDER], 5);
file.Get(SectionName, "a_button", &joysticks[i].buttons[CTL_A_BUTTON], 0);
file.Get(SectionName, "b_button", &joysticks[i].buttons[CTL_B_BUTTON], 1);
file.Get(SectionName, "x_button", &joysticks[i].buttons[CTL_X_BUTTON], 3);
file.Get(SectionName, "y_button", &joysticks[i].buttons[CTL_Y_BUTTON], 2);
file.Get(SectionName, "z_trigger", &joysticks[i].buttons[CTL_Z_TRIGGER], 7);
file.Get(SectionName, "start_button", &joysticks[i].buttons[CTL_START], 9);
file.Get(SectionName, "dpad", &joysticks[i].dpad, 0);
file.Get(SectionName, "main_x", &joysticks[i].axis[CTL_MAIN_X], 0);
file.Get(SectionName, "main_y", &joysticks[i].axis[CTL_MAIN_Y], 1);
file.Get(SectionName, "sub_x", &joysticks[i].axis[CTL_SUB_X], 2);
file.Get(SectionName, "sub_y", &joysticks[i].axis[CTL_SUB_Y], 3);
file.Get(SectionName, "enabled", &joysticks[i].enabled, 1);
file.Get(SectionName, "deadzone", &joysticks[i].deadzone, 9);
file.Get(SectionName, "halfpress", &joysticks[i].halfpress, 0);
file.Get(SectionName, "joy_id", &joysticks[i].ID, 0);
}
}
+116
View File
@@ -0,0 +1,116 @@
//////////////////////////////////////////////////////////////////////////////////////////
// Project description
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
// Name: nJoy
// Description: A Dolphin Compatible Input Plugin
//
// Author: Falcon4ever (nJoy@falcon4ever.com)
// Site: www.multigesture.net
// Copyright (C) 2003-2008 Dolphin Project.
//
//////////////////////////////////////////////////////////////////////////////////////////
//
// Licensetype: GNU General Public License (GPL)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
//
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
//
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
//
//////////////////////////////////////////////////////////////////////////////////////////
#define _CRT_SECURE_NO_WARNINGS
#define WIN32_LEAN_AND_MEAN
#include <tchar.h>
#include <vector>
#include <stdio.h>
#include <time.h>
#include <SDL.h> // includes SDL
#include "pluginspecs_pad.h"
#include "config.h"
#include "IniFile.h"
#pragma comment(lib, "SDL.lib")
// #pragma comment(lib, "SDLmain.lib")
//////////////////////////////////////////////////////////////////////////////////////////
// Define
// ¯¯¯¯¯¯
#define INPUT_VERSION "0.3"
#define INPUT_STATE "PUBLIC RELEASE"
#define RELDAY "21"
#define RELMONTH "07"
#define RELYEAR "2008"
#define THANKYOU "`plot`, Absolute0, Aprentice, Bositman, Brice, ChaosCode, CKemu, CoDeX, Dave2001, dn, drk||Raziel, Florin, Gent, Gigaherz, Hacktarux, JegHegy, Linker, Linuzappz, Martin64, Muad, Knuckles, Raziel, Refraction, Rudy_x, Shadowprince, Snake785, Saqib, vEX, yaz0r, Zilmar, Zenogais and ZeZu."
struct CONTROLLER_STATE{ // GC PAD INFO/STATE
int buttons[8]; // Amount of buttons (A B X Y Z, L-Trigger R-Trigger Start) might need to change the triggers buttons
int dpad; // 1 HAT (8 directions + neutral)
int axis[4]; // 2 x 2 Axes (Main & Sub)
SDL_Joystick *joy; // SDL joystick device
};
struct CONTROLLER_MAPPING{ // GC PAD MAPPING
int buttons[8]; // Amount of buttons (A B X Y Z, L-Trigger R-Trigger Start) might need to change the triggers buttons
int dpad; // 1 HAT (8 directions + neutral)
int axis[4]; // 2 x 2 Axes (Main & Sub)
int enabled; // Pad attached?
int deadzone; // Deadzone... what else?
int halfpress; // Not implemented
int ID; // SDL joystick device ID
};
struct CONTROLLER_INFO{ // CONNECTED WINDOWS DEVICES INFO
int NumAxes; // Amount of Axes
int NumButtons; // Amount of Buttons
int NumBalls; // Amount of Balls
int NumHats; // Amount of Hats (POV)
const char *Name; // Joypad/stickname
int ID; // SDL joystick device ID
SDL_Joystick *joy; // SDL joystick device
};
enum
{
CTL_MAIN_X = 0,
CTL_MAIN_Y,
CTL_SUB_X,
CTL_SUB_Y,
};
enum
{
CTL_L_SHOULDER = 0,
CTL_R_SHOULDER,
CTL_A_BUTTON,
CTL_B_BUTTON,
CTL_X_BUTTON,
CTL_Y_BUTTON,
CTL_Z_TRIGGER,
CTL_START
};
//////////////////////////////////////////////////////////////////////////////////////////
// Custom Functions
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
void GetJoyState(int controller);
int Search_Devices();
void DEBUG_INIT();
void DEBUG_QUIT();
void SaveConfig();
void LoadConfig();
+115
View File
@@ -0,0 +1,115 @@
nJoy v0.3 by Falcon4ever 2008
A Dolphin Compatible Input Plugin
Copyright (C) 2003-2008 Dolphin Project.
Changelog
==========================================================================
0.3: 3nd version of nJoy
- Release: July 2008
- Support for four players
- Misc. improvements
0.2: 2nd version of nJoy
- Release: 14th July 2005
- Now using SDL instead of DirectInput9
- Config/INI support
- Adjustable deadzone
- First public release
0.1: First version of nJoy
- Private Release: january 2005
- Using DirectInput9
- Specially made for the Logitech Rumblepad 2, but other joypads work too
- Advanced debug window, activated during gameplay
- No deadzone configurable
- No config/Ini
The Author
==========================================================================
* Falcon4ever (nJoy@falcon4ever.com)
System and Software Requirements
==========================================================================
Dolphin
The latest Dolphin release, avaible at www.dolphin-emu.com
SDL.dll (SDL-1.2.13)
(included with this release)
latest version avaible at www.libsdl.org
A Joystick
A Windows 9x compatible input device
Plugin Information
==========================================================================
nJoy was written in C++, compiled with Microsoft Visual Studio 2005 Professional Edition.
nJoy uses SDL for joysticks, mouse and keyboard.
For the graphical interface plain Win32 code was used.
How to install
==========================================================================
Just unzip the content of the zipfile to your dolphin plugin dir and place
sdl.dll in the root dir.
example config:
[C:]
|
+-Dolphin Dir
+-DolphinWx.exe File
+-SDL.dll File
|
+-Plugins Dir
+-nJoy.dll File
FAQ
==========================================================================
What's SDL???
SDL is the Simple DirectMedia Layer written by Sam Lantinga.
It provides an API for audio, video, input ...
For more information go to http://www.libsdl.org/
Where can I download the latest releases???
nJoy will be released @ www.multigesture.net
Can I mirror this file???
Sure, just don't forget to add a link to:
www.multigesture.net OR www.dolphin-emu.com
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Why should I use nJoy instead of the default input plugin???
At this moment the default plugin only supports keyboard input.
nJoy supports Joysticks. And besides that, if you have an GC-adapter
you can use your original GC controllers with dolphin !
Could you add [insert feature here] please???
no.
But perhaps...
NO!
Hmm... There is coming smoke out of my pc, wtf?
err, this plugin comes without any warranty,
use it at own risk :)
What should I do if my question isn't listed here???
Just panic, call 911 or leave a message on:
(1) Emutalk http://www.emutalk.net/forumdisplay.php?f=100
(2) NGemu http://forums.ngemu.com/dolphin-discussion/
Thanks / Greetings
==========================================================================
Special Thanks too:
F|RES & ector
Greetings too:
`plot`, Absolute0, Aprentice, Bositman, Brice, ChaosCode, CKemu,
CoDeX, Dave2001, dn, drk||Raziel, Florin, Gent, Gigaherz, Hacktarux,
icepir8, JegHegy, Linker, Linuzappz, Martin64, Muad, Knuckles, Raziel,
Refraction, Rudy_x, Shadowprince, Snake785, Saqib, vEX, yaz0r,
Zilmar, Zenogais and ZeZu.
AAaannd everyone else I forgot ;)...