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

View File

@ -0,0 +1,520 @@
//////////////////////////////////////////////////////////////////////////////////////////
// Project description
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// 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"
extern CONTROLLER_INFO *joyinfo;
extern CONTROLLER_MAPPING joysticks[4];
extern bool emulator_running;
// Create dialog and pages
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int OpenConfig(HINSTANCE hInst, HWND _hParent)
{
PROPSHEETPAGE psp[4];
PROPSHEETHEADER psh;
psp[0].dwSize = sizeof(PROPSHEETPAGE);
psp[0].dwFlags = PSP_USETITLE;
psp[0].hInstance = hInst;
psp[0].pszTemplate = MAKEINTRESOURCE(IDD_CONFIG);
psp[0].pszIcon = NULL;
psp[0].pfnDlgProc = (DLGPROC)ControllerTab1;
psp[0].pszTitle = "Controller 1";
psp[0].lParam = 0;
psp[1].dwSize = sizeof(PROPSHEETPAGE);
psp[1].dwFlags = PSP_USETITLE;
psp[1].hInstance = hInst;
psp[1].pszTemplate = MAKEINTRESOURCE(IDD_CONFIG);
psp[1].pszIcon = NULL;
psp[1].pfnDlgProc = (DLGPROC)ControllerTab2;
psp[1].pszTitle = "Controller 2";
psp[1].lParam = 0;
psp[2].dwSize = sizeof(PROPSHEETPAGE);
psp[2].dwFlags = PSP_USETITLE;
psp[2].hInstance = hInst;
psp[2].pszTemplate = MAKEINTRESOURCE(IDD_CONFIG);
psp[2].pszIcon = NULL;
psp[2].pfnDlgProc = (DLGPROC)ControllerTab3;
psp[2].pszTitle = "Controller 3";
psp[2].lParam = 0;
psp[3].dwSize = sizeof(PROPSHEETPAGE);
psp[3].dwFlags = PSP_USETITLE;
psp[3].hInstance = hInst;
psp[3].pszTemplate = MAKEINTRESOURCE(IDD_CONFIG);
psp[3].pszIcon = NULL;
psp[3].pfnDlgProc = (DLGPROC)ControllerTab4;
psp[3].pszTitle = "Controller 4";
psp[3].lParam = 0;
psh.dwSize = sizeof(PROPSHEETHEADER);
psh.dwFlags = PSH_PROPSHEETPAGE | PSH_NOAPPLYNOW | PSH_NOCONTEXTHELP;
psh.hwndParent = _hParent;
psh.hInstance = hInst;
psh.pszIcon = NULL;
#ifndef _DEBUG
psh.pszCaption = (LPSTR) "Configure: nJoy v"INPUT_VERSION " Input Plugin";
#else
psh.pszCaption = (LPSTR) "Configure: nJoy v"INPUT_VERSION " (Debug) Input Plugin";
#endif
psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE);
psh.ppsp = (LPCPROPSHEETPAGE) &psp;
return (int)(PropertySheet(&psh));
}
// Create Tab
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
BOOL APIENTRY ControllerTab1(HWND hDlg, UINT message, UINT wParam, LONG lParam)
{
return ControllerTab(hDlg, message, wParam, lParam, 0);
}
BOOL APIENTRY ControllerTab2(HWND hDlg, UINT message, UINT wParam, LONG lParam)
{
return ControllerTab(hDlg, message, wParam, lParam, 1);
}
BOOL APIENTRY ControllerTab3(HWND hDlg, UINT message, UINT wParam, LONG lParam)
{
return ControllerTab(hDlg, message, wParam, lParam, 2);
}
BOOL APIENTRY ControllerTab4(HWND hDlg, UINT message, UINT wParam, LONG lParam)
{
return ControllerTab(hDlg, message, wParam, lParam, 3);
}
// Create Controller Tab
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
BOOL ControllerTab(HWND hDlg, UINT message, UINT wParam, LONG lParam, int controller)
{
switch (message)
{
case WM_INITDIALOG:
// Prevent user from changing the joystick while emulation is running
if(emulator_running)
{
ComboBox_Enable(GetDlgItem(hDlg, IDC_JOYNAME), FALSE);
Button_Enable(GetDlgItem(hDlg, IDC_JOYATTACH), FALSE);
}
else
{
ComboBox_Enable(GetDlgItem(hDlg, IDC_JOYNAME), TRUE);
Button_Enable(GetDlgItem(hDlg, IDC_JOYATTACH), TRUE);
}
// Search for devices and add the to the device list
if(Search_Devices())
{
HWND CB = GetDlgItem(hDlg, IDC_JOYNAME);
for(int x = 0; x < SDL_NumJoysticks(); x++)
{
SendMessage(CB, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>((LPCTSTR)joyinfo[x].Name));
}
char buffer [8];
CB = GetDlgItem(hDlg, IDC_DEADZONE);
SendMessage(CB, CB_RESETCONTENT, 0, 0);
for(int x = 1; x <= 100; x++)
{
sprintf (buffer, "%d %%", x);
SendMessage(CB, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>((LPCTSTR)buffer));
}
SetControllerAll(hDlg, controller);
return TRUE;
}
else
{
HWND CB = GetDlgItem(hDlg, IDC_JOYNAME);
SendMessage(CB, CB_ADDSTRING, 0, (LPARAM)"No Joystick detected!");
SendMessage(CB, CB_SETCURSEL, 0, 0);
return FALSE;
}
break;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDC_JOYNAME:
{
// Selected a different joystick
if(HIWORD(wParam) == CBN_SELCHANGE)
{
joysticks[controller].ID = (int)SendMessage(GetDlgItem(hDlg, IDC_JOYNAME), CB_GETCURSEL, 0, 0);
}
return TRUE;
}
break;
case IDC_SHOULDERL:
case IDC_SHOULDERR:
case IDC_A:
case IDC_B:
case IDC_X:
case IDC_Y:
case IDC_Z:
case IDC_START:
{
GetButtons(hDlg, LOWORD(wParam), controller);
return TRUE;
}
break;
case IDC_DPAD:
{
GetHats(hDlg, LOWORD(wParam), controller);
return TRUE;
}
break;
case IDC_SX:
case IDC_SY:
case IDC_MX:
case IDC_MY:
{
GetAxis(hDlg, LOWORD(wParam), controller);
return TRUE;
}
break;
}
break;
case WM_DESTROY:
GetControllerAll(hDlg, controller);
break;
}
return FALSE;
}
// Wait for button press
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
bool GetButtons(HWND hDlg, int buttonid, int controller)
{
buttonid += 1000;
SDL_Joystick *joy;
joy=SDL_JoystickOpen(joysticks[controller].ID);
char format[128];
int buttons = SDL_JoystickNumButtons(joy);
bool waiting = true;
bool succeed = false;
int pressed = 0;
int counter1 = 0;
int counter2 = 10;
sprintf(format, "[%d]", counter2);
SetDlgItemText(hDlg, buttonid, format);
while(waiting)
{
SDL_JoystickUpdate();
for(int b = 0; b < buttons; b++)
{
if(SDL_JoystickGetButton(joy, b))
{
pressed = b;
waiting = false;
succeed = true;
break;
}
}
counter1++;
if(counter1==100)
{
counter1=0;
counter2--;
sprintf(format, "[%d]", counter2);
SetDlgItemText(hDlg, buttonid, format);
if(counter2<0)
waiting = false;
}
Sleep(10);
}
if(succeed)
sprintf(format, "%d", pressed);
else
sprintf(format, "-1", pressed);
SetDlgItemText(hDlg, buttonid, format);
if(SDL_JoystickOpened(joysticks[controller].ID))
SDL_JoystickClose(joy);
return true;
}
// Wait for D-Pad
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
bool GetHats(HWND hDlg, int buttonid, int controller)
{
buttonid += 1000;
SDL_Joystick *joy;
joy=SDL_JoystickOpen(joysticks[controller].ID);
char format[128];
int hats = SDL_JoystickNumHats(joy);
bool waiting = true;
bool succeed = false;
int pressed = 0;
int counter1 = 0;
int counter2 = 10;
sprintf(format, "[%d]", counter2);
SetDlgItemText(hDlg, buttonid, format);
while(waiting)
{
SDL_JoystickUpdate();
for(int b = 0; b < hats; b++)
{
if(SDL_JoystickGetHat(joy, b))
{
pressed = b;
waiting = false;
succeed = true;
break;
}
}
counter1++;
if(counter1==100)
{
counter1=0;
counter2--;
sprintf(format, "[%d]", counter2);
SetDlgItemText(hDlg, buttonid, format);
if(counter2<0)
waiting = false;
}
Sleep(10);
}
if(succeed)
sprintf(format, "%d", pressed);
else
sprintf(format, "-1", pressed);
SetDlgItemText(hDlg, buttonid, format);
if(SDL_JoystickOpened(joysticks[controller].ID))
SDL_JoystickClose(joy);
return true;
}
// Wait for Analog
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
bool GetAxis(HWND hDlg, int buttonid, int controller)
{
buttonid += 1000;
SDL_Joystick *joy;
joy=SDL_JoystickOpen(joysticks[controller].ID);
char format[128];
int axes = SDL_JoystickNumAxes(joy);
bool waiting = true;
bool succeed = false;
int pressed = 0;
Sint16 value;
int counter1 = 0;
int counter2 = 10;
sprintf(format, "[%d]", counter2);
SetDlgItemText(hDlg, buttonid, format);
while(waiting)
{
SDL_JoystickUpdate();
for(int b = 0; b < axes; b++)
{
value = SDL_JoystickGetAxis(joy, b);
if(value < -10000 || value > 10000)
{
pressed = b;
waiting = false;
succeed = true;
break;
}
}
counter1++;
if(counter1==100)
{
counter1=0;
counter2--;
sprintf(format, "[%d]", counter2);
SetDlgItemText(hDlg, buttonid, format);
if(counter2<0)
waiting = false;
}
Sleep(10);
}
if(succeed)
sprintf(format, "%d", pressed);
else
sprintf(format, "-1", pressed);
SetDlgItemText(hDlg, buttonid, format);
if(SDL_JoystickOpened(joysticks[controller].ID))
SDL_JoystickClose(joy);
return true;
}
// Set dialog items
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void SetControllerAll(HWND hDlg, int controller)
{
SendMessage(GetDlgItem(hDlg, IDC_JOYNAME), CB_SETCURSEL, joysticks[controller].ID, 0);
SetButton(hDlg, IDTEXT_SHOULDERL, joysticks[controller].buttons[CTL_L_SHOULDER]);
SetButton(hDlg, IDTEXT_SHOULDERR, joysticks[controller].buttons[CTL_R_SHOULDER]);
SetButton(hDlg, IDTEXT_A, joysticks[controller].buttons[CTL_A_BUTTON]);
SetButton(hDlg, IDTEXT_B, joysticks[controller].buttons[CTL_B_BUTTON]);
SetButton(hDlg, IDTEXT_X, joysticks[controller].buttons[CTL_X_BUTTON]);
SetButton(hDlg, IDTEXT_Y, joysticks[controller].buttons[CTL_Y_BUTTON]);
SetButton(hDlg, IDTEXT_Z, joysticks[controller].buttons[CTL_Z_TRIGGER]);
SetButton(hDlg, IDTEXT_START, joysticks[controller].buttons[CTL_START]);
SetButton(hDlg, IDTEXT_DPAD, joysticks[controller].dpad);
SetButton(hDlg, IDTEXT_MX, joysticks[controller].axis[CTL_MAIN_X]);
SetButton(hDlg, IDTEXT_MY, joysticks[controller].axis[CTL_MAIN_Y]);
SetButton(hDlg, IDTEXT_SX, joysticks[controller].axis[CTL_SUB_X]);
SetButton(hDlg, IDTEXT_SY, joysticks[controller].axis[CTL_SUB_Y]);
SendDlgItemMessage(hDlg, IDC_JOYATTACH, BM_SETCHECK, joysticks[controller].enabled, 0);
SendMessage(GetDlgItem(hDlg, IDC_DEADZONE), CB_SETCURSEL, joysticks[controller].deadzone, 0);
}
// Get dialog items
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void GetControllerAll(HWND hDlg, int controller)
{
joysticks[controller].ID = (int)SendMessage(GetDlgItem(hDlg, IDC_JOYNAME), CB_GETCURSEL, 0, 0);
joysticks[controller].buttons[CTL_L_SHOULDER] = GetButton(hDlg, IDTEXT_SHOULDERL);
joysticks[controller].buttons[CTL_R_SHOULDER] = GetButton(hDlg, IDTEXT_SHOULDERR);
joysticks[controller].buttons[CTL_A_BUTTON] = GetButton(hDlg, IDTEXT_A);
joysticks[controller].buttons[CTL_B_BUTTON] = GetButton(hDlg, IDTEXT_B);
joysticks[controller].buttons[CTL_X_BUTTON] = GetButton(hDlg, IDTEXT_X);
joysticks[controller].buttons[CTL_Y_BUTTON] = GetButton(hDlg, IDTEXT_Y);
joysticks[controller].buttons[CTL_Z_TRIGGER] = GetButton(hDlg, IDTEXT_Z);
joysticks[controller].buttons[CTL_START] = GetButton(hDlg, IDTEXT_START);
joysticks[controller].dpad = GetButton(hDlg, IDTEXT_DPAD);
joysticks[controller].axis[CTL_MAIN_X] = GetButton(hDlg, IDTEXT_MX);
joysticks[controller].axis[CTL_MAIN_Y] = GetButton(hDlg, IDTEXT_MY);
joysticks[controller].axis[CTL_SUB_X] = GetButton(hDlg, IDTEXT_SX);
joysticks[controller].axis[CTL_SUB_Y] = GetButton(hDlg, IDTEXT_SY);
joysticks[controller].enabled = (int)SendMessage(GetDlgItem(hDlg, IDC_JOYATTACH), BM_GETCHECK, 0, 0);
joysticks[controller].deadzone = (int)SendMessage(GetDlgItem(hDlg, IDC_DEADZONE), CB_GETCURSEL, 0, 0);
}
// Set text in static text item
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void SetButton(HWND hDlg, int item, int value)
{
char format[8];
sprintf(format, "%d", value);
SetDlgItemText(hDlg, item, format);
}
// Get text from static text item
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int GetButton(HWND hDlg, int item)
{
char format[8];
GetDlgItemText(hDlg, item, format, sizeof(format));
return atoi(format);
}
//////////////////////////////////////////////////////////////////////////////////////////
// About dialog functions
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void OpenAbout(HINSTANCE hInst, HWND _hParent)
{
DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUT), _hParent, (DLGPROC)AboutDlg);
}
BOOL CALLBACK AboutDlg(HWND abouthWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
char format[0xFFF];
switch (message)
{
case WM_INITDIALOG:
sprintf(format,"nJoy v"INPUT_VERSION" by Falcon4ever\n"
"Release: "RELDAY"/"RELMONTH"/"RELYEAR"\n"
"www.multigesture.net");
SetDlgItemText(abouthWnd,IDC_ABOUT_TEXT,format);
sprintf(format, THANKYOU);
SetDlgItemText(abouthWnd,IDC_ABOUT_TEXT2,format);
sprintf(format, INPUT_STATE);
SetDlgItemText(abouthWnd,IDC_ABOUT_TEXT3,format);
break;
case WM_COMMAND:
if (LOWORD(wParam) == IDOK)
{
EndDialog(abouthWnd, LOWORD(wParam));
return TRUE;
}
break;
}
return FALSE;
}

