huge merge
This commit is contained in:
@@ -1,227 +0,0 @@
|
||||
#include "global.h"
|
||||
#include "ArchHooks_Xbox.h"
|
||||
#include "dsound.h" // for timeGetTime
|
||||
#include "archutils/Xbox/custom_launch_params.h" // for XGetCustomLaunchData
|
||||
#include "archutils/Xbox/VirtualMemory.h"
|
||||
|
||||
#include <xtl.h> // for XNetStartup
|
||||
#include <new.h> // for _set_new_handler and _set_new_mode
|
||||
|
||||
typedef struct _UNICODE_STRING {unsigned short Length; unsigned short MaximumLength; PSTR Buffer;} UNICODE_STRING,*PUNICODE_STRING;
|
||||
extern "C" XBOXAPI DWORD WINAPI IoCreateSymbolicLink(IN PUNICODE_STRING SymbolicLinkName,IN PUNICODE_STRING DeviceName);
|
||||
|
||||
static bool g_bTimerInitialized;
|
||||
static DWORD g_iStartTime;
|
||||
|
||||
static void InitTimer()
|
||||
{
|
||||
if( g_bTimerInitialized )
|
||||
return;
|
||||
g_bTimerInitialized = true;
|
||||
|
||||
g_iStartTime = timeGetTime();
|
||||
}
|
||||
|
||||
int64_t ArchHooks::GetMicrosecondsSinceStart( bool bAccurate )
|
||||
{
|
||||
if( !g_bTimerInitialized )
|
||||
InitTimer();
|
||||
|
||||
int64_t ret = (timeGetTime() - g_iStartTime) * int64_t(1000);
|
||||
if( bAccurate )
|
||||
{
|
||||
ret = FixupTimeIfLooped( ret );
|
||||
ret = FixupTimeIfBackwards( ret );
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void MountDriveLetter(char drive, char* szDevice, char* szDir)
|
||||
{
|
||||
char szSourceDevice[256];
|
||||
char szDestinationDrive[16];
|
||||
sprintf(szDestinationDrive, "\\??\\%c:", drive);
|
||||
sprintf(szSourceDevice,"\\Device\\%s",szDevice);
|
||||
if (*szDir != 0x00 && *szDir != '\\')
|
||||
{
|
||||
strcat(szSourceDevice, "\\");
|
||||
strcat(szSourceDevice, szDir);
|
||||
}
|
||||
|
||||
UNICODE_STRING LinkName =
|
||||
{
|
||||
strlen(szDestinationDrive),
|
||||
strlen(szDestinationDrive) + 1,
|
||||
szDestinationDrive
|
||||
};
|
||||
UNICODE_STRING DeviceName =
|
||||
{
|
||||
strlen(szSourceDevice),
|
||||
strlen(szSourceDevice) + 1,
|
||||
szSourceDevice
|
||||
};
|
||||
|
||||
IoCreateSymbolicLink(&LinkName, &DeviceName);
|
||||
}
|
||||
|
||||
void MountDrives()
|
||||
{
|
||||
MountDriveLetter('A', "Cdrom0", "\\");
|
||||
MountDriveLetter('E', "Harddisk0\\Partition1", "\\");
|
||||
MountDriveLetter('C', "Harddisk0\\Partition2", "\\");
|
||||
MountDriveLetter('X', "Harddisk0\\Partition3", "\\");
|
||||
MountDriveLetter('Y', "Harddisk0\\Partition4", "\\");
|
||||
MountDriveLetter('F', "Harddisk0\\Partition6", "\\");
|
||||
MountDriveLetter('G', "Harddisk0\\Partition7", "\\");
|
||||
}
|
||||
|
||||
bool SetupNetwork()
|
||||
{
|
||||
#if !defined(WITHOUT_NETWORKING)
|
||||
XNetStartupParams xnsp;
|
||||
memset(&xnsp, 0, sizeof(xnsp));
|
||||
xnsp.cfgSizeOfStruct = sizeof(XNetStartupParams);
|
||||
xnsp.cfgFlags = XNET_STARTUP_BYPASS_SECURITY;
|
||||
|
||||
INT err = XNetStartup(&xnsp);
|
||||
|
||||
return err == 0;
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
// if Xbox has 128 meg RAM make sure its used
|
||||
void EnableExtraRAM()
|
||||
{
|
||||
LARGE_INTEGER regVal;
|
||||
|
||||
// Verify that we have 128 megs available
|
||||
MEMORYSTATUS memStatus;
|
||||
GlobalMemoryStatus( &memStatus );
|
||||
if( memStatus.dwTotalPhys < (100 * 1024 * 1024) )
|
||||
return;
|
||||
|
||||
// Grab the existing default type (0x02FF)
|
||||
READMSRREG( 0x02FF, ®Val );
|
||||
|
||||
// Set the default to WriteBack (0x06)
|
||||
regVal.LowPart = (regVal.LowPart & ~0xFF) | 0x06;
|
||||
WRITEMSRREG( 0x02FF, regVal );
|
||||
}
|
||||
|
||||
void InitDevices()
|
||||
{
|
||||
XDEVICE_PREALLOC_TYPE xdpt[] = {{XDEVICE_TYPE_GAMEPAD, 4}, {XDEVICE_TYPE_MEMORY_UNIT, 2}};
|
||||
XInitDevices( sizeof(xdpt) / sizeof(XDEVICE_PREALLOC_TYPE), xdpt );
|
||||
}
|
||||
|
||||
ArchHooks_Xbox::ArchHooks_Xbox()
|
||||
{
|
||||
_set_new_handler(NoMemory);
|
||||
_set_new_mode(1);
|
||||
SetUnhandledExceptionFilter((LPTOP_LEVEL_EXCEPTION_FILTER) CheckPageFault);
|
||||
|
||||
XGetCustomLaunchData();
|
||||
|
||||
// mount A to DVD, C, E, F, G, X, and Y to the harddisk
|
||||
MountDrives();
|
||||
|
||||
SetupNetwork();
|
||||
|
||||
EnableExtraRAM();
|
||||
|
||||
InitDevices();
|
||||
}
|
||||
|
||||
static RString XLangID( DWORD Lang )
|
||||
{
|
||||
switch(Lang)
|
||||
{
|
||||
case XC_LANGUAGE_JAPANESE:return "JA";
|
||||
case XC_LANGUAGE_GERMAN:return "DE";
|
||||
case XC_LANGUAGE_FRENCH:return "FR";
|
||||
case XC_LANGUAGE_SPANISH:return "ES";
|
||||
case XC_LANGUAGE_ITALIAN:return "IT";
|
||||
case XC_LANGUAGE_KOREAN:return "KO";
|
||||
case XC_LANGUAGE_TCHINESE:return "ZH";
|
||||
case XC_LANGUAGE_PORTUGUESE:return "PT";
|
||||
default:
|
||||
case XC_LANGUAGE_ENGLISH: return "EN";
|
||||
}
|
||||
}
|
||||
|
||||
RString ArchHooks::GetPreferredLanguage()
|
||||
{
|
||||
return XLangID( XGetLanguage() );
|
||||
}
|
||||
|
||||
ArchHooks_Xbox::~ArchHooks_Xbox()
|
||||
{
|
||||
// We only want to reboot the Xbox in a software manner.
|
||||
XLaunchNewImage( NULL, NULL );
|
||||
}
|
||||
|
||||
void ArchHooks_Xbox::DumpDebugInfo()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
float ArchHooks_Xbox::GetDisplayAspectRatio()
|
||||
{
|
||||
// xxx: does this take into account system settings? -aj
|
||||
float fDisplayAspectRatio = 4.0 / 3.0;
|
||||
IDirect3DSurface8 *pBackBuffer = NULL;
|
||||
if( D3D__pDevice->GetBackBuffer( -1, D3DBACKBUFFER_TYPE_MONO, &pBackBuffer) == D3D_OK )
|
||||
{
|
||||
D3DSURFACE_DESC Desc;
|
||||
if( pBackBuffer->GetDesc(&Desc) == D3D_OK )
|
||||
{
|
||||
fDisplayAspectRatio = (float)Desc.Width / (float)Desc.Height;
|
||||
}
|
||||
pBackBuffer->Release();
|
||||
}
|
||||
return fDisplayAspectRatio;
|
||||
}
|
||||
|
||||
#include "RageFileManager.h"
|
||||
|
||||
void ArchHooks::MountInitialFilesystems( const RString &sDirOfExecutable )
|
||||
{
|
||||
FILEMAN->Mount( "dir", "D:\\", "/" );
|
||||
}
|
||||
|
||||
void ArchHooks::MountUserFilesystems( const RString &sDirOfExecutable )
|
||||
{
|
||||
// Mount everything game-writable (not counting the editor) to the game title persistent data region ( /E/TDATA/33342530/ )
|
||||
FILEMAN->Mount( "dir", "T:/Cache", "/Cache" );
|
||||
FILEMAN->Mount( "dir", "T:/Logs", "/Logs" );
|
||||
FILEMAN->Mount( "dir", "T:/Save", "/Save" );
|
||||
FILEMAN->Mount( "dir", "T:/Screenshots", "/Screenshots" );
|
||||
}
|
||||
|
||||
/*
|
||||
* (c) 2003-2004 Glenn Maynard, Chris Danford
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons to
|
||||
* whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
||||
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
||||
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
@@ -1,78 +0,0 @@
|
||||
#ifndef ARCH_HOOKS_XBOX_H
|
||||
#define ARCH_HOOKS_XBOX_H
|
||||
|
||||
#include "ArchHooks.h"
|
||||
class RageMutex;
|
||||
|
||||
class ArchHooks_Xbox: public ArchHooks
|
||||
{
|
||||
public:
|
||||
ArchHooks_Xbox();
|
||||
~ArchHooks_Xbox();
|
||||
RString GetArchName() { return "Xbox"; }
|
||||
void DumpDebugInfo();
|
||||
float GetDisplayAspectRatio();
|
||||
|
||||
//void MountInitialFilesystems( const RString &sDirOfExecutable );
|
||||
};
|
||||
|
||||
// XXX: This stuff doesn't belong here. Hide it in ArchHooks.
|
||||
|
||||
// Read a 64 bit MSR register
|
||||
inline void READMSRREG( UINT32 reg, LARGE_INTEGER *val )
|
||||
{
|
||||
UINT32 lowPart, highPart;
|
||||
__asm
|
||||
{
|
||||
mov ecx, reg
|
||||
rdmsr
|
||||
mov lowPart, eax
|
||||
mov highPart, edx
|
||||
};
|
||||
|
||||
val->LowPart = lowPart;
|
||||
val->HighPart = highPart;
|
||||
}
|
||||
|
||||
// Write a 64 bit MSR register
|
||||
inline void WRITEMSRREG( UINT32 reg, LARGE_INTEGER val )
|
||||
{
|
||||
__asm
|
||||
{
|
||||
mov ecx, reg
|
||||
mov eax, val.LowPart
|
||||
mov edx, val.HighPart
|
||||
wrmsr
|
||||
};
|
||||
}
|
||||
|
||||
#ifdef ARCH_HOOKS
|
||||
#error "More than one ArchHooks selected!"
|
||||
#endif
|
||||
#define ARCH_HOOKS ArchHooks_Xbox
|
||||
|
||||
#endif
|
||||
/*
|
||||
* (c) 2002-2004 Glenn Maynard, Chris Danford
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons to
|
||||
* whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
||||
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
||||
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
@@ -25,7 +25,7 @@ public:
|
||||
static void Create( const RString &sDrivers, vector<InputHandler *> &apAdd );
|
||||
static DriverList m_pDriverList;
|
||||
|
||||
InputHandler(): m_iInputsSinceUpdate(0) {}
|
||||
InputHandler(): m_LastUpdate(), m_iInputsSinceUpdate(0) {}
|
||||
virtual ~InputHandler() { }
|
||||
virtual void Update() { }
|
||||
virtual bool DevicesChanged() { return false; }
|
||||
|
||||
@@ -413,12 +413,21 @@ void InputHandler_DInput::UpdatePolled( DIDevice &device, const RageTimer &tm )
|
||||
break;
|
||||
case DIMOFS_Z:
|
||||
{
|
||||
neg = MOUSE_WHEELUP; pos = MOUSE_WHEELDOWN;
|
||||
neg = MOUSE_WHEELDOWN; pos = MOUSE_WHEELUP;
|
||||
val = state.lZ;
|
||||
//LOG->Trace("MouseWheel polled: %i",val);
|
||||
INPUTFILTER->UpdateMouseWheel(val);
|
||||
|
||||
float l = SCALE( int(val), -120.0f, 120.0f, 0.0f, 1.0f );
|
||||
ButtonPressed( DeviceInput(dev, neg, max(-l,0), tm) );
|
||||
ButtonPressed( DeviceInput(dev, pos, max(+l,0), tm) );
|
||||
/*
|
||||
if( (int)val != 0 )
|
||||
{
|
||||
// positive values: WheelUp
|
||||
// negative values: WheelDown
|
||||
float l = SCALE( int(val), -120.0f, 120.0f, -1.0f, 1.0f );
|
||||
ButtonPressed( DeviceInput(dev, neg, max(-l,0), tm) );
|
||||
ButtonPressed( DeviceInput(dev, pos, max(+l,0), tm) );
|
||||
}
|
||||
*/
|
||||
}
|
||||
break;
|
||||
default: LOG->MapLog( "unknown input",
|
||||
@@ -515,10 +524,12 @@ void InputHandler_DInput::UpdateBuffered( DIDevice &device, const RageTimer &tm
|
||||
INPUTFILTER->UpdateCursorLocation((float)cursorPos.x,(float)cursorPos.y);
|
||||
break;
|
||||
case DIMOFS_Z:
|
||||
// positive values: WheelUp
|
||||
// negative values: WheelDown
|
||||
INPUTFILTER->UpdateMouseWheel(l);
|
||||
{
|
||||
up = MOUSE_WHEELUP; down = MOUSE_WHEELDOWN;
|
||||
l = SCALE( int(evtbuf[i].dwData), -120.0f, 120.0f, 1.0f, -1.0f );
|
||||
l = SCALE( int(evtbuf[i].dwData), -WHEEL_DELTA, WHEEL_DELTA, 1.0f, -1.0f );
|
||||
DeviceInput diUp = DeviceInput(dev, up, max(-l,0), tm);
|
||||
DeviceInput diDown = DeviceInput(dev, down, max(+l,0), tm);
|
||||
ButtonPressed( diUp );
|
||||
|
||||
@@ -331,7 +331,6 @@ static BOOL CALLBACK DIMouse_EnumDevObjectsProc(LPCDIDEVICEOBJECTINSTANCE dev, L
|
||||
|
||||
in.ofs = dev->dwOfs;
|
||||
|
||||
// xxx: does this check for scrollwheels? -aj
|
||||
if(dev->dwType & DIDFT_BUTTON)
|
||||
{
|
||||
in.type = in.BUTTON;
|
||||
|
||||
@@ -398,7 +398,7 @@ void InputHandler_Linux_Event::InputThread()
|
||||
DeviceButton neg = g_apEventDevices[i]->aiAbsMappingLow[event.code];
|
||||
DeviceButton pos = g_apEventDevices[i]->aiAbsMappingHigh[event.code];
|
||||
|
||||
float l = SCALE( int(event.value), (float) g_apEventDevices[i]->aiAbsMin[i], (float) g_apEventDevices[i]->aiAbsMax[i], -1.0f, 1.0f );
|
||||
float l = SCALE( int(event.value), (float) g_apEventDevices[i]->aiAbsMin[event.code], (float) g_apEventDevices[i]->aiAbsMax[event.code], -1.0f, 1.0f );
|
||||
ButtonPressed( DeviceInput(g_apEventDevices[i]->m_Dev, neg, max(-l,0), now) );
|
||||
ButtonPressed( DeviceInput(g_apEventDevices[i]->m_Dev, pos, max(+l,0), now) );
|
||||
break;
|
||||
|
||||
@@ -247,10 +247,10 @@ InputHandler_MacOSX_HID::InputHandler_MacOSX_HID() : m_Sem( "Input thread starte
|
||||
// Add devices.
|
||||
LOG->Trace( "Finding keyboards" );
|
||||
AddDevices( kHIDPage_GenericDesktop, kHIDUsage_GD_Keyboard, id );
|
||||
/*
|
||||
|
||||
LOG->Trace( "Finding mice" );
|
||||
AddDevices( kHIDPage_GenericDesktop, kHIDUsage_GD_Mouse, id );
|
||||
*/
|
||||
|
||||
LOG->Trace( "Finding joysticks" );
|
||||
id = DEVICE_JOY1;
|
||||
AddDevices( kHIDPage_GenericDesktop, kHIDUsage_GD_Joystick, id );
|
||||
|
||||
@@ -1,232 +0,0 @@
|
||||
#include "global.h"
|
||||
#include "InputHandler_Xbox.h"
|
||||
#include "RageUtil.h"
|
||||
#include "RageLog.h"
|
||||
#include "RageDisplay.h"
|
||||
|
||||
|
||||
#include <xtl.h>
|
||||
|
||||
struct DEVICE_STATE {
|
||||
XPP_DEVICE_TYPE *pxdt;
|
||||
DWORD dwState;
|
||||
};
|
||||
|
||||
byte buttonMasks[] = { XINPUT_GAMEPAD_DPAD_LEFT,
|
||||
XINPUT_GAMEPAD_DPAD_RIGHT,
|
||||
XINPUT_GAMEPAD_DPAD_UP,
|
||||
XINPUT_GAMEPAD_DPAD_DOWN,
|
||||
XINPUT_GAMEPAD_START,
|
||||
XINPUT_GAMEPAD_BACK,
|
||||
XINPUT_GAMEPAD_LEFT_THUMB,
|
||||
XINPUT_GAMEPAD_RIGHT_THUMB};
|
||||
|
||||
|
||||
/**
|
||||
* XBOX controller maps to the following RageInputDevice constants:
|
||||
* DPAD -> JOY_HAT_...
|
||||
* START -> JOY_AUX_1
|
||||
* BACK -> JOY_AUX_2
|
||||
* Left thumb button -> JOY_AUX_3
|
||||
* Right thumb button -> JOY_AUX_4
|
||||
* Following buttons are JOY_(index):
|
||||
* A, B, X, Y, BLACK, WHITE, Left trigger, right trigger
|
||||
*/
|
||||
|
||||
InputHandler_Xbox::InputHandler_Xbox()
|
||||
{
|
||||
//
|
||||
// Init joysticks
|
||||
//
|
||||
ZeroMemory( joysticks, sizeof(joysticks) );
|
||||
|
||||
getHandles();
|
||||
}
|
||||
|
||||
InputHandler_Xbox::~InputHandler_Xbox()
|
||||
{
|
||||
for(unsigned i = 0; i < NUM_JOYSTICKS; i++)
|
||||
{
|
||||
if(joysticks[i] != 0)
|
||||
XInputClose(joysticks[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void InputHandler_Xbox::Update()
|
||||
{
|
||||
// check insertions and removals
|
||||
DWORD dwInsert, dwRemove;
|
||||
DEVICE_STATE devices = {XDEVICE_TYPE_GAMEPAD, 0};
|
||||
|
||||
bool changes = false;
|
||||
// Check each device type to see if any changes have occurred.
|
||||
if( XGetDeviceChanges( devices.pxdt, &dwInsert, &dwRemove ) )
|
||||
{
|
||||
for(int j = 0; j < 4; j++)
|
||||
{
|
||||
if(1 << j & dwRemove)
|
||||
{
|
||||
changes = true;
|
||||
LOG->Trace("A joystick was removed");
|
||||
}
|
||||
if(1 << j & dwInsert)
|
||||
{
|
||||
changes = true;
|
||||
LOG->Trace("A joystick was inserted");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(changes)
|
||||
{
|
||||
getHandles();
|
||||
return;
|
||||
}
|
||||
|
||||
for(unsigned i = 0; i < NUM_JOYSTICKS; i++)
|
||||
{
|
||||
if(joysticks[i] == 0)
|
||||
continue;
|
||||
|
||||
InputDevice inputDevice = InputDevice(DEVICE_JOY1 + i);
|
||||
XINPUT_STATE xis;
|
||||
// Query latest state.
|
||||
XInputGetState( joysticks[i], &xis );
|
||||
|
||||
// check buttons
|
||||
for(int j = 0; j < ARRAYLEN(buttonMasks); j++)
|
||||
{
|
||||
DWORD nowPressed = xis.Gamepad.wButtons & buttonMasks[j];
|
||||
DWORD wasPressed = lastState[i].wButtons & buttonMasks[j];
|
||||
|
||||
if(nowPressed != wasPressed)
|
||||
{
|
||||
DeviceButton Button = DeviceButton(JOY_HAT_LEFT + j);
|
||||
if(Button >= JOY_BUTTON_32)
|
||||
{
|
||||
LOG->Warn("Ignored joystick event (button too high)");
|
||||
continue;
|
||||
}
|
||||
DeviceInput di(inputDevice, Button, nowPressed != 0);
|
||||
ButtonPressed(di);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// check analog buttons
|
||||
for(int j = 0; j < ARRAYLEN(xis.Gamepad.bAnalogButtons); j++)
|
||||
{
|
||||
bool nowPressed = xis.Gamepad.bAnalogButtons[j] > XINPUT_GAMEPAD_MAX_CROSSTALK;
|
||||
bool wasPressed = lastState[i].bAnalogButtons[j] > XINPUT_GAMEPAD_MAX_CROSSTALK;
|
||||
|
||||
if(nowPressed != wasPressed)
|
||||
{
|
||||
DeviceButton Button = DeviceButton(JOY_BUTTON_1 + j);
|
||||
if(Button >= JOY_BUTTON_32)
|
||||
{
|
||||
LOG->Warn("Ignored joystick event (button too high)");
|
||||
continue;
|
||||
}
|
||||
DeviceInput di(inputDevice, Button, nowPressed);
|
||||
ButtonPressed(di);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// check thumbsticks
|
||||
SHORT axes[] = { xis.Gamepad.sThumbLX, xis.Gamepad.sThumbLY, xis.Gamepad.sThumbRX, xis.Gamepad.sThumbRY};
|
||||
|
||||
for(int j = 0; j < ARRAYLEN(axes); j++)
|
||||
{
|
||||
if(axes[j] != 0)
|
||||
{
|
||||
// Reverse y axis (negative values are down, not up)
|
||||
if(j == 1 || j == 3)
|
||||
axes[j] = -axes[j];
|
||||
|
||||
DeviceButton neg = (DeviceButton)(JOY_LEFT + (2 * j));
|
||||
DeviceButton pos = (DeviceButton)(JOY_RIGHT + (2 * j));
|
||||
float l = SCALE( axes[j], 0.0f, 32768.0f, 0.0f, 1.0f );
|
||||
ButtonPressed(DeviceInput(inputDevice, neg,max(-l,0),RageZeroTimer));
|
||||
ButtonPressed(DeviceInput(inputDevice, pos,max(+l,0),RageZeroTimer));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
memcpy(&lastState[i], &xis.Gamepad, sizeof(XINPUT_GAMEPAD));
|
||||
}
|
||||
|
||||
InputHandler::UpdateTimer();
|
||||
}
|
||||
|
||||
void InputHandler_Xbox::GetDevicesAndDescriptions( vector<InputDeviceInfo>& vDevicesOut )
|
||||
{
|
||||
for( int i=0; i<NUM_JOYSTICKS; i++ )
|
||||
{
|
||||
if( joysticks[i] != 0 )
|
||||
{
|
||||
vDevicesOut.push_back( InputDeviceInfo(InputDevice(DEVICE_JOY1+i),"XboxGameHardware") );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void InputHandler_Xbox::getHandles()
|
||||
{
|
||||
for(unsigned i = 0; i < NUM_JOYSTICKS; i++)
|
||||
{
|
||||
if(joysticks[i] != 0)
|
||||
XInputClose(joysticks[i]);
|
||||
}
|
||||
|
||||
ZeroMemory( joysticks, sizeof(joysticks) );
|
||||
ZeroMemory( lastState, sizeof(lastState) );
|
||||
|
||||
// Work out joystick handles
|
||||
DEVICE_STATE devices = {XDEVICE_TYPE_GAMEPAD, 0};
|
||||
devices.dwState = XGetDevices( devices.pxdt );
|
||||
|
||||
// Check the global gamepad state for a connected device.
|
||||
unsigned playersAllocated = 0;
|
||||
unsigned joysFound = 0;
|
||||
|
||||
for( unsigned i = 0; i < NUM_PORTS; i++ )
|
||||
{
|
||||
if( devices.dwState & 1 << i)
|
||||
{
|
||||
if(playersAllocated < NUM_JOYSTICKS)
|
||||
{
|
||||
XINPUT_POLLING_PARAMETERS pollingParameters = {TRUE, TRUE, 0, 8, 8, 0,};
|
||||
joysticks[playersAllocated] = XInputOpen(XDEVICE_TYPE_GAMEPAD, (DWORD)i, XDEVICE_NO_SLOT, &pollingParameters);
|
||||
playersAllocated++;
|
||||
}
|
||||
joysFound++;
|
||||
}
|
||||
}
|
||||
|
||||
LOG->Info( "Found %d connected joysticks for %d players", joysFound, playersAllocated );
|
||||
}
|
||||
|
||||
/*
|
||||
* (c) 2004 Ryan Dortmans
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons to
|
||||
* whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
||||
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
||||
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
@@ -1,52 +0,0 @@
|
||||
#ifndef INPUT_HANDLER_XBOX_H
|
||||
#define INPUT_HANDLER_XBOX_H
|
||||
|
||||
#include "InputHandler.h"
|
||||
|
||||
#include <xtl.h>
|
||||
|
||||
#define NUM_PORTS 4
|
||||
|
||||
class InputHandler_Xbox: public InputHandler
|
||||
{
|
||||
HANDLE joysticks[NUM_JOYSTICKS];
|
||||
XINPUT_GAMEPAD lastState[NUM_JOYSTICKS];
|
||||
|
||||
public:
|
||||
void Update();
|
||||
InputHandler_Xbox();
|
||||
~InputHandler_Xbox();
|
||||
void GetDevicesAndDescriptions( vector<InputDeviceInfo>& vDevicesOut );
|
||||
|
||||
private:
|
||||
void getHandles();
|
||||
};
|
||||
#define USE_INPUT_HANDLER_XBOX
|
||||
REGISTER_INPUT_HANDLER_CLASS( Xbox );
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* (c) 2004 Ryan Dortmans
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons to
|
||||
* whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
||||
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
||||
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
@@ -12,7 +12,7 @@ LoadingWindow *LoadingWindow::Create()
|
||||
return new LoadingWindow_Null;
|
||||
#endif
|
||||
// Don't load NULL by default.
|
||||
const RString drivers = "xbox,win32,macosx,gtk";
|
||||
const RString drivers = "win32,macosx,gtk";
|
||||
vector<RString> DriversToTry;
|
||||
split( drivers, ",", DriversToTry, true );
|
||||
|
||||
@@ -33,9 +33,6 @@ LoadingWindow *LoadingWindow::Create()
|
||||
#endif
|
||||
#ifdef USE_LOADING_WINDOW_WIN32
|
||||
if( !DriversToTry[i].CompareNoCase("Win32") ) ret = new LoadingWindow_Win32;
|
||||
#endif
|
||||
#ifdef USE_LOADING_WINDOW_XBOX
|
||||
if( !DriversToTry[i].CompareNoCase("Xbox") ) ret = new LoadingWindow_Xbox;
|
||||
#endif
|
||||
if( !DriversToTry[i].CompareNoCase("Null") ) ret = new LoadingWindow_Null;
|
||||
|
||||
|
||||
@@ -1,179 +0,0 @@
|
||||
#include "global.h"
|
||||
#include "LoadingWindow_Xbox.h"
|
||||
#include "RageLog.h"
|
||||
|
||||
#include "ProductInfo.h"
|
||||
|
||||
LPDIRECT3D8 g_pD3D = NULL; // DirectX Object
|
||||
LPDIRECT3DDEVICE8 g_pD3DDevice = NULL; // Screen Object
|
||||
LPDIRECT3DTEXTURE8 splash = NULL; // splash texture
|
||||
LPD3DXSPRITE g_sprite = NULL; // sprite object
|
||||
|
||||
LoadingWindow_Xbox::LoadingWindow_Xbox()
|
||||
{
|
||||
// Initialise Direct3D
|
||||
g_pD3D = Direct3DCreate8(D3D_SDK_VERSION);
|
||||
|
||||
// Create a structure to hold the settings for our device
|
||||
D3DPRESENT_PARAMETERS d3dpp;
|
||||
ZeroMemory(&d3dpp, sizeof(d3dpp));
|
||||
|
||||
// Fill the structure.
|
||||
// Set fullscreen 640x480x32 mode
|
||||
d3dpp.BackBufferWidth = 640;
|
||||
d3dpp.BackBufferHeight = 480;
|
||||
d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
|
||||
|
||||
// Create one backbuffer and a zbuffer
|
||||
d3dpp.BackBufferCount = 1;
|
||||
|
||||
// Set up how the backbuffer is "presented" to the frontbuffer each time
|
||||
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
|
||||
|
||||
//Create a Direct3D device.
|
||||
g_pD3D->CreateDevice(0, D3DDEVTYPE_HAL, NULL,
|
||||
D3DCREATE_HARDWARE_VERTEXPROCESSING,
|
||||
&d3dpp, &g_pD3DDevice);
|
||||
g_pD3DDevice->SetRenderState(D3DRS_LIGHTING, FALSE);
|
||||
|
||||
// Create the sprite object (for painting the image)
|
||||
D3DXCreateSprite(g_pD3DDevice, &g_sprite);
|
||||
|
||||
// Load the default font
|
||||
XFONT_OpenDefaultFont(&font);
|
||||
font->SetTextColor(D3DCOLOR_XRGB(255,255,255));
|
||||
font->SetTextAlignment(XFONT_CENTER);
|
||||
|
||||
// Load the splash.png
|
||||
|
||||
HRESULT result = D3DXCreateTextureFromFileA(g_pD3DDevice, "D:\\Data\\splash.png", &splash);
|
||||
useImage = (result == D3D_OK);
|
||||
|
||||
if(!useImage)
|
||||
LOG->Trace("Error loading splash.png - %i", result);
|
||||
|
||||
SetText(RString("Loading songs"));
|
||||
}
|
||||
|
||||
LoadingWindow_Xbox::~LoadingWindow_Xbox()
|
||||
{
|
||||
g_pD3DDevice->Release();
|
||||
g_pD3D->Release();
|
||||
font->Release();
|
||||
}
|
||||
|
||||
void LoadingWindow_Xbox::Paint()
|
||||
{
|
||||
LPDIRECT3DSURFACE8 g_pFrontBuffer;
|
||||
|
||||
if(text == "")
|
||||
return;
|
||||
|
||||
g_pD3DDevice->Clear(0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);
|
||||
|
||||
g_pD3DDevice->BeginScene();
|
||||
g_pD3DDevice->GetBackBuffer(0,D3DBACKBUFFER_TYPE_MONO,&g_pFrontBuffer);
|
||||
|
||||
if(useImage)
|
||||
{
|
||||
// Draw the splash image
|
||||
// Only draw if the splash texture is successfully loaded
|
||||
D3DXVECTOR2 pos;
|
||||
pos.x = 70.0f;
|
||||
pos.y = 30.0f;
|
||||
|
||||
g_sprite->Begin();
|
||||
g_sprite->Draw(splash, NULL, NULL, NULL, NULL, &pos, 0xFFFFFFFF);
|
||||
g_sprite->End();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Lo-fi version: print the product name and version at the top of the screen
|
||||
font->SetTextColor(D3DCOLOR_XRGB(255, 0, 0));
|
||||
RString title = "Version ";
|
||||
title = title + PRODUCT_VER;
|
||||
WCHAR wc_title[200] = {0};
|
||||
swprintf(wc_title, L"%S", title.c_str());
|
||||
|
||||
font->TextOut(g_pFrontBuffer, L"StepMania", -1, 320, 30);
|
||||
font->SetTextColor(D3DCOLOR_XRGB(255, 255, 0));
|
||||
font->TextOut(g_pFrontBuffer, wc_title, -1, 320, 40 + font->GetTextHeight());
|
||||
}
|
||||
|
||||
// Draw the text on the screen
|
||||
font->SetTextColor(D3DCOLOR_XRGB(255, 255, 255));
|
||||
basic_string <char>::size_type newLineIndex = text.find("\n", 0);
|
||||
int y = 240;
|
||||
|
||||
if(newLineIndex == RString.npos)
|
||||
{
|
||||
WCHAR wc_text[200] = {0};
|
||||
swprintf(wc_text, L"%S", text.c_str());
|
||||
|
||||
font->TextOut(g_pFrontBuffer, wc_text, wcslen(wc_text), 320, y);
|
||||
}
|
||||
else
|
||||
{
|
||||
int start = 0;
|
||||
|
||||
while(start != RString.npos)
|
||||
{
|
||||
RString toPrint;
|
||||
if(newLineIndex != RString.npos)
|
||||
toPrint = text.substr(start, newLineIndex - start);
|
||||
else
|
||||
toPrint = text.substr(start);
|
||||
|
||||
if(toPrint != "")
|
||||
{
|
||||
WCHAR wc_text[200] = {0};
|
||||
swprintf(wc_text, L"%S", toPrint.c_str());
|
||||
|
||||
font->TextOut(g_pFrontBuffer, wc_text, wcslen(wc_text), 320, y);
|
||||
}
|
||||
y = y + font->GetTextHeight() + 10;
|
||||
|
||||
if(newLineIndex != RString.npos)
|
||||
start = newLineIndex + 1;
|
||||
else
|
||||
start = RString.npos;
|
||||
|
||||
newLineIndex = text.find("\n", start);
|
||||
}
|
||||
}
|
||||
|
||||
g_pFrontBuffer->Release();
|
||||
|
||||
g_pD3DDevice->EndScene();
|
||||
g_pD3DDevice->Present(NULL, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
void LoadingWindow_Xbox::SetText(RString str)
|
||||
{
|
||||
text = str ;
|
||||
}
|
||||
|
||||
/*
|
||||
* (c) 2004 Ryan Dortmans
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons to
|
||||
* whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
||||
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
||||
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
@@ -1,51 +0,0 @@
|
||||
#ifndef LOADING_WINDOW_XBOX_H
|
||||
#define LOADING_WINDOW_XBOX_H
|
||||
|
||||
#include "LoadingWindow.h"
|
||||
|
||||
#include <xtl.h>
|
||||
#include <xfont.h>
|
||||
#define XFONT_TRUETYPE
|
||||
|
||||
class LoadingWindow_Xbox: public LoadingWindow
|
||||
{
|
||||
public:
|
||||
LoadingWindow_Xbox();
|
||||
~LoadingWindow_Xbox();
|
||||
|
||||
void Paint();
|
||||
void SetText(RString str);
|
||||
|
||||
protected:
|
||||
RString text ;
|
||||
XFONT* font;
|
||||
bool useImage;
|
||||
};
|
||||
#define USE_LOADING_WINDOW_XBOX
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* (c) 2004 Ryan Dortmans
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons to
|
||||
* whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
||||
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
||||
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
@@ -1,150 +0,0 @@
|
||||
#include "global.h"
|
||||
#include "MemoryCardDriverThreaded_Xbox.h"
|
||||
#include "RageUtil.h"
|
||||
#include "RageLog.h"
|
||||
|
||||
MemoryCardDriverThreaded_Xbox::MemoryCardDriverThreaded_Xbox()
|
||||
{
|
||||
}
|
||||
|
||||
MemoryCardDriverThreaded_Xbox::~MemoryCardDriverThreaded_Xbox()
|
||||
{
|
||||
}
|
||||
|
||||
static bool TestReady( const RString &sDrive, RString &sVolumeLabelOut )
|
||||
{
|
||||
TCHAR szVolumeNameBuffer[MAX_PATH];
|
||||
DWORD dwVolumeSerialNumber;
|
||||
DWORD dwMaximumComponentLength;
|
||||
DWORD lpFileSystemFlags;
|
||||
TCHAR szFileSystemNameBuffer[MAX_PATH];
|
||||
|
||||
if( !GetVolumeInformation(
|
||||
sDrive,
|
||||
szVolumeNameBuffer,
|
||||
sizeof(szVolumeNameBuffer),
|
||||
&dwVolumeSerialNumber,
|
||||
&dwMaximumComponentLength,
|
||||
&lpFileSystemFlags,
|
||||
szFileSystemNameBuffer,
|
||||
sizeof(szFileSystemNameBuffer)) ){
|
||||
LOG->Trace("GetVolumeInformation failed %u", GetLastError());
|
||||
return false;
|
||||
}
|
||||
|
||||
sVolumeLabelOut = szVolumeNameBuffer;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MemoryCardDriverThreaded_Xbox::TestWrite( UsbStorageDevice* pDevice )
|
||||
{
|
||||
/* Try to write a file, to check if the device is writable and that we have write permission.*/
|
||||
for( int i = 0; i < 10; ++i )
|
||||
{
|
||||
HANDLE hFile = CreateFile(
|
||||
ssprintf( "%s\\tmp%i", pDevice->sOsMountDir.c_str(), RandomInt(100000)),
|
||||
GENERIC_WRITE,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
NULL,
|
||||
CREATE_NEW,
|
||||
FILE_FLAG_DELETE_ON_CLOSE,
|
||||
NULL );
|
||||
|
||||
if( hFile == INVALID_HANDLE_VALUE )
|
||||
{
|
||||
DWORD iError = GetLastError();
|
||||
LOG->Warn( "Couldn't write to %s (%u)", pDevice->sOsMountDir.c_str(), iError);
|
||||
|
||||
if( iError == ERROR_FILE_EXISTS )
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
|
||||
CloseHandle( hFile );
|
||||
return true;
|
||||
}
|
||||
|
||||
pDevice->SetError( "TestFailed" );
|
||||
return false;
|
||||
}
|
||||
|
||||
void MemoryCardDriverThreaded_Xbox::GetUSBStorageDevices( vector<UsbStorageDevice>& vDevicesOut )
|
||||
{
|
||||
DWORD devices=XGetDevices(XDEVICE_TYPE_MEMORY_UNIT);
|
||||
|
||||
for(int port=0;port<4;port++){
|
||||
//top slot
|
||||
if(devices&(1<<port)){
|
||||
vDevicesOut.push_back( UsbStorageDevice() );
|
||||
UsbStorageDevice &usbd = vDevicesOut.back();
|
||||
usbd.iPort=port;
|
||||
usbd.iLevel=0;
|
||||
usbd.sDevice=ssprintf("Memory card on port %u on slot 0", port);
|
||||
}
|
||||
//bottom slot
|
||||
if(devices&(1<<(port+16))){
|
||||
vDevicesOut.push_back( UsbStorageDevice() );
|
||||
UsbStorageDevice &usbd = vDevicesOut.back();
|
||||
usbd.iPort=port;
|
||||
usbd.iLevel=1;
|
||||
usbd.sDevice=ssprintf("Memory card on port %u on slot 1", port);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool MemoryCardDriverThreaded_Xbox::USBStorageDevicesChanged()
|
||||
{
|
||||
DWORD ins, rem;
|
||||
return XGetDeviceChanges(XDEVICE_TYPE_MEMORY_UNIT, &ins, &rem)==TRUE;
|
||||
}
|
||||
|
||||
bool MemoryCardDriverThreaded_Xbox::Mount( UsbStorageDevice* pDevice )
|
||||
{
|
||||
LOG->Trace( "%s", __FUNCTION__);
|
||||
CHAR drive;
|
||||
DWORD MountRetval=XMountMU(pDevice->iPort, pDevice->iLevel, &drive);
|
||||
if(MountRetval==ERROR_SUCCESS){
|
||||
LOG->Trace("Mounted memory card from port %u slot %u to %c:", pDevice->iPort, pDevice->iLevel, drive);
|
||||
pDevice->SetOsMountDir(ssprintf("%c:", drive));
|
||||
RString sVolumeLabel;
|
||||
if( !TestReady(pDevice->sOsMountDir + "\\", sVolumeLabel) )
|
||||
{
|
||||
LOG->Trace( "not TestReady" );
|
||||
}
|
||||
pDevice->sVolumeLabel = sVolumeLabel;
|
||||
return true;
|
||||
}else{
|
||||
LOG->Trace("Could not mount memory card %u", MountRetval);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void MemoryCardDriverThreaded_Xbox::Unmount( UsbStorageDevice* pDevice )
|
||||
{
|
||||
XUnmountMU(pDevice->iPort, pDevice->iLevel);
|
||||
}
|
||||
|
||||
/*
|
||||
* (c) 2003-2004 Chris Danford
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons to
|
||||
* whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
||||
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
||||
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
@@ -1,51 +0,0 @@
|
||||
#ifndef MemoryCardDriverThreaded_Xbox_H
|
||||
#define MemoryCardDriverThreaded_Xbox_H
|
||||
|
||||
#include "MemoryCardDriver.h"
|
||||
|
||||
class MemoryCardDriverThreaded_Xbox: public MemoryCardDriver
|
||||
{
|
||||
public:
|
||||
MemoryCardDriverThreaded_Xbox();
|
||||
virtual ~MemoryCardDriverThreaded_Xbox();
|
||||
|
||||
virtual bool Mount( UsbStorageDevice* pDevice );
|
||||
virtual void Unmount( UsbStorageDevice* pDevice );
|
||||
|
||||
private:
|
||||
void GetUSBStorageDevices( vector<UsbStorageDevice>& vDevicesOut );
|
||||
bool USBStorageDevicesChanged();
|
||||
bool TestWrite( UsbStorageDevice* pDevice );
|
||||
};
|
||||
|
||||
#ifdef ARCH_MEMORY_CARD_DRIVER
|
||||
#error "More than one MemoryCardDriver included!"
|
||||
#endif
|
||||
#define ARCH_MEMORY_CARD_DRIVER MemoryCardDriverThreaded_Xbox
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* (c) 2003-2004 Chris Danford
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons to
|
||||
* whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
||||
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
||||
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
@@ -29,34 +29,15 @@ namespace avcodec
|
||||
};
|
||||
|
||||
/*
|
||||
#if defined(_MSC_VER) && !defined(XBOX)
|
||||
#if defined(_MSC_VER)
|
||||
#pragma comment(lib, "ffmpeg/lib/avcodec.lib")
|
||||
#pragma comment(lib, "ffmpeg/lib/avformat.lib")
|
||||
#if defined(USE_MODERN_FFMPEG)
|
||||
#pragma comment(lib, "ffmpeg/lib/swscale.lib")
|
||||
#endif
|
||||
#endif // _MSC_VER && !XBOX
|
||||
#endif // _MSC_VER
|
||||
*/
|
||||
|
||||
#if defined(XBOX)
|
||||
/* NOTES: ffmpeg static libraries arent included in SVN. You have to build
|
||||
*them yourself or remove this file to produce the xbox build.
|
||||
*
|
||||
* build ffmpeg with mingw32 ( howto http://ffmpeg.arrozcru.org/wiki/index.php?title=Main_Page )
|
||||
* ./configure --enable-memalign-hack --enable-static --disable-mmx --target-os=mingw32 --arch=x86
|
||||
* you can use various switches to enable/disable codecs/muxers/etc.
|
||||
*
|
||||
* libgcc.a and libmingwex.a comes from mingw installation
|
||||
* msys\mingw\lib\gcc\mingw32\3.4.5\libgcc.a */
|
||||
#pragma comment(lib, "ffmpeg/lib/libavcodec.a")
|
||||
#pragma comment(lib, "ffmpeg/lib/libavformat.a")
|
||||
#pragma comment(lib, "ffmpeg/lib/libavutil.a")
|
||||
#pragma comment(lib, "ffmpeg/lib/libswscale.a")
|
||||
#pragma comment(lib, "ffmpeg/lib/libgcc.a")
|
||||
#pragma comment(lib, "ffmpeg/lib/libmingwex.a")
|
||||
#pragma comment(lib, "ffmpeg/lib/libcoldname.a")
|
||||
#endif
|
||||
|
||||
#if !defined(MACOSX)
|
||||
static const int sws_flags = SWS_BICUBIC; // XXX: Reasonable default?
|
||||
#endif
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "RageUtil.h"
|
||||
#include "Sprite.h"
|
||||
|
||||
#if defined(WIN32) && !defined(XBOX)
|
||||
#if defined(WIN32)
|
||||
#include "archutils/Win32/ErrorStrings.h"
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
@@ -79,7 +79,7 @@ RString RageSoundDriver_PulseAudio::Init()
|
||||
#endif
|
||||
|
||||
pa_context_set_state_callback(m_PulseCtx, StaticCtxStateCb, this);
|
||||
|
||||
|
||||
LOG->Trace("Pulse: pa_context_connect()...");
|
||||
error = pa_context_connect(m_PulseCtx, NULL, (pa_context_flags_t)0, NULL);
|
||||
|
||||
@@ -299,6 +299,11 @@ int64_t RageSoundDriver_PulseAudio::GetPosition() const
|
||||
return m_LastPosition;
|
||||
}
|
||||
|
||||
/*
|
||||
* XXX: Something here is slow and causes arrows to stutter in gameplay.
|
||||
* This needs to be looked into (and for some reason the ALSA driver is
|
||||
* useless on my laptop). - Colby
|
||||
*/
|
||||
void RageSoundDriver_PulseAudio::StreamWriteCb(pa_stream *s, size_t length)
|
||||
{
|
||||
#if PA_API_VERSION <= 11
|
||||
@@ -359,4 +364,4 @@ void RageSoundDriver_PulseAudio::StaticStreamWriteCb(pa_stream *s, size_t length
|
||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
*/
|
||||
|
||||
@@ -31,11 +31,9 @@ HANDLE Win32ThreadIdToHandle( uint64_t iID )
|
||||
|
||||
void ThreadImpl_Win32::Halt( bool Kill )
|
||||
{
|
||||
#ifndef _XBOX
|
||||
if( Kill )
|
||||
TerminateThread( ThreadHandle, 0 );
|
||||
else
|
||||
#endif
|
||||
SuspendThread( ThreadHandle );
|
||||
}
|
||||
|
||||
|
||||
+7
-14
@@ -52,9 +52,6 @@ void MakeInputHandlers( const RString &drivers, vector<InputHandler *> &Add )
|
||||
#ifdef USE_INPUT_HANDLER_X11
|
||||
if( !s->CompareNoCase("X11") ) ret = new InputHandler_X11;
|
||||
#endif
|
||||
#ifdef USE_INPUT_HANDLER_XBOX
|
||||
if( !s->CompareNoCase("Xbox") ) ret = new InputHandler_Xbox;
|
||||
#endif
|
||||
#ifdef USE_INPUT_HANDLER_MACOSX_HID
|
||||
if( !s->CompareNoCase("MacOSX") ) ret = new InputHandler_MacOSX_HID;
|
||||
#endif
|
||||
@@ -104,7 +101,7 @@ LoadingWindow *MakeLoadingWindow()
|
||||
return new LoadingWindow_Null;
|
||||
#endif
|
||||
// Don't load NULL by default.
|
||||
const RString drivers = "xbox,win32,cocoa,gtk";
|
||||
const RString drivers = "win32,cocoa,gtk";
|
||||
vector<RString> DriversToTry;
|
||||
split( drivers, ",", DriversToTry, true );
|
||||
|
||||
@@ -129,11 +126,7 @@ LoadingWindow *MakeLoadingWindow()
|
||||
#ifdef USE_LOADING_WINDOW_WIN32
|
||||
if( !DriversToTry[i].CompareNoCase("Win32") ) ret = new LoadingWindow_Win32;
|
||||
#endif
|
||||
#ifdef USE_LOADING_WINDOW_XBOX
|
||||
if( !DriversToTry[i].CompareNoCase("Xbox") ) ret = new LoadingWindow_Xbox;
|
||||
#endif
|
||||
|
||||
|
||||
if( ret == NULL )
|
||||
continue;
|
||||
|
||||
@@ -144,10 +137,10 @@ LoadingWindow *MakeLoadingWindow()
|
||||
SAFE_DELETE( ret );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(ret)
|
||||
LOG->Info( "Loading window: %s", Driver.c_str() );
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -191,7 +184,7 @@ RageMovieTexture *MakeRageMovieTexture( RageTextureID ID )
|
||||
|
||||
vector<RString> DriversToTry;
|
||||
split( sDrivers, ",", DriversToTry, true );
|
||||
|
||||
|
||||
if( DriversToTry.empty() )
|
||||
RageException::Throw( MOVIE_DRIVERS_EMPTY.GetValue() );
|
||||
|
||||
@@ -231,7 +224,7 @@ RageMovieTexture *MakeRageMovieTexture( RageTextureID ID )
|
||||
RageException::Throw( COULDNT_CREATE_MOVIE_DRIVER.GetValue() );
|
||||
|
||||
LOG->Trace( "Created movie texture \"%s\" with driver \"%s\"",
|
||||
ID.filename.c_str(), Driver.c_str() );
|
||||
ID.filename.c_str(), Driver.c_str() );
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -291,10 +284,10 @@ RageSoundDriver *MakeRageSoundDriver( const RString &drivers )
|
||||
SAFE_DELETE( ret );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if( ret )
|
||||
LOG->Info( "Sound driver: %s", Driver.c_str() );
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
#if defined(_WINDOWS)
|
||||
#define SUPPORT_OPENGL
|
||||
#define SUPPORT_D3D
|
||||
#elif defined(_XBOX)
|
||||
#define SUPPORT_D3D
|
||||
#else
|
||||
#define SUPPORT_OPENGL
|
||||
#endif
|
||||
|
||||
@@ -22,16 +22,6 @@
|
||||
#define DEFAULT_SOUND_DRIVER_LIST "AudioUnit,Null"
|
||||
|
||||
|
||||
#elif defined(_XBOX)
|
||||
#include "ArchHooks/ArchHooks_Xbox.h"
|
||||
#include "LoadingWindow/LoadingWindow_Xbox.h"
|
||||
#include "LowLevelWindow/LowLevelWindow_Win32.h"
|
||||
#include "MemoryCard/MemoryCardDriverThreaded_Xbox.h"
|
||||
#define DEFAULT_INPUT_DRIVER_LIST "Xbox"
|
||||
#define DEFAULT_MOVIE_DRIVER_LIST "Theora,FFMpeg,DShow,Null"
|
||||
#define DEFAULT_SOUND_DRIVER_LIST "DirectSound,DirectSound-sw,Null"
|
||||
|
||||
|
||||
#elif defined(UNIX)
|
||||
#include "ArchHooks/ArchHooks_Unix.h"
|
||||
#include "LowLevelWindow/LowLevelWindow_X11.h"
|
||||
|
||||
Reference in New Issue
Block a user