Build fix

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4983 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
nakeee 2010-01-29 07:29:11 +00:00
parent fdaa0e8d4c
commit fefcc6f5b5
1 changed files with 26 additions and 42 deletions

View File

@ -1,16 +1,5 @@
// Project description
// -------------------
// Name: Input Configuration and Calibration
// Description: Common SDL Input Functions
//
// Author: Falcon4ever (nJoy@falcon4ever.com, www.multigesture.net), JPeterson etc
// Copyright (C) 2003 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.
@ -27,8 +16,6 @@
// http://code.google.com/p/dolphin-emu/
//
// Include
// -------------------
#if defined HAVE_WX && HAVE_WX
#include <wx/wx.h>
#endif
@ -38,14 +25,13 @@
#include <Windows.h>
#endif
#include "SDL.h" // Local
#include "SDL_Util.h" // Local
namespace InputCommon
{
// Degree to radian and back
// -------------
float Deg2Rad(float Deg)
{
return Deg * (float)M_PI / 180.0f;
@ -56,7 +42,6 @@ float Rad2Deg(float Rad)
}
// Check if the pad is within the dead zone, we assume the range is 0x8000
// ----------------
float CoordinatesToRadius(int x, int y)
{
return sqrt(pow((float)x, 2) + pow((float)y, 2));
@ -77,17 +62,18 @@ bool IsDeadZone(float DeadZone, int x, int y)
}
// Scale down stick values from 0x8000 to 0x80
/* ----------------
The value returned by SDL_JoystickGetAxis is a signed integer s16
(-32768 to 32767). The value used for the gamecube controller is an unsigned
char u8 (0 to 255) with neutral at 0x80 (128), so that it's equivalent to a signed
-128 to 127.
*/
// ---------------------
/*
The value returned by SDL_JoystickGetAxis is a signed integer s16 (-32768 to
32767). The value used for the gamecube controller is an unsigned char u8 (0
to 255) with neutral at 0x80 (128), so that it's equivalent to a signed -128
to 127. */
//
int Pad_Convert(int _val)
{
/* If the limits on PadState[].axis[] actually is a u16 then we don't need this
but if it's not actually limited to that we need to apply these limits */
/* If the limits on PadState[].axis[] actually is a u16 then we don't need
this but if it's not actually limited to that we need to apply these
limits */
if(_val > 32767) _val = 32767; // upper limit
if(_val < -32768) _val = -32768; // lower limit
@ -103,7 +89,6 @@ int Pad_Convert(int _val)
}
// Adjust the radius
// ----------------
void RadiusAdjustment(s8 &_x, s8 &_y, int _Radius)
{
// Get the radius setting
@ -115,13 +100,14 @@ void RadiusAdjustment(s8 &_x, s8 &_y, int _Radius)
_y = (s8)y;
}
/* Convert the stick raidus from a square or rounded box to a circular radius. I don't know what
input values the actual GC controller produce for the GC, it may be a square, a circle or
something in between. But one thing that is certain is that PC pads differ in their output
(as shown in the list below), so it may be beneficiary to convert whatever radius they
produce to the radius the GC games expect. This is the first implementation of this
that convert a square radius to a circual radius. Use the advanced settings to enable
and calibrate it.
/* Convert the stick raidus from a square or rounded box to a circular
radius. I don't know what input values the actual GC controller produce for
the GC, it may be a square, a circle or something in between. But one thing
that is certain is that PC pads differ in their output (as shown in the list
below), so it may be beneficiary to convert whatever radius they produce to
the radius the GC games expect. This is the first implementation of this
that convert a square radius to a circual radius. Use the advanced settings
to enable and calibrate it.
Observed diagonals:
Perfect circle: 71% = sin(45)
@ -130,11 +116,11 @@ void RadiusAdjustment(s8 &_x, s8 &_y, int _Radius)
XBox 360 Wireless: 85%
GameCube Controller (Third Party) with EMS Trio Linker Plus II: 60%
*/
// ---------------------
/* Calculate the distance from the outer edges of the box to the outer edges of the circle inside the box
at any angle from 0 to 360. The returned value is 1 + Distance, for example at most sqrt(2) in the
corners and at least 1.0 at the horizontal and vertical angles. */
/* Calculate the distance from the outer edges of the box to the outer edges of
the circle inside the box at any angle from 0 to 360. The returned value is
1 + Distance, for example at most sqrt(2) in the corners and at least 1.0 at
the horizontal and vertical angles. */
float Square2CircleDistance(float deg)
{
// See if we have to adjust the angle
@ -157,9 +143,7 @@ void Square2Circle(int &_x, int &_y, int _Diagonal, bool Circle2Square)
if(_x > 32767) _x = 32767; if(_y > 32767) _y = 32767; // upper limit
if(_x < -32768) _x = -32768; if(_y < -32768) _y = -32768; // lower limit
// ====================================
// Convert to circle
// -----------
// Get the manually configured diagonal distance
float Diagonal = (float)_Diagonal / 100.0f;
@ -167,8 +151,9 @@ void Square2Circle(int &_x, int &_y, int _Diagonal, bool Circle2Square)
float OrigDist = sqrt( pow((float)_y, 2) + pow((float)_x, 2) ); // Get current distance
float deg = Rad2Deg(atan2((float)_y, (float)_x)); // Get current angle
/* Calculate the actual distance between the maxium diagonal values, and the outer edges of the
square. A diagonal of 85% means a maximum distance of 0.85 * sqrt(2) ~1.2 in the diagonals. */
/* Calculate the actual distance between the maxium diagonal values, and
the outer edges of the square. A diagonal of 85% means a maximum
distance of 0.85 * sqrt(2) ~1.2 in the diagonals. */
float corner_circle_dist = ( Diagonal / sin(Deg2Rad(45.0f)) );
float SquareDist = Square2CircleDistance(deg);
// The original-to-square distance adjustment
@ -203,7 +188,6 @@ void Square2Circle(int &_x, int &_y, int _Diagonal, bool Circle2Square)
}
// Windows Virtual Key Codes Names
// ---------------------
#ifdef _WIN32
std::string VKToString(int keycode)
{