View File

@ -0,0 +1,67 @@
//////////////////////////////////////////////////////////////////////////////////////////
// Project description
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// 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
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
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
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void OpenAbout(HINSTANCE hInst, HWND _hParent);
BOOL CALLBACK AboutDlg(HWND abouthWnd, UINT message, WPARAM wParam, LPARAM lParam);

View File

@ -0,0 +1,445 @@
//////////////////////////////////////////////////////////////////////////////////////////
// Project description
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// 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
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
FILE *pFile;
HINSTANCE nJoy_hInst = NULL;
CONTROLLER_INFO *joyinfo = 0;
CONTROLLER_STATE joystate[4];
CONTROLLER_MAPPING joysticks[4];
bool emulator_running = FALSE;
//////////////////////////////////////////////////////////////////////////////////////////
// DllMain
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
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)
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// Get properties of plugin
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
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
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void DllAbout(HWND _hParent)
{
OpenAbout(nJoy_hInst, _hParent);
}
// Call config dialog
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
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)
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
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)
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
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
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
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
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void PAD_Rumble(BYTE _numPAD, unsigned int _uType, unsigned int _uStrength)
{
// not supported by SDL
}
// Set PAD attached pads
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
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
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
unsigned int SaveLoadState(char *ptr, BOOL save)
{
// not used
return 0;
}
//////////////////////////////////////////////////////////////////////////////////////////
// Custom Functions
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// Request joystick state
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
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
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
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, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\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
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
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, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
}
// Disable output log
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
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
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
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
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
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);
}
}

View File

@ -0,0 +1,116 @@
//////////////////////////////////////////////////////////////////////////////////////////
// Project description
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// 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
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#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
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void GetJoyState(int controller);
int Search_Devices();
void DEBUG_INIT();
void DEBUG_QUIT();
void SaveConfig();
void LoadConfig();