2008-12-08 04:46:09 +00:00
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// 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/
|
|
|
|
|
//
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2009-01-19 17:47:00 +00:00
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// Settings
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2008-12-08 04:46:09 +00:00
|
|
|
|
// Set this if you want to use the rumble 'hack' for controller one
|
|
|
|
|
//#define USE_RUMBLE_DINPUT_HACK
|
2009-01-19 17:47:00 +00:00
|
|
|
|
//////////////////////////
|
2008-12-08 04:46:09 +00:00
|
|
|
|
|
2009-01-19 17:47:00 +00:00
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// Includes
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2008-12-27 11:32:03 +00:00
|
|
|
|
#include <vector> // System
|
2009-01-05 22:11:08 +00:00
|
|
|
|
#include <cstdio>
|
|
|
|
|
#include <ctime>
|
|
|
|
|
#include <cmath>
|
2008-12-08 04:46:09 +00:00
|
|
|
|
#include <SDL.h>
|
|
|
|
|
|
2008-12-27 11:32:03 +00:00
|
|
|
|
#include "Common.h" // Common
|
2008-12-18 01:21:56 +00:00
|
|
|
|
#include "pluginspecs_pad.h"
|
|
|
|
|
#include "IniFile.h"
|
2009-01-22 11:18:46 +00:00
|
|
|
|
#include "ConsoleWindow.h"
|
2009-01-21 18:09:31 +00:00
|
|
|
|
//#include "Timer.h"
|
2008-12-08 04:46:09 +00:00
|
|
|
|
|
2008-12-27 11:32:03 +00:00
|
|
|
|
#include "Config.h" // Local
|
2009-01-20 14:25:33 +00:00
|
|
|
|
#include "XInput.h"
|
2008-12-27 11:32:03 +00:00
|
|
|
|
|
2008-12-14 23:52:01 +00:00
|
|
|
|
#if defined(HAVE_WX) && HAVE_WX
|
2008-12-27 11:32:03 +00:00
|
|
|
|
#include "GUI/AboutBox.h"
|
|
|
|
|
#include "GUI/ConfigBox.h"
|
|
|
|
|
//extern ConfigBox* m_frame;
|
2008-12-14 23:52:01 +00:00
|
|
|
|
#endif
|
2008-12-08 04:46:09 +00:00
|
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
2008-12-26 02:42:15 +00:00
|
|
|
|
#include <tchar.h>
|
|
|
|
|
#define DIRECTINPUT_VERSION 0x0800
|
|
|
|
|
#define WIN32_LEAN_AND_MEAN
|
|
|
|
|
|
|
|
|
|
#ifdef USE_RUMBLE_DINPUT_HACK
|
|
|
|
|
#pragma comment(lib, "dxguid.lib")
|
|
|
|
|
#pragma comment(lib, "dinput8.lib")
|
|
|
|
|
#pragma comment(lib, "winmm.lib")
|
|
|
|
|
#include <dinput.h>
|
|
|
|
|
VOID FreeDirectInput(); // Needed in both nJoy.cpp and Rumble.cpp
|
|
|
|
|
#endif
|
2008-12-18 01:21:56 +00:00
|
|
|
|
#endif // _WIN32
|
|
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
2009-01-19 17:47:00 +00:00
|
|
|
|
#define SLEEP(x) Sleep(x)
|
2008-12-18 01:21:56 +00:00
|
|
|
|
#else
|
2009-01-19 17:47:00 +00:00
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
|
#define SLEEP(x) usleep(x*1000)
|
2008-12-18 01:21:56 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef __linux__
|
|
|
|
|
#include <linux/input.h>
|
2008-12-08 04:46:09 +00:00
|
|
|
|
#endif
|
2009-01-19 17:47:00 +00:00
|
|
|
|
//////////////////////////////
|
2008-12-08 04:46:09 +00:00
|
|
|
|
|
2008-12-26 02:42:15 +00:00
|
|
|
|
|
2008-12-08 04:46:09 +00:00
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// Define
|
2009-01-19 17:47:00 +00:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2008-12-08 04:46:09 +00:00
|
|
|
|
|
|
|
|
|
#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."
|
|
|
|
|
|
2008-12-26 02:42:15 +00:00
|
|
|
|
|
2008-12-08 04:46:09 +00:00
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// Structures
|
2008-12-28 18:50:24 +00:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2009-01-24 22:13:53 +00:00
|
|
|
|
CONTROLLER_STATE buttons (PadState) = 0 or 1
|
2008-12-28 18:50:24 +00:00
|
|
|
|
CONTROLLER_MAPPING buttons (joystick) = 0 or 1, 2, 3, 4, a certain joypad button
|
2008-12-08 04:46:09 +00:00
|
|
|
|
|
2009-01-19 17:47:00 +00:00
|
|
|
|
Please remember: The axis limit is hardcoded here, if you allow more axises (for
|
|
|
|
|
example for analog A and B buttons) you must first incrase the size of the axis array
|
|
|
|
|
size here
|
|
|
|
|
*/
|
|
|
|
|
struct CONTROLLER_STATE // GC PAD INFO/STATE
|
|
|
|
|
{
|
2008-12-08 04:46:09 +00:00
|
|
|
|
int buttons[8]; // Amount of buttons (A B X Y Z, L-Trigger R-Trigger Start) might need to change the triggers buttons
|
2009-01-19 17:47:00 +00:00
|
|
|
|
int dpad; // Automatic SDL D-Pad (8 directions + neutral)
|
|
|
|
|
int dpad2[4]; // D-pad using buttons
|
|
|
|
|
int axis[6]; // 2 x 2 Axes (Main & Sub)
|
|
|
|
|
int halfpress; // Halfpress... you know, like not fully pressed ;)...
|
2008-12-08 04:46:09 +00:00
|
|
|
|
SDL_Joystick *joy; // SDL joystick device
|
|
|
|
|
};
|
|
|
|
|
|
2009-01-19 17:47:00 +00:00
|
|
|
|
struct CONTROLLER_MAPPING // GC PAD MAPPING
|
|
|
|
|
{
|
|
|
|
|
int buttons[8]; // (See above)
|
|
|
|
|
int dpad; // (See above)
|
|
|
|
|
int dpad2[4]; // (See above)
|
|
|
|
|
int axis[6]; // (See above)
|
|
|
|
|
int halfpress; // (See above)
|
2008-12-08 04:46:09 +00:00
|
|
|
|
int enabled; // Pad attached?
|
|
|
|
|
int deadzone; // Deadzone... what else?
|
|
|
|
|
int ID; // SDL joystick device ID
|
2009-01-20 05:28:30 +00:00
|
|
|
|
int controllertype; // Hat: Hat or custom buttons
|
|
|
|
|
int triggertype; // Triggers range
|
2009-01-21 18:09:31 +00:00
|
|
|
|
std::string SDiagonal;
|
|
|
|
|
bool bSquareToCircle;
|
2008-12-08 04:46:09 +00:00
|
|
|
|
int eventnum; // Linux Event Number, Can't be found dynamically yet
|
|
|
|
|
};
|
|
|
|
|
|
2009-01-19 17:47:00 +00:00
|
|
|
|
struct CONTROLLER_INFO // CONNECTED WINDOWS DEVICES INFO
|
|
|
|
|
{
|
2008-12-08 04:46:09 +00:00
|
|
|
|
int NumAxes; // Amount of Axes
|
|
|
|
|
int NumButtons; // Amount of Buttons
|
|
|
|
|
int NumBalls; // Amount of Balls
|
|
|
|
|
int NumHats; // Amount of Hats (POV)
|
2009-01-21 18:09:31 +00:00
|
|
|
|
std::string Name; // Joypad/stickname
|
2008-12-08 04:46:09 +00:00
|
|
|
|
int ID; // SDL joystick device ID
|
2009-01-24 22:13:53 +00:00
|
|
|
|
bool Good;
|
2008-12-08 04:46:09 +00:00
|
|
|
|
SDL_Joystick *joy; // SDL joystick device
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum
|
|
|
|
|
{
|
2009-01-19 17:47:00 +00:00
|
|
|
|
// CTL_L_SHOULDER and CTL_R_SHOULDER = 0 and 1
|
|
|
|
|
CTL_MAIN_X = 2,
|
2008-12-08 04:46:09 +00:00
|
|
|
|
CTL_MAIN_Y,
|
|
|
|
|
CTL_SUB_X,
|
2009-01-19 17:47:00 +00:00
|
|
|
|
CTL_SUB_Y
|
2008-12-08 04:46:09 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
};
|
|
|
|
|
|
2009-01-20 05:28:30 +00:00
|
|
|
|
// DPad Type
|
2008-12-08 04:46:09 +00:00
|
|
|
|
enum
|
|
|
|
|
{
|
2009-01-19 17:47:00 +00:00
|
|
|
|
CTL_DPAD_HAT = 0, // Automatically use the first hat that SDL finds
|
|
|
|
|
CTL_DPAD_CUSTOM // Custom directional pad settings
|
2008-12-08 04:46:09 +00:00
|
|
|
|
};
|
|
|
|
|
|
2009-01-20 05:28:30 +00:00
|
|
|
|
// Trigger Type
|
|
|
|
|
enum
|
|
|
|
|
{
|
2009-01-20 14:25:33 +00:00
|
|
|
|
CTL_TRIGGER_SDL = 0, //
|
|
|
|
|
CTL_TRIGGER_XINPUT // The XBox 360 pad
|
2009-01-20 05:28:30 +00:00
|
|
|
|
};
|
|
|
|
|
|
2008-12-08 04:46:09 +00:00
|
|
|
|
enum
|
|
|
|
|
{
|
|
|
|
|
CTL_D_PAD_UP = 0,
|
|
|
|
|
CTL_D_PAD_DOWN,
|
|
|
|
|
CTL_D_PAD_LEFT,
|
|
|
|
|
CTL_D_PAD_RIGHT
|
|
|
|
|
};
|
|
|
|
|
|
2009-01-19 17:47:00 +00:00
|
|
|
|
// Button type for the configuration
|
|
|
|
|
enum
|
|
|
|
|
{
|
|
|
|
|
CTL_AXIS = 0,
|
|
|
|
|
CTL_HAT,
|
|
|
|
|
CTL_BUTTON,
|
|
|
|
|
CTL_KEY
|
|
|
|
|
};
|
|
|
|
|
|
2009-01-20 14:25:33 +00:00
|
|
|
|
// XInput buttons
|
|
|
|
|
enum
|
|
|
|
|
{
|
|
|
|
|
XI_TRIGGER_L = 0,
|
|
|
|
|
XI_TRIGGER_R
|
|
|
|
|
};
|
|
|
|
|
|
2008-12-26 02:42:15 +00:00
|
|
|
|
|
2008-12-28 18:50:24 +00:00
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// Input vector. Todo: Save the configured keys here instead of in joystick
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
/*
|
|
|
|
|
#ifndef _CONTROLLER_STATE_H
|
|
|
|
|
extern std::vector<u8> Keys;
|
|
|
|
|
#endif
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-12-26 02:42:15 +00:00
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// Variables
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
#ifndef _CONTROLLER_STATE_H
|
|
|
|
|
extern FILE *pFile;
|
2009-01-24 22:13:53 +00:00
|
|
|
|
extern std::vector<CONTROLLER_INFO> joyinfo;
|
|
|
|
|
extern CONTROLLER_STATE PadState[4];
|
2009-01-21 18:09:31 +00:00
|
|
|
|
extern CONTROLLER_MAPPING PadMapping[4];
|
2008-12-26 02:42:15 +00:00
|
|
|
|
extern HWND m_hWnd; // Handle to window
|
2009-01-24 22:13:53 +00:00
|
|
|
|
extern int NumPads, NumGoodPads; // Number of goods pads
|
2008-12-26 02:42:15 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
2008-12-08 04:46:09 +00:00
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// 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();
|
2009-02-01 16:29:35 +00:00
|
|
|
|
bool IsFocus();
|
2008-12-08 04:46:09 +00:00
|
|
|
|
|
2008-12-27 11:32:03 +00:00
|
|
|
|
void Pad_Use_Rumble(u8 _numPAD, SPADStatus* _pPADStatus); // Rumble
|
2009-01-20 14:25:33 +00:00
|
|
|
|
int Pad_Convert(int _val); // Value conversion
|
2009-01-20 06:38:29 +00:00
|
|
|
|
std::vector<int> Pad_Square_to_Circle(int _x, int _y, int _pad); // Value conversion
|
2008-12-26 02:42:15 +00:00
|
|
|
|
|
2008-12-27 11:32:03 +00:00
|
|
|
|
//void SaveConfig();
|
|
|
|
|
//void LoadConfig();
|