Allow cxbxr to build with LLE USB
This commit is contained in:
parent
06a5cbc5a9
commit
87e1833941
|
@ -367,6 +367,7 @@
|
|||
</PreBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\src\Common\CxbxCommon.h" />
|
||||
<ClInclude Include="..\..\src\Common\Input\InputConfig.h" />
|
||||
<ClInclude Include="..\..\src\Common\Input\SDL2_Device.h" />
|
||||
<ClInclude Include="..\..\src\Common\Win32\Threads.h" />
|
||||
|
@ -383,7 +384,7 @@
|
|||
<ClInclude Include="..\..\src\Common\Win32\AlignPrefix1.h" />
|
||||
<ClInclude Include="..\..\src\Common\XDVDFS Tools\buffered_io.h" />
|
||||
<ClInclude Include="..\..\src\Common\XDVDFS Tools\xdvdfs.h" />
|
||||
<ClInclude Include="..\..\src\CxbxCommon.h" />
|
||||
<ClInclude Include="..\..\src\Cxbx.h" />
|
||||
<ClInclude Include="..\..\src\CxbxKrnl\CxbxKrnl.h" />
|
||||
<ClInclude Include="..\..\src\CxbxKrnl\DbgConsole.h" />
|
||||
<ClInclude Include="..\..\src\CxbxKrnl\EmuD3D8.h" />
|
||||
|
@ -744,16 +745,6 @@
|
|||
<ClCompile Include="..\..\src\CxbxKrnl\gloffscreen\glextensions.cpp" />
|
||||
<ClCompile Include="..\..\src\CxbxKrnl\gloffscreen\gloffscreen_common.cpp" />
|
||||
<ClCompile Include="..\..\src\CxbxKrnl\gloffscreen\gloffscreen_wgl.cpp" />
|
||||
<ClCompile Include="..\..\src\CxbxKrnl\HLEDataBase.cpp">
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug_USB_Packets|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug_Direct3D9|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug_USB_Packets|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug_Direct3D9|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\CxbxKrnl\HLEIntercept.cpp">
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug_USB_Packets|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
|
|
|
@ -293,7 +293,6 @@
|
|||
<ClCompile Include="..\..\src\devices\usb\Hub.cpp">
|
||||
<Filter>Hardware\Usb</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\Common\CxbxCommon.cpp" />
|
||||
<ClCompile Include="..\..\src\devices\usb\XidGamepad.cpp">
|
||||
<Filter>Hardware\Usb</Filter>
|
||||
</ClCompile>
|
||||
|
@ -315,6 +314,9 @@
|
|||
<ClCompile Include="..\..\src\Common\Input\SDL2_Device.cpp">
|
||||
<Filter>Shared\Input</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\Common\CxbxCommon.cpp">
|
||||
<Filter>Cross Platform</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\src\Cxbx\DlgControllerConfig.h">
|
||||
|
@ -599,9 +601,6 @@
|
|||
<ClInclude Include="..\..\src\devices\usb\UsbCommon.h">
|
||||
<Filter>Hardware\Usb</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\CxbxCommon.h">
|
||||
<Filter>Shared</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\devices\usb\XidGamepad.h">
|
||||
<Filter>Hardware\Usb</Filter>
|
||||
</ClInclude>
|
||||
|
@ -617,6 +616,12 @@
|
|||
<ClInclude Include="..\..\src\Common\Input\SDL2_Device.h">
|
||||
<Filter>Shared\Input</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\Cxbx.h">
|
||||
<Filter>Shared</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\Common\CxbxCommon.h">
|
||||
<Filter>Cross Platform</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\..\resource\Splash.jpg">
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
// * `88bo,__,o, oP"``"Yo, _88o,,od8P oP"``"Yo,
|
||||
// * "YUMMMMMP",m" "Mm,""YUMMMP" ,m" "Mm,
|
||||
// *
|
||||
// * Cxbx->Common->Cxbx.cpp
|
||||
// * Cxbx->Common->CxbxCommon.cpp
|
||||
// *
|
||||
// * This file is part of the Cxbx project.
|
||||
// *
|
||||
|
@ -36,7 +36,8 @@
|
|||
|
||||
// The intent of this file is to add general functions which are not kernel specific (for those CxbxKrnl.h should be used instead)
|
||||
|
||||
#include "CxbxKrnl\CxbxKrnl.h"
|
||||
#include "CxbxCommon.h"
|
||||
#include "CxbxKrnl\CxbxKrnl.h"
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
||||
|
|
|
@ -0,0 +1,74 @@
|
|||
// This is an open source non-commercial project. Dear PVS-Studio, please check it.
|
||||
// PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
|
||||
// ******************************************************************
|
||||
// *
|
||||
// * .,-::::: .,:: .::::::::. .,:: .:
|
||||
// * ,;;;'````' `;;;, .,;; ;;;'';;' `;;;, .,;;
|
||||
// * [[[ '[[,,[[' [[[__[[\. '[[,,[['
|
||||
// * $$$ Y$$$P $$""""Y$$ Y$$$P
|
||||
// * `88bo,__,o, oP"``"Yo, _88o,,od8P oP"``"Yo,
|
||||
// * "YUMMMMMP",m" "Mm,""YUMMMP" ,m" "Mm,
|
||||
// *
|
||||
// * Cxbx->Common->CxbxCommon.h
|
||||
// *
|
||||
// * This file is part of the Cxbx project.
|
||||
// *
|
||||
// * Cxbx and Cxbe are free software; you can redistribute them
|
||||
// * and/or modify them under the terms of the GNU General Public
|
||||
// * License as published by the Free Software Foundation; either
|
||||
// * version 2 of the license, or (at your option) any later version.
|
||||
// *
|
||||
// * 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 for more details.
|
||||
// *
|
||||
// * You should have recieved a copy of the GNU General Public License
|
||||
// * along with this program; see the file COPYING.
|
||||
// * If not, write to the Free Software Foundation, Inc.,
|
||||
// * 59 Temple Place - Suite 330, Bostom, MA 02111-1307, USA.
|
||||
// *
|
||||
// * (c) 2018 ergo720
|
||||
// *
|
||||
// * All rights reserved
|
||||
// *
|
||||
// ******************************************************************
|
||||
|
||||
#ifndef CXBX_COMMON_H
|
||||
#define CXBX_COMMON_H
|
||||
|
||||
#include "Cxbx.h"
|
||||
#include <stdint.h>
|
||||
#include <assert.h>
|
||||
|
||||
/* This is a linux struct for vectored I/O. See readv() and writev() */
|
||||
struct IoVec
|
||||
{
|
||||
void* Iov_Base; // Starting address
|
||||
size_t Iov_Len; // Number of bytes to transfer
|
||||
};
|
||||
|
||||
struct IOVector
|
||||
{
|
||||
IoVec* IoVecStruct;
|
||||
int IoVecNumber; // number of I/O buffers supplied
|
||||
int AllocNumber; // number of IoVec structs currently allocated
|
||||
size_t Size; // total size of all I/O buffers supplied
|
||||
};
|
||||
|
||||
uint64_t Muldiv64(uint64_t a, uint32_t b, uint32_t c);
|
||||
|
||||
void IoVecReset(IOVector* qiov);
|
||||
void IoVecAdd(IOVector* qiov, void* base, size_t len);
|
||||
size_t IoVecTobuffer(const IoVec* iov, const unsigned int iov_cnt, size_t offset, void *buf, size_t bytes);
|
||||
size_t IoVecFromBuffer(const IoVec* iov, unsigned int iov_cnt, size_t offset, void* buf, size_t bytes);
|
||||
|
||||
void WriteDwords(xbaddr Paddr, uint32_t* Buffer, int Number);
|
||||
void GetDwords(xbaddr Paddr, uint32_t* Buffer, int Number);
|
||||
void GetWords(xbaddr Paddr, uint16_t* Buffer, int Number);
|
||||
void WriteWords(xbaddr Paddr, uint16_t* Buffer, int Number);
|
||||
|
||||
#define GET_WORD_LOW(value) (uint8_t)((value) & 0xFF)
|
||||
#define GET_WORD_HIGH(value) (uint8_t)(((value) >> 8) & 0xFF)
|
||||
|
||||
#endif
|
|
@ -32,7 +32,7 @@
|
|||
// *
|
||||
// ******************************************************************
|
||||
|
||||
#include "CxbxCommon.h"
|
||||
#include "Cxbx.h"
|
||||
#include "CxbxKrnl/EmuShared.h"
|
||||
#include "CxbxDebugger.h"
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ namespace xboxkrnl
|
|||
#include <stdio.h> // For printf
|
||||
#include <shlobj.h> // For HANDLE, CreateFile, CreateFileMapping, MapViewOfFile
|
||||
|
||||
#include "CxbxCommon.h" // For DbgPrintf
|
||||
#include "Cxbx.h" // For DbgPrintf
|
||||
#include "EmuEEPROM.h" // For EEPROMInfo, EEPROMInfos
|
||||
#include "..\CxbxKrnl\Emu.h" // For EmuWarning
|
||||
#include "..\..\src\devices\LED.h" // For SetLEDSequence
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
#ifndef ERROR_H
|
||||
#define ERROR_H
|
||||
|
||||
#include "CxbxCommon.h"
|
||||
#include "Cxbx.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
|
|
|
@ -34,7 +34,16 @@
|
|||
// *
|
||||
// ******************************************************************
|
||||
|
||||
#define _XBOXKRNL_DEFEXTRN_
|
||||
|
||||
// prevent name collisions
|
||||
namespace xboxkrnl
|
||||
{
|
||||
#include <xboxkrnl/xboxkrnl.h> // For PKINTERRUPT, etc.
|
||||
};
|
||||
|
||||
#include "InputConfig.h"
|
||||
#include "SDL2_Device.h"
|
||||
#include "..\devices\usb\XidGamepad.h"
|
||||
#include "..\..\CxbxKrnl\EmuKrnl.h" // For EmuWarning
|
||||
#include <thread>
|
||||
|
@ -324,6 +333,7 @@ void InputDeviceManager::InputThread(InputDeviceManager* pVoid)
|
|||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -377,6 +387,7 @@ void InputDeviceManager::UpdateButtonState(SDL_JoystickID id, uint8_t button, ui
|
|||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -70,8 +70,6 @@
|
|||
|
||||
#define BUTTON_MASK(button) (1 << ((button) - GAMEPAD_DPAD_UP))
|
||||
|
||||
#include "SDL2_Device.h"
|
||||
|
||||
|
||||
/* enum indicating the device type to attach to the virtual xbox */
|
||||
typedef enum {
|
||||
|
@ -83,7 +81,10 @@ typedef enum {
|
|||
MEMORY_UNIT,
|
||||
IR_DONGLE,
|
||||
STEEL_BATTALION_CONTROLLER,
|
||||
};
|
||||
}
|
||||
XBOX_INPUT_DEVICE;
|
||||
|
||||
class SDL2Devices; // forward declare
|
||||
|
||||
|
||||
class InputDeviceManager
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
#include <sstream> // For std::stringstream
|
||||
#include <iostream> // For std::cout
|
||||
#include <iomanip> // For std::setw
|
||||
#include "CxbxCommon.h" // For g_bPrintfOn
|
||||
#include "Cxbx.h" // For g_bPrintfOn
|
||||
|
||||
|
||||
//
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
#ifndef XBAUDIO_H
|
||||
#define XBAUDIO_H
|
||||
|
||||
#include "CxbxCommon.h"
|
||||
#include "Cxbx.h"
|
||||
#include "Common/Error.h"
|
||||
#include "Mutex.h"
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
#ifndef XBCONTROLLER_H
|
||||
#define XBCONTROLLER_H
|
||||
|
||||
#include "CxbxCommon.h"
|
||||
#include "Cxbx.h"
|
||||
#include "Common/Error.h"
|
||||
#include "Mutex.h"
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
#ifndef XBVIDEO_H
|
||||
#define XBVIDEO_H
|
||||
|
||||
#include "CxbxCommon.h"
|
||||
#include "Cxbx.h"
|
||||
#include "Common/Error.h"
|
||||
#include "Mutex.h"
|
||||
|
||||
|
|
|
@ -34,10 +34,6 @@
|
|||
#ifndef CXBX_H
|
||||
#define CXBX_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <assert.h>
|
||||
#include <processthreadsapi.h>
|
||||
|
||||
#define FUNC_EXPORTS __pragma(comment(linker, "/EXPORT:" __FUNCTION__ "=" __FUNCDNAME__))
|
||||
|
||||
/*! \name primitive typedefs */
|
||||
|
@ -161,35 +157,4 @@ extern volatile bool g_bPrintfOn;
|
|||
#define CxbxSetThreadName(Name)
|
||||
#endif
|
||||
|
||||
|
||||
/* This is a linux struct for vectored I/O. See readv() and writev() */
|
||||
struct IoVec
|
||||
{
|
||||
void* Iov_Base; // Starting address
|
||||
size_t Iov_Len; // Number of bytes to transfer
|
||||
};
|
||||
|
||||
struct IOVector
|
||||
{
|
||||
IoVec* IoVecStruct;
|
||||
int IoVecNumber; // number of I/O buffers supplied
|
||||
int AllocNumber; // number of IoVec structs currently allocated
|
||||
size_t Size; // total size of all I/O buffers supplied
|
||||
};
|
||||
|
||||
inline uint64_t Muldiv64(uint64_t a, uint32_t b, uint32_t c);
|
||||
|
||||
void IoVecReset(IOVector* qiov);
|
||||
void IoVecAdd(IOVector* qiov, void* base, size_t len);
|
||||
size_t IoVecTobuffer(const IoVec* iov, const unsigned int iov_cnt, size_t offset, void *buf, size_t bytes);
|
||||
size_t IoVecFromBuffer(const IoVec* iov, unsigned int iov_cnt, size_t offset, void* buf, size_t bytes);
|
||||
|
||||
void WriteDwords(xbaddr Paddr, uint32_t* Buffer, int Number);
|
||||
void GetDwords(xbaddr Paddr, uint32_t* Buffer, int Number);
|
||||
void GetWords(xbaddr Paddr, uint16_t* Buffer, int Number);
|
||||
void WriteWords(xbaddr Paddr, uint16_t* Buffer, int Number);
|
||||
|
||||
#define GET_WORD_LOW(value) (uint8_t)((value) & 0xFF)
|
||||
#define GET_WORD_HIGH(value) (uint8_t)(((value) >> 8) & 0xFF)
|
||||
|
||||
#endif
|
|
@ -42,7 +42,7 @@
|
|||
#include <cctype>
|
||||
#include <clocale>
|
||||
|
||||
#include "CxbxCommon.h"
|
||||
#include "Cxbx.h"
|
||||
#include "Logging.h"
|
||||
|
||||
namespace xbdm {
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
#ifndef CXBXKRNL_H
|
||||
#define CXBXKRNL_H
|
||||
|
||||
#include "CxbxCommon.h"
|
||||
#include "Cxbx.h"
|
||||
#include "Common/Xbe.h"
|
||||
|
||||
#undef FIELD_OFFSET // prevent macro redefinition warnings
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
#ifndef DBGCONSOLE_H
|
||||
#define DBGCONSOLE_H
|
||||
|
||||
#include "CxbxCommon.h"
|
||||
#include "Cxbx.h"
|
||||
|
||||
// debug console input
|
||||
class DbgConsole
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "CxbxCommon.h"
|
||||
#include "Cxbx.h"
|
||||
|
||||
// dump pixel shader definition to file
|
||||
void DumpPixelShaderDefToFile( X_D3DPIXELSHADERDEF* pPSDef, const char* pszCode );
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
#ifndef VERTEXBUFFER_H
|
||||
#define VERTEXBUFFER_H
|
||||
|
||||
#include "CxbxCommon.h"
|
||||
#include "Cxbx.h"
|
||||
//#include <ctime> // Conflict with io.h
|
||||
|
||||
#define MAX_NBR_STREAMS 16
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
#ifndef VERTEXSHADER_H
|
||||
#define VERTEXSHADER_H
|
||||
|
||||
#include "CxbxCommon.h"
|
||||
#include "Cxbx.h"
|
||||
|
||||
// nv2a microcode header
|
||||
typedef struct
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
#ifndef EMUSHARED_H
|
||||
#define EMUSHARED_H
|
||||
|
||||
#include "CxbxCommon.h"
|
||||
#include "Cxbx.h"
|
||||
#include "Common/Win32/XBController.h"
|
||||
#include "Common/Win32/XBVideo.h"
|
||||
#include "Common/Win32/XBAudio.h"
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
#ifndef EMUX86_H
|
||||
#define EMUX86_H
|
||||
|
||||
#include "CxbxCommon.h"
|
||||
#include "Cxbx.h"
|
||||
#include <cstdint>
|
||||
#include <windows.h>
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ namespace xboxkrnl
|
|||
#include <xboxkrnl/xboxkrnl.h>
|
||||
};
|
||||
|
||||
#include "CxbxCommon.h" // For CxbxKrnl_KernelThunkTable
|
||||
#include "Cxbx.h" // For CxbxKrnl_KernelThunkTable
|
||||
#include "CxbxKrnl.h" // For UINT
|
||||
|
||||
#define FUNC(f) f
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
#ifndef RESOURCETRACKER_H
|
||||
#define RESOURCETRACKER_H
|
||||
|
||||
#include "CxbxCommon.h"
|
||||
#include "Cxbx.h"
|
||||
#include "Common/Win32/Mutex.h"
|
||||
|
||||
extern class ResourceTracker : public Mutex
|
||||
|
|
|
@ -72,7 +72,7 @@ inline uint64_t GetTime_NS(TimerObject* Timer)
|
|||
clock_gettime(CLOCK_MONOTONIC_RAW, &ts);
|
||||
uint64_t Ret = Muldiv64(ts.tv_sec, SCALE_S, 1) + ts.tv_nsec;
|
||||
#else
|
||||
#error
|
||||
#error "Unsupported OS"
|
||||
#endif
|
||||
return Timer->Type == CLOCK_REALTIME ? Ret : Ret / Timer->SlowdownFactor;
|
||||
}
|
||||
|
@ -162,6 +162,6 @@ void Timer_Init()
|
|||
#elif __linux__
|
||||
ClockFrequency = 0;
|
||||
#else
|
||||
#error
|
||||
#error "Unsupported OS"
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
// ******************************************************************
|
||||
|
||||
#include "Xbox.h" // For HardwareModel
|
||||
#include "Xbe.h" // Without this HLEIntercept complains about some undefined xbe variables
|
||||
#include "..\CxbxKrnl\HLEIntercept.h"
|
||||
|
||||
PCIBus* g_PCIBus;
|
||||
|
|
|
@ -34,8 +34,17 @@
|
|||
// *
|
||||
// ******************************************************************
|
||||
|
||||
#define _XBOXKRNL_DEFEXTRN_
|
||||
|
||||
// prevent name collisions
|
||||
namespace xboxkrnl
|
||||
{
|
||||
#include <xboxkrnl/xboxkrnl.h> // For PKINTERRUPT, etc.
|
||||
};
|
||||
|
||||
#include "OHCI.h"
|
||||
#include "Hub.h"
|
||||
#include "CxbxKrnl\EmuKrnl.h" // For EmuWarning
|
||||
|
||||
#define LOG_STR_HUB "Hub"
|
||||
|
||||
|
@ -96,62 +105,61 @@ struct USBHubState {
|
|||
USBHubPort ports[NUM_PORTS]; // downstream ports of the hub
|
||||
};
|
||||
|
||||
USBDescIface::USBDescIface()
|
||||
{
|
||||
std::memset(this, 0, sizeof(USBDescIface));
|
||||
eps = new USBDescEndpoint();
|
||||
bInterfaceNumber = 0;
|
||||
bNumEndpoints = 1;
|
||||
bInterfaceClass = USB_CLASS_HUB;
|
||||
eps->bEndpointAddress = USB_DIR_IN | 0x01;
|
||||
eps->bmAttributes = USB_ENDPOINT_XFER_INT;
|
||||
eps->wMaxPacketSize = 1 + (NUM_PORTS + 7) / 8;
|
||||
eps->bInterval = 0xFF;
|
||||
}
|
||||
static const USBDescEndpoint desc_endp_hub = {
|
||||
USB_DIR_IN | 0x01, // bEndpointAddress;
|
||||
USB_ENDPOINT_XFER_INT, // bmAttributes;
|
||||
1 + (NUM_PORTS + 7) / 8, // wMaxPacketSize;
|
||||
0xFF, // bInterval;
|
||||
0, // bRefresh;
|
||||
0, // bSynchAddress
|
||||
0, // is_audio
|
||||
nullptr // extra
|
||||
};
|
||||
|
||||
static const USBDescIface desc_iface_hub = {
|
||||
0, // bInterfaceNumber;
|
||||
0, // bAlternateSetting;
|
||||
1, // bNumEndpoints;
|
||||
USB_CLASS_HUB, // bInterfaceClass;
|
||||
0, // bInterfaceSubClass
|
||||
0, // bInterfaceProtocol
|
||||
0, // iInterface
|
||||
0, // ndesc
|
||||
nullptr, // descs
|
||||
&desc_endp_hub
|
||||
};
|
||||
|
||||
USBDescIface::~USBDescIface()
|
||||
{
|
||||
delete eps;
|
||||
}
|
||||
|
||||
static const USBDescIface desc_iface_hub;
|
||||
|
||||
USBDescDevice::USBDescDevice()
|
||||
{
|
||||
std::memset(this, 0, sizeof(USBDescDevice));
|
||||
USBDescConfig* pUSBDescConfig = new USBDescConfig();
|
||||
bcdUSB = 0x0110;
|
||||
bDeviceClass = USB_CLASS_HUB;
|
||||
bMaxPacketSize0 = 8;
|
||||
bNumConfigurations = 1;
|
||||
pUSBDescConfig->bNumInterfaces = 1;
|
||||
pUSBDescConfig->bConfigurationValue = 1;
|
||||
pUSBDescConfig->bmAttributes = 0xE0;
|
||||
pUSBDescConfig->nif = 1;
|
||||
pUSBDescConfig->ifs = &desc_iface_hub;
|
||||
confs = pUSBDescConfig;
|
||||
}
|
||||
|
||||
USBDescDevice::~USBDescDevice()
|
||||
{
|
||||
delete confs;
|
||||
}
|
||||
|
||||
static const USBDescDevice desc_device_hub;
|
||||
|
||||
USBDesc::USBDesc()
|
||||
{
|
||||
std::memset(this, 0, sizeof(USBDesc));
|
||||
id.idVendor = 0x0409;
|
||||
id.idProduct = 0x55AA;
|
||||
id.bcdDevice = 0x0101;
|
||||
id.iManufacturer = STR_MANUFACTURER;
|
||||
id.iProduct = STR_PRODUCT;
|
||||
id.iSerialNumber = STR_SERIALNUMBER;
|
||||
full = &desc_device_hub;
|
||||
}
|
||||
|
||||
static const USBDesc desc_hub;
|
||||
static const USBDescConfig desc_config_hub = {
|
||||
1, // bNumInterfaces
|
||||
1, // bConfigurationValue
|
||||
0, // iConfiguration
|
||||
0xE0, // bmAttributes
|
||||
0, // bMaxPower
|
||||
1, // nif
|
||||
&desc_iface_hub
|
||||
};
|
||||
|
||||
static const USBDescDevice desc_device_hub = {
|
||||
0x0110, // bcdUSB
|
||||
USB_CLASS_HUB, // bDeviceClass
|
||||
0, // bDeviceSubClass
|
||||
0, // bDeviceProtocol
|
||||
8, // bMaxPacketSize0
|
||||
1, // bNumConfigurations
|
||||
&desc_config_hub
|
||||
};
|
||||
|
||||
static const USBDesc desc_hub = {
|
||||
{
|
||||
0x0409, // idVendor
|
||||
0x55AA, // idProduct
|
||||
0x0101, // bcdDevice
|
||||
STR_MANUFACTURER, // iManufacturer
|
||||
STR_PRODUCT, // iProduct
|
||||
STR_SERIALNUMBER // iSerialNumber
|
||||
},
|
||||
&desc_device_hub
|
||||
};
|
||||
|
||||
// Class-specific hub descriptor. Remember to update DeviceRemovable and PortPwrCtrlMask if you change NUM_PORTS since their values depend on
|
||||
// the number of downstream ports available on the hub! Also note that this descriptor cannot be put in the descs member of the interface descriptor
|
||||
|
|
|
@ -33,9 +33,18 @@
|
|||
// * All rights reserved
|
||||
// *
|
||||
// ******************************************************************
|
||||
|
||||
#define _XBOXKRNL_DEFEXTRN_
|
||||
|
||||
/* prevent name collisions */
|
||||
namespace xboxkrnl
|
||||
{
|
||||
#include <xboxkrnl/xboxkrnl.h>
|
||||
};
|
||||
|
||||
#include "OHCI.h"
|
||||
#include "CxbxKrnl\EmuKrnl.h" // For HalSystemInterrupt
|
||||
#include "CxbxKrnl\EmuKrnl.h" // For HalSystemInterrupt
|
||||
#include "CxbxCommon.h"
|
||||
|
||||
#define LOG_STR_OHCI "Ohci"
|
||||
|
||||
|
|
|
@ -33,10 +33,19 @@
|
|||
// * All rights reserved
|
||||
// *
|
||||
// ******************************************************************
|
||||
|
||||
#define _XBOXKRNL_DEFEXTRN_
|
||||
|
||||
// prevent name collisions
|
||||
namespace xboxkrnl
|
||||
{
|
||||
#include <xboxkrnl/xboxkrnl.h> // For PKINTERRUPT, etc.
|
||||
};
|
||||
|
||||
#include "USBDevice.h"
|
||||
#include "OHCI.h"
|
||||
#include "CxbxKrnl\EmuKrnl.h" // For EmuWarning
|
||||
#include "CxbxKrnl\EmuKrnl.h" // For EmuWarning
|
||||
#include "CxbxCommon.h"
|
||||
|
||||
#define LOG_STR_USB "Usb"
|
||||
|
||||
|
@ -628,7 +637,7 @@ void USBDevice::USB_EPsetType(XboxDeviceState* dev, int pid, int ep, uint8_t typ
|
|||
uep->Type = type;
|
||||
}
|
||||
|
||||
uint8_t USBDevice::USB_EPsetIfnum(XboxDeviceState* dev, int pid, int ep, uint8_t ifnum)
|
||||
void USBDevice::USB_EPsetIfnum(XboxDeviceState* dev, int pid, int ep, uint8_t ifnum)
|
||||
{
|
||||
USBEndpoint* uep = USB_GetEP(dev, pid, ep);
|
||||
uep->IfNum = ifnum;
|
||||
|
@ -1031,7 +1040,7 @@ int USBDevice::USBDesc_HandleStandardGetDescriptor(XboxDeviceState* dev, USBPack
|
|||
break;
|
||||
}
|
||||
|
||||
// Dropped from XQEMU descriptor types USB_DT_DEVICE_QUALIFIER (6), USB_DT_OTHER_SPEED_CONFIG (7) -> usb 2.0 only and reserved on usb 3.0,
|
||||
// Dropped from XQEMU descriptor types USB_DT_DEVICE_QUALIFIER (6), USB_DT_OTHER_SPEED_CONFIG (7) -> usb 2.0 only and reserved in usb 3.0,
|
||||
// USB_DT_BOS (15) and USB_DT_DEBUG (10) -> usb 3.0 only
|
||||
|
||||
default:
|
||||
|
@ -1168,9 +1177,9 @@ int USBDevice::USB_ReadInterfaceDesc(const USBDescIface* iface, int flags, uint8
|
|||
return pos;
|
||||
}
|
||||
|
||||
int USBDevice::USB_ReadOtherDesc(const USBDescOther* desc, uint8_t* dest, size_t len)
|
||||
size_t USBDevice::USB_ReadOtherDesc(const USBDescOther* desc, uint8_t* dest, size_t len)
|
||||
{
|
||||
int bLength = desc->length ? desc->length : desc->data[0];
|
||||
size_t bLength = desc->length ? desc->length : desc->data[0];
|
||||
|
||||
if (len < bLength) {
|
||||
return -1;
|
||||
|
@ -1182,15 +1191,15 @@ int USBDevice::USB_ReadOtherDesc(const USBDescOther* desc, uint8_t* dest, size_t
|
|||
|
||||
int USBDevice::USB_ReadEndpointDesc(const USBDescEndpoint* ep, int flags, uint8_t* dest, size_t len)
|
||||
{
|
||||
uint8_t bLength = ep->is_audio ? 0x09 : 0x07; // an endpoint descriptor is 7 bytes large (or 9 if it is an audio device)
|
||||
uint8_t extralen = ep->extra ? ep->extra[0] : 0;
|
||||
size_t bLength = ep->is_audio ? 0x09 : 0x07; // an endpoint descriptor is 7 bytes large (or 9 if it is an audio device)
|
||||
size_t extralen = ep->extra ? ep->extra[0] : 0;
|
||||
USBDescriptor* d = reinterpret_cast<USBDescriptor*>(dest);
|
||||
|
||||
if (len < bLength + extralen) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
d->bLength = bLength;
|
||||
d->bLength = static_cast<uint8_t>(bLength);
|
||||
d->bDescriptorType = USB_DT_ENDPOINT;
|
||||
|
||||
d->u.endpoint.bEndpointAddress = ep->bEndpointAddress;
|
||||
|
@ -1214,7 +1223,8 @@ int USBDevice::USB_ReadEndpointDesc(const USBDescEndpoint* ep, int flags, uint8_
|
|||
|
||||
int USBDevice::USB_ReadStringDesc(XboxDeviceState* dev, int index, uint8_t* dest, size_t len)
|
||||
{
|
||||
uint8_t bLength, pos, i;
|
||||
size_t bLength, i;
|
||||
unsigned int pos;
|
||||
const char* str;
|
||||
|
||||
if (len < 4) {
|
||||
|
|
|
@ -57,7 +57,7 @@ class USBDevice : public PCIDevice {
|
|||
void Init(unsigned int address);
|
||||
void Reset() {}
|
||||
|
||||
uint32_t IORead(int barIndex, uint32_t port, unsigned size) {}
|
||||
uint32_t IORead(int barIndex, uint32_t port, unsigned size) { return 0; }
|
||||
void IOWrite(int barIndex, uint32_t port, uint32_t value, unsigned size) {}
|
||||
uint32_t MMIORead(int barIndex, uint32_t addr, unsigned size);
|
||||
void MMIOWrite(int barIndex, uint32_t addr, uint32_t value, unsigned size);
|
||||
|
@ -146,7 +146,7 @@ class USBDevice : public PCIDevice {
|
|||
// set the type of the endpoint
|
||||
void USB_EPsetType(XboxDeviceState* dev, int pid, int ep, uint8_t type);
|
||||
// set the interface number of the endpoint
|
||||
uint8_t USB_EPsetIfnum(XboxDeviceState* dev, int pid, int ep, uint8_t ifnum);
|
||||
void USB_EPsetIfnum(XboxDeviceState* dev, int pid, int ep, uint8_t ifnum);
|
||||
// set the maximum packet size parameter of the endpoint
|
||||
void USB_EPsetMaxPacketSize(XboxDeviceState* dev, int pid, int ep, uint16_t raw);
|
||||
// assign port numbers (also for hubs)
|
||||
|
@ -184,7 +184,7 @@ class USBDevice : public PCIDevice {
|
|||
// return the binary rapresentation of interface descriptors
|
||||
int USB_ReadInterfaceDesc(const USBDescIface* iface, int flags, uint8_t* dest, size_t len);
|
||||
// return the binary rapresentation of class-specific descriptors
|
||||
int USB_ReadOtherDesc(const USBDescOther* desc, uint8_t* dest, size_t len);
|
||||
size_t USB_ReadOtherDesc(const USBDescOther* desc, uint8_t* dest, size_t len);
|
||||
// return the binary rapresentation of endpoint descriptors
|
||||
int USB_ReadEndpointDesc(const USBDescEndpoint* ep, int flags, uint8_t* dest, size_t len);
|
||||
// return the binary rapresentation of string descriptors
|
||||
|
|
|
@ -39,7 +39,6 @@
|
|||
|
||||
#include "CxbxCommon.h"
|
||||
#include "..\devices\video\queue.h"
|
||||
#include "..\CxbxKrnl\EmuKrnl.h" // For EmuWarning
|
||||
#include <functional>
|
||||
|
||||
#define USB_MAX_ENDPOINTS 15
|
||||
|
@ -157,10 +156,13 @@ typedef enum {
|
|||
STR_MANUFACTURER = 1,
|
||||
STR_PRODUCT,
|
||||
STR_SERIALNUMBER,
|
||||
};
|
||||
}
|
||||
STRING_DESC_INDEX;
|
||||
|
||||
// Forward declarations
|
||||
struct USBPacket;
|
||||
struct XboxDeviceState;
|
||||
struct USBPortOps;
|
||||
|
||||
/* String descriptor */
|
||||
struct USBDescString {
|
||||
|
@ -203,9 +205,7 @@ struct USBDescIface {
|
|||
|
||||
uint8_t ndesc; // number of device-specific class descriptors (if any)
|
||||
USBDescOther* descs; // pointer to the extra class descriptors
|
||||
USBDescEndpoint* eps; // endpoints supported by this interface
|
||||
USBDescIface();
|
||||
~USBDescIface();
|
||||
const USBDescEndpoint* eps; // endpoints supported by this interface
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -234,8 +234,6 @@ struct USBDescDevice {
|
|||
uint8_t bMaxPacketSize0; // maximum packet size for endpoint zero (only 8, 16, 32, or 64 are valid)
|
||||
uint8_t bNumConfigurations; // number of possible configurations
|
||||
const USBDescConfig* confs; // configurations supported by this device
|
||||
USBDescDevice();
|
||||
~USBDescDevice();
|
||||
};
|
||||
|
||||
/* Device descriptor part 2 */
|
||||
|
@ -252,7 +250,6 @@ struct USBDescID {
|
|||
struct USBDesc {
|
||||
USBDescID id; // id-specific info of the device descriptor
|
||||
const USBDescDevice* full; // remaining fields of the device descriptor
|
||||
USBDesc();
|
||||
};
|
||||
|
||||
#pragma pack(1)
|
||||
|
@ -326,6 +323,63 @@ struct USBEndpoint {
|
|||
QTAILQ_HEAD(, USBPacket) Queue; // queue of packets to this endpoint
|
||||
};
|
||||
|
||||
/* Struct describing the status of a usb port */
|
||||
struct USBPort {
|
||||
XboxDeviceState* Dev; // usb device (if present)
|
||||
USBPortOps* Operations; // functions to call when a port event happens
|
||||
int SpeedMask; // usb speeds supported
|
||||
std::string Path; // the number of the port + 1, used to create a serial number for this device
|
||||
int PortIndex; // internal port index
|
||||
};
|
||||
|
||||
/* Struct which stores general functions/variables regarding the peripheral */
|
||||
struct USBDeviceClass {
|
||||
std::function<int(XboxDeviceState* dev)> init;
|
||||
|
||||
// Walk (enabled) downstream ports, check for a matching device.
|
||||
// Only hubs implement this.
|
||||
std::function<XboxDeviceState*(XboxDeviceState* dev, uint8_t addr)> find_device;
|
||||
|
||||
// Called when a packet is canceled.
|
||||
std::function<void(XboxDeviceState* dev, USBPacket* p)> cancel_packet;
|
||||
|
||||
// Called when device is destroyed.
|
||||
std::function<void(void)> handle_destroy;
|
||||
|
||||
// Attach the device
|
||||
std::function<void(XboxDeviceState* dev)> handle_attach;
|
||||
|
||||
// Reset the device
|
||||
std::function<void(XboxDeviceState* dev)> handle_reset;
|
||||
|
||||
// Process control request.
|
||||
// Called from handle_packet().
|
||||
// Status gets stored in p->status, and if p->status == USB_RET_SUCCESS
|
||||
// then the number of bytes transferred is stored in p->actual_length
|
||||
std::function<void(XboxDeviceState* dev, USBPacket* p, int request, int value,
|
||||
int index, int length, uint8_t *data)> handle_control;
|
||||
|
||||
// Process data transfers (both BULK and ISOC).
|
||||
// Called from handle_packet().
|
||||
// Status gets stored in p->status, and if p->status == USB_RET_SUCCESS
|
||||
// then the number of bytes transferred is stored in p->actual_length
|
||||
std::function<void(XboxDeviceState* dev, USBPacket* p)> handle_data;
|
||||
|
||||
std::function<void(XboxDeviceState* dev, int Interface,
|
||||
int alt_old, int alt_new)> set_interface;
|
||||
|
||||
// Called when the hcd is done queuing packets for an endpoint, only
|
||||
// necessary for devices which can return USB_RET_ADD_TO_QUEUE.
|
||||
std::function<void(XboxDeviceState* dev, USBEndpoint* ep)> flush_ep_queue;
|
||||
|
||||
// Called by the hcd to let the device know the queue for an endpoint
|
||||
// has been unlinked / stopped. Optional may be NULL.
|
||||
std::function<void(XboxDeviceState* Dev, USBEndpoint* EP)> ep_stopped;
|
||||
|
||||
const char* product_desc; // friendly name of the device
|
||||
const USBDesc* usb_desc; // device descriptor
|
||||
};
|
||||
|
||||
/* definition of an Xbox usb device */
|
||||
struct XboxDeviceState {
|
||||
USBPort* Port; // usb port struct of this device
|
||||
|
@ -402,61 +456,4 @@ struct USBPortOps {
|
|||
std::function<void(USBPort* port, USBPacket* p)> complete;
|
||||
};
|
||||
|
||||
/* Struct describing the status of a usb port */
|
||||
struct USBPort {
|
||||
XboxDeviceState* Dev; // usb device (if present)
|
||||
USBPortOps* Operations; // functions to call when a port event happens
|
||||
int SpeedMask; // usb speeds supported
|
||||
std::string Path; // the number of the port + 1, used to create a serial number for this device
|
||||
int PortIndex; // internal port index
|
||||
};
|
||||
|
||||
/* Struct which stores general functions/variables regarding the peripheral */
|
||||
struct USBDeviceClass {
|
||||
std::function<int(XboxDeviceState* dev)> init;
|
||||
|
||||
// Walk (enabled) downstream ports, check for a matching device.
|
||||
// Only hubs implement this.
|
||||
std::function<XboxDeviceState*(XboxDeviceState* dev, uint8_t addr)> find_device;
|
||||
|
||||
// Called when a packet is canceled.
|
||||
std::function<void(XboxDeviceState* dev, USBPacket* p)> cancel_packet;
|
||||
|
||||
// Called when device is destroyed.
|
||||
std::function<void(void)> handle_destroy;
|
||||
|
||||
// Attach the device
|
||||
std::function<void(XboxDeviceState* dev)> handle_attach;
|
||||
|
||||
// Reset the device
|
||||
std::function<void(XboxDeviceState* dev)> handle_reset;
|
||||
|
||||
// Process control request.
|
||||
// Called from handle_packet().
|
||||
// Status gets stored in p->status, and if p->status == USB_RET_SUCCESS
|
||||
// then the number of bytes transferred is stored in p->actual_length
|
||||
std::function<void(XboxDeviceState* dev, USBPacket* p, int request, int value,
|
||||
int index, int length, uint8_t *data)> handle_control;
|
||||
|
||||
// Process data transfers (both BULK and ISOC).
|
||||
// Called from handle_packet().
|
||||
// Status gets stored in p->status, and if p->status == USB_RET_SUCCESS
|
||||
// then the number of bytes transferred is stored in p->actual_length
|
||||
std::function<void(XboxDeviceState* dev, USBPacket* p)> handle_data;
|
||||
|
||||
std::function<void(XboxDeviceState* dev, int Interface,
|
||||
int alt_old, int alt_new)> set_interface;
|
||||
|
||||
// Called when the hcd is done queuing packets for an endpoint, only
|
||||
// necessary for devices which can return USB_RET_ADD_TO_QUEUE.
|
||||
std::function<void(XboxDeviceState* dev, USBEndpoint* ep)> flush_ep_queue;
|
||||
|
||||
// Called by the hcd to let the device know the queue for an endpoint
|
||||
// has been unlinked / stopped. Optional may be NULL.
|
||||
std::function<void(XboxDeviceState* Dev, USBEndpoint* EP)> ep_stopped;
|
||||
|
||||
const char* product_desc; // friendly name of the device
|
||||
const USBDesc* usb_desc; // device descriptor
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -33,11 +33,21 @@
|
|||
// * All rights reserved
|
||||
// *
|
||||
// ******************************************************************
|
||||
|
||||
#define _XBOXKRNL_DEFEXTRN_
|
||||
|
||||
// prevent name collisions
|
||||
namespace xboxkrnl
|
||||
{
|
||||
#include <xboxkrnl/xboxkrnl.h> // For PKINTERRUPT, etc.
|
||||
};
|
||||
|
||||
#include "XidGamepad.h"
|
||||
#include "USBDevice.h"
|
||||
#include "Common/Input/InputConfig.h"
|
||||
#include "OHCI.h"
|
||||
#include "Common/Input/SDL2_Device.h"
|
||||
#include "OHCI.h"
|
||||
#include "CxbxKrnl\EmuKrnl.h" // For EmuWarning
|
||||
|
||||
#define LOG_STR_GAMEPAD "Gamepad:"
|
||||
|
||||
|
@ -63,7 +73,6 @@ struct XIDDesc {
|
|||
uint8_t bMaxInputReportSize;
|
||||
uint8_t bMaxOutputReportSize;
|
||||
uint16_t wAlternateProductIds[4];
|
||||
XIDDesc();
|
||||
};
|
||||
|
||||
/* Struct used by the Get_Report request -> button's state */
|
||||
|
@ -98,88 +107,86 @@ struct USBXIDState {
|
|||
XIDGamepadReport in_state_capabilities; // Get_Capabilities struct (in)
|
||||
XIDGamepadOutputReport out_state; // Set_Report struct
|
||||
XIDGamepadOutputReport out_state_capabilities; // Get_Capabilities struct (out)
|
||||
};
|
||||
|
||||
static const USBDescEndpoint desc_endp_xbox_gamepad[2] = {
|
||||
{
|
||||
USB_DIR_IN | 0x02, // bEndpointAddress;
|
||||
USB_ENDPOINT_XFER_INT, // bmAttributes;
|
||||
0x20, // wMaxPacketSize;
|
||||
4, // bInterval;
|
||||
0, // bRefresh;
|
||||
0, // bSynchAddress
|
||||
0, // is_audio
|
||||
nullptr // extra
|
||||
},
|
||||
{
|
||||
USB_DIR_OUT | 0x02,
|
||||
USB_ENDPOINT_XFER_INT,
|
||||
0x20,
|
||||
4,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
nullptr
|
||||
}
|
||||
};
|
||||
|
||||
USBDescIface::USBDescIface()
|
||||
{
|
||||
std::memset(this, 0, sizeof(USBDescIface));
|
||||
eps = new USBDescEndpoint[2]();
|
||||
bInterfaceNumber = 0;
|
||||
bNumEndpoints = 2;
|
||||
bInterfaceClass = USB_CLASS_XID;
|
||||
bInterfaceSubClass = 0x42;
|
||||
bInterfaceProtocol = 0x00;
|
||||
eps->bEndpointAddress = USB_DIR_IN | 0x02;
|
||||
eps->bmAttributes = USB_ENDPOINT_XFER_INT;
|
||||
eps->wMaxPacketSize = 0x20;
|
||||
eps->bInterval = 4;
|
||||
eps++;
|
||||
eps->bEndpointAddress = USB_DIR_OUT | 0x02;
|
||||
eps->bmAttributes = USB_ENDPOINT_XFER_INT;
|
||||
eps->wMaxPacketSize = 0x20;
|
||||
eps->bInterval = 4;
|
||||
}
|
||||
static const USBDescIface desc_iface_xbox_gamepad = {
|
||||
0, // bInterfaceNumber;
|
||||
0, // bAlternateSetting;
|
||||
2, // bNumEndpoints;
|
||||
USB_CLASS_XID, // bInterfaceClass;
|
||||
0x42, // bInterfaceSubClass
|
||||
0x00, // bInterfaceProtocol
|
||||
0, // iInterface
|
||||
0, // ndesc
|
||||
nullptr, // descs
|
||||
desc_endp_xbox_gamepad
|
||||
};
|
||||
|
||||
static const USBDescConfig desc_config_xbox_gamepad = {
|
||||
1, // bNumInterfaces
|
||||
1, // bConfigurationValue
|
||||
0, // iConfiguration
|
||||
0x80, // bmAttributes
|
||||
50, // bMaxPower
|
||||
1, // nif
|
||||
&desc_iface_xbox_gamepad
|
||||
};
|
||||
|
||||
USBDescIface::~USBDescIface()
|
||||
{
|
||||
delete[] eps;
|
||||
}
|
||||
static const USBDescDevice desc_device_xbox_gamepad = {
|
||||
0x0110, // bcdUSB
|
||||
0, // bDeviceClass
|
||||
0, // bDeviceSubClass
|
||||
0, // bDeviceProtocol
|
||||
0x40, // bMaxPacketSize0
|
||||
1, // bNumConfigurations
|
||||
&desc_config_xbox_gamepad
|
||||
};
|
||||
|
||||
static const USBDescIface desc_iface_xbox_gamepad;
|
||||
static const USBDesc desc_xbox_gamepad = {
|
||||
{
|
||||
0x045E, // idVendor
|
||||
0x0202, // idProduct
|
||||
0x0100, // bcdDevice
|
||||
STR_MANUFACTURER, // iManufacturer
|
||||
STR_PRODUCT, // iProduct
|
||||
STR_SERIALNUMBER // iSerialNumber
|
||||
},
|
||||
&desc_device_xbox_gamepad
|
||||
};
|
||||
|
||||
USBDescDevice::USBDescDevice()
|
||||
{
|
||||
std::memset(this, 0, sizeof(USBDescDevice));
|
||||
USBDescConfig* pUSBDescConfig = new USBDescConfig();
|
||||
bcdUSB = 0x0110;
|
||||
bMaxPacketSize0 = 0x40;
|
||||
bNumConfigurations = 1;
|
||||
pUSBDescConfig->bNumInterfaces = 1;
|
||||
pUSBDescConfig->bConfigurationValue = 1;
|
||||
pUSBDescConfig->bmAttributes = 0x80;
|
||||
pUSBDescConfig->bMaxPower = 50;
|
||||
pUSBDescConfig->nif = 1;
|
||||
pUSBDescConfig->ifs = &desc_iface_xbox_gamepad;
|
||||
confs = pUSBDescConfig;
|
||||
}
|
||||
|
||||
USBDescDevice::~USBDescDevice()
|
||||
{
|
||||
delete confs;
|
||||
}
|
||||
|
||||
static const USBDescDevice desc_device_xbox_gamepad;
|
||||
|
||||
USBDesc::USBDesc()
|
||||
{
|
||||
std::memset(this, 0, sizeof(USBDesc));
|
||||
id.idVendor = 0x045E;
|
||||
id.idProduct = 0x0202;
|
||||
id.bcdDevice = 0x0100;
|
||||
id.iManufacturer = STR_MANUFACTURER;
|
||||
id.iProduct = STR_PRODUCT;
|
||||
id.iSerialNumber = STR_SERIALNUMBER;
|
||||
full = &desc_device_xbox_gamepad;
|
||||
}
|
||||
|
||||
static const USBDesc desc_xbox_gamepad;
|
||||
|
||||
XIDDesc::XIDDesc()
|
||||
{
|
||||
bLength = 0x10;
|
||||
bDescriptorType = USB_DT_XID;
|
||||
bcdXid = 0x100;
|
||||
bType = 1;
|
||||
bSubType = 1;
|
||||
bMaxInputReportSize = 20;
|
||||
bMaxOutputReportSize = 6;
|
||||
wAlternateProductIds[0] = 0xFFFF;
|
||||
wAlternateProductIds[1] = 0xFFFF;
|
||||
wAlternateProductIds[2] = 0xFFFF;
|
||||
wAlternateProductIds[3] = 0xFFFF;
|
||||
}
|
||||
|
||||
static const XIDDesc desc_xid_xbox_gamepad;
|
||||
static const XIDDesc desc_xid_xbox_gamepad = {
|
||||
0x10, // bLength
|
||||
USB_DT_XID, // bDescriptorType
|
||||
0x100, // bcdXid
|
||||
1, // bType
|
||||
1, // bSubType
|
||||
20, // bMaxInputReportSize
|
||||
6, // bMaxOutputReportSize
|
||||
{ 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF } // wAlternateProductIds
|
||||
};
|
||||
|
||||
int XidGamepad::Init(int port)
|
||||
{
|
||||
|
@ -229,7 +236,6 @@ XboxDeviceState* XidGamepad::ClassInitFn()
|
|||
int XidGamepad::UsbXidClaimPort(XboxDeviceState* dev, int port)
|
||||
{
|
||||
int i;
|
||||
int port_offset;
|
||||
std::vector<USBPort*>::iterator it;
|
||||
|
||||
assert(dev->Port == nullptr);
|
||||
|
@ -525,7 +531,7 @@ void XidGamepad::XidCleanUp()
|
|||
void XidGamepad::UpdateForceFeedback()
|
||||
{
|
||||
// JayFoxRox's remarks: "Xbox -> XID packets were not tested
|
||||
// The handling out output packets / force feedback was not checked."
|
||||
// The handling of output packets / force feedback was not checked."
|
||||
// For the above reason we don't implement vibration support for now since the current
|
||||
// implementation is untested and could potentially contain errors
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
#include "glib_compat.h" // For GHashTable, g_hash_table_new, g_hash_table_lookup, g_hash_table_insert
|
||||
#endif
|
||||
|
||||
#include "CxbxCommon.h" // For xbaddr
|
||||
#include "Cxbx.h" // For xbaddr
|
||||
#include "devices\PCIDevice.h" // For PCIDevice
|
||||
|
||||
#include <queue>
|
||||
|
|
Loading…
Reference in New Issue