mirror of https://github.com/PCSX2/pcsx2.git
commit
c03b388786
|
@ -70,7 +70,7 @@ PenaltyBreakFirstLessLess: 120
|
||||||
PenaltyBreakString: 1000
|
PenaltyBreakString: 1000
|
||||||
PenaltyExcessCharacter: 1000000
|
PenaltyExcessCharacter: 1000000
|
||||||
PenaltyReturnTypeOnItsOwnLine: 60
|
PenaltyReturnTypeOnItsOwnLine: 60
|
||||||
PointerAlignment: Left
|
PointerAlignment: Right
|
||||||
ReflowComments: true
|
ReflowComments: true
|
||||||
SortIncludes: false
|
SortIncludes: false
|
||||||
SpaceAfterCStyleCast: false
|
SpaceAfterCStyleCast: false
|
||||||
|
|
|
@ -5,6 +5,18 @@ set -x
|
||||||
|
|
||||||
ret=0
|
ret=0
|
||||||
|
|
||||||
|
if command -v clang-format-3.8 > /dev/null ; then
|
||||||
|
clang_format=clang-format-3.8
|
||||||
|
else
|
||||||
|
if command -v clang-format > /dev/null ; then
|
||||||
|
clang_format=clang-format
|
||||||
|
else
|
||||||
|
return 2;
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
$clang_format -version
|
||||||
|
|
||||||
# Doesn't work as travis only populate a single branch history
|
# Doesn't work as travis only populate a single branch history
|
||||||
|
|
||||||
#branch=`git rev-parse --abbrev-ref HEAD`
|
#branch=`git rev-parse --abbrev-ref HEAD`
|
||||||
|
@ -36,7 +48,6 @@ files=`git diff --name-only --diff-filter=ACMRT $diff_range -- $PWD | \
|
||||||
grep -v "${1}common/" | \
|
grep -v "${1}common/" | \
|
||||||
grep -v "${1}pcsx2/" | \
|
grep -v "${1}pcsx2/" | \
|
||||||
grep -v "${1}plugins/cdvdGigaherz/" | \
|
grep -v "${1}plugins/cdvdGigaherz/" | \
|
||||||
grep -v "${1}plugins/CDVDiso/" | \
|
|
||||||
grep -v "${1}plugins/CDVDisoEFP/" | \
|
grep -v "${1}plugins/CDVDisoEFP/" | \
|
||||||
grep -v "${1}plugins/CDVDlinuz/" | \
|
grep -v "${1}plugins/CDVDlinuz/" | \
|
||||||
grep -v "${1}plugins/CDVDolio/" | \
|
grep -v "${1}plugins/CDVDolio/" | \
|
||||||
|
@ -44,8 +55,6 @@ files=`git diff --name-only --diff-filter=ACMRT $diff_range -- $PWD | \
|
||||||
grep -v "${1}plugins/dev9ghzdrk/" | \
|
grep -v "${1}plugins/dev9ghzdrk/" | \
|
||||||
grep -v "${1}plugins/GSdx/" | \
|
grep -v "${1}plugins/GSdx/" | \
|
||||||
grep -v "${1}plugins/GSdx_legacy/" | \
|
grep -v "${1}plugins/GSdx_legacy/" | \
|
||||||
grep -v "${1}plugins/LilyPad/" | \
|
|
||||||
grep -v "${1}plugins/onepad/" | \
|
|
||||||
grep -v "${1}plugins/PeopsSPU2/" | \
|
grep -v "${1}plugins/PeopsSPU2/" | \
|
||||||
grep -v "${1}plugins/spu2-x/" | \
|
grep -v "${1}plugins/spu2-x/" | \
|
||||||
grep -v "${1}plugins/SSSPSXPAD/" | \
|
grep -v "${1}plugins/SSSPSXPAD/" | \
|
||||||
|
@ -67,7 +76,7 @@ files=`git diff --name-only --diff-filter=ACMRT $diff_range -- $PWD | \
|
||||||
# Check remaining files are clang-format compliant
|
# Check remaining files are clang-format compliant
|
||||||
for f in $files
|
for f in $files
|
||||||
do
|
do
|
||||||
clang-format -style=file -output-replacements-xml $f | grep "<replacement " >/dev/null
|
$clang_format -style=file -output-replacements-xml $f | grep "<replacement " >/dev/null
|
||||||
if [ $? -ne 1 ]
|
if [ $? -ne 1 ]
|
||||||
then
|
then
|
||||||
echo "file $f did not match clang-format"
|
echo "file $f did not match clang-format"
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#define __CDVDISO_H__
|
#define __CDVDISO_H__
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#pragma warning(disable:4018)
|
#pragma warning(disable : 4018)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "PS2Edefs.h"
|
#include "PS2Edefs.h"
|
||||||
|
@ -31,7 +31,7 @@
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#define EXPORT_C_(type) extern "C" __declspec(dllexport) type CALLBACK
|
#define EXPORT_C_(type) extern "C" __declspec(dllexport) type CALLBACK
|
||||||
#else
|
#else
|
||||||
#define EXPORT_C_(type) extern "C" __attribute__((stdcall,externally_visible,visibility("default"))) type
|
#define EXPORT_C_(type) extern "C" __attribute__((stdcall, externally_visible, visibility("default"))) type
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
@ -39,40 +39,61 @@
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#define EXPORT_C_(type) __declspec(dllexport) type __stdcall
|
#define EXPORT_C_(type) __declspec(dllexport) type __stdcall
|
||||||
#else
|
#else
|
||||||
#define EXPORT_C_(type) __attribute__((stdcall,externally_visible,visibility("default"))) type
|
#define EXPORT_C_(type) __attribute__((stdcall, externally_visible, visibility("default"))) type
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
EXPORT_C_(u32) PS2EgetLibType();
|
EXPORT_C_(u32)
|
||||||
EXPORT_C_(u32) PS2EgetLibVersion2(u32 type);
|
PS2EgetLibType();
|
||||||
EXPORT_C_(char*) PS2EgetLibName();
|
EXPORT_C_(u32)
|
||||||
|
PS2EgetLibVersion2(u32 type);
|
||||||
|
EXPORT_C_(char *)
|
||||||
|
PS2EgetLibName();
|
||||||
|
|
||||||
|
|
||||||
EXPORT_C_(s32) CDVDinit();
|
EXPORT_C_(s32)
|
||||||
EXPORT_C_(s32) CDVDopen(const char* pTitleFilename);
|
CDVDinit();
|
||||||
EXPORT_C_(void) CDVDclose();
|
EXPORT_C_(s32)
|
||||||
EXPORT_C_(void) CDVDshutdown();
|
CDVDopen(const char *pTitleFilename);
|
||||||
EXPORT_C_(s32) CDVDreadTrack(u32 lsn, int mode);
|
EXPORT_C_(void)
|
||||||
|
CDVDclose();
|
||||||
|
EXPORT_C_(void)
|
||||||
|
CDVDshutdown();
|
||||||
|
EXPORT_C_(s32)
|
||||||
|
CDVDreadTrack(u32 lsn, int mode);
|
||||||
|
|
||||||
// return can be NULL (for async modes)
|
// return can be NULL (for async modes)
|
||||||
EXPORT_C_(u8*) CDVDgetBuffer();
|
EXPORT_C_(u8 *)
|
||||||
|
CDVDgetBuffer();
|
||||||
|
|
||||||
EXPORT_C_(s32) CDVDreadSubQ(u32 lsn, cdvdSubQ* subq);//read subq from disc (only cds have subq data)
|
EXPORT_C_(s32)
|
||||||
EXPORT_C_(s32) CDVDgetTN(cdvdTN *Buffer); //disk information
|
CDVDreadSubQ(u32 lsn, cdvdSubQ *subq); //read subq from disc (only cds have subq data)
|
||||||
EXPORT_C_(s32) CDVDgetTD(u8 Track, cdvdTD *Buffer); //track info: min,sec,frame,type
|
EXPORT_C_(s32)
|
||||||
EXPORT_C_(s32) CDVDgetTOC(void* toc); //gets ps2 style toc from disc
|
CDVDgetTN(cdvdTN *Buffer); //disk information
|
||||||
EXPORT_C_(s32) CDVDgetDiskType(); //CDVD_TYPE_xxxx
|
EXPORT_C_(s32)
|
||||||
EXPORT_C_(s32) CDVDgetTrayStatus(); //CDVD_TRAY_xxxx
|
CDVDgetTD(u8 Track, cdvdTD *Buffer); //track info: min,sec,frame,type
|
||||||
EXPORT_C_(s32) CDVDctrlTrayOpen(); //open disc tray
|
EXPORT_C_(s32)
|
||||||
EXPORT_C_(s32) CDVDctrlTrayClose(); //close disc tray
|
CDVDgetTOC(void *toc); //gets ps2 style toc from disc
|
||||||
|
EXPORT_C_(s32)
|
||||||
|
CDVDgetDiskType(); //CDVD_TYPE_xxxx
|
||||||
|
EXPORT_C_(s32)
|
||||||
|
CDVDgetTrayStatus(); //CDVD_TRAY_xxxx
|
||||||
|
EXPORT_C_(s32)
|
||||||
|
CDVDctrlTrayOpen(); //open disc tray
|
||||||
|
EXPORT_C_(s32)
|
||||||
|
CDVDctrlTrayClose(); //close disc tray
|
||||||
|
|
||||||
// extended funcs
|
// extended funcs
|
||||||
|
|
||||||
EXPORT_C_(void) CDVDconfigure();
|
EXPORT_C_(void)
|
||||||
EXPORT_C_(void) CDVDabout();
|
CDVDconfigure();
|
||||||
EXPORT_C_(s32) CDVDtest();
|
EXPORT_C_(void)
|
||||||
EXPORT_C_(void) CDVDnewDiskCB(void (*callback)());
|
CDVDabout();
|
||||||
|
EXPORT_C_(s32)
|
||||||
|
CDVDtest();
|
||||||
|
EXPORT_C_(void)
|
||||||
|
CDVDnewDiskCB(void (*callback)());
|
||||||
|
|
||||||
#define CDVD_LOG __Log
|
#define CDVD_LOG __Log
|
||||||
extern FILE *cdvdLog;
|
extern FILE *cdvdLog;
|
||||||
|
@ -81,29 +102,29 @@ void __Log(char *fmt, ...);
|
||||||
|
|
||||||
#define VERBOSE 1
|
#define VERBOSE 1
|
||||||
|
|
||||||
#define DEV_DEF ""
|
#define DEV_DEF ""
|
||||||
#define CDDEV_DEF "/dev/cdrom"
|
#define CDDEV_DEF "/dev/cdrom"
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int slsn;
|
int slsn;
|
||||||
int elsn;
|
int elsn;
|
||||||
#ifdef _WINDOWS_
|
#ifdef _WINDOWS_
|
||||||
HANDLE handle;
|
HANDLE handle;
|
||||||
#else
|
#else
|
||||||
FILE *handle;
|
FILE *handle;
|
||||||
#endif
|
#endif
|
||||||
} _cdIso;
|
} _cdIso;
|
||||||
|
|
||||||
extern _cdIso cdIso[8];
|
extern _cdIso cdIso[8];
|
||||||
|
|
||||||
#define CD_FRAMESIZE_RAW 2352
|
#define CD_FRAMESIZE_RAW 2352
|
||||||
#define DATA_SIZE (CD_FRAMESIZE_RAW-12)
|
#define DATA_SIZE (CD_FRAMESIZE_RAW - 12)
|
||||||
|
|
||||||
#define itob(i) ((i)/10*16 + (i)%10) /* u_char to BCD */
|
#define itob(i) ((i) / 10 * 16 + (i) % 10) /* u_char to BCD */
|
||||||
#define btoi(b) ((b)/16*10 + (b)%16) /* BCD to u_char */
|
#define btoi(b) ((b) / 16 * 10 + (b) % 16) /* BCD to u_char */
|
||||||
|
|
||||||
#define MSF2SECT(m,s,f) (((m)*60+(s)-2)*75+(f))
|
#define MSF2SECT(m, s, f) (((m)*60 + (s)-2) * 75 + (f))
|
||||||
|
|
||||||
extern const u8 version;
|
extern const u8 version;
|
||||||
extern const u8 revision;
|
extern const u8 revision;
|
||||||
|
@ -125,8 +146,8 @@ extern int cdoffset;
|
||||||
extern int cdtype;
|
extern int cdtype;
|
||||||
extern int cdblocks;
|
extern int cdblocks;
|
||||||
|
|
||||||
extern int Zmode; // 1 Z - 2 bz2
|
extern int Zmode; // 1 Z - 2 bz2
|
||||||
extern int fmode; // 0 - file / 1 - Zfile
|
extern int fmode; // 0 - file / 1 - Zfile
|
||||||
extern char *Ztable;
|
extern char *Ztable;
|
||||||
|
|
||||||
extern char *methods[];
|
extern char *methods[];
|
||||||
|
|
|
@ -26,8 +26,8 @@ int cdoffset;
|
||||||
int cdtype;
|
int cdtype;
|
||||||
int cdblocks;
|
int cdblocks;
|
||||||
|
|
||||||
int Zmode; // 1 Z - 2 bz2
|
int Zmode; // 1 Z - 2 bz2
|
||||||
int fmode; // 0 - file / 1 - Zfile
|
int fmode; // 0 - file / 1 - Zfile
|
||||||
char *Ztable;
|
char *Ztable;
|
||||||
|
|
||||||
int BlockDump;
|
int BlockDump;
|
||||||
|
@ -41,11 +41,10 @@ FILE *cdvdLog = NULL;
|
||||||
static char cdvdCurrentIso[MAX_PATH];
|
static char cdvdCurrentIso[MAX_PATH];
|
||||||
|
|
||||||
char *methods[] =
|
char *methods[] =
|
||||||
{
|
{
|
||||||
".Z - compress faster",
|
".Z - compress faster",
|
||||||
".BZ - compress better",
|
".BZ - compress better",
|
||||||
NULL
|
NULL};
|
||||||
};
|
|
||||||
|
|
||||||
#ifdef PCSX2_DEBUG
|
#ifdef PCSX2_DEBUG
|
||||||
char *LibName = "Linuz Iso CDVD (Debug) ";
|
char *LibName = "Linuz Iso CDVD (Debug) ";
|
||||||
|
@ -61,290 +60,295 @@ u8 cdbuffer[CD_FRAMESIZE_RAW * 10] = {0};
|
||||||
|
|
||||||
s32 msf_to_lba(u8 m, u8 s, u8 f)
|
s32 msf_to_lba(u8 m, u8 s, u8 f)
|
||||||
{
|
{
|
||||||
u32 lsn;
|
u32 lsn;
|
||||||
lsn = f;
|
lsn = f;
|
||||||
lsn += (s - 2) * 75;
|
lsn += (s - 2) * 75;
|
||||||
lsn += m * 75 * 60;
|
lsn += m * 75 * 60;
|
||||||
return lsn;
|
return lsn;
|
||||||
}
|
}
|
||||||
|
|
||||||
void lba_to_msf(s32 lba, u8* m, u8* s, u8* f)
|
void lba_to_msf(s32 lba, u8 *m, u8 *s, u8 *f)
|
||||||
{
|
{
|
||||||
lba += 150;
|
lba += 150;
|
||||||
*m = lba / (60 * 75);
|
*m = lba / (60 * 75);
|
||||||
*s = (lba / 75) % 60;
|
*s = (lba / 75) % 60;
|
||||||
*f = lba % 75;
|
*f = lba % 75;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define btoi(b) ((b)/16*10 + (b)%16) /* BCD to u_char */
|
#define btoi(b) ((b) / 16 * 10 + (b) % 16) /* BCD to u_char */
|
||||||
#define itob(i) ((i)/10*16 + (i)%10) /* u_char to BCD */
|
#define itob(i) ((i) / 10 * 16 + (i) % 10) /* u_char to BCD */
|
||||||
|
|
||||||
|
|
||||||
EXPORT_C_(char*) PS2EgetLibName()
|
EXPORT_C_(char *)
|
||||||
|
PS2EgetLibName()
|
||||||
{
|
{
|
||||||
return LibName;
|
return LibName;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(u32) PS2EgetLibType()
|
EXPORT_C_(u32)
|
||||||
|
PS2EgetLibType()
|
||||||
{
|
{
|
||||||
return PS2E_LT_CDVD;
|
return PS2E_LT_CDVD;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(u32) PS2EgetLibVersion2(u32 type)
|
EXPORT_C_(u32)
|
||||||
|
PS2EgetLibVersion2(u32 type)
|
||||||
{
|
{
|
||||||
return (version << 16) | (revision << 8) | build;
|
return (version << 16) | (revision << 8) | build;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PCSX2_DEBUG
|
#ifdef PCSX2_DEBUG
|
||||||
void __Log(char *fmt, ...)
|
void __Log(char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list list;
|
va_list list;
|
||||||
|
|
||||||
if (cdvdLog == NULL) return;
|
if (cdvdLog == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
va_start(list, fmt);
|
va_start(list, fmt);
|
||||||
vfprintf(cdvdLog, fmt, list);
|
vfprintf(cdvdLog, fmt, list);
|
||||||
va_end(list);
|
va_end(list);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
#define __Log 0&&
|
#define __Log 0 &&
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
EXPORT_C_(s32) CDVDinit()
|
EXPORT_C_(s32)
|
||||||
|
CDVDinit()
|
||||||
{
|
{
|
||||||
#ifdef PCSX2_DEBUG
|
#ifdef PCSX2_DEBUG
|
||||||
cdvdLog = fopen("logs/cdvdLog.txt", "w");
|
cdvdLog = fopen("logs/cdvdLog.txt", "w");
|
||||||
if (cdvdLog == NULL)
|
if (cdvdLog == NULL) {
|
||||||
{
|
cdvdLog = fopen("cdvdLog.txt", "w");
|
||||||
cdvdLog = fopen("cdvdLog.txt", "w");
|
if (cdvdLog == NULL) {
|
||||||
if (cdvdLog == NULL)
|
SysMessage("Can't create cdvdLog.txt");
|
||||||
{
|
return -1;
|
||||||
SysMessage("Can't create cdvdLog.txt");
|
}
|
||||||
return -1;
|
}
|
||||||
}
|
setvbuf(cdvdLog, NULL, _IONBF, 0);
|
||||||
}
|
CDVD_LOG("CDVDinit\n");
|
||||||
setvbuf(cdvdLog, NULL, _IONBF, 0);
|
|
||||||
CDVD_LOG("CDVDinit\n");
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
cdvdCurrentIso[0] = 0;
|
cdvdCurrentIso[0] = 0;
|
||||||
memset(cdIso, 0, sizeof(cdIso));
|
memset(cdIso, 0, sizeof(cdIso));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(void) CDVDshutdown()
|
EXPORT_C_(void)
|
||||||
|
CDVDshutdown()
|
||||||
{
|
{
|
||||||
cdvdCurrentIso[0] = 0;
|
cdvdCurrentIso[0] = 0;
|
||||||
#ifdef CDVD_LOG
|
#ifdef CDVD_LOG
|
||||||
if (cdvdLog != NULL) fclose(cdvdLog);
|
if (cdvdLog != NULL)
|
||||||
|
fclose(cdvdLog);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(s32) CDVDopen(const char* pTitle)
|
EXPORT_C_(s32)
|
||||||
|
CDVDopen(const char *pTitle)
|
||||||
{
|
{
|
||||||
LoadConf();
|
LoadConf();
|
||||||
|
|
||||||
if (pTitle != NULL) strcpy(IsoFile, pTitle);
|
if (pTitle != NULL)
|
||||||
|
strcpy(IsoFile, pTitle);
|
||||||
|
|
||||||
if (*IsoFile == 0) strcpy(IsoFile, cdvdCurrentIso);
|
if (*IsoFile == 0)
|
||||||
|
strcpy(IsoFile, cdvdCurrentIso);
|
||||||
|
|
||||||
if (*IsoFile == 0)
|
if (*IsoFile == 0) {
|
||||||
{
|
char temp[256];
|
||||||
char temp[256];
|
|
||||||
|
|
||||||
CfgOpenFile();
|
CfgOpenFile();
|
||||||
|
|
||||||
if (IsoFile[0] == 0)
|
if (IsoFile[0] == 0) {
|
||||||
{
|
// user pressed CANCEL
|
||||||
// user pressed CANCEL
|
return 1;
|
||||||
return 1;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
strcpy(temp, IsoFile);
|
|
||||||
*IsoFile = 0;
|
|
||||||
SaveConf();
|
|
||||||
strcpy(IsoFile, temp);
|
|
||||||
}
|
|
||||||
|
|
||||||
iso = isoOpen(IsoFile);
|
strcpy(temp, IsoFile);
|
||||||
if (iso == NULL)
|
*IsoFile = 0;
|
||||||
{
|
SaveConf();
|
||||||
SysMessage("Error loading %s\nMake sure the iso file is not mounted in any disk emulation software!", IsoFile);
|
strcpy(IsoFile, temp);
|
||||||
return -1;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (iso->type == ISOTYPE_DVD)
|
iso = isoOpen(IsoFile);
|
||||||
cdtype = CDVD_TYPE_PS2DVD;
|
if (iso == NULL) {
|
||||||
else if (iso->type == ISOTYPE_AUDIO)
|
SysMessage("Error loading %s\nMake sure the iso file is not mounted in any disk emulation software!", IsoFile);
|
||||||
cdtype = CDVD_TYPE_CDDA;
|
return -1;
|
||||||
else
|
}
|
||||||
cdtype = CDVD_TYPE_PS2CD;
|
|
||||||
|
|
||||||
if (BlockDump)
|
if (iso->type == ISOTYPE_DVD)
|
||||||
{
|
cdtype = CDVD_TYPE_PS2DVD;
|
||||||
char fname_only[MAX_PATH];
|
else if (iso->type == ISOTYPE_AUDIO)
|
||||||
|
cdtype = CDVD_TYPE_CDDA;
|
||||||
|
else
|
||||||
|
cdtype = CDVD_TYPE_PS2CD;
|
||||||
|
|
||||||
|
if (BlockDump) {
|
||||||
|
char fname_only[MAX_PATH];
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
char fname[MAX_PATH], ext[MAX_PATH];
|
char fname[MAX_PATH], ext[MAX_PATH];
|
||||||
_splitpath(IsoFile, NULL, NULL, fname, ext);
|
_splitpath(IsoFile, NULL, NULL, fname, ext);
|
||||||
_makepath(fname_only, NULL, NULL, fname, NULL);
|
_makepath(fname_only, NULL, NULL, fname, NULL);
|
||||||
#else
|
#else
|
||||||
char* p, *plast;
|
char *p, *plast;
|
||||||
|
|
||||||
plast = p = strchr(IsoFile, '/');
|
plast = p = strchr(IsoFile, '/');
|
||||||
while (p != NULL)
|
while (p != NULL) {
|
||||||
{
|
plast = p;
|
||||||
plast = p;
|
p = strchr(p + 1, '/');
|
||||||
p = strchr(p + 1, '/');
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Lets not create dumps in the plugin directory.
|
// Lets not create dumps in the plugin directory.
|
||||||
strcpy(fname_only, "../");
|
strcpy(fname_only, "../");
|
||||||
if (plast != NULL)
|
if (plast != NULL)
|
||||||
strcat(fname_only, plast + 1);
|
strcat(fname_only, plast + 1);
|
||||||
else
|
else
|
||||||
strcat(fname_only, IsoFile);
|
strcat(fname_only, IsoFile);
|
||||||
|
|
||||||
plast = p = strchr(fname_only, '.');
|
plast = p = strchr(fname_only, '.');
|
||||||
|
|
||||||
while (p != NULL)
|
while (p != NULL) {
|
||||||
{
|
plast = p;
|
||||||
plast = p;
|
p = strchr(p + 1, '.');
|
||||||
p = strchr(p + 1, '.');
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (plast != NULL) *plast = 0;
|
if (plast != NULL)
|
||||||
|
*plast = 0;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
strcat(fname_only, ".dump");
|
strcat(fname_only, ".dump");
|
||||||
fdump = isoCreate(fname_only, ISOFLAGS_BLOCKDUMP);
|
fdump = isoCreate(fname_only, ISOFLAGS_BLOCKDUMP);
|
||||||
if (fdump) isoSetFormat(fdump, iso->blockofs, iso->blocksize, iso->blocks);
|
if (fdump)
|
||||||
}
|
isoSetFormat(fdump, iso->blockofs, iso->blocksize, iso->blocks);
|
||||||
else
|
} else {
|
||||||
{
|
fdump = NULL;
|
||||||
fdump = NULL;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(void) CDVDclose()
|
EXPORT_C_(void)
|
||||||
|
CDVDclose()
|
||||||
{
|
{
|
||||||
if (!iso) return;
|
if (!iso)
|
||||||
|
return;
|
||||||
|
|
||||||
strcpy(cdvdCurrentIso, IsoFile);
|
strcpy(cdvdCurrentIso, IsoFile);
|
||||||
|
|
||||||
isoClose(iso);
|
isoClose(iso);
|
||||||
if (fdump != NULL) isoClose(fdump);
|
if (fdump != NULL)
|
||||||
|
isoClose(fdump);
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(s32) CDVDreadSubQ(u32 lsn, cdvdSubQ* subq)
|
EXPORT_C_(s32)
|
||||||
|
CDVDreadSubQ(u32 lsn, cdvdSubQ *subq)
|
||||||
{
|
{
|
||||||
if (!iso) return -1;
|
if (!iso)
|
||||||
|
return -1;
|
||||||
|
|
||||||
// fake it
|
// fake it
|
||||||
u8 min, sec, frm;
|
u8 min, sec, frm;
|
||||||
subq->ctrl = 4;
|
subq->ctrl = 4;
|
||||||
subq->mode = 1;
|
subq->mode = 1;
|
||||||
subq->trackNum = itob(1);
|
subq->trackNum = itob(1);
|
||||||
subq->trackIndex = itob(1);
|
subq->trackIndex = itob(1);
|
||||||
|
|
||||||
lba_to_msf(lsn, &min, &sec, &frm);
|
lba_to_msf(lsn, &min, &sec, &frm);
|
||||||
subq->trackM = itob(min);
|
subq->trackM = itob(min);
|
||||||
subq->trackS = itob(sec);
|
subq->trackS = itob(sec);
|
||||||
subq->trackF = itob(frm);
|
subq->trackF = itob(frm);
|
||||||
|
|
||||||
subq->pad = 0;
|
subq->pad = 0;
|
||||||
|
|
||||||
lba_to_msf(lsn + (2*75), &min, &sec, &frm);
|
lba_to_msf(lsn + (2 * 75), &min, &sec, &frm);
|
||||||
subq->discM = itob(min);
|
subq->discM = itob(min);
|
||||||
subq->discS = itob(sec);
|
subq->discS = itob(sec);
|
||||||
subq->discF = itob(frm);
|
subq->discF = itob(frm);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(s32) CDVDgetTN(cdvdTN *Buffer)
|
EXPORT_C_(s32)
|
||||||
|
CDVDgetTN(cdvdTN *Buffer)
|
||||||
{
|
{
|
||||||
Buffer->strack = 1;
|
Buffer->strack = 1;
|
||||||
Buffer->etrack = 1;
|
Buffer->etrack = 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(s32) CDVDgetTD(u8 Track, cdvdTD *Buffer)
|
EXPORT_C_(s32)
|
||||||
|
CDVDgetTD(u8 Track, cdvdTD *Buffer)
|
||||||
{
|
{
|
||||||
if (!iso) return -1;
|
if (!iso)
|
||||||
|
return -1;
|
||||||
|
|
||||||
if (Track == 0)
|
if (Track == 0) {
|
||||||
{
|
Buffer->lsn = iso->blocks;
|
||||||
Buffer->lsn = iso->blocks;
|
} else {
|
||||||
}
|
Buffer->type = CDVD_MODE1_TRACK;
|
||||||
else
|
Buffer->lsn = 0;
|
||||||
{
|
}
|
||||||
Buffer->type = CDVD_MODE1_TRACK;
|
|
||||||
Buffer->lsn = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static s32 layer1start = -1;
|
static s32 layer1start = -1;
|
||||||
|
|
||||||
static bool testForPartitionInfo( const u8 (&tempbuffer)[CD_FRAMESIZE_RAW] )
|
static bool testForPartitionInfo(const u8 (&tempbuffer)[CD_FRAMESIZE_RAW])
|
||||||
{
|
{
|
||||||
const int off = iso->blockofs;
|
const int off = iso->blockofs;
|
||||||
|
|
||||||
// test for: CD001
|
// test for: CD001
|
||||||
return (
|
return (
|
||||||
(tempbuffer[off+1] == 0x43) &&
|
(tempbuffer[off + 1] == 0x43) &&
|
||||||
(tempbuffer[off+2] == 0x44) &&
|
(tempbuffer[off + 2] == 0x44) &&
|
||||||
(tempbuffer[off+3] == 0x30) &&
|
(tempbuffer[off + 3] == 0x30) &&
|
||||||
(tempbuffer[off+4] == 0x30) &&
|
(tempbuffer[off + 4] == 0x30) &&
|
||||||
(tempbuffer[off+5] == 0x31)
|
(tempbuffer[off + 5] == 0x31));
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(s32) CDVDgetTOC(void* toc)
|
EXPORT_C_(s32)
|
||||||
|
CDVDgetTOC(void *toc)
|
||||||
{
|
{
|
||||||
if (!iso) return -1;
|
if (!iso)
|
||||||
|
return -1;
|
||||||
u8 type = CDVDgetDiskType();
|
|
||||||
u8* tocBuff = (u8*)toc;
|
|
||||||
|
|
||||||
//__Log("CDVDgetTOC\n");
|
u8 type = CDVDgetDiskType();
|
||||||
|
u8 *tocBuff = (u8 *)toc;
|
||||||
|
|
||||||
if (type == CDVD_TYPE_DVDV || type == CDVD_TYPE_PS2DVD)
|
//__Log("CDVDgetTOC\n");
|
||||||
{
|
|
||||||
// get dvd structure format
|
|
||||||
// scsi command 0x43
|
|
||||||
memset(tocBuff, 0, 2048);
|
|
||||||
|
|
||||||
if (layer1start != -2 && iso->blocks >= 0x300000)
|
if (type == CDVD_TYPE_DVDV || type == CDVD_TYPE_PS2DVD) {
|
||||||
{
|
// get dvd structure format
|
||||||
//int off = iso->blockofs;
|
// scsi command 0x43
|
||||||
|
memset(tocBuff, 0, 2048);
|
||||||
|
|
||||||
// dual sided
|
if (layer1start != -2 && iso->blocks >= 0x300000) {
|
||||||
tocBuff[ 0] = 0x24;
|
//int off = iso->blockofs;
|
||||||
tocBuff[ 1] = 0x02;
|
|
||||||
tocBuff[ 2] = 0xF2;
|
|
||||||
tocBuff[ 3] = 0x00;
|
|
||||||
tocBuff[ 4] = 0x41;
|
|
||||||
tocBuff[ 5] = 0x95;
|
|
||||||
|
|
||||||
tocBuff[14] = 0x60; // dual sided, ptp
|
// dual sided
|
||||||
|
tocBuff[0] = 0x24;
|
||||||
|
tocBuff[1] = 0x02;
|
||||||
|
tocBuff[2] = 0xF2;
|
||||||
|
tocBuff[3] = 0x00;
|
||||||
|
tocBuff[4] = 0x41;
|
||||||
|
tocBuff[5] = 0x95;
|
||||||
|
|
||||||
tocBuff[16] = 0x00;
|
tocBuff[14] = 0x60; // dual sided, ptp
|
||||||
tocBuff[17] = 0x03;
|
|
||||||
tocBuff[18] = 0x00;
|
|
||||||
tocBuff[19] = 0x00;
|
|
||||||
|
|
||||||
// search for it
|
tocBuff[16] = 0x00;
|
||||||
if (layer1start == -1)
|
tocBuff[17] = 0x03;
|
||||||
{
|
tocBuff[18] = 0x00;
|
||||||
printf("CDVD: searching for layer1...");
|
tocBuff[19] = 0x00;
|
||||||
|
|
||||||
/*tempbuffer = (u8*)malloc(CD_FRAMESIZE_RAW * 10);
|
// search for it
|
||||||
|
if (layer1start == -1) {
|
||||||
|
printf("CDVD: searching for layer1...");
|
||||||
|
|
||||||
|
/*tempbuffer = (u8*)malloc(CD_FRAMESIZE_RAW * 10);
|
||||||
for (layer1start = (iso->blocks / 2 - 0x10) & ~0xf; layer1start < 0x200010; layer1start += 16)
|
for (layer1start = (iso->blocks / 2 - 0x10) & ~0xf; layer1start < 0x200010; layer1start += 16)
|
||||||
{
|
{
|
||||||
isoReadBlock(iso, tempbuffer, layer1start);
|
isoReadBlock(iso, tempbuffer, layer1start);
|
||||||
|
@ -358,201 +362,196 @@ EXPORT_C_(s32) CDVDgetTOC(void* toc)
|
||||||
}
|
}
|
||||||
free(tempbuffer);*/
|
free(tempbuffer);*/
|
||||||
|
|
||||||
uint midsector = (iso->blocks / 2) & ~0xf;
|
uint midsector = (iso->blocks / 2) & ~0xf;
|
||||||
uint deviation = 0;
|
uint deviation = 0;
|
||||||
|
|
||||||
while( (layer1start == -1) && (deviation < midsector-16) )
|
while ((layer1start == -1) && (deviation < midsector - 16)) {
|
||||||
{
|
u8 tempbuffer[CD_FRAMESIZE_RAW];
|
||||||
u8 tempbuffer[CD_FRAMESIZE_RAW];
|
isoReadBlock(iso, tempbuffer, midsector - deviation);
|
||||||
isoReadBlock(iso, tempbuffer, midsector-deviation);
|
|
||||||
|
|
||||||
if(testForPartitionInfo( tempbuffer ))
|
if (testForPartitionInfo(tempbuffer))
|
||||||
layer1start = midsector-deviation;
|
layer1start = midsector - deviation;
|
||||||
else
|
else {
|
||||||
{
|
isoReadBlock(iso, tempbuffer, midsector + deviation);
|
||||||
isoReadBlock(iso, tempbuffer, midsector+deviation);
|
if (testForPartitionInfo(tempbuffer))
|
||||||
if( testForPartitionInfo( tempbuffer ) )
|
layer1start = midsector + deviation;
|
||||||
layer1start = midsector+deviation;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if( layer1start != -1 )
|
if (layer1start != -1) {
|
||||||
{
|
if (tempbuffer[iso->blockofs] != 0x01) {
|
||||||
if( tempbuffer[iso->blockofs] != 0x01 )
|
fprintf(stderr, "(LinuzCDVDiso): Invalid partition type on layer 1!? (type=0x%x)", tempbuffer[iso->blockofs]);
|
||||||
{
|
}
|
||||||
fprintf( stderr, "(LinuzCDVDiso): Invalid partition type on layer 1!? (type=0x%x)", tempbuffer[iso->blockofs] );
|
}
|
||||||
}
|
deviation += 16;
|
||||||
}
|
}
|
||||||
deviation += 16;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (layer1start == -1)
|
if (layer1start == -1) {
|
||||||
{
|
printf("(LinuzCDVDiso): Couldn't find second layer on dual layer... ignoring\n");
|
||||||
printf("(LinuzCDVDiso): Couldn't find second layer on dual layer... ignoring\n");
|
// fake it
|
||||||
// fake it
|
tocBuff[0] = 0x04;
|
||||||
tocBuff[ 0] = 0x04;
|
tocBuff[1] = 0x02;
|
||||||
tocBuff[ 1] = 0x02;
|
tocBuff[2] = 0xF2;
|
||||||
tocBuff[ 2] = 0xF2;
|
tocBuff[3] = 0x00;
|
||||||
tocBuff[ 3] = 0x00;
|
tocBuff[4] = 0x86;
|
||||||
tocBuff[ 4] = 0x86;
|
tocBuff[5] = 0x72;
|
||||||
tocBuff[ 5] = 0x72;
|
|
||||||
|
|
||||||
tocBuff[16] = 0x00;
|
tocBuff[16] = 0x00;
|
||||||
tocBuff[17] = 0x03;
|
tocBuff[17] = 0x03;
|
||||||
tocBuff[18] = 0x00;
|
tocBuff[18] = 0x00;
|
||||||
tocBuff[19] = 0x00;
|
tocBuff[19] = 0x00;
|
||||||
layer1start = -2;
|
layer1start = -2;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("(LinuzCDVDiso): found at 0x%8.8x\n", layer1start);
|
printf("(LinuzCDVDiso): found at 0x%8.8x\n", layer1start);
|
||||||
layer1start = layer1start + 0x30000 - 1;
|
layer1start = layer1start + 0x30000 - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
tocBuff[20] = layer1start >> 24;
|
tocBuff[20] = layer1start >> 24;
|
||||||
tocBuff[21] = (layer1start >> 16) & 0xff;
|
tocBuff[21] = (layer1start >> 16) & 0xff;
|
||||||
tocBuff[22] = (layer1start >> 8) & 0xff;
|
tocBuff[22] = (layer1start >> 8) & 0xff;
|
||||||
tocBuff[23] = (layer1start >> 0) & 0xff;
|
tocBuff[23] = (layer1start >> 0) & 0xff;
|
||||||
}
|
} else {
|
||||||
else
|
// fake it
|
||||||
{
|
tocBuff[0] = 0x04;
|
||||||
// fake it
|
tocBuff[1] = 0x02;
|
||||||
tocBuff[ 0] = 0x04;
|
tocBuff[2] = 0xF2;
|
||||||
tocBuff[ 1] = 0x02;
|
tocBuff[3] = 0x00;
|
||||||
tocBuff[ 2] = 0xF2;
|
tocBuff[4] = 0x86;
|
||||||
tocBuff[ 3] = 0x00;
|
tocBuff[5] = 0x72;
|
||||||
tocBuff[ 4] = 0x86;
|
|
||||||
tocBuff[ 5] = 0x72;
|
|
||||||
|
|
||||||
tocBuff[16] = 0x00;
|
tocBuff[16] = 0x00;
|
||||||
tocBuff[17] = 0x03;
|
tocBuff[17] = 0x03;
|
||||||
tocBuff[18] = 0x00;
|
tocBuff[18] = 0x00;
|
||||||
tocBuff[19] = 0x00;
|
tocBuff[19] = 0x00;
|
||||||
}
|
}
|
||||||
}
|
} else if ((type == CDVD_TYPE_CDDA) || (type == CDVD_TYPE_PS2CDDA) ||
|
||||||
else if ((type == CDVD_TYPE_CDDA) || (type == CDVD_TYPE_PS2CDDA) ||
|
(type == CDVD_TYPE_PS2CD) || (type == CDVD_TYPE_PSCDDA) || (type == CDVD_TYPE_PSCD)) {
|
||||||
(type == CDVD_TYPE_PS2CD) || (type == CDVD_TYPE_PSCDDA) || (type == CDVD_TYPE_PSCD))
|
// cd toc
|
||||||
{
|
// (could be replaced by 1 command that reads the full toc)
|
||||||
// cd toc
|
u8 min, sec, frm;
|
||||||
// (could be replaced by 1 command that reads the full toc)
|
s32 i, err;
|
||||||
u8 min, sec, frm;
|
cdvdTN diskInfo;
|
||||||
s32 i, err;
|
cdvdTD trackInfo;
|
||||||
cdvdTN diskInfo;
|
memset(tocBuff, 0, 1024);
|
||||||
cdvdTD trackInfo;
|
if (CDVDgetTN(&diskInfo) == -1) {
|
||||||
memset(tocBuff, 0, 1024);
|
diskInfo.etrack = 0;
|
||||||
if (CDVDgetTN(&diskInfo) == -1)
|
diskInfo.strack = 1;
|
||||||
{
|
}
|
||||||
diskInfo.etrack = 0;
|
if (CDVDgetTD(0, &trackInfo) == -1)
|
||||||
diskInfo.strack = 1;
|
trackInfo.lsn = 0;
|
||||||
}
|
|
||||||
if (CDVDgetTD(0, &trackInfo) == -1) trackInfo.lsn = 0;
|
|
||||||
|
|
||||||
tocBuff[0] = 0x41;
|
tocBuff[0] = 0x41;
|
||||||
tocBuff[1] = 0x00;
|
tocBuff[1] = 0x00;
|
||||||
|
|
||||||
//Number of FirstTrack
|
//Number of FirstTrack
|
||||||
tocBuff[2] = 0xA0;
|
tocBuff[2] = 0xA0;
|
||||||
tocBuff[7] = itob(diskInfo.strack);
|
tocBuff[7] = itob(diskInfo.strack);
|
||||||
|
|
||||||
//Number of LastTrack
|
//Number of LastTrack
|
||||||
tocBuff[12] = 0xA1;
|
tocBuff[12] = 0xA1;
|
||||||
tocBuff[17] = itob(diskInfo.etrack);
|
tocBuff[17] = itob(diskInfo.etrack);
|
||||||
|
|
||||||
//DiskLength
|
//DiskLength
|
||||||
lba_to_msf(trackInfo.lsn, &min, &sec, &frm);
|
lba_to_msf(trackInfo.lsn, &min, &sec, &frm);
|
||||||
tocBuff[22] = 0xA2;
|
tocBuff[22] = 0xA2;
|
||||||
tocBuff[27] = itob(min);
|
tocBuff[27] = itob(min);
|
||||||
tocBuff[28] = itob(sec);
|
tocBuff[28] = itob(sec);
|
||||||
|
|
||||||
for (i = diskInfo.strack; i <= diskInfo.etrack; i++)
|
for (i = diskInfo.strack; i <= diskInfo.etrack; i++) {
|
||||||
{
|
err = CDVDgetTD(i, &trackInfo);
|
||||||
err = CDVDgetTD(i, &trackInfo);
|
lba_to_msf(trackInfo.lsn, &min, &sec, &frm);
|
||||||
lba_to_msf(trackInfo.lsn, &min, &sec, &frm);
|
tocBuff[i * 10 + 30] = trackInfo.type;
|
||||||
tocBuff[i*10+30] = trackInfo.type;
|
tocBuff[i * 10 + 32] = err == -1 ? 0 : itob(i); //number
|
||||||
tocBuff[i*10+32] = err == -1 ? 0 : itob(i); //number
|
tocBuff[i * 10 + 37] = itob(min);
|
||||||
tocBuff[i*10+37] = itob(min);
|
tocBuff[i * 10 + 38] = itob(sec);
|
||||||
tocBuff[i*10+38] = itob(sec);
|
tocBuff[i * 10 + 39] = itob(frm);
|
||||||
tocBuff[i*10+39] = itob(frm);
|
}
|
||||||
}
|
} else
|
||||||
}
|
return -1;
|
||||||
else
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(s32) CDVDreadTrack(u32 lsn, int mode)
|
EXPORT_C_(s32)
|
||||||
|
CDVDreadTrack(u32 lsn, int mode)
|
||||||
{
|
{
|
||||||
if (!iso) return -1;
|
if (!iso)
|
||||||
|
return -1;
|
||||||
|
|
||||||
int _lsn = lsn;
|
int _lsn = lsn;
|
||||||
|
|
||||||
//__Log("CDVDreadTrack: %x %x\n", lsn, mode);
|
//__Log("CDVDreadTrack: %x %x\n", lsn, mode);
|
||||||
if (_lsn < 0)
|
if (_lsn < 0) {
|
||||||
{
|
// lsn = 2097152 + (-_lsn);
|
||||||
// lsn = 2097152 + (-_lsn);
|
lsn = iso->blocks - (-_lsn);
|
||||||
lsn = iso->blocks - (-_lsn);
|
}
|
||||||
}
|
// printf ("CDRreadTrack %d\n", lsn);
|
||||||
// printf ("CDRreadTrack %d\n", lsn);
|
|
||||||
|
|
||||||
isoReadBlock(iso, cdbuffer, lsn);
|
isoReadBlock(iso, cdbuffer, lsn);
|
||||||
if (fdump != NULL)
|
if (fdump != NULL) {
|
||||||
{
|
isoWriteBlock(fdump, cdbuffer, lsn);
|
||||||
isoWriteBlock(fdump, cdbuffer, lsn);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
pbuffer = cdbuffer;
|
pbuffer = cdbuffer;
|
||||||
switch (mode)
|
switch (mode) {
|
||||||
{
|
case CDVD_MODE_2352:
|
||||||
case CDVD_MODE_2352:
|
break;
|
||||||
break;
|
case CDVD_MODE_2340:
|
||||||
case CDVD_MODE_2340:
|
pbuffer += 12;
|
||||||
pbuffer += 12;
|
break;
|
||||||
break;
|
case CDVD_MODE_2328:
|
||||||
case CDVD_MODE_2328:
|
pbuffer += 24;
|
||||||
pbuffer += 24;
|
break;
|
||||||
break;
|
case CDVD_MODE_2048:
|
||||||
case CDVD_MODE_2048:
|
pbuffer += 24;
|
||||||
pbuffer += 24;
|
break;
|
||||||
break;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(u8*) CDVDgetBuffer()
|
EXPORT_C_(u8 *)
|
||||||
|
CDVDgetBuffer()
|
||||||
{
|
{
|
||||||
return pbuffer;
|
return pbuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(s32) CDVDgetDiskType()
|
EXPORT_C_(s32)
|
||||||
|
CDVDgetDiskType()
|
||||||
{
|
{
|
||||||
return cdtype;
|
return cdtype;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(s32) CDVDgetTrayStatus()
|
EXPORT_C_(s32)
|
||||||
|
CDVDgetTrayStatus()
|
||||||
{
|
{
|
||||||
return CDVD_TRAY_CLOSE;
|
return CDVD_TRAY_CLOSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(s32) CDVDctrlTrayOpen()
|
EXPORT_C_(s32)
|
||||||
|
CDVDctrlTrayOpen()
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
EXPORT_C_(s32) CDVDctrlTrayClose()
|
EXPORT_C_(s32)
|
||||||
|
CDVDctrlTrayClose()
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
EXPORT_C_(s32) CDVDtest()
|
EXPORT_C_(s32)
|
||||||
|
CDVDtest()
|
||||||
{
|
{
|
||||||
if (*IsoFile == 0) return 0;
|
if (*IsoFile == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
iso = isoOpen(IsoFile);
|
iso = isoOpen(IsoFile);
|
||||||
if (iso == NULL) return -1;
|
if (iso == NULL)
|
||||||
isoClose(iso);
|
return -1;
|
||||||
|
isoClose(iso);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,308 +18,311 @@
|
||||||
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
|
||||||
const char *s_strIniPath="./inis/CDVDiso.ini";
|
const char *s_strIniPath = "./inis/CDVDiso.ini";
|
||||||
GtkWidget *AboutDlg, *ConfDlg, *MsgDlg, *FileSel;
|
GtkWidget *AboutDlg, *ConfDlg, *MsgDlg, *FileSel;
|
||||||
GtkWidget *Edit, *CdEdit;
|
GtkWidget *Edit, *CdEdit;
|
||||||
|
|
||||||
void LoadConf()
|
void LoadConf()
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
char cfg[256];
|
char cfg[256];
|
||||||
|
|
||||||
//sprintf(cfg, "%s/.PS2E/CDVDiso.cfg", getenv("HOME"));
|
//sprintf(cfg, "%s/.PS2E/CDVDiso.cfg", getenv("HOME"));
|
||||||
strcpy(cfg, s_strIniPath);
|
strcpy(cfg, s_strIniPath);
|
||||||
f = fopen(cfg, "r");
|
f = fopen(cfg, "r");
|
||||||
|
|
||||||
if (f == NULL)
|
if (f == NULL) {
|
||||||
{
|
printf("Unable to load %s\n", cfg);
|
||||||
printf("Unable to load %s\n", cfg);
|
strcpy(IsoFile, DEV_DEF);
|
||||||
strcpy(IsoFile, DEV_DEF);
|
strcpy(CdDev, CDDEV_DEF);
|
||||||
strcpy(CdDev, CDDEV_DEF);
|
BlockDump = 0;
|
||||||
BlockDump = 0;
|
SaveConf();
|
||||||
SaveConf();
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fscanf(f, "IsoFile = %[^\n]\n", IsoFile);
|
fscanf(f, "IsoFile = %[^\n]\n", IsoFile);
|
||||||
fscanf(f, "CdDev = %[^\n]\n", CdDev);
|
fscanf(f, "CdDev = %[^\n]\n", CdDev);
|
||||||
fscanf(f, "BlockDump = %d\n", &BlockDump);
|
fscanf(f, "BlockDump = %d\n", &BlockDump);
|
||||||
|
|
||||||
if (!strncmp(IsoFile, "CdDev =", 9)) *IsoFile = 0; // quick fix
|
if (!strncmp(IsoFile, "CdDev =", 9))
|
||||||
if (*CdDev == 0) strcpy(CdDev, CDDEV_DEF);
|
*IsoFile = 0; // quick fix
|
||||||
|
if (*CdDev == 0)
|
||||||
|
strcpy(CdDev, CDDEV_DEF);
|
||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SaveConf()
|
void SaveConf()
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
char cfg[256];
|
char cfg[256];
|
||||||
|
|
||||||
//sprintf(cfg, "%s/.PS2E", getenv("HOME"));
|
//sprintf(cfg, "%s/.PS2E", getenv("HOME"));
|
||||||
|
|
||||||
//mkdir(cfg, 0755);
|
//mkdir(cfg, 0755);
|
||||||
//sprintf(cfg, "%s/.PS2E/CDVDiso.cfg", getenv("HOME"));
|
//sprintf(cfg, "%s/.PS2E/CDVDiso.cfg", getenv("HOME"));
|
||||||
strcpy(cfg, s_strIniPath);
|
strcpy(cfg, s_strIniPath);
|
||||||
|
|
||||||
f = fopen(cfg, "w");
|
f = fopen(cfg, "w");
|
||||||
if (f == NULL)
|
if (f == NULL) {
|
||||||
{
|
printf("Unable to save %s\n", cfg);
|
||||||
printf("Unable to save %s\n", cfg);
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fprintf(f, "IsoFile = %s\n", IsoFile);
|
fprintf(f, "IsoFile = %s\n", IsoFile);
|
||||||
fprintf(f, "CdDev = %s\n", CdDev);
|
fprintf(f, "CdDev = %s\n", CdDev);
|
||||||
fprintf(f, "BlockDump = %d\n", BlockDump);
|
fprintf(f, "BlockDump = %d\n", BlockDump);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SysMessage(char *fmt, ...)
|
void SysMessage(char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list list;
|
va_list list;
|
||||||
char tmp[256];
|
char tmp[256];
|
||||||
char cmd[256];
|
char cmd[256];
|
||||||
|
|
||||||
va_start(list, fmt);
|
va_start(list, fmt);
|
||||||
vsprintf(tmp, fmt, list);
|
vsprintf(tmp, fmt, list);
|
||||||
va_end(list);
|
va_end(list);
|
||||||
|
|
||||||
sprintf(cmd, "message \"%s\"", tmp);
|
sprintf(cmd, "message \"%s\"", tmp);
|
||||||
SysMessageLoc(tmp);
|
SysMessageLoc(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnFile_Ok()
|
void OnFile_Ok()
|
||||||
{
|
{
|
||||||
const gchar *File;
|
const gchar *File;
|
||||||
|
|
||||||
gtk_widget_hide(FileSel);
|
gtk_widget_hide(FileSel);
|
||||||
File = gtk_file_selection_get_filename(GTK_FILE_SELECTION(FileSel));
|
File = gtk_file_selection_get_filename(GTK_FILE_SELECTION(FileSel));
|
||||||
strcpy(IsoFile, File);
|
strcpy(IsoFile, File);
|
||||||
gtk_main_quit();
|
gtk_main_quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnFile_Cancel()
|
void OnFile_Cancel()
|
||||||
{
|
{
|
||||||
gtk_widget_hide(FileSel);
|
gtk_widget_hide(FileSel);
|
||||||
gtk_main_quit();
|
gtk_main_quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CfgOpenFile()
|
void CfgOpenFile()
|
||||||
{
|
{
|
||||||
GtkWidget *Ok, *Cancel;
|
GtkWidget *Ok, *Cancel;
|
||||||
|
|
||||||
FileSel = gtk_file_selection_new("Select Iso File");
|
FileSel = gtk_file_selection_new("Select Iso File");
|
||||||
|
|
||||||
Ok = GTK_FILE_SELECTION(FileSel)->ok_button;
|
Ok = GTK_FILE_SELECTION(FileSel)->ok_button;
|
||||||
gtk_signal_connect(GTK_OBJECT(Ok), "clicked",
|
gtk_signal_connect(GTK_OBJECT(Ok), "clicked",
|
||||||
GTK_SIGNAL_FUNC(OnFile_Ok), NULL);
|
GTK_SIGNAL_FUNC(OnFile_Ok), NULL);
|
||||||
gtk_widget_show(Ok);
|
gtk_widget_show(Ok);
|
||||||
|
|
||||||
Cancel = GTK_FILE_SELECTION(FileSel)->cancel_button;
|
Cancel = GTK_FILE_SELECTION(FileSel)->cancel_button;
|
||||||
gtk_signal_connect(GTK_OBJECT(Cancel), "clicked",
|
gtk_signal_connect(GTK_OBJECT(Cancel), "clicked",
|
||||||
GTK_SIGNAL_FUNC(OnFile_Cancel), NULL);
|
GTK_SIGNAL_FUNC(OnFile_Cancel), NULL);
|
||||||
gtk_widget_show(Cancel);
|
gtk_widget_show(Cancel);
|
||||||
|
|
||||||
gtk_widget_show(FileSel);
|
gtk_widget_show(FileSel);
|
||||||
gdk_window_raise(FileSel->window);
|
gdk_window_raise(FileSel->window);
|
||||||
|
|
||||||
gtk_main();
|
gtk_main();
|
||||||
|
|
||||||
SaveConf();
|
SaveConf();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnMsg_Ok()
|
void OnMsg_Ok()
|
||||||
{
|
{
|
||||||
gtk_widget_destroy(MsgDlg);
|
gtk_widget_destroy(MsgDlg);
|
||||||
gtk_main_quit();
|
gtk_main_quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SysMessageLoc(char *fmt, ...)
|
void SysMessageLoc(char *fmt, ...)
|
||||||
{
|
{
|
||||||
GtkWidget *Ok, *Txt;
|
GtkWidget *Ok, *Txt;
|
||||||
GtkWidget *Box, *Box1;
|
GtkWidget *Box, *Box1;
|
||||||
va_list list;
|
va_list list;
|
||||||
int w;
|
int w;
|
||||||
char msg[512];
|
char msg[512];
|
||||||
|
|
||||||
va_start(list, fmt);
|
va_start(list, fmt);
|
||||||
vsprintf(msg, fmt, list);
|
vsprintf(msg, fmt, list);
|
||||||
va_end(list);
|
va_end(list);
|
||||||
|
|
||||||
if (msg[strlen(msg)-1] == '\n') msg[strlen(msg)-1] = 0;
|
if (msg[strlen(msg) - 1] == '\n')
|
||||||
|
msg[strlen(msg) - 1] = 0;
|
||||||
|
|
||||||
w = strlen(msg) * 6 + 20;
|
w = strlen(msg) * 6 + 20;
|
||||||
|
|
||||||
MsgDlg = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
MsgDlg = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||||
gtk_widget_set_usize(MsgDlg, w, 70);
|
gtk_widget_set_usize(MsgDlg, w, 70);
|
||||||
gtk_window_set_position(GTK_WINDOW(MsgDlg), GTK_WIN_POS_CENTER);
|
gtk_window_set_position(GTK_WINDOW(MsgDlg), GTK_WIN_POS_CENTER);
|
||||||
gtk_window_set_title(GTK_WINDOW(MsgDlg), "cdriso Msg");
|
gtk_window_set_title(GTK_WINDOW(MsgDlg), "cdriso Msg");
|
||||||
gtk_container_set_border_width(GTK_CONTAINER(MsgDlg), 0);
|
gtk_container_set_border_width(GTK_CONTAINER(MsgDlg), 0);
|
||||||
|
|
||||||
Box = gtk_vbox_new(0, 0);
|
Box = gtk_vbox_new(0, 0);
|
||||||
gtk_container_add(GTK_CONTAINER(MsgDlg), Box);
|
gtk_container_add(GTK_CONTAINER(MsgDlg), Box);
|
||||||
gtk_widget_show(Box);
|
gtk_widget_show(Box);
|
||||||
|
|
||||||
Txt = gtk_label_new(msg);
|
Txt = gtk_label_new(msg);
|
||||||
|
|
||||||
gtk_box_pack_start(GTK_BOX(Box), Txt, FALSE, FALSE, 5);
|
gtk_box_pack_start(GTK_BOX(Box), Txt, FALSE, FALSE, 5);
|
||||||
gtk_widget_show(Txt);
|
gtk_widget_show(Txt);
|
||||||
|
|
||||||
Box1 = gtk_hbutton_box_new();
|
Box1 = gtk_hbutton_box_new();
|
||||||
gtk_box_pack_start(GTK_BOX(Box), Box1, FALSE, FALSE, 0);
|
gtk_box_pack_start(GTK_BOX(Box), Box1, FALSE, FALSE, 0);
|
||||||
gtk_widget_show(Box1);
|
gtk_widget_show(Box1);
|
||||||
|
|
||||||
Ok = gtk_button_new_with_label("Ok");
|
Ok = gtk_button_new_with_label("Ok");
|
||||||
gtk_signal_connect(GTK_OBJECT(Ok), "clicked", GTK_SIGNAL_FUNC(OnMsg_Ok), NULL);
|
gtk_signal_connect(GTK_OBJECT(Ok), "clicked", GTK_SIGNAL_FUNC(OnMsg_Ok), NULL);
|
||||||
gtk_container_add(GTK_CONTAINER(Box1), Ok);
|
gtk_container_add(GTK_CONTAINER(Box1), Ok);
|
||||||
GTK_WIDGET_SET_FLAGS(Ok, GTK_CAN_DEFAULT);
|
GTK_WIDGET_SET_FLAGS(Ok, GTK_CAN_DEFAULT);
|
||||||
gtk_widget_show(Ok);
|
gtk_widget_show(Ok);
|
||||||
|
|
||||||
gtk_widget_show(MsgDlg);
|
gtk_widget_show(MsgDlg);
|
||||||
|
|
||||||
gtk_main();
|
gtk_main();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnOk (GtkButton *button, gpointer user_data)
|
void OnOk(GtkButton *button, gpointer user_data)
|
||||||
{
|
{
|
||||||
const char *tmp;
|
const char *tmp;
|
||||||
|
|
||||||
stop = true;
|
stop = true;
|
||||||
tmp = gtk_entry_get_text(GTK_ENTRY(Edit));
|
tmp = gtk_entry_get_text(GTK_ENTRY(Edit));
|
||||||
strcpy(IsoFile, tmp);
|
strcpy(IsoFile, tmp);
|
||||||
tmp = gtk_entry_get_text(GTK_ENTRY(CdEdit));
|
tmp = gtk_entry_get_text(GTK_ENTRY(CdEdit));
|
||||||
strcpy(CdDev, tmp);
|
strcpy(CdDev, tmp);
|
||||||
|
|
||||||
if is_checked(ConfDlg, "checkBlockDump")
|
if
|
||||||
BlockDump = 1;
|
is_checked(ConfDlg, "checkBlockDump")
|
||||||
else
|
BlockDump = 1;
|
||||||
BlockDump = 0;
|
else
|
||||||
|
BlockDump = 0;
|
||||||
|
|
||||||
SaveConf();
|
SaveConf();
|
||||||
gtk_widget_destroy(ConfDlg);
|
gtk_widget_destroy(ConfDlg);
|
||||||
gtk_main_quit();
|
gtk_main_quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnCancel(GtkButton *button, gpointer user_data)
|
void OnCancel(GtkButton *button, gpointer user_data)
|
||||||
{
|
{
|
||||||
stop = true;
|
stop = true;
|
||||||
gtk_widget_destroy(ConfDlg);
|
gtk_widget_destroy(ConfDlg);
|
||||||
gtk_main_quit();
|
gtk_main_quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnFileSel_Ok()
|
void OnFileSel_Ok()
|
||||||
{
|
{
|
||||||
const gchar *File;
|
const gchar *File;
|
||||||
|
|
||||||
File = gtk_file_selection_get_filename(GTK_FILE_SELECTION(FileSel));
|
File = gtk_file_selection_get_filename(GTK_FILE_SELECTION(FileSel));
|
||||||
gtk_entry_set_text(GTK_ENTRY(Edit), File);
|
gtk_entry_set_text(GTK_ENTRY(Edit), File);
|
||||||
gtk_widget_destroy(FileSel);
|
gtk_widget_destroy(FileSel);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnFileSel_Cancel()
|
void OnFileSel_Cancel()
|
||||||
{
|
{
|
||||||
gtk_widget_destroy(FileSel);
|
gtk_widget_destroy(FileSel);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnFileSel(GtkButton *button, gpointer user_data)
|
void OnFileSel(GtkButton *button, gpointer user_data)
|
||||||
{
|
{
|
||||||
GtkWidget *Ok, *Cancel;
|
GtkWidget *Ok, *Cancel;
|
||||||
|
|
||||||
FileSel = gtk_file_selection_new("Select Psx Iso File");
|
FileSel = gtk_file_selection_new("Select Psx Iso File");
|
||||||
gtk_file_selection_set_filename(GTK_FILE_SELECTION(FileSel), IsoFile);
|
gtk_file_selection_set_filename(GTK_FILE_SELECTION(FileSel), IsoFile);
|
||||||
|
|
||||||
Ok = GTK_FILE_SELECTION(FileSel)->ok_button;
|
Ok = GTK_FILE_SELECTION(FileSel)->ok_button;
|
||||||
gtk_signal_connect(GTK_OBJECT(Ok), "clicked", GTK_SIGNAL_FUNC(OnFileSel_Ok), NULL);
|
gtk_signal_connect(GTK_OBJECT(Ok), "clicked", GTK_SIGNAL_FUNC(OnFileSel_Ok), NULL);
|
||||||
gtk_widget_show(Ok);
|
gtk_widget_show(Ok);
|
||||||
|
|
||||||
Cancel = GTK_FILE_SELECTION(FileSel)->cancel_button;
|
Cancel = GTK_FILE_SELECTION(FileSel)->cancel_button;
|
||||||
gtk_signal_connect(GTK_OBJECT(Cancel), "clicked", GTK_SIGNAL_FUNC(OnFileSel_Cancel), NULL);
|
gtk_signal_connect(GTK_OBJECT(Cancel), "clicked", GTK_SIGNAL_FUNC(OnFileSel_Cancel), NULL);
|
||||||
gtk_widget_show(Cancel);
|
gtk_widget_show(Cancel);
|
||||||
|
|
||||||
gtk_widget_show(FileSel);
|
gtk_widget_show(FileSel);
|
||||||
gdk_window_raise(FileSel->window);
|
gdk_window_raise(FileSel->window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
EXPORT_C_(void) CDVDconfigure()
|
EXPORT_C_(void)
|
||||||
|
CDVDconfigure()
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
LoadConf();
|
LoadConf();
|
||||||
|
|
||||||
ConfDlg = create_Config();
|
ConfDlg = create_Config();
|
||||||
|
|
||||||
Edit = lookup_widget(ConfDlg, "GtkEntry_Iso");
|
Edit = lookup_widget(ConfDlg, "GtkEntry_Iso");
|
||||||
gtk_entry_set_text(GTK_ENTRY(Edit), IsoFile);
|
gtk_entry_set_text(GTK_ENTRY(Edit), IsoFile);
|
||||||
CdEdit = lookup_widget(ConfDlg, "GtkEntry_CdDev");
|
CdEdit = lookup_widget(ConfDlg, "GtkEntry_CdDev");
|
||||||
gtk_entry_set_text(GTK_ENTRY(CdEdit), CdDev);
|
gtk_entry_set_text(GTK_ENTRY(CdEdit), CdDev);
|
||||||
|
|
||||||
Progress = lookup_widget(ConfDlg, "GtkProgressBar_Progress");
|
Progress = lookup_widget(ConfDlg, "GtkProgressBar_Progress");
|
||||||
|
|
||||||
BtnCompress = lookup_widget(ConfDlg, "GtkButton_Compress");
|
BtnCompress = lookup_widget(ConfDlg, "GtkButton_Compress");
|
||||||
BtnDecompress = lookup_widget(ConfDlg, "GtkButton_Decompress");
|
BtnDecompress = lookup_widget(ConfDlg, "GtkButton_Decompress");
|
||||||
BtnCreate = lookup_widget(ConfDlg, "GtkButton_Create");
|
BtnCreate = lookup_widget(ConfDlg, "GtkButton_Create");
|
||||||
BtnCreateZ = lookup_widget(ConfDlg, "GtkButton_CreateZ");
|
BtnCreateZ = lookup_widget(ConfDlg, "GtkButton_CreateZ");
|
||||||
|
|
||||||
methodlist = NULL;
|
methodlist = NULL;
|
||||||
for (i = 0; i < 2; i++)
|
for (i = 0; i < 2; i++)
|
||||||
methodlist = g_list_append(methodlist, methods[i]);
|
methodlist = g_list_append(methodlist, methods[i]);
|
||||||
|
|
||||||
Method = lookup_widget(ConfDlg, "GtkCombo_Method");
|
Method = lookup_widget(ConfDlg, "GtkCombo_Method");
|
||||||
gtk_combo_set_popdown_strings(GTK_COMBO(Method), methodlist);
|
gtk_combo_set_popdown_strings(GTK_COMBO(Method), methodlist);
|
||||||
if (strstr(IsoFile, ".Z") != NULL)
|
if (strstr(IsoFile, ".Z") != NULL)
|
||||||
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(Method)->entry), methods[0]);
|
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(Method)->entry), methods[0]);
|
||||||
else
|
else
|
||||||
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(Method)->entry), methods[1]);
|
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(Method)->entry), methods[1]);
|
||||||
|
|
||||||
set_checked(ConfDlg, "checkBlockDump", (BlockDump == 1));
|
set_checked(ConfDlg, "checkBlockDump", (BlockDump == 1));
|
||||||
|
|
||||||
gtk_widget_show_all(ConfDlg);
|
|
||||||
gtk_main();
|
|
||||||
|
|
||||||
|
gtk_widget_show_all(ConfDlg);
|
||||||
|
gtk_main();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnAboutOk(GtkMenuItem * menuitem, gpointer userdata)
|
void OnAboutOk(GtkMenuItem *menuitem, gpointer userdata)
|
||||||
{
|
{
|
||||||
gtk_widget_hide(AboutDlg);
|
gtk_widget_hide(AboutDlg);
|
||||||
gtk_main_quit();
|
gtk_main_quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(void) CDVDabout()
|
EXPORT_C_(void)
|
||||||
|
CDVDabout()
|
||||||
{
|
{
|
||||||
GtkWidget *Label;
|
GtkWidget *Label;
|
||||||
GtkWidget *Ok;
|
GtkWidget *Ok;
|
||||||
GtkWidget *Box, *BBox;
|
GtkWidget *Box, *BBox;
|
||||||
char AboutText[255];
|
char AboutText[255];
|
||||||
|
|
||||||
sprintf(AboutText, "%s %d.%d\n", LibName, revision, build);
|
sprintf(AboutText, "%s %d.%d\n", LibName, revision, build);
|
||||||
|
|
||||||
AboutDlg = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
AboutDlg = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||||
gtk_widget_set_usize(AboutDlg, 260, 80);
|
gtk_widget_set_usize(AboutDlg, 260, 80);
|
||||||
gtk_window_set_title(GTK_WINDOW(AboutDlg), "CDVD About Dialog");
|
gtk_window_set_title(GTK_WINDOW(AboutDlg), "CDVD About Dialog");
|
||||||
gtk_window_set_position(GTK_WINDOW(AboutDlg), GTK_WIN_POS_CENTER);
|
gtk_window_set_position(GTK_WINDOW(AboutDlg), GTK_WIN_POS_CENTER);
|
||||||
gtk_container_set_border_width(GTK_CONTAINER(AboutDlg), 10);
|
gtk_container_set_border_width(GTK_CONTAINER(AboutDlg), 10);
|
||||||
|
|
||||||
Box = gtk_vbox_new(0, 0);
|
Box = gtk_vbox_new(0, 0);
|
||||||
gtk_container_add(GTK_CONTAINER(AboutDlg), Box);
|
gtk_container_add(GTK_CONTAINER(AboutDlg), Box);
|
||||||
gtk_widget_show(Box);
|
gtk_widget_show(Box);
|
||||||
|
|
||||||
Label = gtk_label_new(AboutText);
|
Label = gtk_label_new(AboutText);
|
||||||
gtk_box_pack_start(GTK_BOX(Box), Label, FALSE, FALSE, 0);
|
gtk_box_pack_start(GTK_BOX(Box), Label, FALSE, FALSE, 0);
|
||||||
gtk_widget_show(Label);
|
gtk_widget_show(Label);
|
||||||
|
|
||||||
BBox = gtk_hbutton_box_new();
|
BBox = gtk_hbutton_box_new();
|
||||||
gtk_box_pack_start(GTK_BOX(Box), BBox, FALSE, FALSE, 0);
|
gtk_box_pack_start(GTK_BOX(Box), BBox, FALSE, FALSE, 0);
|
||||||
gtk_widget_show(BBox);
|
gtk_widget_show(BBox);
|
||||||
|
|
||||||
Ok = gtk_button_new_with_label("Ok");
|
Ok = gtk_button_new_with_label("Ok");
|
||||||
gtk_signal_connect(GTK_OBJECT(Ok), "clicked",
|
gtk_signal_connect(GTK_OBJECT(Ok), "clicked",
|
||||||
GTK_SIGNAL_FUNC(OnAboutOk), NULL);
|
GTK_SIGNAL_FUNC(OnAboutOk), NULL);
|
||||||
gtk_container_add(GTK_CONTAINER(BBox), Ok);
|
gtk_container_add(GTK_CONTAINER(BBox), Ok);
|
||||||
GTK_WIDGET_SET_FLAGS(Ok, GTK_CAN_DEFAULT);
|
GTK_WIDGET_SET_FLAGS(Ok, GTK_CAN_DEFAULT);
|
||||||
gtk_widget_show(Ok);
|
gtk_widget_show(Ok);
|
||||||
|
|
||||||
gtk_widget_show(AboutDlg);
|
gtk_widget_show(AboutDlg);
|
||||||
gtk_main();
|
gtk_main();
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,9 +31,8 @@
|
||||||
#include <bzlib.h>
|
#include <bzlib.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C"
|
extern "C" {
|
||||||
{
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "support.h"
|
#include "support.h"
|
||||||
|
@ -59,7 +58,7 @@ extern GtkWidget *AboutDlg, *ConfDlg, *MsgDlg, *FileSel;
|
||||||
extern GtkWidget *Edit, *CdEdit;
|
extern GtkWidget *Edit, *CdEdit;
|
||||||
extern bool stop;
|
extern bool stop;
|
||||||
|
|
||||||
extern GtkWidget *Method,*Progress;
|
extern GtkWidget *Method, *Progress;
|
||||||
extern GtkWidget *BtnCompress, *BtnDecompress;
|
extern GtkWidget *BtnCompress, *BtnDecompress;
|
||||||
extern GtkWidget *BtnCreate, *BtnCreateZ;
|
extern GtkWidget *BtnCreate, *BtnCreateZ;
|
||||||
|
|
||||||
|
@ -67,7 +66,7 @@ extern GList *methodlist;
|
||||||
|
|
||||||
// Make it easier to check and set checkmarks in the gui
|
// Make it easier to check and set checkmarks in the gui
|
||||||
#define is_checked(main_widget, widget_name) (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(main_widget, widget_name))))
|
#define is_checked(main_widget, widget_name) (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(main_widget, widget_name))))
|
||||||
#define set_checked(main_widget,widget_name, state) gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(main_widget, widget_name)), state)
|
#define set_checked(main_widget, widget_name, state) gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(main_widget, widget_name)), state)
|
||||||
|
|
||||||
|
|
||||||
extern void OnFileSel(GtkButton *button, gpointer user_data);
|
extern void OnFileSel(GtkButton *button, gpointer user_data);
|
||||||
|
@ -78,4 +77,3 @@ extern void OnCreate(GtkButton *button, gpointer user_data);
|
||||||
extern void OnCreateZ(GtkButton *button, gpointer user_data);
|
extern void OnCreateZ(GtkButton *button, gpointer user_data);
|
||||||
extern void OnOk(GtkButton *button, gpointer user_data);
|
extern void OnOk(GtkButton *button, gpointer user_data);
|
||||||
extern void OnCancel(GtkButton *button, gpointer user_data);
|
extern void OnCancel(GtkButton *button, gpointer user_data);
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
unsigned char Zbuf[CD_FRAMESIZE_RAW * 10 * 2];
|
unsigned char Zbuf[CD_FRAMESIZE_RAW * 10 * 2];
|
||||||
|
|
||||||
GtkWidget *Method,*Progress;
|
GtkWidget *Method, *Progress;
|
||||||
GtkWidget *BtnCompress, *BtnDecompress;
|
GtkWidget *BtnCompress, *BtnDecompress;
|
||||||
GtkWidget *BtnCreate, *BtnCreateZ;
|
GtkWidget *BtnCreate, *BtnCreateZ;
|
||||||
|
|
||||||
|
@ -30,107 +30,112 @@ unsigned char param[4];
|
||||||
int cddev = -1;
|
int cddev = -1;
|
||||||
bool stop;
|
bool stop;
|
||||||
|
|
||||||
#define CD_LEADOUT (0xaa)
|
#define CD_LEADOUT (0xaa)
|
||||||
|
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
struct cdrom_msf msf;
|
struct cdrom_msf msf;
|
||||||
unsigned char buf[CD_FRAMESIZE_RAW];
|
unsigned char buf[CD_FRAMESIZE_RAW];
|
||||||
} cr;
|
} cr;
|
||||||
|
|
||||||
void OnStop(GtkButton *button, gpointer user_data)
|
void OnStop(GtkButton *button, gpointer user_data)
|
||||||
{
|
{
|
||||||
stop = true;
|
stop = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdZmode()
|
void UpdZmode()
|
||||||
{
|
{
|
||||||
const char *tmp;
|
const char *tmp;
|
||||||
|
|
||||||
tmp = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(Method)->entry));
|
tmp = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(Method)->entry));
|
||||||
if (!strcmp(tmp, methods[0])) Zmode = 1;
|
if (!strcmp(tmp, methods[0]))
|
||||||
else Zmode = 2;
|
Zmode = 1;
|
||||||
|
else
|
||||||
|
Zmode = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
char buffer[2352 * 10];
|
char buffer[2352 * 10];
|
||||||
|
|
||||||
void OnCompress(GtkButton *button, gpointer user_data)
|
void OnCompress(GtkButton *button, gpointer user_data)
|
||||||
{
|
{
|
||||||
struct stat buf;
|
struct stat buf;
|
||||||
u32 lsn;
|
u32 lsn;
|
||||||
u8 cdbuff[10*2352];
|
u8 cdbuff[10 * 2352];
|
||||||
char Zfile[256];
|
char Zfile[256];
|
||||||
const char *tmp;
|
const char *tmp;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
isoFile *src;
|
isoFile *src;
|
||||||
isoFile *dst;
|
isoFile *dst;
|
||||||
|
|
||||||
tmp = gtk_entry_get_text(GTK_ENTRY(Edit));
|
tmp = gtk_entry_get_text(GTK_ENTRY(Edit));
|
||||||
strcpy(IsoFile, tmp);
|
strcpy(IsoFile, tmp);
|
||||||
UpdZmode();
|
UpdZmode();
|
||||||
|
|
||||||
if (Zmode == 1) sprintf(Zfile, "%s.Z2", IsoFile);
|
if (Zmode == 1)
|
||||||
if (Zmode == 2) sprintf(Zfile, "%s.BZ2", IsoFile);
|
sprintf(Zfile, "%s.Z2", IsoFile);
|
||||||
|
if (Zmode == 2)
|
||||||
|
sprintf(Zfile, "%s.BZ2", IsoFile);
|
||||||
|
|
||||||
if (stat(Zfile, &buf) != -1)
|
if (stat(Zfile, &buf) != -1) {
|
||||||
{
|
/*char str[256];*/
|
||||||
/*char str[256];*/
|
return;
|
||||||
return;
|
/* sprintf(str, "'%s' already exists, overwrite?", Zfile);
|
||||||
/* sprintf(str, "'%s' already exists, overwrite?", Zfile);
|
|
||||||
if (MessageBox(hDlg, str, "Question", MB_YESNO) != IDYES) {
|
if (MessageBox(hDlg, str, "Question", MB_YESNO) != IDYES) {
|
||||||
return;
|
return;
|
||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
src = isoOpen(IsoFile);
|
src = isoOpen(IsoFile);
|
||||||
if (src == NULL) return;
|
if (src == NULL)
|
||||||
dst = isoCreate(Zfile, Zmode == 1 ? ISOFLAGS_Z2 : ISOFLAGS_BZ2);
|
return;
|
||||||
if (dst == NULL) return;
|
dst = isoCreate(Zfile, Zmode == 1 ? ISOFLAGS_Z2 : ISOFLAGS_BZ2);
|
||||||
|
if (dst == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
gtk_widget_set_sensitive(BtnCompress, FALSE);
|
gtk_widget_set_sensitive(BtnCompress, FALSE);
|
||||||
gtk_widget_set_sensitive(BtnDecompress, FALSE);
|
gtk_widget_set_sensitive(BtnDecompress, FALSE);
|
||||||
gtk_widget_set_sensitive(BtnCreate, FALSE);
|
gtk_widget_set_sensitive(BtnCreate, FALSE);
|
||||||
gtk_widget_set_sensitive(BtnCreateZ, FALSE);
|
gtk_widget_set_sensitive(BtnCreateZ, FALSE);
|
||||||
stop = false;
|
stop = false;
|
||||||
|
|
||||||
for (lsn = 0; lsn < src->blocks; lsn++)
|
for (lsn = 0; lsn < src->blocks; lsn++) {
|
||||||
{
|
printf("block %d ", lsn);
|
||||||
printf("block %d ", lsn);
|
putchar(13);
|
||||||
putchar(13);
|
fflush(stdout);
|
||||||
fflush(stdout);
|
ret = isoReadBlock(src, cdbuff, lsn);
|
||||||
ret = isoReadBlock(src, cdbuff, lsn);
|
if (ret == -1)
|
||||||
if (ret == -1) break;
|
break;
|
||||||
ret = isoWriteBlock(dst, cdbuff, lsn);
|
ret = isoWriteBlock(dst, cdbuff, lsn);
|
||||||
if (ret == -1) break;
|
if (ret == -1)
|
||||||
|
break;
|
||||||
|
|
||||||
gtk_progress_bar_update(GTK_PROGRESS_BAR(Progress), (lsn * 100) / src->blocks);
|
gtk_progress_bar_update(GTK_PROGRESS_BAR(Progress), (lsn * 100) / src->blocks);
|
||||||
while (gtk_events_pending()) gtk_main_iteration();
|
while (gtk_events_pending())
|
||||||
if (stop) break;
|
gtk_main_iteration();
|
||||||
}
|
if (stop)
|
||||||
isoClose(src);
|
break;
|
||||||
isoClose(dst);
|
}
|
||||||
|
isoClose(src);
|
||||||
|
isoClose(dst);
|
||||||
|
|
||||||
if (!stop) gtk_entry_set_text(GTK_ENTRY(Edit), IsoFile);
|
if (!stop)
|
||||||
|
gtk_entry_set_text(GTK_ENTRY(Edit), IsoFile);
|
||||||
|
|
||||||
gtk_widget_set_sensitive(BtnCompress, TRUE);
|
gtk_widget_set_sensitive(BtnCompress, TRUE);
|
||||||
gtk_widget_set_sensitive(BtnDecompress, TRUE);
|
gtk_widget_set_sensitive(BtnDecompress, TRUE);
|
||||||
gtk_widget_set_sensitive(BtnCreate, TRUE);
|
gtk_widget_set_sensitive(BtnCreate, TRUE);
|
||||||
gtk_widget_set_sensitive(BtnCreateZ, TRUE);
|
gtk_widget_set_sensitive(BtnCreateZ, TRUE);
|
||||||
|
|
||||||
if (!stop)
|
if (!stop) {
|
||||||
{
|
if (ret == -1) {
|
||||||
if (ret == -1)
|
SysMessageLoc("Error compressing iso image");
|
||||||
{
|
} else {
|
||||||
SysMessageLoc("Error compressing iso image");
|
SysMessageLoc("Iso image compressed OK");
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
{
|
|
||||||
SysMessageLoc("Iso image compressed OK");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnDecompress(GtkButton *button, gpointer user_data)
|
void OnDecompress(GtkButton *button, gpointer user_data)
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
struct stat buf;
|
struct stat buf;
|
||||||
|
@ -255,40 +260,38 @@ void OnDecompress(GtkButton *button, gpointer user_data)
|
||||||
|
|
||||||
void incSector()
|
void incSector()
|
||||||
{
|
{
|
||||||
param[2]++;
|
param[2]++;
|
||||||
if (param[2] == 75)
|
if (param[2] == 75) {
|
||||||
{
|
param[2] = 0;
|
||||||
param[2] = 0;
|
param[1]++;
|
||||||
param[1]++;
|
}
|
||||||
}
|
if (param[1] == 60) {
|
||||||
if (param[1] == 60)
|
param[1] = 0;
|
||||||
{
|
param[0]++;
|
||||||
param[1] = 0;
|
}
|
||||||
param[0]++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
long CDR_open(void)
|
long CDR_open(void)
|
||||||
{
|
{
|
||||||
if (cddev != -1)
|
if (cddev != -1)
|
||||||
return 0;
|
return 0;
|
||||||
cddev = open(CdDev, O_RDONLY);
|
cddev = open(CdDev, O_RDONLY);
|
||||||
if (cddev == -1)
|
if (cddev == -1) {
|
||||||
{
|
printf("CDR: Could not open %s\n", CdDev);
|
||||||
printf("CDR: Could not open %s\n", CdDev);
|
return -1;
|
||||||
return -1;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
long CDR_close(void)
|
long CDR_close(void)
|
||||||
{
|
{
|
||||||
if (cddev == -1) return 0;
|
if (cddev == -1)
|
||||||
close(cddev);
|
return 0;
|
||||||
cddev = -1;
|
close(cddev);
|
||||||
|
cddev = -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// return Starting and Ending Track
|
// return Starting and Ending Track
|
||||||
|
@ -297,14 +300,15 @@ long CDR_close(void)
|
||||||
// byte 1 - end track
|
// byte 1 - end track
|
||||||
long CDR_getTN(unsigned char *buffer)
|
long CDR_getTN(unsigned char *buffer)
|
||||||
{
|
{
|
||||||
struct cdrom_tochdr toc;
|
struct cdrom_tochdr toc;
|
||||||
|
|
||||||
if (ioctl(cddev, CDROMREADTOCHDR, &toc) == -1) return -1;
|
if (ioctl(cddev, CDROMREADTOCHDR, &toc) == -1)
|
||||||
|
return -1;
|
||||||
|
|
||||||
buffer[0] = toc.cdth_trk0; // start track
|
buffer[0] = toc.cdth_trk0; // start track
|
||||||
buffer[1] = toc.cdth_trk1; // end track
|
buffer[1] = toc.cdth_trk1; // end track
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// return Track Time
|
// return Track Time
|
||||||
|
@ -314,19 +318,21 @@ long CDR_getTN(unsigned char *buffer)
|
||||||
// byte 2 - minute
|
// byte 2 - minute
|
||||||
long CDR_getTD(unsigned char track, unsigned char *buffer)
|
long CDR_getTD(unsigned char track, unsigned char *buffer)
|
||||||
{
|
{
|
||||||
struct cdrom_tocentry entry;
|
struct cdrom_tocentry entry;
|
||||||
|
|
||||||
if (track == 0) track = 0xaa; // total time
|
if (track == 0)
|
||||||
entry.cdte_track = track;
|
track = 0xaa; // total time
|
||||||
entry.cdte_format = CDROM_MSF;
|
entry.cdte_track = track;
|
||||||
|
entry.cdte_format = CDROM_MSF;
|
||||||
|
|
||||||
if (ioctl(cddev, CDROMREADTOCENTRY, &entry) == -1) return -1;
|
if (ioctl(cddev, CDROMREADTOCENTRY, &entry) == -1)
|
||||||
|
return -1;
|
||||||
|
|
||||||
buffer[0] = entry.cdte_addr.msf.minute; /* minute */
|
buffer[0] = entry.cdte_addr.msf.minute; /* minute */
|
||||||
buffer[1] = entry.cdte_addr.msf.second; /* second */
|
buffer[1] = entry.cdte_addr.msf.second; /* second */
|
||||||
buffer[2] = entry.cdte_addr.msf.frame; /* frame */
|
buffer[2] = entry.cdte_addr.msf.frame; /* frame */
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// read track
|
// read track
|
||||||
|
@ -336,340 +342,333 @@ long CDR_getTD(unsigned char track, unsigned char *buffer)
|
||||||
// byte 2 - frame
|
// byte 2 - frame
|
||||||
unsigned char *CDR_readTrack(unsigned char *time)
|
unsigned char *CDR_readTrack(unsigned char *time)
|
||||||
{
|
{
|
||||||
cr.msf.cdmsf_min0 = time[0];
|
cr.msf.cdmsf_min0 = time[0];
|
||||||
cr.msf.cdmsf_sec0 = time[1];
|
cr.msf.cdmsf_sec0 = time[1];
|
||||||
cr.msf.cdmsf_frame0 = time[2];
|
cr.msf.cdmsf_frame0 = time[2];
|
||||||
|
|
||||||
if (ioctl(cddev, CDROMREADRAW, &cr) == -1) return NULL;
|
if (ioctl(cddev, CDROMREADRAW, &cr) == -1)
|
||||||
return cr.buf;
|
return NULL;
|
||||||
|
return cr.buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void OnCreate(GtkButton *button, gpointer user_data)
|
void OnCreate(GtkButton *button, gpointer user_data)
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
struct stat buf;
|
struct stat buf;
|
||||||
struct tm *Tm;
|
struct tm *Tm;
|
||||||
time_t Ttime;
|
time_t Ttime;
|
||||||
unsigned long ftrack, ltrack;
|
unsigned long ftrack, ltrack;
|
||||||
unsigned long p = 0, s;
|
unsigned long p = 0, s;
|
||||||
unsigned char *buffer;
|
unsigned char *buffer;
|
||||||
unsigned char bufferz[2352];
|
unsigned char bufferz[2352];
|
||||||
unsigned char start[4], end[4];
|
unsigned char start[4], end[4];
|
||||||
const char *tmp;
|
const char *tmp;
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
unsigned long count = 0;
|
unsigned long count = 0;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
memset(bufferz, 0, sizeof(bufferz));
|
memset(bufferz, 0, sizeof(bufferz));
|
||||||
ftrack = 1;
|
ftrack = 1;
|
||||||
ltrack = CD_LEADOUT;
|
ltrack = CD_LEADOUT;
|
||||||
|
|
||||||
tmp = gtk_entry_get_text(GTK_ENTRY(Edit));
|
tmp = gtk_entry_get_text(GTK_ENTRY(Edit));
|
||||||
strcpy(IsoFile, tmp);
|
strcpy(IsoFile, tmp);
|
||||||
|
|
||||||
if (stat(IsoFile, &buf) == 0)
|
if (stat(IsoFile, &buf) == 0) {
|
||||||
{
|
printf("File %s Already exists\n", IsoFile);
|
||||||
printf("File %s Already exists\n", IsoFile);
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (CDR_open() == -1)
|
if (CDR_open() == -1) {
|
||||||
{
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (CDR_getTD(ftrack, start) == -1)
|
if (CDR_getTD(ftrack, start) == -1) {
|
||||||
{
|
printf("Error getting TD\n");
|
||||||
printf("Error getting TD\n");
|
|
||||||
|
|
||||||
CDR_close();
|
CDR_close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (CDR_getTD(ltrack, end) == -1)
|
if (CDR_getTD(ltrack, end) == -1) {
|
||||||
{
|
printf("Error getting TD\n");
|
||||||
printf("Error getting TD\n");
|
|
||||||
|
|
||||||
CDR_close();
|
CDR_close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
f = fopen(IsoFile, "wb");
|
f = fopen(IsoFile, "wb");
|
||||||
if (f == NULL)
|
if (f == NULL) {
|
||||||
{
|
CDR_close();
|
||||||
CDR_close();
|
printf("Error opening %s", IsoFile);
|
||||||
printf("Error opening %s", IsoFile);
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
printf("Making Iso: from %2.2d:%2.2d:%2.2d to %2.2d:%2.2d:%2.2d\n",
|
printf("Making Iso: from %2.2d:%2.2d:%2.2d to %2.2d:%2.2d:%2.2d\n",
|
||||||
start[0], start[1], start[2], end[0], end[1], end[2]);
|
start[0], start[1], start[2], end[0], end[1], end[2]);
|
||||||
|
|
||||||
memcpy(param, start, 3);
|
memcpy(param, start, 3);
|
||||||
|
|
||||||
time(&Ttime);
|
time(&Ttime);
|
||||||
|
|
||||||
stop = false;
|
stop = false;
|
||||||
s = MSF2SECT(end[0], end[1], end[2]);
|
s = MSF2SECT(end[0], end[1], end[2]);
|
||||||
gtk_widget_set_sensitive(BtnCompress, FALSE);
|
gtk_widget_set_sensitive(BtnCompress, FALSE);
|
||||||
gtk_widget_set_sensitive(BtnDecompress, FALSE);
|
gtk_widget_set_sensitive(BtnDecompress, FALSE);
|
||||||
gtk_widget_set_sensitive(BtnCreate, FALSE);
|
gtk_widget_set_sensitive(BtnCreate, FALSE);
|
||||||
gtk_widget_set_sensitive(BtnCreateZ, FALSE);
|
gtk_widget_set_sensitive(BtnCreateZ, FALSE);
|
||||||
|
|
||||||
for (;;) /* loop until end */
|
for (;;) /* loop until end */
|
||||||
{
|
{
|
||||||
float per;
|
float per;
|
||||||
|
|
||||||
if ((param[0] == end[0]) & (param[1] == end[1]) & (param[2] == end[2]))
|
if ((param[0] == end[0]) & (param[1] == end[1]) & (param[2] == end[2]))
|
||||||
break;
|
break;
|
||||||
buffer = CDR_readTrack(param);
|
buffer = CDR_readTrack(param);
|
||||||
if (buffer == NULL)
|
if (buffer == NULL) {
|
||||||
{
|
int i;
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < 10; i++)
|
for (i = 0; i < 10; i++) {
|
||||||
{
|
buffer = CDR_readTrack(param);
|
||||||
buffer = CDR_readTrack(param);
|
if (buffer != NULL)
|
||||||
if (buffer != NULL) break;
|
break;
|
||||||
}
|
}
|
||||||
if (buffer == NULL)
|
if (buffer == NULL) {
|
||||||
{
|
printf("Error Reading %2d:%2d:%2d\n", param[0], param[1], param[2]);
|
||||||
printf("Error Reading %2d:%2d:%2d\n", param[0], param[1], param[2]);
|
buffer = bufferz;
|
||||||
buffer = bufferz;
|
buffer[12] = param[0];
|
||||||
buffer[12] = param[0];
|
buffer[13] = param[1];
|
||||||
buffer[13] = param[1];
|
buffer[14] = param[2];
|
||||||
buffer[14] = param[2];
|
buffer[15] = 0x2;
|
||||||
buffer[15] = 0x2;
|
}
|
||||||
}
|
}
|
||||||
}
|
fwrite(buffer, 1, 2352, f);
|
||||||
fwrite(buffer, 1, 2352, f);
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
count += CD_FRAMESIZE_RAW;
|
count += CD_FRAMESIZE_RAW;
|
||||||
|
|
||||||
printf("reading %2d:%2d:%2d ", param[0], param[1], param[2]);
|
printf("reading %2d:%2d:%2d ", param[0], param[1], param[2]);
|
||||||
if ((time(NULL) - Ttime) != 0)
|
if ((time(NULL) - Ttime) != 0) {
|
||||||
{
|
i = (count / 1024) / (time(NULL) - Ttime);
|
||||||
i = (count / 1024) / (time(NULL) - Ttime);
|
printf("( %5dKbytes/s, %dX)", i, i / 150);
|
||||||
printf("( %5dKbytes/s, %dX)", i, i / 150);
|
}
|
||||||
}
|
putchar(13);
|
||||||
putchar(13);
|
fflush(stdout);
|
||||||
fflush(stdout);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
incSector();
|
incSector();
|
||||||
|
|
||||||
p++;
|
p++;
|
||||||
per = ((float)p / s);
|
per = ((float)p / s);
|
||||||
gtk_progress_bar_update(GTK_PROGRESS_BAR(Progress), per);
|
gtk_progress_bar_update(GTK_PROGRESS_BAR(Progress), per);
|
||||||
while (gtk_events_pending()) gtk_main_iteration();
|
while (gtk_events_pending())
|
||||||
if (stop) break;
|
gtk_main_iteration();
|
||||||
}
|
if (stop)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
Ttime = time(NULL) - Ttime;
|
Ttime = time(NULL) - Ttime;
|
||||||
Tm = gmtime(&Ttime);
|
Tm = gmtime(&Ttime);
|
||||||
printf("\nTotal Time used: %d:%d:%d\n", Tm->tm_hour, Tm->tm_min,
|
printf("\nTotal Time used: %d:%d:%d\n", Tm->tm_hour, Tm->tm_min,
|
||||||
Tm->tm_sec);
|
Tm->tm_sec);
|
||||||
|
|
||||||
CDR_close();
|
CDR_close();
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
gtk_widget_set_sensitive(BtnCompress, TRUE);
|
gtk_widget_set_sensitive(BtnCompress, TRUE);
|
||||||
gtk_widget_set_sensitive(BtnDecompress, TRUE);
|
gtk_widget_set_sensitive(BtnDecompress, TRUE);
|
||||||
gtk_widget_set_sensitive(BtnCreate, TRUE);
|
gtk_widget_set_sensitive(BtnCreate, TRUE);
|
||||||
gtk_widget_set_sensitive(BtnCreateZ, TRUE);
|
gtk_widget_set_sensitive(BtnCreateZ, TRUE);
|
||||||
|
|
||||||
if (!stop) SysMessageLoc("Iso Image Created OK");
|
if (!stop)
|
||||||
|
SysMessageLoc("Iso Image Created OK");
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnCreateZ(GtkButton *button, gpointer user_data)
|
void OnCreateZ(GtkButton *button, gpointer user_data)
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
FILE *t;
|
FILE *t;
|
||||||
struct stat buf;
|
struct stat buf;
|
||||||
struct tm *Tm;
|
struct tm *Tm;
|
||||||
time_t Ttime;
|
time_t Ttime;
|
||||||
unsigned long ftrack, ltrack;
|
unsigned long ftrack, ltrack;
|
||||||
unsigned long p = 0, s, c = 0;
|
unsigned long p = 0, s, c = 0;
|
||||||
unsigned char *buffer;
|
unsigned char *buffer;
|
||||||
unsigned char bufferz[2352];
|
unsigned char bufferz[2352];
|
||||||
unsigned char start[4], end[4];
|
unsigned char start[4], end[4];
|
||||||
char table[256];
|
char table[256];
|
||||||
const char *tmp;
|
const char *tmp;
|
||||||
int b, blocks;
|
int b, blocks;
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
unsigned long count = 0;
|
unsigned long count = 0;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
memset(bufferz, 0, sizeof(bufferz));
|
memset(bufferz, 0, sizeof(bufferz));
|
||||||
ftrack = 1;
|
ftrack = 1;
|
||||||
ltrack = CD_LEADOUT;
|
ltrack = CD_LEADOUT;
|
||||||
|
|
||||||
tmp = gtk_entry_get_text(GTK_ENTRY(Edit));
|
tmp = gtk_entry_get_text(GTK_ENTRY(Edit));
|
||||||
strcpy(IsoFile, tmp);
|
strcpy(IsoFile, tmp);
|
||||||
|
|
||||||
UpdZmode();
|
UpdZmode();
|
||||||
|
|
||||||
if (Zmode == 1)
|
if (Zmode == 1) {
|
||||||
{
|
blocks = 1;
|
||||||
blocks = 1;
|
if (strstr(IsoFile, ".Z") == NULL)
|
||||||
if (strstr(IsoFile, ".Z") == NULL) strcat(IsoFile, ".Z");
|
strcat(IsoFile, ".Z");
|
||||||
}
|
} else {
|
||||||
else
|
blocks = 10;
|
||||||
{
|
if (strstr(IsoFile, ".bz") == NULL)
|
||||||
blocks = 10;
|
strcat(IsoFile, ".bz");
|
||||||
if (strstr(IsoFile, ".bz") == NULL) strcat(IsoFile, ".bz");
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (stat(IsoFile, &buf) == 0)
|
if (stat(IsoFile, &buf) == 0) {
|
||||||
{
|
printf("File %s Already exists\n", IsoFile);
|
||||||
printf("File %s Already exists\n", IsoFile);
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
strcpy(table, IsoFile);
|
strcpy(table, IsoFile);
|
||||||
if (Zmode == 1)
|
if (Zmode == 1)
|
||||||
strcat(table, ".table");
|
strcat(table, ".table");
|
||||||
else
|
else
|
||||||
strcat(table, ".index");
|
strcat(table, ".index");
|
||||||
|
|
||||||
t = fopen(table, "wb");
|
t = fopen(table, "wb");
|
||||||
|
|
||||||
if (t == NULL) return;
|
if (t == NULL)
|
||||||
if (CDR_open() == -1)
|
return;
|
||||||
{
|
if (CDR_open() == -1) {
|
||||||
fclose(t);
|
fclose(t);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (CDR_getTD(ftrack, start) == -1)
|
if (CDR_getTD(ftrack, start) == -1) {
|
||||||
{
|
printf("Error getting TD\n");
|
||||||
printf("Error getting TD\n");
|
CDR_close();
|
||||||
CDR_close();
|
fclose(t);
|
||||||
fclose(t);
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (CDR_getTD(ltrack, end) == -1)
|
if (CDR_getTD(ltrack, end) == -1) {
|
||||||
{
|
printf("Error getting TD\n");
|
||||||
printf("Error getting TD\n");
|
CDR_close();
|
||||||
CDR_close();
|
fclose(t);
|
||||||
fclose(t);
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
f = fopen(IsoFile, "wb");
|
f = fopen(IsoFile, "wb");
|
||||||
if (f == NULL)
|
if (f == NULL) {
|
||||||
{
|
CDR_close();
|
||||||
CDR_close();
|
fclose(t);
|
||||||
fclose(t);
|
printf("Error opening %s", IsoFile);
|
||||||
printf("Error opening %s", IsoFile);
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
printf("Making Iso: from %2.2d:%2.2d:%2.2d to %2.2d:%2.2d:%2.2d\n",
|
printf("Making Iso: from %2.2d:%2.2d:%2.2d to %2.2d:%2.2d:%2.2d\n",
|
||||||
start[0], start[1], start[2], end[0], end[1], end[2]);
|
start[0], start[1], start[2], end[0], end[1], end[2]);
|
||||||
|
|
||||||
memcpy(param, start, 3);
|
memcpy(param, start, 3);
|
||||||
|
|
||||||
time(&Ttime);
|
time(&Ttime);
|
||||||
|
|
||||||
stop = false;
|
stop = false;
|
||||||
s = MSF2SECT(end[0], end[1], end[2]) / blocks;
|
s = MSF2SECT(end[0], end[1], end[2]) / blocks;
|
||||||
gtk_widget_set_sensitive(BtnCompress, FALSE);
|
gtk_widget_set_sensitive(BtnCompress, FALSE);
|
||||||
gtk_widget_set_sensitive(BtnDecompress, FALSE);
|
gtk_widget_set_sensitive(BtnDecompress, FALSE);
|
||||||
gtk_widget_set_sensitive(BtnCreate, FALSE);
|
gtk_widget_set_sensitive(BtnCreate, FALSE);
|
||||||
gtk_widget_set_sensitive(BtnCreateZ, FALSE);
|
gtk_widget_set_sensitive(BtnCreateZ, FALSE);
|
||||||
|
|
||||||
for (;;) /* loop until end */
|
for (;;) /* loop until end */
|
||||||
{
|
{
|
||||||
unsigned long size;
|
unsigned long size;
|
||||||
unsigned char Zbuf[CD_FRAMESIZE_RAW * 10 * 2];
|
unsigned char Zbuf[CD_FRAMESIZE_RAW * 10 * 2];
|
||||||
float per;
|
float per;
|
||||||
|
|
||||||
for (b = 0; b < blocks; b++)
|
for (b = 0; b < blocks; b++) {
|
||||||
{
|
if ((param[0] == end[0]) & (param[1] == end[1]) & (param[2] == end[2]))
|
||||||
if ((param[0] == end[0]) & (param[1] == end[1]) & (param[2] == end[2]))
|
break;
|
||||||
break;
|
|
||||||
|
|
||||||
buffer = CDR_readTrack(param);
|
buffer = CDR_readTrack(param);
|
||||||
if (buffer == NULL)
|
if (buffer == NULL) {
|
||||||
{
|
int i;
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < 10; i++)
|
for (i = 0; i < 10; i++) {
|
||||||
{
|
buffer = CDR_readTrack(param);
|
||||||
buffer = CDR_readTrack(param);
|
if (buffer != NULL)
|
||||||
if (buffer != NULL) break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buffer == NULL)
|
if (buffer == NULL) {
|
||||||
{
|
printf("Error Reading %2d:%2d:%2d\n", param[0], param[1], param[2]);
|
||||||
printf("Error Reading %2d:%2d:%2d\n", param[0], param[1], param[2]);
|
buffer = bufferz;
|
||||||
buffer = bufferz;
|
buffer[12] = param[0];
|
||||||
buffer[12] = param[0];
|
buffer[13] = param[1];
|
||||||
buffer[13] = param[1];
|
buffer[14] = param[2];
|
||||||
buffer[14] = param[2];
|
buffer[15] = 0x2;
|
||||||
buffer[15] = 0x2;
|
}
|
||||||
}
|
}
|
||||||
}
|
memcpy(cdbuffer + b * CD_FRAMESIZE_RAW, buffer, CD_FRAMESIZE_RAW);
|
||||||
memcpy(cdbuffer + b * CD_FRAMESIZE_RAW, buffer, CD_FRAMESIZE_RAW);
|
|
||||||
|
|
||||||
incSector();
|
incSector();
|
||||||
}
|
}
|
||||||
if ((param[0] == end[0]) & (param[1] == end[1]) & (param[2] == end[2]))
|
if ((param[0] == end[0]) & (param[1] == end[1]) & (param[2] == end[2]))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
size = CD_FRAMESIZE_RAW * blocks * 2;
|
size = CD_FRAMESIZE_RAW * blocks * 2;
|
||||||
if (Zmode == 1)
|
if (Zmode == 1)
|
||||||
compress(Zbuf, &size, cdbuffer, CD_FRAMESIZE_RAW);
|
compress(Zbuf, &size, cdbuffer, CD_FRAMESIZE_RAW);
|
||||||
else
|
else
|
||||||
BZ2_bzBuffToBuffCompress((char*)Zbuf, (unsigned int*)&size, (char*)cdbuffer, CD_FRAMESIZE_RAW * 10, 1, 0, 30);
|
BZ2_bzBuffToBuffCompress((char *)Zbuf, (unsigned int *)&size, (char *)cdbuffer, CD_FRAMESIZE_RAW * 10, 1, 0, 30);
|
||||||
|
|
||||||
fwrite(&c, 1, 4, t);
|
fwrite(&c, 1, 4, t);
|
||||||
if (Zmode == 1) fwrite(&size, 1, 2, t);
|
if (Zmode == 1)
|
||||||
|
fwrite(&size, 1, 2, t);
|
||||||
|
|
||||||
fwrite(Zbuf, 1, size, f);
|
fwrite(Zbuf, 1, size, f);
|
||||||
|
|
||||||
c += size;
|
c += size;
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
count += CD_FRAMESIZE_RAW * blocks;
|
count += CD_FRAMESIZE_RAW * blocks;
|
||||||
|
|
||||||
printf("reading %2d:%2d:%2d ", param[0], param[1], param[2]);
|
printf("reading %2d:%2d:%2d ", param[0], param[1], param[2]);
|
||||||
if ((time(NULL) - Ttime) != 0)
|
if ((time(NULL) - Ttime) != 0) {
|
||||||
{
|
i = (count / 1024) / (time(NULL) - Ttime);
|
||||||
i = (count / 1024) / (time(NULL) - Ttime);
|
printf("( %5dKbytes/s, %dX)", i, i / 150);
|
||||||
printf("( %5dKbytes/s, %dX)", i, i / 150);
|
}
|
||||||
}
|
putchar(13);
|
||||||
putchar(13);
|
fflush(stdout);
|
||||||
fflush(stdout);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
p++;
|
p++;
|
||||||
per = ((float)p / s);
|
per = ((float)p / s);
|
||||||
|
|
||||||
gtk_progress_bar_update(GTK_PROGRESS_BAR(Progress), per);
|
gtk_progress_bar_update(GTK_PROGRESS_BAR(Progress), per);
|
||||||
while (gtk_events_pending()) gtk_main_iteration();
|
while (gtk_events_pending())
|
||||||
|
gtk_main_iteration();
|
||||||
|
|
||||||
if (stop) break;
|
if (stop)
|
||||||
}
|
break;
|
||||||
if (Zmode == 2) fwrite(&c, 1, 4, f);
|
}
|
||||||
|
if (Zmode == 2)
|
||||||
|
fwrite(&c, 1, 4, f);
|
||||||
|
|
||||||
if (!stop) gtk_entry_set_text(GTK_ENTRY(Edit), IsoFile);
|
if (!stop)
|
||||||
|
gtk_entry_set_text(GTK_ENTRY(Edit), IsoFile);
|
||||||
|
|
||||||
Ttime = time(NULL) - Ttime;
|
Ttime = time(NULL) - Ttime;
|
||||||
Tm = gmtime(&Ttime);
|
Tm = gmtime(&Ttime);
|
||||||
printf("\nTotal Time used: %d:%d:%d\n", Tm->tm_hour, Tm->tm_min,
|
printf("\nTotal Time used: %d:%d:%d\n", Tm->tm_hour, Tm->tm_min,
|
||||||
Tm->tm_sec);
|
Tm->tm_sec);
|
||||||
|
|
||||||
CDR_close();
|
CDR_close();
|
||||||
fclose(f);
|
fclose(f);
|
||||||
fclose(t);
|
fclose(t);
|
||||||
|
|
||||||
gtk_widget_set_sensitive(BtnCompress, TRUE);
|
gtk_widget_set_sensitive(BtnCompress, TRUE);
|
||||||
gtk_widget_set_sensitive(BtnDecompress, TRUE);
|
gtk_widget_set_sensitive(BtnDecompress, TRUE);
|
||||||
gtk_widget_set_sensitive(BtnCreate, TRUE);
|
gtk_widget_set_sensitive(BtnCreate, TRUE);
|
||||||
gtk_widget_set_sensitive(BtnCreateZ, TRUE);
|
gtk_widget_set_sensitive(BtnCreateZ, TRUE);
|
||||||
|
|
||||||
if (!stop) SysMessageLoc("Compressed Iso Image Created OK");
|
if (!stop)
|
||||||
|
SysMessageLoc("Compressed Iso Image Created OK");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,34 +1,26 @@
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
|
||||||
void
|
void OnFileSel(GtkButton *button,
|
||||||
OnFileSel (GtkButton *button,
|
gpointer user_data);
|
||||||
gpointer user_data);
|
|
||||||
|
|
||||||
void
|
void OnStop(GtkButton *button,
|
||||||
OnStop (GtkButton *button,
|
gpointer user_data);
|
||||||
gpointer user_data);
|
|
||||||
|
|
||||||
void
|
void OnCompress(GtkButton *button,
|
||||||
OnCompress (GtkButton *button,
|
gpointer user_data);
|
||||||
gpointer user_data);
|
|
||||||
|
|
||||||
void
|
void OnDecompress(GtkButton *button,
|
||||||
OnDecompress (GtkButton *button,
|
gpointer user_data);
|
||||||
gpointer user_data);
|
|
||||||
|
|
||||||
void
|
void OnCreate(GtkButton *button,
|
||||||
OnCreate (GtkButton *button,
|
gpointer user_data);
|
||||||
gpointer user_data);
|
|
||||||
|
|
||||||
void
|
void OnCreateZ(GtkButton *button,
|
||||||
OnCreateZ (GtkButton *button,
|
gpointer user_data);
|
||||||
gpointer user_data);
|
|
||||||
|
|
||||||
void
|
void OnOk(GtkButton *button,
|
||||||
OnOk (GtkButton *button,
|
gpointer user_data);
|
||||||
gpointer user_data);
|
|
||||||
|
|
||||||
void
|
void OnCancel(GtkButton *button,
|
||||||
OnCancel (GtkButton *button,
|
gpointer user_data);
|
||||||
gpointer user_data);
|
|
||||||
|
|
|
@ -2,4 +2,4 @@
|
||||||
* DO NOT EDIT THIS FILE - it is generated by Glade.
|
* DO NOT EDIT THIS FILE - it is generated by Glade.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
GtkWidget* create_Config (void);
|
GtkWidget *create_Config(void);
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
# include <config.h>
|
#include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
@ -12,24 +12,24 @@
|
||||||
* Standard gettext macros.
|
* Standard gettext macros.
|
||||||
*/
|
*/
|
||||||
#ifdef ENABLE_NLS
|
#ifdef ENABLE_NLS
|
||||||
# include <libintl.h>
|
#include <libintl.h>
|
||||||
# undef _
|
#undef _
|
||||||
# define _(String) dgettext (PACKAGE, String)
|
#define _(String) dgettext(PACKAGE, String)
|
||||||
# define Q_(String) g_strip_context ((String), gettext (String))
|
#define Q_(String) g_strip_context((String), gettext(String))
|
||||||
# ifdef gettext_noop
|
#ifdef gettext_noop
|
||||||
# define N_(String) gettext_noop (String)
|
#define N_(String) gettext_noop(String)
|
||||||
# else
|
|
||||||
# define N_(String) (String)
|
|
||||||
# endif
|
|
||||||
#else
|
#else
|
||||||
# define textdomain(String) (String)
|
#define N_(String) (String)
|
||||||
# define gettext(String) (String)
|
#endif
|
||||||
# define dgettext(Domain,Message) (Message)
|
#else
|
||||||
# define dcgettext(Domain,Message,Type) (Message)
|
#define textdomain(String) (String)
|
||||||
# define bindtextdomain(Domain,Directory) (Domain)
|
#define gettext(String) (String)
|
||||||
# define _(String) (String)
|
#define dgettext(Domain, Message) (Message)
|
||||||
# define Q_(String) g_strip_context ((String), (String))
|
#define dcgettext(Domain, Message, Type) (Message)
|
||||||
# define N_(String) (String)
|
#define bindtextdomain(Domain, Directory) (Domain)
|
||||||
|
#define _(String) (String)
|
||||||
|
#define Q_(String) g_strip_context((String), (String))
|
||||||
|
#define N_(String) (String)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -43,12 +43,12 @@
|
||||||
* or alternatively any widget in the component, and the name of the widget
|
* or alternatively any widget in the component, and the name of the widget
|
||||||
* you want returned.
|
* you want returned.
|
||||||
*/
|
*/
|
||||||
GtkWidget* lookup_widget (GtkWidget *widget,
|
GtkWidget *lookup_widget(GtkWidget *widget,
|
||||||
const gchar *widget_name);
|
const gchar *widget_name);
|
||||||
|
|
||||||
|
|
||||||
/* Use this function to set the directory containing installed pixmaps. */
|
/* Use this function to set the directory containing installed pixmaps. */
|
||||||
void add_pixmap_directory (const gchar *directory);
|
void add_pixmap_directory(const gchar *directory);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -56,14 +56,13 @@ void add_pixmap_directory (const gchar *directory);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* This is used to create the pixmaps used in the interface. */
|
/* This is used to create the pixmaps used in the interface. */
|
||||||
GtkWidget* create_pixmap (GtkWidget *widget,
|
GtkWidget *create_pixmap(GtkWidget *widget,
|
||||||
const gchar *filename);
|
const gchar *filename);
|
||||||
|
|
||||||
/* This is used to create the pixbufs used in the interface. */
|
/* This is used to create the pixbufs used in the interface. */
|
||||||
GdkPixbuf* create_pixbuf (const gchar *filename);
|
GdkPixbuf *create_pixbuf(const gchar *filename);
|
||||||
|
|
||||||
/* This is used to set ATK action descriptions. */
|
/* This is used to set ATK action descriptions. */
|
||||||
void glade_set_atk_action_description (AtkAction *action,
|
void glade_set_atk_action_description(AtkAction *action,
|
||||||
const gchar *action_name,
|
const gchar *action_name,
|
||||||
const gchar *description);
|
const gchar *description);
|
||||||
|
|
||||||
|
|
|
@ -4,48 +4,48 @@
|
||||||
#include "../CDVDiso.h"
|
#include "../CDVDiso.h"
|
||||||
|
|
||||||
#define GetKeyV(name, var, s, t) \
|
#define GetKeyV(name, var, s, t) \
|
||||||
size = s; type = t; \
|
size = s; \
|
||||||
RegQueryValueEx(myKey, name, 0, &type, (LPBYTE) var, &size);
|
type = t; \
|
||||||
|
RegQueryValueEx(myKey, name, 0, &type, (LPBYTE)var, &size);
|
||||||
|
|
||||||
#define GetKeyVdw(name, var) \
|
#define GetKeyVdw(name, var) \
|
||||||
GetKeyV(name, var, 4, REG_DWORD);
|
GetKeyV(name, var, 4, REG_DWORD);
|
||||||
|
|
||||||
#define SetKeyV(name, var, s, t) \
|
#define SetKeyV(name, var, s, t) \
|
||||||
RegSetValueEx(myKey, name, 0, t, (LPBYTE) var, s);
|
RegSetValueEx(myKey, name, 0, t, (LPBYTE)var, s);
|
||||||
|
|
||||||
#define SetKeyVdw(name, var) \
|
#define SetKeyVdw(name, var) \
|
||||||
SetKeyV(name, var, 4, REG_DWORD);
|
SetKeyV(name, var, 4, REG_DWORD);
|
||||||
|
|
||||||
void SaveConf()
|
void SaveConf()
|
||||||
{
|
{
|
||||||
HKEY myKey;
|
HKEY myKey;
|
||||||
DWORD myDisp;
|
DWORD myDisp;
|
||||||
|
|
||||||
RegCreateKeyEx(HKEY_CURRENT_USER, "Software\\PS2Eplugin\\CDVD\\CDVDiso", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &myKey, &myDisp);
|
RegCreateKeyEx(HKEY_CURRENT_USER, "Software\\PS2Eplugin\\CDVD\\CDVDiso", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &myKey, &myDisp);
|
||||||
|
|
||||||
SetKeyV("IsoFile", IsoFile, sizeof(IsoFile), REG_BINARY);
|
SetKeyV("IsoFile", IsoFile, sizeof(IsoFile), REG_BINARY);
|
||||||
SetKeyV("CurrentWorkingFolder", IsoCWD, sizeof(IsoCWD), REG_BINARY);
|
SetKeyV("CurrentWorkingFolder", IsoCWD, sizeof(IsoCWD), REG_BINARY);
|
||||||
SetKeyVdw("BlockDump", &BlockDump);
|
SetKeyVdw("BlockDump", &BlockDump);
|
||||||
|
|
||||||
RegCloseKey(myKey);
|
RegCloseKey(myKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadConf()
|
void LoadConf()
|
||||||
{
|
{
|
||||||
HKEY myKey;
|
HKEY myKey;
|
||||||
DWORD type, size;
|
DWORD type, size;
|
||||||
|
|
||||||
memset(IsoFile, 0, sizeof(IsoFile));
|
memset(IsoFile, 0, sizeof(IsoFile));
|
||||||
|
|
||||||
if (RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\PS2Eplugin\\CDVD\\CDVDiso", 0, KEY_ALL_ACCESS, &myKey) != ERROR_SUCCESS)
|
if (RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\PS2Eplugin\\CDVD\\CDVDiso", 0, KEY_ALL_ACCESS, &myKey) != ERROR_SUCCESS) {
|
||||||
{
|
SaveConf();
|
||||||
SaveConf();
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
GetKeyV("IsoFile", IsoFile, sizeof(IsoFile), REG_BINARY);
|
GetKeyV("IsoFile", IsoFile, sizeof(IsoFile), REG_BINARY);
|
||||||
GetKeyV("CurrentWorkingFolder", IsoCWD, sizeof(IsoCWD), REG_BINARY);
|
GetKeyV("CurrentWorkingFolder", IsoCWD, sizeof(IsoCWD), REG_BINARY);
|
||||||
GetKeyVdw("BlockDump", &BlockDump);
|
GetKeyVdw("BlockDump", &BlockDump);
|
||||||
|
|
||||||
RegCloseKey(myKey);
|
RegCloseKey(myKey);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,2 @@
|
||||||
void SaveConf();
|
void SaveConf();
|
||||||
void LoadConf();
|
void LoadConf();
|
||||||
|
|
||||||
|
|
|
@ -27,372 +27,348 @@ int stop;
|
||||||
|
|
||||||
void SysMessage(char *fmt, ...)
|
void SysMessage(char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list list;
|
va_list list;
|
||||||
char tmp[512];
|
char tmp[512];
|
||||||
|
|
||||||
va_start(list, fmt);
|
va_start(list, fmt);
|
||||||
vsprintf(tmp, fmt, list);
|
vsprintf(tmp, fmt, list);
|
||||||
va_end(list);
|
va_end(list);
|
||||||
MessageBox(GetActiveWindow(), tmp, "CDVDiso Msg", 0);
|
MessageBox(GetActiveWindow(), tmp, "CDVDiso Msg", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int _GetFile(char *out)
|
int _GetFile(char *out)
|
||||||
{
|
{
|
||||||
OPENFILENAME ofn;
|
OPENFILENAME ofn;
|
||||||
char szFileName[MAXFILENAME];
|
char szFileName[MAXFILENAME];
|
||||||
char szFileTitle[MAXFILENAME];
|
char szFileTitle[MAXFILENAME];
|
||||||
|
|
||||||
memset(&szFileName, 0, sizeof(szFileName));
|
memset(&szFileName, 0, sizeof(szFileName));
|
||||||
memset(&szFileTitle, 0, sizeof(szFileTitle));
|
memset(&szFileTitle, 0, sizeof(szFileTitle));
|
||||||
|
|
||||||
ofn.lStructSize = sizeof(OPENFILENAME);
|
ofn.lStructSize = sizeof(OPENFILENAME);
|
||||||
ofn.hwndOwner = GetActiveWindow();
|
ofn.hwndOwner = GetActiveWindow();
|
||||||
ofn.lpstrFilter =
|
ofn.lpstrFilter =
|
||||||
"Supported Formats\0*.bin;*.iso;*.img;*.nrg;*.mdf;*.Z;*.Z2;*.BZ2;*.dump\0"
|
"Supported Formats\0*.bin;*.iso;*.img;*.nrg;*.mdf;*.Z;*.Z2;*.BZ2;*.dump\0"
|
||||||
"Cd Iso Format (*.bin;*.iso;*.img;*.nrg;*.mdf)\0"
|
"Cd Iso Format (*.bin;*.iso;*.img;*.nrg;*.mdf)\0"
|
||||||
"*.bin;*.iso;*.img;*.nrg;*.mdf\0"
|
"*.bin;*.iso;*.img;*.nrg;*.mdf\0"
|
||||||
"Compressed Z Iso Format (*.Z;*.Z2)\0"
|
"Compressed Z Iso Format (*.Z;*.Z2)\0"
|
||||||
"*.Z;*.Z2\0Compressed BZ Iso Format (*.BZ2)\0"
|
"*.Z;*.Z2\0Compressed BZ Iso Format (*.BZ2)\0"
|
||||||
"*.BZ2\0Block Dumps (*.dump)\0*.dump\0All Files\0*.*\0";
|
"*.BZ2\0Block Dumps (*.dump)\0*.dump\0All Files\0*.*\0";
|
||||||
|
|
||||||
ofn.lpstrCustomFilter = NULL;
|
ofn.lpstrCustomFilter = NULL;
|
||||||
ofn.nMaxCustFilter = 0;
|
ofn.nMaxCustFilter = 0;
|
||||||
ofn.nFilterIndex = 1;
|
ofn.nFilterIndex = 1;
|
||||||
ofn.lpstrFile = szFileName;
|
ofn.lpstrFile = szFileName;
|
||||||
ofn.nMaxFile = MAXFILENAME;
|
ofn.nMaxFile = MAXFILENAME;
|
||||||
ofn.lpstrInitialDir = (IsoCWD[0] == 0) ? NULL : IsoCWD;
|
ofn.lpstrInitialDir = (IsoCWD[0] == 0) ? NULL : IsoCWD;
|
||||||
ofn.lpstrFileTitle = szFileTitle;
|
ofn.lpstrFileTitle = szFileTitle;
|
||||||
ofn.nMaxFileTitle = MAXFILENAME;
|
ofn.nMaxFileTitle = MAXFILENAME;
|
||||||
ofn.lpstrTitle = NULL;
|
ofn.lpstrTitle = NULL;
|
||||||
ofn.lpstrDefExt = NULL;
|
ofn.lpstrDefExt = NULL;
|
||||||
ofn.Flags = OFN_HIDEREADONLY;
|
ofn.Flags = OFN_HIDEREADONLY;
|
||||||
|
|
||||||
if (GetOpenFileName((LPOPENFILENAME)&ofn))
|
if (GetOpenFileName((LPOPENFILENAME)&ofn)) {
|
||||||
{
|
strcpy(out, szFileName);
|
||||||
strcpy(out, szFileName);
|
return 1;
|
||||||
return 1;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int _OpenFile(int saveConf)
|
int _OpenFile(int saveConf)
|
||||||
{
|
{
|
||||||
|
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
|
|
||||||
// for saving the pcsx2 current working directory;
|
// for saving the pcsx2 current working directory;
|
||||||
char* cwd_pcsx2 = _getcwd(NULL, MAXFILENAME);
|
char *cwd_pcsx2 = _getcwd(NULL, MAXFILENAME);
|
||||||
|
|
||||||
if (IsoCWD[0] != 0)
|
if (IsoCWD[0] != 0)
|
||||||
_chdir(IsoCWD);
|
_chdir(IsoCWD);
|
||||||
|
|
||||||
if (_GetFile(IsoFile) == 1)
|
if (_GetFile(IsoFile) == 1) {
|
||||||
{
|
// Save the user's new cwd:
|
||||||
// Save the user's new cwd:
|
if (_getcwd(IsoCWD, MAXFILENAME) == NULL)
|
||||||
if (_getcwd(IsoCWD, MAXFILENAME) == NULL)
|
IsoCWD[0] = 0;
|
||||||
IsoCWD[0] = 0;
|
|
||||||
|
|
||||||
if (saveConf)
|
if (saveConf)
|
||||||
SaveConf();
|
SaveConf();
|
||||||
|
|
||||||
retval = 1;
|
retval = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restore Pcsx2's path.
|
// Restore Pcsx2's path.
|
||||||
if (cwd_pcsx2 != NULL)
|
if (cwd_pcsx2 != NULL) {
|
||||||
{
|
_chdir(cwd_pcsx2);
|
||||||
_chdir(cwd_pcsx2);
|
free(cwd_pcsx2);
|
||||||
free(cwd_pcsx2);
|
cwd_pcsx2 = NULL;
|
||||||
cwd_pcsx2 = NULL;
|
}
|
||||||
}
|
return retval;
|
||||||
return retval;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CfgOpenFile()
|
void CfgOpenFile()
|
||||||
{
|
{
|
||||||
_OpenFile(TRUE);
|
_OpenFile(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdZmode()
|
void UpdZmode()
|
||||||
{
|
{
|
||||||
if (ComboBox_GetCurSel(hMethod) == 0)
|
if (ComboBox_GetCurSel(hMethod) == 0) {
|
||||||
{
|
Zmode = 1;
|
||||||
Zmode = 1;
|
} else {
|
||||||
}
|
Zmode = 2;
|
||||||
else
|
}
|
||||||
{
|
|
||||||
Zmode = 2;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SysUpdate()
|
void SysUpdate()
|
||||||
{
|
{
|
||||||
MSG msg;
|
MSG msg;
|
||||||
|
|
||||||
while (PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE))
|
while (PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE)) {
|
||||||
{
|
TranslateMessage(&msg);
|
||||||
TranslateMessage(&msg);
|
DispatchMessage(&msg);
|
||||||
DispatchMessage(&msg);
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnCompress()
|
void OnCompress()
|
||||||
{
|
{
|
||||||
u32 lsn;
|
u32 lsn;
|
||||||
u8 cdbuff[10*2352];
|
u8 cdbuff[10 * 2352];
|
||||||
char Zfile[256];
|
char Zfile[256];
|
||||||
int ret;
|
int ret;
|
||||||
isoFile *src;
|
isoFile *src;
|
||||||
isoFile *dst;
|
isoFile *dst;
|
||||||
|
|
||||||
Edit_GetText(hIsoFile, IsoFile, 256);
|
Edit_GetText(hIsoFile, IsoFile, 256);
|
||||||
UpdZmode();
|
UpdZmode();
|
||||||
|
|
||||||
if (Zmode == 1)
|
if (Zmode == 1) {
|
||||||
{
|
sprintf(Zfile, "%s.Z2", IsoFile);
|
||||||
sprintf(Zfile, "%s.Z2", IsoFile);
|
} else {
|
||||||
}
|
sprintf(Zfile, "%s.BZ2", IsoFile);
|
||||||
else
|
}
|
||||||
{
|
|
||||||
sprintf(Zfile, "%s.BZ2", IsoFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
src = isoOpen(IsoFile);
|
src = isoOpen(IsoFile);
|
||||||
if (src == NULL) return;
|
if (src == NULL)
|
||||||
if (Zmode == 1)
|
return;
|
||||||
{
|
if (Zmode == 1) {
|
||||||
dst = isoCreate(Zfile, ISOFLAGS_Z2);
|
dst = isoCreate(Zfile, ISOFLAGS_Z2);
|
||||||
}
|
} else {
|
||||||
else
|
dst = isoCreate(Zfile, ISOFLAGS_BZ2);
|
||||||
{
|
}
|
||||||
dst = isoCreate(Zfile, ISOFLAGS_BZ2);
|
if (dst == NULL)
|
||||||
}
|
return;
|
||||||
if (dst == NULL) return;
|
|
||||||
|
|
||||||
isoSetFormat(dst, src->blockofs, src->blocksize, src->blocks);
|
isoSetFormat(dst, src->blockofs, src->blocksize, src->blocks);
|
||||||
Button_Enable(GetDlgItem(hDlg, IDC_COMPRESSISO), FALSE);
|
Button_Enable(GetDlgItem(hDlg, IDC_COMPRESSISO), FALSE);
|
||||||
Button_Enable(GetDlgItem(hDlg, IDC_DECOMPRESSISO), FALSE);
|
Button_Enable(GetDlgItem(hDlg, IDC_DECOMPRESSISO), FALSE);
|
||||||
stop = 0;
|
stop = 0;
|
||||||
|
|
||||||
for (lsn = 0; lsn < src->blocks; lsn++)
|
for (lsn = 0; lsn < src->blocks; lsn++) {
|
||||||
{
|
//printf("block %d ", lsn);
|
||||||
//printf("block %d ", lsn);
|
//putchar(13);
|
||||||
//putchar(13);
|
//fflush(stdout);
|
||||||
//fflush(stdout);
|
ret = isoReadBlock(src, cdbuff, lsn);
|
||||||
ret = isoReadBlock(src, cdbuff, lsn);
|
if (ret == -1)
|
||||||
if (ret == -1) break;
|
break;
|
||||||
ret = isoWriteBlock(dst, cdbuff, lsn);
|
ret = isoWriteBlock(dst, cdbuff, lsn);
|
||||||
if (ret == -1) break;
|
if (ret == -1)
|
||||||
|
break;
|
||||||
|
|
||||||
SendMessage(hProgress, PBM_SETPOS, (lsn * 100) / src->blocks, 0);
|
SendMessage(hProgress, PBM_SETPOS, (lsn * 100) / src->blocks, 0);
|
||||||
SysUpdate();
|
SysUpdate();
|
||||||
if (stop) break;
|
if (stop)
|
||||||
}
|
break;
|
||||||
isoClose(src);
|
}
|
||||||
isoClose(dst);
|
isoClose(src);
|
||||||
|
isoClose(dst);
|
||||||
|
|
||||||
if (!stop) Edit_SetText(hIsoFile, Zfile);
|
if (!stop)
|
||||||
|
Edit_SetText(hIsoFile, Zfile);
|
||||||
|
|
||||||
Button_Enable(GetDlgItem(hDlg, IDC_COMPRESSISO), TRUE);
|
Button_Enable(GetDlgItem(hDlg, IDC_COMPRESSISO), TRUE);
|
||||||
Button_Enable(GetDlgItem(hDlg, IDC_DECOMPRESSISO), TRUE);
|
Button_Enable(GetDlgItem(hDlg, IDC_DECOMPRESSISO), TRUE);
|
||||||
|
|
||||||
if (!stop)
|
if (!stop) {
|
||||||
{
|
if (ret == -1) {
|
||||||
if (ret == -1)
|
SysMessage("Error compressing iso image");
|
||||||
{
|
} else {
|
||||||
SysMessage("Error compressing iso image");
|
SysMessage("Iso image compressed OK");
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
{
|
|
||||||
SysMessage("Iso image compressed OK");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnDecompress()
|
void OnDecompress()
|
||||||
{
|
{
|
||||||
char file[256];
|
char file[256];
|
||||||
u8 cdbuff[10*2352];
|
u8 cdbuff[10 * 2352];
|
||||||
u32 lsn;
|
u32 lsn;
|
||||||
isoFile *src;
|
isoFile *src;
|
||||||
isoFile *dst;
|
isoFile *dst;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
Edit_GetText(hIsoFile, IsoFile, 256);
|
Edit_GetText(hIsoFile, IsoFile, 256);
|
||||||
|
|
||||||
src = isoOpen(IsoFile);
|
src = isoOpen(IsoFile);
|
||||||
if (src == NULL) return;
|
if (src == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
strcpy(file, IsoFile);
|
strcpy(file, IsoFile);
|
||||||
if (src->flags & ISOFLAGS_Z)
|
if (src->flags & ISOFLAGS_Z) {
|
||||||
{
|
file[strlen(file) - 2] = 0;
|
||||||
file[strlen(file) - 2] = 0;
|
} else if (src->flags & ISOFLAGS_Z2) {
|
||||||
}
|
file[strlen(file) - 3] = 0;
|
||||||
else
|
} else if (src->flags & ISOFLAGS_BZ2) {
|
||||||
if (src->flags & ISOFLAGS_Z2)
|
file[strlen(file) - 3] = 0;
|
||||||
{
|
} else {
|
||||||
file[strlen(file) - 3] = 0;
|
SysMessage("%s is not a compressed image", IsoFile);
|
||||||
}
|
return;
|
||||||
else
|
}
|
||||||
if (src->flags & ISOFLAGS_BZ2)
|
|
||||||
{
|
|
||||||
file[strlen(file) - 3] = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SysMessage("%s is not a compressed image", IsoFile);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
dst = isoCreate(file, 0);
|
dst = isoCreate(file, 0);
|
||||||
if (dst == NULL) return;
|
if (dst == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
isoSetFormat(dst, src->blockofs, src->blocksize, src->blocks);
|
isoSetFormat(dst, src->blockofs, src->blocksize, src->blocks);
|
||||||
Button_Enable(GetDlgItem(hDlg, IDC_COMPRESSISO), FALSE);
|
Button_Enable(GetDlgItem(hDlg, IDC_COMPRESSISO), FALSE);
|
||||||
Button_Enable(GetDlgItem(hDlg, IDC_DECOMPRESSISO), FALSE);
|
Button_Enable(GetDlgItem(hDlg, IDC_DECOMPRESSISO), FALSE);
|
||||||
stop = 0;
|
stop = 0;
|
||||||
|
|
||||||
for (lsn = 0; lsn < src->blocks; lsn++)
|
for (lsn = 0; lsn < src->blocks; lsn++) {
|
||||||
{
|
printf("block %d ", lsn);
|
||||||
printf("block %d ", lsn);
|
putchar(13);
|
||||||
putchar(13);
|
fflush(stdout);
|
||||||
fflush(stdout);
|
ret = isoReadBlock(src, cdbuff, lsn);
|
||||||
ret = isoReadBlock(src, cdbuff, lsn);
|
if (ret == -1)
|
||||||
if (ret == -1) break;
|
break;
|
||||||
ret = isoWriteBlock(dst, cdbuff, lsn);
|
ret = isoWriteBlock(dst, cdbuff, lsn);
|
||||||
if (ret == -1) break;
|
if (ret == -1)
|
||||||
|
break;
|
||||||
|
|
||||||
SendMessage(hProgress, PBM_SETPOS, (lsn * 100) / src->blocks, 0);
|
SendMessage(hProgress, PBM_SETPOS, (lsn * 100) / src->blocks, 0);
|
||||||
SysUpdate();
|
SysUpdate();
|
||||||
if (stop) break;
|
if (stop)
|
||||||
}
|
break;
|
||||||
if (!stop) Edit_SetText(hIsoFile, file);
|
}
|
||||||
|
if (!stop)
|
||||||
|
Edit_SetText(hIsoFile, file);
|
||||||
|
|
||||||
isoClose(src);
|
isoClose(src);
|
||||||
isoClose(dst);
|
isoClose(dst);
|
||||||
|
|
||||||
Button_Enable(GetDlgItem(hDlg, IDC_COMPRESSISO), TRUE);
|
Button_Enable(GetDlgItem(hDlg, IDC_COMPRESSISO), TRUE);
|
||||||
Button_Enable(GetDlgItem(hDlg, IDC_DECOMPRESSISO), TRUE);
|
Button_Enable(GetDlgItem(hDlg, IDC_DECOMPRESSISO), TRUE);
|
||||||
|
|
||||||
if (!stop)
|
if (!stop) {
|
||||||
{
|
if (ret == -1) {
|
||||||
if (ret == -1)
|
SysMessage("Error decompressing iso image");
|
||||||
{
|
} else {
|
||||||
SysMessage("Error decompressing iso image");
|
SysMessage("Iso image decompressed OK");
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
{
|
|
||||||
SysMessage("Iso image decompressed OK");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL CALLBACK ConfigureDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
BOOL CALLBACK ConfigureDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
switch (uMsg)
|
switch (uMsg) {
|
||||||
{
|
case WM_INITDIALOG:
|
||||||
case WM_INITDIALOG:
|
hDlg = hW;
|
||||||
hDlg = hW;
|
LoadConf();
|
||||||
LoadConf();
|
|
||||||
|
|
||||||
hProgress = GetDlgItem(hW, IDC_PROGRESS);
|
hProgress = GetDlgItem(hW, IDC_PROGRESS);
|
||||||
hIsoFile = GetDlgItem(hW, IDC_ISOFILE);
|
hIsoFile = GetDlgItem(hW, IDC_ISOFILE);
|
||||||
hMethod = GetDlgItem(hW, IDC_METHOD);
|
hMethod = GetDlgItem(hW, IDC_METHOD);
|
||||||
hBlockDump = GetDlgItem(hW, IDC_BLOCKDUMP);
|
hBlockDump = GetDlgItem(hW, IDC_BLOCKDUMP);
|
||||||
|
|
||||||
for (i = 0; methods[i] != NULL; i++)
|
for (i = 0; methods[i] != NULL; i++) {
|
||||||
{
|
ComboBox_AddString(hMethod, methods[i]);
|
||||||
ComboBox_AddString(hMethod, methods[i]);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Edit_SetText(hIsoFile, IsoFile);
|
Edit_SetText(hIsoFile, IsoFile);
|
||||||
ComboBox_SetCurSel(hMethod, 0);
|
ComboBox_SetCurSel(hMethod, 0);
|
||||||
/* if (strstr(IsoFile, ".Z") != NULL)
|
/* if (strstr(IsoFile, ".Z") != NULL)
|
||||||
ComboBox_SetCurSel(hMethod, 1);
|
ComboBox_SetCurSel(hMethod, 1);
|
||||||
else ComboBox_SetCurSel(hMethod, 0);*/
|
else ComboBox_SetCurSel(hMethod, 0);*/
|
||||||
Button_SetCheck(hBlockDump, BlockDump);
|
Button_SetCheck(hBlockDump, BlockDump);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
case WM_COMMAND:
|
case WM_COMMAND:
|
||||||
switch (LOWORD(wParam))
|
switch (LOWORD(wParam)) {
|
||||||
{
|
case IDC_SELECTISO:
|
||||||
case IDC_SELECTISO:
|
if (_OpenFile(FALSE) == 1)
|
||||||
if (_OpenFile(FALSE) == 1)
|
Edit_SetText(hIsoFile, IsoFile);
|
||||||
Edit_SetText(hIsoFile, IsoFile);
|
return TRUE;
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
case IDC_COMPRESSISO:
|
case IDC_COMPRESSISO:
|
||||||
OnCompress();
|
OnCompress();
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
case IDC_DECOMPRESSISO:
|
case IDC_DECOMPRESSISO:
|
||||||
OnDecompress();
|
OnDecompress();
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
case IDC_STOP:
|
case IDC_STOP:
|
||||||
stop = 1;
|
stop = 1;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
case IDCANCEL:
|
case IDCANCEL:
|
||||||
EndDialog(hW, TRUE);
|
EndDialog(hW, TRUE);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
case IDOK:
|
case IDOK:
|
||||||
Edit_GetText(hIsoFile, IsoFile, 256);
|
Edit_GetText(hIsoFile, IsoFile, 256);
|
||||||
BlockDump = Button_GetCheck(hBlockDump);
|
BlockDump = Button_GetCheck(hBlockDump);
|
||||||
|
|
||||||
SaveConf();
|
SaveConf();
|
||||||
EndDialog(hW, FALSE);
|
EndDialog(hW, FALSE);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(void) CDVDconfigure()
|
EXPORT_C_(void)
|
||||||
|
CDVDconfigure()
|
||||||
{
|
{
|
||||||
DialogBox(hInst,
|
DialogBox(hInst,
|
||||||
MAKEINTRESOURCE(IDD_CONFIG),
|
MAKEINTRESOURCE(IDD_CONFIG),
|
||||||
GetActiveWindow(),
|
GetActiveWindow(),
|
||||||
(DLGPROC)ConfigureDlgProc);
|
(DLGPROC)ConfigureDlgProc);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
switch (uMsg)
|
switch (uMsg) {
|
||||||
{
|
case WM_INITDIALOG:
|
||||||
case WM_INITDIALOG:
|
return TRUE;
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
case WM_COMMAND:
|
case WM_COMMAND:
|
||||||
switch (LOWORD(wParam))
|
switch (LOWORD(wParam)) {
|
||||||
{
|
case IDOK:
|
||||||
case IDOK:
|
EndDialog(hW, TRUE);
|
||||||
EndDialog(hW, TRUE);
|
return FALSE;
|
||||||
return FALSE;
|
}
|
||||||
}
|
}
|
||||||
}
|
return FALSE;
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(void) CDVDabout()
|
EXPORT_C_(void)
|
||||||
|
CDVDabout()
|
||||||
{
|
{
|
||||||
DialogBox(hInst,
|
DialogBox(hInst,
|
||||||
MAKEINTRESOURCE(IDD_ABOUT),
|
MAKEINTRESOURCE(IDD_ABOUT),
|
||||||
GetActiveWindow(),
|
GetActiveWindow(),
|
||||||
(DLGPROC)AboutDlgProc);
|
(DLGPROC)AboutDlgProc);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL APIENTRY DllMain(HANDLE hModule, // DLL INIT
|
BOOL APIENTRY DllMain(HANDLE hModule, // DLL INIT
|
||||||
DWORD dwReason,
|
DWORD dwReason,
|
||||||
LPVOID lpReserved)
|
LPVOID lpReserved)
|
||||||
{
|
{
|
||||||
hInst = (HINSTANCE)hModule;
|
hInst = (HINSTANCE)hModule;
|
||||||
return TRUE; // very quick :)
|
return TRUE; // very quick :)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -2,59 +2,59 @@
|
||||||
#define __LIBISO_H__
|
#define __LIBISO_H__
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#pragma warning(disable:4018)
|
#pragma warning(disable : 4018)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define ISOTYPE_ILLEGAL 0
|
#define ISOTYPE_ILLEGAL 0
|
||||||
#define ISOTYPE_CD 1
|
#define ISOTYPE_CD 1
|
||||||
#define ISOTYPE_DVD 2
|
#define ISOTYPE_DVD 2
|
||||||
#define ISOTYPE_AUDIO 3
|
#define ISOTYPE_AUDIO 3
|
||||||
|
|
||||||
#define ISOFLAGS_Z 0x0001
|
#define ISOFLAGS_Z 0x0001
|
||||||
#define ISOFLAGS_Z2 0x0002
|
#define ISOFLAGS_Z2 0x0002
|
||||||
#define ISOFLAGS_BLOCKDUMP 0x0004
|
#define ISOFLAGS_BLOCKDUMP 0x0004
|
||||||
#define ISOFLAGS_MULTI 0x0008
|
#define ISOFLAGS_MULTI 0x0008
|
||||||
#define ISOFLAGS_BZ2 0x0010
|
#define ISOFLAGS_BZ2 0x0010
|
||||||
|
|
||||||
#define CD_FRAMESIZE_RAW 2352
|
#define CD_FRAMESIZE_RAW 2352
|
||||||
#define DATA_SIZE (CD_FRAMESIZE_RAW-12)
|
#define DATA_SIZE (CD_FRAMESIZE_RAW - 12)
|
||||||
|
|
||||||
#define itob(i) ((i)/10*16 + (i)%10) /* u_char to BCD */
|
#define itob(i) ((i) / 10 * 16 + (i) % 10) /* u_char to BCD */
|
||||||
#define btoi(b) ((b)/16*10 + (b)%16) /* BCD to u_char */
|
#define btoi(b) ((b) / 16 * 10 + (b) % 16) /* BCD to u_char */
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
u32 slsn;
|
u32 slsn;
|
||||||
u32 elsn;
|
u32 elsn;
|
||||||
void *handle;
|
void *handle;
|
||||||
} _multih;
|
} _multih;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
char filename[256];
|
char filename[256];
|
||||||
u32 type;
|
u32 type;
|
||||||
u32 flags;
|
u32 flags;
|
||||||
u32 offset;
|
u32 offset;
|
||||||
u32 blockofs;
|
u32 blockofs;
|
||||||
u32 blocksize;
|
u32 blocksize;
|
||||||
u32 blocks;
|
u32 blocks;
|
||||||
void *handle;
|
void *handle;
|
||||||
void *htable;
|
void *htable;
|
||||||
char *Ztable;
|
char *Ztable;
|
||||||
u32 *dtable;
|
u32 *dtable;
|
||||||
int dtablesize;
|
int dtablesize;
|
||||||
_multih multih[8];
|
_multih multih[8];
|
||||||
int buflsn;
|
int buflsn;
|
||||||
u8 *buffer;
|
u8 *buffer;
|
||||||
} isoFile;
|
} isoFile;
|
||||||
|
|
||||||
|
|
||||||
isoFile *isoOpen(const char *filename);
|
isoFile *isoOpen(const char *filename);
|
||||||
isoFile *isoCreate(const char *filename, int mode);
|
isoFile *isoCreate(const char *filename, int mode);
|
||||||
int isoSetFormat(isoFile *iso, int blockofs, int blocksize, int blocks);
|
int isoSetFormat(isoFile *iso, int blockofs, int blocksize, int blocks);
|
||||||
int isoDetect(isoFile *iso);
|
int isoDetect(isoFile *iso);
|
||||||
int isoReadBlock(isoFile *iso, u8 *dst, int lsn);
|
int isoReadBlock(isoFile *iso, u8 *dst, int lsn);
|
||||||
int isoWriteBlock(isoFile *iso, u8 *src, int lsn);
|
int isoWriteBlock(isoFile *iso, u8 *src, int lsn);
|
||||||
void isoClose(isoFile *iso);
|
void isoClose(isoFile *iso);
|
||||||
|
|
||||||
void *_openfile(const char *filename, int flags);
|
void *_openfile(const char *filename, int flags);
|
||||||
|
|
|
@ -27,127 +27,121 @@
|
||||||
|
|
||||||
void Compress(char *filename, int mode)
|
void Compress(char *filename, int mode)
|
||||||
{
|
{
|
||||||
struct stat buf;
|
struct stat buf;
|
||||||
u32 lsn;
|
u32 lsn;
|
||||||
u8 cdbuff[1024*16];
|
u8 cdbuff[1024 * 16];
|
||||||
char Zfile[256];
|
char Zfile[256];
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
isoFile *src;
|
isoFile *src;
|
||||||
isoFile *dst;
|
isoFile *dst;
|
||||||
|
|
||||||
if (mode == 1)
|
if (mode == 1) {
|
||||||
{
|
sprintf(Zfile, "%s.Z2", filename);
|
||||||
sprintf(Zfile, "%s.Z2", filename);
|
} else {
|
||||||
}
|
sprintf(Zfile, "%s.BZ2", filename);
|
||||||
else
|
}
|
||||||
{
|
|
||||||
sprintf(Zfile, "%s.BZ2", filename);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (stat(Zfile, &buf) != -1)
|
if (stat(Zfile, &buf) != -1) {
|
||||||
{
|
printf("'%s' already exists\n", Zfile);
|
||||||
printf("'%s' already exists\n", Zfile);
|
return;
|
||||||
return;
|
/* sprintf(str, "'%s' already exists, overwrite?", Zfile);
|
||||||
/* sprintf(str, "'%s' already exists, overwrite?", Zfile);
|
|
||||||
if (MessageBox(hDlg, str, "Question", MB_YESNO) != IDYES) {
|
if (MessageBox(hDlg, str, "Question", MB_YESNO) != IDYES) {
|
||||||
return;
|
return;
|
||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("src %s; dst %s\n", filename, Zfile);
|
printf("src %s; dst %s\n", filename, Zfile);
|
||||||
src = isoOpen(filename);
|
src = isoOpen(filename);
|
||||||
if (src == NULL) return;
|
if (src == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
if (mode == 1)
|
if (mode == 1) {
|
||||||
{
|
dst = isoCreate(Zfile, ISOFLAGS_Z2);
|
||||||
dst = isoCreate(Zfile, ISOFLAGS_Z2);
|
} else {
|
||||||
}
|
dst = isoCreate(Zfile, ISOFLAGS_BZ2);
|
||||||
else
|
}
|
||||||
{
|
isoSetFormat(dst, src->blockofs, src->blocksize, src->blocks);
|
||||||
dst = isoCreate(Zfile, ISOFLAGS_BZ2);
|
if (dst == NULL)
|
||||||
}
|
return;
|
||||||
isoSetFormat(dst, src->blockofs, src->blocksize, src->blocks);
|
|
||||||
if (dst == NULL) return;
|
|
||||||
|
|
||||||
for (lsn = 0; lsn < src->blocks; lsn++)
|
for (lsn = 0; lsn < src->blocks; lsn++) {
|
||||||
{
|
printf("block %d ", lsn);
|
||||||
printf("block %d ", lsn);
|
putchar(13);
|
||||||
putchar(13);
|
fflush(stdout);
|
||||||
fflush(stdout);
|
ret = isoReadBlock(src, cdbuff, lsn);
|
||||||
ret = isoReadBlock(src, cdbuff, lsn);
|
if (ret == -1)
|
||||||
if (ret == -1) break;
|
break;
|
||||||
ret = isoWriteBlock(dst, cdbuff, lsn);
|
ret = isoWriteBlock(dst, cdbuff, lsn);
|
||||||
if (ret == -1) break;
|
if (ret == -1)
|
||||||
}
|
break;
|
||||||
isoClose(src);
|
}
|
||||||
isoClose(dst);
|
isoClose(src);
|
||||||
|
isoClose(dst);
|
||||||
|
|
||||||
if (ret == -1)
|
if (ret == -1) {
|
||||||
{
|
printf("Error compressing iso image\n");
|
||||||
printf("Error compressing iso image\n");
|
} else {
|
||||||
}
|
printf("Iso image compressed OK\n");
|
||||||
else
|
}
|
||||||
{
|
|
||||||
printf("Iso image compressed OK\n");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Decompress(char *filename)
|
void Decompress(char *filename)
|
||||||
{
|
{
|
||||||
struct stat buf;
|
struct stat buf;
|
||||||
char file[256];
|
char file[256];
|
||||||
u8 cdbuff[10*2352];
|
u8 cdbuff[10 * 2352];
|
||||||
u32 lsn;
|
u32 lsn;
|
||||||
isoFile *src;
|
isoFile *src;
|
||||||
isoFile *dst;
|
isoFile *dst;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
src = isoOpen(filename);
|
src = isoOpen(filename);
|
||||||
if (src == NULL) return;
|
if (src == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
strcpy(file, filename);
|
strcpy(file, filename);
|
||||||
if (src->flags & ISOFLAGS_Z)
|
if (src->flags & ISOFLAGS_Z)
|
||||||
file[strlen(file) - 2] = 0;
|
file[strlen(file) - 2] = 0;
|
||||||
else if (src->flags & ISOFLAGS_Z2)
|
else if (src->flags & ISOFLAGS_Z2)
|
||||||
file[strlen(file) - 3] = 0;
|
file[strlen(file) - 3] = 0;
|
||||||
else if (src->flags & ISOFLAGS_BZ2)
|
else if (src->flags & ISOFLAGS_BZ2)
|
||||||
file[strlen(file) - 3] = 0;
|
file[strlen(file) - 3] = 0;
|
||||||
else
|
else {
|
||||||
{
|
printf("%s is not a compressed image\n", filename);
|
||||||
printf("%s is not a compressed image\n", filename);
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (stat(file, &buf) != -1)
|
if (stat(file, &buf) != -1) {
|
||||||
{
|
char str[256];
|
||||||
char str[256];
|
sprintf(str, "'%s' already exists", file);
|
||||||
sprintf(str, "'%s' already exists", file);
|
isoClose(src);
|
||||||
isoClose(src);
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
dst = isoCreate(file, 0);
|
dst = isoCreate(file, 0);
|
||||||
if (dst == NULL) return;
|
if (dst == NULL)
|
||||||
isoSetFormat(dst, src->blockofs, src->blocksize, src->blocks);
|
return;
|
||||||
|
isoSetFormat(dst, src->blockofs, src->blocksize, src->blocks);
|
||||||
|
|
||||||
for (lsn = 0; lsn < src->blocks; lsn++)
|
for (lsn = 0; lsn < src->blocks; lsn++) {
|
||||||
{
|
printf("block %d ", lsn);
|
||||||
printf("block %d ", lsn);
|
putchar(13);
|
||||||
putchar(13);
|
fflush(stdout);
|
||||||
fflush(stdout);
|
ret = isoReadBlock(src, cdbuff, lsn);
|
||||||
ret = isoReadBlock(src, cdbuff, lsn);
|
if (ret == -1)
|
||||||
if (ret == -1) break;
|
break;
|
||||||
ret = isoWriteBlock(dst, cdbuff, lsn);
|
ret = isoWriteBlock(dst, cdbuff, lsn);
|
||||||
if (ret == -1) break;
|
if (ret == -1)
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
isoClose(src);
|
isoClose(src);
|
||||||
isoClose(dst);
|
isoClose(dst);
|
||||||
|
|
||||||
if (ret == -1)
|
if (ret == -1)
|
||||||
printf("Error decompressing iso image\n");
|
printf("Error decompressing iso image\n");
|
||||||
else
|
else
|
||||||
printf("Iso image decompressed OK\n");
|
printf("Iso image decompressed OK\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ const unsigned char version = PS2E_CDVD_VERSION;
|
||||||
const unsigned char revision = 0;
|
const unsigned char revision = 0;
|
||||||
const unsigned char build = 6;
|
const unsigned char build = 6;
|
||||||
|
|
||||||
EXPORT_C_(char*)
|
EXPORT_C_(char *)
|
||||||
PS2EgetLibName()
|
PS2EgetLibName()
|
||||||
{
|
{
|
||||||
snprintf(libraryName, 255, "CDVDnull Driver %lld%s", SVN_REV, SVN_MODS ? "m" : "");
|
snprintf(libraryName, 255, "CDVDnull Driver %lld%s", SVN_REV, SVN_MODS ? "m" : "");
|
||||||
|
@ -53,7 +53,7 @@ CDVDinit()
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(s32)
|
EXPORT_C_(s32)
|
||||||
CDVDopen(const char* pTitle)
|
CDVDopen(const char *pTitle)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -75,32 +75,32 @@ CDVDreadTrack(u32 lsn, int mode)
|
||||||
}
|
}
|
||||||
|
|
||||||
// return can be NULL (for async modes)
|
// return can be NULL (for async modes)
|
||||||
EXPORT_C_(u8*)
|
EXPORT_C_(u8 *)
|
||||||
CDVDgetBuffer()
|
CDVDgetBuffer()
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(s32)
|
EXPORT_C_(s32)
|
||||||
CDVDreadSubQ(u32 lsn, cdvdSubQ* subq)
|
CDVDreadSubQ(u32 lsn, cdvdSubQ *subq)
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(s32)
|
EXPORT_C_(s32)
|
||||||
CDVDgetTN(cdvdTN* Buffer)
|
CDVDgetTN(cdvdTN *Buffer)
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(s32)
|
EXPORT_C_(s32)
|
||||||
CDVDgetTD(u8 Track, cdvdTD* Buffer)
|
CDVDgetTD(u8 Track, cdvdTD *Buffer)
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(s32)
|
EXPORT_C_(s32)
|
||||||
CDVDgetTOC(void* toc)
|
CDVDgetTOC(void *toc)
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,5 +38,5 @@ extern const unsigned char revision;
|
||||||
extern const unsigned char build;
|
extern const unsigned char build;
|
||||||
extern const unsigned int minor;
|
extern const unsigned int minor;
|
||||||
|
|
||||||
extern void SysMessage(const char* fmt, ...);
|
extern void SysMessage(const char *fmt, ...);
|
||||||
#endif /* __CDVD_H__ */
|
#endif /* __CDVD_H__ */
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
void SaveConf();
|
void SaveConf();
|
||||||
void LoadConf();
|
void LoadConf();
|
||||||
void SysMessage(const char* fmt, ...);
|
void SysMessage(const char *fmt, ...);
|
||||||
|
|
||||||
#define is_checked(main_widget, widget_name) (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(main_widget, widget_name))))
|
#define is_checked(main_widget, widget_name) (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(main_widget, widget_name))))
|
||||||
#define set_checked(main_widget, widget_name, state) gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(main_widget, widget_name)), state)
|
#define set_checked(main_widget, widget_name, state) gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(main_widget, widget_name)), state)
|
||||||
|
|
|
@ -36,7 +36,7 @@ string s_strIniPath = "inis";
|
||||||
string s_strLogPath = "logs";
|
string s_strLogPath = "logs";
|
||||||
|
|
||||||
u8 phyregs[16];
|
u8 phyregs[16];
|
||||||
s8* fwregs;
|
s8 *fwregs;
|
||||||
Config conf;
|
Config conf;
|
||||||
PluginLog FWLog;
|
PluginLog FWLog;
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ void LogInit()
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(void)
|
EXPORT_C_(void)
|
||||||
FWsetLogDir(const char* dir)
|
FWsetLogDir(const char *dir)
|
||||||
{
|
{
|
||||||
// Get the path to the log directory.
|
// Get the path to the log directory.
|
||||||
s_strLogPath = (dir == NULL) ? "logs" : dir;
|
s_strLogPath = (dir == NULL) ? "logs" : dir;
|
||||||
|
@ -66,7 +66,7 @@ PS2EgetLibType()
|
||||||
return PS2E_LT_FW;
|
return PS2E_LT_FW;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(char*)
|
EXPORT_C_(char *)
|
||||||
PS2EgetLibName()
|
PS2EgetLibName()
|
||||||
{
|
{
|
||||||
snprintf(libraryName, 255, "FWnull Driver %lld%s", SVN_REV, SVN_MODS ? "m" : "");
|
snprintf(libraryName, 255, "FWnull Driver %lld%s", SVN_REV, SVN_MODS ? "m" : "");
|
||||||
|
@ -89,7 +89,7 @@ FWinit()
|
||||||
|
|
||||||
memset(phyregs, 0, sizeof(phyregs));
|
memset(phyregs, 0, sizeof(phyregs));
|
||||||
// Initializing our registers.
|
// Initializing our registers.
|
||||||
fwregs = (s8*)calloc(0x10000, 1);
|
fwregs = (s8 *)calloc(0x10000, 1);
|
||||||
if (fwregs == NULL) {
|
if (fwregs == NULL) {
|
||||||
FWLog.Message("Error allocating Memory");
|
FWLog.Message("Error allocating Memory");
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -108,7 +108,7 @@ FWshutdown()
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(s32)
|
EXPORT_C_(s32)
|
||||||
FWopen(void* pDsp)
|
FWopen(void *pDsp)
|
||||||
{
|
{
|
||||||
FWLog.WriteLn("Opening FWnull.");
|
FWLog.WriteLn("Opening FWnull.");
|
||||||
|
|
||||||
|
@ -278,14 +278,14 @@ FWirqCallback(void (*callback)())
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(void)
|
EXPORT_C_(void)
|
||||||
FWsetSettingsDir(const char* dir)
|
FWsetSettingsDir(const char *dir)
|
||||||
{
|
{
|
||||||
// Find out from pcsx2 where we are supposed to put our ini file.
|
// Find out from pcsx2 where we are supposed to put our ini file.
|
||||||
s_strIniPath = (dir == NULL) ? "inis" : dir;
|
s_strIniPath = (dir == NULL) ? "inis" : dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(s32)
|
EXPORT_C_(s32)
|
||||||
FWfreeze(int mode, freezeData* data)
|
FWfreeze(int mode, freezeData *data)
|
||||||
{
|
{
|
||||||
// This should store or retrieve any information, for if emulation
|
// This should store or retrieve any information, for if emulation
|
||||||
// gets suspended, or for savestates.
|
// gets suspended, or for savestates.
|
||||||
|
|
|
@ -23,9 +23,9 @@
|
||||||
#include "PS2Eext.h"
|
#include "PS2Eext.h"
|
||||||
|
|
||||||
// Our main memory storage, and defines for accessing it.
|
// Our main memory storage, and defines for accessing it.
|
||||||
extern s8* fwregs;
|
extern s8 *fwregs;
|
||||||
#define fwRs32(mem) (*(s32*)&fwregs[(mem)&0xffff])
|
#define fwRs32(mem) (*(s32 *)&fwregs[(mem)&0xffff])
|
||||||
#define fwRu32(mem) (*(u32*)&fwregs[(mem)&0xffff])
|
#define fwRu32(mem) (*(u32 *)&fwregs[(mem)&0xffff])
|
||||||
|
|
||||||
//PHY Access Address for ease of use :P
|
//PHY Access Address for ease of use :P
|
||||||
#define PHYACC fwRu32(0x8414)
|
#define PHYACC fwRu32(0x8414)
|
||||||
|
|
|
@ -21,8 +21,8 @@ extern HINSTANCE hInst;
|
||||||
void SaveConfig()
|
void SaveConfig()
|
||||||
{
|
{
|
||||||
|
|
||||||
Config* Conf1 = &conf;
|
Config *Conf1 = &conf;
|
||||||
char* szTemp;
|
char *szTemp;
|
||||||
char szIniFile[256], szValue[256];
|
char szIniFile[256], szValue[256];
|
||||||
|
|
||||||
GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
|
GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
|
||||||
|
@ -37,11 +37,11 @@ void SaveConfig()
|
||||||
|
|
||||||
void LoadConfig()
|
void LoadConfig()
|
||||||
{
|
{
|
||||||
FILE* fp;
|
FILE *fp;
|
||||||
|
|
||||||
|
|
||||||
Config* Conf1 = &conf;
|
Config *Conf1 = &conf;
|
||||||
char* szTemp;
|
char *szTemp;
|
||||||
char szIniFile[256], szValue[256];
|
char szIniFile[256], szValue[256];
|
||||||
|
|
||||||
GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
|
GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
HINSTANCE hInst;
|
HINSTANCE hInst;
|
||||||
|
|
||||||
void SysMessage(char* fmt, ...)
|
void SysMessage(char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list list;
|
va_list list;
|
||||||
char tmp[512];
|
char tmp[512];
|
||||||
|
|
|
@ -42,7 +42,7 @@ bool GSShift = false, GSAlt = false;
|
||||||
|
|
||||||
string s_strIniPath = "inis";
|
string s_strIniPath = "inis";
|
||||||
extern std::string s_strLogPath;
|
extern std::string s_strLogPath;
|
||||||
const char* s_iniFilename = "GSnull.ini";
|
const char *s_iniFilename = "GSnull.ini";
|
||||||
GSVars gs;
|
GSVars gs;
|
||||||
|
|
||||||
// Because I haven't bothered to get GSOpen2 working in Windows yet in GSNull.
|
// Because I haven't bothered to get GSOpen2 working in Windows yet in GSNull.
|
||||||
|
@ -62,7 +62,7 @@ PS2EgetLibType()
|
||||||
return PS2E_LT_GS;
|
return PS2E_LT_GS;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(char*)
|
EXPORT_C_(char *)
|
||||||
PS2EgetLibName()
|
PS2EgetLibName()
|
||||||
{
|
{
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
|
@ -80,7 +80,7 @@ PS2EgetLibVersion2(u32 type)
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(void)
|
EXPORT_C_(void)
|
||||||
GSprintf(int timeout, char* fmt, ...)
|
GSprintf(int timeout, char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list list;
|
va_list list;
|
||||||
char msg[512];
|
char msg[512];
|
||||||
|
@ -94,13 +94,13 @@ GSprintf(int timeout, char* fmt, ...)
|
||||||
|
|
||||||
// basic funcs
|
// basic funcs
|
||||||
EXPORT_C_(void)
|
EXPORT_C_(void)
|
||||||
GSsetSettingsDir(const char* dir)
|
GSsetSettingsDir(const char *dir)
|
||||||
{
|
{
|
||||||
s_strIniPath = (dir == NULL) ? "inis" : dir;
|
s_strIniPath = (dir == NULL) ? "inis" : dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(void)
|
EXPORT_C_(void)
|
||||||
GSsetLogDir(const char* dir)
|
GSsetLogDir(const char *dir)
|
||||||
{
|
{
|
||||||
// Get the path to the log directory.
|
// Get the path to the log directory.
|
||||||
s_strLogPath = (dir == NULL) ? "logs" : dir;
|
s_strLogPath = (dir == NULL) ? "logs" : dir;
|
||||||
|
@ -130,7 +130,7 @@ GSshutdown()
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(s32)
|
EXPORT_C_(s32)
|
||||||
GSopen(void* pDsp, const char* Title, int multithread)
|
GSopen(void *pDsp, const char *Title, int multithread)
|
||||||
{
|
{
|
||||||
int err = 0;
|
int err = 0;
|
||||||
GSLog::WriteLn("GS open.");
|
GSLog::WriteLn("GS open.");
|
||||||
|
@ -148,7 +148,7 @@ GSopen(void* pDsp, const char* Title, int multithread)
|
||||||
|
|
||||||
#ifdef USE_GSOPEN2
|
#ifdef USE_GSOPEN2
|
||||||
EXPORT_C_(s32)
|
EXPORT_C_(s32)
|
||||||
GSopen2(void* pDsp, u32 flags)
|
GSopen2(void *pDsp, u32 flags)
|
||||||
{
|
{
|
||||||
GSLog::WriteLn("GS open2.");
|
GSLog::WriteLn("GS open2.");
|
||||||
|
|
||||||
|
@ -181,7 +181,7 @@ GSirqCallback(void (*callback)())
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(s32)
|
EXPORT_C_(s32)
|
||||||
GSfreeze(int mode, freezeData* data)
|
GSfreeze(int mode, freezeData *data)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -201,9 +201,9 @@ GSvsync(int field)
|
||||||
|
|
||||||
// returns the last tag processed (64 bits)
|
// returns the last tag processed (64 bits)
|
||||||
EXPORT_C_(void)
|
EXPORT_C_(void)
|
||||||
GSgetLastTag(u64* ptag)
|
GSgetLastTag(u64 *ptag)
|
||||||
{
|
{
|
||||||
*(u32*)ptag = gs.nPath3Hack;
|
*(u32 *)ptag = gs.nPath3Hack;
|
||||||
gs.nPath3Hack = 0;
|
gs.nPath3Hack = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,12 +214,12 @@ GSgifSoftReset(u32 mask)
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(void)
|
EXPORT_C_(void)
|
||||||
GSreadFIFO(u64* mem)
|
GSreadFIFO(u64 *mem)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(void)
|
EXPORT_C_(void)
|
||||||
GSreadFIFO2(u64* mem, int qwc)
|
GSreadFIFO2(u64 *mem, int qwc)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,31 +227,31 @@ GSreadFIFO2(u64* mem, int qwc)
|
||||||
|
|
||||||
// GSkeyEvent gets called when there is a keyEvent from the PAD plugin
|
// GSkeyEvent gets called when there is a keyEvent from the PAD plugin
|
||||||
EXPORT_C_(void)
|
EXPORT_C_(void)
|
||||||
GSkeyEvent(keyEvent* ev)
|
GSkeyEvent(keyEvent *ev)
|
||||||
{
|
{
|
||||||
HandleKeyEvent(ev);
|
HandleKeyEvent(ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(void)
|
EXPORT_C_(void)
|
||||||
GSchangeSaveState(int, const char* filename)
|
GSchangeSaveState(int, const char *filename)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(void)
|
EXPORT_C_(void)
|
||||||
GSmakeSnapshot(char* path)
|
GSmakeSnapshot(char *path)
|
||||||
{
|
{
|
||||||
|
|
||||||
GSLog::WriteLn("Taking a snapshot.");
|
GSLog::WriteLn("Taking a snapshot.");
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(void)
|
EXPORT_C_(void)
|
||||||
GSmakeSnapshot2(char* pathname, int* snapdone, int savejpg)
|
GSmakeSnapshot2(char *pathname, int *snapdone, int savejpg)
|
||||||
{
|
{
|
||||||
GSLog::WriteLn("Taking a snapshot to %s.", pathname);
|
GSLog::WriteLn("Taking a snapshot to %s.", pathname);
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(void)
|
EXPORT_C_(void)
|
||||||
GSsetBaseMem(void*)
|
GSsetBaseMem(void *)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -273,7 +273,7 @@ GSsetFrameSkip(int frameskip)
|
||||||
// returns a non zero value if successful
|
// returns a non zero value if successful
|
||||||
// for now, pData is not used
|
// for now, pData is not used
|
||||||
EXPORT_C_(int)
|
EXPORT_C_(int)
|
||||||
GSsetupRecording(int start, void* pData)
|
GSsetupRecording(int start, void *pData)
|
||||||
{
|
{
|
||||||
if (start)
|
if (start)
|
||||||
GSLog::WriteLn("Pretending to record.");
|
GSLog::WriteLn("Pretending to record.");
|
||||||
|
@ -295,6 +295,6 @@ GSwriteCSR(u32 value)
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(void)
|
EXPORT_C_(void)
|
||||||
GSgetDriverInfo(GSdriverInfo* info)
|
GSgetDriverInfo(GSdriverInfo *info)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,10 +81,10 @@ namespace GSLog
|
||||||
{
|
{
|
||||||
extern bool Open();
|
extern bool Open();
|
||||||
extern void Close();
|
extern void Close();
|
||||||
extern void Log(char* fmt, ...);
|
extern void Log(char *fmt, ...);
|
||||||
extern void Message(char* fmt, ...);
|
extern void Message(char *fmt, ...);
|
||||||
extern void Print(const char* fmt, ...);
|
extern void Print(const char *fmt, ...);
|
||||||
extern void WriteLn(const char* fmt, ...);
|
extern void WriteLn(const char *fmt, ...);
|
||||||
};
|
};
|
||||||
|
|
||||||
extern void SaveConfig();
|
extern void SaveConfig();
|
||||||
|
|
|
@ -32,7 +32,7 @@ std::string s_strLogPath("logs");
|
||||||
|
|
||||||
namespace GSLog
|
namespace GSLog
|
||||||
{
|
{
|
||||||
FILE* gsLog;
|
FILE *gsLog;
|
||||||
|
|
||||||
bool Open()
|
bool Open()
|
||||||
{
|
{
|
||||||
|
@ -63,7 +63,7 @@ void Close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Log(char* fmt, ...)
|
void Log(char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list list;
|
va_list list;
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ void Log(char* fmt, ...)
|
||||||
va_end(list);
|
va_end(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Message(char* fmt, ...)
|
void Message(char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list list;
|
va_list list;
|
||||||
char msg[512];
|
char msg[512];
|
||||||
|
@ -87,7 +87,7 @@ void Message(char* fmt, ...)
|
||||||
SysMessage("%s\n", msg);
|
SysMessage("%s\n", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Print(const char* fmt, ...)
|
void Print(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list list;
|
va_list list;
|
||||||
char msg[512];
|
char msg[512];
|
||||||
|
@ -101,7 +101,7 @@ void Print(const char* fmt, ...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void WriteLn(const char* fmt, ...)
|
void WriteLn(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list list;
|
va_list list;
|
||||||
char msg[512];
|
char msg[512];
|
||||||
|
|
|
@ -29,11 +29,11 @@ extern GSVars gs;
|
||||||
PCSX2_ALIGNED16(u8 g_RealGSMem[0x2000]);
|
PCSX2_ALIGNED16(u8 g_RealGSMem[0x2000]);
|
||||||
|
|
||||||
template <int index>
|
template <int index>
|
||||||
void _GSgifTransfer(const u32* pMem, u32 size)
|
void _GSgifTransfer(const u32 *pMem, u32 size)
|
||||||
{
|
{
|
||||||
// FUNCLOG
|
// FUNCLOG
|
||||||
|
|
||||||
pathInfo* path = &gs.path[index];
|
pathInfo *path = &gs.path[index];
|
||||||
|
|
||||||
while (size > 0) {
|
while (size > 0) {
|
||||||
//GSLog::Writeln(_T("Transfer(%08x, %d) START\n"), pMem, size);
|
//GSLog::Writeln(_T("Transfer(%08x, %d) START\n"), pMem, size);
|
||||||
|
@ -49,7 +49,7 @@ void _GSgifTransfer(const u32* pMem, u32 size)
|
||||||
|
|
||||||
if (path->tag.PRE && (path->tag.FLG == GIF_FLG_PACKED)) {
|
if (path->tag.PRE && (path->tag.FLG == GIF_FLG_PACKED)) {
|
||||||
u32 tagprim = path->tag.PRIM;
|
u32 tagprim = path->tag.PRIM;
|
||||||
GIFRegHandlerPRIM((u32*)&tagprim);
|
GIFRegHandlerPRIM((u32 *)&tagprim);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -150,34 +150,34 @@ void _GSgifTransfer(const u32* pMem, u32 size)
|
||||||
|
|
||||||
// Obsolete. Included because it's still in GSdef.
|
// Obsolete. Included because it's still in GSdef.
|
||||||
EXPORT_C_(void)
|
EXPORT_C_(void)
|
||||||
GSgifTransfer1(u32* pMem, u32 addr)
|
GSgifTransfer1(u32 *pMem, u32 addr)
|
||||||
{
|
{
|
||||||
#ifdef DO_GIF_TRANSFERS
|
#ifdef DO_GIF_TRANSFERS
|
||||||
_GSgifTransfer<0>((u32*)((u8*)pMem + addr), (0x4000 - addr) / 16);
|
_GSgifTransfer<0>((u32 *)((u8 *)pMem + addr), (0x4000 - addr) / 16);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(void)
|
EXPORT_C_(void)
|
||||||
GSgifTransfer(const u32* pMem, u32 size)
|
GSgifTransfer(const u32 *pMem, u32 size)
|
||||||
{
|
{
|
||||||
#ifdef DO_GIF_TRANSFERS
|
#ifdef DO_GIF_TRANSFERS
|
||||||
_GSgifTransfer<3>(const_cast<u32*>(pMem), size);
|
_GSgifTransfer<3>(const_cast<u32 *>(pMem), size);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(void)
|
EXPORT_C_(void)
|
||||||
GSgifTransfer2(u32* pMem, u32 size)
|
GSgifTransfer2(u32 *pMem, u32 size)
|
||||||
{
|
{
|
||||||
#ifdef DO_GIF_TRANSFERS
|
#ifdef DO_GIF_TRANSFERS
|
||||||
_GSgifTransfer<1>(const_cast<u32*>(pMem), size);
|
_GSgifTransfer<1>(const_cast<u32 *>(pMem), size);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(void)
|
EXPORT_C_(void)
|
||||||
GSgifTransfer3(u32* pMem, u32 size)
|
GSgifTransfer3(u32 *pMem, u32 size)
|
||||||
{
|
{
|
||||||
#ifdef DO_GIF_TRANSFERS
|
#ifdef DO_GIF_TRANSFERS
|
||||||
_GSgifTransfer<2>(const_cast<u32*>(pMem), size);
|
_GSgifTransfer<2>(const_cast<u32 *>(pMem), size);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,14 +47,14 @@ union GIFTag
|
||||||
u64 REGS : 64;
|
u64 REGS : 64;
|
||||||
};
|
};
|
||||||
|
|
||||||
void set(const u32* data)
|
void set(const u32 *data)
|
||||||
{
|
{
|
||||||
for (int i = 0; i <= 3; i++) {
|
for (int i = 0; i <= 3; i++) {
|
||||||
ai32[i] = data[i];
|
ai32[i] = data[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GIFTag(u32* data)
|
GIFTag(u32 *data)
|
||||||
{
|
{
|
||||||
set(data);
|
set(data);
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ typedef struct
|
||||||
u32 adonly;
|
u32 adonly;
|
||||||
GIFTag tag;
|
GIFTag tag;
|
||||||
|
|
||||||
void setTag(const u32* data)
|
void setTag(const u32 *data)
|
||||||
{
|
{
|
||||||
tag.set(data);
|
tag.set(data);
|
||||||
|
|
||||||
|
@ -123,10 +123,10 @@ typedef struct
|
||||||
|
|
||||||
} pathInfo;
|
} pathInfo;
|
||||||
|
|
||||||
extern void _GSgifPacket(pathInfo* path, const u32* pMem);
|
extern void _GSgifPacket(pathInfo *path, const u32 *pMem);
|
||||||
extern void _GSgifRegList(pathInfo* path, const u32* pMem);
|
extern void _GSgifRegList(pathInfo *path, const u32 *pMem);
|
||||||
template <int index>
|
template <int index>
|
||||||
extern void _GSgifTransfer(const u32* pMem, u32 size);
|
extern void _GSgifTransfer(const u32 *pMem, u32 size);
|
||||||
extern GIFRegHandler GIFPackedRegHandlers[];
|
extern GIFRegHandler GIFPackedRegHandlers[];
|
||||||
extern GIFRegHandler GIFRegHandlers[];
|
extern GIFRegHandler GIFRegHandlers[];
|
||||||
#endif // GIFTRANSFER_H_INCLUDED
|
#endif // GIFTRANSFER_H_INCLUDED
|
||||||
|
|
|
@ -19,6 +19,6 @@
|
||||||
void SaveConf();
|
void SaveConf();
|
||||||
void LoadConf();
|
void LoadConf();
|
||||||
|
|
||||||
extern long CFGmessage(char* msg);
|
extern long CFGmessage(char *msg);
|
||||||
extern void CFGconfigure();
|
extern void CFGconfigure();
|
||||||
extern void CFGabout();
|
extern void CFGabout();
|
||||||
|
|
|
@ -16,28 +16,28 @@
|
||||||
#include "GS.h"
|
#include "GS.h"
|
||||||
#include "GSLinux.h"
|
#include "GSLinux.h"
|
||||||
|
|
||||||
Display* display;
|
Display *display;
|
||||||
int screen;
|
int screen;
|
||||||
GtkScrolledWindow* win;
|
GtkScrolledWindow *win;
|
||||||
|
|
||||||
int GSOpenWindow(void* pDsp, const char* Title)
|
int GSOpenWindow(void *pDsp, const char *Title)
|
||||||
{
|
{
|
||||||
display = XOpenDisplay(0);
|
display = XOpenDisplay(0);
|
||||||
screen = DefaultScreen(display);
|
screen = DefaultScreen(display);
|
||||||
|
|
||||||
if (pDsp != NULL)
|
if (pDsp != NULL)
|
||||||
*(Display**)pDsp = display;
|
*(Display **)pDsp = display;
|
||||||
else
|
else
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GSOpenWindow2(void* pDsp, u32 flags)
|
int GSOpenWindow2(void *pDsp, u32 flags)
|
||||||
{
|
{
|
||||||
GtkWidget* widget;
|
GtkWidget *widget;
|
||||||
if (pDsp != NULL)
|
if (pDsp != NULL)
|
||||||
win = *(GtkScrolledWindow**)pDsp;
|
win = *(GtkScrolledWindow **)pDsp;
|
||||||
else
|
else
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ void GSProcessMessages()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void HandleKeyEvent(keyEvent* ev)
|
void HandleKeyEvent(keyEvent *ev)
|
||||||
{
|
{
|
||||||
switch (ev->evt) {
|
switch (ev->evt) {
|
||||||
case KEYPRESS:
|
case KEYPRESS:
|
||||||
|
|
|
@ -20,10 +20,10 @@
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <X11/keysym.h>
|
#include <X11/keysym.h>
|
||||||
|
|
||||||
extern int GSOpenWindow(void* pDsp, const char* Title);
|
extern int GSOpenWindow(void *pDsp, const char *Title);
|
||||||
extern int GSOpenWindow2(void* pDsp, u32 flags);
|
extern int GSOpenWindow2(void *pDsp, u32 flags);
|
||||||
extern void GSCloseWindow();
|
extern void GSCloseWindow();
|
||||||
extern void GSProcessMessages();
|
extern void GSProcessMessages();
|
||||||
extern void HandleKeyEvent(keyEvent* ev);
|
extern void HandleKeyEvent(keyEvent *ev);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -25,35 +25,35 @@ GIFRegHandler GIFRegHandlers[256];
|
||||||
// For now, I'm just rigging this up to store all the register information coming in, without doing
|
// For now, I'm just rigging this up to store all the register information coming in, without doing
|
||||||
// any of the normal processing.
|
// any of the normal processing.
|
||||||
|
|
||||||
void __gifCall GIFPackedRegHandlerNull(const u32* data)
|
void __gifCall GIFPackedRegHandlerNull(const u32 *data)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
// All these just call their non-packed equivalent.
|
// All these just call their non-packed equivalent.
|
||||||
void __gifCall GIFPackedRegHandlerPRIM(const u32* data) { GIFRegHandlerPRIM(data); }
|
void __gifCall GIFPackedRegHandlerPRIM(const u32 *data) { GIFRegHandlerPRIM(data); }
|
||||||
|
|
||||||
template <u32 i>
|
template <u32 i>
|
||||||
void __gifCall GIFPackedRegHandlerTEX0(const u32* data)
|
void __gifCall GIFPackedRegHandlerTEX0(const u32 *data)
|
||||||
{
|
{
|
||||||
GIFRegHandlerTEX0<i>(data);
|
GIFRegHandlerTEX0<i>(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <u32 i>
|
template <u32 i>
|
||||||
void __gifCall GIFPackedRegHandlerCLAMP(const u32* data)
|
void __gifCall GIFPackedRegHandlerCLAMP(const u32 *data)
|
||||||
{
|
{
|
||||||
GIFRegHandlerCLAMP<i>(data);
|
GIFRegHandlerCLAMP<i>(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void __gifCall GIFPackedRegHandlerTEX0_1(const u32* data) { GIFRegHandlerTEX0<0>(data); }
|
void __gifCall GIFPackedRegHandlerTEX0_1(const u32 *data) { GIFRegHandlerTEX0<0>(data); }
|
||||||
void __gifCall GIFPackedRegHandlerTEX0_2(const u32* data) { GIFRegHandlerTEX0<1>(data); }
|
void __gifCall GIFPackedRegHandlerTEX0_2(const u32 *data) { GIFRegHandlerTEX0<1>(data); }
|
||||||
void __gifCall GIFPackedRegHandlerCLAMP_1(const u32* data) { GIFRegHandlerCLAMP<0>(data); }
|
void __gifCall GIFPackedRegHandlerCLAMP_1(const u32 *data) { GIFRegHandlerCLAMP<0>(data); }
|
||||||
void __gifCall GIFPackedRegHandlerCLAMP_2(const u32* data) { GIFRegHandlerCLAMP<1>(data); }
|
void __gifCall GIFPackedRegHandlerCLAMP_2(const u32 *data) { GIFRegHandlerCLAMP<1>(data); }
|
||||||
void __gifCall GIFPackedRegHandlerXYZF3(const u32* data) { GIFRegHandlerXYZF3(data); }
|
void __gifCall GIFPackedRegHandlerXYZF3(const u32 *data) { GIFRegHandlerXYZF3(data); }
|
||||||
void __gifCall GIFPackedRegHandlerXYZ3(const u32* data) { GIFRegHandlerXYZ3(data); }
|
void __gifCall GIFPackedRegHandlerXYZ3(const u32 *data) { GIFRegHandlerXYZ3(data); }
|
||||||
|
|
||||||
void __gifCall GIFPackedRegHandlerRGBA(const u32* data)
|
void __gifCall GIFPackedRegHandlerRGBA(const u32 *data)
|
||||||
{
|
{
|
||||||
GIFPackedRGBA* r = (GIFPackedRGBA*)(data);
|
GIFPackedRGBA *r = (GIFPackedRGBA *)(data);
|
||||||
gs.regs.RGBAQ.R = r->R;
|
gs.regs.RGBAQ.R = r->R;
|
||||||
gs.regs.RGBAQ.G = r->G;
|
gs.regs.RGBAQ.G = r->G;
|
||||||
gs.regs.RGBAQ.B = r->B;
|
gs.regs.RGBAQ.B = r->B;
|
||||||
|
@ -61,17 +61,17 @@ void __gifCall GIFPackedRegHandlerRGBA(const u32* data)
|
||||||
gs.regs.RGBAQ.Q = gs.q;
|
gs.regs.RGBAQ.Q = gs.q;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __gifCall GIFPackedRegHandlerSTQ(const u32* data)
|
void __gifCall GIFPackedRegHandlerSTQ(const u32 *data)
|
||||||
{
|
{
|
||||||
GIFPackedSTQ* r = (GIFPackedSTQ*)(data);
|
GIFPackedSTQ *r = (GIFPackedSTQ *)(data);
|
||||||
gs.regs.ST.S = r->S;
|
gs.regs.ST.S = r->S;
|
||||||
gs.regs.ST.T = r->T;
|
gs.regs.ST.T = r->T;
|
||||||
gs.q = r->Q;
|
gs.q = r->Q;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __gifCall GIFPackedRegHandlerUV(const u32* data)
|
void __gifCall GIFPackedRegHandlerUV(const u32 *data)
|
||||||
{
|
{
|
||||||
GIFPackedUV* r = (GIFPackedUV*)(data);
|
GIFPackedUV *r = (GIFPackedUV *)(data);
|
||||||
gs.regs.UV.U = r->U;
|
gs.regs.UV.U = r->U;
|
||||||
gs.regs.UV.V = r->V;
|
gs.regs.UV.V = r->V;
|
||||||
}
|
}
|
||||||
|
@ -80,309 +80,309 @@ void __gifCall KickVertex(bool adc)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void __gifCall GIFPackedRegHandlerXYZF2(const u32* data)
|
void __gifCall GIFPackedRegHandlerXYZF2(const u32 *data)
|
||||||
{
|
{
|
||||||
GIFPackedXYZF2* r = (GIFPackedXYZF2*)(data);
|
GIFPackedXYZF2 *r = (GIFPackedXYZF2 *)(data);
|
||||||
gs.regs.XYZ.X = r->X;
|
gs.regs.XYZ.X = r->X;
|
||||||
gs.regs.XYZ.Y = r->Y;
|
gs.regs.XYZ.Y = r->Y;
|
||||||
gs.regs.XYZ.Z = r->Z;
|
gs.regs.XYZ.Z = r->Z;
|
||||||
gs.regs.FOG.F = r->F;
|
gs.regs.FOG.F = r->F;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __gifCall GIFPackedRegHandlerXYZ2(const u32* data)
|
void __gifCall GIFPackedRegHandlerXYZ2(const u32 *data)
|
||||||
{
|
{
|
||||||
GIFPackedXYZ2* r = (GIFPackedXYZ2*)(data);
|
GIFPackedXYZ2 *r = (GIFPackedXYZ2 *)(data);
|
||||||
gs.regs.XYZ.X = r->X;
|
gs.regs.XYZ.X = r->X;
|
||||||
gs.regs.XYZ.Y = r->Y;
|
gs.regs.XYZ.Y = r->Y;
|
||||||
gs.regs.XYZ.Z = r->Z;
|
gs.regs.XYZ.Z = r->Z;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __gifCall GIFPackedRegHandlerFOG(const u32* data)
|
void __gifCall GIFPackedRegHandlerFOG(const u32 *data)
|
||||||
{
|
{
|
||||||
GIFPackedFOG* r = (GIFPackedFOG*)(data);
|
GIFPackedFOG *r = (GIFPackedFOG *)(data);
|
||||||
gs.regs.FOG.F = r->F;
|
gs.regs.FOG.F = r->F;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __gifCall GIFPackedRegHandlerA_D(const u32* data)
|
void __gifCall GIFPackedRegHandlerA_D(const u32 *data)
|
||||||
{
|
{
|
||||||
GIFPackedA_D* r = (GIFPackedA_D*)(data);
|
GIFPackedA_D *r = (GIFPackedA_D *)(data);
|
||||||
|
|
||||||
GIFRegHandlers[r->ADDR](data);
|
GIFRegHandlers[r->ADDR](data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void __gifCall GIFPackedRegHandlerNOP(const u32* data)
|
void __gifCall GIFPackedRegHandlerNOP(const u32 *data)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void __gifCall GIFRegHandlerNull(const u32* data)
|
void __gifCall GIFRegHandlerNull(const u32 *data)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void __gifCall GIFRegHandlerRGBAQ(const u32* data)
|
void __gifCall GIFRegHandlerRGBAQ(const u32 *data)
|
||||||
{
|
{
|
||||||
GIFRegRGBAQ* r = (GIFRegRGBAQ*)(data);
|
GIFRegRGBAQ *r = (GIFRegRGBAQ *)(data);
|
||||||
gs.regs.RGBAQ._u64 = r->_u64;
|
gs.regs.RGBAQ._u64 = r->_u64;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __gifCall GIFRegHandlerST(const u32* data)
|
void __gifCall GIFRegHandlerST(const u32 *data)
|
||||||
{
|
{
|
||||||
GIFRegST* r = (GIFRegST*)(data);
|
GIFRegST *r = (GIFRegST *)(data);
|
||||||
gs.regs.ST._u64 = r->_u64;
|
gs.regs.ST._u64 = r->_u64;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __gifCall GIFRegHandlerUV(const u32* data)
|
void __gifCall GIFRegHandlerUV(const u32 *data)
|
||||||
{
|
{
|
||||||
GIFRegUV* r = (GIFRegUV*)(data);
|
GIFRegUV *r = (GIFRegUV *)(data);
|
||||||
gs.regs.UV._u64 = r->_u64;
|
gs.regs.UV._u64 = r->_u64;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __gifCall GIFRegHandlerXYZF2(const u32* data)
|
void __gifCall GIFRegHandlerXYZF2(const u32 *data)
|
||||||
{
|
{
|
||||||
GIFRegXYZF* r = (GIFRegXYZF*)(data);
|
GIFRegXYZF *r = (GIFRegXYZF *)(data);
|
||||||
gs.regs.XYZF._u64 = r->_u64;
|
gs.regs.XYZF._u64 = r->_u64;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __gifCall GIFRegHandlerXYZ2(const u32* data)
|
void __gifCall GIFRegHandlerXYZ2(const u32 *data)
|
||||||
{
|
{
|
||||||
GIFRegXYZ* r = (GIFRegXYZ*)(data);
|
GIFRegXYZ *r = (GIFRegXYZ *)(data);
|
||||||
gs.regs.XYZ._u64 = r->_u64;
|
gs.regs.XYZ._u64 = r->_u64;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <u32 i>
|
template <u32 i>
|
||||||
void __gifCall GIFRegHandlerTEX0(const u32* data)
|
void __gifCall GIFRegHandlerTEX0(const u32 *data)
|
||||||
{
|
{
|
||||||
GIFRegTEX0* r = (GIFRegTEX0*)(data);
|
GIFRegTEX0 *r = (GIFRegTEX0 *)(data);
|
||||||
gs.ctxt_regs[i].TEX0._u64 = r->_u64;
|
gs.ctxt_regs[i].TEX0._u64 = r->_u64;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <u32 i>
|
template <u32 i>
|
||||||
void __gifCall GIFRegHandlerCLAMP(const u32* data)
|
void __gifCall GIFRegHandlerCLAMP(const u32 *data)
|
||||||
{
|
{
|
||||||
GIFRegCLAMP* r = (GIFRegCLAMP*)(data);
|
GIFRegCLAMP *r = (GIFRegCLAMP *)(data);
|
||||||
gs.ctxt_regs[i].CLAMP._u64 = r->_u64;
|
gs.ctxt_regs[i].CLAMP._u64 = r->_u64;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __gifCall GIFRegHandlerFOG(const u32* data)
|
void __gifCall GIFRegHandlerFOG(const u32 *data)
|
||||||
{
|
{
|
||||||
GIFRegFOG* r = (GIFRegFOG*)(data);
|
GIFRegFOG *r = (GIFRegFOG *)(data);
|
||||||
gs.regs.FOG.F = r->F;
|
gs.regs.FOG.F = r->F;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __gifCall GIFRegHandlerXYZF3(const u32* data)
|
void __gifCall GIFRegHandlerXYZF3(const u32 *data)
|
||||||
{
|
{
|
||||||
GIFRegXYZF* r = (GIFRegXYZF*)(data);
|
GIFRegXYZF *r = (GIFRegXYZF *)(data);
|
||||||
gs.regs.XYZF._u64 = r->_u64;
|
gs.regs.XYZF._u64 = r->_u64;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __gifCall GIFRegHandlerXYZ3(const u32* data)
|
void __gifCall GIFRegHandlerXYZ3(const u32 *data)
|
||||||
{
|
{
|
||||||
GIFRegXYZ* r = (GIFRegXYZ*)(data);
|
GIFRegXYZ *r = (GIFRegXYZ *)(data);
|
||||||
gs.regs.XYZ._u64 = r->_u64;
|
gs.regs.XYZ._u64 = r->_u64;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __gifCall GIFRegHandlerNOP(const u32* data)
|
void __gifCall GIFRegHandlerNOP(const u32 *data)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
template <u32 i>
|
template <u32 i>
|
||||||
void __fastcall GIFRegHandlerTEX1(const u32* data)
|
void __fastcall GIFRegHandlerTEX1(const u32 *data)
|
||||||
{
|
{
|
||||||
GIFRegTEX1* r = (GIFRegTEX1*)(data);
|
GIFRegTEX1 *r = (GIFRegTEX1 *)(data);
|
||||||
gs.ctxt_regs[i].TEX1._u64 = r->_u64;
|
gs.ctxt_regs[i].TEX1._u64 = r->_u64;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <u32 i>
|
template <u32 i>
|
||||||
void __gifCall GIFRegHandlerTEX2(const u32* data)
|
void __gifCall GIFRegHandlerTEX2(const u32 *data)
|
||||||
{
|
{
|
||||||
GIFRegTEX2* r = (GIFRegTEX2*)(data);
|
GIFRegTEX2 *r = (GIFRegTEX2 *)(data);
|
||||||
gs.ctxt_regs[i].TEX2._u64 = r->_u64;
|
gs.ctxt_regs[i].TEX2._u64 = r->_u64;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <u32 i>
|
template <u32 i>
|
||||||
void __gifCall GIFRegHandlerXYOFFSET(const u32* data)
|
void __gifCall GIFRegHandlerXYOFFSET(const u32 *data)
|
||||||
{
|
{
|
||||||
GIFRegXYOFFSET* r = (GIFRegXYOFFSET*)(data);
|
GIFRegXYOFFSET *r = (GIFRegXYOFFSET *)(data);
|
||||||
gs.ctxt_regs[i].XYOFFSET.OFX = r->OFX;
|
gs.ctxt_regs[i].XYOFFSET.OFX = r->OFX;
|
||||||
gs.ctxt_regs[i].XYOFFSET.OFY = r->OFY;
|
gs.ctxt_regs[i].XYOFFSET.OFY = r->OFY;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fill out the vertex queue(prim) and the attributes.
|
// Fill out the vertex queue(prim) and the attributes.
|
||||||
void __gifCall GIFRegHandlerPRIM(const u32* data)
|
void __gifCall GIFRegHandlerPRIM(const u32 *data)
|
||||||
{
|
{
|
||||||
GIFRegPRIM* r = (GIFRegPRIM*)(data);
|
GIFRegPRIM *r = (GIFRegPRIM *)(data);
|
||||||
gs.regs.PRIM._u64 = r->_u64;
|
gs.regs.PRIM._u64 = r->_u64;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fill out an alternate set of attributes.
|
// Fill out an alternate set of attributes.
|
||||||
void __gifCall GIFRegHandlerPRMODE(const u32* data)
|
void __gifCall GIFRegHandlerPRMODE(const u32 *data)
|
||||||
{
|
{
|
||||||
GIFRegPRMODE* r = (GIFRegPRMODE*)(data);
|
GIFRegPRMODE *r = (GIFRegPRMODE *)(data);
|
||||||
gs.regs.PRMODE._u64 = r->_u64;
|
gs.regs.PRMODE._u64 = r->_u64;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Switch between the primary set of attributes and the secondary.
|
// Switch between the primary set of attributes and the secondary.
|
||||||
void __gifCall GIFRegHandlerPRMODECONT(const u32* data)
|
void __gifCall GIFRegHandlerPRMODECONT(const u32 *data)
|
||||||
{
|
{
|
||||||
GIFRegPRMODECONT* r = (GIFRegPRMODECONT*)(data);
|
GIFRegPRMODECONT *r = (GIFRegPRMODECONT *)(data);
|
||||||
gs.regs.PRMODECONT._u64 = r->_u64;
|
gs.regs.PRMODECONT._u64 = r->_u64;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __gifCall GIFRegHandlerTEXCLUT(const u32* data)
|
void __gifCall GIFRegHandlerTEXCLUT(const u32 *data)
|
||||||
{
|
{
|
||||||
GIFRegTEXCLUT* r = (GIFRegTEXCLUT*)(data);
|
GIFRegTEXCLUT *r = (GIFRegTEXCLUT *)(data);
|
||||||
gs.regs.TEXCLUT._u64 = r->_u64;
|
gs.regs.TEXCLUT._u64 = r->_u64;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __gifCall GIFRegHandlerSCANMSK(const u32* data)
|
void __gifCall GIFRegHandlerSCANMSK(const u32 *data)
|
||||||
{
|
{
|
||||||
GIFRegSCANMSK* r = (GIFRegSCANMSK*)(data);
|
GIFRegSCANMSK *r = (GIFRegSCANMSK *)(data);
|
||||||
gs.regs.SCANMSK._u64 = r->_u64;
|
gs.regs.SCANMSK._u64 = r->_u64;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <u32 i>
|
template <u32 i>
|
||||||
void __gifCall GIFRegHandlerMIPTBP1(const u32* data)
|
void __gifCall GIFRegHandlerMIPTBP1(const u32 *data)
|
||||||
{
|
{
|
||||||
GIFRegMIPTBP1* r = (GIFRegMIPTBP1*)(data);
|
GIFRegMIPTBP1 *r = (GIFRegMIPTBP1 *)(data);
|
||||||
gs.ctxt_regs[i].MIPTBP1._u64 = r->_u64;
|
gs.ctxt_regs[i].MIPTBP1._u64 = r->_u64;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <u32 i>
|
template <u32 i>
|
||||||
void __gifCall GIFRegHandlerMIPTBP2(const u32* data)
|
void __gifCall GIFRegHandlerMIPTBP2(const u32 *data)
|
||||||
{
|
{
|
||||||
GIFRegMIPTBP2* r = (GIFRegMIPTBP2*)(data);
|
GIFRegMIPTBP2 *r = (GIFRegMIPTBP2 *)(data);
|
||||||
gs.ctxt_regs[i].MIPTBP2._u64 = r->_u64;
|
gs.ctxt_regs[i].MIPTBP2._u64 = r->_u64;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __gifCall GIFRegHandlerTEXA(const u32* data)
|
void __gifCall GIFRegHandlerTEXA(const u32 *data)
|
||||||
{
|
{
|
||||||
GIFRegTEXA* r = (GIFRegTEXA*)(data);
|
GIFRegTEXA *r = (GIFRegTEXA *)(data);
|
||||||
gs.regs.TEXA._u64 = r->_u64;
|
gs.regs.TEXA._u64 = r->_u64;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __gifCall GIFRegHandlerFOGCOL(const u32* data)
|
void __gifCall GIFRegHandlerFOGCOL(const u32 *data)
|
||||||
{
|
{
|
||||||
GIFRegFOGCOL* r = (GIFRegFOGCOL*)(data);
|
GIFRegFOGCOL *r = (GIFRegFOGCOL *)(data);
|
||||||
gs.regs.FOGCOL._u64 = r->_u64;
|
gs.regs.FOGCOL._u64 = r->_u64;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __gifCall GIFRegHandlerTEXFLUSH(const u32* data)
|
void __gifCall GIFRegHandlerTEXFLUSH(const u32 *data)
|
||||||
{
|
{
|
||||||
GIFRegTEXFLUSH* r = (GIFRegTEXFLUSH*)(data);
|
GIFRegTEXFLUSH *r = (GIFRegTEXFLUSH *)(data);
|
||||||
gs.regs.TEXFLUSH._u64 = r->_u64;
|
gs.regs.TEXFLUSH._u64 = r->_u64;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <u32 i>
|
template <u32 i>
|
||||||
void __gifCall GIFRegHandlerSCISSOR(const u32* data)
|
void __gifCall GIFRegHandlerSCISSOR(const u32 *data)
|
||||||
{
|
{
|
||||||
GIFRegSCISSOR* r = (GIFRegSCISSOR*)(data);
|
GIFRegSCISSOR *r = (GIFRegSCISSOR *)(data);
|
||||||
gs.ctxt_regs[i].SCISSOR._u64 = r->_u64;
|
gs.ctxt_regs[i].SCISSOR._u64 = r->_u64;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <u32 i>
|
template <u32 i>
|
||||||
void __gifCall GIFRegHandlerALPHA(const u32* data)
|
void __gifCall GIFRegHandlerALPHA(const u32 *data)
|
||||||
{
|
{
|
||||||
GIFRegALPHA* r = (GIFRegALPHA*)(data);
|
GIFRegALPHA *r = (GIFRegALPHA *)(data);
|
||||||
gs.ctxt_regs[i].ALPHA._u64 = r->_u64;
|
gs.ctxt_regs[i].ALPHA._u64 = r->_u64;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __gifCall GIFRegHandlerDIMX(const u32* data)
|
void __gifCall GIFRegHandlerDIMX(const u32 *data)
|
||||||
{
|
{
|
||||||
GIFRegDIMX* r = (GIFRegDIMX*)(data);
|
GIFRegDIMX *r = (GIFRegDIMX *)(data);
|
||||||
gs.regs.DIMX._u64 = r->_u64;
|
gs.regs.DIMX._u64 = r->_u64;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __gifCall GIFRegHandlerDTHE(const u32* data)
|
void __gifCall GIFRegHandlerDTHE(const u32 *data)
|
||||||
{
|
{
|
||||||
GIFRegDTHE* r = (GIFRegDTHE*)(data);
|
GIFRegDTHE *r = (GIFRegDTHE *)(data);
|
||||||
gs.regs.DTHE._u64 = r->_u64;
|
gs.regs.DTHE._u64 = r->_u64;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __gifCall GIFRegHandlerCOLCLAMP(const u32* data)
|
void __gifCall GIFRegHandlerCOLCLAMP(const u32 *data)
|
||||||
{
|
{
|
||||||
GIFRegCOLCLAMP* r = (GIFRegCOLCLAMP*)(data);
|
GIFRegCOLCLAMP *r = (GIFRegCOLCLAMP *)(data);
|
||||||
gs.regs.COLCLAMP._u64 = r->_u64;
|
gs.regs.COLCLAMP._u64 = r->_u64;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <u32 i>
|
template <u32 i>
|
||||||
void __gifCall GIFRegHandlerTEST(const u32* data)
|
void __gifCall GIFRegHandlerTEST(const u32 *data)
|
||||||
{
|
{
|
||||||
GIFRegTEST* r = (GIFRegTEST*)(data);
|
GIFRegTEST *r = (GIFRegTEST *)(data);
|
||||||
gs.ctxt_regs[i].TEST._u64 = r->_u64;
|
gs.ctxt_regs[i].TEST._u64 = r->_u64;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __gifCall GIFRegHandlerPABE(const u32* data)
|
void __gifCall GIFRegHandlerPABE(const u32 *data)
|
||||||
{
|
{
|
||||||
GIFRegPABE* r = (GIFRegPABE*)(data);
|
GIFRegPABE *r = (GIFRegPABE *)(data);
|
||||||
gs.regs.PABE._u64 = r->_u64;
|
gs.regs.PABE._u64 = r->_u64;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <u32 i>
|
template <u32 i>
|
||||||
void __gifCall GIFRegHandlerFBA(const u32* data)
|
void __gifCall GIFRegHandlerFBA(const u32 *data)
|
||||||
{
|
{
|
||||||
GIFRegFBA* r = (GIFRegFBA*)(data);
|
GIFRegFBA *r = (GIFRegFBA *)(data);
|
||||||
gs.ctxt_regs[i].FBA._u64 = r->_u64;
|
gs.ctxt_regs[i].FBA._u64 = r->_u64;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <u32 i>
|
template <u32 i>
|
||||||
void __gifCall GIFRegHandlerFRAME(const u32* data)
|
void __gifCall GIFRegHandlerFRAME(const u32 *data)
|
||||||
{
|
{
|
||||||
GIFRegFRAME* r = (GIFRegFRAME*)(data);
|
GIFRegFRAME *r = (GIFRegFRAME *)(data);
|
||||||
gs.ctxt_regs[i].FRAME._u64 = r->_u64;
|
gs.ctxt_regs[i].FRAME._u64 = r->_u64;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <u32 i>
|
template <u32 i>
|
||||||
void __gifCall GIFRegHandlerZBUF(const u32* data)
|
void __gifCall GIFRegHandlerZBUF(const u32 *data)
|
||||||
{
|
{
|
||||||
GIFRegZBUF* r = (GIFRegZBUF*)(data);
|
GIFRegZBUF *r = (GIFRegZBUF *)(data);
|
||||||
gs.ctxt_regs[i].ZBUF._u64 = r->_u64;
|
gs.ctxt_regs[i].ZBUF._u64 = r->_u64;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __gifCall GIFRegHandlerBITBLTBUF(const u32* data)
|
void __gifCall GIFRegHandlerBITBLTBUF(const u32 *data)
|
||||||
{
|
{
|
||||||
GIFRegBITBLTBUF* r = (GIFRegBITBLTBUF*)(data);
|
GIFRegBITBLTBUF *r = (GIFRegBITBLTBUF *)(data);
|
||||||
gs.regs.BITBLTBUF._u64 = r->_u64;
|
gs.regs.BITBLTBUF._u64 = r->_u64;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __gifCall GIFRegHandlerTRXPOS(const u32* data)
|
void __gifCall GIFRegHandlerTRXPOS(const u32 *data)
|
||||||
{
|
{
|
||||||
GIFRegTRXPOS* r = (GIFRegTRXPOS*)(data);
|
GIFRegTRXPOS *r = (GIFRegTRXPOS *)(data);
|
||||||
gs.regs.TRXPOS._u64 = r->_u64;
|
gs.regs.TRXPOS._u64 = r->_u64;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __gifCall GIFRegHandlerTRXREG(const u32* data)
|
void __gifCall GIFRegHandlerTRXREG(const u32 *data)
|
||||||
{
|
{
|
||||||
GIFRegTRXREG* r = (GIFRegTRXREG*)(data);
|
GIFRegTRXREG *r = (GIFRegTRXREG *)(data);
|
||||||
gs.regs.TRXREG._u64 = r->_u64;
|
gs.regs.TRXREG._u64 = r->_u64;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __gifCall GIFRegHandlerTRXDIR(const u32* data)
|
void __gifCall GIFRegHandlerTRXDIR(const u32 *data)
|
||||||
{
|
{
|
||||||
GIFRegTRXDIR* r = (GIFRegTRXDIR*)(data);
|
GIFRegTRXDIR *r = (GIFRegTRXDIR *)(data);
|
||||||
gs.regs.TRXDIR._u64 = r->_u64;
|
gs.regs.TRXDIR._u64 = r->_u64;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __gifCall GIFRegHandlerHWREG(const u32* data)
|
void __gifCall GIFRegHandlerHWREG(const u32 *data)
|
||||||
{
|
{
|
||||||
GIFRegHWREG* r = (GIFRegHWREG*)(data);
|
GIFRegHWREG *r = (GIFRegHWREG *)(data);
|
||||||
gs.regs.HWREG._u64 = r->_u64;
|
gs.regs.HWREG._u64 = r->_u64;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void __gifCall GIFRegHandlerSIGNAL(const u32* data)
|
void __gifCall GIFRegHandlerSIGNAL(const u32 *data)
|
||||||
{
|
{
|
||||||
GIFRegSIGNAL* r = (GIFRegSIGNAL*)(data);
|
GIFRegSIGNAL *r = (GIFRegSIGNAL *)(data);
|
||||||
gs.regs.SIGNAL._u64 = r->_u64;
|
gs.regs.SIGNAL._u64 = r->_u64;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __gifCall GIFRegHandlerFINISH(const u32* data)
|
void __gifCall GIFRegHandlerFINISH(const u32 *data)
|
||||||
{
|
{
|
||||||
GIFRegFINISH* r = (GIFRegFINISH*)(data);
|
GIFRegFINISH *r = (GIFRegFINISH *)(data);
|
||||||
gs.regs.FINISH._u64 = r->_u64;
|
gs.regs.FINISH._u64 = r->_u64;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __gifCall GIFRegHandlerLABEL(const u32* data)
|
void __gifCall GIFRegHandlerLABEL(const u32 *data)
|
||||||
{
|
{
|
||||||
GIFRegLABEL* r = (GIFRegLABEL*)(data);
|
GIFRegLABEL *r = (GIFRegLABEL *)(data);
|
||||||
gs.regs.LABEL._u64 = r->_u64;
|
gs.regs.LABEL._u64 = r->_u64;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -114,8 +114,8 @@ enum GIF_A_D_REG {
|
||||||
// In case we want to change to/from __fastcall for GIF register handlers:
|
// In case we want to change to/from __fastcall for GIF register handlers:
|
||||||
#define __gifCall __fastcall
|
#define __gifCall __fastcall
|
||||||
|
|
||||||
typedef void __gifCall FnType_GIFRegHandler(const u32* data);
|
typedef void __gifCall FnType_GIFRegHandler(const u32 *data);
|
||||||
typedef FnType_GIFRegHandler* GIFRegHandler;
|
typedef FnType_GIFRegHandler *GIFRegHandler;
|
||||||
|
|
||||||
extern FnType_GIFRegHandler GIFPackedRegHandlerNull;
|
extern FnType_GIFRegHandler GIFPackedRegHandlerNull;
|
||||||
extern FnType_GIFRegHandler GIFPackedRegHandlerRGBA;
|
extern FnType_GIFRegHandler GIFPackedRegHandlerRGBA;
|
||||||
|
|
|
@ -21,8 +21,8 @@ extern HINSTANCE hInst;
|
||||||
void SaveConfig()
|
void SaveConfig()
|
||||||
{
|
{
|
||||||
|
|
||||||
Config* Conf1 = &conf;
|
Config *Conf1 = &conf;
|
||||||
char* szTemp;
|
char *szTemp;
|
||||||
char szIniFile[256], szValue[256];
|
char szIniFile[256], szValue[256];
|
||||||
|
|
||||||
GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
|
GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
|
||||||
|
@ -37,11 +37,11 @@ void SaveConfig()
|
||||||
|
|
||||||
void LoadConfig()
|
void LoadConfig()
|
||||||
{
|
{
|
||||||
FILE* fp;
|
FILE *fp;
|
||||||
|
|
||||||
|
|
||||||
Config* Conf1 = &conf;
|
Config *Conf1 = &conf;
|
||||||
char* szTemp;
|
char *szTemp;
|
||||||
char szIniFile[256], szValue[256];
|
char szIniFile[256], szValue[256];
|
||||||
|
|
||||||
GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
|
GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
|
||||||
|
|
|
@ -33,7 +33,7 @@ LRESULT CALLBACK MsgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GSOpenWindow(void* pDsp, const char* Title)
|
int GSOpenWindow(void *pDsp, const char *Title)
|
||||||
{
|
{
|
||||||
WNDCLASSEX wc = {sizeof(WNDCLASSEX), CS_CLASSDC, MsgProc, 0L, 0L,
|
WNDCLASSEX wc = {sizeof(WNDCLASSEX), CS_CLASSDC, MsgProc, 0L, 0L,
|
||||||
GetModuleHandle(NULL), NULL, NULL, NULL, NULL,
|
GetModuleHandle(NULL), NULL, NULL, NULL, NULL,
|
||||||
|
@ -49,7 +49,7 @@ int GSOpenWindow(void* pDsp, const char* Title)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pDsp != NULL)
|
if (pDsp != NULL)
|
||||||
*(uptr*)pDsp = (uptr)GShwnd;
|
*(uptr *)pDsp = (uptr)GShwnd;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -64,6 +64,6 @@ void GSProcessMessages()
|
||||||
}
|
}
|
||||||
|
|
||||||
// GSkeyEvent gets called when there is a keyEvent from the PAD plugin
|
// GSkeyEvent gets called when there is a keyEvent from the PAD plugin
|
||||||
void HandleKeyEvent(keyEvent* ev)
|
void HandleKeyEvent(keyEvent *ev)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <windowsx.h>
|
#include <windowsx.h>
|
||||||
|
|
||||||
extern int GSOpenWindow(void* pDsp, const char* Title);
|
extern int GSOpenWindow(void *pDsp, const char *Title);
|
||||||
extern void GSCloseWindow();
|
extern void GSCloseWindow();
|
||||||
extern void GSProcessMessages();
|
extern void GSProcessMessages();
|
||||||
extern void HandleKeyEvent(keyEvent* ev);
|
extern void HandleKeyEvent(keyEvent *ev);
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
HINSTANCE hInst;
|
HINSTANCE hInst;
|
||||||
extern HWND GShwnd;
|
extern HWND GShwnd;
|
||||||
|
|
||||||
void SysMessage(char* fmt, ...)
|
void SysMessage(char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list list;
|
va_list list;
|
||||||
char tmp[512];
|
char tmp[512];
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -21,60 +21,65 @@
|
||||||
extern u8 ps2e;
|
extern u8 ps2e;
|
||||||
|
|
||||||
enum PadType {
|
enum PadType {
|
||||||
DisabledPad,
|
DisabledPad,
|
||||||
Dualshock2Pad,
|
Dualshock2Pad,
|
||||||
GuitarPad,
|
GuitarPad,
|
||||||
PopnPad
|
PopnPad
|
||||||
};
|
};
|
||||||
|
|
||||||
const int numPadTypes= 4;
|
const int numPadTypes = 4;
|
||||||
extern const wchar_t *padTypes[numPadTypes];
|
extern const wchar_t *padTypes[numPadTypes];
|
||||||
|
|
||||||
struct PadConfig {
|
struct PadConfig
|
||||||
PadType type;
|
{
|
||||||
u8 autoAnalog;
|
PadType type;
|
||||||
|
u8 autoAnalog;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct GeneralConfig {
|
struct GeneralConfig
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
PadConfig padConfigs[2][4];
|
PadConfig padConfigs[2][4];
|
||||||
|
|
||||||
u8 closeHacks;
|
u8 closeHacks;
|
||||||
|
|
||||||
DeviceAPI keyboardApi;
|
DeviceAPI keyboardApi;
|
||||||
DeviceAPI mouseApi;
|
DeviceAPI mouseApi;
|
||||||
|
|
||||||
// Derived value, calculated by GetInput().
|
// Derived value, calculated by GetInput().
|
||||||
u8 ignoreKeys;
|
u8 ignoreKeys;
|
||||||
|
|
||||||
union {
|
union
|
||||||
struct {
|
{
|
||||||
u8 forceHide;
|
struct
|
||||||
u8 mouseUnfocus;
|
{
|
||||||
u8 background;
|
u8 forceHide;
|
||||||
u8 multipleBinding;
|
u8 mouseUnfocus;
|
||||||
|
u8 background;
|
||||||
|
u8 multipleBinding;
|
||||||
|
|
||||||
struct {
|
struct
|
||||||
u8 directInput;
|
{
|
||||||
u8 xInput;
|
u8 directInput;
|
||||||
u8 dualShock3;
|
u8 xInput;
|
||||||
} gameApis;
|
u8 dualShock3;
|
||||||
|
} gameApis;
|
||||||
|
|
||||||
u8 multitap[2];
|
u8 multitap[2];
|
||||||
|
|
||||||
u8 escapeFullscreenHack;
|
u8 escapeFullscreenHack;
|
||||||
u8 disableScreenSaver;
|
u8 disableScreenSaver;
|
||||||
u8 debug;
|
u8 debug;
|
||||||
|
|
||||||
u8 saveStateTitle;
|
u8 saveStateTitle;
|
||||||
u8 GH2;
|
u8 GH2;
|
||||||
u8 turboKeyHack;
|
u8 turboKeyHack;
|
||||||
};
|
};
|
||||||
u8 bools[15];
|
u8 bools[15];
|
||||||
};
|
};
|
||||||
|
|
||||||
wchar_t lastSaveConfigPath[MAX_PATH+1];
|
wchar_t lastSaveConfigPath[MAX_PATH + 1];
|
||||||
wchar_t lastSaveConfigFileName[MAX_PATH+1];
|
wchar_t lastSaveConfigFileName[MAX_PATH + 1];
|
||||||
};
|
};
|
||||||
|
|
||||||
extern GeneralConfig config;
|
extern GeneralConfig config;
|
||||||
|
|
|
@ -33,24 +33,25 @@
|
||||||
#include "Linux/JoyEvdev.h"
|
#include "Linux/JoyEvdev.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void EnumDevices(int hideDXXinput) {
|
void EnumDevices(int hideDXXinput)
|
||||||
// Needed for enumeration of some device types.
|
{
|
||||||
dm->ReleaseInput();
|
// Needed for enumeration of some device types.
|
||||||
InputDeviceManager *oldDm = dm;
|
dm->ReleaseInput();
|
||||||
dm = new InputDeviceManager();
|
InputDeviceManager *oldDm = dm;
|
||||||
|
dm = new InputDeviceManager();
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
EnumWindowsMessagingDevices();
|
EnumWindowsMessagingDevices();
|
||||||
EnumRawInputDevices();
|
EnumRawInputDevices();
|
||||||
EnumDualShock3s();
|
EnumDualShock3s();
|
||||||
EnumXInputDevices();
|
EnumXInputDevices();
|
||||||
EnumDirectInputDevices(hideDXXinput);
|
EnumDirectInputDevices(hideDXXinput);
|
||||||
#else
|
#else
|
||||||
EnumLnx();
|
EnumLnx();
|
||||||
EnumJoystickEvdev();
|
EnumJoystickEvdev();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
dm->CopyBindings(oldDm->numDevices, oldDm->devices);
|
dm->CopyBindings(oldDm->numDevices, oldDm->devices);
|
||||||
|
|
||||||
delete oldDm;
|
delete oldDm;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,4 +16,3 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void EnumDevices(int hideDXXinput);
|
void EnumDevices(int hideDXXinput);
|
||||||
|
|
||||||
|
|
|
@ -25,121 +25,121 @@
|
||||||
|
|
||||||
Device *dev;
|
Device *dev;
|
||||||
|
|
||||||
INT_PTR CALLBACK DiagDialog(HWND hWnd, unsigned int uMsg, WPARAM wParam, LPARAM lParam) {
|
INT_PTR CALLBACK DiagDialog(HWND hWnd, unsigned int uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
int i;
|
{
|
||||||
HWND hWndList = GetDlgItem(hWnd, IDC_LIST);
|
int i;
|
||||||
static int fullRefresh;
|
HWND hWndList = GetDlgItem(hWnd, IDC_LIST);
|
||||||
if (dev) {
|
static int fullRefresh;
|
||||||
switch (uMsg) {
|
if (dev) {
|
||||||
case WM_INITDIALOG:
|
switch (uMsg) {
|
||||||
{
|
case WM_INITDIALOG: {
|
||||||
fullRefresh = 1;
|
fullRefresh = 1;
|
||||||
SetWindowText(hWnd, dev->displayName);
|
SetWindowText(hWnd, dev->displayName);
|
||||||
LVCOLUMNW c;
|
LVCOLUMNW c;
|
||||||
c.mask = LVCF_TEXT | LVCF_WIDTH;
|
c.mask = LVCF_TEXT | LVCF_WIDTH;
|
||||||
c.cx = 151;
|
c.cx = 151;
|
||||||
c.pszText = L"Control";
|
c.pszText = L"Control";
|
||||||
ListView_InsertColumn(hWndList, 0, &c);
|
ListView_InsertColumn(hWndList, 0, &c);
|
||||||
c.cx = 90;
|
c.cx = 90;
|
||||||
c.pszText = L"Value";
|
c.pszText = L"Value";
|
||||||
ListView_InsertColumn(hWndList, 1, &c);
|
ListView_InsertColumn(hWndList, 1, &c);
|
||||||
ListView_DeleteAllItems(hWndList);
|
ListView_DeleteAllItems(hWndList);
|
||||||
LVITEM item;
|
LVITEM item;
|
||||||
item.mask = LVIF_TEXT;
|
item.mask = LVIF_TEXT;
|
||||||
item.iSubItem = 0;
|
item.iSubItem = 0;
|
||||||
for (i=0; i<dev->numVirtualControls; i++) {
|
for (i = 0; i < dev->numVirtualControls; i++) {
|
||||||
item.pszText = dev->GetVirtualControlName(dev->virtualControls+i);
|
item.pszText = dev->GetVirtualControlName(dev->virtualControls + i);
|
||||||
item.iItem = i;
|
item.iItem = i;
|
||||||
ListView_InsertItem(hWndList, &item);
|
ListView_InsertItem(hWndList, &item);
|
||||||
}
|
}
|
||||||
SetTimer(hWnd, 1, 200, 0);
|
SetTimer(hWnd, 1, 200, 0);
|
||||||
}
|
}
|
||||||
//break;
|
//break;
|
||||||
case WM_TIMER:
|
case WM_TIMER: {
|
||||||
{
|
hWndButtonProc.SetWndHandle(hWndList);
|
||||||
hWndButtonProc.SetWndHandle(hWndList);
|
InitInfo info = {0, 1, hWnd, &hWndButtonProc};
|
||||||
InitInfo info = {0, 1, hWnd, &hWndButtonProc};
|
dm->Update(&info);
|
||||||
dm->Update(&info);
|
LVITEMW item;
|
||||||
LVITEMW item;
|
item.mask = LVIF_TEXT;
|
||||||
item.mask = LVIF_TEXT;
|
item.iSubItem = 1;
|
||||||
item.iSubItem = 1;
|
//ShowWindow(hWndList, 0);
|
||||||
//ShowWindow(hWndList, 0);
|
//LockWindowUpdate(hWndList);
|
||||||
//LockWindowUpdate(hWndList);
|
if (!dev->active) {
|
||||||
if (!dev->active) {
|
item.pszText = L"?";
|
||||||
item.pszText = L"?";
|
for (i = 0; i < dev->numVirtualControls; i++) {
|
||||||
for (i=0; i<dev->numVirtualControls; i++) {
|
item.iItem = i;
|
||||||
item.iItem = i;
|
ListView_SetItem(hWndList, &item);
|
||||||
ListView_SetItem(hWndList, &item);
|
}
|
||||||
}
|
fullRefresh = 1;
|
||||||
fullRefresh = 1;
|
} else {
|
||||||
}
|
for (i = 0; i < dev->numVirtualControls; i++) {
|
||||||
else {
|
if (fullRefresh || dev->virtualControlState[i] != dev->oldVirtualControlState[i]) {
|
||||||
for (i=0; i<dev->numVirtualControls; i++) {
|
|
||||||
if (fullRefresh || dev->virtualControlState[i] != dev->oldVirtualControlState[i]) {
|
|
||||||
|
|
||||||
VirtualControl *c = dev->virtualControls + i;
|
VirtualControl *c = dev->virtualControls + i;
|
||||||
wchar_t temp[50];
|
wchar_t temp[50];
|
||||||
int val = dev->virtualControlState[i];
|
int val = dev->virtualControlState[i];
|
||||||
if (c->uid & (UID_POV)) {
|
if (c->uid & (UID_POV)) {
|
||||||
wsprintfW(temp, L"%i", val);
|
wsprintfW(temp, L"%i", val);
|
||||||
}
|
} else {
|
||||||
else {
|
wchar_t *sign = L"";
|
||||||
wchar_t *sign = L"";
|
if (val < 0) {
|
||||||
if (val < 0) {
|
sign = L"-";
|
||||||
sign = L"-";
|
val = -val;
|
||||||
val = -val;
|
}
|
||||||
}
|
if ((c->uid & UID_AXIS) && val) {
|
||||||
if ((c->uid& UID_AXIS) && val) {
|
val = val;
|
||||||
val = val;
|
}
|
||||||
}
|
val = (int)floor(0.5 + val * 1000.0 / (double)FULLY_DOWN);
|
||||||
val = (int)floor(0.5 + val * 1000.0 / (double)FULLY_DOWN);
|
wsprintfW(temp, L"%s%i.%03i", sign, val / 1000, val % 1000);
|
||||||
wsprintfW(temp, L"%s%i.%03i", sign, val/1000, val%1000);
|
}
|
||||||
}
|
item.pszText = temp;
|
||||||
item.pszText = temp;
|
item.iItem = i;
|
||||||
item.iItem = i;
|
ListView_SetItem(hWndList, &item);
|
||||||
ListView_SetItem(hWndList, &item);
|
}
|
||||||
}
|
}
|
||||||
}
|
dm->PostRead();
|
||||||
dm->PostRead();
|
fullRefresh = 0;
|
||||||
fullRefresh = 0;
|
}
|
||||||
}
|
//LockWindowUpdate(0);
|
||||||
//LockWindowUpdate(0);
|
//ShowWindow(hWndList, 1);
|
||||||
//ShowWindow(hWndList, 1);
|
//UpdateWindow(hWnd);
|
||||||
//UpdateWindow(hWnd);
|
} break;
|
||||||
}
|
case WM_NOTIFY: {
|
||||||
break;
|
NMLVKEYDOWN *n = (NMLVKEYDOWN *)lParam;
|
||||||
case WM_NOTIFY:
|
// Don't always get the notification when testing DirectInput non-keyboard devices.
|
||||||
{
|
// Don't get it (Or want it) when testing keyboards.
|
||||||
NMLVKEYDOWN *n = (NMLVKEYDOWN *) lParam;
|
if (n->hdr.idFrom != IDC_LIST || n->hdr.code != LVN_KEYDOWN || n->wVKey != VK_ESCAPE)
|
||||||
// Don't always get the notification when testing DirectInput non-keyboard devices.
|
break;
|
||||||
// Don't get it (Or want it) when testing keyboards.
|
}
|
||||||
if (n->hdr.idFrom != IDC_LIST || n->hdr.code != LVN_KEYDOWN || n->wVKey != VK_ESCAPE) break;
|
case WM_ACTIVATE:
|
||||||
}
|
if (uMsg == WM_ACTIVATE && wParam != WA_INACTIVE)
|
||||||
case WM_ACTIVATE:
|
break;
|
||||||
if (uMsg == WM_ACTIVATE && wParam != WA_INACTIVE) break;
|
break;
|
||||||
break;
|
case WM_CLOSE:
|
||||||
case WM_CLOSE:
|
KillTimer(hWnd, 1);
|
||||||
KillTimer(hWnd, 1);
|
dm->ReleaseInput();
|
||||||
dm->ReleaseInput();
|
// Prevents reaching this branch again.
|
||||||
// Prevents reaching this branch again.
|
dev = 0;
|
||||||
dev = 0;
|
EndDialog(hWnd, 1);
|
||||||
EndDialog(hWnd, 1);
|
break;
|
||||||
break;
|
default:
|
||||||
default:
|
break;
|
||||||
break;
|
}
|
||||||
}
|
}
|
||||||
}
|
return 0;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Diagnose(int id, HWND hWnd) {
|
void Diagnose(int id, HWND hWnd)
|
||||||
// init = 0;
|
{
|
||||||
dev = dm->devices[id];
|
// init = 0;
|
||||||
for (int i=0; i<dm->numDevices; i++) {
|
dev = dm->devices[id];
|
||||||
if (i != id) dm->DisableDevice(i);
|
for (int i = 0; i < dm->numDevices; i++) {
|
||||||
// Shouldn't be needed.
|
if (i != id)
|
||||||
else dm->EnableDevice(i);
|
dm->DisableDevice(i);
|
||||||
}
|
// Shouldn't be needed.
|
||||||
DialogBox(hInst, MAKEINTRESOURCE(IDD_DIAG), hWnd, DiagDialog);
|
else
|
||||||
ClearKeyQueue();
|
dm->EnableDevice(i);
|
||||||
|
}
|
||||||
|
DialogBox(hInst, MAKEINTRESOURCE(IDD_DIAG), hWnd, DiagDialog);
|
||||||
|
ClearKeyQueue();
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -41,15 +41,15 @@
|
||||||
unsigned int lastDS3Check = 0;
|
unsigned int lastDS3Check = 0;
|
||||||
unsigned int lastDS3Enum = 0;
|
unsigned int lastDS3Enum = 0;
|
||||||
|
|
||||||
typedef void (__cdecl *_usb_init)(void);
|
typedef void(__cdecl *_usb_init)(void);
|
||||||
typedef int (__cdecl *_usb_close)(usb_dev_handle *dev);
|
typedef int(__cdecl *_usb_close)(usb_dev_handle *dev);
|
||||||
typedef int (__cdecl *_usb_get_string_simple)(usb_dev_handle *dev, int index, char *buf, size_t buflen);
|
typedef int(__cdecl *_usb_get_string_simple)(usb_dev_handle *dev, int index, char *buf, size_t buflen);
|
||||||
typedef usb_dev_handle *(__cdecl *_usb_open)(struct usb_device *dev);
|
typedef usb_dev_handle *(__cdecl *_usb_open)(struct usb_device *dev);
|
||||||
typedef int (__cdecl *_usb_find_busses)(void);
|
typedef int(__cdecl *_usb_find_busses)(void);
|
||||||
typedef int (__cdecl *_usb_find_devices)(void);
|
typedef int(__cdecl *_usb_find_devices)(void);
|
||||||
typedef struct usb_bus *(__cdecl *_usb_get_busses)(void);
|
typedef struct usb_bus *(__cdecl *_usb_get_busses)(void);
|
||||||
typedef usb_dev_handle *(__cdecl *_usb_open)(struct usb_device *dev);
|
typedef usb_dev_handle *(__cdecl *_usb_open)(struct usb_device *dev);
|
||||||
typedef int (__cdecl *_usb_control_msg)(usb_dev_handle *dev, int requesttype, int request, int value, int index, char *bytes, int size, int timeout);
|
typedef int(__cdecl *_usb_control_msg)(usb_dev_handle *dev, int requesttype, int request, int value, int index, char *bytes, int size, int timeout);
|
||||||
|
|
||||||
_usb_init pusb_init;
|
_usb_init pusb_init;
|
||||||
_usb_close pusb_close;
|
_usb_close pusb_close;
|
||||||
|
@ -62,408 +62,435 @@ _usb_control_msg pusb_control_msg;
|
||||||
|
|
||||||
HMODULE hModLibusb = 0;
|
HMODULE hModLibusb = 0;
|
||||||
|
|
||||||
void UninitLibUsb() {
|
void UninitLibUsb()
|
||||||
if (hModLibusb) {
|
{
|
||||||
FreeLibrary(hModLibusb);
|
if (hModLibusb) {
|
||||||
hModLibusb = 0;
|
FreeLibrary(hModLibusb);
|
||||||
}
|
hModLibusb = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TryInitDS3(usb_device *dev) {
|
void TryInitDS3(usb_device *dev)
|
||||||
while (dev) {
|
{
|
||||||
if (dev->descriptor.idVendor == VID && dev->descriptor.idProduct == PID) {
|
while (dev) {
|
||||||
usb_dev_handle *handle = pusb_open(dev);
|
if (dev->descriptor.idVendor == VID && dev->descriptor.idProduct == PID) {
|
||||||
if (handle) {
|
usb_dev_handle *handle = pusb_open(dev);
|
||||||
char junk[20];
|
if (handle) {
|
||||||
// This looks like HidD_GetFeature with a feature report id of 0xF2 to me and a length of 17.
|
char junk[20];
|
||||||
// That doesn't work, however, and 17 is shorter than the report length.
|
// This looks like HidD_GetFeature with a feature report id of 0xF2 to me and a length of 17.
|
||||||
pusb_control_msg(handle, 0xa1, 1, 0x03f2, dev->config->interface->altsetting->bInterfaceNumber, junk, 17, 1000);
|
// That doesn't work, however, and 17 is shorter than the report length.
|
||||||
pusb_close(handle);
|
pusb_control_msg(handle, 0xa1, 1, 0x03f2, dev->config->interface->altsetting->bInterfaceNumber, junk, 17, 1000);
|
||||||
}
|
pusb_close(handle);
|
||||||
}
|
}
|
||||||
if (dev->num_children) {
|
}
|
||||||
for (int i=0; i<dev->num_children; i++) {
|
if (dev->num_children) {
|
||||||
TryInitDS3(dev->children[i]);
|
for (int i = 0; i < dev->num_children; i++) {
|
||||||
}
|
TryInitDS3(dev->children[i]);
|
||||||
}
|
}
|
||||||
dev = dev->next;
|
}
|
||||||
}
|
dev = dev->next;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DS3Enum(unsigned int time) {
|
void DS3Enum(unsigned int time)
|
||||||
if (time - lastDS3Enum < DOUBLE_ENUM_DELAY) {
|
{
|
||||||
return;
|
if (time - lastDS3Enum < DOUBLE_ENUM_DELAY) {
|
||||||
}
|
return;
|
||||||
lastDS3Enum = time;
|
}
|
||||||
pusb_find_busses();
|
lastDS3Enum = time;
|
||||||
pusb_find_devices();
|
pusb_find_busses();
|
||||||
|
pusb_find_devices();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DS3Check(unsigned int time) {
|
void DS3Check(unsigned int time)
|
||||||
if (time - lastDS3Check < DOUBLE_CHECK_DELAY) {
|
{
|
||||||
return;
|
if (time - lastDS3Check < DOUBLE_CHECK_DELAY) {
|
||||||
}
|
return;
|
||||||
if (!lastDS3Check) {
|
}
|
||||||
DS3Enum(time);
|
if (!lastDS3Check) {
|
||||||
}
|
DS3Enum(time);
|
||||||
lastDS3Check = time;
|
}
|
||||||
|
lastDS3Check = time;
|
||||||
|
|
||||||
usb_bus *bus = pusb_get_busses();
|
usb_bus *bus = pusb_get_busses();
|
||||||
while (bus) {
|
while (bus) {
|
||||||
TryInitDS3(bus->devices);
|
TryInitDS3(bus->devices);
|
||||||
bus = bus->next;
|
bus = bus->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int InitLibUsb() {
|
int InitLibUsb()
|
||||||
if (hModLibusb) {
|
{
|
||||||
return 1;
|
if (hModLibusb) {
|
||||||
}
|
return 1;
|
||||||
hModLibusb = LoadLibraryA("C:\\windows\\system32\\libusb0.dll");
|
}
|
||||||
if (hModLibusb) {
|
hModLibusb = LoadLibraryA("C:\\windows\\system32\\libusb0.dll");
|
||||||
if ((pusb_init = (_usb_init) GetProcAddress(hModLibusb, "usb_init")) &&
|
if (hModLibusb) {
|
||||||
(pusb_close = (_usb_close) GetProcAddress(hModLibusb, "usb_close")) &&
|
if ((pusb_init = (_usb_init)GetProcAddress(hModLibusb, "usb_init")) &&
|
||||||
(pusb_get_string_simple = (_usb_get_string_simple) GetProcAddress(hModLibusb, "usb_get_string_simple")) &&
|
(pusb_close = (_usb_close)GetProcAddress(hModLibusb, "usb_close")) &&
|
||||||
(pusb_open = (_usb_open) GetProcAddress(hModLibusb, "usb_open")) &&
|
(pusb_get_string_simple = (_usb_get_string_simple)GetProcAddress(hModLibusb, "usb_get_string_simple")) &&
|
||||||
(pusb_find_busses = (_usb_find_busses) GetProcAddress(hModLibusb, "usb_find_busses")) &&
|
(pusb_open = (_usb_open)GetProcAddress(hModLibusb, "usb_open")) &&
|
||||||
(pusb_find_devices = (_usb_find_devices) GetProcAddress(hModLibusb, "usb_find_devices")) &&
|
(pusb_find_busses = (_usb_find_busses)GetProcAddress(hModLibusb, "usb_find_busses")) &&
|
||||||
(pusb_get_busses = (_usb_get_busses) GetProcAddress(hModLibusb, "usb_get_busses")) &&
|
(pusb_find_devices = (_usb_find_devices)GetProcAddress(hModLibusb, "usb_find_devices")) &&
|
||||||
(pusb_control_msg = (_usb_control_msg) GetProcAddress(hModLibusb, "usb_control_msg"))) {
|
(pusb_get_busses = (_usb_get_busses)GetProcAddress(hModLibusb, "usb_get_busses")) &&
|
||||||
pusb_init();
|
(pusb_control_msg = (_usb_control_msg)GetProcAddress(hModLibusb, "usb_control_msg"))) {
|
||||||
return 1;
|
pusb_init();
|
||||||
}
|
return 1;
|
||||||
UninitLibUsb();
|
}
|
||||||
}
|
UninitLibUsb();
|
||||||
return 0;
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int DualShock3Possible() {
|
int DualShock3Possible()
|
||||||
return InitLibUsb();
|
{
|
||||||
|
return InitLibUsb();
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <pshpack1.h>
|
#include <pshpack1.h>
|
||||||
|
|
||||||
struct MotorState {
|
struct MotorState
|
||||||
unsigned char duration;
|
{
|
||||||
unsigned char force;
|
unsigned char duration;
|
||||||
|
unsigned char force;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct LightState {
|
struct LightState
|
||||||
// 0xFF makes it stay on.
|
{
|
||||||
unsigned char duration;
|
// 0xFF makes it stay on.
|
||||||
// Have to make one or the other non-zero to turn on light.
|
unsigned char duration;
|
||||||
unsigned char dunno[2];
|
// Have to make one or the other non-zero to turn on light.
|
||||||
// 0 is fully lit.
|
unsigned char dunno[2];
|
||||||
unsigned char dimness;
|
// 0 is fully lit.
|
||||||
// Have to make non-zero to turn on light.
|
unsigned char dimness;
|
||||||
unsigned char on;
|
// Have to make non-zero to turn on light.
|
||||||
|
unsigned char on;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Data sent to DS3 to set state.
|
// Data sent to DS3 to set state.
|
||||||
struct DS3Command {
|
struct DS3Command
|
||||||
unsigned char id;
|
{
|
||||||
unsigned char unsure;
|
unsigned char id;
|
||||||
// Small is first, then big.
|
unsigned char unsure;
|
||||||
MotorState motors[2];
|
// Small is first, then big.
|
||||||
unsigned char noClue[4];
|
MotorState motors[2];
|
||||||
// 2 is pad 1 light, 4 is pad 2, 8 is pad 3, 16 is pad 4. No clue about the others.
|
unsigned char noClue[4];
|
||||||
unsigned char lightFlags;
|
// 2 is pad 1 light, 4 is pad 2, 8 is pad 3, 16 is pad 4. No clue about the others.
|
||||||
// Lights are in reverse order. pad 1 is last.
|
unsigned char lightFlags;
|
||||||
LightState lights[4];
|
// Lights are in reverse order. pad 1 is last.
|
||||||
unsigned char dunno[18];
|
LightState lights[4];
|
||||||
|
unsigned char dunno[18];
|
||||||
};
|
};
|
||||||
|
|
||||||
#include <poppack.h>
|
#include <poppack.h>
|
||||||
|
|
||||||
int CharToAxis(unsigned char c) {
|
int CharToAxis(unsigned char c)
|
||||||
int v = (int)c + ((unsigned int)c >> 7);
|
{
|
||||||
return ((c-128) * FULLY_DOWN)>>7;
|
int v = (int)c + ((unsigned int)c >> 7);
|
||||||
|
return ((c - 128) * FULLY_DOWN) >> 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CharToButton(unsigned char c) {
|
int CharToButton(unsigned char c)
|
||||||
int v = (int)c + ((unsigned int)c >> 7);
|
{
|
||||||
return (v * FULLY_DOWN)>>8;
|
int v = (int)c + ((unsigned int)c >> 7);
|
||||||
|
return (v * FULLY_DOWN) >> 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
class DualShock3Device : public Device {
|
class DualShock3Device : public Device
|
||||||
// Cached last vibration values by pad and motor.
|
{
|
||||||
// Need this, as only one value is changed at a time.
|
// Cached last vibration values by pad and motor.
|
||||||
int ps2Vibration[2][4][2];
|
// Need this, as only one value is changed at a time.
|
||||||
int vibration[2];
|
int ps2Vibration[2][4][2];
|
||||||
|
int vibration[2];
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int index;
|
int index;
|
||||||
HANDLE hFile;
|
HANDLE hFile;
|
||||||
DS3Command sendState;
|
DS3Command sendState;
|
||||||
unsigned char getState[49];
|
unsigned char getState[49];
|
||||||
OVERLAPPED readop;
|
OVERLAPPED readop;
|
||||||
OVERLAPPED writeop;
|
OVERLAPPED writeop;
|
||||||
int writeCount;
|
int writeCount;
|
||||||
int lastWrite;
|
int lastWrite;
|
||||||
|
|
||||||
unsigned int dataLastReceived;
|
unsigned int dataLastReceived;
|
||||||
|
|
||||||
int writeQueued;
|
int writeQueued;
|
||||||
int writing;
|
int writing;
|
||||||
|
|
||||||
int StartRead() {
|
int StartRead()
|
||||||
int res = ReadFile(hFile, &getState, sizeof(getState), 0, &readop);
|
{
|
||||||
return (res || GetLastError() == ERROR_IO_PENDING);
|
int res = ReadFile(hFile, &getState, sizeof(getState), 0, &readop);
|
||||||
}
|
return (res || GetLastError() == ERROR_IO_PENDING);
|
||||||
|
}
|
||||||
|
|
||||||
void QueueWrite() {
|
void QueueWrite()
|
||||||
// max of 2 queued writes allowed, one for either motor.
|
{
|
||||||
if (writeQueued < 2) {
|
// max of 2 queued writes allowed, one for either motor.
|
||||||
writeQueued++;
|
if (writeQueued < 2) {
|
||||||
StartWrite();
|
writeQueued++;
|
||||||
}
|
StartWrite();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int StartWrite() {
|
int StartWrite()
|
||||||
if (!writing && writeQueued) {
|
{
|
||||||
lastWrite = GetTickCount();
|
if (!writing && writeQueued) {
|
||||||
writing++;
|
lastWrite = GetTickCount();
|
||||||
writeQueued--;
|
writing++;
|
||||||
sendState.motors[0].duration = 0x50;
|
writeQueued--;
|
||||||
sendState.motors[1].duration = 0x50;
|
sendState.motors[0].duration = 0x50;
|
||||||
|
sendState.motors[1].duration = 0x50;
|
||||||
|
|
||||||
int bigForce = vibration[0] * 256/FULLY_DOWN;
|
int bigForce = vibration[0] * 256 / FULLY_DOWN;
|
||||||
if (bigForce > 255) bigForce = 255;
|
if (bigForce > 255)
|
||||||
sendState.motors[1].force = (unsigned char) bigForce;
|
bigForce = 255;
|
||||||
sendState.motors[0].force = (unsigned char) (vibration[1] >= FULLY_DOWN/2);
|
sendState.motors[1].force = (unsigned char)bigForce;
|
||||||
// Can't seem to have them both non-zero at once.
|
sendState.motors[0].force = (unsigned char)(vibration[1] >= FULLY_DOWN / 2);
|
||||||
if (sendState.motors[writeCount&1].force) {
|
// Can't seem to have them both non-zero at once.
|
||||||
sendState.motors[(writeCount&1)^1].force = 0;
|
if (sendState.motors[writeCount & 1].force) {
|
||||||
sendState.motors[(writeCount&1)^1].duration = 0;
|
sendState.motors[(writeCount & 1) ^ 1].force = 0;
|
||||||
}
|
sendState.motors[(writeCount & 1) ^ 1].duration = 0;
|
||||||
|
}
|
||||||
|
|
||||||
writeCount++;
|
writeCount++;
|
||||||
int res = WriteFile(hFile, &sendState, sizeof(sendState), 0, &writeop);
|
int res = WriteFile(hFile, &sendState, sizeof(sendState), 0, &writeop);
|
||||||
return (res || GetLastError() == ERROR_IO_PENDING);
|
return (res || GetLastError() == ERROR_IO_PENDING);
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
DualShock3Device(int index, wchar_t *name, wchar_t *path) : Device(DS3, OTHER, name, path, L"DualShock 3") {
|
DualShock3Device(int index, wchar_t *name, wchar_t *path)
|
||||||
writeCount = 0;
|
: Device(DS3, OTHER, name, path, L"DualShock 3")
|
||||||
writing = 0;
|
{
|
||||||
writeQueued = 0;
|
writeCount = 0;
|
||||||
memset(&readop, 0, sizeof(readop));
|
writing = 0;
|
||||||
memset(&writeop, 0, sizeof(writeop));
|
writeQueued = 0;
|
||||||
memset(&sendState, 0, sizeof(sendState));
|
memset(&readop, 0, sizeof(readop));
|
||||||
sendState.id = 1;
|
memset(&writeop, 0, sizeof(writeop));
|
||||||
int temp = (index&4);
|
memset(&sendState, 0, sizeof(sendState));
|
||||||
sendState.lightFlags = (1 << (temp+1));
|
sendState.id = 1;
|
||||||
sendState.lights[3-temp].duration = 0xFF;
|
int temp = (index & 4);
|
||||||
sendState.lights[3-temp].dunno[0] = 1;
|
sendState.lightFlags = (1 << (temp + 1));
|
||||||
sendState.lights[3-temp].on = 1;
|
sendState.lights[3 - temp].duration = 0xFF;
|
||||||
memset(ps2Vibration, 0, sizeof(ps2Vibration));
|
sendState.lights[3 - temp].dunno[0] = 1;
|
||||||
vibration[0] = vibration[1] = 0;
|
sendState.lights[3 - temp].on = 1;
|
||||||
this->index = index;
|
memset(ps2Vibration, 0, sizeof(ps2Vibration));
|
||||||
int i;
|
vibration[0] = vibration[1] = 0;
|
||||||
for (i=0; i<16; i++) {
|
this->index = index;
|
||||||
if (i != 14 && i != 15 && i != 8 && i != 9) {
|
int i;
|
||||||
AddPhysicalControl(PRESSURE_BTN, i, 0);
|
for (i = 0; i < 16; i++) {
|
||||||
}
|
if (i != 14 && i != 15 && i != 8 && i != 9) {
|
||||||
else {
|
AddPhysicalControl(PRESSURE_BTN, i, 0);
|
||||||
AddPhysicalControl(PSHBTN, i, 0);
|
} else {
|
||||||
}
|
AddPhysicalControl(PSHBTN, i, 0);
|
||||||
}
|
}
|
||||||
for (; i<23; i++) {
|
}
|
||||||
AddPhysicalControl(ABSAXIS, i, 0);
|
for (; i < 23; i++) {
|
||||||
}
|
AddPhysicalControl(ABSAXIS, i, 0);
|
||||||
AddFFAxis(L"Big Motor", 0);
|
}
|
||||||
AddFFAxis(L"Small Motor", 1);
|
AddFFAxis(L"Big Motor", 0);
|
||||||
AddFFEffectType(L"Constant Effect", L"Constant", EFFECT_CONSTANT);
|
AddFFAxis(L"Small Motor", 1);
|
||||||
hFile = INVALID_HANDLE_VALUE;
|
AddFFEffectType(L"Constant Effect", L"Constant", EFFECT_CONSTANT);
|
||||||
}
|
hFile = INVALID_HANDLE_VALUE;
|
||||||
|
}
|
||||||
|
|
||||||
wchar_t *GetPhysicalControlName(PhysicalControl *c) {
|
wchar_t *GetPhysicalControlName(PhysicalControl *c)
|
||||||
const static wchar_t *names[] = {
|
{
|
||||||
L"Square",
|
const static wchar_t *names[] = {
|
||||||
L"Cross",
|
L"Square",
|
||||||
L"Circle",
|
L"Cross",
|
||||||
L"Triangle",
|
L"Circle",
|
||||||
L"R1",
|
L"Triangle",
|
||||||
L"L1",
|
L"R1",
|
||||||
L"R2",
|
L"L1",
|
||||||
L"L2",
|
L"R2",
|
||||||
L"R3",
|
L"L2",
|
||||||
L"L3",
|
L"R3",
|
||||||
L"Left",
|
L"L3",
|
||||||
L"Down",
|
L"Left",
|
||||||
L"Right",
|
L"Down",
|
||||||
L"Up",
|
L"Right",
|
||||||
L"Start",
|
L"Up",
|
||||||
L"Select",
|
L"Start",
|
||||||
L"L-Stick X",
|
L"Select",
|
||||||
L"L-Stick Y",
|
L"L-Stick X",
|
||||||
L"R-Stick X",
|
L"L-Stick Y",
|
||||||
L"R-Stick Y",
|
L"R-Stick X",
|
||||||
L"Left/Right Tilt",
|
L"R-Stick Y",
|
||||||
L"Forward/Back Tilt",
|
L"Left/Right Tilt",
|
||||||
L"???",
|
L"Forward/Back Tilt",
|
||||||
};
|
L"???",
|
||||||
unsigned int i = (unsigned int) (c - physicalControls);
|
};
|
||||||
if (i < sizeof(names)/sizeof(names[0])) {
|
unsigned int i = (unsigned int)(c - physicalControls);
|
||||||
return (wchar_t*)names[i];
|
if (i < sizeof(names) / sizeof(names[0])) {
|
||||||
}
|
return (wchar_t *)names[i];
|
||||||
return Device::GetPhysicalControlName(c);
|
}
|
||||||
}
|
return Device::GetPhysicalControlName(c);
|
||||||
|
}
|
||||||
|
|
||||||
int Activate(InitInfo *initInfo) {
|
int Activate(InitInfo *initInfo)
|
||||||
if (active) Deactivate();
|
{
|
||||||
// Give grace period before get mad.
|
if (active)
|
||||||
lastWrite = dataLastReceived = GetTickCount();
|
Deactivate();
|
||||||
readop.hEvent = CreateEvent(0, 0, 0, 0);
|
// Give grace period before get mad.
|
||||||
writeop.hEvent = CreateEvent(0, 0, 0, 0);
|
lastWrite = dataLastReceived = GetTickCount();
|
||||||
hFile = CreateFileW(instanceID, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, 0);
|
readop.hEvent = CreateEvent(0, 0, 0, 0);
|
||||||
if (!readop.hEvent || !writeop.hEvent || hFile == INVALID_HANDLE_VALUE ||
|
writeop.hEvent = CreateEvent(0, 0, 0, 0);
|
||||||
!StartRead()) {
|
hFile = CreateFileW(instanceID, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, 0);
|
||||||
Deactivate();
|
if (!readop.hEvent || !writeop.hEvent || hFile == INVALID_HANDLE_VALUE ||
|
||||||
return 0;
|
!StartRead()) {
|
||||||
}
|
Deactivate();
|
||||||
active = 1;
|
return 0;
|
||||||
AllocState();
|
}
|
||||||
return 1;
|
active = 1;
|
||||||
}
|
AllocState();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
int Update() {
|
int Update()
|
||||||
if (!active) return 0;
|
{
|
||||||
HANDLE h[2] = {
|
if (!active)
|
||||||
readop.hEvent,
|
return 0;
|
||||||
writeop.hEvent
|
HANDLE h[2] = {
|
||||||
};
|
readop.hEvent,
|
||||||
unsigned int time = GetTickCount();
|
writeop.hEvent};
|
||||||
if (time - lastWrite > UPDATE_INTERVAL) {
|
unsigned int time = GetTickCount();
|
||||||
QueueWrite();
|
if (time - lastWrite > UPDATE_INTERVAL) {
|
||||||
}
|
QueueWrite();
|
||||||
while (1) {
|
}
|
||||||
DWORD res = WaitForMultipleObjects(2, h, 0, 0);
|
while (1) {
|
||||||
if (res == WAIT_OBJECT_0) {
|
DWORD res = WaitForMultipleObjects(2, h, 0, 0);
|
||||||
dataLastReceived = time;
|
if (res == WAIT_OBJECT_0) {
|
||||||
if (!StartRead()) {
|
dataLastReceived = time;
|
||||||
Deactivate();
|
if (!StartRead()) {
|
||||||
return 0;
|
Deactivate();
|
||||||
}
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
physicalControlState[0] = CharToButton(getState[25]);
|
physicalControlState[0] = CharToButton(getState[25]);
|
||||||
physicalControlState[1] = CharToButton(getState[24]);
|
physicalControlState[1] = CharToButton(getState[24]);
|
||||||
physicalControlState[2] = CharToButton(getState[23]);
|
physicalControlState[2] = CharToButton(getState[23]);
|
||||||
physicalControlState[3] = CharToButton(getState[22]);
|
physicalControlState[3] = CharToButton(getState[22]);
|
||||||
physicalControlState[4] = CharToButton(getState[21]);
|
physicalControlState[4] = CharToButton(getState[21]);
|
||||||
physicalControlState[5] = CharToButton(getState[20]);
|
physicalControlState[5] = CharToButton(getState[20]);
|
||||||
physicalControlState[6] = CharToButton(getState[19]);
|
physicalControlState[6] = CharToButton(getState[19]);
|
||||||
physicalControlState[7] = CharToButton(getState[18]);
|
physicalControlState[7] = CharToButton(getState[18]);
|
||||||
physicalControlState[10] = CharToButton(getState[17]);
|
physicalControlState[10] = CharToButton(getState[17]);
|
||||||
physicalControlState[11] = CharToButton(getState[16]);
|
physicalControlState[11] = CharToButton(getState[16]);
|
||||||
physicalControlState[12] = CharToButton(getState[15]);
|
physicalControlState[12] = CharToButton(getState[15]);
|
||||||
physicalControlState[13] = CharToButton(getState[14]);
|
physicalControlState[13] = CharToButton(getState[14]);
|
||||||
physicalControlState[8] = ((getState[2]&4)/4) * FULLY_DOWN;
|
physicalControlState[8] = ((getState[2] & 4) / 4) * FULLY_DOWN;
|
||||||
physicalControlState[9] = ((getState[2]&2)/2) * FULLY_DOWN;
|
physicalControlState[9] = ((getState[2] & 2) / 2) * FULLY_DOWN;
|
||||||
physicalControlState[15] = ((getState[2]&1)/1) * FULLY_DOWN;
|
physicalControlState[15] = ((getState[2] & 1) / 1) * FULLY_DOWN;
|
||||||
physicalControlState[14] = ((getState[2]&8)/8) * FULLY_DOWN;
|
physicalControlState[14] = ((getState[2] & 8) / 8) * FULLY_DOWN;
|
||||||
physicalControlState[16] = CharToAxis(getState[6]);
|
physicalControlState[16] = CharToAxis(getState[6]);
|
||||||
physicalControlState[17] = CharToAxis(getState[7]);
|
physicalControlState[17] = CharToAxis(getState[7]);
|
||||||
physicalControlState[18] = CharToAxis(getState[8]);
|
physicalControlState[18] = CharToAxis(getState[8]);
|
||||||
physicalControlState[19] = CharToAxis(getState[9]);
|
physicalControlState[19] = CharToAxis(getState[9]);
|
||||||
physicalControlState[20] = CharToAxis(getState[42]+128);
|
physicalControlState[20] = CharToAxis(getState[42] + 128);
|
||||||
physicalControlState[21] = CharToAxis(getState[44]+128);
|
physicalControlState[21] = CharToAxis(getState[44] + 128);
|
||||||
physicalControlState[22] = CharToAxis(getState[46]+128);
|
physicalControlState[22] = CharToAxis(getState[46] + 128);
|
||||||
continue;
|
continue;
|
||||||
}
|
} else if (res == WAIT_OBJECT_0 + 1) {
|
||||||
else if (res == WAIT_OBJECT_0+1) {
|
writing = 0;
|
||||||
writing = 0;
|
if (!writeQueued && (vibration[0] | vibration[1])) {
|
||||||
if (!writeQueued && (vibration[0] | vibration[1])) {
|
QueueWrite();
|
||||||
QueueWrite();
|
}
|
||||||
}
|
if (!StartWrite()) {
|
||||||
if (!StartWrite()) {
|
Deactivate();
|
||||||
Deactivate();
|
return 0;
|
||||||
return 0;
|
}
|
||||||
}
|
} else {
|
||||||
}
|
if (time - dataLastReceived >= DEVICE_CHECK_DELAY) {
|
||||||
else {
|
if (time - dataLastReceived >= DEVICE_ENUM_DELAY) {
|
||||||
if (time-dataLastReceived >= DEVICE_CHECK_DELAY) {
|
DS3Enum(time);
|
||||||
if (time-dataLastReceived >= DEVICE_ENUM_DELAY) {
|
}
|
||||||
DS3Enum(time);
|
DS3Check(time);
|
||||||
}
|
QueueWrite();
|
||||||
DS3Check(time);
|
}
|
||||||
QueueWrite();
|
}
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
break;
|
return 1;
|
||||||
}
|
}
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetEffects(unsigned char port, unsigned int slot, unsigned char motor, unsigned char force) {
|
void SetEffects(unsigned char port, unsigned int slot, unsigned char motor, unsigned char force)
|
||||||
ps2Vibration[port][slot][motor] = force;
|
{
|
||||||
vibration[0] = vibration[1] = 0;
|
ps2Vibration[port][slot][motor] = force;
|
||||||
for (int p=0; p<2; p++) {
|
vibration[0] = vibration[1] = 0;
|
||||||
for (int s=0; s<4; s++) {
|
for (int p = 0; p < 2; p++) {
|
||||||
for (int i=0; i<pads[p][s].numFFBindings; i++) {
|
for (int s = 0; s < 4; s++) {
|
||||||
// Technically should also be a *65535/BASE_SENSITIVITY, but that's close enough to 1 for me.
|
for (int i = 0; i < pads[p][s].numFFBindings; i++) {
|
||||||
ForceFeedbackBinding *ffb = &pads[p][s].ffBindings[i];
|
// Technically should also be a *65535/BASE_SENSITIVITY, but that's close enough to 1 for me.
|
||||||
vibration[0] += (int)((ffb->axes[0].force * (__int64)ps2Vibration[p][s][ffb->motor]) / 255);
|
ForceFeedbackBinding *ffb = &pads[p][s].ffBindings[i];
|
||||||
vibration[1] += (int)((ffb->axes[1].force * (__int64)ps2Vibration[p][s][ffb->motor]) / 255);
|
vibration[0] += (int)((ffb->axes[0].force * (__int64)ps2Vibration[p][s][ffb->motor]) / 255);
|
||||||
}
|
vibration[1] += (int)((ffb->axes[1].force * (__int64)ps2Vibration[p][s][ffb->motor]) / 255);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Make sure at least 2 writes are queued, to update both motors.
|
}
|
||||||
QueueWrite();
|
// Make sure at least 2 writes are queued, to update both motors.
|
||||||
QueueWrite();
|
QueueWrite();
|
||||||
}
|
QueueWrite();
|
||||||
|
}
|
||||||
|
|
||||||
void SetEffect(ForceFeedbackBinding *binding, unsigned char force) {
|
void SetEffect(ForceFeedbackBinding *binding, unsigned char force)
|
||||||
PadBindings pBackup = pads[0][0];
|
{
|
||||||
pads[0][0].ffBindings = binding;
|
PadBindings pBackup = pads[0][0];
|
||||||
pads[0][0].numFFBindings = 1;
|
pads[0][0].ffBindings = binding;
|
||||||
SetEffects(0, 0, binding->motor, 255);
|
pads[0][0].numFFBindings = 1;
|
||||||
pads[0][0] = pBackup;
|
SetEffects(0, 0, binding->motor, 255);
|
||||||
}
|
pads[0][0] = pBackup;
|
||||||
|
}
|
||||||
|
|
||||||
void Deactivate() {
|
void Deactivate()
|
||||||
if (hFile != INVALID_HANDLE_VALUE) {
|
{
|
||||||
CancelIo(hFile);
|
if (hFile != INVALID_HANDLE_VALUE) {
|
||||||
CloseHandle(hFile);
|
CancelIo(hFile);
|
||||||
hFile = INVALID_HANDLE_VALUE;
|
CloseHandle(hFile);
|
||||||
}
|
hFile = INVALID_HANDLE_VALUE;
|
||||||
if (readop.hEvent) {
|
}
|
||||||
CloseHandle(readop.hEvent);
|
if (readop.hEvent) {
|
||||||
}
|
CloseHandle(readop.hEvent);
|
||||||
if (writeop.hEvent) {
|
}
|
||||||
CloseHandle(writeop.hEvent);
|
if (writeop.hEvent) {
|
||||||
}
|
CloseHandle(writeop.hEvent);
|
||||||
writing = 0;
|
}
|
||||||
writeQueued = 0;
|
writing = 0;
|
||||||
memset(ps2Vibration, 0, sizeof(ps2Vibration));
|
writeQueued = 0;
|
||||||
vibration[0] = vibration[1] = 0;
|
memset(ps2Vibration, 0, sizeof(ps2Vibration));
|
||||||
|
vibration[0] = vibration[1] = 0;
|
||||||
|
|
||||||
FreeState();
|
FreeState();
|
||||||
active = 0;
|
active = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
~DualShock3Device() {
|
~DualShock3Device()
|
||||||
}
|
{
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void EnumDualShock3s() {
|
void EnumDualShock3s()
|
||||||
if (!InitLibUsb()) return;
|
{
|
||||||
|
if (!InitLibUsb())
|
||||||
|
return;
|
||||||
|
|
||||||
HidDeviceInfo *foundDevs = 0;
|
HidDeviceInfo *foundDevs = 0;
|
||||||
|
|
||||||
int numDevs = FindHids(&foundDevs, VID, PID);
|
int numDevs = FindHids(&foundDevs, VID, PID);
|
||||||
if (!numDevs) return;
|
if (!numDevs)
|
||||||
int index = 0;
|
return;
|
||||||
for (int i=0; i<numDevs; i++) {
|
int index = 0;
|
||||||
if (foundDevs[i].caps.FeatureReportByteLength == 49 &&
|
for (int i = 0; i < numDevs; i++) {
|
||||||
foundDevs[i].caps.InputReportByteLength == 49 &&
|
if (foundDevs[i].caps.FeatureReportByteLength == 49 &&
|
||||||
foundDevs[i].caps.OutputReportByteLength == 49) {
|
foundDevs[i].caps.InputReportByteLength == 49 &&
|
||||||
wchar_t temp[100];
|
foundDevs[i].caps.OutputReportByteLength == 49) {
|
||||||
wsprintfW(temp, L"DualShock 3 #%i", index+1);
|
wchar_t temp[100];
|
||||||
dm->AddDevice(new DualShock3Device(index, temp, foundDevs[i].path));
|
wsprintfW(temp, L"DualShock 3 #%i", index + 1);
|
||||||
index++;
|
dm->AddDevice(new DualShock3Device(index, temp, foundDevs[i].path));
|
||||||
}
|
index++;
|
||||||
free(foundDevs[i].path);
|
}
|
||||||
}
|
free(foundDevs[i].path);
|
||||||
free(foundDevs);
|
}
|
||||||
|
free(foundDevs);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,58 +23,62 @@
|
||||||
typedef uint32_t DWORD;
|
typedef uint32_t DWORD;
|
||||||
typedef uint16_t USHORT;
|
typedef uint16_t USHORT;
|
||||||
#ifndef __INTEL_COMPILER
|
#ifndef __INTEL_COMPILER
|
||||||
typedef int64_t __int64;
|
typedef int64_t __int64;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MAX_PATH (256) // random value
|
#define MAX_PATH (256) // random value
|
||||||
|
|
||||||
#include <X11/keysym.h>
|
#include <X11/keysym.h>
|
||||||
|
|
||||||
#define VK_SHIFT XK_Shift_L
|
#define VK_SHIFT XK_Shift_L
|
||||||
#define VK_LSHIFT XK_Shift_L
|
#define VK_LSHIFT XK_Shift_L
|
||||||
#define VK_RSHIFT XK_Shift_R
|
#define VK_RSHIFT XK_Shift_R
|
||||||
#define VK_LMENU XK_Menu
|
#define VK_LMENU XK_Menu
|
||||||
#define VK_RMENU XK_Menu
|
#define VK_RMENU XK_Menu
|
||||||
#define VK_MENU XK_Menu
|
#define VK_MENU XK_Menu
|
||||||
#define VK_CONTROL XK_Control_L
|
#define VK_CONTROL XK_Control_L
|
||||||
#define VK_TAB XK_Tab
|
#define VK_TAB XK_Tab
|
||||||
#define VK_ESCAPE XK_Escape
|
#define VK_ESCAPE XK_Escape
|
||||||
#define VK_F4 XK_F4
|
#define VK_F4 XK_F4
|
||||||
|
|
||||||
#include <cwchar>
|
#include <cwchar>
|
||||||
#include <cstdarg>
|
#include <cstdarg>
|
||||||
|
|
||||||
template <typename Array>
|
template <typename Array>
|
||||||
void wsprintfW(Array& buf, const wchar_t *format, ...) {
|
void wsprintfW(Array &buf, const wchar_t *format, ...)
|
||||||
va_list a;
|
{
|
||||||
va_start(a, format);
|
va_list a;
|
||||||
|
va_start(a, format);
|
||||||
|
|
||||||
vswprintf(buf, sizeof(buf)/sizeof(buf[0]), format, a);
|
vswprintf(buf, sizeof(buf) / sizeof(buf[0]), format, a);
|
||||||
|
|
||||||
va_end(a);
|
va_end(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Array>
|
template <typename Array>
|
||||||
void wsprintf(Array& buf, const wchar_t *format, ...) {
|
void wsprintf(Array &buf, const wchar_t *format, ...)
|
||||||
va_list a;
|
{
|
||||||
va_start(a, format);
|
va_list a;
|
||||||
|
va_start(a, format);
|
||||||
|
|
||||||
vswprintf(buf, sizeof(buf)/sizeof(buf[0]), format, a);
|
vswprintf(buf, sizeof(buf) / sizeof(buf[0]), format, a);
|
||||||
|
|
||||||
va_end(a);
|
va_end(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int wcsicmp(const wchar_t* w1, const wchar_t* w2) {
|
static inline int wcsicmp(const wchar_t *w1, const wchar_t *w2)
|
||||||
// I didn't find a way to put ignore case ...
|
{
|
||||||
return wcscmp(w1, w2);
|
// I didn't find a way to put ignore case ...
|
||||||
|
return wcscmp(w1, w2);
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
static inline unsigned int timeGetTime() {
|
static inline unsigned int timeGetTime()
|
||||||
struct timeval now;
|
{
|
||||||
gettimeofday(&now, NULL);
|
struct timeval now;
|
||||||
uint64_t ms = (now.tv_usec/1000) + ((uint64_t)now.tv_sec * 1000);
|
gettimeofday(&now, NULL);
|
||||||
return (ms & 0xFFFFFFFF); // MS code is u32 ...
|
uint64_t ms = (now.tv_usec / 1000) + ((uint64_t)now.tv_sec * 1000);
|
||||||
|
return (ms & 0xFFFFFFFF); // MS code is u32 ...
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "Utilities/Dependencies.h"
|
#include "Utilities/Dependencies.h"
|
||||||
|
@ -84,7 +88,7 @@ static inline unsigned int timeGetTime() {
|
||||||
#include <X11/Xutil.h>
|
#include <X11/Xutil.h>
|
||||||
|
|
||||||
extern Display *GSdsp;
|
extern Display *GSdsp;
|
||||||
extern Window GSwin;
|
extern Window GSwin;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -95,7 +99,7 @@ extern Window GSwin;
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#define EXPORT_C_(type) extern "C" type CALLBACK
|
#define EXPORT_C_(type) extern "C" type CALLBACK
|
||||||
#else
|
#else
|
||||||
#define EXPORT_C_(type) extern "C" __attribute__((stdcall,externally_visible,visibility("default"))) type CALLBACK
|
#define EXPORT_C_(type) extern "C" __attribute__((stdcall, externally_visible, visibility("default"))) type CALLBACK
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
|
@ -136,35 +140,60 @@ extern HINSTANCE hInst;
|
||||||
// Needed for config screen
|
// Needed for config screen
|
||||||
void GetNameAndVersionString(wchar_t *out);
|
void GetNameAndVersionString(wchar_t *out);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct
|
||||||
unsigned char controllerType;
|
{
|
||||||
unsigned short buttonStatus;
|
unsigned char controllerType;
|
||||||
unsigned char rightJoyX, rightJoyY, leftJoyX, leftJoyY;
|
unsigned short buttonStatus;
|
||||||
unsigned char moveX, moveY;
|
unsigned char rightJoyX, rightJoyY, leftJoyX, leftJoyY;
|
||||||
unsigned char reserved[91];
|
unsigned char moveX, moveY;
|
||||||
|
unsigned char reserved[91];
|
||||||
} PadDataS;
|
} PadDataS;
|
||||||
|
|
||||||
EXPORT_C_(void) PADupdate(int pad);
|
EXPORT_C_(void)
|
||||||
EXPORT_C_(u32) PS2EgetLibType(void);
|
PADupdate(int pad);
|
||||||
EXPORT_C_(u32) PS2EgetLibVersion2(u32 type);
|
EXPORT_C_(u32)
|
||||||
EXPORT_C_(char*) PSEgetLibName();
|
PS2EgetLibType(void);
|
||||||
EXPORT_C_(char*) PS2EgetLibName(void);
|
EXPORT_C_(u32)
|
||||||
EXPORT_C_(void) PADshutdown();
|
PS2EgetLibVersion2(u32 type);
|
||||||
EXPORT_C_(s32) PADinit(u32 flags);
|
EXPORT_C_(char *)
|
||||||
EXPORT_C_(s32) PADopen(void *pDsp);
|
PSEgetLibName();
|
||||||
EXPORT_C_(void) PADclose();
|
EXPORT_C_(char *)
|
||||||
EXPORT_C_(u8) PADstartPoll(int pad);
|
PS2EgetLibName(void);
|
||||||
EXPORT_C_(u8) PADpoll(u8 value);
|
EXPORT_C_(void)
|
||||||
EXPORT_C_(u32) PADquery();
|
PADshutdown();
|
||||||
EXPORT_C_(void) PADabout();
|
EXPORT_C_(s32)
|
||||||
EXPORT_C_(s32) PADtest();
|
PADinit(u32 flags);
|
||||||
EXPORT_C_(keyEvent*) PADkeyEvent();
|
EXPORT_C_(s32)
|
||||||
EXPORT_C_(u32) PADreadPort1 (PadDataS* pads);
|
PADopen(void *pDsp);
|
||||||
EXPORT_C_(u32) PADreadPort2 (PadDataS* pads);
|
EXPORT_C_(void)
|
||||||
EXPORT_C_(u32) PSEgetLibType();
|
PADclose();
|
||||||
EXPORT_C_(u32) PSEgetLibVersion();
|
EXPORT_C_(u8)
|
||||||
EXPORT_C_(void) PADconfigure();
|
PADstartPoll(int pad);
|
||||||
EXPORT_C_(s32) PADfreeze(int mode, freezeData *data);
|
EXPORT_C_(u8)
|
||||||
EXPORT_C_(s32) PADsetSlot(u8 port, u8 slot);
|
PADpoll(u8 value);
|
||||||
EXPORT_C_(s32) PADqueryMtap(u8 port);
|
EXPORT_C_(u32)
|
||||||
EXPORT_C_(void) PADsetSettingsDir(const char *dir);
|
PADquery();
|
||||||
|
EXPORT_C_(void)
|
||||||
|
PADabout();
|
||||||
|
EXPORT_C_(s32)
|
||||||
|
PADtest();
|
||||||
|
EXPORT_C_(keyEvent *)
|
||||||
|
PADkeyEvent();
|
||||||
|
EXPORT_C_(u32)
|
||||||
|
PADreadPort1(PadDataS *pads);
|
||||||
|
EXPORT_C_(u32)
|
||||||
|
PADreadPort2(PadDataS *pads);
|
||||||
|
EXPORT_C_(u32)
|
||||||
|
PSEgetLibType();
|
||||||
|
EXPORT_C_(u32)
|
||||||
|
PSEgetLibVersion();
|
||||||
|
EXPORT_C_(void)
|
||||||
|
PADconfigure();
|
||||||
|
EXPORT_C_(s32)
|
||||||
|
PADfreeze(int mode, freezeData *data);
|
||||||
|
EXPORT_C_(s32)
|
||||||
|
PADsetSlot(u8 port, u8 slot);
|
||||||
|
EXPORT_C_(s32)
|
||||||
|
PADqueryMtap(u8 port);
|
||||||
|
EXPORT_C_(void)
|
||||||
|
PADsetSettingsDir(const char *dir);
|
||||||
|
|
|
@ -20,57 +20,61 @@
|
||||||
#include <setupapi.h>
|
#include <setupapi.h>
|
||||||
#include <hidsdi.h>
|
#include <hidsdi.h>
|
||||||
|
|
||||||
int FindHids(HidDeviceInfo **foundDevs, int vid, int pid) {
|
int FindHids(HidDeviceInfo **foundDevs, int vid, int pid)
|
||||||
GUID GUID_DEVINTERFACE_HID;
|
{
|
||||||
int numFoundDevs = 0;
|
GUID GUID_DEVINTERFACE_HID;
|
||||||
*foundDevs = 0;
|
int numFoundDevs = 0;
|
||||||
HidD_GetHidGuid(&GUID_DEVINTERFACE_HID);
|
*foundDevs = 0;
|
||||||
HDEVINFO hdev = SetupDiGetClassDevs(&GUID_DEVINTERFACE_HID, 0, 0, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
|
HidD_GetHidGuid(&GUID_DEVINTERFACE_HID);
|
||||||
if (hdev != INVALID_HANDLE_VALUE) {
|
HDEVINFO hdev = SetupDiGetClassDevs(&GUID_DEVINTERFACE_HID, 0, 0, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
|
||||||
SP_DEVICE_INTERFACE_DATA devInterfaceData;
|
if (hdev != INVALID_HANDLE_VALUE) {
|
||||||
devInterfaceData.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
|
SP_DEVICE_INTERFACE_DATA devInterfaceData;
|
||||||
for (int i=0; SetupDiEnumDeviceInterfaces(hdev, 0, &GUID_DEVINTERFACE_HID, i, &devInterfaceData); i++) {
|
devInterfaceData.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
|
||||||
|
for (int i = 0; SetupDiEnumDeviceInterfaces(hdev, 0, &GUID_DEVINTERFACE_HID, i, &devInterfaceData); i++) {
|
||||||
|
|
||||||
DWORD size = 0;
|
DWORD size = 0;
|
||||||
SetupDiGetDeviceInterfaceDetail(hdev, &devInterfaceData, 0, 0, &size, 0);
|
SetupDiGetDeviceInterfaceDetail(hdev, &devInterfaceData, 0, 0, &size, 0);
|
||||||
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER || !size) continue;
|
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER || !size)
|
||||||
SP_DEVICE_INTERFACE_DETAIL_DATA *devInterfaceDetails = (SP_DEVICE_INTERFACE_DETAIL_DATA *) malloc(size);
|
continue;
|
||||||
if (!devInterfaceDetails) continue;
|
SP_DEVICE_INTERFACE_DETAIL_DATA *devInterfaceDetails = (SP_DEVICE_INTERFACE_DETAIL_DATA *)malloc(size);
|
||||||
|
if (!devInterfaceDetails)
|
||||||
|
continue;
|
||||||
|
|
||||||
devInterfaceDetails->cbSize = sizeof(*devInterfaceDetails);
|
devInterfaceDetails->cbSize = sizeof(*devInterfaceDetails);
|
||||||
SP_DEVINFO_DATA devInfoData;
|
SP_DEVINFO_DATA devInfoData;
|
||||||
devInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
|
devInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
|
||||||
|
|
||||||
if (!SetupDiGetDeviceInterfaceDetail(hdev, &devInterfaceData, devInterfaceDetails, size, &size, &devInfoData)) continue;
|
if (!SetupDiGetDeviceInterfaceDetail(hdev, &devInterfaceData, devInterfaceDetails, size, &size, &devInfoData))
|
||||||
|
continue;
|
||||||
|
|
||||||
HANDLE hfile = CreateFile(devInterfaceDetails->DevicePath, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0);
|
HANDLE hfile = CreateFile(devInterfaceDetails->DevicePath, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0);
|
||||||
if (hfile != INVALID_HANDLE_VALUE) {
|
if (hfile != INVALID_HANDLE_VALUE) {
|
||||||
HIDD_ATTRIBUTES attributes;
|
HIDD_ATTRIBUTES attributes;
|
||||||
attributes.Size = sizeof(attributes);
|
attributes.Size = sizeof(attributes);
|
||||||
if (HidD_GetAttributes(hfile, &attributes)) {
|
if (HidD_GetAttributes(hfile, &attributes)) {
|
||||||
if (attributes.VendorID == vid && attributes.ProductID == pid) {
|
if (attributes.VendorID == vid && attributes.ProductID == pid) {
|
||||||
PHIDP_PREPARSED_DATA pData;
|
PHIDP_PREPARSED_DATA pData;
|
||||||
HIDP_CAPS caps;
|
HIDP_CAPS caps;
|
||||||
if (HidD_GetPreparsedData(hfile, &pData)) {
|
if (HidD_GetPreparsedData(hfile, &pData)) {
|
||||||
if (HidP_GetCaps(pData, &caps) == HIDP_STATUS_SUCCESS) {
|
if (HidP_GetCaps(pData, &caps) == HIDP_STATUS_SUCCESS) {
|
||||||
if (numFoundDevs % 32 == 0) {
|
if (numFoundDevs % 32 == 0) {
|
||||||
*foundDevs = (HidDeviceInfo*) realloc(*foundDevs, sizeof(HidDeviceInfo) * (32 + numFoundDevs));
|
*foundDevs = (HidDeviceInfo *)realloc(*foundDevs, sizeof(HidDeviceInfo) * (32 + numFoundDevs));
|
||||||
}
|
}
|
||||||
HidDeviceInfo *dev = &foundDevs[0][numFoundDevs++];
|
HidDeviceInfo *dev = &foundDevs[0][numFoundDevs++];
|
||||||
dev->caps = caps;
|
dev->caps = caps;
|
||||||
dev->vid = attributes.VendorID;
|
dev->vid = attributes.VendorID;
|
||||||
dev->pid = attributes.ProductID;
|
dev->pid = attributes.ProductID;
|
||||||
dev->path = wcsdup(devInterfaceDetails->DevicePath);
|
dev->path = wcsdup(devInterfaceDetails->DevicePath);
|
||||||
}
|
}
|
||||||
HidD_FreePreparsedData(pData);
|
HidD_FreePreparsedData(pData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CloseHandle(hfile);
|
CloseHandle(hfile);
|
||||||
}
|
}
|
||||||
free(devInterfaceDetails);
|
free(devInterfaceDetails);
|
||||||
}
|
}
|
||||||
SetupDiDestroyDeviceInfoList(hdev);
|
SetupDiDestroyDeviceInfoList(hdev);
|
||||||
}
|
}
|
||||||
return numFoundDevs;
|
return numFoundDevs;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,11 +20,12 @@
|
||||||
|
|
||||||
#include <hidsdi.h>
|
#include <hidsdi.h>
|
||||||
|
|
||||||
struct HidDeviceInfo {
|
struct HidDeviceInfo
|
||||||
HIDP_CAPS caps;
|
{
|
||||||
wchar_t *path;
|
HIDP_CAPS caps;
|
||||||
unsigned short vid;
|
wchar_t *path;
|
||||||
unsigned short pid;
|
unsigned short vid;
|
||||||
|
unsigned short pid;
|
||||||
};
|
};
|
||||||
|
|
||||||
int FindHids(HidDeviceInfo **foundDevs, int vid, int pid);
|
int FindHids(HidDeviceInfo **foundDevs, int vid, int pid);
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -23,10 +23,10 @@
|
||||||
// Fully down means that value corresponds to a button being fully down (255).
|
// Fully down means that value corresponds to a button being fully down (255).
|
||||||
// a value of 128 or more corresponds to that button being pressed, for binary
|
// a value of 128 or more corresponds to that button being pressed, for binary
|
||||||
// values.
|
// values.
|
||||||
#define BASE_SENSITIVITY (1<<16)
|
#define BASE_SENSITIVITY (1 << 16)
|
||||||
#define FULLY_DOWN (1<<16)
|
#define FULLY_DOWN (1 << 16)
|
||||||
|
|
||||||
#define DEFAULT_DEADZONE (BASE_SENSITIVITY * 201/1000)
|
#define DEFAULT_DEADZONE (BASE_SENSITIVITY * 201 / 1000)
|
||||||
|
|
||||||
/* Idea is for this file and the associated cpp file to be Windows independent.
|
/* Idea is for this file and the associated cpp file to be Windows independent.
|
||||||
* Still more effort than it's worth to port to Linux, however.
|
* Still more effort than it's worth to port to Linux, however.
|
||||||
|
@ -36,28 +36,28 @@
|
||||||
// One physical axis maps to 3 virtual ones, and one physical POV control maps to
|
// One physical axis maps to 3 virtual ones, and one physical POV control maps to
|
||||||
// 4 virtual ones.
|
// 4 virtual ones.
|
||||||
enum ControlType {
|
enum ControlType {
|
||||||
NO_CONTROL = 0,
|
NO_CONTROL = 0,
|
||||||
// Axes are ints. Relative axes are for mice, mice wheels, etc,
|
// Axes are ints. Relative axes are for mice, mice wheels, etc,
|
||||||
// and are always reported relative to their last value.
|
// and are always reported relative to their last value.
|
||||||
// Absolute axes range from -65536 to 65536 and are absolute positions,
|
// Absolute axes range from -65536 to 65536 and are absolute positions,
|
||||||
// like for joysticks and pressure sensitive buttons.
|
// like for joysticks and pressure sensitive buttons.
|
||||||
RELAXIS = 1,
|
RELAXIS = 1,
|
||||||
ABSAXIS = 2,
|
ABSAXIS = 2,
|
||||||
|
|
||||||
// Buttons range from 0 to 65536.
|
// Buttons range from 0 to 65536.
|
||||||
PSHBTN = 4,
|
PSHBTN = 4,
|
||||||
TGLBTN = 8,
|
TGLBTN = 8,
|
||||||
|
|
||||||
// POV controls are ints, values range from -1 to 36000.
|
// POV controls are ints, values range from -1 to 36000.
|
||||||
// -1 means not pressed, otherwise it's an angle.
|
// -1 means not pressed, otherwise it's an angle.
|
||||||
// For easy DirectInput compatibility, anything outside.
|
// For easy DirectInput compatibility, anything outside.
|
||||||
// that range is treated as -1 (Though 36000-37000 is treated
|
// that range is treated as -1 (Though 36000-37000 is treated
|
||||||
// like 0 to 1000, just in case).
|
// like 0 to 1000, just in case).
|
||||||
POV = 16,
|
POV = 16,
|
||||||
|
|
||||||
// Pressure sensitive buttons. Only a different type because
|
// Pressure sensitive buttons. Only a different type because
|
||||||
// they have configurable dead zones, unlike push or toggle buttons.
|
// they have configurable dead zones, unlike push or toggle buttons.
|
||||||
PRESSURE_BTN = 32,
|
PRESSURE_BTN = 32,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Masks to determine button type. Don't need one for POV.
|
// Masks to determine button type. Don't need one for POV.
|
||||||
|
@ -65,37 +65,39 @@ enum ControlType {
|
||||||
#define BINARY_BUTTON (PSHBTN | TGLBTN)
|
#define BINARY_BUTTON (PSHBTN | TGLBTN)
|
||||||
#define AXIS 3
|
#define AXIS 3
|
||||||
|
|
||||||
struct Binding {
|
struct Binding
|
||||||
int controlIndex;
|
{
|
||||||
int command;
|
int controlIndex;
|
||||||
int sensitivity;
|
int command;
|
||||||
int deadZone;
|
int sensitivity;
|
||||||
unsigned char turbo;
|
int deadZone;
|
||||||
|
unsigned char turbo;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define UID_AXIS (1U<<31)
|
#define UID_AXIS (1U << 31)
|
||||||
#define UID_POV (1<<30)
|
#define UID_POV (1 << 30)
|
||||||
|
|
||||||
#define UID_AXIS_POS (1U<<24)
|
#define UID_AXIS_POS (1U << 24)
|
||||||
#define UID_AXIS_NEG (2U<<24)
|
#define UID_AXIS_NEG (2U << 24)
|
||||||
#define UID_POV_N (3<<24)
|
#define UID_POV_N (3 << 24)
|
||||||
#define UID_POV_E (4<<24)
|
#define UID_POV_E (4 << 24)
|
||||||
#define UID_POV_S (5<<24)
|
#define UID_POV_S (5 << 24)
|
||||||
#define UID_POV_W (6<<24)
|
#define UID_POV_W (6 << 24)
|
||||||
|
|
||||||
// One of these exists for each bindable object.
|
// One of these exists for each bindable object.
|
||||||
// Bindable objects consist of buttons, axis, pov controls,
|
// Bindable objects consist of buttons, axis, pov controls,
|
||||||
// and individual axis/pov directions. Not that pov controls
|
// and individual axis/pov directions. Not that pov controls
|
||||||
// cannot actually be bound, but when trying to bind as an axis,
|
// cannot actually be bound, but when trying to bind as an axis,
|
||||||
// all directions are assigned individually.
|
// all directions are assigned individually.
|
||||||
struct VirtualControl {
|
struct VirtualControl
|
||||||
// Unique id for control, given device. Based on source control's id,
|
{
|
||||||
// source control type, axis/pov flags if it's a pov/axis (Rather than
|
// Unique id for control, given device. Based on source control's id,
|
||||||
// a button or a pov/axis control's individual button), and an index,
|
// source control type, axis/pov flags if it's a pov/axis (Rather than
|
||||||
// if the control is split.
|
// a button or a pov/axis control's individual button), and an index,
|
||||||
unsigned int uid;
|
// if the control is split.
|
||||||
// virtual key code. 0 if none.
|
unsigned int uid;
|
||||||
int physicalControlIndex;
|
// virtual key code. 0 if none.
|
||||||
|
int physicalControlIndex;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Need one for each button, axis, and pov control.
|
// Need one for each button, axis, and pov control.
|
||||||
|
@ -103,79 +105,84 @@ struct VirtualControl {
|
||||||
// updates their state, standard function then populates
|
// updates their state, standard function then populates
|
||||||
// the VirtualControls and queues the keyboard messages, if
|
// the VirtualControls and queues the keyboard messages, if
|
||||||
// needed.
|
// needed.
|
||||||
struct PhysicalControl {
|
struct PhysicalControl
|
||||||
// index of the first virtual control corresponding to this.
|
{
|
||||||
// Buttons have 1 virtual control, axes 3, and povs 5, all
|
// index of the first virtual control corresponding to this.
|
||||||
// in a row.
|
// Buttons have 1 virtual control, axes 3, and povs 5, all
|
||||||
int baseVirtualControlIndex;
|
// in a row.
|
||||||
ControlType type;
|
int baseVirtualControlIndex;
|
||||||
// id. Must be unique for control type.
|
ControlType type;
|
||||||
// short so can be combined with other values to get
|
// id. Must be unique for control type.
|
||||||
// uid for virtual controls.
|
// short so can be combined with other values to get
|
||||||
unsigned short id;
|
// uid for virtual controls.
|
||||||
unsigned short vkey;
|
unsigned short id;
|
||||||
wchar_t *name;
|
unsigned short vkey;
|
||||||
|
wchar_t *name;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum DeviceAPI {
|
enum DeviceAPI {
|
||||||
NO_API = 0,
|
NO_API = 0,
|
||||||
DI = 1,
|
DI = 1,
|
||||||
WM = 2,
|
WM = 2,
|
||||||
RAW = 3,
|
RAW = 3,
|
||||||
XINPUT = 4,
|
XINPUT = 4,
|
||||||
DS3 = 5,
|
DS3 = 5,
|
||||||
// Not currently used.
|
// Not currently used.
|
||||||
LLHOOK = 6,
|
LLHOOK = 6,
|
||||||
// Not a real API, obviously. Only used with keyboards,
|
// Not a real API, obviously. Only used with keyboards,
|
||||||
// to ignore individual buttons. Wrapper itself takes care
|
// to ignore individual buttons. Wrapper itself takes care
|
||||||
// of ignoring bound keys. Otherwise, works normally.
|
// of ignoring bound keys. Otherwise, works normally.
|
||||||
IGNORE_KEYBOARD = 7,
|
IGNORE_KEYBOARD = 7,
|
||||||
// XXX
|
// XXX
|
||||||
LNX_KEYBOARD = 16,
|
LNX_KEYBOARD = 16,
|
||||||
LNX_JOY = 17,
|
LNX_JOY = 17,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum DeviceType {
|
enum DeviceType {
|
||||||
NO_DEVICE = 0,
|
NO_DEVICE = 0,
|
||||||
KEYBOARD = 1,
|
KEYBOARD = 1,
|
||||||
MOUSE = 2,
|
MOUSE = 2,
|
||||||
OTHER = 3
|
OTHER = 3
|
||||||
};
|
};
|
||||||
|
|
||||||
enum EffectType {
|
enum EffectType {
|
||||||
EFFECT_CONSTANT,
|
EFFECT_CONSTANT,
|
||||||
EFFECT_PERIODIC,
|
EFFECT_PERIODIC,
|
||||||
EFFECT_RAMP
|
EFFECT_RAMP
|
||||||
};
|
};
|
||||||
|
|
||||||
// force range sfrom -BASE_SENSITIVITY to BASE_SENSITIVITY.
|
// force range sfrom -BASE_SENSITIVITY to BASE_SENSITIVITY.
|
||||||
// Order matches ForceFeedbackAxis order. force of 0 means to
|
// Order matches ForceFeedbackAxis order. force of 0 means to
|
||||||
// ignore that axis completely. Force of 1 or -1 means to initialize
|
// ignore that axis completely. Force of 1 or -1 means to initialize
|
||||||
// the axis with minimum force (Possibly 0 force), if applicable.
|
// the axis with minimum force (Possibly 0 force), if applicable.
|
||||||
struct AxisEffectInfo {
|
struct AxisEffectInfo
|
||||||
int force;
|
{
|
||||||
|
int force;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ForceFeedbackBinding {
|
struct ForceFeedbackBinding
|
||||||
AxisEffectInfo *axes;
|
{
|
||||||
int effectIndex;
|
AxisEffectInfo *axes;
|
||||||
unsigned char motor;
|
int effectIndex;
|
||||||
|
unsigned char motor;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Bindings listed by effect, so I don't have to bother with
|
// Bindings listed by effect, so I don't have to bother with
|
||||||
// indexing effects.
|
// indexing effects.
|
||||||
struct ForceFeedbackEffectType {
|
struct ForceFeedbackEffectType
|
||||||
wchar_t *displayName;
|
{
|
||||||
// Because I'm lazy, can only have ASCII characters and no spaces.
|
wchar_t *displayName;
|
||||||
wchar_t *effectID;
|
// Because I'm lazy, can only have ASCII characters and no spaces.
|
||||||
// constant, ramp, or periodic
|
wchar_t *effectID;
|
||||||
EffectType type;
|
// constant, ramp, or periodic
|
||||||
|
EffectType type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct ForceFeedbackAxis {
|
struct ForceFeedbackAxis
|
||||||
wchar_t *displayName;
|
{
|
||||||
int id;
|
wchar_t *displayName;
|
||||||
|
int id;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Used both for active devices and for sets of settings for devices.
|
// Used both for active devices and for sets of settings for devices.
|
||||||
|
@ -184,190 +191,200 @@ struct ForceFeedbackAxis {
|
||||||
// one set of generic devices. Then I enumerate all devices. Then I merge
|
// one set of generic devices. Then I enumerate all devices. Then I merge
|
||||||
// them, moving settings from the generic devices to the enumerated ones.
|
// them, moving settings from the generic devices to the enumerated ones.
|
||||||
|
|
||||||
struct PadBindings {
|
struct PadBindings
|
||||||
Binding *bindings;
|
{
|
||||||
int numBindings;
|
Binding *bindings;
|
||||||
ForceFeedbackBinding *ffBindings;
|
int numBindings;
|
||||||
int numFFBindings;
|
ForceFeedbackBinding *ffBindings;
|
||||||
|
int numFFBindings;
|
||||||
};
|
};
|
||||||
|
|
||||||
class WndProcEater;
|
class WndProcEater;
|
||||||
|
|
||||||
struct InitInfo {
|
struct InitInfo
|
||||||
// 1 when binding key to ignore.
|
{
|
||||||
int bindingIgnore;
|
// 1 when binding key to ignore.
|
||||||
// 1 when binding.
|
int bindingIgnore;
|
||||||
int binding;
|
// 1 when binding.
|
||||||
|
int binding;
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
HWND hWndTop;
|
HWND hWndTop;
|
||||||
|
|
||||||
// For config screen, need to eat button's message handling.
|
// For config screen, need to eat button's message handling.
|
||||||
//HWND hWndButton;
|
//HWND hWndButton;
|
||||||
|
|
||||||
WndProcEater* hWndProc;
|
WndProcEater *hWndProc;
|
||||||
#else
|
#else
|
||||||
// Linux equivalent to HWND
|
// Linux equivalent to HWND
|
||||||
Display *GSdsp;
|
Display *GSdsp;
|
||||||
Window GSwin;
|
Window GSwin;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Mostly self-contained, but bindings are modified by config.cpp, to make
|
// Mostly self-contained, but bindings are modified by config.cpp, to make
|
||||||
// updating the ListView simpler.
|
// updating the ListView simpler.
|
||||||
class Device {
|
class Device
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
DeviceAPI api;
|
DeviceAPI api;
|
||||||
DeviceType type;
|
DeviceType type;
|
||||||
char active;
|
char active;
|
||||||
char attached;
|
char attached;
|
||||||
// Based on input modes.
|
// Based on input modes.
|
||||||
char enabled;
|
char enabled;
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
// Not all devices need to subclass the windproc, but most do so might as well
|
// Not all devices need to subclass the windproc, but most do so might as well
|
||||||
// put it here... --air
|
// put it here... --air
|
||||||
WndProcEater* hWndProc;
|
WndProcEater *hWndProc;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
union {
|
union
|
||||||
// Allows for one loop to compare all 3 in order.
|
{
|
||||||
wchar_t *IDs[3];
|
// Allows for one loop to compare all 3 in order.
|
||||||
struct {
|
wchar_t *IDs[3];
|
||||||
// Same as DisplayName, when not given. Absolutely must be unique.
|
struct
|
||||||
// Used for loading/saving controls. If matches, all other strings
|
{
|
||||||
// are ignored, so must be unique.
|
// Same as DisplayName, when not given. Absolutely must be unique.
|
||||||
wchar_t *instanceID;
|
// Used for loading/saving controls. If matches, all other strings
|
||||||
// Not required. Used when a device's instance id changes, doesn't have to
|
// are ignored, so must be unique.
|
||||||
// be unique. For devices that can only have one instance, not needed.
|
wchar_t *instanceID;
|
||||||
wchar_t *productID;
|
// Not required. Used when a device's instance id changes, doesn't have to
|
||||||
|
// be unique. For devices that can only have one instance, not needed.
|
||||||
|
wchar_t *productID;
|
||||||
|
|
||||||
wchar_t *displayName;
|
wchar_t *displayName;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
PadBindings pads[2][4];
|
PadBindings pads[2][4];
|
||||||
|
|
||||||
// Virtual controls. All basically act like pressure sensitivity buttons, with
|
// Virtual controls. All basically act like pressure sensitivity buttons, with
|
||||||
// values between 0 and 2^16. 2^16 is fully down, 0 is up. Larger values
|
// values between 0 and 2^16. 2^16 is fully down, 0 is up. Larger values
|
||||||
// are allowed, but *only* for absolute axes (Which don't support the flip checkbox).
|
// are allowed, but *only* for absolute axes (Which don't support the flip checkbox).
|
||||||
// Each control on a device must have a unique id, used for binding.
|
// Each control on a device must have a unique id, used for binding.
|
||||||
VirtualControl *virtualControls;
|
VirtualControl *virtualControls;
|
||||||
int numVirtualControls;
|
int numVirtualControls;
|
||||||
|
|
||||||
int *virtualControlState;
|
int *virtualControlState;
|
||||||
int *oldVirtualControlState;
|
int *oldVirtualControlState;
|
||||||
|
|
||||||
PhysicalControl *physicalControls;
|
PhysicalControl *physicalControls;
|
||||||
int numPhysicalControls;
|
int numPhysicalControls;
|
||||||
int *physicalControlState;
|
int *physicalControlState;
|
||||||
|
|
||||||
ForceFeedbackEffectType *ffEffectTypes;
|
ForceFeedbackEffectType *ffEffectTypes;
|
||||||
int numFFEffectTypes;
|
int numFFEffectTypes;
|
||||||
ForceFeedbackAxis *ffAxes;
|
ForceFeedbackAxis *ffAxes;
|
||||||
int numFFAxes;
|
int numFFAxes;
|
||||||
void AddFFAxis(const wchar_t *displayName, int id);
|
void AddFFAxis(const wchar_t *displayName, int id);
|
||||||
void AddFFEffectType(const wchar_t *displayName, const wchar_t *effectID, EffectType type);
|
void AddFFEffectType(const wchar_t *displayName, const wchar_t *effectID, EffectType type);
|
||||||
|
|
||||||
Device(DeviceAPI, DeviceType, const wchar_t *displayName, const wchar_t *instanceID = 0, const wchar_t *deviceID = 0);
|
Device(DeviceAPI, DeviceType, const wchar_t *displayName, const wchar_t *instanceID = 0, const wchar_t *deviceID = 0);
|
||||||
virtual ~Device();
|
virtual ~Device();
|
||||||
|
|
||||||
// Allocates memory for old and new state, sets everything to 0.
|
// Allocates memory for old and new state, sets everything to 0.
|
||||||
// all old states are in one array, buttons, axes, and then POVs.
|
// all old states are in one array, buttons, axes, and then POVs.
|
||||||
// start of each section is int aligned. This makes it DirectInput
|
// start of each section is int aligned. This makes it DirectInput
|
||||||
// compatible.
|
// compatible.
|
||||||
void AllocState();
|
void AllocState();
|
||||||
|
|
||||||
// Doesn't actually flip. Copies current state to old state.
|
// Doesn't actually flip. Copies current state to old state.
|
||||||
void FlipState();
|
void FlipState();
|
||||||
|
|
||||||
// Frees state variables.
|
// Frees state variables.
|
||||||
void FreeState();
|
void FreeState();
|
||||||
|
|
||||||
ForceFeedbackEffectType *GetForcefeedbackEffect(wchar_t *id);
|
ForceFeedbackEffectType *GetForcefeedbackEffect(wchar_t *id);
|
||||||
ForceFeedbackAxis *GetForceFeedbackAxis(int id);
|
ForceFeedbackAxis *GetForceFeedbackAxis(int id);
|
||||||
|
|
||||||
VirtualControl *GetVirtualControl(unsigned int uid);
|
VirtualControl *GetVirtualControl(unsigned int uid);
|
||||||
|
|
||||||
PhysicalControl *AddPhysicalControl(ControlType type, unsigned short id, unsigned short vkey, const wchar_t *name = 0);
|
PhysicalControl *AddPhysicalControl(ControlType type, unsigned short id, unsigned short vkey, const wchar_t *name = 0);
|
||||||
VirtualControl *AddVirtualControl(unsigned int uid, int physicalControlIndex);
|
VirtualControl *AddVirtualControl(unsigned int uid, int physicalControlIndex);
|
||||||
|
|
||||||
virtual wchar_t *GetVirtualControlName(VirtualControl *c);
|
virtual wchar_t *GetVirtualControlName(VirtualControl *c);
|
||||||
virtual wchar_t *GetPhysicalControlName(PhysicalControl *c);
|
virtual wchar_t *GetPhysicalControlName(PhysicalControl *c);
|
||||||
|
|
||||||
void CalcVirtualState();
|
void CalcVirtualState();
|
||||||
|
|
||||||
virtual int Activate(InitInfo *args) {
|
virtual int Activate(InitInfo *args)
|
||||||
return 0;
|
{
|
||||||
}
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
inline virtual void Deactivate() {
|
inline virtual void Deactivate()
|
||||||
FreeState();
|
{
|
||||||
active = 0;
|
FreeState();
|
||||||
}
|
active = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// Default update proc. All that's needed for post-based APIs.
|
// Default update proc. All that's needed for post-based APIs.
|
||||||
inline virtual int Update() {
|
inline virtual int Update()
|
||||||
return active;
|
{
|
||||||
}
|
return active;
|
||||||
|
}
|
||||||
|
|
||||||
// force is from -FULLY_DOWN to FULLY_DOWN.
|
// force is from -FULLY_DOWN to FULLY_DOWN.
|
||||||
// Either function can be overridden. Second one by default calls the first
|
// Either function can be overridden. Second one by default calls the first
|
||||||
// for every bound effect that's affected.
|
// for every bound effect that's affected.
|
||||||
|
|
||||||
// Note: Only used externally for binding, so if override the other one, can assume
|
// Note: Only used externally for binding, so if override the other one, can assume
|
||||||
// all other forces are currently 0.
|
// all other forces are currently 0.
|
||||||
inline virtual void SetEffect(ForceFeedbackBinding *binding, unsigned char force) {}
|
inline virtual void SetEffect(ForceFeedbackBinding *binding, unsigned char force) {}
|
||||||
virtual void SetEffects(unsigned char port, unsigned int slot, unsigned char motor, unsigned char force);
|
virtual void SetEffects(unsigned char port, unsigned int slot, unsigned char motor, unsigned char force);
|
||||||
|
|
||||||
// Called after reading. Basically calls FlipState().
|
// Called after reading. Basically calls FlipState().
|
||||||
// Some device types (Those that don't incrementally update)
|
// Some device types (Those that don't incrementally update)
|
||||||
// could call FlipState elsewhere, but this makes it simpler to ignore
|
// could call FlipState elsewhere, but this makes it simpler to ignore
|
||||||
// while binding.
|
// while binding.
|
||||||
virtual void PostRead();
|
virtual void PostRead();
|
||||||
};
|
};
|
||||||
|
|
||||||
class InputDeviceManager {
|
class InputDeviceManager
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
Device **devices;
|
Device **devices;
|
||||||
int numDevices;
|
int numDevices;
|
||||||
|
|
||||||
void ClearDevices();
|
void ClearDevices();
|
||||||
|
|
||||||
// When refreshing devices, back up old devices, then
|
// When refreshing devices, back up old devices, then
|
||||||
// populate this with new devices, then call copy bindings.
|
// populate this with new devices, then call copy bindings.
|
||||||
// All old bindings are copied to matching devices.
|
// All old bindings are copied to matching devices.
|
||||||
|
|
||||||
// When old devices are missing, I do a slightly more careful search
|
// When old devices are missing, I do a slightly more careful search
|
||||||
// using productIDs and then (in desperation) displayName.
|
// using productIDs and then (in desperation) displayName.
|
||||||
// Finally create new dummy devices if no matches found.
|
// Finally create new dummy devices if no matches found.
|
||||||
void CopyBindings(int numDevices, Device **devices);
|
void CopyBindings(int numDevices, Device **devices);
|
||||||
|
|
||||||
|
|
||||||
InputDeviceManager();
|
InputDeviceManager();
|
||||||
~InputDeviceManager();
|
~InputDeviceManager();
|
||||||
|
|
||||||
void AddDevice(Device *d);
|
void AddDevice(Device *d);
|
||||||
Device *GetActiveDevice(InitInfo *info, unsigned int *uid, int *index, int *value);
|
Device *GetActiveDevice(InitInfo *info, unsigned int *uid, int *index, int *value);
|
||||||
void Update(InitInfo *initInfo);
|
void Update(InitInfo *initInfo);
|
||||||
|
|
||||||
// Called after reading state, after Update().
|
// Called after reading state, after Update().
|
||||||
void PostRead();
|
void PostRead();
|
||||||
|
|
||||||
void SetEffect(unsigned char port, unsigned int slot, unsigned char motor, unsigned char force);
|
void SetEffect(unsigned char port, unsigned int slot, unsigned char motor, unsigned char force);
|
||||||
|
|
||||||
// Update does this as needed.
|
// Update does this as needed.
|
||||||
// void GetInput(void *v);
|
// void GetInput(void *v);
|
||||||
void ReleaseInput();
|
void ReleaseInput();
|
||||||
|
|
||||||
void DisableDevice(int index);
|
void DisableDevice(int index);
|
||||||
inline void EnableDevice(int i) {
|
inline void EnableDevice(int i)
|
||||||
devices[i]->enabled = 1;
|
{
|
||||||
}
|
devices[i]->enabled = 1;
|
||||||
|
}
|
||||||
|
|
||||||
void EnableDevices(DeviceType type, DeviceAPI api);
|
void EnableDevices(DeviceType type, DeviceAPI api);
|
||||||
void DisableAllDevices();
|
void DisableAllDevices();
|
||||||
};
|
};
|
||||||
|
|
||||||
extern InputDeviceManager *dm;
|
extern InputDeviceManager *dm;
|
||||||
|
|
|
@ -34,64 +34,68 @@ static u8 lastQueuedEvent = 0;
|
||||||
static u8 nextQueuedEvent = 0;
|
static u8 nextQueuedEvent = 0;
|
||||||
static keyEvent queuedEvents[EVENT_QUEUE_LEN];
|
static keyEvent queuedEvents[EVENT_QUEUE_LEN];
|
||||||
|
|
||||||
void QueueKeyEvent(int key, int event) {
|
void QueueKeyEvent(int key, int event)
|
||||||
|
{
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
if (!csInitialized) {
|
if (!csInitialized) {
|
||||||
csInitialized = 1;
|
csInitialized = 1;
|
||||||
InitializeCriticalSection(&cSection);
|
InitializeCriticalSection(&cSection);
|
||||||
}
|
}
|
||||||
EnterCriticalSection(&cSection);
|
EnterCriticalSection(&cSection);
|
||||||
#else
|
#else
|
||||||
std::lock_guard<std::mutex> lock(cSection);
|
std::lock_guard<std::mutex> lock(cSection);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Don't queue events if escape is on top of queue. This is just for safety
|
// Don't queue events if escape is on top of queue. This is just for safety
|
||||||
// purposes when a game is killing the emulator for whatever reason.
|
// purposes when a game is killing the emulator for whatever reason.
|
||||||
if (nextQueuedEvent == lastQueuedEvent ||
|
if (nextQueuedEvent == lastQueuedEvent ||
|
||||||
queuedEvents[nextQueuedEvent].key != VK_ESCAPE ||
|
queuedEvents[nextQueuedEvent].key != VK_ESCAPE ||
|
||||||
queuedEvents[nextQueuedEvent].evt != KEYPRESS) {
|
queuedEvents[nextQueuedEvent].evt != KEYPRESS) {
|
||||||
// Clear queue on escape down, bringing escape to front. May do something
|
// Clear queue on escape down, bringing escape to front. May do something
|
||||||
// with shift/ctrl/alt and F-keys, later.
|
// with shift/ctrl/alt and F-keys, later.
|
||||||
if (event == KEYPRESS && key == VK_ESCAPE) {
|
if (event == KEYPRESS && key == VK_ESCAPE) {
|
||||||
nextQueuedEvent = lastQueuedEvent;
|
nextQueuedEvent = lastQueuedEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
queuedEvents[lastQueuedEvent].key = key;
|
queuedEvents[lastQueuedEvent].key = key;
|
||||||
queuedEvents[lastQueuedEvent].evt = event;
|
queuedEvents[lastQueuedEvent].evt = event;
|
||||||
|
|
||||||
lastQueuedEvent = (lastQueuedEvent + 1) % EVENT_QUEUE_LEN;
|
lastQueuedEvent = (lastQueuedEvent + 1) % EVENT_QUEUE_LEN;
|
||||||
// If queue wrapped around, remove last element.
|
// If queue wrapped around, remove last element.
|
||||||
if (nextQueuedEvent == lastQueuedEvent) {
|
if (nextQueuedEvent == lastQueuedEvent) {
|
||||||
nextQueuedEvent = (nextQueuedEvent + 1) % EVENT_QUEUE_LEN;
|
nextQueuedEvent = (nextQueuedEvent + 1) % EVENT_QUEUE_LEN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
LeaveCriticalSection(&cSection);
|
LeaveCriticalSection(&cSection);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetQueuedKeyEvent(keyEvent *event) {
|
int GetQueuedKeyEvent(keyEvent *event)
|
||||||
if (lastQueuedEvent == nextQueuedEvent) return 0;
|
{
|
||||||
|
if (lastQueuedEvent == nextQueuedEvent)
|
||||||
|
return 0;
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
EnterCriticalSection(&cSection);
|
EnterCriticalSection(&cSection);
|
||||||
#else
|
#else
|
||||||
std::lock_guard<std::mutex> lock(cSection);
|
std::lock_guard<std::mutex> lock(cSection);
|
||||||
#endif
|
#endif
|
||||||
*event = queuedEvents[nextQueuedEvent];
|
*event = queuedEvents[nextQueuedEvent];
|
||||||
nextQueuedEvent = (nextQueuedEvent + 1) % EVENT_QUEUE_LEN;
|
nextQueuedEvent = (nextQueuedEvent + 1) % EVENT_QUEUE_LEN;
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
LeaveCriticalSection(&cSection);
|
LeaveCriticalSection(&cSection);
|
||||||
#endif
|
#endif
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClearKeyQueue() {
|
void ClearKeyQueue()
|
||||||
lastQueuedEvent = nextQueuedEvent;
|
{
|
||||||
|
lastQueuedEvent = nextQueuedEvent;
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
if (csInitialized) {
|
if (csInitialized) {
|
||||||
DeleteCriticalSection(&cSection);
|
DeleteCriticalSection(&cSection);
|
||||||
csInitialized = 0;
|
csInitialized = 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ int GetQueuedKeyEvent(keyEvent *event);
|
||||||
void ClearKeyQueue();
|
void ClearKeyQueue();
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
void R_QueueKeyEvent(const keyEvent& event);
|
void R_QueueKeyEvent(const keyEvent &event);
|
||||||
int R_GetQueuedKeyEvent(keyEvent *event);
|
int R_GetQueuedKeyEvent(keyEvent *event);
|
||||||
void R_ClearKeyQueue();
|
void R_ClearKeyQueue();
|
||||||
#endif
|
#endif
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -28,393 +28,411 @@ u8 ps2e = 0;
|
||||||
#if 0
|
#if 0
|
||||||
remove 0x10F0 to compute the cmd value
|
remove 0x10F0 to compute the cmd value
|
||||||
|
|
||||||
#define ID_SENSITIVITY 0x1007
|
#define ID_SENSITIVITY 0x1007
|
||||||
#define ID_LOCK_BUTTONS 0x10FC
|
#define ID_LOCK_BUTTONS 0x10FC
|
||||||
#define ID_LOCK 0x10FD
|
#define ID_LOCK 0x10FD
|
||||||
#define ID_LOCK_DIRECTION 0x10FE
|
#define ID_LOCK_DIRECTION 0x10FE
|
||||||
#define ID_MOUSE 0x10FF
|
#define ID_MOUSE 0x10FF
|
||||||
#define ID_SELECT 0x1100
|
#define ID_SELECT 0x1100
|
||||||
#define ID_L3 0x1101
|
#define ID_L3 0x1101
|
||||||
#define ID_R3 0x1102
|
#define ID_R3 0x1102
|
||||||
#define ID_START 0x1103
|
#define ID_START 0x1103
|
||||||
#define ID_DPAD_UP 0x1104
|
#define ID_DPAD_UP 0x1104
|
||||||
#define ID_DPAD_RIGHT 0x1105
|
#define ID_DPAD_RIGHT 0x1105
|
||||||
#define ID_DPAD_DOWN 0x1106
|
#define ID_DPAD_DOWN 0x1106
|
||||||
#define ID_DPAD_LEFT 0x1107
|
#define ID_DPAD_LEFT 0x1107
|
||||||
#define ID_L2 0x1108
|
#define ID_L2 0x1108
|
||||||
#define ID_R2 0x1109
|
#define ID_R2 0x1109
|
||||||
#define ID_L1 0x110A
|
#define ID_L1 0x110A
|
||||||
#define ID_R1 0x110B
|
#define ID_R1 0x110B
|
||||||
#define ID_TRIANGLE 0x110C
|
#define ID_TRIANGLE 0x110C
|
||||||
#define ID_CIRCLE 0x110D
|
#define ID_CIRCLE 0x110D
|
||||||
#define ID_CROSS 0x110E
|
#define ID_CROSS 0x110E
|
||||||
#define ID_SQUARE 0x110F
|
#define ID_SQUARE 0x110F
|
||||||
#define ID_LSTICK_UP 0x1110
|
#define ID_LSTICK_UP 0x1110
|
||||||
#define ID_LSTICK_RIGHT 0x1111
|
#define ID_LSTICK_RIGHT 0x1111
|
||||||
#define ID_LSTICK_DOWN 0x1112
|
#define ID_LSTICK_DOWN 0x1112
|
||||||
#define ID_LSTICK_LEFT 0x1113
|
#define ID_LSTICK_LEFT 0x1113
|
||||||
#define ID_RSTICK_UP 0x1114
|
#define ID_RSTICK_UP 0x1114
|
||||||
#define ID_RSTICK_RIGHT 0x1115
|
#define ID_RSTICK_RIGHT 0x1115
|
||||||
#define ID_RSTICK_DOWN 0x1116
|
#define ID_RSTICK_DOWN 0x1116
|
||||||
#define ID_RSTICK_LEFT 0x1117
|
#define ID_RSTICK_LEFT 0x1117
|
||||||
#define ID_ANALOG 0x1118
|
#define ID_ANALOG 0x1118
|
||||||
#define ID_DELETE 0x11FF
|
#define ID_DELETE 0x11FF
|
||||||
#define ID_DEBUG 0x1200
|
#define ID_DEBUG 0x1200
|
||||||
#define ID_IGNORE 0x1201
|
#define ID_IGNORE 0x1201
|
||||||
#define ID_CLEAR 0x1202
|
#define ID_CLEAR 0x1202
|
||||||
#define ID_REFRESH 0x1202
|
#define ID_REFRESH 0x1202
|
||||||
#define ID_SAVE 0x1204
|
#define ID_SAVE 0x1204
|
||||||
#define ID_LOAD 0x1205
|
#define ID_LOAD 0x1205
|
||||||
#define ID_BIG_MOTOR 0x120A
|
#define ID_BIG_MOTOR 0x120A
|
||||||
#define ID_SMALL_MOTOR 0x120B
|
#define ID_SMALL_MOTOR 0x120B
|
||||||
#define ID_TEST 0x1300
|
#define ID_TEST 0x1300
|
||||||
#define ID_CONTROLS 0x1301
|
#define ID_CONTROLS 0x1301
|
||||||
#define ID_FF 0x1304
|
#define ID_FF 0x1304
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct GeneralSettingsBool {
|
struct GeneralSettingsBool
|
||||||
const wchar_t *name;
|
{
|
||||||
unsigned int ControlId;
|
const wchar_t *name;
|
||||||
u8 defaultValue;
|
unsigned int ControlId;
|
||||||
|
u8 defaultValue;
|
||||||
};
|
};
|
||||||
|
|
||||||
// XXX: I try to remove only gui stuff
|
// XXX: I try to remove only gui stuff
|
||||||
void DeleteBinding(int port, int slot, Device *dev, Binding *b) {
|
void DeleteBinding(int port, int slot, Device *dev, Binding *b)
|
||||||
fprintf(stderr, "delete binding %d:%d\n", port, slot);
|
{
|
||||||
Binding *bindings = dev->pads[port][slot].bindings;
|
fprintf(stderr, "delete binding %d:%d\n", port, slot);
|
||||||
int i = b - bindings;
|
Binding *bindings = dev->pads[port][slot].bindings;
|
||||||
memmove(bindings+i, bindings+i+1, sizeof(Binding) * (dev->pads[port][slot].numBindings - i - 1));
|
int i = b - bindings;
|
||||||
dev->pads[port][slot].numBindings--;
|
memmove(bindings + i, bindings + i + 1, sizeof(Binding) * (dev->pads[port][slot].numBindings - i - 1));
|
||||||
|
dev->pads[port][slot].numBindings--;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeleteBinding(int port, int slot, Device *dev, ForceFeedbackBinding *b) {
|
void DeleteBinding(int port, int slot, Device *dev, ForceFeedbackBinding *b)
|
||||||
ForceFeedbackBinding *bindings = dev->pads[port][slot].ffBindings;
|
{
|
||||||
int i = b - bindings;
|
ForceFeedbackBinding *bindings = dev->pads[port][slot].ffBindings;
|
||||||
memmove(bindings+i, bindings+i+1, sizeof(Binding) * (dev->pads[port][slot].numFFBindings - i - 1));
|
int i = b - bindings;
|
||||||
dev->pads[port][slot].numFFBindings--;
|
memmove(bindings + i, bindings + i + 1, sizeof(Binding) * (dev->pads[port][slot].numFFBindings - i - 1));
|
||||||
|
dev->pads[port][slot].numFFBindings--;
|
||||||
}
|
}
|
||||||
|
|
||||||
int BindCommand(Device *dev, unsigned int uid, unsigned int port, unsigned int slot, int command, int sensitivity, int turbo, int deadZone) {
|
int BindCommand(Device *dev, unsigned int uid, unsigned int port, unsigned int slot, int command, int sensitivity, int turbo, int deadZone)
|
||||||
// Checks needed because I use this directly when loading bindings.
|
{
|
||||||
if (port > 1 || slot>3) {
|
// Checks needed because I use this directly when loading bindings.
|
||||||
return -1;
|
if (port > 1 || slot > 3) {
|
||||||
}
|
return -1;
|
||||||
if (!sensitivity) sensitivity = BASE_SENSITIVITY;
|
}
|
||||||
if ((uid>>16) & (PSHBTN|TGLBTN)) {
|
if (!sensitivity)
|
||||||
deadZone = 0;
|
sensitivity = BASE_SENSITIVITY;
|
||||||
}
|
if ((uid >> 16) & (PSHBTN | TGLBTN)) {
|
||||||
else if (!deadZone) {
|
deadZone = 0;
|
||||||
if ((uid>>16) & PRESSURE_BTN) {
|
} else if (!deadZone) {
|
||||||
deadZone = 1;
|
if ((uid >> 16) & PRESSURE_BTN) {
|
||||||
}
|
deadZone = 1;
|
||||||
else {
|
} else {
|
||||||
deadZone = DEFAULT_DEADZONE;
|
deadZone = DEFAULT_DEADZONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Relative axes can have negative sensitivity.
|
// Relative axes can have negative sensitivity.
|
||||||
else if (((uid>>16) & 0xFF) == RELAXIS) {
|
else if (((uid >> 16) & 0xFF) == RELAXIS) {
|
||||||
sensitivity = abs(sensitivity);
|
sensitivity = abs(sensitivity);
|
||||||
}
|
}
|
||||||
VirtualControl *c = dev->GetVirtualControl(uid);
|
VirtualControl *c = dev->GetVirtualControl(uid);
|
||||||
if (!c) return -1;
|
if (!c)
|
||||||
// Add before deleting. Means I won't scroll up one line when scrolled down to bottom.
|
return -1;
|
||||||
int controlIndex = c - dev->virtualControls;
|
// Add before deleting. Means I won't scroll up one line when scrolled down to bottom.
|
||||||
int index = 0;
|
int controlIndex = c - dev->virtualControls;
|
||||||
PadBindings *p = dev->pads[port]+slot;
|
int index = 0;
|
||||||
p->bindings = (Binding*) realloc(p->bindings, (p->numBindings+1) * sizeof(Binding));
|
PadBindings *p = dev->pads[port] + slot;
|
||||||
for (index = p->numBindings; index > 0; index--) {
|
p->bindings = (Binding *)realloc(p->bindings, (p->numBindings + 1) * sizeof(Binding));
|
||||||
if (p->bindings[index-1].controlIndex < controlIndex) break;
|
for (index = p->numBindings; index > 0; index--) {
|
||||||
p->bindings[index] = p->bindings[index-1];
|
if (p->bindings[index - 1].controlIndex < controlIndex)
|
||||||
}
|
break;
|
||||||
Binding *b = p->bindings+index;
|
p->bindings[index] = p->bindings[index - 1];
|
||||||
p->numBindings++;
|
}
|
||||||
b->command = command;
|
Binding *b = p->bindings + index;
|
||||||
b->controlIndex = controlIndex;
|
p->numBindings++;
|
||||||
b->turbo = turbo;
|
b->command = command;
|
||||||
b->sensitivity = sensitivity;
|
b->controlIndex = controlIndex;
|
||||||
b->deadZone = deadZone;
|
b->turbo = turbo;
|
||||||
// Where it appears in listview.
|
b->sensitivity = sensitivity;
|
||||||
//int count = ListBoundCommand(port, slot, dev, b);
|
b->deadZone = deadZone;
|
||||||
|
// Where it appears in listview.
|
||||||
|
//int count = ListBoundCommand(port, slot, dev, b);
|
||||||
|
|
||||||
int newBindingIndex = index;
|
int newBindingIndex = index;
|
||||||
index = 0;
|
index = 0;
|
||||||
while (index < p->numBindings) {
|
while (index < p->numBindings) {
|
||||||
if (index == newBindingIndex) {
|
if (index == newBindingIndex) {
|
||||||
index ++;
|
index++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
b = p->bindings + index;
|
b = p->bindings + index;
|
||||||
int nuke = 0;
|
int nuke = 0;
|
||||||
if (config.multipleBinding) {
|
if (config.multipleBinding) {
|
||||||
if (b->controlIndex == controlIndex && b->command == command)
|
if (b->controlIndex == controlIndex && b->command == command)
|
||||||
nuke = 1;
|
nuke = 1;
|
||||||
}
|
} else {
|
||||||
else {
|
int uid2 = dev->virtualControls[b->controlIndex].uid;
|
||||||
int uid2 = dev->virtualControls[b->controlIndex].uid;
|
if (b->controlIndex == controlIndex || (!((uid2 ^ uid) & 0xFFFFFF) && ((uid | uid2) & (UID_POV | UID_AXIS))))
|
||||||
if (b->controlIndex == controlIndex || (!((uid2^uid) & 0xFFFFFF) && ((uid|uid2) & (UID_POV | UID_AXIS))))
|
nuke = 1;
|
||||||
nuke = 1;
|
}
|
||||||
}
|
if (!nuke) {
|
||||||
if (!nuke) {
|
index++;
|
||||||
index++;
|
continue;
|
||||||
continue;
|
}
|
||||||
}
|
if (index < newBindingIndex) {
|
||||||
if (index < newBindingIndex) {
|
newBindingIndex--;
|
||||||
newBindingIndex--;
|
//count --;
|
||||||
//count --;
|
}
|
||||||
}
|
DeleteBinding(port, slot, dev, b);
|
||||||
DeleteBinding(port, slot, dev, b);
|
}
|
||||||
}
|
if (!config.multipleBinding) {
|
||||||
if (!config.multipleBinding) {
|
for (int port2 = 0; port2 < 2; port2++) {
|
||||||
for (int port2=0; port2<2; port2++) {
|
for (int slot2 = 0; slot2 < 4; slot2++) {
|
||||||
for (int slot2=0; slot2<4; slot2++) {
|
if (port2 == (int)port && slot2 == (int)slot)
|
||||||
if (port2==(int)port && slot2 == (int)slot) continue;
|
continue;
|
||||||
PadBindings *p = dev->pads[port2]+slot2;
|
PadBindings *p = dev->pads[port2] + slot2;
|
||||||
for (int i=0; i < p->numBindings; i++) {
|
for (int i = 0; i < p->numBindings; i++) {
|
||||||
Binding *b = p->bindings+i;
|
Binding *b = p->bindings + i;
|
||||||
int uid2 = dev->virtualControls[b->controlIndex].uid;
|
int uid2 = dev->virtualControls[b->controlIndex].uid;
|
||||||
if (b->controlIndex == controlIndex || (!((uid2^uid) & 0xFFFFFF) && ((uid|uid2) & (UID_POV | UID_AXIS)))) {
|
if (b->controlIndex == controlIndex || (!((uid2 ^ uid) & 0xFFFFFF) && ((uid | uid2) & (UID_POV | UID_AXIS)))) {
|
||||||
DeleteBinding(port2, slot2, dev, b);
|
DeleteBinding(port2, slot2, dev, b);
|
||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//return count;
|
//return count;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ties together config data structure, config files, and general config
|
// Ties together config data structure, config files, and general config
|
||||||
// dialog.
|
// dialog.
|
||||||
const GeneralSettingsBool BoolOptionsInfo[] = {
|
const GeneralSettingsBool BoolOptionsInfo[] = {
|
||||||
{L"Force Cursor Hide", 0 /*IDC_FORCE_HIDE*/, 0},
|
{L"Force Cursor Hide", 0 /*IDC_FORCE_HIDE*/, 0},
|
||||||
{L"Mouse Unfocus", 0 /*IDC_MOUSE_UNFOCUS*/, 1},
|
{L"Mouse Unfocus", 0 /*IDC_MOUSE_UNFOCUS*/, 1},
|
||||||
{L"Background", 0 /*IDC_BACKGROUND*/, 1},
|
{L"Background", 0 /*IDC_BACKGROUND*/, 1},
|
||||||
{L"Multiple Bindings", 0 /*IDC_MULTIPLE_BINDING*/, 0},
|
{L"Multiple Bindings", 0 /*IDC_MULTIPLE_BINDING*/, 0},
|
||||||
|
|
||||||
{L"DirectInput Game Devices", 0 /*IDC_G_DI*/, 1},
|
{L"DirectInput Game Devices", 0 /*IDC_G_DI*/, 1},
|
||||||
{L"XInput", 0 /*IDC_G_XI*/, 1},
|
{L"XInput", 0 /*IDC_G_XI*/, 1},
|
||||||
{L"DualShock 3", 0 /*IDC_G_DS3*/, 0},
|
{L"DualShock 3", 0 /*IDC_G_DS3*/, 0},
|
||||||
|
|
||||||
{L"Multitap 1", 0 /*IDC_MULTITAP1*/, 0},
|
{L"Multitap 1", 0 /*IDC_MULTITAP1*/, 0},
|
||||||
{L"Multitap 2", 0 /*IDC_MULTITAP2*/, 0},
|
{L"Multitap 2", 0 /*IDC_MULTITAP2*/, 0},
|
||||||
|
|
||||||
{L"Escape Fullscreen Hack", 0 /*IDC_ESCAPE_FULLSCREEN_HACK*/, 1},
|
{L"Escape Fullscreen Hack", 0 /*IDC_ESCAPE_FULLSCREEN_HACK*/, 1},
|
||||||
{L"Disable Screen Saver", 0 /*IDC_DISABLE_SCREENSAVER*/, 1},
|
{L"Disable Screen Saver", 0 /*IDC_DISABLE_SCREENSAVER*/, 1},
|
||||||
{L"Logging", 0 /*IDC_DEBUG_FILE*/, 0},
|
{L"Logging", 0 /*IDC_DEBUG_FILE*/, 0},
|
||||||
|
|
||||||
{L"Save State in Title", 0 /*IDC_SAVE_STATE_TITLE*/, 0}, //No longer required, PCSX2 now handles it - avih 2011-05-17
|
{L"Save State in Title", 0 /*IDC_SAVE_STATE_TITLE*/, 0}, //No longer required, PCSX2 now handles it - avih 2011-05-17
|
||||||
{L"GH2", 0 /*IDC_GH2_HACK*/, 0},
|
{L"GH2", 0 /*IDC_GH2_HACK*/, 0},
|
||||||
{L"Turbo Key Hack", 0 /*IDC_TURBO_KEY_HACK*/, 0},
|
{L"Turbo Key Hack", 0 /*IDC_TURBO_KEY_HACK*/, 0},
|
||||||
};
|
};
|
||||||
|
|
||||||
void CALLBACK PADsetSettingsDir( const char *dir )
|
void CALLBACK PADsetSettingsDir(const char *dir)
|
||||||
{
|
{
|
||||||
CfgHelper::SetSettingsDir(dir);
|
CfgHelper::SetSettingsDir(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
int SaveSettings(wchar_t *file=0) {
|
int SaveSettings(wchar_t *file = 0)
|
||||||
CfgHelper cfg;
|
{
|
||||||
|
CfgHelper cfg;
|
||||||
|
|
||||||
for (size_t i=0; i<sizeof(BoolOptionsInfo)/sizeof(BoolOptionsInfo[0]); i++) {
|
for (size_t i = 0; i < sizeof(BoolOptionsInfo) / sizeof(BoolOptionsInfo[0]); i++) {
|
||||||
cfg.WriteBool(L"General Settings", BoolOptionsInfo[i].name, config.bools[i]);
|
cfg.WriteBool(L"General Settings", BoolOptionsInfo[i].name, config.bools[i]);
|
||||||
}
|
}
|
||||||
cfg.WriteInt(L"General Settings", L"Close Hacks", config.closeHacks);
|
cfg.WriteInt(L"General Settings", L"Close Hacks", config.closeHacks);
|
||||||
|
|
||||||
cfg.WriteInt(L"General Settings", L"Keyboard Mode", config.keyboardApi);
|
cfg.WriteInt(L"General Settings", L"Keyboard Mode", config.keyboardApi);
|
||||||
cfg.WriteInt(L"General Settings", L"Mouse Mode", config.mouseApi);
|
cfg.WriteInt(L"General Settings", L"Mouse Mode", config.mouseApi);
|
||||||
|
|
||||||
for (int port=0; port<2; port++) {
|
for (int port = 0; port < 2; port++) {
|
||||||
for (int slot=0; slot<4; slot++) {
|
for (int slot = 0; slot < 4; slot++) {
|
||||||
wchar_t temp[50];
|
wchar_t temp[50];
|
||||||
wsprintf(temp, L"Pad %i %i", port, slot);
|
wsprintf(temp, L"Pad %i %i", port, slot);
|
||||||
cfg.WriteInt(temp, L"Mode", config.padConfigs[port][slot].type);
|
cfg.WriteInt(temp, L"Mode", config.padConfigs[port][slot].type);
|
||||||
cfg.WriteInt(temp, L"Auto Analog", config.padConfigs[port][slot].autoAnalog);
|
cfg.WriteInt(temp, L"Auto Analog", config.padConfigs[port][slot].autoAnalog);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dm)
|
if (!dm)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
for (int i=0; i<dm->numDevices; i++) {
|
for (int i = 0; i < dm->numDevices; i++) {
|
||||||
wchar_t id[50];
|
wchar_t id[50];
|
||||||
wchar_t temp[50], temp2[1000];
|
wchar_t temp[50], temp2[1000];
|
||||||
wsprintfW(id, L"Device %i", i);
|
wsprintfW(id, L"Device %i", i);
|
||||||
Device *dev = dm->devices[i];
|
Device *dev = dm->devices[i];
|
||||||
wchar_t *name = dev->displayName;
|
wchar_t *name = dev->displayName;
|
||||||
while (name[0] == '[') {
|
while (name[0] == '[') {
|
||||||
wchar_t *name2 = wcschr(name, ']');
|
wchar_t *name2 = wcschr(name, ']');
|
||||||
if (!name2) break;
|
if (!name2)
|
||||||
name = name2+1;
|
break;
|
||||||
while (iswspace(name[0])) name++;
|
name = name2 + 1;
|
||||||
}
|
while (iswspace(name[0]))
|
||||||
|
name++;
|
||||||
|
}
|
||||||
|
|
||||||
cfg.WriteStr(id, L"Display Name", name);
|
cfg.WriteStr(id, L"Display Name", name);
|
||||||
cfg.WriteStr(id, L"Instance ID", dev->instanceID);
|
cfg.WriteStr(id, L"Instance ID", dev->instanceID);
|
||||||
if (dev->productID) {
|
if (dev->productID) {
|
||||||
cfg.WriteStr(id, L"Product ID", dev->productID);
|
cfg.WriteStr(id, L"Product ID", dev->productID);
|
||||||
}
|
}
|
||||||
cfg.WriteInt(id, L"API", dev->api);
|
cfg.WriteInt(id, L"API", dev->api);
|
||||||
cfg.WriteInt(id, L"Type", dev->type);
|
cfg.WriteInt(id, L"Type", dev->type);
|
||||||
int ffBindingCount = 0;
|
int ffBindingCount = 0;
|
||||||
int bindingCount = 0;
|
int bindingCount = 0;
|
||||||
for (int port=0; port<2; port++) {
|
for (int port = 0; port < 2; port++) {
|
||||||
for (int slot=0; slot<4; slot++) {
|
for (int slot = 0; slot < 4; slot++) {
|
||||||
for (int j=0; j<dev->pads[port][slot].numBindings; j++) {
|
for (int j = 0; j < dev->pads[port][slot].numBindings; j++) {
|
||||||
Binding *b = dev->pads[port][slot].bindings+j;
|
Binding *b = dev->pads[port][slot].bindings + j;
|
||||||
VirtualControl *c = &dev->virtualControls[b->controlIndex];
|
VirtualControl *c = &dev->virtualControls[b->controlIndex];
|
||||||
wsprintfW(temp, L"Binding %i", bindingCount++);
|
wsprintfW(temp, L"Binding %i", bindingCount++);
|
||||||
wsprintfW(temp2, L"0x%08X, %i, %i, %i, %i, %i, %i", c->uid, port, b->command, b->sensitivity, b->turbo, slot, b->deadZone);
|
wsprintfW(temp2, L"0x%08X, %i, %i, %i, %i, %i, %i", c->uid, port, b->command, b->sensitivity, b->turbo, slot, b->deadZone);
|
||||||
cfg.WriteStr(id, temp, temp2);
|
cfg.WriteStr(id, temp, temp2);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int j=0; j<dev->pads[port][slot].numFFBindings; j++) {
|
for (int j = 0; j < dev->pads[port][slot].numFFBindings; j++) {
|
||||||
ForceFeedbackBinding *b = dev->pads[port][slot].ffBindings+j;
|
ForceFeedbackBinding *b = dev->pads[port][slot].ffBindings + j;
|
||||||
ForceFeedbackEffectType *eff = &dev->ffEffectTypes[b->effectIndex];
|
ForceFeedbackEffectType *eff = &dev->ffEffectTypes[b->effectIndex];
|
||||||
wsprintfW(temp, L"FF Binding %i", ffBindingCount++);
|
wsprintfW(temp, L"FF Binding %i", ffBindingCount++);
|
||||||
wsprintfW(temp2, L"%s %i, %i, %i", eff->effectID, port, b->motor, slot);
|
wsprintfW(temp2, L"%s %i, %i, %i", eff->effectID, port, b->motor, slot);
|
||||||
for (int k=0; k<dev->numFFAxes; k++) {
|
for (int k = 0; k < dev->numFFAxes; k++) {
|
||||||
ForceFeedbackAxis *axis = dev->ffAxes + k;
|
ForceFeedbackAxis *axis = dev->ffAxes + k;
|
||||||
AxisEffectInfo *info = b->axes + k;
|
AxisEffectInfo *info = b->axes + k;
|
||||||
//wsprintfW(wcschr(temp2,0), L", %i, %i", axis->id, info->force);
|
//wsprintfW(wcschr(temp2,0), L", %i, %i", axis->id, info->force);
|
||||||
// Not secure because I'm too lazy to compute the remaining size
|
// Not secure because I'm too lazy to compute the remaining size
|
||||||
wprintf(wcschr(temp2, 0), L", %i, %i", axis->id, info->force);
|
wprintf(wcschr(temp2, 0), L", %i, %i", axis->id, info->force);
|
||||||
}
|
}
|
||||||
cfg.WriteStr(id, temp, temp2);
|
cfg.WriteStr(id, temp, temp2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int LoadSettings(int force, wchar_t *file) {
|
int LoadSettings(int force, wchar_t *file)
|
||||||
if (dm && !force) return 0;
|
{
|
||||||
|
if (dm && !force)
|
||||||
|
return 0;
|
||||||
|
|
||||||
// Could just do ClearDevices() instead, but if I ever add any extra stuff,
|
// Could just do ClearDevices() instead, but if I ever add any extra stuff,
|
||||||
// this will still work.
|
// this will still work.
|
||||||
UnloadConfigs();
|
UnloadConfigs();
|
||||||
dm = new InputDeviceManager();
|
dm = new InputDeviceManager();
|
||||||
|
|
||||||
CfgHelper cfg;
|
CfgHelper cfg;
|
||||||
|
|
||||||
for (size_t i=0; i<sizeof(BoolOptionsInfo)/sizeof(BoolOptionsInfo[0]); i++) {
|
for (size_t i = 0; i < sizeof(BoolOptionsInfo) / sizeof(BoolOptionsInfo[0]); i++) {
|
||||||
config.bools[i] = cfg.ReadBool(L"General Settings", BoolOptionsInfo[i].name, BoolOptionsInfo[i].defaultValue);
|
config.bools[i] = cfg.ReadBool(L"General Settings", BoolOptionsInfo[i].name, BoolOptionsInfo[i].defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
config.closeHacks = (u8)cfg.ReadInt(L"General Settings", L"Close Hacks");
|
config.closeHacks = (u8)cfg.ReadInt(L"General Settings", L"Close Hacks");
|
||||||
if (config.closeHacks&1) config.closeHacks &= ~2;
|
if (config.closeHacks & 1)
|
||||||
|
config.closeHacks &= ~2;
|
||||||
|
|
||||||
config.keyboardApi = (DeviceAPI)cfg.ReadInt(L"General Settings", L"Keyboard Mode", LNX_KEYBOARD);
|
config.keyboardApi = (DeviceAPI)cfg.ReadInt(L"General Settings", L"Keyboard Mode", LNX_KEYBOARD);
|
||||||
if (!config.keyboardApi) config.keyboardApi = LNX_KEYBOARD;
|
if (!config.keyboardApi)
|
||||||
config.mouseApi = (DeviceAPI) cfg.ReadInt(L"General Settings", L"Mouse Mode");
|
config.keyboardApi = LNX_KEYBOARD;
|
||||||
|
config.mouseApi = (DeviceAPI)cfg.ReadInt(L"General Settings", L"Mouse Mode");
|
||||||
|
|
||||||
for (int port=0; port<2; port++) {
|
for (int port = 0; port < 2; port++) {
|
||||||
for (int slot=0; slot<4; slot++) {
|
for (int slot = 0; slot < 4; slot++) {
|
||||||
wchar_t temp[50];
|
wchar_t temp[50];
|
||||||
wsprintf(temp, L"Pad %i %i", port, slot);
|
wsprintf(temp, L"Pad %i %i", port, slot);
|
||||||
config.padConfigs[port][slot].type = (PadType) cfg.ReadInt(temp, L"Mode", Dualshock2Pad);
|
config.padConfigs[port][slot].type = (PadType)cfg.ReadInt(temp, L"Mode", Dualshock2Pad);
|
||||||
config.padConfigs[port][slot].autoAnalog = cfg.ReadBool(temp, L"Auto Analog");
|
config.padConfigs[port][slot].autoAnalog = cfg.ReadBool(temp, L"Auto Analog");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int i=0;
|
int i = 0;
|
||||||
int multipleBinding = config.multipleBinding;
|
int multipleBinding = config.multipleBinding;
|
||||||
// Disabling multiple binding only prevents new multiple bindings.
|
// Disabling multiple binding only prevents new multiple bindings.
|
||||||
config.multipleBinding = 1;
|
config.multipleBinding = 1;
|
||||||
while (1) {
|
while (1) {
|
||||||
wchar_t id[50];
|
wchar_t id[50];
|
||||||
wchar_t temp[50], temp2[1000], temp3[1000], temp4[1000];
|
wchar_t temp[50], temp2[1000], temp3[1000], temp4[1000];
|
||||||
wsprintfW(id, L"Device %i", i++);
|
wsprintfW(id, L"Device %i", i++);
|
||||||
if (!cfg.ReadStr(id, L"Display Name", temp2) || !temp2[0] ||
|
if (!cfg.ReadStr(id, L"Display Name", temp2) || !temp2[0] ||
|
||||||
!cfg.ReadStr(id, L"Instance ID", temp3) || !temp3[0]) {
|
!cfg.ReadStr(id, L"Instance ID", temp3) || !temp3[0]) {
|
||||||
if (i >= 100) break;
|
if (i >= 100)
|
||||||
continue;
|
break;
|
||||||
}
|
continue;
|
||||||
wchar_t *id2 = 0;
|
}
|
||||||
if (cfg.ReadStr(id, L"Product ID", temp4) && temp4[0])
|
wchar_t *id2 = 0;
|
||||||
id2 = temp4;
|
if (cfg.ReadStr(id, L"Product ID", temp4) && temp4[0])
|
||||||
|
id2 = temp4;
|
||||||
|
|
||||||
int api = cfg.ReadInt(id, L"API");
|
int api = cfg.ReadInt(id, L"API");
|
||||||
int type = cfg.ReadInt(id, L"Type");
|
int type = cfg.ReadInt(id, L"Type");
|
||||||
if (!api || !type) continue;
|
if (!api || !type)
|
||||||
|
continue;
|
||||||
|
|
||||||
Device *dev = new Device((DeviceAPI)api, (DeviceType)type, temp2, temp3, id2);
|
Device *dev = new Device((DeviceAPI)api, (DeviceType)type, temp2, temp3, id2);
|
||||||
dev->attached = 0;
|
dev->attached = 0;
|
||||||
dm->AddDevice(dev);
|
dm->AddDevice(dev);
|
||||||
int j = 0;
|
int j = 0;
|
||||||
int last = 0;
|
int last = 0;
|
||||||
while (1) {
|
while (1) {
|
||||||
wsprintfW(temp, L"Binding %i", j++);
|
wsprintfW(temp, L"Binding %i", j++);
|
||||||
if (!cfg.ReadStr(id, temp, temp2)) {
|
if (!cfg.ReadStr(id, temp, temp2)) {
|
||||||
if (j >= 100) {
|
if (j >= 100) {
|
||||||
if (!last) break;
|
if (!last)
|
||||||
last = 0;
|
break;
|
||||||
}
|
last = 0;
|
||||||
continue;
|
}
|
||||||
}
|
continue;
|
||||||
last = 1;
|
}
|
||||||
unsigned int uid;
|
last = 1;
|
||||||
int port, command, sensitivity, turbo, slot = 0, deadZone = 0;
|
unsigned int uid;
|
||||||
int w = 0;
|
int port, command, sensitivity, turbo, slot = 0, deadZone = 0;
|
||||||
char string[1000];
|
int w = 0;
|
||||||
while (temp2[w]) {
|
char string[1000];
|
||||||
string[w] = (char)temp2[w];
|
while (temp2[w]) {
|
||||||
w++;
|
string[w] = (char)temp2[w];
|
||||||
}
|
w++;
|
||||||
string[w] = 0;
|
}
|
||||||
int len = sscanf(string, " %u , %i , %i , %i , %i , %i , %i", &uid, &port, &command, &sensitivity, &turbo, &slot, &deadZone);
|
string[w] = 0;
|
||||||
if (len >= 5 && type) {
|
int len = sscanf(string, " %u , %i , %i , %i , %i , %i , %i", &uid, &port, &command, &sensitivity, &turbo, &slot, &deadZone);
|
||||||
VirtualControl *c = dev->GetVirtualControl(uid);
|
if (len >= 5 && type) {
|
||||||
if (!c) c = dev->AddVirtualControl(uid, -1);
|
VirtualControl *c = dev->GetVirtualControl(uid);
|
||||||
if (c) {
|
if (!c)
|
||||||
BindCommand(dev, uid, port, slot, command, sensitivity, turbo, deadZone);
|
c = dev->AddVirtualControl(uid, -1);
|
||||||
}
|
if (c) {
|
||||||
}
|
BindCommand(dev, uid, port, slot, command, sensitivity, turbo, deadZone);
|
||||||
}
|
}
|
||||||
j = 0;
|
}
|
||||||
while (1) {
|
}
|
||||||
wsprintfW(temp, L"FF Binding %i", j++);
|
j = 0;
|
||||||
if (!cfg.ReadStr(id, temp, temp2)) {
|
while (1) {
|
||||||
if (j >= 10) {
|
wsprintfW(temp, L"FF Binding %i", j++);
|
||||||
if (!last) break;
|
if (!cfg.ReadStr(id, temp, temp2)) {
|
||||||
last = 0;
|
if (j >= 10) {
|
||||||
}
|
if (!last)
|
||||||
continue;
|
break;
|
||||||
}
|
last = 0;
|
||||||
last = 1;
|
}
|
||||||
int port, slot, motor;
|
continue;
|
||||||
int w = 0;
|
}
|
||||||
char string[1000];
|
last = 1;
|
||||||
char effect[1000];
|
int port, slot, motor;
|
||||||
while (temp2[w]) {
|
int w = 0;
|
||||||
string[w] = (char)temp2[w];
|
char string[1000];
|
||||||
w++;
|
char effect[1000];
|
||||||
}
|
while (temp2[w]) {
|
||||||
string[w] = 0;
|
string[w] = (char)temp2[w];
|
||||||
// wcstok not in ntdll. More effore than its worth to shave off
|
w++;
|
||||||
// whitespace without it.
|
}
|
||||||
if (sscanf(string, " %s %i , %i , %i", effect, &port, &motor, &slot) == 4) {
|
string[w] = 0;
|
||||||
char *s = strchr(strchr(strchr(string, ',')+1, ',')+1, ',');
|
// wcstok not in ntdll. More effore than its worth to shave off
|
||||||
if (!s) continue;
|
// whitespace without it.
|
||||||
s++;
|
if (sscanf(string, " %s %i , %i , %i", effect, &port, &motor, &slot) == 4) {
|
||||||
w = 0;
|
char *s = strchr(strchr(strchr(string, ',') + 1, ',') + 1, ',');
|
||||||
while (effect[w]) {
|
if (!s)
|
||||||
temp2[w] = effect[w];
|
continue;
|
||||||
w++;
|
s++;
|
||||||
}
|
w = 0;
|
||||||
temp2[w] = 0;
|
while (effect[w]) {
|
||||||
ForceFeedbackEffectType *eff = dev->GetForcefeedbackEffect(temp2);
|
temp2[w] = effect[w];
|
||||||
if (!eff) {
|
w++;
|
||||||
// At the moment, don't record effect types.
|
}
|
||||||
// Only used internally, anyways, so not an issue.
|
temp2[w] = 0;
|
||||||
dev->AddFFEffectType(temp2, temp2, EFFECT_CONSTANT);
|
ForceFeedbackEffectType *eff = dev->GetForcefeedbackEffect(temp2);
|
||||||
// eff = &dev->ffEffectTypes[dev->numFFEffectTypes-1];
|
if (!eff) {
|
||||||
}
|
// At the moment, don't record effect types.
|
||||||
|
// Only used internally, anyways, so not an issue.
|
||||||
|
dev->AddFFEffectType(temp2, temp2, EFFECT_CONSTANT);
|
||||||
|
// eff = &dev->ffEffectTypes[dev->numFFEffectTypes-1];
|
||||||
|
}
|
||||||
#if 0
|
#if 0
|
||||||
ForceFeedbackBinding *b;
|
ForceFeedbackBinding *b;
|
||||||
CreateEffectBinding(dev, temp2, port, slot, motor, &b);
|
CreateEffectBinding(dev, temp2, port, slot, motor, &b);
|
||||||
|
@ -437,45 +455,47 @@ int LoadSettings(int force, wchar_t *file) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
config.multipleBinding = multipleBinding;
|
config.multipleBinding = multipleBinding;
|
||||||
|
|
||||||
//TODO RefreshEnabledDevicesAndDisplay(1);
|
//TODO RefreshEnabledDevicesAndDisplay(1);
|
||||||
RefreshEnabledDevices(1); // XXX For the moment only a subfonction
|
RefreshEnabledDevices(1); // XXX For the moment only a subfonction
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnloadConfigs() {
|
void UnloadConfigs()
|
||||||
if (dm) {
|
{
|
||||||
delete dm;
|
if (dm) {
|
||||||
dm = 0;
|
delete dm;
|
||||||
}
|
dm = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RefreshEnabledDevices(int updateDeviceList) {
|
void RefreshEnabledDevices(int updateDeviceList)
|
||||||
// Clears all device state.
|
{
|
||||||
static int lastXInputState = -1;
|
// Clears all device state.
|
||||||
if (updateDeviceList || lastXInputState != config.gameApis.xInput) {
|
static int lastXInputState = -1;
|
||||||
EnumDevices(config.gameApis.xInput);
|
if (updateDeviceList || lastXInputState != config.gameApis.xInput) {
|
||||||
lastXInputState = config.gameApis.xInput;
|
EnumDevices(config.gameApis.xInput);
|
||||||
}
|
lastXInputState = config.gameApis.xInput;
|
||||||
|
}
|
||||||
|
|
||||||
for (int i=0; i<dm->numDevices; i++) {
|
for (int i = 0; i < dm->numDevices; i++) {
|
||||||
Device *dev = dm->devices[i];
|
Device *dev = dm->devices[i];
|
||||||
|
|
||||||
// XXX windows magic?
|
// XXX windows magic?
|
||||||
if (!dev->attached && dev->displayName[0] != '[') {
|
if (!dev->attached && dev->displayName[0] != '[') {
|
||||||
wchar_t *newName = (wchar_t*) malloc(sizeof(wchar_t) * (wcslen(dev->displayName) + 12));
|
wchar_t *newName = (wchar_t *)malloc(sizeof(wchar_t) * (wcslen(dev->displayName) + 12));
|
||||||
wsprintfW(newName, L"[Detached] %s", dev->displayName);
|
wsprintfW(newName, L"[Detached] %s", dev->displayName);
|
||||||
free(dev->displayName);
|
free(dev->displayName);
|
||||||
dev->displayName = newName;
|
dev->displayName = newName;
|
||||||
}
|
}
|
||||||
|
|
||||||
dm->EnableDevice(i);
|
dm->EnableDevice(i);
|
||||||
#if 0 // windows magic?
|
#if 0 // windows magic?
|
||||||
if ((dev->type == KEYBOARD && dev->api == IGNORE_KEYBOARD) ||
|
if ((dev->type == KEYBOARD && dev->api == IGNORE_KEYBOARD) ||
|
||||||
(dev->type == KEYBOARD && dev->api == config.keyboardApi) ||
|
(dev->type == KEYBOARD && dev->api == config.keyboardApi) ||
|
||||||
(dev->type == MOUSE && dev->api == config.mouseApi) ||
|
(dev->type == MOUSE && dev->api == config.mouseApi) ||
|
||||||
|
@ -496,13 +516,14 @@ void RefreshEnabledDevices(int updateDeviceList) {
|
||||||
dm->DisableDevice(i);
|
dm->DisableDevice(i);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Configure() {
|
void Configure()
|
||||||
// Can end up here without PADinit() being called first.
|
{
|
||||||
LoadSettings();
|
// Can end up here without PADinit() being called first.
|
||||||
// Can also end up here after running emulator a bit, and possibly
|
LoadSettings();
|
||||||
// disabling some devices due to focus changes, or releasing mouse.
|
// Can also end up here after running emulator a bit, and possibly
|
||||||
RefreshEnabledDevices(0);
|
// disabling some devices due to focus changes, or releasing mouse.
|
||||||
|
RefreshEnabledDevices(0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,91 +22,91 @@
|
||||||
|
|
||||||
wxString CfgHelper::m_path = L"inis/LilyPad.ini";
|
wxString CfgHelper::m_path = L"inis/LilyPad.ini";
|
||||||
|
|
||||||
void CfgHelper::SetSettingsDir(const char* dir)
|
void CfgHelper::SetSettingsDir(const char *dir)
|
||||||
{
|
{
|
||||||
m_path = wxString::FromAscii(dir) + L"/LilyPad.ini";
|
m_path = wxString::FromAscii(dir) + L"/LilyPad.ini";
|
||||||
}
|
}
|
||||||
|
|
||||||
CfgHelper::CfgHelper()
|
CfgHelper::CfgHelper()
|
||||||
{
|
{
|
||||||
m_config = new wxFileConfig(L"", L"", m_path, L"", wxCONFIG_USE_LOCAL_FILE);
|
m_config = new wxFileConfig(L"", L"", m_path, L"", wxCONFIG_USE_LOCAL_FILE);
|
||||||
}
|
}
|
||||||
|
|
||||||
CfgHelper::~CfgHelper()
|
CfgHelper::~CfgHelper()
|
||||||
{
|
{
|
||||||
delete m_config;
|
delete m_config;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CfgHelper::setIni(const wchar_t* Section)
|
void CfgHelper::setIni(const wchar_t *Section)
|
||||||
{
|
{
|
||||||
m_config->SetPath(wxsFormat(L"/%s", Section));
|
m_config->SetPath(wxsFormat(L"/%s", Section));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CfgHelper::WriteBool(const wchar_t* Section, const wchar_t* Name, bool Value)
|
void CfgHelper::WriteBool(const wchar_t *Section, const wchar_t *Name, bool Value)
|
||||||
{
|
{
|
||||||
setIni(Section);
|
setIni(Section);
|
||||||
m_config->Write(Name, Value);
|
m_config->Write(Name, Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CfgHelper::WriteInt(const wchar_t* Section, const wchar_t* Name, int Value)
|
void CfgHelper::WriteInt(const wchar_t *Section, const wchar_t *Name, int Value)
|
||||||
{
|
{
|
||||||
setIni(Section);
|
setIni(Section);
|
||||||
m_config->Write(Name, Value);
|
m_config->Write(Name, Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CfgHelper::WriteFloat(const wchar_t* Section, const wchar_t* Name, float Value)
|
void CfgHelper::WriteFloat(const wchar_t *Section, const wchar_t *Name, float Value)
|
||||||
{
|
{
|
||||||
setIni(Section);
|
setIni(Section);
|
||||||
m_config->Write(Name, (double)Value);
|
m_config->Write(Name, (double)Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CfgHelper::WriteStr(const wchar_t* Section, const wchar_t* Name, const wxString& Data)
|
void CfgHelper::WriteStr(const wchar_t *Section, const wchar_t *Name, const wxString &Data)
|
||||||
{
|
{
|
||||||
setIni(Section);
|
setIni(Section);
|
||||||
m_config->Write(Name, Data);
|
m_config->Write(Name, Data);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CfgHelper::ReadBool(const wchar_t *Section,const wchar_t* Name, bool Default)
|
bool CfgHelper::ReadBool(const wchar_t *Section, const wchar_t *Name, bool Default)
|
||||||
{
|
{
|
||||||
bool ret;
|
bool ret;
|
||||||
|
|
||||||
setIni(Section);
|
setIni(Section);
|
||||||
m_config->Read(Name, &ret, Default);
|
m_config->Read(Name, &ret, Default);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CfgHelper::ReadInt(const wchar_t* Section, const wchar_t* Name,int Default)
|
int CfgHelper::ReadInt(const wchar_t *Section, const wchar_t *Name, int Default)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
setIni(Section);
|
setIni(Section);
|
||||||
m_config->Read(Name, &ret, Default);
|
m_config->Read(Name, &ret, Default);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
float CfgHelper::ReadFloat(const wchar_t* Section, const wchar_t* Name, float Default)
|
float CfgHelper::ReadFloat(const wchar_t *Section, const wchar_t *Name, float Default)
|
||||||
{
|
{
|
||||||
double ret;
|
double ret;
|
||||||
|
|
||||||
setIni(Section);
|
setIni(Section);
|
||||||
m_config->Read(Name, &ret, (double)Default);
|
m_config->Read(Name, &ret, (double)Default);
|
||||||
|
|
||||||
return (float)ret;
|
return (float)ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CfgHelper::ReadStr(const wchar_t* Section, const wchar_t* Name, wchar_t* Data, const wchar_t* Default)
|
int CfgHelper::ReadStr(const wchar_t *Section, const wchar_t *Name, wchar_t *Data, const wchar_t *Default)
|
||||||
{
|
{
|
||||||
setIni(Section);
|
setIni(Section);
|
||||||
wcscpy(Data, m_config->Read(Name, Default).wc_str());
|
wcscpy(Data, m_config->Read(Name, Default).wc_str());
|
||||||
return wcslen(Data);
|
return wcslen(Data);
|
||||||
}
|
}
|
||||||
|
|
||||||
int CfgHelper::ReadStr(const wchar_t* Section, const wchar_t* Name, wxString& Data, const wchar_t* Default)
|
int CfgHelper::ReadStr(const wchar_t *Section, const wchar_t *Name, wxString &Data, const wchar_t *Default)
|
||||||
{
|
{
|
||||||
setIni(Section);
|
setIni(Section);
|
||||||
Data = m_config->Read(Name, Default);
|
Data = m_config->Read(Name, Default);
|
||||||
return Data.size();
|
return Data.size();
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,29 +20,29 @@
|
||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
#include <wx/fileconf.h>
|
#include <wx/fileconf.h>
|
||||||
|
|
||||||
extern void CfgSetSettingsDir(const char* dir);
|
extern void CfgSetSettingsDir(const char *dir);
|
||||||
|
|
||||||
class CfgHelper {
|
class CfgHelper
|
||||||
wxFileConfig* m_config;
|
{
|
||||||
static wxString m_path;
|
wxFileConfig *m_config;
|
||||||
|
static wxString m_path;
|
||||||
|
|
||||||
void setIni(const wchar_t* Section);
|
void setIni(const wchar_t *Section);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CfgHelper();
|
CfgHelper();
|
||||||
~CfgHelper();
|
~CfgHelper();
|
||||||
|
|
||||||
void WriteBool(const wchar_t* Section, const wchar_t* Name, bool Value);
|
void WriteBool(const wchar_t *Section, const wchar_t *Name, bool Value);
|
||||||
void WriteInt(const wchar_t* Section, const wchar_t* Name, int Value);
|
void WriteInt(const wchar_t *Section, const wchar_t *Name, int Value);
|
||||||
void WriteFloat(const wchar_t* Section, const wchar_t* Name, float Value);
|
void WriteFloat(const wchar_t *Section, const wchar_t *Name, float Value);
|
||||||
void WriteStr(const wchar_t* Section, const wchar_t* Name, const wxString& Data);
|
void WriteStr(const wchar_t *Section, const wchar_t *Name, const wxString &Data);
|
||||||
|
|
||||||
bool ReadBool(const wchar_t *Section,const wchar_t* Name, bool Default = false);
|
bool ReadBool(const wchar_t *Section, const wchar_t *Name, bool Default = false);
|
||||||
int ReadStr(const wchar_t* Section, const wchar_t* Name, wxString& Data, const wchar_t* Default = 0);
|
int ReadStr(const wchar_t *Section, const wchar_t *Name, wxString &Data, const wchar_t *Default = 0);
|
||||||
int ReadStr(const wchar_t* Section, const wchar_t* Name, wchar_t* Data, const wchar_t* Default = 0);
|
int ReadStr(const wchar_t *Section, const wchar_t *Name, wchar_t *Data, const wchar_t *Default = 0);
|
||||||
int ReadInt(const wchar_t* Section, const wchar_t* Name,int Default = 0);
|
int ReadInt(const wchar_t *Section, const wchar_t *Name, int Default = 0);
|
||||||
float ReadFloat(const wchar_t* Section, const wchar_t* Name, float Default = 0.0f);
|
float ReadFloat(const wchar_t *Section, const wchar_t *Name, float Default = 0.0f);
|
||||||
|
|
||||||
static void SetSettingsDir(const char* dir);
|
|
||||||
|
|
||||||
|
static void SetSettingsDir(const char *dir);
|
||||||
};
|
};
|
||||||
|
|
|
@ -20,189 +20,191 @@
|
||||||
#include "Linux/JoyEvdev.h"
|
#include "Linux/JoyEvdev.h"
|
||||||
#include "Linux/bitmaskros.h"
|
#include "Linux/bitmaskros.h"
|
||||||
|
|
||||||
JoyEvdev::JoyEvdev(int fd, bool ds3, const wchar_t *id) : Device(LNX_JOY, OTHER, id, id), m_fd(fd) {
|
JoyEvdev::JoyEvdev(int fd, bool ds3, const wchar_t *id)
|
||||||
// XXX LNX_JOY => DS3 or ???
|
: Device(LNX_JOY, OTHER, id, id)
|
||||||
|
, m_fd(fd)
|
||||||
|
{
|
||||||
|
// XXX LNX_JOY => DS3 or ???
|
||||||
|
|
||||||
m_abs.clear();
|
m_abs.clear();
|
||||||
m_btn.clear();
|
m_btn.clear();
|
||||||
m_rel.clear();
|
m_rel.clear();
|
||||||
int last = 0;
|
int last = 0;
|
||||||
|
|
||||||
uint8_t abs_bitmap[nUcharsForNBits(ABS_CNT)] = {0};
|
uint8_t abs_bitmap[nUcharsForNBits(ABS_CNT)] = {0};
|
||||||
uint8_t btn_bitmap[nUcharsForNBits(KEY_CNT)] = {0};
|
uint8_t btn_bitmap[nUcharsForNBits(KEY_CNT)] = {0};
|
||||||
uint8_t rel_bitmap[nUcharsForNBits(REL_CNT)] = {0};
|
uint8_t rel_bitmap[nUcharsForNBits(REL_CNT)] = {0};
|
||||||
|
|
||||||
// Add buttons
|
// Add buttons
|
||||||
if (ioctl(fd, EVIOCGBIT(EV_KEY, sizeof(btn_bitmap)), btn_bitmap) >= 0) {
|
if (ioctl(fd, EVIOCGBIT(EV_KEY, sizeof(btn_bitmap)), btn_bitmap) >= 0) {
|
||||||
for (int bit = BTN_MISC; bit < KEY_CNT; bit++) {
|
for (int bit = BTN_MISC; bit < KEY_CNT; bit++) {
|
||||||
if (testBit(bit, btn_bitmap)) {
|
if (testBit(bit, btn_bitmap)) {
|
||||||
AddPhysicalControl(PSHBTN, last, 0);
|
AddPhysicalControl(PSHBTN, last, 0);
|
||||||
m_btn.push_back(bit);
|
m_btn.push_back(bit);
|
||||||
last++;
|
last++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add Absolute axis
|
// Add Absolute axis
|
||||||
if (ioctl(fd, EVIOCGBIT(EV_ABS, sizeof(abs_bitmap)), abs_bitmap) >= 0) {
|
if (ioctl(fd, EVIOCGBIT(EV_ABS, sizeof(abs_bitmap)), abs_bitmap) >= 0) {
|
||||||
for (int bit = 0; bit < ABS_CNT; bit++) {
|
for (int bit = 0; bit < ABS_CNT; bit++) {
|
||||||
ControlType type = ABSAXIS; // FIXME DS3
|
ControlType type = ABSAXIS; // FIXME DS3
|
||||||
|
|
||||||
if (testBit(bit, abs_bitmap)) {
|
if (testBit(bit, abs_bitmap)) {
|
||||||
input_absinfo info;
|
input_absinfo info;
|
||||||
if (ioctl(m_fd, EVIOCGABS(bit), &info) < 0) {
|
if (ioctl(m_fd, EVIOCGABS(bit), &info) < 0) {
|
||||||
fprintf(stderr, "Invalid IOCTL EVIOCGID\n");
|
fprintf(stderr, "Invalid IOCTL EVIOCGID\n");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
AddPhysicalControl(ABSAXIS, last, 0);
|
AddPhysicalControl(ABSAXIS, last, 0);
|
||||||
last++;
|
last++;
|
||||||
if (std::abs(info.value - 127) < 2) {
|
if (std::abs(info.value - 127) < 2) {
|
||||||
fprintf(stderr, "HALF Axis info %d=>%d, current %d, flat %d, resolution %d\n", info.minimum, info.maximum, info.value, info.flat, info.resolution);
|
fprintf(stderr, "HALF Axis info %d=>%d, current %d, flat %d, resolution %d\n", info.minimum, info.maximum, info.value, info.flat, info.resolution);
|
||||||
|
|
||||||
// Half axis must be split into 2 parts...
|
// Half axis must be split into 2 parts...
|
||||||
AddPhysicalControl(ABSAXIS, last, 0);
|
AddPhysicalControl(ABSAXIS, last, 0);
|
||||||
last++;
|
last++;
|
||||||
|
|
||||||
m_abs.push_back(abs_info(bit, info.minimum, info.value, type));
|
m_abs.push_back(abs_info(bit, info.minimum, info.value, type));
|
||||||
m_abs.push_back(abs_info(bit, info.value, info.maximum, type));
|
m_abs.push_back(abs_info(bit, info.value, info.maximum, type));
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "FULL Axis info %d=>%d, current %d, flat %d, resolution %d\n", info.minimum, info.maximum, info.value, info.flat, info.resolution);
|
fprintf(stderr, "FULL Axis info %d=>%d, current %d, flat %d, resolution %d\n", info.minimum, info.maximum, info.value, info.flat, info.resolution);
|
||||||
|
|
||||||
m_abs.push_back(abs_info(bit, info.minimum, info.maximum, type));
|
m_abs.push_back(abs_info(bit, info.minimum, info.maximum, type));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add relative axis
|
// Add relative axis
|
||||||
if (ioctl(fd, EVIOCGBIT(EV_REL, sizeof(rel_bitmap)), rel_bitmap) >= 0) {
|
if (ioctl(fd, EVIOCGBIT(EV_REL, sizeof(rel_bitmap)), rel_bitmap) >= 0) {
|
||||||
for (int bit = 0; bit < REL_CNT; bit++) {
|
for (int bit = 0; bit < REL_CNT; bit++) {
|
||||||
if (testBit(bit, rel_bitmap)) {
|
if (testBit(bit, rel_bitmap)) {
|
||||||
AddPhysicalControl(RELAXIS, last, last);
|
AddPhysicalControl(RELAXIS, last, last);
|
||||||
m_rel.push_back(bit);
|
m_rel.push_back(bit);
|
||||||
last++;
|
last++;
|
||||||
|
|
||||||
fprintf(stderr, "Add relative nb %d\n", bit);
|
fprintf(stderr, "Add relative nb %d\n", bit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, "New device created. Found axe:%zu, buttons:%zu, m_rel:%zu\n\n", m_abs.size(), m_btn.size(), m_rel.size());
|
fprintf(stderr, "New device created. Found axe:%zu, buttons:%zu, m_rel:%zu\n\n", m_abs.size(), m_btn.size(), m_rel.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
JoyEvdev::~JoyEvdev() {
|
JoyEvdev::~JoyEvdev()
|
||||||
close(m_fd);
|
{
|
||||||
|
close(m_fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
int JoyEvdev::Activate(InitInfo* args) {
|
int JoyEvdev::Activate(InitInfo *args)
|
||||||
AllocState();
|
{
|
||||||
|
AllocState();
|
||||||
|
|
||||||
uint16_t size = m_abs.size()+m_rel.size()+m_btn.size();
|
uint16_t size = m_abs.size() + m_rel.size() + m_btn.size();
|
||||||
memset(physicalControlState, 0, sizeof(int)*size);
|
memset(physicalControlState, 0, sizeof(int) * size);
|
||||||
|
|
||||||
active = 1;
|
active = 1;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int JoyEvdev::Update() {
|
int JoyEvdev::Update()
|
||||||
|
{
|
||||||
struct input_event events[32];
|
struct input_event events[32];
|
||||||
int len;
|
int len;
|
||||||
int status = 0;
|
int status = 0;
|
||||||
//fprintf(stderr, "Update was called\n");
|
//fprintf(stderr, "Update was called\n");
|
||||||
|
|
||||||
// Do a big read to reduce kernel validation
|
// Do a big read to reduce kernel validation
|
||||||
while ((len = read(m_fd, events, (sizeof events))) > 0) {
|
while ((len = read(m_fd, events, (sizeof events))) > 0) {
|
||||||
int evt_nb = len / sizeof(input_event);
|
int evt_nb = len / sizeof(input_event);
|
||||||
//fprintf(stderr, "Poll %d events available\n", evt_nb);
|
//fprintf(stderr, "Poll %d events available\n", evt_nb);
|
||||||
for (int i = 0; i < evt_nb; i++) {
|
for (int i = 0; i < evt_nb; i++) {
|
||||||
switch(events[i].type) {
|
switch (events[i].type) {
|
||||||
case EV_ABS:
|
case EV_ABS: {
|
||||||
{
|
for (size_t idx = 0; idx < m_abs.size(); idx++) {
|
||||||
for (size_t idx = 0; idx < m_abs.size(); idx++) {
|
if (m_abs[idx].code == events[i].code) {
|
||||||
if (m_abs[idx].code == events[i].code) {
|
// XXX strict or not ?
|
||||||
// XXX strict or not ?
|
if ((events[i].value >= m_abs[idx].min) && (events[i].value <= m_abs[idx].max)) {
|
||||||
if ((events[i].value >= m_abs[idx].min) && (events[i].value <= m_abs[idx].max)) {
|
// XXX FIX shitty api
|
||||||
// XXX FIX shitty api
|
int scale = m_abs[idx].scale(events[i].value);
|
||||||
int scale = m_abs[idx].scale(events[i].value);
|
fprintf(stderr, "axis value %d scaled to %d\n", events[i].value, scale);
|
||||||
fprintf(stderr, "axis value %d scaled to %d\n", events[i].value, scale);
|
physicalControlState[idx + m_btn.size()] = scale;
|
||||||
physicalControlState[idx + m_btn.size()] = scale;
|
status = 1;
|
||||||
status = 1;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} break;
|
||||||
}
|
case EV_KEY: {
|
||||||
break;
|
for (size_t idx = 0; idx < m_btn.size(); idx++) {
|
||||||
case EV_KEY:
|
if (m_btn[idx] == events[i].code) {
|
||||||
{
|
fprintf(stderr, "Event KEY:%d detected with value %d\n", events[i].code, events[i].value);
|
||||||
for (size_t idx = 0; idx < m_btn.size(); idx++) {
|
physicalControlState[idx] = FULLY_DOWN * events[i].value;
|
||||||
if (m_btn[idx] == events[i].code) {
|
status = 1;
|
||||||
fprintf(stderr, "Event KEY:%d detected with value %d\n", events[i].code, events[i].value);
|
break;
|
||||||
physicalControlState[idx] = FULLY_DOWN * events[i].value;
|
}
|
||||||
status = 1;
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
} break;
|
||||||
break;
|
case EV_REL:
|
||||||
case EV_REL:
|
// XXX
|
||||||
// XXX
|
break;
|
||||||
break;
|
default:
|
||||||
default:
|
break;
|
||||||
break;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
return status;
|
||||||
|
|
||||||
return status;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static std::wstring CorrectJoySupport(int fd) {
|
static std::wstring CorrectJoySupport(int fd)
|
||||||
struct input_id id;
|
{
|
||||||
if (ioctl(fd, EVIOCGID, &id) < 0) {
|
struct input_id id;
|
||||||
fprintf(stderr, "Invalid IOCTL EVIOCGID\n");
|
if (ioctl(fd, EVIOCGID, &id) < 0) {
|
||||||
return L"";
|
fprintf(stderr, "Invalid IOCTL EVIOCGID\n");
|
||||||
}
|
return L"";
|
||||||
|
}
|
||||||
|
|
||||||
char dev_name[128];
|
char dev_name[128];
|
||||||
if (ioctl(fd, EVIOCGNAME(128), dev_name) < 0) {
|
if (ioctl(fd, EVIOCGNAME(128), dev_name) < 0) {
|
||||||
fprintf(stderr, "Invalid IOCTL EVIOCGNAME\n");
|
fprintf(stderr, "Invalid IOCTL EVIOCGNAME\n");
|
||||||
return L"";
|
return L"";
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, "Found input device => bustype:%x, vendor:%x, product:%x, version:%x\n", id.bustype, id.vendor, id.product, id.version);
|
fprintf(stderr, "Found input device => bustype:%x, vendor:%x, product:%x, version:%x\n", id.bustype, id.vendor, id.product, id.version);
|
||||||
fprintf(stderr, "\tName:%s\n", dev_name);
|
fprintf(stderr, "\tName:%s\n", dev_name);
|
||||||
|
|
||||||
std::string s(dev_name);
|
std::string s(dev_name);
|
||||||
return std::wstring(s.begin(), s.end());
|
return std::wstring(s.begin(), s.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
void EnumJoystickEvdev() {
|
void EnumJoystickEvdev()
|
||||||
// Technically it must be done with udev but another lib for
|
{
|
||||||
// avoid a loop is too much for me (even if udev is mandatory
|
// Technically it must be done with udev but another lib for
|
||||||
// so maybe later)
|
// avoid a loop is too much for me (even if udev is mandatory
|
||||||
int found_devices = 0;
|
// so maybe later)
|
||||||
std::string input_root("/dev/input/event");
|
int found_devices = 0;
|
||||||
for (int i = 0; i < 32; i++) {
|
std::string input_root("/dev/input/event");
|
||||||
std::string dev = input_root + std::to_string(i);
|
for (int i = 0; i < 32; i++) {
|
||||||
|
std::string dev = input_root + std::to_string(i);
|
||||||
|
|
||||||
int fd = open(dev.c_str(), O_RDWR | O_NONBLOCK);
|
int fd = open(dev.c_str(), O_RDWR | O_NONBLOCK);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::wstring id = CorrectJoySupport(fd);
|
|
||||||
if (id.size() != 0) {
|
|
||||||
bool ds3 = id.find(L"PLAYSTATION(R)3") != std::string::npos;
|
|
||||||
if (ds3) {
|
|
||||||
fprintf(stderr, "DS3 device detected !!!\n");
|
|
||||||
}
|
|
||||||
dm->AddDevice(new JoyEvdev(fd, ds3, id.c_str()));
|
|
||||||
} else if (fd >= 0)
|
|
||||||
close(fd);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
std::wstring id = CorrectJoySupport(fd);
|
||||||
|
if (id.size() != 0) {
|
||||||
|
bool ds3 = id.find(L"PLAYSTATION(R)3") != std::string::npos;
|
||||||
|
if (ds3) {
|
||||||
|
fprintf(stderr, "DS3 device detected !!!\n");
|
||||||
|
}
|
||||||
|
dm->AddDevice(new JoyEvdev(fd, ds3, id.c_str()));
|
||||||
|
} else if (fd >= 0)
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,55 +23,62 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <linux/input.h>
|
#include <linux/input.h>
|
||||||
|
|
||||||
struct abs_info {
|
struct abs_info
|
||||||
uint16_t code;
|
{
|
||||||
int32_t min;
|
uint16_t code;
|
||||||
int32_t max;
|
int32_t min;
|
||||||
|
int32_t max;
|
||||||
|
|
||||||
int32_t factor;
|
int32_t factor;
|
||||||
int32_t translation;
|
int32_t translation;
|
||||||
|
|
||||||
abs_info(int32_t _code, int32_t _min, int32_t _max, ControlType type) : code(_code), min(_min), max(_max) {
|
abs_info(int32_t _code, int32_t _min, int32_t _max, ControlType type)
|
||||||
translation = 0;
|
: code(_code)
|
||||||
// Note: ABSAXIS ranges from -64K to 64K
|
, min(_min)
|
||||||
// Note: PSHBTN ranges from 0 to 64K
|
, max(_max)
|
||||||
if ((min == 0) && (max == 255)) {
|
{
|
||||||
if (type == ABSAXIS) {
|
translation = 0;
|
||||||
translation = 128;
|
// Note: ABSAXIS ranges from -64K to 64K
|
||||||
factor = FULLY_DOWN/128;
|
// Note: PSHBTN ranges from 0 to 64K
|
||||||
} else {
|
if ((min == 0) && (max == 255)) {
|
||||||
factor = FULLY_DOWN/256;
|
if (type == ABSAXIS) {
|
||||||
}
|
translation = 128;
|
||||||
} else if ((min == -1) && (max == 1)) {
|
factor = FULLY_DOWN / 128;
|
||||||
factor = FULLY_DOWN;
|
} else {
|
||||||
} else if ((min == 0) && (std::abs(max - 127) < 2)) {
|
factor = FULLY_DOWN / 256;
|
||||||
translation = 64;
|
}
|
||||||
factor = -FULLY_DOWN/64;
|
} else if ((min == -1) && (max == 1)) {
|
||||||
} else if ((max == 255) && (std::abs(min - 127) < 2)) {
|
factor = FULLY_DOWN;
|
||||||
translation = 64+128;
|
} else if ((min == 0) && (std::abs(max - 127) < 2)) {
|
||||||
factor = FULLY_DOWN/64;
|
translation = 64;
|
||||||
} else {
|
factor = -FULLY_DOWN / 64;
|
||||||
fprintf(stderr, "Scale not supported\n");
|
} else if ((max == 255) && (std::abs(min - 127) < 2)) {
|
||||||
factor = 0;
|
translation = 64 + 128;
|
||||||
}
|
factor = FULLY_DOWN / 64;
|
||||||
}
|
} else {
|
||||||
|
fprintf(stderr, "Scale not supported\n");
|
||||||
|
factor = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int scale(int32_t value) {
|
int scale(int32_t value)
|
||||||
return (value - translation) * factor;
|
{
|
||||||
}
|
return (value - translation) * factor;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class JoyEvdev : public Device {
|
class JoyEvdev : public Device
|
||||||
int m_fd;
|
{
|
||||||
std::vector<abs_info> m_abs;
|
int m_fd;
|
||||||
std::vector<uint16_t> m_btn;
|
std::vector<abs_info> m_abs;
|
||||||
std::vector<uint16_t> m_rel;
|
std::vector<uint16_t> m_btn;
|
||||||
|
std::vector<uint16_t> m_rel;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
JoyEvdev(int fd, bool ds3, const wchar_t *id);
|
JoyEvdev(int fd, bool ds3, const wchar_t *id);
|
||||||
~JoyEvdev();
|
~JoyEvdev();
|
||||||
int Activate(InitInfo* args);
|
int Activate(InitInfo *args);
|
||||||
int Update();
|
int Update();
|
||||||
};
|
};
|
||||||
|
|
||||||
void EnumJoystickEvdev();
|
void EnumJoystickEvdev();
|
||||||
|
|
|
@ -20,19 +20,20 @@
|
||||||
// actually it is even more but it is enough to distinguish different key
|
// actually it is even more but it is enough to distinguish different key
|
||||||
#define MAX_KEYCODE (0xFF)
|
#define MAX_KEYCODE (0xFF)
|
||||||
|
|
||||||
LinuxKeyboard::LinuxKeyboard() :
|
LinuxKeyboard::LinuxKeyboard()
|
||||||
Device(LNX_KEYBOARD, KEYBOARD, L"displayName", L"instanceID", L"deviceID")
|
: Device(LNX_KEYBOARD, KEYBOARD, L"displayName", L"instanceID", L"deviceID")
|
||||||
{
|
{
|
||||||
for (int i=0; i<MAX_KEYCODE; i++) {
|
for (int i = 0; i < MAX_KEYCODE; i++) {
|
||||||
AddPhysicalControl(PSHBTN, i, i);
|
AddPhysicalControl(PSHBTN, i, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int LinuxKeyboard::Activate(InitInfo* args) {
|
int LinuxKeyboard::Activate(InitInfo *args)
|
||||||
// Always active
|
{
|
||||||
active = 1;
|
// Always active
|
||||||
|
active = 1;
|
||||||
AllocState();
|
|
||||||
|
AllocState();
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
for (int vkey=5; vkey<256; vkey++) {
|
for (int vkey=5; vkey<256; vkey++) {
|
||||||
|
@ -44,35 +45,37 @@ int LinuxKeyboard::Activate(InitInfo* args) {
|
||||||
physicalControlState[vkey] = 0;
|
physicalControlState[vkey] = 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
// Every button released
|
// Every button released
|
||||||
memset(physicalControlState, 0, sizeof(int)*MAX_KEYCODE);
|
memset(physicalControlState, 0, sizeof(int) * MAX_KEYCODE);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int LinuxKeyboard::Update() {
|
int LinuxKeyboard::Update()
|
||||||
keyEvent event;
|
{
|
||||||
int status = 0;
|
keyEvent event;
|
||||||
while (R_GetQueuedKeyEvent(&event)) {
|
int status = 0;
|
||||||
switch (event.evt) {
|
while (R_GetQueuedKeyEvent(&event)) {
|
||||||
case KeyPress:
|
switch (event.evt) {
|
||||||
physicalControlState[MAX_KEYCODE & event.key] = FULLY_DOWN;
|
case KeyPress:
|
||||||
status = 1;
|
physicalControlState[MAX_KEYCODE & event.key] = FULLY_DOWN;
|
||||||
break;
|
status = 1;
|
||||||
case KeyRelease:
|
break;
|
||||||
physicalControlState[MAX_KEYCODE & event.key] = 0;
|
case KeyRelease:
|
||||||
status = 1;
|
physicalControlState[MAX_KEYCODE & event.key] = 0;
|
||||||
break;
|
status = 1;
|
||||||
default:
|
break;
|
||||||
//fprintf(stderr, "Unsupported event %x\n", event.evt);
|
default:
|
||||||
//assert(0);
|
//fprintf(stderr, "Unsupported event %x\n", event.evt);
|
||||||
break;
|
//assert(0);
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return status; // XXX ????
|
return status; // XXX ????
|
||||||
}
|
}
|
||||||
|
|
||||||
void EnumLnx() {
|
void EnumLnx()
|
||||||
dm->AddDevice(new LinuxKeyboard());
|
{
|
||||||
|
dm->AddDevice(new LinuxKeyboard());
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,11 +19,12 @@
|
||||||
#include "InputManager.h"
|
#include "InputManager.h"
|
||||||
#include "KeyboardQueue.h"
|
#include "KeyboardQueue.h"
|
||||||
|
|
||||||
class LinuxKeyboard : public Device {
|
class LinuxKeyboard : public Device
|
||||||
public:
|
{
|
||||||
LinuxKeyboard();
|
public:
|
||||||
int Activate(InitInfo* args);
|
LinuxKeyboard();
|
||||||
int Update();
|
int Activate(InitInfo *args);
|
||||||
|
int Update();
|
||||||
};
|
};
|
||||||
|
|
||||||
void EnumLnx();
|
void EnumLnx();
|
||||||
|
|
|
@ -32,30 +32,35 @@ static u8 R_lastQueuedEvent = 0;
|
||||||
static u8 R_nextQueuedEvent = 0;
|
static u8 R_nextQueuedEvent = 0;
|
||||||
static keyEvent R_queuedEvents[R_EVENT_QUEUE_LEN];
|
static keyEvent R_queuedEvents[R_EVENT_QUEUE_LEN];
|
||||||
|
|
||||||
void R_QueueKeyEvent(const keyEvent &evt) {
|
void R_QueueKeyEvent(const keyEvent &evt)
|
||||||
std::lock_guard<std::mutex> lock(core_event);
|
|
||||||
|
|
||||||
R_queuedEvents[R_lastQueuedEvent] = evt;
|
|
||||||
R_lastQueuedEvent = (R_lastQueuedEvent + 1) % R_EVENT_QUEUE_LEN;
|
|
||||||
// In case someone has a severe Parkingson's disease
|
|
||||||
assert(R_nextQueuedEvent != R_lastQueuedEvent);
|
|
||||||
}
|
|
||||||
|
|
||||||
int R_GetQueuedKeyEvent(keyEvent *event) {
|
|
||||||
if (R_lastQueuedEvent == R_nextQueuedEvent) return 0;
|
|
||||||
|
|
||||||
std::lock_guard<std::mutex> lock(core_event);
|
|
||||||
*event = R_queuedEvents[R_nextQueuedEvent];
|
|
||||||
R_nextQueuedEvent = (R_nextQueuedEvent + 1) % R_EVENT_QUEUE_LEN;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void R_ClearKeyQueue() {
|
|
||||||
R_lastQueuedEvent = R_nextQueuedEvent;
|
|
||||||
}
|
|
||||||
|
|
||||||
EXPORT_C_(void) PADWriteEvent(keyEvent &evt)
|
|
||||||
{
|
{
|
||||||
R_QueueKeyEvent(evt);
|
std::lock_guard<std::mutex> lock(core_event);
|
||||||
|
|
||||||
|
R_queuedEvents[R_lastQueuedEvent] = evt;
|
||||||
|
R_lastQueuedEvent = (R_lastQueuedEvent + 1) % R_EVENT_QUEUE_LEN;
|
||||||
|
// In case someone has a severe Parkingson's disease
|
||||||
|
assert(R_nextQueuedEvent != R_lastQueuedEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
int R_GetQueuedKeyEvent(keyEvent *event)
|
||||||
|
{
|
||||||
|
if (R_lastQueuedEvent == R_nextQueuedEvent)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
std::lock_guard<std::mutex> lock(core_event);
|
||||||
|
*event = R_queuedEvents[R_nextQueuedEvent];
|
||||||
|
R_nextQueuedEvent = (R_nextQueuedEvent + 1) % R_EVENT_QUEUE_LEN;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void R_ClearKeyQueue()
|
||||||
|
{
|
||||||
|
R_lastQueuedEvent = R_nextQueuedEvent;
|
||||||
|
}
|
||||||
|
|
||||||
|
EXPORT_C_(void)
|
||||||
|
PADWriteEvent(keyEvent &evt)
|
||||||
|
{
|
||||||
|
R_QueueKeyEvent(evt);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -21,20 +21,20 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Number of bits for 1 unsigned char */
|
/* Number of bits for 1 unsigned char */
|
||||||
#define nBitsPerUchar (sizeof(unsigned char) * 8)
|
#define nBitsPerUchar (sizeof(unsigned char) * 8)
|
||||||
|
|
||||||
/* Number of unsigned chars to contain a given number of bits */
|
/* Number of unsigned chars to contain a given number of bits */
|
||||||
#define nUcharsForNBits(nBits) ((((nBits)-1)/nBitsPerUchar)+1)
|
#define nUcharsForNBits(nBits) ((((nBits)-1) / nBitsPerUchar) + 1)
|
||||||
|
|
||||||
/* Index=Offset of given bit in 1 unsigned char */
|
/* Index=Offset of given bit in 1 unsigned char */
|
||||||
#define bitOffsetInUchar(bit) ((bit)%nBitsPerUchar)
|
#define bitOffsetInUchar(bit) ((bit) % nBitsPerUchar)
|
||||||
|
|
||||||
/* Index=Offset of the unsigned char associated to the bit
|
/* Index=Offset of the unsigned char associated to the bit
|
||||||
at the given index=offset */
|
at the given index=offset */
|
||||||
#define ucharIndexForBit(bit) ((bit)/nBitsPerUchar)
|
#define ucharIndexForBit(bit) ((bit) / nBitsPerUchar)
|
||||||
|
|
||||||
/* Value of an unsigned char with bit set at given index=offset */
|
/* Value of an unsigned char with bit set at given index=offset */
|
||||||
#define ucharValueForBit(bit) (((unsigned char)(1))<<bitOffsetInUchar(bit))
|
#define ucharValueForBit(bit) (((unsigned char)(1)) << bitOffsetInUchar(bit))
|
||||||
|
|
||||||
/* Test the bit with given index=offset in an unsigned char array */
|
/* Test the bit with given index=offset in an unsigned char array */
|
||||||
#define testBit(bit, array) ((array[ucharIndexForBit(bit)] >> bitOffsetInUchar(bit)) & 1)
|
#define testBit(bit, array) ((array[ucharIndexForBit(bit)] >> bitOffsetInUchar(bit)) & 1)
|
||||||
|
|
|
@ -26,44 +26,48 @@
|
||||||
|
|
||||||
ExtraWndProcResult RawInputWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *output);
|
ExtraWndProcResult RawInputWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *output);
|
||||||
|
|
||||||
int GetRawKeyboards(HWND hWnd) {
|
int GetRawKeyboards(HWND hWnd)
|
||||||
RAWINPUTDEVICE Rid;
|
{
|
||||||
Rid.hwndTarget = hWnd;
|
RAWINPUTDEVICE Rid;
|
||||||
|
Rid.hwndTarget = hWnd;
|
||||||
|
|
||||||
Rid.dwFlags = 0;
|
Rid.dwFlags = 0;
|
||||||
Rid.usUsagePage = 0x01;
|
Rid.usUsagePage = 0x01;
|
||||||
Rid.usUsage = 0x06;
|
Rid.usUsage = 0x06;
|
||||||
return RegisterRawInputDevices(&Rid, 1, sizeof(Rid));
|
return RegisterRawInputDevices(&Rid, 1, sizeof(Rid));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReleaseRawKeyboards() {
|
void ReleaseRawKeyboards()
|
||||||
RAWINPUTDEVICE Rid;
|
{
|
||||||
Rid.hwndTarget = 0;
|
RAWINPUTDEVICE Rid;
|
||||||
|
Rid.hwndTarget = 0;
|
||||||
|
|
||||||
Rid.dwFlags = RIDEV_REMOVE;
|
Rid.dwFlags = RIDEV_REMOVE;
|
||||||
Rid.usUsagePage = 0x01;
|
Rid.usUsagePage = 0x01;
|
||||||
Rid.usUsage = 0x06;
|
Rid.usUsage = 0x06;
|
||||||
RegisterRawInputDevices(&Rid, 1, sizeof(Rid));
|
RegisterRawInputDevices(&Rid, 1, sizeof(Rid));
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetRawMice(HWND hWnd) {
|
int GetRawMice(HWND hWnd)
|
||||||
RAWINPUTDEVICE Rid;
|
{
|
||||||
Rid.hwndTarget = hWnd;
|
RAWINPUTDEVICE Rid;
|
||||||
|
Rid.hwndTarget = hWnd;
|
||||||
|
|
||||||
Rid.dwFlags = RIDEV_NOLEGACY | RIDEV_CAPTUREMOUSE;
|
Rid.dwFlags = RIDEV_NOLEGACY | RIDEV_CAPTUREMOUSE;
|
||||||
Rid.usUsagePage = 0x01;
|
Rid.usUsagePage = 0x01;
|
||||||
Rid.usUsage = 0x02;
|
Rid.usUsage = 0x02;
|
||||||
return RegisterRawInputDevices(&Rid, 1, sizeof(Rid));
|
return RegisterRawInputDevices(&Rid, 1, sizeof(Rid));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReleaseRawMice() {
|
void ReleaseRawMice()
|
||||||
RAWINPUTDEVICE Rid;
|
{
|
||||||
Rid.hwndTarget = 0;
|
RAWINPUTDEVICE Rid;
|
||||||
|
Rid.hwndTarget = 0;
|
||||||
|
|
||||||
Rid.dwFlags = RIDEV_REMOVE;
|
Rid.dwFlags = RIDEV_REMOVE;
|
||||||
Rid.usUsagePage = 0x01;
|
Rid.usUsagePage = 0x01;
|
||||||
Rid.usUsage = 0x02;
|
Rid.usUsage = 0x02;
|
||||||
RegisterRawInputDevices(&Rid, 1, sizeof(Rid));
|
RegisterRawInputDevices(&Rid, 1, sizeof(Rid));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Count of active raw keyboard devices.
|
// Count of active raw keyboard devices.
|
||||||
|
@ -72,234 +76,256 @@ static int rawKeyboardActivatedCount = 0;
|
||||||
// Same for mice.
|
// Same for mice.
|
||||||
static int rawMouseActivatedCount = 0;
|
static int rawMouseActivatedCount = 0;
|
||||||
|
|
||||||
class RawInputKeyboard : public WindowsKeyboard {
|
class RawInputKeyboard : public WindowsKeyboard
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
HANDLE hDevice;
|
HANDLE hDevice;
|
||||||
|
|
||||||
RawInputKeyboard(HANDLE hDevice, wchar_t *name, wchar_t *instanceID=0) : WindowsKeyboard(RAW, name, instanceID) {
|
RawInputKeyboard(HANDLE hDevice, wchar_t *name, wchar_t *instanceID = 0)
|
||||||
this->hDevice = hDevice;
|
: WindowsKeyboard(RAW, name, instanceID)
|
||||||
}
|
{
|
||||||
|
this->hDevice = hDevice;
|
||||||
|
}
|
||||||
|
|
||||||
int Activate(InitInfo *initInfo) {
|
int Activate(InitInfo *initInfo)
|
||||||
Deactivate();
|
{
|
||||||
|
Deactivate();
|
||||||
|
|
||||||
hWndProc = initInfo->hWndProc;
|
hWndProc = initInfo->hWndProc;
|
||||||
|
|
||||||
active = 1;
|
active = 1;
|
||||||
if (!rawKeyboardActivatedCount++) {
|
if (!rawKeyboardActivatedCount++) {
|
||||||
if (!rawMouseActivatedCount)
|
if (!rawMouseActivatedCount)
|
||||||
hWndProc->Eat(RawInputWndProc, EATPROC_NO_UPDATE_WHILE_UPDATING_DEVICES);
|
hWndProc->Eat(RawInputWndProc, EATPROC_NO_UPDATE_WHILE_UPDATING_DEVICES);
|
||||||
|
|
||||||
if (!GetRawKeyboards(hWndProc->hWndEaten)) {
|
if (!GetRawKeyboards(hWndProc->hWndEaten)) {
|
||||||
Deactivate();
|
Deactivate();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
InitState();
|
InitState();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Deactivate() {
|
void Deactivate()
|
||||||
FreeState();
|
{
|
||||||
if (active) {
|
FreeState();
|
||||||
active = 0;
|
if (active) {
|
||||||
rawKeyboardActivatedCount --;
|
active = 0;
|
||||||
if (!rawKeyboardActivatedCount) {
|
rawKeyboardActivatedCount--;
|
||||||
ReleaseRawKeyboards();
|
if (!rawKeyboardActivatedCount) {
|
||||||
if (!rawMouseActivatedCount)
|
ReleaseRawKeyboards();
|
||||||
hWndProc->ReleaseExtraProc(RawInputWndProc);
|
if (!rawMouseActivatedCount)
|
||||||
}
|
hWndProc->ReleaseExtraProc(RawInputWndProc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class RawInputMouse : public WindowsMouse {
|
class RawInputMouse : public WindowsMouse
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
HANDLE hDevice;
|
HANDLE hDevice;
|
||||||
|
|
||||||
RawInputMouse(HANDLE hDevice, wchar_t *name, wchar_t *instanceID=0, wchar_t *productID=0) : WindowsMouse(RAW, 0, name, instanceID, productID) {
|
RawInputMouse(HANDLE hDevice, wchar_t *name, wchar_t *instanceID = 0, wchar_t *productID = 0)
|
||||||
this->hDevice = hDevice;
|
: WindowsMouse(RAW, 0, name, instanceID, productID)
|
||||||
}
|
{
|
||||||
|
this->hDevice = hDevice;
|
||||||
|
}
|
||||||
|
|
||||||
int Activate(InitInfo *initInfo) {
|
int Activate(InitInfo *initInfo)
|
||||||
Deactivate();
|
{
|
||||||
|
Deactivate();
|
||||||
|
|
||||||
hWndProc = initInfo->hWndProc;
|
hWndProc = initInfo->hWndProc;
|
||||||
|
|
||||||
active = 1;
|
active = 1;
|
||||||
|
|
||||||
// Have to be careful with order. At worst, one unmatched call to ReleaseRawMice on
|
// Have to be careful with order. At worst, one unmatched call to ReleaseRawMice on
|
||||||
// EatWndProc fail. In all other cases, no unmatched initialization/cleanup
|
// EatWndProc fail. In all other cases, no unmatched initialization/cleanup
|
||||||
// lines.
|
// lines.
|
||||||
if (!rawMouseActivatedCount++) {
|
if (!rawMouseActivatedCount++) {
|
||||||
GetMouseCapture(hWndProc->hWndEaten);
|
GetMouseCapture(hWndProc->hWndEaten);
|
||||||
if (!rawKeyboardActivatedCount)
|
if (!rawKeyboardActivatedCount)
|
||||||
hWndProc->Eat(RawInputWndProc, EATPROC_NO_UPDATE_WHILE_UPDATING_DEVICES);
|
hWndProc->Eat(RawInputWndProc, EATPROC_NO_UPDATE_WHILE_UPDATING_DEVICES);
|
||||||
|
|
||||||
if (!GetRawMice(hWndProc->hWndEaten)) {
|
if (!GetRawMice(hWndProc->hWndEaten)) {
|
||||||
Deactivate();
|
Deactivate();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AllocState();
|
AllocState();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Deactivate() {
|
void Deactivate()
|
||||||
FreeState();
|
{
|
||||||
if (active) {
|
FreeState();
|
||||||
active = 0;
|
if (active) {
|
||||||
rawMouseActivatedCount --;
|
active = 0;
|
||||||
if (!rawMouseActivatedCount) {
|
rawMouseActivatedCount--;
|
||||||
ReleaseRawMice();
|
if (!rawMouseActivatedCount) {
|
||||||
ReleaseMouseCapture();
|
ReleaseRawMice();
|
||||||
if (!rawKeyboardActivatedCount) {
|
ReleaseMouseCapture();
|
||||||
hWndProc->ReleaseExtraProc(RawInputWndProc);
|
if (!rawKeyboardActivatedCount) {
|
||||||
}
|
hWndProc->ReleaseExtraProc(RawInputWndProc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ExtraWndProcResult RawInputWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *output) {
|
ExtraWndProcResult RawInputWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *output)
|
||||||
if (uMsg == WM_INPUT) {
|
{
|
||||||
if (GET_RAWINPUT_CODE_WPARAM (wParam) == RIM_INPUT) {
|
if (uMsg == WM_INPUT) {
|
||||||
RAWINPUT in;
|
if (GET_RAWINPUT_CODE_WPARAM(wParam) == RIM_INPUT) {
|
||||||
unsigned int size = sizeof(RAWINPUT);
|
RAWINPUT in;
|
||||||
if (GetRawInputData((HRAWINPUT)lParam, RID_INPUT, &in, &size, sizeof(RAWINPUTHEADER)) > 0) {
|
unsigned int size = sizeof(RAWINPUT);
|
||||||
for (int i=0; i<dm->numDevices; i++) {
|
if (GetRawInputData((HRAWINPUT)lParam, RID_INPUT, &in, &size, sizeof(RAWINPUTHEADER)) > 0) {
|
||||||
Device *dev = dm->devices[i];
|
for (int i = 0; i < dm->numDevices; i++) {
|
||||||
if (dev->api != RAW || !dev->active) continue;
|
Device *dev = dm->devices[i];
|
||||||
if (in.header.dwType == RIM_TYPEKEYBOARD && dev->type == KEYBOARD) {
|
if (dev->api != RAW || !dev->active)
|
||||||
RawInputKeyboard* rik = (RawInputKeyboard*)dev;
|
continue;
|
||||||
if (rik->hDevice != in.header.hDevice) continue;
|
if (in.header.dwType == RIM_TYPEKEYBOARD && dev->type == KEYBOARD) {
|
||||||
|
RawInputKeyboard *rik = (RawInputKeyboard *)dev;
|
||||||
|
if (rik->hDevice != in.header.hDevice)
|
||||||
|
continue;
|
||||||
|
|
||||||
u32 uMsg = in.data.keyboard.Message;
|
u32 uMsg = in.data.keyboard.Message;
|
||||||
if (!(in.data.keyboard.VKey>>8))
|
if (!(in.data.keyboard.VKey >> 8))
|
||||||
rik->UpdateKey((u8) in.data.keyboard.VKey, (uMsg == WM_KEYDOWN || uMsg == WM_SYSKEYDOWN));
|
rik->UpdateKey((u8)in.data.keyboard.VKey, (uMsg == WM_KEYDOWN || uMsg == WM_SYSKEYDOWN));
|
||||||
}
|
} else if (in.header.dwType == RIM_TYPEMOUSE && dev->type == MOUSE) {
|
||||||
else if (in.header.dwType == RIM_TYPEMOUSE && dev->type == MOUSE) {
|
RawInputMouse *rim = (RawInputMouse *)dev;
|
||||||
RawInputMouse* rim = (RawInputMouse*)dev;
|
if (rim->hDevice != in.header.hDevice)
|
||||||
if (rim->hDevice != in.header.hDevice) continue;
|
continue;
|
||||||
if (in.data.mouse.usFlags) {
|
if (in.data.mouse.usFlags) {
|
||||||
// Never been set for me, and specs on what most of them
|
// Never been set for me, and specs on what most of them
|
||||||
// actually mean is sorely lacking. Also, specs erroneously
|
// actually mean is sorely lacking. Also, specs erroneously
|
||||||
// indicate MOUSE_MOVE_RELATIVE is a flag, when it's really
|
// indicate MOUSE_MOVE_RELATIVE is a flag, when it's really
|
||||||
// 0...
|
// 0...
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned short buttons = in.data.mouse.usButtonFlags & 0x3FF;
|
unsigned short buttons = in.data.mouse.usButtonFlags & 0x3FF;
|
||||||
int button = 0;
|
int button = 0;
|
||||||
while (buttons) {
|
while (buttons) {
|
||||||
if (buttons & 3) {
|
if (buttons & 3) {
|
||||||
// 2 is up, 1 is down. Up takes precedence over down.
|
// 2 is up, 1 is down. Up takes precedence over down.
|
||||||
rim->UpdateButton(button, !(buttons & 2));
|
rim->UpdateButton(button, !(buttons & 2));
|
||||||
}
|
}
|
||||||
button++;
|
button++;
|
||||||
buttons >>= 2;
|
buttons >>= 2;
|
||||||
}
|
}
|
||||||
if (in.data.mouse.usButtonFlags & RI_MOUSE_WHEEL) {
|
if (in.data.mouse.usButtonFlags & RI_MOUSE_WHEEL) {
|
||||||
rim->UpdateAxis(2, ((short)in.data.mouse.usButtonData)/WHEEL_DELTA);
|
rim->UpdateAxis(2, ((short)in.data.mouse.usButtonData) / WHEEL_DELTA);
|
||||||
}
|
}
|
||||||
if (in.data.mouse.lLastX || in.data.mouse.lLastY) {
|
if (in.data.mouse.lLastX || in.data.mouse.lLastY) {
|
||||||
rim->UpdateAxis(0, in.data.mouse.lLastX);
|
rim->UpdateAxis(0, in.data.mouse.lLastX);
|
||||||
rim->UpdateAxis(1, in.data.mouse.lLastY);
|
rim->UpdateAxis(1, in.data.mouse.lLastY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else if (uMsg == WM_ACTIVATE) {
|
||||||
else if (uMsg == WM_ACTIVATE) {
|
for (int i = 0; i < dm->numDevices; i++) {
|
||||||
for (int i=0; i<dm->numDevices; i++) {
|
Device *dev = dm->devices[i];
|
||||||
Device *dev = dm->devices[i];
|
if (dev->api != RAW || dev->physicalControlState == 0)
|
||||||
if (dev->api != RAW || dev->physicalControlState == 0) continue;
|
continue;
|
||||||
memset(dev->physicalControlState, 0, sizeof(int) * dev->numPhysicalControls);
|
memset(dev->physicalControlState, 0, sizeof(int) * dev->numPhysicalControls);
|
||||||
}
|
}
|
||||||
}
|
} else if (uMsg == WM_SIZE && rawMouseActivatedCount) {
|
||||||
else if (uMsg == WM_SIZE && rawMouseActivatedCount) {
|
// Doesn't really matter for raw mice, as I disable legacy stuff, but shouldn't hurt.
|
||||||
// Doesn't really matter for raw mice, as I disable legacy stuff, but shouldn't hurt.
|
WindowsMouse::WindowResized(hWnd);
|
||||||
WindowsMouse::WindowResized(hWnd);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return CONTINUE_BLISSFULLY;
|
return CONTINUE_BLISSFULLY;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EnumRawInputDevices() {
|
void EnumRawInputDevices()
|
||||||
int count = 0;
|
{
|
||||||
if (GetRawInputDeviceList(0, (unsigned int*)&count, sizeof(RAWINPUTDEVICELIST)) != (UINT)-1 && count > 0) {
|
int count = 0;
|
||||||
wchar_t *instanceID = (wchar_t *) malloc(41000*sizeof(wchar_t));
|
if (GetRawInputDeviceList(0, (unsigned int *)&count, sizeof(RAWINPUTDEVICELIST)) != (UINT)-1 && count > 0) {
|
||||||
wchar_t *keyName = instanceID + 11000;
|
wchar_t *instanceID = (wchar_t *)malloc(41000 * sizeof(wchar_t));
|
||||||
wchar_t *displayName = keyName + 10000;
|
wchar_t *keyName = instanceID + 11000;
|
||||||
wchar_t *productID = displayName + 10000;
|
wchar_t *displayName = keyName + 10000;
|
||||||
|
wchar_t *productID = displayName + 10000;
|
||||||
|
|
||||||
RAWINPUTDEVICELIST *list = (RAWINPUTDEVICELIST*) malloc(sizeof(RAWINPUTDEVICELIST) * count);
|
RAWINPUTDEVICELIST *list = (RAWINPUTDEVICELIST *)malloc(sizeof(RAWINPUTDEVICELIST) * count);
|
||||||
int keyboardCount = 1;
|
int keyboardCount = 1;
|
||||||
int mouseCount = 1;
|
int mouseCount = 1;
|
||||||
count = GetRawInputDeviceList(list, (unsigned int*)&count, sizeof(RAWINPUTDEVICELIST));
|
count = GetRawInputDeviceList(list, (unsigned int *)&count, sizeof(RAWINPUTDEVICELIST));
|
||||||
|
|
||||||
// Not necessary, but reminder that count is -1 on failure.
|
// Not necessary, but reminder that count is -1 on failure.
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
for (int i=0; i<count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
if (list[i].dwType != RIM_TYPEKEYBOARD && list[i].dwType != RIM_TYPEMOUSE) continue;
|
if (list[i].dwType != RIM_TYPEKEYBOARD && list[i].dwType != RIM_TYPEMOUSE)
|
||||||
|
continue;
|
||||||
|
|
||||||
UINT bufferLen = 10000;
|
UINT bufferLen = 10000;
|
||||||
int nameLen = GetRawInputDeviceInfo(list[i].hDevice, RIDI_DEVICENAME, instanceID, &bufferLen);
|
int nameLen = GetRawInputDeviceInfo(list[i].hDevice, RIDI_DEVICENAME, instanceID, &bufferLen);
|
||||||
if (nameLen >= 4) {
|
if (nameLen >= 4) {
|
||||||
// nameLen includes terminating null.
|
// nameLen includes terminating null.
|
||||||
nameLen--;
|
nameLen--;
|
||||||
|
|
||||||
// Strip out GUID parts of instanceID to make it a generic product id,
|
// Strip out GUID parts of instanceID to make it a generic product id,
|
||||||
// and reformat it to point to registry entry containing device description.
|
// and reformat it to point to registry entry containing device description.
|
||||||
wcscpy(productID, instanceID);
|
wcscpy(productID, instanceID);
|
||||||
wchar_t *temp = 0;
|
wchar_t *temp = 0;
|
||||||
for (int j=0; j<3; j++) {
|
for (int j = 0; j < 3; j++) {
|
||||||
wchar_t *s = wcschr(productID, '#');
|
wchar_t *s = wcschr(productID, '#');
|
||||||
if (!s) break;
|
if (!s)
|
||||||
*s = '\\';
|
break;
|
||||||
if (j==2) {
|
*s = '\\';
|
||||||
*s = 0;
|
if (j == 2) {
|
||||||
}
|
*s = 0;
|
||||||
if (j==1) temp = s;
|
}
|
||||||
}
|
if (j == 1)
|
||||||
|
temp = s;
|
||||||
|
}
|
||||||
|
|
||||||
wsprintfW(keyName, L"SYSTEM\\CurrentControlSet\\Enum%s", productID+3);
|
wsprintfW(keyName, L"SYSTEM\\CurrentControlSet\\Enum%s", productID + 3);
|
||||||
if (temp) *temp = 0;
|
if (temp)
|
||||||
int haveDescription = 0;
|
*temp = 0;
|
||||||
HKEY hKey;
|
int haveDescription = 0;
|
||||||
if (ERROR_SUCCESS == RegOpenKeyExW(HKEY_LOCAL_MACHINE, keyName, 0, KEY_QUERY_VALUE, &hKey)) {
|
HKEY hKey;
|
||||||
DWORD type;
|
if (ERROR_SUCCESS == RegOpenKeyExW(HKEY_LOCAL_MACHINE, keyName, 0, KEY_QUERY_VALUE, &hKey)) {
|
||||||
DWORD len = 10000 * sizeof(wchar_t);
|
DWORD type;
|
||||||
if (ERROR_SUCCESS == RegQueryValueExW(hKey, L"DeviceDesc", 0, &type, (BYTE*)displayName, &len) &&
|
DWORD len = 10000 * sizeof(wchar_t);
|
||||||
len && type == REG_SZ) {
|
if (ERROR_SUCCESS == RegQueryValueExW(hKey, L"DeviceDesc", 0, &type, (BYTE *)displayName, &len) &&
|
||||||
wchar_t *temp2 = wcsrchr(displayName, ';');
|
len && type == REG_SZ) {
|
||||||
if (!temp2) temp2 = displayName;
|
wchar_t *temp2 = wcsrchr(displayName, ';');
|
||||||
else temp2++;
|
if (!temp2)
|
||||||
// Could do without this, but more effort than it's worth.
|
temp2 = displayName;
|
||||||
wcscpy(keyName, temp2);
|
else
|
||||||
haveDescription = 1;
|
temp2++;
|
||||||
}
|
// Could do without this, but more effort than it's worth.
|
||||||
RegCloseKey(hKey);
|
wcscpy(keyName, temp2);
|
||||||
}
|
haveDescription = 1;
|
||||||
if (list[i].dwType == RIM_TYPEKEYBOARD) {
|
}
|
||||||
if (!haveDescription) wsprintfW(displayName, L"Raw Keyboard %i", keyboardCount++);
|
RegCloseKey(hKey);
|
||||||
else wsprintfW(displayName, L"Raw KB: %s", keyName);
|
}
|
||||||
dm->AddDevice(new RawInputKeyboard(list[i].hDevice, displayName, instanceID));
|
if (list[i].dwType == RIM_TYPEKEYBOARD) {
|
||||||
}
|
if (!haveDescription)
|
||||||
else if (list[i].dwType == RIM_TYPEMOUSE) {
|
wsprintfW(displayName, L"Raw Keyboard %i", keyboardCount++);
|
||||||
if (!haveDescription) wsprintfW(displayName, L"Raw Mouse %i", mouseCount++);
|
else
|
||||||
else wsprintfW(displayName, L"Raw MS: %s", keyName);
|
wsprintfW(displayName, L"Raw KB: %s", keyName);
|
||||||
dm->AddDevice(new RawInputMouse(list[i].hDevice, displayName, instanceID, productID));
|
dm->AddDevice(new RawInputKeyboard(list[i].hDevice, displayName, instanceID));
|
||||||
}
|
} else if (list[i].dwType == RIM_TYPEMOUSE) {
|
||||||
}
|
if (!haveDescription)
|
||||||
}
|
wsprintfW(displayName, L"Raw Mouse %i", mouseCount++);
|
||||||
}
|
else
|
||||||
free(list);
|
wsprintfW(displayName, L"Raw MS: %s", keyName);
|
||||||
free(instanceID);
|
dm->AddDevice(new RawInputMouse(list[i].hDevice, displayName, instanceID, productID));
|
||||||
dm->AddDevice(new RawInputKeyboard(0, L"Simulated Keyboard"));
|
}
|
||||||
dm->AddDevice(new RawInputMouse(0, L"Simulated Mouse"));
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
free(list);
|
||||||
|
free(instanceID);
|
||||||
|
dm->AddDevice(new RawInputKeyboard(0, L"Simulated Keyboard"));
|
||||||
|
dm->AddDevice(new RawInputMouse(0, L"Simulated Mouse"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,68 +18,91 @@
|
||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
#include "VKey.h"
|
#include "VKey.h"
|
||||||
|
|
||||||
wchar_t *GetVKStringW(unsigned char vk) {
|
wchar_t *GetVKStringW(unsigned char vk)
|
||||||
int flag;
|
{
|
||||||
static wchar_t t[20];
|
int flag;
|
||||||
switch(vk) {
|
static wchar_t t[20];
|
||||||
case 0x0C: return L"Clear";
|
switch (vk) {
|
||||||
case 0x13: return L"Pause";
|
case 0x0C:
|
||||||
|
return L"Clear";
|
||||||
|
case 0x13:
|
||||||
|
return L"Pause";
|
||||||
|
|
||||||
case 0x21:// return "Page Up";
|
case 0x21: // return "Page Up";
|
||||||
case 0x22:// return "Page Down";
|
case 0x22: // return "Page Down";
|
||||||
case 0x23:// return "End";
|
case 0x23: // return "End";
|
||||||
case 0x24:// return "Home";
|
case 0x24: // return "Home";
|
||||||
case 0x25:// return "Left";
|
case 0x25: // return "Left";
|
||||||
case 0x26:// return "Up";
|
case 0x26: // return "Up";
|
||||||
case 0x27:// return "Right";
|
case 0x27: // return "Right";
|
||||||
case 0x28:// return "Down";
|
case 0x28: // return "Down";
|
||||||
case 0x2D:// return "Insert";
|
case 0x2D: // return "Insert";
|
||||||
case 0x2E:// return "Delete";
|
case 0x2E: // return "Delete";
|
||||||
case 0x5B:// return "Left Windows";
|
case 0x5B: // return "Left Windows";
|
||||||
case 0x5C:// return "Right Windows";
|
case 0x5C: // return "Right Windows";
|
||||||
case 0x5D:// return "Application";
|
case 0x5D: // return "Application";
|
||||||
case 0x6F:// return "Num /";
|
case 0x6F: // return "Num /";
|
||||||
flag = 1<<24;
|
flag = 1 << 24;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x29: return L"Select";
|
case 0x29:
|
||||||
case 0x2A: return L"Print";
|
return L"Select";
|
||||||
case 0x2B: return L"Execute";
|
case 0x2A:
|
||||||
case 0x2C: return L"Prnt Scrn";
|
return L"Print";
|
||||||
case 0x2F: return L"Help";
|
case 0x2B:
|
||||||
|
return L"Execute";
|
||||||
|
case 0x2C:
|
||||||
|
return L"Prnt Scrn";
|
||||||
|
case 0x2F:
|
||||||
|
return L"Help";
|
||||||
|
|
||||||
case 0x6C: return L"|";
|
case 0x6C:
|
||||||
case 0x90: return L"Num Lock";
|
return L"|";
|
||||||
|
case 0x90:
|
||||||
|
return L"Num Lock";
|
||||||
|
|
||||||
case 0xA0: return L"Left Shift";
|
case 0xA0:
|
||||||
case 0xA1: return L"Right Shift";
|
return L"Left Shift";
|
||||||
case 0xA2: return L"Left Ctrl";
|
case 0xA1:
|
||||||
case 0xA3: return L"Right Ctrl";
|
return L"Right Shift";
|
||||||
case 0xA4: return L"Left Alt";
|
case 0xA2:
|
||||||
case 0xA5: return L"Right Alt";
|
return L"Left Ctrl";
|
||||||
|
case 0xA3:
|
||||||
|
return L"Right Ctrl";
|
||||||
|
case 0xA4:
|
||||||
|
return L"Left Alt";
|
||||||
|
case 0xA5:
|
||||||
|
return L"Right Alt";
|
||||||
|
|
||||||
case 0xA6: return L"Back";
|
case 0xA6:
|
||||||
case 0xA7: return L"Forward";
|
return L"Back";
|
||||||
case 0xA8: return L"Refresh";
|
case 0xA7:
|
||||||
case 0xA9: return L"Stop";
|
return L"Forward";
|
||||||
case 0xAA: return L"Search";
|
case 0xA8:
|
||||||
case 0xAB: return L"Favorites";
|
return L"Refresh";
|
||||||
case 0xAC: return L"Browser";
|
case 0xA9:
|
||||||
|
return L"Stop";
|
||||||
|
case 0xAA:
|
||||||
|
return L"Search";
|
||||||
|
case 0xAB:
|
||||||
|
return L"Favorites";
|
||||||
|
case 0xAC:
|
||||||
|
return L"Browser";
|
||||||
|
|
||||||
case 0xFA: return L"Play";
|
case 0xFA:
|
||||||
case 0xFB: return L"Zoom";
|
return L"Play";
|
||||||
default:
|
case 0xFB:
|
||||||
flag = 0;
|
return L"Zoom";
|
||||||
break;
|
default:
|
||||||
}
|
flag = 0;
|
||||||
int res = MapVirtualKey(vk, MAPVK_VK_TO_VSC);
|
break;
|
||||||
if (res && GetKeyNameText((res<<16) | flag, t, 20)) {
|
}
|
||||||
// don't trust windows
|
int res = MapVirtualKey(vk, MAPVK_VK_TO_VSC);
|
||||||
t[19] = 0;
|
if (res && GetKeyNameText((res << 16) | flag, t, 20)) {
|
||||||
}
|
// don't trust windows
|
||||||
else {
|
t[19] = 0;
|
||||||
wsprintfW(t, L"Key %i", vk);
|
} else {
|
||||||
}
|
wsprintfW(t, L"Key %i", vk);
|
||||||
return t;
|
}
|
||||||
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,45 +21,51 @@
|
||||||
#include "WindowsKeyboard.h"
|
#include "WindowsKeyboard.h"
|
||||||
#include "KeyboardQueue.h"
|
#include "KeyboardQueue.h"
|
||||||
|
|
||||||
WindowsKeyboard::WindowsKeyboard(DeviceAPI api, wchar_t *displayName, wchar_t *instanceID, wchar_t *deviceID) :
|
WindowsKeyboard::WindowsKeyboard(DeviceAPI api, wchar_t *displayName, wchar_t *instanceID, wchar_t *deviceID)
|
||||||
Device(api, KEYBOARD, displayName, instanceID, deviceID) {
|
: Device(api, KEYBOARD, displayName, instanceID, deviceID)
|
||||||
for (int i=0; i<256; i++) {
|
{
|
||||||
AddPhysicalControl(PSHBTN, i, i);
|
for (int i = 0; i < 256; i++) {
|
||||||
}
|
AddPhysicalControl(PSHBTN, i, i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wchar_t *WindowsKeyboard::GetPhysicalControlName(PhysicalControl *control) {
|
wchar_t *WindowsKeyboard::GetPhysicalControlName(PhysicalControl *control)
|
||||||
int id = control->id;
|
{
|
||||||
if (control->type == PSHBTN && id >= 0 && id < 256) {
|
int id = control->id;
|
||||||
wchar_t *w = GetVKStringW(id);
|
if (control->type == PSHBTN && id >= 0 && id < 256) {
|
||||||
if (w) return w;
|
wchar_t *w = GetVKStringW(id);
|
||||||
}
|
if (w)
|
||||||
return Device::GetPhysicalControlName(control);
|
return w;
|
||||||
|
}
|
||||||
|
return Device::GetPhysicalControlName(control);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowsKeyboard::UpdateKey(int vkey, int state) {
|
void WindowsKeyboard::UpdateKey(int vkey, int state)
|
||||||
if (vkey > 7 && vkey < 256) {
|
{
|
||||||
int newState = state * FULLY_DOWN;
|
if (vkey > 7 && vkey < 256) {
|
||||||
if (newState != physicalControlState[vkey]) {
|
int newState = state * FULLY_DOWN;
|
||||||
// Check for alt-F4 to avoid toggling skip mode incorrectly.
|
if (newState != physicalControlState[vkey]) {
|
||||||
if (vkey != VK_F4 || !(physicalControlState[VK_MENU] || physicalControlState[VK_RMENU] || physicalControlState[VK_LMENU])) {
|
// Check for alt-F4 to avoid toggling skip mode incorrectly.
|
||||||
int event = KEYPRESS;
|
if (vkey != VK_F4 || !(physicalControlState[VK_MENU] || physicalControlState[VK_RMENU] || physicalControlState[VK_LMENU])) {
|
||||||
if (!newState) event = KEYRELEASE;
|
int event = KEYPRESS;
|
||||||
QueueKeyEvent(vkey, event);
|
if (!newState)
|
||||||
}
|
event = KEYRELEASE;
|
||||||
}
|
QueueKeyEvent(vkey, event);
|
||||||
physicalControlState[vkey] = newState;
|
}
|
||||||
}
|
}
|
||||||
|
physicalControlState[vkey] = newState;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowsKeyboard::InitState() {
|
void WindowsKeyboard::InitState()
|
||||||
AllocState();
|
{
|
||||||
for (int vkey=5; vkey<256; vkey++) {
|
AllocState();
|
||||||
int value = (unsigned short)(((short)GetAsyncKeyState(vkey))>>15);
|
for (int vkey = 5; vkey < 256; vkey++) {
|
||||||
value += value&1;
|
int value = (unsigned short)(((short)GetAsyncKeyState(vkey)) >> 15);
|
||||||
if (vkey == VK_CONTROL || vkey == VK_MENU || vkey == VK_SHIFT) {
|
value += value & 1;
|
||||||
value = 0;
|
if (vkey == VK_CONTROL || vkey == VK_MENU || vkey == VK_SHIFT) {
|
||||||
}
|
value = 0;
|
||||||
physicalControlState[vkey] = value;
|
}
|
||||||
}
|
physicalControlState[vkey] = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,12 +16,13 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Shared functionality for WM and RAW keyboards.
|
// Shared functionality for WM and RAW keyboards.
|
||||||
class WindowsKeyboard : public Device {
|
class WindowsKeyboard : public Device
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
WindowsKeyboard(DeviceAPI api, wchar_t *displayName, wchar_t *instanceID=0, wchar_t *deviceID=0);
|
WindowsKeyboard(DeviceAPI api, wchar_t *displayName, wchar_t *instanceID = 0, wchar_t *deviceID = 0);
|
||||||
wchar_t *GetPhysicalControlName(PhysicalControl *control);
|
wchar_t *GetPhysicalControlName(PhysicalControl *control);
|
||||||
void UpdateKey(int vkey, int state);
|
void UpdateKey(int vkey, int state);
|
||||||
// Calls AllocState() and initializes to current keyboard state using
|
// Calls AllocState() and initializes to current keyboard state using
|
||||||
// GetAsyncKeyState().
|
// GetAsyncKeyState().
|
||||||
void InitState();
|
void InitState();
|
||||||
};
|
};
|
||||||
|
|
|
@ -32,160 +32,162 @@ class WindowsMessagingMouse;
|
||||||
static WindowsMessagingKeyboard *wmk = 0;
|
static WindowsMessagingKeyboard *wmk = 0;
|
||||||
static WindowsMessagingMouse *wmm = 0;
|
static WindowsMessagingMouse *wmm = 0;
|
||||||
|
|
||||||
class WindowsMessagingKeyboard : public WindowsKeyboard {
|
class WindowsMessagingKeyboard : public WindowsKeyboard
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
|
WindowsMessagingKeyboard()
|
||||||
|
: WindowsKeyboard(WM, L"WM Keyboard")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
WindowsMessagingKeyboard() : WindowsKeyboard(WM, L"WM Keyboard") {
|
int Activate(InitInfo *initInfo)
|
||||||
}
|
{
|
||||||
|
// Redundant. Should match the next line.
|
||||||
|
// Deactivate();
|
||||||
|
if (wmk)
|
||||||
|
wmk->Deactivate();
|
||||||
|
|
||||||
int Activate(InitInfo *initInfo) {
|
hWndProc = initInfo->hWndProc;
|
||||||
// Redundant. Should match the next line.
|
|
||||||
// Deactivate();
|
|
||||||
if (wmk) wmk->Deactivate();
|
|
||||||
|
|
||||||
hWndProc = initInfo->hWndProc;
|
if (!wmm)
|
||||||
|
hWndProc->Eat(WindowsMessagingWndProc, EATPROC_NO_UPDATE_WHILE_UPDATING_DEVICES);
|
||||||
|
|
||||||
if (!wmm)
|
wmk = this;
|
||||||
hWndProc->Eat(WindowsMessagingWndProc, EATPROC_NO_UPDATE_WHILE_UPDATING_DEVICES);
|
InitState();
|
||||||
|
|
||||||
wmk = this;
|
active = 1;
|
||||||
InitState();
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
active = 1;
|
void Deactivate()
|
||||||
return 1;
|
{
|
||||||
}
|
if (active) {
|
||||||
|
if (!wmm)
|
||||||
void Deactivate() {
|
hWndProc->ReleaseExtraProc(WindowsMessagingWndProc);
|
||||||
if (active) {
|
wmk = 0;
|
||||||
if (!wmm)
|
active = 0;
|
||||||
hWndProc->ReleaseExtraProc(WindowsMessagingWndProc);
|
FreeState();
|
||||||
wmk = 0;
|
}
|
||||||
active = 0;
|
}
|
||||||
FreeState();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void CheckKey(int vkey) {
|
void CheckKey(int vkey)
|
||||||
UpdateKey(vkey, 1&(((unsigned short)GetAsyncKeyState(vkey))>>15));
|
{
|
||||||
}
|
UpdateKey(vkey, 1 & (((unsigned short)GetAsyncKeyState(vkey)) >> 15));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class WindowsMessagingMouse : public WindowsMouse {
|
class WindowsMessagingMouse : public WindowsMouse
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
|
WindowsMessagingMouse()
|
||||||
|
: WindowsMouse(WM, 1, L"WM Mouse")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
WindowsMessagingMouse() : WindowsMouse(WM, 1, L"WM Mouse") {
|
int Activate(InitInfo *initInfo)
|
||||||
}
|
{
|
||||||
|
// Redundant. Should match the next line.
|
||||||
|
// Deactivate();
|
||||||
|
if (wmm)
|
||||||
|
wmm->Deactivate();
|
||||||
|
hWndProc = initInfo->hWndProc;
|
||||||
|
|
||||||
int Activate(InitInfo *initInfo) {
|
if (!wmk)
|
||||||
// Redundant. Should match the next line.
|
hWndProc->Eat(WindowsMessagingWndProc, EATPROC_NO_UPDATE_WHILE_UPDATING_DEVICES);
|
||||||
// Deactivate();
|
|
||||||
if (wmm) wmm->Deactivate();
|
|
||||||
hWndProc = initInfo->hWndProc;
|
|
||||||
|
|
||||||
if (!wmk)
|
GetMouseCapture(hWndProc->hWndEaten);
|
||||||
hWndProc->Eat(WindowsMessagingWndProc, EATPROC_NO_UPDATE_WHILE_UPDATING_DEVICES);
|
|
||||||
|
|
||||||
GetMouseCapture(hWndProc->hWndEaten);
|
active = 1;
|
||||||
|
|
||||||
active = 1;
|
wmm = this;
|
||||||
|
AllocState();
|
||||||
|
|
||||||
wmm = this;
|
return 1;
|
||||||
AllocState();
|
}
|
||||||
|
|
||||||
return 1;
|
void Deactivate()
|
||||||
}
|
{
|
||||||
|
if (active) {
|
||||||
void Deactivate() {
|
if (!wmk)
|
||||||
if (active) {
|
hWndProc->ReleaseExtraProc(WindowsMessagingWndProc);
|
||||||
if (!wmk)
|
ReleaseMouseCapture();
|
||||||
hWndProc->ReleaseExtraProc(WindowsMessagingWndProc);
|
wmm = 0;
|
||||||
ReleaseMouseCapture();
|
active = 0;
|
||||||
wmm = 0;
|
FreeState();
|
||||||
active = 0;
|
}
|
||||||
FreeState();
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
ExtraWndProcResult WindowsMessagingWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *output) {
|
ExtraWndProcResult WindowsMessagingWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *output)
|
||||||
if (wmk) {
|
{
|
||||||
if (uMsg == WM_KEYDOWN || uMsg == WM_SYSKEYDOWN || uMsg == WM_KEYUP || uMsg == WM_SYSKEYUP) {
|
if (wmk) {
|
||||||
if (wParam == VK_SHIFT) {
|
if (uMsg == WM_KEYDOWN || uMsg == WM_SYSKEYDOWN || uMsg == WM_KEYUP || uMsg == WM_SYSKEYUP) {
|
||||||
wmk->CheckKey(VK_RSHIFT);
|
if (wParam == VK_SHIFT) {
|
||||||
wmk->CheckKey(VK_LSHIFT);
|
wmk->CheckKey(VK_RSHIFT);
|
||||||
}
|
wmk->CheckKey(VK_LSHIFT);
|
||||||
else if (wParam == VK_CONTROL) {
|
} else if (wParam == VK_CONTROL) {
|
||||||
wmk->CheckKey(VK_RCONTROL);
|
wmk->CheckKey(VK_RCONTROL);
|
||||||
wmk->CheckKey(VK_LCONTROL);
|
wmk->CheckKey(VK_LCONTROL);
|
||||||
}
|
} else if (wParam == VK_MENU) {
|
||||||
else if (wParam == VK_MENU) {
|
wmk->CheckKey(VK_RMENU);
|
||||||
wmk->CheckKey(VK_RMENU);
|
wmk->CheckKey(VK_LMENU);
|
||||||
wmk->CheckKey(VK_LMENU);
|
} else
|
||||||
}
|
wmk->UpdateKey(wParam, (uMsg == WM_KEYDOWN || uMsg == WM_SYSKEYDOWN));
|
||||||
else
|
return NO_WND_PROC;
|
||||||
wmk->UpdateKey(wParam, (uMsg == WM_KEYDOWN || uMsg == WM_SYSKEYDOWN));
|
}
|
||||||
return NO_WND_PROC;
|
// Needed to prevent default handling of keys in some situations.
|
||||||
}
|
else if (uMsg == WM_CHAR || uMsg == WM_UNICHAR) {
|
||||||
// Needed to prevent default handling of keys in some situations.
|
return NO_WND_PROC;
|
||||||
else if (uMsg == WM_CHAR || uMsg == WM_UNICHAR) {
|
} else if (uMsg == WM_ACTIVATE) {
|
||||||
return NO_WND_PROC;
|
// Not really needed, but doesn't hurt.
|
||||||
}
|
memset(wmk->physicalControlState, 0, sizeof(int) * wmk->numPhysicalControls);
|
||||||
else if (uMsg == WM_ACTIVATE) {
|
}
|
||||||
// Not really needed, but doesn't hurt.
|
}
|
||||||
memset(wmk->physicalControlState, 0, sizeof(int) * wmk->numPhysicalControls);
|
if (wmm) {
|
||||||
}
|
if (uMsg == WM_MOUSEMOVE) {
|
||||||
}
|
POINT p;
|
||||||
if (wmm) {
|
GetCursorPos(&p);
|
||||||
if (uMsg == WM_MOUSEMOVE) {
|
// Need check to prevent cursor movement cascade.
|
||||||
POINT p;
|
if (p.x != wmm->center.x || p.y != wmm->center.y) {
|
||||||
GetCursorPos(&p);
|
wmm->UpdateAxis(0, p.x - wmm->center.x);
|
||||||
// Need check to prevent cursor movement cascade.
|
wmm->UpdateAxis(1, p.y - wmm->center.y);
|
||||||
if (p.x != wmm->center.x || p.y != wmm->center.y) {
|
|
||||||
wmm->UpdateAxis(0, p.x - wmm->center.x);
|
|
||||||
wmm->UpdateAxis(1, p.y - wmm->center.y);
|
|
||||||
|
|
||||||
SetCursorPos(wmm->center.x, wmm->center.y);
|
SetCursorPos(wmm->center.x, wmm->center.y);
|
||||||
}
|
}
|
||||||
return NO_WND_PROC;
|
return NO_WND_PROC;
|
||||||
}
|
} else if (uMsg == WM_LBUTTONDOWN || uMsg == WM_LBUTTONUP) {
|
||||||
else if (uMsg == WM_LBUTTONDOWN || uMsg == WM_LBUTTONUP) {
|
wmm->UpdateButton(0, uMsg == WM_LBUTTONDOWN);
|
||||||
wmm->UpdateButton(0, uMsg == WM_LBUTTONDOWN);
|
return NO_WND_PROC;
|
||||||
return NO_WND_PROC;
|
} else if (uMsg == WM_RBUTTONDOWN || uMsg == WM_RBUTTONUP) {
|
||||||
}
|
wmm->UpdateButton(1, uMsg == WM_RBUTTONDOWN);
|
||||||
else if (uMsg == WM_RBUTTONDOWN || uMsg == WM_RBUTTONUP) {
|
return NO_WND_PROC;
|
||||||
wmm->UpdateButton(1, uMsg == WM_RBUTTONDOWN);
|
} else if (uMsg == WM_MBUTTONDOWN || uMsg == WM_MBUTTONUP) {
|
||||||
return NO_WND_PROC;
|
wmm->UpdateButton(2, uMsg == WM_MBUTTONDOWN);
|
||||||
}
|
return NO_WND_PROC;
|
||||||
else if (uMsg == WM_MBUTTONDOWN || uMsg == WM_MBUTTONUP) {
|
} else if (uMsg == WM_XBUTTONDOWN || uMsg == WM_XBUTTONUP) {
|
||||||
wmm->UpdateButton(2, uMsg == WM_MBUTTONDOWN);
|
wmm->UpdateButton(3 + ((wParam >> 16) == XBUTTON2), uMsg == WM_XBUTTONDOWN);
|
||||||
return NO_WND_PROC;
|
return NO_WND_PROC;
|
||||||
}
|
} else if (uMsg == WM_MOUSEWHEEL) {
|
||||||
else if (uMsg == WM_XBUTTONDOWN || uMsg == WM_XBUTTONUP) {
|
wmm->UpdateAxis(2, ((int)wParam >> 16) / WHEEL_DELTA);
|
||||||
wmm->UpdateButton(3+((wParam>>16) == XBUTTON2), uMsg == WM_XBUTTONDOWN);
|
return NO_WND_PROC;
|
||||||
return NO_WND_PROC;
|
} else if (uMsg == WM_MOUSEHWHEEL) {
|
||||||
}
|
wmm->UpdateAxis(3, ((int)wParam >> 16) / WHEEL_DELTA);
|
||||||
else if (uMsg == WM_MOUSEWHEEL) {
|
return NO_WND_PROC;
|
||||||
wmm->UpdateAxis(2, ((int)wParam>>16)/WHEEL_DELTA);
|
} else if (uMsg == WM_SIZE && wmm->active) {
|
||||||
return NO_WND_PROC;
|
WindowsMouse::WindowResized(hWnd);
|
||||||
}
|
}
|
||||||
else if (uMsg == WM_MOUSEHWHEEL) {
|
// Taken care of elsewhere. When binding, killing focus means stop reading input.
|
||||||
wmm->UpdateAxis(3, ((int)wParam>>16)/WHEEL_DELTA);
|
// When running PCSX2, I release all mouse and keyboard input elsewhere.
|
||||||
return NO_WND_PROC;
|
/*else if (uMsg == WM_KILLFOCUS) {
|
||||||
}
|
|
||||||
else if (uMsg == WM_SIZE && wmm->active) {
|
|
||||||
WindowsMouse::WindowResized(hWnd);
|
|
||||||
}
|
|
||||||
// Taken care of elsewhere. When binding, killing focus means stop reading input.
|
|
||||||
// When running PCSX2, I release all mouse and keyboard input elsewhere.
|
|
||||||
/*else if (uMsg == WM_KILLFOCUS) {
|
|
||||||
wmm->Deactivate();
|
wmm->Deactivate();
|
||||||
}//*/
|
}//*/
|
||||||
}
|
}
|
||||||
return CONTINUE_BLISSFULLY;
|
return CONTINUE_BLISSFULLY;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EnumWindowsMessagingDevices() {
|
void EnumWindowsMessagingDevices()
|
||||||
dm->AddDevice(new WindowsMessagingKeyboard());
|
{
|
||||||
dm->AddDevice(new WindowsMessagingMouse());
|
dm->AddDevice(new WindowsMessagingKeyboard());
|
||||||
|
dm->AddDevice(new WindowsMessagingMouse());
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,71 +23,80 @@
|
||||||
POINT WindowsMouse::origCursorPos;
|
POINT WindowsMouse::origCursorPos;
|
||||||
POINT WindowsMouse::center;
|
POINT WindowsMouse::center;
|
||||||
|
|
||||||
WindowsMouse::WindowsMouse(DeviceAPI api, int hWheel, wchar_t *displayName, wchar_t *instanceID, wchar_t *deviceID) :
|
WindowsMouse::WindowsMouse(DeviceAPI api, int hWheel, wchar_t *displayName, wchar_t *instanceID, wchar_t *deviceID)
|
||||||
Device(api, MOUSE, displayName, instanceID, deviceID) {
|
: Device(api, MOUSE, displayName, instanceID, deviceID)
|
||||||
int i;
|
{
|
||||||
for (i=0; i<5; i++) {
|
int i;
|
||||||
AddPhysicalControl(PSHBTN, i, i);
|
for (i = 0; i < 5; i++) {
|
||||||
}
|
AddPhysicalControl(PSHBTN, i, i);
|
||||||
|
}
|
||||||
|
|
||||||
for (i=0; i<3+hWheel; i++) {
|
for (i = 0; i < 3 + hWheel; i++) {
|
||||||
AddPhysicalControl(RELAXIS, i+5, i+5);
|
AddPhysicalControl(RELAXIS, i + 5, i + 5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wchar_t *WindowsMouse::GetPhysicalControlName(PhysicalControl *control) {
|
wchar_t *WindowsMouse::GetPhysicalControlName(PhysicalControl *control)
|
||||||
wchar_t *names[9] = {
|
{
|
||||||
L"L Button",
|
wchar_t *names[9] = {
|
||||||
L"R Button",
|
L"L Button",
|
||||||
L"M Button",
|
L"R Button",
|
||||||
L"Mouse 4",
|
L"M Button",
|
||||||
L"Mouse 5",
|
L"Mouse 4",
|
||||||
L"X Axis",
|
L"Mouse 5",
|
||||||
L"Y Axis",
|
L"X Axis",
|
||||||
L"Y Wheel",
|
L"Y Axis",
|
||||||
L"X Wheel"
|
L"Y Wheel",
|
||||||
};
|
L"X Wheel"};
|
||||||
if (control->id < 9) return names[control->id];
|
if (control->id < 9)
|
||||||
return Device::GetPhysicalControlName(control);
|
return names[control->id];
|
||||||
|
return Device::GetPhysicalControlName(control);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowsMouse::UpdateButton(unsigned int button, int state) {
|
void WindowsMouse::UpdateButton(unsigned int button, int state)
|
||||||
if (button > 4) return;
|
{
|
||||||
physicalControlState[button] = (state << 16);
|
if (button > 4)
|
||||||
|
return;
|
||||||
|
physicalControlState[button] = (state << 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowsMouse::UpdateAxis(unsigned int axis, int delta) {
|
void WindowsMouse::UpdateAxis(unsigned int axis, int delta)
|
||||||
if (axis > 3) return;
|
{
|
||||||
// 1 mouse pixel = 1/8th way down.
|
if (axis > 3)
|
||||||
physicalControlState[5+axis] += (delta<<(16 - 3*(axis < 2)));
|
return;
|
||||||
|
// 1 mouse pixel = 1/8th way down.
|
||||||
|
physicalControlState[5 + axis] += (delta << (16 - 3 * (axis < 2)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowsMouse::WindowResized(HWND hWnd) {
|
void WindowsMouse::WindowResized(HWND hWnd)
|
||||||
RECT r;
|
{
|
||||||
GetWindowRect(hWnd, &r);
|
RECT r;
|
||||||
ClipCursor(&r);
|
GetWindowRect(hWnd, &r);
|
||||||
center.x = (r.left + r.right)/2;
|
ClipCursor(&r);
|
||||||
center.y = (r.top + r.bottom)/2;
|
center.x = (r.left + r.right) / 2;
|
||||||
SetCursorPos(center.x, center.y);
|
center.y = (r.top + r.bottom) / 2;
|
||||||
|
SetCursorPos(center.x, center.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowsMouse::GetMouseCapture(HWND hWnd) {
|
void WindowsMouse::GetMouseCapture(HWND hWnd)
|
||||||
SetCapture(hWnd);
|
{
|
||||||
ShowCursor(0);
|
SetCapture(hWnd);
|
||||||
|
ShowCursor(0);
|
||||||
|
|
||||||
GetCursorPos(&origCursorPos);
|
GetCursorPos(&origCursorPos);
|
||||||
|
|
||||||
RECT r;
|
RECT r;
|
||||||
GetWindowRect(hWnd, &r);
|
GetWindowRect(hWnd, &r);
|
||||||
ClipCursor(&r);
|
ClipCursor(&r);
|
||||||
center.x = (r.left + r.right)/2;
|
center.x = (r.left + r.right) / 2;
|
||||||
center.y = (r.top + r.bottom)/2;
|
center.y = (r.top + r.bottom) / 2;
|
||||||
SetCursorPos(center.x, center.y);
|
SetCursorPos(center.x, center.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowsMouse::ReleaseMouseCapture() {
|
void WindowsMouse::ReleaseMouseCapture()
|
||||||
ClipCursor(0);
|
{
|
||||||
ReleaseCapture();
|
ClipCursor(0);
|
||||||
ShowCursor(1);
|
ReleaseCapture();
|
||||||
SetCursorPos(origCursorPos.x, origCursorPos.y);
|
ShowCursor(1);
|
||||||
|
SetCursorPos(origCursorPos.x, origCursorPos.y);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,26 +16,27 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Shared functionality for WM and RAW keyboards.
|
// Shared functionality for WM and RAW keyboards.
|
||||||
class WindowsMouse : public Device {
|
class WindowsMouse : public Device
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
// Used by GetMouseCapture()/ReleaseMouseCapture()
|
// Used by GetMouseCapture()/ReleaseMouseCapture()
|
||||||
// Static because can have multiple raw mice active at once,
|
// Static because can have multiple raw mice active at once,
|
||||||
// and only get/release capture once.
|
// and only get/release capture once.
|
||||||
static POINT origCursorPos;
|
static POINT origCursorPos;
|
||||||
static POINT center;
|
static POINT center;
|
||||||
|
|
||||||
static void GetMouseCapture(HWND hWnd);
|
static void GetMouseCapture(HWND hWnd);
|
||||||
static void WindowResized(HWND hWnd);
|
static void WindowResized(HWND hWnd);
|
||||||
static void ReleaseMouseCapture();
|
static void ReleaseMouseCapture();
|
||||||
|
|
||||||
// hWheel variable lets me display no horizontal wheel for raw input, just to make it clear
|
// hWheel variable lets me display no horizontal wheel for raw input, just to make it clear
|
||||||
// that it's not supported.
|
// that it's not supported.
|
||||||
WindowsMouse(DeviceAPI api, int hWheel, wchar_t *displayName, wchar_t *instanceID=0, wchar_t *deviceID=0);
|
WindowsMouse(DeviceAPI api, int hWheel, wchar_t *displayName, wchar_t *instanceID = 0, wchar_t *deviceID = 0);
|
||||||
wchar_t *GetPhysicalControlName(PhysicalControl *control);
|
wchar_t *GetPhysicalControlName(PhysicalControl *control);
|
||||||
// State is 0 for up, 1 for down.
|
// State is 0 for up, 1 for down.
|
||||||
void UpdateButton(unsigned int button, int state);
|
void UpdateButton(unsigned int button, int state);
|
||||||
// 0/1 are x/y. 2 is vert wheel, 3 is horiz wheel.
|
// 0/1 are x/y. 2 is vert wheel, 3 is horiz wheel.
|
||||||
// Delta is in my micro units. change of (1<<16) is 1 full unit, with
|
// Delta is in my micro units. change of (1<<16) is 1 full unit, with
|
||||||
// the default sensitivity.
|
// the default sensitivity.
|
||||||
void UpdateAxis(unsigned int axis, int delta);
|
void UpdateAxis(unsigned int axis, int delta);
|
||||||
};
|
};
|
||||||
|
|
|
@ -20,128 +20,136 @@
|
||||||
|
|
||||||
WndProcEater::WndProcEater()
|
WndProcEater::WndProcEater()
|
||||||
{
|
{
|
||||||
hWndEaten = 0;
|
hWndEaten = 0;
|
||||||
eatenWndProc = 0;
|
eatenWndProc = 0;
|
||||||
|
|
||||||
extraProcs = 0;
|
extraProcs = 0;
|
||||||
numExtraProcs = 0;
|
numExtraProcs = 0;
|
||||||
|
|
||||||
hMutex = CreateMutex(0, 0, L"LilyPad");
|
hMutex = CreateMutex(0, 0, L"LilyPad");
|
||||||
}
|
}
|
||||||
|
|
||||||
WndProcEater::~WndProcEater() throw()
|
WndProcEater::~WndProcEater() throw()
|
||||||
{
|
{
|
||||||
if (hMutex) {
|
if (hMutex) {
|
||||||
ReleaseMutex(hMutex);
|
ReleaseMutex(hMutex);
|
||||||
CloseHandle(hMutex);
|
CloseHandle(hMutex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WndProcEater::ReleaseExtraProc(ExtraWndProc proc) {
|
void WndProcEater::ReleaseExtraProc(ExtraWndProc proc)
|
||||||
// Probably isn't needed, but just in case...
|
{
|
||||||
if (hMutex) WaitForSingleObject(hMutex, 100);
|
// Probably isn't needed, but just in case...
|
||||||
|
if (hMutex)
|
||||||
|
WaitForSingleObject(hMutex, 100);
|
||||||
|
|
||||||
//printf( "(Lilypad) Regurgitating! -> 0x%x\n", proc );
|
//printf( "(Lilypad) Regurgitating! -> 0x%x\n", proc );
|
||||||
|
|
||||||
for (int i=0; i<numExtraProcs; i++) {
|
for (int i = 0; i < numExtraProcs; i++) {
|
||||||
if (extraProcs[i].proc == proc) {
|
if (extraProcs[i].proc == proc) {
|
||||||
extraProcs[i] = extraProcs[--numExtraProcs];
|
extraProcs[i] = extraProcs[--numExtraProcs];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!numExtraProcs && eatenWndProc) {
|
if (!numExtraProcs && eatenWndProc) {
|
||||||
free(extraProcs);
|
free(extraProcs);
|
||||||
extraProcs = 0;
|
extraProcs = 0;
|
||||||
// As numExtraProcs is 0, won't cause recursion if called from Release().
|
// As numExtraProcs is 0, won't cause recursion if called from Release().
|
||||||
Release();
|
Release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WndProcEater::Release() {
|
void WndProcEater::Release()
|
||||||
while (numExtraProcs) ReleaseExtraProc(extraProcs[0].proc);
|
{
|
||||||
if (hWndEaten && IsWindow(hWndEaten)) {
|
while (numExtraProcs)
|
||||||
RemoveProp(hWndEaten, L"LilyHaxxor");
|
ReleaseExtraProc(extraProcs[0].proc);
|
||||||
SetWindowLongPtr(hWndEaten, GWLP_WNDPROC, (LONG_PTR)eatenWndProc);
|
if (hWndEaten && IsWindow(hWndEaten)) {
|
||||||
hWndEaten = 0;
|
RemoveProp(hWndEaten, L"LilyHaxxor");
|
||||||
eatenWndProc = 0;
|
SetWindowLongPtr(hWndEaten, GWLP_WNDPROC, (LONG_PTR)eatenWndProc);
|
||||||
}
|
hWndEaten = 0;
|
||||||
|
eatenWndProc = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LRESULT WndProcEater::_OverrideWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
LRESULT WndProcEater::_OverrideWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
if( hWnd != hWndEaten )
|
if (hWnd != hWndEaten)
|
||||||
fprintf( stderr, "Totally mismatched window handles on OverrideWndProc!\n" );
|
fprintf(stderr, "Totally mismatched window handles on OverrideWndProc!\n");
|
||||||
|
|
||||||
ExtraWndProcResult res = CONTINUE_BLISSFULLY;
|
ExtraWndProcResult res = CONTINUE_BLISSFULLY;
|
||||||
LRESULT out = 0;
|
LRESULT out = 0;
|
||||||
// Here because want it for binding, even when no keyboard mode is selected.
|
// Here because want it for binding, even when no keyboard mode is selected.
|
||||||
if (uMsg == WM_GETDLGCODE) {
|
if (uMsg == WM_GETDLGCODE) {
|
||||||
return DLGC_WANTALLKEYS | CallWindowProc(eatenWndProc, hWnd, uMsg, wParam, lParam);
|
return DLGC_WANTALLKEYS | CallWindowProc(eatenWndProc, hWnd, uMsg, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i=0; i<numExtraProcs; i++) {
|
for (int i = 0; i < numExtraProcs; i++) {
|
||||||
// Note: Second bit of deviceUpdateQueued is only set when I receive a device change
|
// Note: Second bit of deviceUpdateQueued is only set when I receive a device change
|
||||||
// notification, which is handled in the GS thread in one of the extraProcs, so this
|
// notification, which is handled in the GS thread in one of the extraProcs, so this
|
||||||
// is all I need to prevent bad things from happening while updating devices. No mutex needed.
|
// is all I need to prevent bad things from happening while updating devices. No mutex needed.
|
||||||
// if ((deviceUpdateQueued&2) && (extraProcs[i].flags & EATPROC_NO_UPDATE_WHILE_UPDATING_DEVICES)) continue;
|
// if ((deviceUpdateQueued&2) && (extraProcs[i].flags & EATPROC_NO_UPDATE_WHILE_UPDATING_DEVICES)) continue;
|
||||||
|
|
||||||
ExtraWndProcResult res2 = extraProcs[i].proc(hWnd, uMsg, wParam, lParam, &out);
|
ExtraWndProcResult res2 = extraProcs[i].proc(hWnd, uMsg, wParam, lParam, &out);
|
||||||
if (res2 != res) {
|
if (res2 != res) {
|
||||||
if (res2 == CONTINUE_BLISSFULLY_AND_RELEASE_PROC) {
|
if (res2 == CONTINUE_BLISSFULLY_AND_RELEASE_PROC) {
|
||||||
ReleaseExtraProc(extraProcs[i].proc);
|
ReleaseExtraProc(extraProcs[i].proc);
|
||||||
i--;
|
i--;
|
||||||
}
|
} else if (res2 > res)
|
||||||
else if (res2 > res) res = res2;
|
res = res2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res != NO_WND_PROC) {
|
if (res != NO_WND_PROC) {
|
||||||
if (out == WM_DESTROY) {
|
if (out == WM_DESTROY) {
|
||||||
Release();
|
Release();
|
||||||
}
|
}
|
||||||
if (res == CONTINUE_BLISSFULLY)
|
if (res == CONTINUE_BLISSFULLY)
|
||||||
out = CallWindowProc(eatenWndProc, hWnd, uMsg, wParam, lParam);
|
out = CallWindowProc(eatenWndProc, hWnd, uMsg, wParam, lParam);
|
||||||
else if (res == USE_DEFAULT_WND_PROC)
|
else if (res == USE_DEFAULT_WND_PROC)
|
||||||
out = DefWindowProc(hWnd, uMsg, wParam, lParam);
|
out = DefWindowProc(hWnd, uMsg, wParam, lParam);
|
||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
static LRESULT CALLBACK OverrideWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
static LRESULT CALLBACK OverrideWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
WndProcEater* obj = (WndProcEater*)GetProp(hWnd, L"LilyHaxxor");
|
WndProcEater *obj = (WndProcEater *)GetProp(hWnd, L"LilyHaxxor");
|
||||||
return (obj == NULL) ?
|
return (obj == NULL) ?
|
||||||
DefWindowProc(hWnd, uMsg, wParam, lParam) :
|
DefWindowProc(hWnd, uMsg, wParam, lParam) :
|
||||||
obj->_OverrideWndProc( hWnd, uMsg, wParam, lParam );
|
obj->_OverrideWndProc(hWnd, uMsg, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WndProcEater::SetWndHandle(HWND hWnd)
|
bool WndProcEater::SetWndHandle(HWND hWnd)
|
||||||
{
|
{
|
||||||
if(hWnd == hWndEaten) return true;
|
if (hWnd == hWndEaten)
|
||||||
|
return true;
|
||||||
|
|
||||||
//printf( "(Lilypad) (Re)-Setting window handle! -> this=0x%08x, hWnd=0x%08x\n", this, hWnd );
|
//printf( "(Lilypad) (Re)-Setting window handle! -> this=0x%08x, hWnd=0x%08x\n", this, hWnd );
|
||||||
|
|
||||||
Release();
|
Release();
|
||||||
SetProp(hWnd, L"LilyHaxxor", (HANDLE)this);
|
SetProp(hWnd, L"LilyHaxxor", (HANDLE) this);
|
||||||
|
|
||||||
eatenWndProc = (WNDPROC) SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)OverrideWndProc);
|
eatenWndProc = (WNDPROC)SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)OverrideWndProc);
|
||||||
hWndEaten = (eatenWndProc) ? hWnd : 0;
|
hWndEaten = (eatenWndProc) ? hWnd : 0;
|
||||||
|
|
||||||
return !!hWndEaten;
|
return !!hWndEaten;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WndProcEater::Eat(ExtraWndProc proc, DWORD flags) {
|
void WndProcEater::Eat(ExtraWndProc proc, DWORD flags)
|
||||||
|
{
|
||||||
|
|
||||||
// check if Subclassing failed to init during SetWndHandle
|
// check if Subclassing failed to init during SetWndHandle
|
||||||
if (!hWndEaten) return;
|
if (!hWndEaten)
|
||||||
|
return;
|
||||||
|
|
||||||
// Probably isn't needed, but just in case...
|
// Probably isn't needed, but just in case...
|
||||||
if (hMutex) WaitForSingleObject(hMutex, 100);
|
if (hMutex)
|
||||||
|
WaitForSingleObject(hMutex, 100);
|
||||||
|
|
||||||
//printf( "(Lilypad) EatingWndProc! -> 0x%x\n", proc );
|
//printf( "(Lilypad) EatingWndProc! -> 0x%x\n", proc );
|
||||||
|
|
||||||
extraProcs = (ExtraWndProcInfo*) realloc(extraProcs, sizeof(ExtraWndProcInfo)*(numExtraProcs+1));
|
extraProcs = (ExtraWndProcInfo *)realloc(extraProcs, sizeof(ExtraWndProcInfo) * (numExtraProcs + 1));
|
||||||
extraProcs[numExtraProcs].proc = proc;
|
extraProcs[numExtraProcs].proc = proc;
|
||||||
extraProcs[numExtraProcs].flags = flags;
|
extraProcs[numExtraProcs].flags = flags;
|
||||||
numExtraProcs++;
|
numExtraProcs++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,45 +15,46 @@
|
||||||
* with PCSX2. If not, see <http://www.gnu.org/licenses/>.
|
* with PCSX2. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define EATPROC_NO_UPDATE_WHILE_UPDATING_DEVICES 1
|
#define EATPROC_NO_UPDATE_WHILE_UPDATING_DEVICES 1
|
||||||
|
|
||||||
/* Need this to let window be subclassed multiple times but still clean up nicely.
|
/* Need this to let window be subclassed multiple times but still clean up nicely.
|
||||||
*/
|
*/
|
||||||
enum ExtraWndProcResult {
|
enum ExtraWndProcResult {
|
||||||
CONTINUE_BLISSFULLY,
|
CONTINUE_BLISSFULLY,
|
||||||
// Calls ReleaseExtraProc without messing up order.
|
// Calls ReleaseExtraProc without messing up order.
|
||||||
CONTINUE_BLISSFULLY_AND_RELEASE_PROC,
|
CONTINUE_BLISSFULLY_AND_RELEASE_PROC,
|
||||||
USE_DEFAULT_WND_PROC,
|
USE_DEFAULT_WND_PROC,
|
||||||
NO_WND_PROC
|
NO_WND_PROC
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef ExtraWndProcResult (*ExtraWndProc)(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *out);
|
typedef ExtraWndProcResult (*ExtraWndProc)(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *out);
|
||||||
|
|
||||||
struct ExtraWndProcInfo {
|
struct ExtraWndProcInfo
|
||||||
ExtraWndProc proc;
|
{
|
||||||
DWORD flags;
|
ExtraWndProc proc;
|
||||||
|
DWORD flags;
|
||||||
};
|
};
|
||||||
|
|
||||||
class WndProcEater
|
class WndProcEater
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
HWND hWndEaten;
|
HWND hWndEaten;
|
||||||
WNDPROC eatenWndProc;
|
WNDPROC eatenWndProc;
|
||||||
ExtraWndProcInfo* extraProcs;
|
ExtraWndProcInfo *extraProcs;
|
||||||
int numExtraProcs;
|
int numExtraProcs;
|
||||||
|
|
||||||
HANDLE hMutex;
|
HANDLE hMutex;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
WndProcEater();
|
WndProcEater();
|
||||||
virtual ~WndProcEater() throw();
|
virtual ~WndProcEater() throw();
|
||||||
|
|
||||||
bool SetWndHandle(HWND hWnd);
|
bool SetWndHandle(HWND hWnd);
|
||||||
void Eat(ExtraWndProc proc, DWORD flags);
|
void Eat(ExtraWndProc proc, DWORD flags);
|
||||||
void ReleaseExtraProc(ExtraWndProc proc);
|
void ReleaseExtraProc(ExtraWndProc proc);
|
||||||
void Release();
|
void Release();
|
||||||
|
|
||||||
LRESULT _OverrideWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
LRESULT _OverrideWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||||
};
|
};
|
||||||
|
|
||||||
extern WndProcEater hWndGSProc;
|
extern WndProcEater hWndGSProc;
|
||||||
|
|
|
@ -27,43 +27,43 @@
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
float SCP_UP;
|
float SCP_UP;
|
||||||
float SCP_RIGHT;
|
float SCP_RIGHT;
|
||||||
float SCP_DOWN;
|
float SCP_DOWN;
|
||||||
float SCP_LEFT;
|
float SCP_LEFT;
|
||||||
|
|
||||||
float SCP_LX;
|
float SCP_LX;
|
||||||
float SCP_LY;
|
float SCP_LY;
|
||||||
|
|
||||||
float SCP_L1;
|
float SCP_L1;
|
||||||
float SCP_L2;
|
float SCP_L2;
|
||||||
float SCP_L3;
|
float SCP_L3;
|
||||||
|
|
||||||
float SCP_RX;
|
float SCP_RX;
|
||||||
float SCP_RY;
|
float SCP_RY;
|
||||||
|
|
||||||
float SCP_R1;
|
float SCP_R1;
|
||||||
float SCP_R2;
|
float SCP_R2;
|
||||||
float SCP_R3;
|
float SCP_R3;
|
||||||
|
|
||||||
float SCP_T;
|
float SCP_T;
|
||||||
float SCP_C;
|
float SCP_C;
|
||||||
float SCP_X;
|
float SCP_X;
|
||||||
float SCP_S;
|
float SCP_S;
|
||||||
|
|
||||||
float SCP_SELECT;
|
float SCP_SELECT;
|
||||||
float SCP_START;
|
float SCP_START;
|
||||||
|
|
||||||
float SCP_PS;
|
float SCP_PS;
|
||||||
|
|
||||||
} SCP_EXTN;
|
} SCP_EXTN;
|
||||||
|
|
||||||
|
|
||||||
// This way, I don't require that XInput junk be installed.
|
// This way, I don't require that XInput junk be installed.
|
||||||
typedef void(CALLBACK *_XInputEnable)(BOOL enable);
|
typedef void(CALLBACK *_XInputEnable)(BOOL enable);
|
||||||
typedef DWORD(CALLBACK *_XInputGetStateEx)(DWORD dwUserIndex, XINPUT_STATE* pState);
|
typedef DWORD(CALLBACK *_XInputGetStateEx)(DWORD dwUserIndex, XINPUT_STATE *pState);
|
||||||
typedef DWORD(CALLBACK *_XInputGetExtended)(DWORD dwUserIndex, SCP_EXTN* pPressure);
|
typedef DWORD(CALLBACK *_XInputGetExtended)(DWORD dwUserIndex, SCP_EXTN *pPressure);
|
||||||
typedef DWORD(CALLBACK *_XInputSetState)(DWORD dwUserIndex, XINPUT_VIBRATION* pVibration);
|
typedef DWORD(CALLBACK *_XInputSetState)(DWORD dwUserIndex, XINPUT_VIBRATION *pVibration);
|
||||||
|
|
||||||
_XInputEnable pXInputEnable = 0;
|
_XInputEnable pXInputEnable = 0;
|
||||||
_XInputGetStateEx pXInputGetStateEx = 0;
|
_XInputGetStateEx pXInputGetStateEx = 0;
|
||||||
|
@ -73,215 +73,230 @@ _XInputSetState pXInputSetState = 0;
|
||||||
static int xInputActiveCount = 0;
|
static int xInputActiveCount = 0;
|
||||||
|
|
||||||
// Completely unncessary, really.
|
// Completely unncessary, really.
|
||||||
__forceinline int ShortToAxis(int v) {
|
__forceinline int ShortToAxis(int v)
|
||||||
// If positive and at least 1 << 14, increment.
|
{
|
||||||
v += (!((v>>15)&1)) & ((v>>14)&1);
|
// If positive and at least 1 << 14, increment.
|
||||||
// Just double.
|
v += (!((v >> 15) & 1)) & ((v >> 14) & 1);
|
||||||
return v * 2;
|
// Just double.
|
||||||
|
return v * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
class XInputDevice : public Device {
|
class XInputDevice : public Device
|
||||||
// Cached last vibration values by pad and motor.
|
{
|
||||||
// Need this, as only one value is changed at a time.
|
// Cached last vibration values by pad and motor.
|
||||||
int ps2Vibration[2][4][2];
|
// Need this, as only one value is changed at a time.
|
||||||
// Minor optimization - cache last set vibration values
|
int ps2Vibration[2][4][2];
|
||||||
// When there's no change, no need to do anything.
|
// Minor optimization - cache last set vibration values
|
||||||
XINPUT_VIBRATION xInputVibration;
|
// When there's no change, no need to do anything.
|
||||||
|
XINPUT_VIBRATION xInputVibration;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int index;
|
int index;
|
||||||
|
|
||||||
XInputDevice(int index, wchar_t *displayName) : Device(XINPUT, OTHER, displayName) {
|
XInputDevice(int index, wchar_t *displayName)
|
||||||
memset(ps2Vibration, 0, sizeof(ps2Vibration));
|
: Device(XINPUT, OTHER, displayName)
|
||||||
memset(&xInputVibration, 0, sizeof(xInputVibration));
|
{
|
||||||
this->index = index;
|
memset(ps2Vibration, 0, sizeof(ps2Vibration));
|
||||||
int i;
|
memset(&xInputVibration, 0, sizeof(xInputVibration));
|
||||||
for (i=0; i<17; i++) { // Skip empty bit
|
this->index = index;
|
||||||
AddPhysicalControl(PRESSURE_BTN, i + (i > 10), 0);
|
int i;
|
||||||
}
|
for (i = 0; i < 17; i++) { // Skip empty bit
|
||||||
for (; i<21; i++) {
|
AddPhysicalControl(PRESSURE_BTN, i + (i > 10), 0);
|
||||||
AddPhysicalControl(ABSAXIS, i + 2, 0);
|
}
|
||||||
}
|
for (; i < 21; i++) {
|
||||||
AddFFAxis(L"Slow Motor", 0);
|
AddPhysicalControl(ABSAXIS, i + 2, 0);
|
||||||
AddFFAxis(L"Fast Motor", 1);
|
}
|
||||||
AddFFEffectType(L"Constant Effect", L"Constant", EFFECT_CONSTANT);
|
AddFFAxis(L"Slow Motor", 0);
|
||||||
}
|
AddFFAxis(L"Fast Motor", 1);
|
||||||
|
AddFFEffectType(L"Constant Effect", L"Constant", EFFECT_CONSTANT);
|
||||||
|
}
|
||||||
|
|
||||||
wchar_t *GetPhysicalControlName(PhysicalControl *c) {
|
wchar_t *GetPhysicalControlName(PhysicalControl *c)
|
||||||
const static wchar_t *names[] = {
|
{
|
||||||
L"D-pad Up",
|
const static wchar_t *names[] = {
|
||||||
L"D-pad Down",
|
L"D-pad Up",
|
||||||
L"D-pad Left",
|
L"D-pad Down",
|
||||||
L"D-pad Right",
|
L"D-pad Left",
|
||||||
L"Start",
|
L"D-pad Right",
|
||||||
L"Back",
|
L"Start",
|
||||||
L"Left Thumb",
|
L"Back",
|
||||||
L"Right Thumb",
|
L"Left Thumb",
|
||||||
L"Left Shoulder",
|
L"Right Thumb",
|
||||||
L"Right Shoulder",
|
L"Left Shoulder",
|
||||||
L"Guide",
|
L"Right Shoulder",
|
||||||
L"A",
|
L"Guide",
|
||||||
L"B",
|
L"A",
|
||||||
L"X",
|
L"B",
|
||||||
L"Y",
|
L"X",
|
||||||
L"Left Trigger",
|
L"Y",
|
||||||
L"Right Trigger",
|
L"Left Trigger",
|
||||||
L"Left Thumb X",
|
L"Right Trigger",
|
||||||
L"Left Thumb Y",
|
L"Left Thumb X",
|
||||||
L"Right Thumb X",
|
L"Left Thumb Y",
|
||||||
L"Right Thumb Y",
|
L"Right Thumb X",
|
||||||
};
|
L"Right Thumb Y",
|
||||||
unsigned int i = (unsigned int) (c - physicalControls);
|
};
|
||||||
if (i < 21) {
|
unsigned int i = (unsigned int)(c - physicalControls);
|
||||||
return (wchar_t*)names[i];
|
if (i < 21) {
|
||||||
}
|
return (wchar_t *)names[i];
|
||||||
return Device::GetPhysicalControlName(c);
|
}
|
||||||
}
|
return Device::GetPhysicalControlName(c);
|
||||||
|
}
|
||||||
|
|
||||||
int Activate(InitInfo *initInfo) {
|
int Activate(InitInfo *initInfo)
|
||||||
if (active) Deactivate();
|
{
|
||||||
if (!xInputActiveCount) {
|
if (active)
|
||||||
pXInputEnable(1);
|
Deactivate();
|
||||||
}
|
if (!xInputActiveCount) {
|
||||||
xInputActiveCount++;
|
pXInputEnable(1);
|
||||||
active = 1;
|
}
|
||||||
AllocState();
|
xInputActiveCount++;
|
||||||
return 1;
|
active = 1;
|
||||||
}
|
AllocState();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
int Update() {
|
int Update()
|
||||||
if (!active) return 0;
|
{
|
||||||
XINPUT_STATE state;
|
if (!active)
|
||||||
if (ERROR_SUCCESS != pXInputGetStateEx(index, &state)) {
|
return 0;
|
||||||
Deactivate();
|
XINPUT_STATE state;
|
||||||
return 0;
|
if (ERROR_SUCCESS != pXInputGetStateEx(index, &state)) {
|
||||||
}
|
Deactivate();
|
||||||
SCP_EXTN pressure;
|
return 0;
|
||||||
if (!pXInputGetExtended || (ERROR_SUCCESS != pXInputGetExtended(index, &pressure))) {
|
}
|
||||||
int buttons = state.Gamepad.wButtons;
|
SCP_EXTN pressure;
|
||||||
for (int i = 0; i < 15; i++) {
|
if (!pXInputGetExtended || (ERROR_SUCCESS != pXInputGetExtended(index, &pressure))) {
|
||||||
physicalControlState[i] = ((buttons >> physicalControls[i].id) & 1) << 16;
|
int buttons = state.Gamepad.wButtons;
|
||||||
}
|
for (int i = 0; i < 15; i++) {
|
||||||
physicalControlState[15] = (int)(state.Gamepad.bLeftTrigger * 257.005);
|
physicalControlState[i] = ((buttons >> physicalControls[i].id) & 1) << 16;
|
||||||
physicalControlState[16] = (int)(state.Gamepad.bRightTrigger * 257.005);
|
}
|
||||||
physicalControlState[17] = ShortToAxis(state.Gamepad.sThumbLX);
|
physicalControlState[15] = (int)(state.Gamepad.bLeftTrigger * 257.005);
|
||||||
physicalControlState[18] = ShortToAxis(state.Gamepad.sThumbLY);
|
physicalControlState[16] = (int)(state.Gamepad.bRightTrigger * 257.005);
|
||||||
physicalControlState[19] = ShortToAxis(state.Gamepad.sThumbRX);
|
physicalControlState[17] = ShortToAxis(state.Gamepad.sThumbLX);
|
||||||
physicalControlState[20] = ShortToAxis(state.Gamepad.sThumbRY);
|
physicalControlState[18] = ShortToAxis(state.Gamepad.sThumbLY);
|
||||||
} else {
|
physicalControlState[19] = ShortToAxis(state.Gamepad.sThumbRX);
|
||||||
physicalControlState[0] = (int)(pressure.SCP_UP * FULLY_DOWN);
|
physicalControlState[20] = ShortToAxis(state.Gamepad.sThumbRY);
|
||||||
physicalControlState[1] = (int)(pressure.SCP_DOWN * FULLY_DOWN);
|
} else {
|
||||||
physicalControlState[2] = (int)(pressure.SCP_LEFT * FULLY_DOWN);
|
physicalControlState[0] = (int)(pressure.SCP_UP * FULLY_DOWN);
|
||||||
physicalControlState[3] = (int)(pressure.SCP_RIGHT * FULLY_DOWN);
|
physicalControlState[1] = (int)(pressure.SCP_DOWN * FULLY_DOWN);
|
||||||
physicalControlState[4] = (int)(pressure.SCP_START * FULLY_DOWN);
|
physicalControlState[2] = (int)(pressure.SCP_LEFT * FULLY_DOWN);
|
||||||
physicalControlState[5] = (int)(pressure.SCP_SELECT * FULLY_DOWN);
|
physicalControlState[3] = (int)(pressure.SCP_RIGHT * FULLY_DOWN);
|
||||||
physicalControlState[6] = (int)(pressure.SCP_L3 * FULLY_DOWN);
|
physicalControlState[4] = (int)(pressure.SCP_START * FULLY_DOWN);
|
||||||
physicalControlState[7] = (int)(pressure.SCP_R3 * FULLY_DOWN);
|
physicalControlState[5] = (int)(pressure.SCP_SELECT * FULLY_DOWN);
|
||||||
physicalControlState[8] = (int)(pressure.SCP_L1 * FULLY_DOWN);
|
physicalControlState[6] = (int)(pressure.SCP_L3 * FULLY_DOWN);
|
||||||
physicalControlState[9] = (int)(pressure.SCP_R1 * FULLY_DOWN);
|
physicalControlState[7] = (int)(pressure.SCP_R3 * FULLY_DOWN);
|
||||||
physicalControlState[10] = (int)(pressure.SCP_PS * FULLY_DOWN);
|
physicalControlState[8] = (int)(pressure.SCP_L1 * FULLY_DOWN);
|
||||||
physicalControlState[11] = (int)(pressure.SCP_X * FULLY_DOWN);
|
physicalControlState[9] = (int)(pressure.SCP_R1 * FULLY_DOWN);
|
||||||
physicalControlState[12] = (int)(pressure.SCP_C * FULLY_DOWN);
|
physicalControlState[10] = (int)(pressure.SCP_PS * FULLY_DOWN);
|
||||||
physicalControlState[13] = (int)(pressure.SCP_S * FULLY_DOWN);
|
physicalControlState[11] = (int)(pressure.SCP_X * FULLY_DOWN);
|
||||||
physicalControlState[14] = (int)(pressure.SCP_T * FULLY_DOWN);
|
physicalControlState[12] = (int)(pressure.SCP_C * FULLY_DOWN);
|
||||||
physicalControlState[15] = (int)(pressure.SCP_L2 * FULLY_DOWN);
|
physicalControlState[13] = (int)(pressure.SCP_S * FULLY_DOWN);
|
||||||
physicalControlState[16] = (int)(pressure.SCP_R2 * FULLY_DOWN);
|
physicalControlState[14] = (int)(pressure.SCP_T * FULLY_DOWN);
|
||||||
physicalControlState[17] = (int)(pressure.SCP_LX * FULLY_DOWN);
|
physicalControlState[15] = (int)(pressure.SCP_L2 * FULLY_DOWN);
|
||||||
physicalControlState[18] = (int)(pressure.SCP_LY * FULLY_DOWN);
|
physicalControlState[16] = (int)(pressure.SCP_R2 * FULLY_DOWN);
|
||||||
physicalControlState[19] = (int)(pressure.SCP_RX * FULLY_DOWN);
|
physicalControlState[17] = (int)(pressure.SCP_LX * FULLY_DOWN);
|
||||||
physicalControlState[20] = (int)(pressure.SCP_RY * FULLY_DOWN);
|
physicalControlState[18] = (int)(pressure.SCP_LY * FULLY_DOWN);
|
||||||
}
|
physicalControlState[19] = (int)(pressure.SCP_RX * FULLY_DOWN);
|
||||||
return 1;
|
physicalControlState[20] = (int)(pressure.SCP_RY * FULLY_DOWN);
|
||||||
}
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
void SetEffects(unsigned char port, unsigned int slot, unsigned char motor, unsigned char force) {
|
void SetEffects(unsigned char port, unsigned int slot, unsigned char motor, unsigned char force)
|
||||||
ps2Vibration[port][slot][motor] = force;
|
{
|
||||||
int newVibration[2] = {0,0};
|
ps2Vibration[port][slot][motor] = force;
|
||||||
for (int p=0; p<2; p++) {
|
int newVibration[2] = {0, 0};
|
||||||
for (int s=0; s<4; s++) {
|
for (int p = 0; p < 2; p++) {
|
||||||
for (int i=0; i<pads[p][s].numFFBindings; i++) {
|
for (int s = 0; s < 4; s++) {
|
||||||
// Technically should also be a *65535/BASE_SENSITIVITY, but that's close enough to 1 for me.
|
for (int i = 0; i < pads[p][s].numFFBindings; i++) {
|
||||||
ForceFeedbackBinding *ffb = &pads[p][s].ffBindings[i];
|
// Technically should also be a *65535/BASE_SENSITIVITY, but that's close enough to 1 for me.
|
||||||
newVibration[0] += (int)((ffb->axes[0].force * (__int64)ps2Vibration[p][s][ffb->motor]) / 255);
|
ForceFeedbackBinding *ffb = &pads[p][s].ffBindings[i];
|
||||||
newVibration[1] += (int)((ffb->axes[1].force * (__int64)ps2Vibration[p][s][ffb->motor]) / 255);
|
newVibration[0] += (int)((ffb->axes[0].force * (__int64)ps2Vibration[p][s][ffb->motor]) / 255);
|
||||||
}
|
newVibration[1] += (int)((ffb->axes[1].force * (__int64)ps2Vibration[p][s][ffb->motor]) / 255);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
newVibration[0] = abs(newVibration[0]);
|
}
|
||||||
if (newVibration[0] > 65535) {
|
newVibration[0] = abs(newVibration[0]);
|
||||||
newVibration[0] = 65535;
|
if (newVibration[0] > 65535) {
|
||||||
}
|
newVibration[0] = 65535;
|
||||||
newVibration[1] = abs(newVibration[1]);
|
}
|
||||||
if (newVibration[1] > 65535) {
|
newVibration[1] = abs(newVibration[1]);
|
||||||
newVibration[1] = 65535;
|
if (newVibration[1] > 65535) {
|
||||||
}
|
newVibration[1] = 65535;
|
||||||
if (newVibration[0] || newVibration[1] || newVibration[0] != xInputVibration.wLeftMotorSpeed || newVibration[1] != xInputVibration.wRightMotorSpeed) {
|
}
|
||||||
XINPUT_VIBRATION newv = {(WORD)newVibration[0], (WORD)newVibration[1]};
|
if (newVibration[0] || newVibration[1] || newVibration[0] != xInputVibration.wLeftMotorSpeed || newVibration[1] != xInputVibration.wRightMotorSpeed) {
|
||||||
if (ERROR_SUCCESS == pXInputSetState(index, &newv)) {
|
XINPUT_VIBRATION newv = {(WORD)newVibration[0], (WORD)newVibration[1]};
|
||||||
xInputVibration = newv;
|
if (ERROR_SUCCESS == pXInputSetState(index, &newv)) {
|
||||||
}
|
xInputVibration = newv;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void SetEffect(ForceFeedbackBinding *binding, unsigned char force) {
|
void SetEffect(ForceFeedbackBinding *binding, unsigned char force)
|
||||||
PadBindings pBackup = pads[0][0];
|
{
|
||||||
pads[0][0].ffBindings = binding;
|
PadBindings pBackup = pads[0][0];
|
||||||
pads[0][0].numFFBindings = 1;
|
pads[0][0].ffBindings = binding;
|
||||||
SetEffects(0, 0, binding->motor, 255);
|
pads[0][0].numFFBindings = 1;
|
||||||
pads[0][0] = pBackup;
|
SetEffects(0, 0, binding->motor, 255);
|
||||||
}
|
pads[0][0] = pBackup;
|
||||||
|
}
|
||||||
|
|
||||||
void Deactivate() {
|
void Deactivate()
|
||||||
memset(&xInputVibration, 0, sizeof(xInputVibration));
|
{
|
||||||
memset(ps2Vibration, 0, sizeof(ps2Vibration));
|
memset(&xInputVibration, 0, sizeof(xInputVibration));
|
||||||
pXInputSetState(index, &xInputVibration);
|
memset(ps2Vibration, 0, sizeof(ps2Vibration));
|
||||||
|
pXInputSetState(index, &xInputVibration);
|
||||||
|
|
||||||
FreeState();
|
FreeState();
|
||||||
if (active) {
|
if (active) {
|
||||||
if (!--xInputActiveCount) {
|
if (!--xInputActiveCount) {
|
||||||
pXInputEnable(0);
|
pXInputEnable(0);
|
||||||
}
|
}
|
||||||
active = 0;
|
active = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
~XInputDevice() {
|
~XInputDevice()
|
||||||
}
|
{
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void EnumXInputDevices() {
|
void EnumXInputDevices()
|
||||||
wchar_t temp[30];
|
{
|
||||||
if (!pXInputSetState) {
|
wchar_t temp[30];
|
||||||
// Also used as flag to indicute XInput not installed, so
|
if (!pXInputSetState) {
|
||||||
// don't repeatedly try to load it.
|
// Also used as flag to indicute XInput not installed, so
|
||||||
if (pXInputEnable) return;
|
// don't repeatedly try to load it.
|
||||||
|
if (pXInputEnable)
|
||||||
|
return;
|
||||||
|
|
||||||
// Prefer XInput 1.3 since SCP only has an XInput 1.3 wrapper right now.
|
// Prefer XInput 1.3 since SCP only has an XInput 1.3 wrapper right now.
|
||||||
// Also use LoadLibrary and not LoadLibraryEx for XInput 1.3, since some
|
// Also use LoadLibrary and not LoadLibraryEx for XInput 1.3, since some
|
||||||
// Windows 7 systems have issues with it.
|
// Windows 7 systems have issues with it.
|
||||||
// FIXME: Missing FreeLibrary call.
|
// FIXME: Missing FreeLibrary call.
|
||||||
HMODULE hMod = LoadLibrary(L"xinput1_3.dll");
|
HMODULE hMod = LoadLibrary(L"xinput1_3.dll");
|
||||||
if (hMod == nullptr && IsWindows8OrGreater()) {
|
if (hMod == nullptr && IsWindows8OrGreater()) {
|
||||||
hMod = LoadLibraryEx(L"XInput1_4.dll", nullptr, LOAD_LIBRARY_SEARCH_APPLICATION_DIR | LOAD_LIBRARY_SEARCH_SYSTEM32);
|
hMod = LoadLibraryEx(L"XInput1_4.dll", nullptr, LOAD_LIBRARY_SEARCH_APPLICATION_DIR | LOAD_LIBRARY_SEARCH_SYSTEM32);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hMod) {
|
if (hMod) {
|
||||||
if ((pXInputEnable = (_XInputEnable) GetProcAddress(hMod, "XInputEnable")) &&
|
if ((pXInputEnable = (_XInputEnable)GetProcAddress(hMod, "XInputEnable")) &&
|
||||||
((pXInputGetStateEx = (_XInputGetStateEx) GetProcAddress(hMod, (LPCSTR)100)) || // Try Ex version first
|
((pXInputGetStateEx = (_XInputGetStateEx)GetProcAddress(hMod, (LPCSTR)100)) || // Try Ex version first
|
||||||
(pXInputGetStateEx = (_XInputGetStateEx) GetProcAddress(hMod, "XInputGetState")))) {
|
(pXInputGetStateEx = (_XInputGetStateEx)GetProcAddress(hMod, "XInputGetState")))) {
|
||||||
pXInputGetExtended = (_XInputGetExtended)GetProcAddress(hMod, "XInputGetExtended");
|
pXInputGetExtended = (_XInputGetExtended)GetProcAddress(hMod, "XInputGetExtended");
|
||||||
pXInputSetState = (_XInputSetState) GetProcAddress(hMod, "XInputSetState");
|
pXInputSetState = (_XInputSetState)GetProcAddress(hMod, "XInputSetState");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!pXInputSetState) {
|
if (!pXInputSetState) {
|
||||||
pXInputEnable = (_XInputEnable)-1;
|
pXInputEnable = (_XInputEnable)-1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pXInputEnable(1);
|
pXInputEnable(1);
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
wsprintfW(temp, L"XInput Pad %i", i);
|
wsprintfW(temp, L"XInput Pad %i", i);
|
||||||
dm->AddDevice(new XInputDevice(i, temp));
|
dm->AddDevice(new XInputDevice(i, temp));
|
||||||
}
|
}
|
||||||
pXInputEnable(0);
|
pXInputEnable(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,39 +57,39 @@
|
||||||
/*
|
/*
|
||||||
* Device and/or Interface Class codes
|
* Device and/or Interface Class codes
|
||||||
*/
|
*/
|
||||||
#define USB_CLASS_PER_INTERFACE 0 /* for DeviceClass */
|
#define USB_CLASS_PER_INTERFACE 0 /* for DeviceClass */
|
||||||
#define USB_CLASS_AUDIO 1
|
#define USB_CLASS_AUDIO 1
|
||||||
#define USB_CLASS_COMM 2
|
#define USB_CLASS_COMM 2
|
||||||
#define USB_CLASS_HID 3
|
#define USB_CLASS_HID 3
|
||||||
#define USB_CLASS_PRINTER 7
|
#define USB_CLASS_PRINTER 7
|
||||||
#define USB_CLASS_MASS_STORAGE 8
|
#define USB_CLASS_MASS_STORAGE 8
|
||||||
#define USB_CLASS_HUB 9
|
#define USB_CLASS_HUB 9
|
||||||
#define USB_CLASS_DATA 10
|
#define USB_CLASS_DATA 10
|
||||||
#define USB_CLASS_VENDOR_SPEC 0xff
|
#define USB_CLASS_VENDOR_SPEC 0xff
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Descriptor types
|
* Descriptor types
|
||||||
*/
|
*/
|
||||||
#define USB_DT_DEVICE 0x01
|
#define USB_DT_DEVICE 0x01
|
||||||
#define USB_DT_CONFIG 0x02
|
#define USB_DT_CONFIG 0x02
|
||||||
#define USB_DT_STRING 0x03
|
#define USB_DT_STRING 0x03
|
||||||
#define USB_DT_INTERFACE 0x04
|
#define USB_DT_INTERFACE 0x04
|
||||||
#define USB_DT_ENDPOINT 0x05
|
#define USB_DT_ENDPOINT 0x05
|
||||||
|
|
||||||
#define USB_DT_HID 0x21
|
#define USB_DT_HID 0x21
|
||||||
#define USB_DT_REPORT 0x22
|
#define USB_DT_REPORT 0x22
|
||||||
#define USB_DT_PHYSICAL 0x23
|
#define USB_DT_PHYSICAL 0x23
|
||||||
#define USB_DT_HUB 0x29
|
#define USB_DT_HUB 0x29
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Descriptor sizes per descriptor type
|
* Descriptor sizes per descriptor type
|
||||||
*/
|
*/
|
||||||
#define USB_DT_DEVICE_SIZE 18
|
#define USB_DT_DEVICE_SIZE 18
|
||||||
#define USB_DT_CONFIG_SIZE 9
|
#define USB_DT_CONFIG_SIZE 9
|
||||||
#define USB_DT_INTERFACE_SIZE 9
|
#define USB_DT_INTERFACE_SIZE 9
|
||||||
#define USB_DT_ENDPOINT_SIZE 7
|
#define USB_DT_ENDPOINT_SIZE 7
|
||||||
#define USB_DT_ENDPOINT_AUDIO_SIZE 9 /* Audio extension */
|
#define USB_DT_ENDPOINT_AUDIO_SIZE 9 /* Audio extension */
|
||||||
#define USB_DT_HUB_NONVAR_SIZE 7
|
#define USB_DT_HUB_NONVAR_SIZE 7
|
||||||
|
|
||||||
|
|
||||||
/* ensure byte-packed structures */
|
/* ensure byte-packed structures */
|
||||||
|
@ -97,159 +97,168 @@
|
||||||
|
|
||||||
|
|
||||||
/* All standard descriptors have these 2 fields in common */
|
/* All standard descriptors have these 2 fields in common */
|
||||||
struct usb_descriptor_header {
|
struct usb_descriptor_header
|
||||||
unsigned char bLength;
|
{
|
||||||
unsigned char bDescriptorType;
|
unsigned char bLength;
|
||||||
|
unsigned char bDescriptorType;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* String descriptor */
|
/* String descriptor */
|
||||||
struct usb_string_descriptor {
|
struct usb_string_descriptor
|
||||||
unsigned char bLength;
|
{
|
||||||
unsigned char bDescriptorType;
|
unsigned char bLength;
|
||||||
unsigned short wData[1];
|
unsigned char bDescriptorType;
|
||||||
|
unsigned short wData[1];
|
||||||
};
|
};
|
||||||
|
|
||||||
/* HID descriptor */
|
/* HID descriptor */
|
||||||
struct usb_hid_descriptor {
|
struct usb_hid_descriptor
|
||||||
unsigned char bLength;
|
{
|
||||||
unsigned char bDescriptorType;
|
unsigned char bLength;
|
||||||
unsigned short bcdHID;
|
unsigned char bDescriptorType;
|
||||||
unsigned char bCountryCode;
|
unsigned short bcdHID;
|
||||||
unsigned char bNumDescriptors;
|
unsigned char bCountryCode;
|
||||||
|
unsigned char bNumDescriptors;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Endpoint descriptor */
|
/* Endpoint descriptor */
|
||||||
#define USB_MAXENDPOINTS 32
|
#define USB_MAXENDPOINTS 32
|
||||||
struct usb_endpoint_descriptor {
|
struct usb_endpoint_descriptor
|
||||||
unsigned char bLength;
|
{
|
||||||
unsigned char bDescriptorType;
|
unsigned char bLength;
|
||||||
unsigned char bEndpointAddress;
|
unsigned char bDescriptorType;
|
||||||
unsigned char bmAttributes;
|
unsigned char bEndpointAddress;
|
||||||
unsigned short wMaxPacketSize;
|
unsigned char bmAttributes;
|
||||||
unsigned char bInterval;
|
unsigned short wMaxPacketSize;
|
||||||
unsigned char bRefresh;
|
unsigned char bInterval;
|
||||||
unsigned char bSynchAddress;
|
unsigned char bRefresh;
|
||||||
|
unsigned char bSynchAddress;
|
||||||
|
|
||||||
unsigned char *extra; /* Extra descriptors */
|
unsigned char *extra; /* Extra descriptors */
|
||||||
int extralen;
|
int extralen;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define USB_ENDPOINT_ADDRESS_MASK 0x0f /* in bEndpointAddress */
|
#define USB_ENDPOINT_ADDRESS_MASK 0x0f /* in bEndpointAddress */
|
||||||
#define USB_ENDPOINT_DIR_MASK 0x80
|
#define USB_ENDPOINT_DIR_MASK 0x80
|
||||||
|
|
||||||
#define USB_ENDPOINT_TYPE_MASK 0x03 /* in bmAttributes */
|
#define USB_ENDPOINT_TYPE_MASK 0x03 /* in bmAttributes */
|
||||||
#define USB_ENDPOINT_TYPE_CONTROL 0
|
#define USB_ENDPOINT_TYPE_CONTROL 0
|
||||||
#define USB_ENDPOINT_TYPE_ISOCHRONOUS 1
|
#define USB_ENDPOINT_TYPE_ISOCHRONOUS 1
|
||||||
#define USB_ENDPOINT_TYPE_BULK 2
|
#define USB_ENDPOINT_TYPE_BULK 2
|
||||||
#define USB_ENDPOINT_TYPE_INTERRUPT 3
|
#define USB_ENDPOINT_TYPE_INTERRUPT 3
|
||||||
|
|
||||||
/* Interface descriptor */
|
/* Interface descriptor */
|
||||||
#define USB_MAXINTERFACES 32
|
#define USB_MAXINTERFACES 32
|
||||||
struct usb_interface_descriptor {
|
struct usb_interface_descriptor
|
||||||
unsigned char bLength;
|
{
|
||||||
unsigned char bDescriptorType;
|
unsigned char bLength;
|
||||||
unsigned char bInterfaceNumber;
|
unsigned char bDescriptorType;
|
||||||
unsigned char bAlternateSetting;
|
unsigned char bInterfaceNumber;
|
||||||
unsigned char bNumEndpoints;
|
unsigned char bAlternateSetting;
|
||||||
unsigned char bInterfaceClass;
|
unsigned char bNumEndpoints;
|
||||||
unsigned char bInterfaceSubClass;
|
unsigned char bInterfaceClass;
|
||||||
unsigned char bInterfaceProtocol;
|
unsigned char bInterfaceSubClass;
|
||||||
unsigned char iInterface;
|
unsigned char bInterfaceProtocol;
|
||||||
|
unsigned char iInterface;
|
||||||
|
|
||||||
struct usb_endpoint_descriptor *endpoint;
|
struct usb_endpoint_descriptor *endpoint;
|
||||||
|
|
||||||
unsigned char *extra; /* Extra descriptors */
|
unsigned char *extra; /* Extra descriptors */
|
||||||
int extralen;
|
int extralen;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define USB_MAXALTSETTING 128 /* Hard limit */
|
#define USB_MAXALTSETTING 128 /* Hard limit */
|
||||||
|
|
||||||
struct usb_interface {
|
struct usb_interface
|
||||||
struct usb_interface_descriptor *altsetting;
|
{
|
||||||
|
struct usb_interface_descriptor *altsetting;
|
||||||
|
|
||||||
int num_altsetting;
|
int num_altsetting;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Configuration descriptor information.. */
|
/* Configuration descriptor information.. */
|
||||||
#define USB_MAXCONFIG 8
|
#define USB_MAXCONFIG 8
|
||||||
struct usb_config_descriptor {
|
struct usb_config_descriptor
|
||||||
unsigned char bLength;
|
{
|
||||||
unsigned char bDescriptorType;
|
unsigned char bLength;
|
||||||
unsigned short wTotalLength;
|
unsigned char bDescriptorType;
|
||||||
unsigned char bNumInterfaces;
|
unsigned short wTotalLength;
|
||||||
unsigned char bConfigurationValue;
|
unsigned char bNumInterfaces;
|
||||||
unsigned char iConfiguration;
|
unsigned char bConfigurationValue;
|
||||||
unsigned char bmAttributes;
|
unsigned char iConfiguration;
|
||||||
unsigned char MaxPower;
|
unsigned char bmAttributes;
|
||||||
|
unsigned char MaxPower;
|
||||||
|
|
||||||
struct usb_interface *interface;
|
struct usb_interface *interface;
|
||||||
|
|
||||||
unsigned char *extra; /* Extra descriptors */
|
unsigned char *extra; /* Extra descriptors */
|
||||||
int extralen;
|
int extralen;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Device descriptor */
|
/* Device descriptor */
|
||||||
struct usb_device_descriptor {
|
struct usb_device_descriptor
|
||||||
unsigned char bLength;
|
{
|
||||||
unsigned char bDescriptorType;
|
unsigned char bLength;
|
||||||
unsigned short bcdUSB;
|
unsigned char bDescriptorType;
|
||||||
unsigned char bDeviceClass;
|
unsigned short bcdUSB;
|
||||||
unsigned char bDeviceSubClass;
|
unsigned char bDeviceClass;
|
||||||
unsigned char bDeviceProtocol;
|
unsigned char bDeviceSubClass;
|
||||||
unsigned char bMaxPacketSize0;
|
unsigned char bDeviceProtocol;
|
||||||
unsigned short idVendor;
|
unsigned char bMaxPacketSize0;
|
||||||
unsigned short idProduct;
|
unsigned short idVendor;
|
||||||
unsigned short bcdDevice;
|
unsigned short idProduct;
|
||||||
unsigned char iManufacturer;
|
unsigned short bcdDevice;
|
||||||
unsigned char iProduct;
|
unsigned char iManufacturer;
|
||||||
unsigned char iSerialNumber;
|
unsigned char iProduct;
|
||||||
unsigned char bNumConfigurations;
|
unsigned char iSerialNumber;
|
||||||
|
unsigned char bNumConfigurations;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct usb_ctrl_setup {
|
struct usb_ctrl_setup
|
||||||
unsigned char bRequestType;
|
{
|
||||||
unsigned char bRequest;
|
unsigned char bRequestType;
|
||||||
unsigned short wValue;
|
unsigned char bRequest;
|
||||||
unsigned short wIndex;
|
unsigned short wValue;
|
||||||
unsigned short wLength;
|
unsigned short wIndex;
|
||||||
|
unsigned short wLength;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Standard requests
|
* Standard requests
|
||||||
*/
|
*/
|
||||||
#define USB_REQ_GET_STATUS 0x00
|
#define USB_REQ_GET_STATUS 0x00
|
||||||
#define USB_REQ_CLEAR_FEATURE 0x01
|
#define USB_REQ_CLEAR_FEATURE 0x01
|
||||||
/* 0x02 is reserved */
|
/* 0x02 is reserved */
|
||||||
#define USB_REQ_SET_FEATURE 0x03
|
#define USB_REQ_SET_FEATURE 0x03
|
||||||
/* 0x04 is reserved */
|
/* 0x04 is reserved */
|
||||||
#define USB_REQ_SET_ADDRESS 0x05
|
#define USB_REQ_SET_ADDRESS 0x05
|
||||||
#define USB_REQ_GET_DESCRIPTOR 0x06
|
#define USB_REQ_GET_DESCRIPTOR 0x06
|
||||||
#define USB_REQ_SET_DESCRIPTOR 0x07
|
#define USB_REQ_SET_DESCRIPTOR 0x07
|
||||||
#define USB_REQ_GET_CONFIGURATION 0x08
|
#define USB_REQ_GET_CONFIGURATION 0x08
|
||||||
#define USB_REQ_SET_CONFIGURATION 0x09
|
#define USB_REQ_SET_CONFIGURATION 0x09
|
||||||
#define USB_REQ_GET_INTERFACE 0x0A
|
#define USB_REQ_GET_INTERFACE 0x0A
|
||||||
#define USB_REQ_SET_INTERFACE 0x0B
|
#define USB_REQ_SET_INTERFACE 0x0B
|
||||||
#define USB_REQ_SYNCH_FRAME 0x0C
|
#define USB_REQ_SYNCH_FRAME 0x0C
|
||||||
|
|
||||||
#define USB_TYPE_STANDARD (0x00 << 5)
|
#define USB_TYPE_STANDARD (0x00 << 5)
|
||||||
#define USB_TYPE_CLASS (0x01 << 5)
|
#define USB_TYPE_CLASS (0x01 << 5)
|
||||||
#define USB_TYPE_VENDOR (0x02 << 5)
|
#define USB_TYPE_VENDOR (0x02 << 5)
|
||||||
#define USB_TYPE_RESERVED (0x03 << 5)
|
#define USB_TYPE_RESERVED (0x03 << 5)
|
||||||
|
|
||||||
#define USB_RECIP_DEVICE 0x00
|
#define USB_RECIP_DEVICE 0x00
|
||||||
#define USB_RECIP_INTERFACE 0x01
|
#define USB_RECIP_INTERFACE 0x01
|
||||||
#define USB_RECIP_ENDPOINT 0x02
|
#define USB_RECIP_ENDPOINT 0x02
|
||||||
#define USB_RECIP_OTHER 0x03
|
#define USB_RECIP_OTHER 0x03
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Various libusb API related stuff
|
* Various libusb API related stuff
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define USB_ENDPOINT_IN 0x80
|
#define USB_ENDPOINT_IN 0x80
|
||||||
#define USB_ENDPOINT_OUT 0x00
|
#define USB_ENDPOINT_OUT 0x00
|
||||||
|
|
||||||
/* Error codes */
|
/* Error codes */
|
||||||
#define USB_ERROR_BEGIN 500000
|
#define USB_ERROR_BEGIN 500000
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is supposed to look weird. This file is generated from autoconf
|
* This is supposed to look weird. This file is generated from autoconf
|
||||||
|
@ -261,49 +270,54 @@ struct usb_ctrl_setup {
|
||||||
/* struct usb_device; */
|
/* struct usb_device; */
|
||||||
/* struct usb_bus; */
|
/* struct usb_bus; */
|
||||||
|
|
||||||
struct usb_device {
|
struct usb_device
|
||||||
struct usb_device *next, *prev;
|
{
|
||||||
|
struct usb_device *next, *prev;
|
||||||
|
|
||||||
char filename[LIBUSB_PATH_MAX];
|
char filename[LIBUSB_PATH_MAX];
|
||||||
|
|
||||||
struct usb_bus *bus;
|
struct usb_bus *bus;
|
||||||
|
|
||||||
struct usb_device_descriptor descriptor;
|
struct usb_device_descriptor descriptor;
|
||||||
struct usb_config_descriptor *config;
|
struct usb_config_descriptor *config;
|
||||||
|
|
||||||
void *dev; /* Darwin support */
|
void *dev; /* Darwin support */
|
||||||
|
|
||||||
unsigned char devnum;
|
unsigned char devnum;
|
||||||
|
|
||||||
unsigned char num_children;
|
unsigned char num_children;
|
||||||
struct usb_device **children;
|
struct usb_device **children;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct usb_bus {
|
struct usb_bus
|
||||||
struct usb_bus *next, *prev;
|
{
|
||||||
|
struct usb_bus *next, *prev;
|
||||||
|
|
||||||
char dirname[LIBUSB_PATH_MAX];
|
char dirname[LIBUSB_PATH_MAX];
|
||||||
|
|
||||||
struct usb_device *devices;
|
struct usb_device *devices;
|
||||||
unsigned long location;
|
unsigned long location;
|
||||||
|
|
||||||
struct usb_device *root_dev;
|
struct usb_device *root_dev;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Version information, Windows specific */
|
/* Version information, Windows specific */
|
||||||
struct usb_version {
|
struct usb_version
|
||||||
struct {
|
{
|
||||||
int major;
|
struct
|
||||||
int minor;
|
{
|
||||||
int micro;
|
int major;
|
||||||
int nano;
|
int minor;
|
||||||
} dll;
|
int micro;
|
||||||
struct {
|
int nano;
|
||||||
int major;
|
} dll;
|
||||||
int minor;
|
struct
|
||||||
int micro;
|
{
|
||||||
int nano;
|
int major;
|
||||||
} driver;
|
int minor;
|
||||||
|
int micro;
|
||||||
|
int nano;
|
||||||
|
} driver;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -324,92 +338,92 @@ typedef struct usb_dev_handle usb_dev_handle;
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Function prototypes */
|
/* Function prototypes */
|
||||||
|
|
||||||
/* usb.c */
|
/* usb.c */
|
||||||
usb_dev_handle *usb_open(struct usb_device *dev);
|
usb_dev_handle *usb_open(struct usb_device *dev);
|
||||||
int usb_close(usb_dev_handle *dev);
|
int usb_close(usb_dev_handle *dev);
|
||||||
int usb_get_string(usb_dev_handle *dev, int index, int langid, char *buf,
|
int usb_get_string(usb_dev_handle *dev, int index, int langid, char *buf,
|
||||||
size_t buflen);
|
size_t buflen);
|
||||||
int usb_get_string_simple(usb_dev_handle *dev, int index, char *buf,
|
int usb_get_string_simple(usb_dev_handle *dev, int index, char *buf,
|
||||||
size_t buflen);
|
size_t buflen);
|
||||||
|
|
||||||
/* descriptors.c */
|
/* descriptors.c */
|
||||||
int usb_get_descriptor_by_endpoint(usb_dev_handle *udev, int ep,
|
int usb_get_descriptor_by_endpoint(usb_dev_handle *udev, int ep,
|
||||||
unsigned char type, unsigned char index,
|
unsigned char type, unsigned char index,
|
||||||
void *buf, int size);
|
void *buf, int size);
|
||||||
int usb_get_descriptor(usb_dev_handle *udev, unsigned char type,
|
int usb_get_descriptor(usb_dev_handle *udev, unsigned char type,
|
||||||
unsigned char index, void *buf, int size);
|
unsigned char index, void *buf, int size);
|
||||||
|
|
||||||
/* <arch>.c */
|
/* <arch>.c */
|
||||||
int usb_bulk_write(usb_dev_handle *dev, int ep, char *bytes, int size,
|
int usb_bulk_write(usb_dev_handle *dev, int ep, char *bytes, int size,
|
||||||
int timeout);
|
int timeout);
|
||||||
int usb_bulk_read(usb_dev_handle *dev, int ep, char *bytes, int size,
|
int usb_bulk_read(usb_dev_handle *dev, int ep, char *bytes, int size,
|
||||||
|
int timeout);
|
||||||
|
int usb_interrupt_write(usb_dev_handle *dev, int ep, char *bytes, int size,
|
||||||
|
int timeout);
|
||||||
|
int usb_interrupt_read(usb_dev_handle *dev, int ep, char *bytes, int size,
|
||||||
|
int timeout);
|
||||||
|
int usb_control_msg(usb_dev_handle *dev, int requesttype, int request,
|
||||||
|
int value, int index, char *bytes, int size,
|
||||||
int timeout);
|
int timeout);
|
||||||
int usb_interrupt_write(usb_dev_handle *dev, int ep, char *bytes, int size,
|
int usb_set_configuration(usb_dev_handle *dev, int configuration);
|
||||||
int timeout);
|
int usb_claim_interface(usb_dev_handle *dev, int interface);
|
||||||
int usb_interrupt_read(usb_dev_handle *dev, int ep, char *bytes, int size,
|
int usb_release_interface(usb_dev_handle *dev, int interface);
|
||||||
int timeout);
|
int usb_set_altinterface(usb_dev_handle *dev, int alternate);
|
||||||
int usb_control_msg(usb_dev_handle *dev, int requesttype, int request,
|
int usb_resetep(usb_dev_handle *dev, unsigned int ep);
|
||||||
int value, int index, char *bytes, int size,
|
int usb_clear_halt(usb_dev_handle *dev, unsigned int ep);
|
||||||
int timeout);
|
int usb_reset(usb_dev_handle *dev);
|
||||||
int usb_set_configuration(usb_dev_handle *dev, int configuration);
|
|
||||||
int usb_claim_interface(usb_dev_handle *dev, int interface);
|
|
||||||
int usb_release_interface(usb_dev_handle *dev, int interface);
|
|
||||||
int usb_set_altinterface(usb_dev_handle *dev, int alternate);
|
|
||||||
int usb_resetep(usb_dev_handle *dev, unsigned int ep);
|
|
||||||
int usb_clear_halt(usb_dev_handle *dev, unsigned int ep);
|
|
||||||
int usb_reset(usb_dev_handle *dev);
|
|
||||||
|
|
||||||
char *usb_strerror(void);
|
char *usb_strerror(void);
|
||||||
|
|
||||||
void usb_init(void);
|
void usb_init(void);
|
||||||
void usb_set_debug(int level);
|
void usb_set_debug(int level);
|
||||||
int usb_find_busses(void);
|
int usb_find_busses(void);
|
||||||
int usb_find_devices(void);
|
int usb_find_devices(void);
|
||||||
struct usb_device *usb_device(usb_dev_handle *dev);
|
struct usb_device *usb_device(usb_dev_handle *dev);
|
||||||
struct usb_bus *usb_get_busses(void);
|
struct usb_bus *usb_get_busses(void);
|
||||||
|
|
||||||
|
|
||||||
/* Windows specific functions */
|
/* Windows specific functions */
|
||||||
|
|
||||||
#define LIBUSB_HAS_INSTALL_SERVICE_NP 1
|
#define LIBUSB_HAS_INSTALL_SERVICE_NP 1
|
||||||
int usb_install_service_np(void);
|
int usb_install_service_np(void);
|
||||||
void CALLBACK usb_install_service_np_rundll(HWND wnd, HINSTANCE instance,
|
void CALLBACK usb_install_service_np_rundll(HWND wnd, HINSTANCE instance,
|
||||||
|
LPSTR cmd_line, int cmd_show);
|
||||||
|
|
||||||
|
#define LIBUSB_HAS_UNINSTALL_SERVICE_NP 1
|
||||||
|
int usb_uninstall_service_np(void);
|
||||||
|
void CALLBACK usb_uninstall_service_np_rundll(HWND wnd, HINSTANCE instance,
|
||||||
LPSTR cmd_line, int cmd_show);
|
LPSTR cmd_line, int cmd_show);
|
||||||
|
|
||||||
#define LIBUSB_HAS_UNINSTALL_SERVICE_NP 1
|
#define LIBUSB_HAS_INSTALL_DRIVER_NP 1
|
||||||
int usb_uninstall_service_np(void);
|
int usb_install_driver_np(const char *inf_file);
|
||||||
void CALLBACK usb_uninstall_service_np_rundll(HWND wnd, HINSTANCE instance,
|
void CALLBACK usb_install_driver_np_rundll(HWND wnd, HINSTANCE instance,
|
||||||
LPSTR cmd_line, int cmd_show);
|
LPSTR cmd_line, int cmd_show);
|
||||||
|
|
||||||
#define LIBUSB_HAS_INSTALL_DRIVER_NP 1
|
#define LIBUSB_HAS_TOUCH_INF_FILE_NP 1
|
||||||
int usb_install_driver_np(const char *inf_file);
|
int usb_touch_inf_file_np(const char *inf_file);
|
||||||
void CALLBACK usb_install_driver_np_rundll(HWND wnd, HINSTANCE instance,
|
void CALLBACK usb_touch_inf_file_np_rundll(HWND wnd, HINSTANCE instance,
|
||||||
LPSTR cmd_line, int cmd_show);
|
LPSTR cmd_line, int cmd_show);
|
||||||
|
|
||||||
#define LIBUSB_HAS_TOUCH_INF_FILE_NP 1
|
#define LIBUSB_HAS_INSTALL_NEEDS_RESTART_NP 1
|
||||||
int usb_touch_inf_file_np(const char *inf_file);
|
int usb_install_needs_restart_np(void);
|
||||||
void CALLBACK usb_touch_inf_file_np_rundll(HWND wnd, HINSTANCE instance,
|
|
||||||
LPSTR cmd_line, int cmd_show);
|
|
||||||
|
|
||||||
#define LIBUSB_HAS_INSTALL_NEEDS_RESTART_NP 1
|
const struct usb_version *usb_get_version(void);
|
||||||
int usb_install_needs_restart_np(void);
|
|
||||||
|
|
||||||
const struct usb_version *usb_get_version(void);
|
int usb_isochronous_setup_async(usb_dev_handle *dev, void **context,
|
||||||
|
unsigned char ep, int pktsize);
|
||||||
|
int usb_bulk_setup_async(usb_dev_handle *dev, void **context,
|
||||||
|
unsigned char ep);
|
||||||
|
int usb_interrupt_setup_async(usb_dev_handle *dev, void **context,
|
||||||
|
unsigned char ep);
|
||||||
|
|
||||||
int usb_isochronous_setup_async(usb_dev_handle *dev, void **context,
|
int usb_submit_async(void *context, char *bytes, int size);
|
||||||
unsigned char ep, int pktsize);
|
int usb_reap_async(void *context, int timeout);
|
||||||
int usb_bulk_setup_async(usb_dev_handle *dev, void **context,
|
int usb_reap_async_nocancel(void *context, int timeout);
|
||||||
unsigned char ep);
|
int usb_cancel_async(void *context);
|
||||||
int usb_interrupt_setup_async(usb_dev_handle *dev, void **context,
|
int usb_free_async(void **context);
|
||||||
unsigned char ep);
|
|
||||||
|
|
||||||
int usb_submit_async(void *context, char *bytes, int size);
|
|
||||||
int usb_reap_async(void *context, int timeout);
|
|
||||||
int usb_reap_async_nocancel(void *context, int timeout);
|
|
||||||
int usb_cancel_async(void *context);
|
|
||||||
int usb_free_async(void **context);
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -418,4 +432,3 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* __USB_H__ */
|
#endif /* __USB_H__ */
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
#include <gdk/gdkx.h>
|
#include <gdk/gdkx.h>
|
||||||
#include "PadLinux.h"
|
#include "PadLinux.h"
|
||||||
|
|
||||||
Display* GSdsp;
|
Display *GSdsp;
|
||||||
int autoRepeatMode;
|
int autoRepeatMode;
|
||||||
|
|
||||||
void _PadUpdate(int pad)
|
void _PadUpdate(int pad)
|
||||||
|
@ -31,7 +31,7 @@ void _PadUpdate(int pad)
|
||||||
XNextEvent(GSdsp, &evt);
|
XNextEvent(GSdsp, &evt);
|
||||||
switch (evt.type) {
|
switch (evt.type) {
|
||||||
case KeyPress:
|
case KeyPress:
|
||||||
key = XLookupKeysym((XKeyEvent*)&evt, 0);
|
key = XLookupKeysym((XKeyEvent *)&evt, 0);
|
||||||
|
|
||||||
// Add code to check if it's one of the keys we configured here on a real pda plugin..
|
// Add code to check if it's one of the keys we configured here on a real pda plugin..
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ void _PadUpdate(int pad)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KeyRelease:
|
case KeyRelease:
|
||||||
key = XLookupKeysym((XKeyEvent*)&evt, 0);
|
key = XLookupKeysym((XKeyEvent *)&evt, 0);
|
||||||
|
|
||||||
// Add code to check if it's one of the keys we configured here on a real pda plugin..
|
// Add code to check if it's one of the keys we configured here on a real pda plugin..
|
||||||
|
|
||||||
|
@ -59,12 +59,12 @@ void _PadUpdate(int pad)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 _PADOpen(void* pDsp)
|
s32 _PADOpen(void *pDsp)
|
||||||
{
|
{
|
||||||
|
|
||||||
GtkScrolledWindow* win;
|
GtkScrolledWindow *win;
|
||||||
|
|
||||||
win = *(GtkScrolledWindow**)pDsp;
|
win = *(GtkScrolledWindow **)pDsp;
|
||||||
|
|
||||||
if (GTK_IS_WIDGET(win)) {
|
if (GTK_IS_WIDGET(win)) {
|
||||||
// Since we have a GtkScrolledWindow, for now we'll grab whatever display
|
// Since we have a GtkScrolledWindow, for now we'll grab whatever display
|
||||||
|
@ -73,7 +73,7 @@ s32 _PADOpen(void* pDsp)
|
||||||
// be able to manage... --arcum42
|
// be able to manage... --arcum42
|
||||||
GSdsp = GDK_DISPLAY_XDISPLAY(gdk_display_get_default());
|
GSdsp = GDK_DISPLAY_XDISPLAY(gdk_display_get_default());
|
||||||
} else {
|
} else {
|
||||||
GSdsp = *(Display**)pDsp;
|
GSdsp = *(Display **)pDsp;
|
||||||
}
|
}
|
||||||
|
|
||||||
XAutoRepeatOff(GSdsp);
|
XAutoRepeatOff(GSdsp);
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
|
|
||||||
void _PadUpdate(int pad);
|
void _PadUpdate(int pad);
|
||||||
s32 _PADOpen(void* pDsp);
|
s32 _PADOpen(void *pDsp);
|
||||||
void _PADClose();
|
void _PADClose();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -32,7 +32,7 @@ static char libraryName[256];
|
||||||
string s_strIniPath = "inis";
|
string s_strIniPath = "inis";
|
||||||
string s_strLogPath = "logs";
|
string s_strLogPath = "logs";
|
||||||
|
|
||||||
FILE* padLog;
|
FILE *padLog;
|
||||||
Config conf;
|
Config conf;
|
||||||
keyEvent event;
|
keyEvent event;
|
||||||
static keyEvent s_event;
|
static keyEvent s_event;
|
||||||
|
@ -43,7 +43,7 @@ PS2EgetLibType()
|
||||||
return PS2E_LT_PAD;
|
return PS2E_LT_PAD;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(char*)
|
EXPORT_C_(char *)
|
||||||
PS2EgetLibName()
|
PS2EgetLibName()
|
||||||
{
|
{
|
||||||
snprintf(libraryName, 255, "Padnull Driver %lld%s", SVN_REV, SVN_MODS ? "m" : "");
|
snprintf(libraryName, 255, "Padnull Driver %lld%s", SVN_REV, SVN_MODS ? "m" : "");
|
||||||
|
@ -56,7 +56,7 @@ PS2EgetLibVersion2(u32 type)
|
||||||
return (version << 16) | (revision << 8) | build;
|
return (version << 16) | (revision << 8) | build;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __Log(const char* fmt, ...)
|
void __Log(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list list;
|
va_list list;
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ void __Log(const char* fmt, ...)
|
||||||
va_end(list);
|
va_end(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
void __LogToConsole(const char* fmt, ...)
|
void __LogToConsole(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list list;
|
va_list list;
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ void __LogToConsole(const char* fmt, ...)
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(void)
|
EXPORT_C_(void)
|
||||||
PADsetSettingsDir(const char* dir)
|
PADsetSettingsDir(const char *dir)
|
||||||
{
|
{
|
||||||
s_strIniPath = (dir == NULL) ? "inis" : dir;
|
s_strIniPath = (dir == NULL) ? "inis" : dir;
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,7 @@ bool OpenLog()
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(void)
|
EXPORT_C_(void)
|
||||||
PADsetLogDir(const char* dir)
|
PADsetLogDir(const char *dir)
|
||||||
{
|
{
|
||||||
// Get the path to the log directory.
|
// Get the path to the log directory.
|
||||||
s_strLogPath = (dir == NULL) ? "logs" : dir;
|
s_strLogPath = (dir == NULL) ? "logs" : dir;
|
||||||
|
@ -144,7 +144,7 @@ PADshutdown()
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(s32)
|
EXPORT_C_(s32)
|
||||||
PADopen(void* pDsp)
|
PADopen(void *pDsp)
|
||||||
{
|
{
|
||||||
memset(&event, 0, sizeof(event));
|
memset(&event, 0, sizeof(event));
|
||||||
|
|
||||||
|
@ -158,7 +158,7 @@ PADclose()
|
||||||
}
|
}
|
||||||
|
|
||||||
// PADkeyEvent is called every vsync (return NULL if no event)
|
// PADkeyEvent is called every vsync (return NULL if no event)
|
||||||
EXPORT_C_(keyEvent*)
|
EXPORT_C_(keyEvent *)
|
||||||
PADkeyEvent()
|
PADkeyEvent()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -204,12 +204,12 @@ PADupdate(int pad)
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(void)
|
EXPORT_C_(void)
|
||||||
PADgsDriverInfo(GSdriverInfo* info)
|
PADgsDriverInfo(GSdriverInfo *info)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(s32)
|
EXPORT_C_(s32)
|
||||||
PADfreeze(int mode, freezeData* data)
|
PADfreeze(int mode, freezeData *data)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,10 +42,10 @@ typedef struct
|
||||||
} Config;
|
} Config;
|
||||||
|
|
||||||
extern Config conf;
|
extern Config conf;
|
||||||
extern FILE* padLog;
|
extern FILE *padLog;
|
||||||
extern keyEvent event;
|
extern keyEvent event;
|
||||||
|
|
||||||
extern void __Log(char* fmt, ...);
|
extern void __Log(char *fmt, ...);
|
||||||
extern void SaveConfig();
|
extern void SaveConfig();
|
||||||
extern void LoadConfig();
|
extern void LoadConfig();
|
||||||
|
|
||||||
|
|
|
@ -52,9 +52,9 @@ void _PadUpdate(int pad)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 _PADOpen(void* pDsp)
|
s32 _PADOpen(void *pDsp)
|
||||||
{
|
{
|
||||||
GShwnd = (HWND) * (long*)pDsp;
|
GShwnd = (HWND) * (long *)pDsp;
|
||||||
|
|
||||||
if (GShwnd != NULL && GSwndProc != NULL) {
|
if (GShwnd != NULL && GSwndProc != NULL) {
|
||||||
// revert
|
// revert
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
void _PadUpdate(int pad);
|
void _PadUpdate(int pad);
|
||||||
s32 _PADOpen(void* pDsp);
|
s32 _PADOpen(void *pDsp);
|
||||||
void _PADClose();
|
void _PADClose();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -36,14 +36,14 @@ const u32 minor = 0; // increase that with each version
|
||||||
#define RELEASE_MS 437L
|
#define RELEASE_MS 437L
|
||||||
|
|
||||||
#ifdef PCSX2_DEBUG
|
#ifdef PCSX2_DEBUG
|
||||||
char* libraryName = "SPU2null (Debug)";
|
char *libraryName = "SPU2null (Debug)";
|
||||||
#else
|
#else
|
||||||
char* libraryName = "SPU2null ";
|
char *libraryName = "SPU2null ";
|
||||||
#endif
|
#endif
|
||||||
string s_strIniPath = "inis/";
|
string s_strIniPath = "inis/";
|
||||||
string s_strLogPath = "logs/";
|
string s_strLogPath = "logs/";
|
||||||
|
|
||||||
FILE* spu2Log;
|
FILE *spu2Log;
|
||||||
Config conf;
|
Config conf;
|
||||||
|
|
||||||
ADMA Adma4;
|
ADMA Adma4;
|
||||||
|
@ -52,9 +52,9 @@ ADMA Adma7;
|
||||||
u32 MemAddr[2];
|
u32 MemAddr[2];
|
||||||
u32 g_nSpuInit = 0;
|
u32 g_nSpuInit = 0;
|
||||||
u16 interrupt = 0;
|
u16 interrupt = 0;
|
||||||
s8* spu2regs = NULL;
|
s8 *spu2regs = NULL;
|
||||||
u16* spu2mem = NULL;
|
u16 *spu2mem = NULL;
|
||||||
u16* pSpuIrq[2] = {NULL};
|
u16 *pSpuIrq[2] = {NULL};
|
||||||
u32 dwEndChannel2[2] = {0}; // keeps track of what channels have ended
|
u32 dwEndChannel2[2] = {0}; // keeps track of what channels have ended
|
||||||
u32 dwNoiseVal = 1; // global noise generator
|
u32 dwNoiseVal = 1; // global noise generator
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ PS2EgetLibType()
|
||||||
return PS2E_LT_SPU2;
|
return PS2E_LT_SPU2;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(char*)
|
EXPORT_C_(char *)
|
||||||
PS2EgetLibName()
|
PS2EgetLibName()
|
||||||
{
|
{
|
||||||
return libraryName;
|
return libraryName;
|
||||||
|
@ -101,7 +101,7 @@ PS2EgetLibVersion2(u32 type)
|
||||||
return (version << 16) | (revision << 8) | build | (minor << 24);
|
return (version << 16) | (revision << 8) | build | (minor << 24);
|
||||||
}
|
}
|
||||||
|
|
||||||
void __Log(char* fmt, ...)
|
void __Log(char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list list;
|
va_list list;
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ void __Log(char* fmt, ...)
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(void)
|
EXPORT_C_(void)
|
||||||
SPU2setSettingsDir(const char* dir)
|
SPU2setSettingsDir(const char *dir)
|
||||||
{
|
{
|
||||||
s_strIniPath = (dir == NULL) ? "inis/" : dir;
|
s_strIniPath = (dir == NULL) ? "inis/" : dir;
|
||||||
}
|
}
|
||||||
|
@ -142,7 +142,7 @@ bool OpenLog()
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(void)
|
EXPORT_C_(void)
|
||||||
SPU2setLogDir(const char* dir)
|
SPU2setLogDir(const char *dir)
|
||||||
{
|
{
|
||||||
// Get the path to the log directory.
|
// Get the path to the log directory.
|
||||||
s_strLogPath = (dir == NULL) ? "logs/" : dir;
|
s_strLogPath = (dir == NULL) ? "logs/" : dir;
|
||||||
|
@ -160,14 +160,14 @@ SPU2init()
|
||||||
{
|
{
|
||||||
OpenLog();
|
OpenLog();
|
||||||
|
|
||||||
spu2regs = (s8*)malloc(0x10000);
|
spu2regs = (s8 *)malloc(0x10000);
|
||||||
if (spu2regs == NULL) {
|
if (spu2regs == NULL) {
|
||||||
SysMessage("Error allocating Memory\n");
|
SysMessage("Error allocating Memory\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
memset(spu2regs, 0, 0x10000);
|
memset(spu2regs, 0, 0x10000);
|
||||||
|
|
||||||
spu2mem = (u16*)malloc(0x200000); // 2Mb
|
spu2mem = (u16 *)malloc(0x200000); // 2Mb
|
||||||
if (spu2mem == NULL) {
|
if (spu2mem == NULL) {
|
||||||
SysMessage("Error allocating Memory\n");
|
SysMessage("Error allocating Memory\n");
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -185,9 +185,9 @@ SPU2init()
|
||||||
// init each channel
|
// init each channel
|
||||||
for (u32 i = 0; i < ArraySize(voices); ++i) {
|
for (u32 i = 0; i < ArraySize(voices); ++i) {
|
||||||
|
|
||||||
voices[i].pLoop = voices[i].pStart = voices[i].pCurr = (u8*)spu2mem;
|
voices[i].pLoop = voices[i].pStart = voices[i].pCurr = (u8 *)spu2mem;
|
||||||
|
|
||||||
voices[i].pvoice = (_SPU_VOICE*)((u8*)spu2regs + voices[i].memoffset) + (i % 24);
|
voices[i].pvoice = (_SPU_VOICE *)((u8 *)spu2regs + voices[i].memoffset) + (i % 24);
|
||||||
voices[i].ADSRX.SustainLevel = 1024; // -> init sustain
|
voices[i].ADSRX.SustainLevel = 1024; // -> init sustain
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,7 +195,7 @@ SPU2init()
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(s32)
|
EXPORT_C_(s32)
|
||||||
SPU2open(void* pDsp)
|
SPU2open(void *pDsp)
|
||||||
{
|
{
|
||||||
LoadConfig();
|
LoadConfig();
|
||||||
SPUCycles = SPUWorkerCycles = 0;
|
SPUCycles = SPUWorkerCycles = 0;
|
||||||
|
@ -286,16 +286,16 @@ void InitADSR() // INIT ADSR
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int MixADSR(VOICE_PROCESSED* pvoice) // MIX ADSR
|
int MixADSR(VOICE_PROCESSED *pvoice) // MIX ADSR
|
||||||
{
|
{
|
||||||
if (pvoice->bStop) // should be stopped:
|
if (pvoice->bStop) // should be stopped:
|
||||||
{
|
{
|
||||||
if (pvoice->bIgnoreLoop == 0) {
|
if (pvoice->bIgnoreLoop == 0) {
|
||||||
pvoice->ADSRX.EnvelopeVol = 0;
|
pvoice->ADSRX.EnvelopeVol = 0;
|
||||||
pvoice->bOn = false;
|
pvoice->bOn = false;
|
||||||
pvoice->pStart = (u8*)(spu2mem + pvoice->iStartAddr);
|
pvoice->pStart = (u8 *)(spu2mem + pvoice->iStartAddr);
|
||||||
pvoice->pLoop = (u8*)(spu2mem + pvoice->iStartAddr);
|
pvoice->pLoop = (u8 *)(spu2mem + pvoice->iStartAddr);
|
||||||
pvoice->pCurr = (u8*)(spu2mem + pvoice->iStartAddr);
|
pvoice->pCurr = (u8 *)(spu2mem + pvoice->iStartAddr);
|
||||||
pvoice->bStop = true;
|
pvoice->bStop = true;
|
||||||
pvoice->bIgnoreLoop = false;
|
pvoice->bIgnoreLoop = false;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -335,9 +335,9 @@ int MixADSR(VOICE_PROCESSED* pvoice) // MIX ADSR
|
||||||
if (pvoice->ADSRX.EnvelopeVol < 0) {
|
if (pvoice->ADSRX.EnvelopeVol < 0) {
|
||||||
pvoice->ADSRX.EnvelopeVol = 0;
|
pvoice->ADSRX.EnvelopeVol = 0;
|
||||||
pvoice->bOn = false;
|
pvoice->bOn = false;
|
||||||
pvoice->pStart = (u8*)(spu2mem + pvoice->iStartAddr);
|
pvoice->pStart = (u8 *)(spu2mem + pvoice->iStartAddr);
|
||||||
pvoice->pLoop = (u8*)(spu2mem + pvoice->iStartAddr);
|
pvoice->pLoop = (u8 *)(spu2mem + pvoice->iStartAddr);
|
||||||
pvoice->pCurr = (u8*)(spu2mem + pvoice->iStartAddr);
|
pvoice->pCurr = (u8 *)(spu2mem + pvoice->iStartAddr);
|
||||||
pvoice->bStop = true;
|
pvoice->bStop = true;
|
||||||
pvoice->bIgnoreLoop = false;
|
pvoice->bIgnoreLoop = false;
|
||||||
//pvoice->bReverb=0;
|
//pvoice->bReverb=0;
|
||||||
|
@ -469,10 +469,10 @@ int MixADSR(VOICE_PROCESSED* pvoice) // MIX ADSR
|
||||||
// simulate SPU2 for 1ms
|
// simulate SPU2 for 1ms
|
||||||
void SPU2Worker()
|
void SPU2Worker()
|
||||||
{
|
{
|
||||||
u8* start;
|
u8 *start;
|
||||||
int ch, flags;
|
int ch, flags;
|
||||||
|
|
||||||
VOICE_PROCESSED* pChannel = voices;
|
VOICE_PROCESSED *pChannel = voices;
|
||||||
for (ch = 0; ch < SPU_NUMBER_VOICES; ch++, pChannel++) // loop em all... we will collect 1 ms of sound of each playing channel
|
for (ch = 0; ch < SPU_NUMBER_VOICES; ch++, pChannel++) // loop em all... we will collect 1 ms of sound of each playing channel
|
||||||
{
|
{
|
||||||
if (pChannel->bNew) {
|
if (pChannel->bNew) {
|
||||||
|
@ -497,7 +497,7 @@ void SPU2Worker()
|
||||||
start = pChannel->pCurr; // set up the current pos
|
start = pChannel->pCurr; // set up the current pos
|
||||||
|
|
||||||
// special "stop" sign
|
// special "stop" sign
|
||||||
if (start == (u8*)-1) //!pChannel->bOn
|
if (start == (u8 *)-1) //!pChannel->bOn
|
||||||
{
|
{
|
||||||
pChannel->bOn = false; // -> turn everything off
|
pChannel->bOn = false; // -> turn everything off
|
||||||
pChannel->ADSRX.lVolume = 0;
|
pChannel->ADSRX.lVolume = 0;
|
||||||
|
@ -515,7 +515,7 @@ void SPU2Worker()
|
||||||
// some callback and irq active?
|
// some callback and irq active?
|
||||||
if (pChannel->GetCtrl()->irq) {
|
if (pChannel->GetCtrl()->irq) {
|
||||||
// if irq address reached or irq on looping addr, when stop/loop flag is set
|
// if irq address reached or irq on looping addr, when stop/loop flag is set
|
||||||
u8* pirq = (u8*)pSpuIrq[ch >= 24];
|
u8 *pirq = (u8 *)pSpuIrq[ch >= 24];
|
||||||
if ((pirq > start - 16 && pirq <= start) || ((flags & 1) && (pirq > pChannel->pLoop - 16 && pirq <= pChannel->pLoop))) {
|
if ((pirq > start - 16 && pirq <= start) || ((flags & 1) && (pirq > pChannel->pLoop - 16 && pirq <= pChannel->pLoop))) {
|
||||||
IRQINFO |= 4 << (int)(ch >= 24);
|
IRQINFO |= 4 << (int)(ch >= 24);
|
||||||
irqCallbackSPU2();
|
irqCallbackSPU2();
|
||||||
|
@ -533,7 +533,7 @@ void SPU2Worker()
|
||||||
//if(!(flags&2)) // 1+2: do loop... otherwise: stop
|
//if(!(flags&2)) // 1+2: do loop... otherwise: stop
|
||||||
if (flags != 3 || pChannel->pLoop == NULL) // PETE: if we don't check exactly for 3, loop hang ups will happen (DQ4, for example)
|
if (flags != 3 || pChannel->pLoop == NULL) // PETE: if we don't check exactly for 3, loop hang ups will happen (DQ4, for example)
|
||||||
{ // and checking if pLoop is set avoids crashes, yeah
|
{ // and checking if pLoop is set avoids crashes, yeah
|
||||||
start = (u8*)-1;
|
start = (u8 *)-1;
|
||||||
pChannel->bStop = true;
|
pChannel->bStop = true;
|
||||||
pChannel->bIgnoreLoop = false;
|
pChannel->bIgnoreLoop = false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -596,7 +596,7 @@ void SPU2Worker()
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(void)
|
EXPORT_C_(void)
|
||||||
SPU2readDMA4Mem(u16* pMem, int size)
|
SPU2readDMA4Mem(u16 *pMem, int size)
|
||||||
{
|
{
|
||||||
u32 spuaddr = C0_SPUADDR;
|
u32 spuaddr = C0_SPUADDR;
|
||||||
int i;
|
int i;
|
||||||
|
@ -604,7 +604,7 @@ SPU2readDMA4Mem(u16* pMem, int size)
|
||||||
SPU2_LOG("SPU2 readDMA4Mem size %x, addr: %x\n", size, pMem);
|
SPU2_LOG("SPU2 readDMA4Mem size %x, addr: %x\n", size, pMem);
|
||||||
|
|
||||||
for (i = 0; i < size; i++) {
|
for (i = 0; i < size; i++) {
|
||||||
*pMem++ = *(u16*)(spu2mem + spuaddr);
|
*pMem++ = *(u16 *)(spu2mem + spuaddr);
|
||||||
if ((spu2Rs16(REG_C0_CTRL) & 0x40) && C0_IRQA == spuaddr) {
|
if ((spu2Rs16(REG_C0_CTRL) & 0x40) && C0_IRQA == spuaddr) {
|
||||||
spu2Ru16(SPDIF_OUT) |= 0x4;
|
spu2Ru16(SPDIF_OUT) |= 0x4;
|
||||||
C0_SPUADDR_SET(spuaddr);
|
C0_SPUADDR_SET(spuaddr);
|
||||||
|
@ -628,7 +628,7 @@ SPU2readDMA4Mem(u16* pMem, int size)
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(void)
|
EXPORT_C_(void)
|
||||||
SPU2readDMA7Mem(u16* pMem, int size)
|
SPU2readDMA7Mem(u16 *pMem, int size)
|
||||||
{
|
{
|
||||||
u32 spuaddr = C1_SPUADDR;
|
u32 spuaddr = C1_SPUADDR;
|
||||||
int i;
|
int i;
|
||||||
|
@ -636,7 +636,7 @@ SPU2readDMA7Mem(u16* pMem, int size)
|
||||||
SPU2_LOG("SPU2 readDMA7Mem size %x, addr: %x\n", size, pMem);
|
SPU2_LOG("SPU2 readDMA7Mem size %x, addr: %x\n", size, pMem);
|
||||||
|
|
||||||
for (i = 0; i < size; i++) {
|
for (i = 0; i < size; i++) {
|
||||||
*pMem++ = *(u16*)(spu2mem + spuaddr);
|
*pMem++ = *(u16 *)(spu2mem + spuaddr);
|
||||||
if ((spu2Rs16(REG_C1_CTRL) & 0x40) && C1_IRQA == spuaddr) {
|
if ((spu2Rs16(REG_C1_CTRL) & 0x40) && C1_IRQA == spuaddr) {
|
||||||
spu2Ru16(SPDIF_OUT) |= 0x8;
|
spu2Ru16(SPDIF_OUT) |= 0x8;
|
||||||
C1_SPUADDR_SET(spuaddr);
|
C1_SPUADDR_SET(spuaddr);
|
||||||
|
@ -676,9 +676,9 @@ int ADMAS4Write()
|
||||||
|
|
||||||
spuaddr = C0_SPUADDR;
|
spuaddr = C0_SPUADDR;
|
||||||
// SPU2 Deinterleaves the Left and Right Channels
|
// SPU2 Deinterleaves the Left and Right Channels
|
||||||
memcpy((s16*)(spu2mem + spuaddr + 0x2000), (s16*)Adma4.MemAddr, 512);
|
memcpy((s16 *)(spu2mem + spuaddr + 0x2000), (s16 *)Adma4.MemAddr, 512);
|
||||||
Adma4.MemAddr += 256;
|
Adma4.MemAddr += 256;
|
||||||
memcpy((s16*)(spu2mem + spuaddr + 0x2200), (s16*)Adma4.MemAddr, 512);
|
memcpy((s16 *)(spu2mem + spuaddr + 0x2200), (s16 *)Adma4.MemAddr, 512);
|
||||||
Adma4.MemAddr += 256;
|
Adma4.MemAddr += 256;
|
||||||
spuaddr = (spuaddr + 256) & 511;
|
spuaddr = (spuaddr + 256) & 511;
|
||||||
C0_SPUADDR_SET(spuaddr);
|
C0_SPUADDR_SET(spuaddr);
|
||||||
|
@ -703,9 +703,9 @@ int ADMAS7Write()
|
||||||
|
|
||||||
spuaddr = C1_SPUADDR;
|
spuaddr = C1_SPUADDR;
|
||||||
// SPU2 Deinterleaves the Left and Right Channels
|
// SPU2 Deinterleaves the Left and Right Channels
|
||||||
memcpy((s16*)(spu2mem + spuaddr + 0x2400), (s16*)Adma7.MemAddr, 512);
|
memcpy((s16 *)(spu2mem + spuaddr + 0x2400), (s16 *)Adma7.MemAddr, 512);
|
||||||
Adma7.MemAddr += 256;
|
Adma7.MemAddr += 256;
|
||||||
memcpy((s16*)(spu2mem + spuaddr + 0x2600), (s16*)Adma7.MemAddr, 512);
|
memcpy((s16 *)(spu2mem + spuaddr + 0x2600), (s16 *)Adma7.MemAddr, 512);
|
||||||
Adma7.MemAddr += 256;
|
Adma7.MemAddr += 256;
|
||||||
spuaddr = (spuaddr + 256) & 511;
|
spuaddr = (spuaddr + 256) & 511;
|
||||||
C1_SPUADDR_SET(spuaddr);
|
C1_SPUADDR_SET(spuaddr);
|
||||||
|
@ -721,7 +721,7 @@ int ADMAS7Write()
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(void)
|
EXPORT_C_(void)
|
||||||
SPU2writeDMA4Mem(u16* pMem, int size)
|
SPU2writeDMA4Mem(u16 *pMem, int size)
|
||||||
{
|
{
|
||||||
u32 spuaddr;
|
u32 spuaddr;
|
||||||
|
|
||||||
|
@ -738,7 +738,7 @@ SPU2writeDMA4Mem(u16* pMem, int size)
|
||||||
}
|
}
|
||||||
|
|
||||||
spuaddr = C0_SPUADDR;
|
spuaddr = C0_SPUADDR;
|
||||||
memcpy((u8*)(spu2mem + spuaddr), (u8*)pMem, size << 1);
|
memcpy((u8 *)(spu2mem + spuaddr), (u8 *)pMem, size << 1);
|
||||||
spuaddr += size;
|
spuaddr += size;
|
||||||
C0_SPUADDR_SET(spuaddr);
|
C0_SPUADDR_SET(spuaddr);
|
||||||
|
|
||||||
|
@ -759,7 +759,7 @@ SPU2writeDMA4Mem(u16* pMem, int size)
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(void)
|
EXPORT_C_(void)
|
||||||
SPU2writeDMA7Mem(u16* pMem, int size)
|
SPU2writeDMA7Mem(u16 *pMem, int size)
|
||||||
{
|
{
|
||||||
u32 spuaddr;
|
u32 spuaddr;
|
||||||
|
|
||||||
|
@ -776,7 +776,7 @@ SPU2writeDMA7Mem(u16* pMem, int size)
|
||||||
}
|
}
|
||||||
|
|
||||||
spuaddr = C1_SPUADDR;
|
spuaddr = C1_SPUADDR;
|
||||||
memcpy((u8*)(spu2mem + spuaddr), (u8*)pMem, size << 1);
|
memcpy((u8 *)(spu2mem + spuaddr), (u8 *)pMem, size << 1);
|
||||||
spuaddr += size;
|
spuaddr += size;
|
||||||
C1_SPUADDR_SET(spuaddr);
|
C1_SPUADDR_SET(spuaddr);
|
||||||
|
|
||||||
|
@ -878,7 +878,7 @@ SPU2write(u32 mem, u16 value)
|
||||||
else
|
else
|
||||||
ch = (r >> 4);
|
ch = (r >> 4);
|
||||||
|
|
||||||
VOICE_PROCESSED* pvoice = &voices[ch];
|
VOICE_PROCESSED *pvoice = &voices[ch];
|
||||||
|
|
||||||
switch (r & 0x0f) {
|
switch (r & 0x0f) {
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -930,25 +930,25 @@ SPU2write(u32 mem, u16 value)
|
||||||
|
|
||||||
ch += ((rx - 0x1c0) / 12);
|
ch += ((rx - 0x1c0) / 12);
|
||||||
rx -= (ch % 24) * 12;
|
rx -= (ch % 24) * 12;
|
||||||
VOICE_PROCESSED* pvoice = &voices[ch];
|
VOICE_PROCESSED *pvoice = &voices[ch];
|
||||||
|
|
||||||
switch (rx) {
|
switch (rx) {
|
||||||
case 0x1C0:
|
case 0x1C0:
|
||||||
pvoice->iStartAddr = (((u32)value & 0x3f) << 16) | (pvoice->iStartAddr & 0xFFFF);
|
pvoice->iStartAddr = (((u32)value & 0x3f) << 16) | (pvoice->iStartAddr & 0xFFFF);
|
||||||
pvoice->pStart = (u8*)(spu2mem + pvoice->iStartAddr);
|
pvoice->pStart = (u8 *)(spu2mem + pvoice->iStartAddr);
|
||||||
break;
|
break;
|
||||||
case 0x1C2:
|
case 0x1C2:
|
||||||
pvoice->iStartAddr = (pvoice->iStartAddr & 0x3f0000) | (value & 0xFFFF);
|
pvoice->iStartAddr = (pvoice->iStartAddr & 0x3f0000) | (value & 0xFFFF);
|
||||||
pvoice->pStart = (u8*)(spu2mem + pvoice->iStartAddr);
|
pvoice->pStart = (u8 *)(spu2mem + pvoice->iStartAddr);
|
||||||
break;
|
break;
|
||||||
case 0x1C4:
|
case 0x1C4:
|
||||||
pvoice->iLoopAddr = (((u32)value & 0x3f) << 16) | (pvoice->iLoopAddr & 0xFFFF);
|
pvoice->iLoopAddr = (((u32)value & 0x3f) << 16) | (pvoice->iLoopAddr & 0xFFFF);
|
||||||
pvoice->pLoop = (u8*)(spu2mem + pvoice->iLoopAddr);
|
pvoice->pLoop = (u8 *)(spu2mem + pvoice->iLoopAddr);
|
||||||
pvoice->bIgnoreLoop = pvoice->iLoopAddr > 0;
|
pvoice->bIgnoreLoop = pvoice->iLoopAddr > 0;
|
||||||
break;
|
break;
|
||||||
case 0x1C6:
|
case 0x1C6:
|
||||||
pvoice->iLoopAddr = (pvoice->iLoopAddr & 0x3f0000) | (value & 0xFFFF);
|
pvoice->iLoopAddr = (pvoice->iLoopAddr & 0x3f0000) | (value & 0xFFFF);
|
||||||
pvoice->pLoop = (u8*)(spu2mem + pvoice->iLoopAddr);
|
pvoice->pLoop = (u8 *)(spu2mem + pvoice->iLoopAddr);
|
||||||
pvoice->bIgnoreLoop = pvoice->iLoopAddr > 0;
|
pvoice->bIgnoreLoop = pvoice->iLoopAddr > 0;
|
||||||
break;
|
break;
|
||||||
case 0x1C8:
|
case 0x1C8:
|
||||||
|
@ -1084,7 +1084,7 @@ SPU2read(u32 mem)
|
||||||
else
|
else
|
||||||
ch = (r >> 4);
|
ch = (r >> 4);
|
||||||
|
|
||||||
VOICE_PROCESSED* pvoice = &voices[ch];
|
VOICE_PROCESSED *pvoice = &voices[ch];
|
||||||
|
|
||||||
switch (r & 0x0f) {
|
switch (r & 0x0f) {
|
||||||
case 10:
|
case 10:
|
||||||
|
@ -1104,21 +1104,21 @@ SPU2read(u32 mem)
|
||||||
|
|
||||||
ch += ((rx - 0x1c0) / 12);
|
ch += ((rx - 0x1c0) / 12);
|
||||||
rx -= (ch % 24) * 12;
|
rx -= (ch % 24) * 12;
|
||||||
VOICE_PROCESSED* pvoice = &voices[ch];
|
VOICE_PROCESSED *pvoice = &voices[ch];
|
||||||
|
|
||||||
switch (rx) {
|
switch (rx) {
|
||||||
case 0x1C0:
|
case 0x1C0:
|
||||||
return (u16)(((pvoice->pStart - (u8*)spu2mem) >> 17) & 0x3F);
|
return (u16)(((pvoice->pStart - (u8 *)spu2mem) >> 17) & 0x3F);
|
||||||
case 0x1C2:
|
case 0x1C2:
|
||||||
return (u16)(((pvoice->pStart - (u8*)spu2mem) >> 1) & 0xFFFF);
|
return (u16)(((pvoice->pStart - (u8 *)spu2mem) >> 1) & 0xFFFF);
|
||||||
case 0x1C4:
|
case 0x1C4:
|
||||||
return (u16)(((pvoice->pLoop - (u8*)spu2mem) >> 17) & 0x3F);
|
return (u16)(((pvoice->pLoop - (u8 *)spu2mem) >> 17) & 0x3F);
|
||||||
case 0x1C6:
|
case 0x1C6:
|
||||||
return (u16)(((pvoice->pLoop - (u8*)spu2mem) >> 1) & 0xFFFF);
|
return (u16)(((pvoice->pLoop - (u8 *)spu2mem) >> 1) & 0xFFFF);
|
||||||
case 0x1C8:
|
case 0x1C8:
|
||||||
return (u16)(((pvoice->pCurr - (u8*)spu2mem) >> 17) & 0x3F);
|
return (u16)(((pvoice->pCurr - (u8 *)spu2mem) >> 17) & 0x3F);
|
||||||
case 0x1CA:
|
case 0x1CA:
|
||||||
return (u16)(((pvoice->pCurr - (u8*)spu2mem) >> 1) & 0xFFFF);
|
return (u16)(((pvoice->pCurr - (u8 *)spu2mem) >> 1) & 0xFFFF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1184,9 +1184,9 @@ SPU2irqCallback(void (*SPU2callback)(), void (*DMA4callback)(), void (*DMA7callb
|
||||||
}
|
}
|
||||||
|
|
||||||
// VOICE_PROCESSED definitions
|
// VOICE_PROCESSED definitions
|
||||||
SPU_CONTROL_* VOICE_PROCESSED::GetCtrl()
|
SPU_CONTROL_ *VOICE_PROCESSED::GetCtrl()
|
||||||
{
|
{
|
||||||
return ((SPU_CONTROL_*)(spu2regs + memoffset + REG_C0_CTRL));
|
return ((SPU_CONTROL_ *)(spu2regs + memoffset + REG_C0_CTRL));
|
||||||
}
|
}
|
||||||
|
|
||||||
void VOICE_PROCESSED::SetVolume(int iProcessRight)
|
void VOICE_PROCESSED::SetVolume(int iProcessRight)
|
||||||
|
@ -1260,19 +1260,19 @@ typedef struct
|
||||||
} SPU2freezeData;
|
} SPU2freezeData;
|
||||||
|
|
||||||
EXPORT_C_(s32)
|
EXPORT_C_(s32)
|
||||||
SPU2freeze(int mode, freezeData* data)
|
SPU2freeze(int mode, freezeData *data)
|
||||||
{
|
{
|
||||||
SPU2freezeData* spud;
|
SPU2freezeData *spud;
|
||||||
|
|
||||||
if (mode == FREEZE_LOAD) {
|
if (mode == FREEZE_LOAD) {
|
||||||
spud = (SPU2freezeData*)data->data;
|
spud = (SPU2freezeData *)data->data;
|
||||||
if (spud->version == 0x11223344) {
|
if (spud->version == 0x11223344) {
|
||||||
memcpy(spu2regs, spud->spu2regs, 0x10000);
|
memcpy(spu2regs, spud->spu2regs, 0x10000);
|
||||||
} else {
|
} else {
|
||||||
printf("SPU2null wrong format\n");
|
printf("SPU2null wrong format\n");
|
||||||
}
|
}
|
||||||
} else if (mode == FREEZE_SAVE) {
|
} else if (mode == FREEZE_SAVE) {
|
||||||
spud = (SPU2freezeData*)data->data;
|
spud = (SPU2freezeData *)data->data;
|
||||||
spud->version = 0x11223344;
|
spud->version = 0x11223344;
|
||||||
memcpy(spud->spu2regs, spu2regs, 0x10000);
|
memcpy(spud->spu2regs, spu2regs, 0x10000);
|
||||||
} else if (mode == FREEZE_SIZE) {
|
} else if (mode == FREEZE_SIZE) {
|
||||||
|
|
|
@ -41,14 +41,14 @@ extern "C" {
|
||||||
#define EXPORT_C_(type) extern "C" __attribute__((stdcall, externally_visible, visibility("default"))) type
|
#define EXPORT_C_(type) extern "C" __attribute__((stdcall, externally_visible, visibility("default"))) type
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern FILE* spu2Log;
|
extern FILE *spu2Log;
|
||||||
#define SPU2_LOG __Log //debug mode
|
#define SPU2_LOG __Log //debug mode
|
||||||
|
|
||||||
extern const u8 version;
|
extern const u8 version;
|
||||||
extern const u8 revision;
|
extern const u8 revision;
|
||||||
extern const u8 build;
|
extern const u8 build;
|
||||||
extern const u32 minor;
|
extern const u32 minor;
|
||||||
extern char* libraryName;
|
extern char *libraryName;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
@ -57,10 +57,10 @@ typedef struct
|
||||||
|
|
||||||
extern Config conf;
|
extern Config conf;
|
||||||
|
|
||||||
void __Log(char* fmt, ...);
|
void __Log(char *fmt, ...);
|
||||||
void SaveConfig();
|
void SaveConfig();
|
||||||
void LoadConfig();
|
void LoadConfig();
|
||||||
void SysMessage(char* fmt, ...);
|
void SysMessage(char *fmt, ...);
|
||||||
|
|
||||||
////////////////////
|
////////////////////
|
||||||
// SPU2 Registers //
|
// SPU2 Registers //
|
||||||
|
@ -134,8 +134,8 @@ void SysMessage(char* fmt, ...);
|
||||||
#define SPDIF_MODE 0x07C6
|
#define SPDIF_MODE 0x07C6
|
||||||
#define SPDIF_MEDIA 0x07C8
|
#define SPDIF_MEDIA 0x07C8
|
||||||
|
|
||||||
#define spu2Rs16(mem) (*(s16*)&spu2regs[(mem)&0xffff])
|
#define spu2Rs16(mem) (*(s16 *)&spu2regs[(mem)&0xffff])
|
||||||
#define spu2Ru16(mem) (*(u16*)&spu2regs[(mem)&0xffff])
|
#define spu2Ru16(mem) (*(u16 *)&spu2regs[(mem)&0xffff])
|
||||||
//#define spu2Rs32(mem) (*(s32*)&spu2regs[(mem) & 0xffff])
|
//#define spu2Rs32(mem) (*(s32*)&spu2regs[(mem) & 0xffff])
|
||||||
//#define spu2Ru32(mem) (*(u32*)&spu2regs[(mem) & 0xffff])
|
//#define spu2Ru32(mem) (*(u32*)&spu2regs[(mem) & 0xffff])
|
||||||
|
|
||||||
|
@ -236,7 +236,7 @@ struct ADSRInfoEx
|
||||||
#define NSSIZE 48 // ~ 1 ms of data
|
#define NSSIZE 48 // ~ 1 ms of data
|
||||||
#define NSFRAMES 16 // gather at least NSFRAMES of NSSIZE before submitting
|
#define NSFRAMES 16 // gather at least NSFRAMES of NSSIZE before submitting
|
||||||
#define NSPACKETS 4
|
#define NSPACKETS 4
|
||||||
#define SPU_VOICE_STATE_SIZE (sizeof(VOICE_PROCESSED) - 4 * sizeof(void*))
|
#define SPU_VOICE_STATE_SIZE (sizeof(VOICE_PROCESSED) - 4 * sizeof(void *))
|
||||||
|
|
||||||
struct VOICE_PROCESSED
|
struct VOICE_PROCESSED
|
||||||
{
|
{
|
||||||
|
@ -254,7 +254,7 @@ struct VOICE_PROCESSED
|
||||||
void FModChangeFrequency(int ns);
|
void FModChangeFrequency(int ns);
|
||||||
void Stop();
|
void Stop();
|
||||||
|
|
||||||
SPU_CONTROL_* GetCtrl();
|
SPU_CONTROL_ *GetCtrl();
|
||||||
|
|
||||||
// start save state
|
// start save state
|
||||||
|
|
||||||
|
@ -276,15 +276,15 @@ struct VOICE_PROCESSED
|
||||||
///////////////////
|
///////////////////
|
||||||
// Sound Buffers //
|
// Sound Buffers //
|
||||||
///////////////////
|
///////////////////
|
||||||
u8* pStart; // start and end addresses
|
u8 *pStart; // start and end addresses
|
||||||
u8 *pLoop, *pCurr;
|
u8 *pLoop, *pCurr;
|
||||||
|
|
||||||
_SPU_VOICE* pvoice;
|
_SPU_VOICE *pvoice;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ADMA
|
struct ADMA
|
||||||
{
|
{
|
||||||
u16* MemAddr;
|
u16 *MemAddr;
|
||||||
s32 IntPointer;
|
s32 IntPointer;
|
||||||
s32 Index;
|
s32 Index;
|
||||||
s32 AmountLeft;
|
s32 AmountLeft;
|
||||||
|
|
|
@ -21,8 +21,8 @@ extern HINSTANCE hInst;
|
||||||
void SaveConfig()
|
void SaveConfig()
|
||||||
{
|
{
|
||||||
|
|
||||||
Config* Conf1 = &conf;
|
Config *Conf1 = &conf;
|
||||||
char* szTemp;
|
char *szTemp;
|
||||||
char szIniFile[256], szValue[256];
|
char szIniFile[256], szValue[256];
|
||||||
|
|
||||||
GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
|
GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
|
||||||
|
@ -37,11 +37,11 @@ void SaveConfig()
|
||||||
|
|
||||||
void LoadConfig()
|
void LoadConfig()
|
||||||
{
|
{
|
||||||
FILE* fp;
|
FILE *fp;
|
||||||
|
|
||||||
|
|
||||||
Config* Conf1 = &conf;
|
Config *Conf1 = &conf;
|
||||||
char* szTemp;
|
char *szTemp;
|
||||||
char szIniFile[256], szValue[256];
|
char szIniFile[256], szValue[256];
|
||||||
|
|
||||||
GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
|
GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
HINSTANCE hInst;
|
HINSTANCE hInst;
|
||||||
|
|
||||||
void SysMessage(char* fmt, ...)
|
void SysMessage(char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list list;
|
va_list list;
|
||||||
char tmp[512];
|
char tmp[512];
|
||||||
|
|
|
@ -44,7 +44,7 @@ void LogInit()
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(void)
|
EXPORT_C_(void)
|
||||||
USBsetLogDir(const char* dir)
|
USBsetLogDir(const char *dir)
|
||||||
{
|
{
|
||||||
// Get the path to the log directory.
|
// Get the path to the log directory.
|
||||||
s_strLogPath = (dir == NULL) ? "logs" : dir;
|
s_strLogPath = (dir == NULL) ? "logs" : dir;
|
||||||
|
@ -60,7 +60,7 @@ PS2EgetLibType()
|
||||||
return PS2E_LT_USB;
|
return PS2E_LT_USB;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(char*)
|
EXPORT_C_(char *)
|
||||||
PS2EgetLibName()
|
PS2EgetLibName()
|
||||||
{
|
{
|
||||||
snprintf(libraryName, 255, "USBnull Driver %lld%s", SVN_REV, SVN_MODS ? "m" : "");
|
snprintf(libraryName, 255, "USBnull Driver %lld%s", SVN_REV, SVN_MODS ? "m" : "");
|
||||||
|
@ -82,7 +82,7 @@ USBinit()
|
||||||
USBLog.WriteLn("Initializing USBnull");
|
USBLog.WriteLn("Initializing USBnull");
|
||||||
|
|
||||||
// Initialize memory structures here.
|
// Initialize memory structures here.
|
||||||
usbregs = (s8*)calloc(0x10000, 1);
|
usbregs = (s8 *)calloc(0x10000, 1);
|
||||||
|
|
||||||
if (usbregs == NULL) {
|
if (usbregs == NULL) {
|
||||||
USBLog.Message("Error allocating memory");
|
USBLog.Message("Error allocating memory");
|
||||||
|
@ -104,7 +104,7 @@ USBshutdown()
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(s32)
|
EXPORT_C_(s32)
|
||||||
USBopen(void* pDsp)
|
USBopen(void *pDsp)
|
||||||
{
|
{
|
||||||
USBLog.WriteLn("Opening USBnull.");
|
USBLog.WriteLn("Opening USBnull.");
|
||||||
|
|
||||||
|
@ -245,14 +245,14 @@ USBirqHandler(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(void)
|
EXPORT_C_(void)
|
||||||
USBsetRAM(void* mem)
|
USBsetRAM(void *mem)
|
||||||
{
|
{
|
||||||
ram = (s8*)mem;
|
ram = (s8 *)mem;
|
||||||
USBLog.WriteLn("*Setting ram.");
|
USBLog.WriteLn("*Setting ram.");
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(void)
|
EXPORT_C_(void)
|
||||||
USBsetSettingsDir(const char* dir)
|
USBsetSettingsDir(const char *dir)
|
||||||
{
|
{
|
||||||
// Get the path to the ini directory.
|
// Get the path to the ini directory.
|
||||||
s_strIniPath = (dir == NULL) ? "inis" : dir;
|
s_strIniPath = (dir == NULL) ? "inis" : dir;
|
||||||
|
@ -261,7 +261,7 @@ USBsetSettingsDir(const char* dir)
|
||||||
// extended funcs
|
// extended funcs
|
||||||
|
|
||||||
EXPORT_C_(s32)
|
EXPORT_C_(s32)
|
||||||
USBfreeze(int mode, freezeData* data)
|
USBfreeze(int mode, freezeData *data)
|
||||||
{
|
{
|
||||||
// This should store or retrieve any information, for if emulation
|
// This should store or retrieve any information, for if emulation
|
||||||
// gets suspended, or for savestates.
|
// gets suspended, or for savestates.
|
||||||
|
|
|
@ -36,11 +36,11 @@ static const s64 PSXCLK = 36864000; /* 36.864 Mhz */
|
||||||
extern s8 *usbregs, *ram;
|
extern s8 *usbregs, *ram;
|
||||||
|
|
||||||
#define usbRs8(mem) usbregs[(mem)&0xffff]
|
#define usbRs8(mem) usbregs[(mem)&0xffff]
|
||||||
#define usbRs16(mem) (*(s16*)&usbregs[(mem)&0xffff])
|
#define usbRs16(mem) (*(s16 *)&usbregs[(mem)&0xffff])
|
||||||
#define usbRs32(mem) (*(s32*)&usbregs[(mem)&0xffff])
|
#define usbRs32(mem) (*(s32 *)&usbregs[(mem)&0xffff])
|
||||||
#define usbRu8(mem) (*(u8*)&usbregs[(mem)&0xffff])
|
#define usbRu8(mem) (*(u8 *)&usbregs[(mem)&0xffff])
|
||||||
#define usbRu16(mem) (*(u16*)&usbregs[(mem)&0xffff])
|
#define usbRu16(mem) (*(u16 *)&usbregs[(mem)&0xffff])
|
||||||
#define usbRu32(mem) (*(u32*)&usbregs[(mem)&0xffff])
|
#define usbRu32(mem) (*(u32 *)&usbregs[(mem)&0xffff])
|
||||||
|
|
||||||
extern void SaveConfig();
|
extern void SaveConfig();
|
||||||
extern void LoadConfig();
|
extern void LoadConfig();
|
||||||
|
|
|
@ -21,8 +21,8 @@ extern HINSTANCE hInst;
|
||||||
void SaveConfig()
|
void SaveConfig()
|
||||||
{
|
{
|
||||||
|
|
||||||
Config* Conf1 = &conf;
|
Config *Conf1 = &conf;
|
||||||
char* szTemp;
|
char *szTemp;
|
||||||
char szIniFile[256], szValue[256];
|
char szIniFile[256], szValue[256];
|
||||||
|
|
||||||
GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
|
GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
|
||||||
|
@ -37,11 +37,11 @@ void SaveConfig()
|
||||||
|
|
||||||
void LoadConfig()
|
void LoadConfig()
|
||||||
{
|
{
|
||||||
FILE* fp;
|
FILE *fp;
|
||||||
|
|
||||||
|
|
||||||
Config* Conf1 = &conf;
|
Config *Conf1 = &conf;
|
||||||
char* szTemp;
|
char *szTemp;
|
||||||
char szIniFile[256], szValue[256];
|
char szIniFile[256], szValue[256];
|
||||||
|
|
||||||
GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
|
GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
HINSTANCE hInst;
|
HINSTANCE hInst;
|
||||||
|
|
||||||
void SysMessage(char* fmt, ...)
|
void SysMessage(char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list list;
|
va_list list;
|
||||||
char tmp[512];
|
char tmp[512];
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
void SaveConfig();
|
void SaveConfig();
|
||||||
void LoadConfig();
|
void LoadConfig();
|
||||||
void SysMessage(char* fmt, ...);
|
void SysMessage(char *fmt, ...);
|
||||||
|
|
||||||
//#define is_checked(main_widget, widget_name) (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(main_widget, widget_name))))
|
//#define is_checked(main_widget, widget_name) (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(main_widget, widget_name))))
|
||||||
//#define set_checked(main_widget,widget_name, state) gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(main_widget, widget_name)), state)
|
//#define set_checked(main_widget,widget_name, state) gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(main_widget, widget_name)), state)
|
||||||
|
|
|
@ -61,7 +61,7 @@ void LogInit()
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(void)
|
EXPORT_C_(void)
|
||||||
DEV9setLogDir(const char* dir)
|
DEV9setLogDir(const char *dir)
|
||||||
{
|
{
|
||||||
// Get the path to the log directory.
|
// Get the path to the log directory.
|
||||||
s_strLogPath = (dir == NULL) ? "logs" : dir;
|
s_strLogPath = (dir == NULL) ? "logs" : dir;
|
||||||
|
@ -77,7 +77,7 @@ PS2EgetLibType()
|
||||||
return PS2E_LT_DEV9;
|
return PS2E_LT_DEV9;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(char*)
|
EXPORT_C_(char *)
|
||||||
PS2EgetLibName()
|
PS2EgetLibName()
|
||||||
{
|
{
|
||||||
snprintf(libraryName, 255, "DEV9null Driver %lld%s", SVN_REV, SVN_MODS ? "m" : "");
|
snprintf(libraryName, 255, "DEV9null Driver %lld%s", SVN_REV, SVN_MODS ? "m" : "");
|
||||||
|
@ -111,7 +111,7 @@ DEV9shutdown()
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(s32)
|
EXPORT_C_(s32)
|
||||||
DEV9open(void* pDsp)
|
DEV9open(void *pDsp)
|
||||||
{
|
{
|
||||||
Dev9Log.WriteLn("Opening Dev9null.");
|
Dev9Log.WriteLn("Opening Dev9null.");
|
||||||
// Get anything ready we need to. Opening and creating hard
|
// Get anything ready we need to. Opening and creating hard
|
||||||
|
@ -237,7 +237,7 @@ DEV9write32(u32 addr, u32 value)
|
||||||
|
|
||||||
//#ifdef ENABLE_NEW_IOPDMA_DEV9
|
//#ifdef ENABLE_NEW_IOPDMA_DEV9
|
||||||
EXPORT_C_(s32)
|
EXPORT_C_(s32)
|
||||||
DEV9dmaRead(s32 channel, u32* data, u32 bytesLeft, u32* bytesProcessed)
|
DEV9dmaRead(s32 channel, u32 *data, u32 bytesLeft, u32 *bytesProcessed)
|
||||||
{
|
{
|
||||||
// You'll want to put your own DMA8 reading code here.
|
// You'll want to put your own DMA8 reading code here.
|
||||||
// Time to interact with your fake (or real) hardware.
|
// Time to interact with your fake (or real) hardware.
|
||||||
|
@ -247,7 +247,7 @@ DEV9dmaRead(s32 channel, u32* data, u32 bytesLeft, u32* bytesProcessed)
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(s32)
|
EXPORT_C_(s32)
|
||||||
DEV9dmaWrite(s32 channel, u32* data, u32 bytesLeft, u32* bytesProcessed)
|
DEV9dmaWrite(s32 channel, u32 *data, u32 bytesLeft, u32 *bytesProcessed)
|
||||||
{
|
{
|
||||||
// See above.
|
// See above.
|
||||||
Dev9Log.WriteLn("Writing DMA8 Mem.");
|
Dev9Log.WriteLn("Writing DMA8 Mem.");
|
||||||
|
@ -262,7 +262,7 @@ DEV9dmaInterrupt(s32 channel)
|
||||||
}
|
}
|
||||||
//#else
|
//#else
|
||||||
EXPORT_C_(void)
|
EXPORT_C_(void)
|
||||||
DEV9readDMA8Mem(u32* pMem, int size)
|
DEV9readDMA8Mem(u32 *pMem, int size)
|
||||||
{
|
{
|
||||||
// You'll want to put your own DMA8 reading code here.
|
// You'll want to put your own DMA8 reading code here.
|
||||||
// Time to interact with your fake (or real) hardware.
|
// Time to interact with your fake (or real) hardware.
|
||||||
|
@ -270,7 +270,7 @@ DEV9readDMA8Mem(u32* pMem, int size)
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(void)
|
EXPORT_C_(void)
|
||||||
DEV9writeDMA8Mem(u32* pMem, int size)
|
DEV9writeDMA8Mem(u32 *pMem, int size)
|
||||||
{
|
{
|
||||||
// See above.
|
// See above.
|
||||||
Dev9Log.WriteLn("Writing DMA8 Mem.");
|
Dev9Log.WriteLn("Writing DMA8 Mem.");
|
||||||
|
@ -299,7 +299,7 @@ DEV9irqHandler(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(void)
|
EXPORT_C_(void)
|
||||||
DEV9setSettingsDir(const char* dir)
|
DEV9setSettingsDir(const char *dir)
|
||||||
{
|
{
|
||||||
// Grab the ini directory.
|
// Grab the ini directory.
|
||||||
s_strIniPath = (dir == NULL) ? "inis" : dir;
|
s_strIniPath = (dir == NULL) ? "inis" : dir;
|
||||||
|
@ -314,7 +314,7 @@ DEV9test()
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(s32)
|
EXPORT_C_(s32)
|
||||||
DEV9freeze(int mode, freezeData* data)
|
DEV9freeze(int mode, freezeData *data)
|
||||||
{
|
{
|
||||||
// This should store or retrieve any information, for if emulation
|
// This should store or retrieve any information, for if emulation
|
||||||
// gets suspended, or for savestates.
|
// gets suspended, or for savestates.
|
||||||
|
|
|
@ -44,11 +44,11 @@ extern void (*DEV9irq)(int);
|
||||||
|
|
||||||
extern __aligned16 s8 dev9regs[0x10000];
|
extern __aligned16 s8 dev9regs[0x10000];
|
||||||
#define dev9Rs8(mem) dev9regs[(mem)&0xffff]
|
#define dev9Rs8(mem) dev9regs[(mem)&0xffff]
|
||||||
#define dev9Rs16(mem) (*(s16*)&dev9regs[(mem)&0xffff])
|
#define dev9Rs16(mem) (*(s16 *)&dev9regs[(mem)&0xffff])
|
||||||
#define dev9Rs32(mem) (*(s32*)&dev9regs[(mem)&0xffff])
|
#define dev9Rs32(mem) (*(s32 *)&dev9regs[(mem)&0xffff])
|
||||||
#define dev9Ru8(mem) (*(u8*)&dev9regs[(mem)&0xffff])
|
#define dev9Ru8(mem) (*(u8 *)&dev9regs[(mem)&0xffff])
|
||||||
#define dev9Ru16(mem) (*(u16*)&dev9regs[(mem)&0xffff])
|
#define dev9Ru16(mem) (*(u16 *)&dev9regs[(mem)&0xffff])
|
||||||
#define dev9Ru32(mem) (*(u32*)&dev9regs[(mem)&0xffff])
|
#define dev9Ru32(mem) (*(u32 *)&dev9regs[(mem)&0xffff])
|
||||||
|
|
||||||
extern void setLoggingState();
|
extern void setLoggingState();
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
#include "GamePad.h"
|
#include "GamePad.h"
|
||||||
#ifdef SDL_BUILD
|
#ifdef SDL_BUILD
|
||||||
#include "SDL/joystick.h"
|
#include "SDL/joystick.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
vector<GamePad*> s_vgamePad;
|
vector<GamePad *> s_vgamePad;
|
||||||
bool GamePadIdWithinBounds(int GamePadId)
|
bool GamePadIdWithinBounds(int GamePadId)
|
||||||
{
|
{
|
||||||
return ((GamePadId >= 0) && (GamePadId < (int)s_vgamePad.size()));
|
return ((GamePadId >= 0) && (GamePadId < (int)s_vgamePad.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -17,17 +17,17 @@ bool GamePadIdWithinBounds(int GamePadId)
|
||||||
/**
|
/**
|
||||||
* Find every interesting devices and create right structure for them(depend on backend)
|
* Find every interesting devices and create right structure for them(depend on backend)
|
||||||
**/
|
**/
|
||||||
void GamePad::EnumerateGamePads(vector<GamePad*>& vgamePad)
|
void GamePad::EnumerateGamePads(vector<GamePad *> &vgamePad)
|
||||||
{
|
{
|
||||||
#ifdef SDL_BUILD
|
#ifdef SDL_BUILD
|
||||||
JoystickInfo::EnumerateJoysticks(vgamePad);
|
JoystickInfo::EnumerateJoysticks(vgamePad);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void GamePad::UpdateReleaseState()
|
void GamePad::UpdateReleaseState()
|
||||||
{
|
{
|
||||||
#ifdef SDL_BUILD
|
#ifdef SDL_BUILD
|
||||||
JoystickInfo::UpdateReleaseState();
|
JoystickInfo::UpdateReleaseState();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,12 +36,12 @@ void GamePad::UpdateReleaseState()
|
||||||
**/
|
**/
|
||||||
void GamePad::DoRumble(int type, int pad)
|
void GamePad::DoRumble(int type, int pad)
|
||||||
{
|
{
|
||||||
u32 id = conf->get_joyid(pad);
|
u32 id = conf->get_joyid(pad);
|
||||||
if (GamePadIdWithinBounds(id)) {
|
if (GamePadIdWithinBounds(id)) {
|
||||||
GamePad* gamePad = s_vgamePad[id];
|
GamePad *gamePad = s_vgamePad[id];
|
||||||
if (gamePad)
|
if (gamePad)
|
||||||
gamePad->Rumble(type, pad);
|
gamePad->Rumble(type, pad);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -49,9 +49,7 @@ void GamePad::DoRumble(int type, int pad)
|
||||||
**/
|
**/
|
||||||
void GamePad::UpdateGamePadState()
|
void GamePad::UpdateGamePadState()
|
||||||
{
|
{
|
||||||
#ifdef SDL_BUILD
|
#ifdef SDL_BUILD
|
||||||
SDL_JoystickUpdate(); // No need to make yet another function call for that
|
SDL_JoystickUpdate(); // No need to make yet another function call for that
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
#include "onepad.h"
|
#include "onepad.h"
|
||||||
#include "controller.h"
|
#include "controller.h"
|
||||||
#ifdef SDL_BUILD
|
#ifdef SDL_BUILD
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#define HAT_UP SDL_HAT_UP
|
#define HAT_UP SDL_HAT_UP
|
||||||
#define HAT_DOWN SDL_HAT_DOWN
|
#define HAT_DOWN SDL_HAT_DOWN
|
||||||
|
@ -12,137 +12,144 @@
|
||||||
|
|
||||||
class GamePad
|
class GamePad
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GamePad() : devname(""), _id(-1), numbuttons(0), numaxes(0), numhats(0),
|
GamePad()
|
||||||
deadzone(1500), pad(-1) {
|
: devname("")
|
||||||
vbuttonstate.clear();
|
, _id(-1)
|
||||||
vaxisstate.clear();
|
, numbuttons(0)
|
||||||
vhatstate.clear();
|
, numaxes(0)
|
||||||
}
|
, numhats(0)
|
||||||
|
, deadzone(1500)
|
||||||
|
, pad(-1)
|
||||||
|
{
|
||||||
|
vbuttonstate.clear();
|
||||||
|
vaxisstate.clear();
|
||||||
|
vhatstate.clear();
|
||||||
|
}
|
||||||
|
|
||||||
virtual ~GamePad()
|
virtual ~GamePad()
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GamePad(const GamePad&); // copy constructor
|
GamePad(const GamePad &); // copy constructor
|
||||||
GamePad& operator=(const GamePad&); // assignment
|
GamePad &operator=(const GamePad &); // assignment
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find every interesting devices and create right structure for them(depend on backend)
|
* Find every interesting devices and create right structure for them(depend on backend)
|
||||||
**/
|
**/
|
||||||
static void EnumerateGamePads(vector<GamePad*>& vgamePad);
|
static void EnumerateGamePads(vector<GamePad *> &vgamePad);
|
||||||
static void UpdateReleaseState();
|
static void UpdateReleaseState();
|
||||||
/**
|
/**
|
||||||
* Update state of every attached devices
|
* Update state of every attached devices
|
||||||
**/
|
**/
|
||||||
static void UpdateGamePadState();
|
static void UpdateGamePadState();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Causes devices to rumble
|
* Causes devices to rumble
|
||||||
* Rumble will differ according to type which is either 0(small motor) or 1(big motor)
|
* Rumble will differ according to type which is either 0(small motor) or 1(big motor)
|
||||||
**/
|
**/
|
||||||
virtual void Rumble(int type,int pad){return;}
|
virtual void Rumble(int type, int pad) { return; }
|
||||||
/**
|
/**
|
||||||
* Safely dispatch to the Rumble method above
|
* Safely dispatch to the Rumble method above
|
||||||
**/
|
**/
|
||||||
static void DoRumble(int type, int pad);
|
static void DoRumble(int type, int pad);
|
||||||
|
|
||||||
virtual bool Init(int id){return false;} // opens a handle and gets information
|
virtual bool Init(int id) { return false; } // opens a handle and gets information
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used for GUI checkbox to give feedback to the user
|
* Used for GUI checkbox to give feedback to the user
|
||||||
**/
|
**/
|
||||||
virtual bool TestForce(float strength = 0.6){return false;}
|
virtual bool TestForce(float strength = 0.6) { return false; }
|
||||||
|
|
||||||
virtual bool PollButtons(u32 &pkey){return false;}
|
virtual bool PollButtons(u32 &pkey) { return false; }
|
||||||
virtual bool PollAxes(u32 &pkey){return false;}
|
virtual bool PollAxes(u32 &pkey) { return false; }
|
||||||
virtual bool PollHats(u32 &pkey){return false;}
|
virtual bool PollHats(u32 &pkey) { return false; }
|
||||||
|
|
||||||
virtual int GetHat(int key_to_axis)
|
virtual int GetHat(int key_to_axis)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual int GetButton(int key_to_button)
|
virtual int GetButton(int key_to_button)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const string& GetName()
|
const string &GetName()
|
||||||
{
|
{
|
||||||
return devname;
|
return devname;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetPAD()
|
int GetPAD()
|
||||||
{
|
{
|
||||||
return pad;
|
return pad;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetNumButtons()
|
int GetNumButtons()
|
||||||
{
|
{
|
||||||
return numbuttons;
|
return numbuttons;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetNumAxes()
|
int GetNumAxes()
|
||||||
{
|
{
|
||||||
return numaxes;
|
return numaxes;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetNumHats()
|
int GetNumHats()
|
||||||
{
|
{
|
||||||
return numhats;
|
return numhats;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual int GetDeadzone()
|
virtual int GetDeadzone()
|
||||||
{
|
{
|
||||||
return deadzone;
|
return deadzone;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void SaveState() {}
|
virtual void SaveState() {}
|
||||||
|
|
||||||
int GetButtonState(int i)
|
int GetButtonState(int i)
|
||||||
{
|
{
|
||||||
return vbuttonstate[i];
|
return vbuttonstate[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetAxisState(int i)
|
int GetAxisState(int i)
|
||||||
{
|
{
|
||||||
return vaxisstate[i];
|
return vaxisstate[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetHatState(int i)
|
int GetHatState(int i)
|
||||||
{
|
{
|
||||||
//PAD_LOG("Getting POV State of %d.\n", i);
|
//PAD_LOG("Getting POV State of %d.\n", i);
|
||||||
return vhatstate[i];
|
return vhatstate[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetButtonState(int i, int state)
|
void SetButtonState(int i, int state)
|
||||||
{
|
{
|
||||||
vbuttonstate[i] = state;
|
vbuttonstate[i] = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetAxisState(int i, int value)
|
void SetAxisState(int i, int value)
|
||||||
{
|
{
|
||||||
vaxisstate[i] = value;
|
vaxisstate[i] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetHatState(int i, int value)
|
void SetHatState(int i, int value)
|
||||||
{
|
{
|
||||||
//PAD_LOG("We should set %d to %d.\n", i, value);
|
//PAD_LOG("We should set %d to %d.\n", i, value);
|
||||||
vhatstate[i] = value;
|
vhatstate[i] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual int GetAxisFromKey(int pad, int index){return 0;}
|
virtual int GetAxisFromKey(int pad, int index) { return 0; }
|
||||||
// These fields need to be inherited by child classes
|
// These fields need to be inherited by child classes
|
||||||
protected:
|
protected:
|
||||||
string devname; // pretty device name
|
string devname; // pretty device name
|
||||||
int _id;
|
int _id;
|
||||||
int numbuttons, numaxes, numhats;
|
int numbuttons, numaxes, numhats;
|
||||||
int deadzone;
|
int deadzone;
|
||||||
int pad;
|
int pad;
|
||||||
vector<int> vbuttonstate, vaxisstate, vhatstate;
|
vector<int> vbuttonstate, vaxisstate, vhatstate;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern vector<GamePad*> s_vgamePad;
|
extern vector<GamePad *> s_vgamePad;
|
||||||
extern bool GamePadIdWithinBounds(int joyid);
|
extern bool GamePadIdWithinBounds(int joyid);
|
||||||
|
|
|
@ -23,164 +23,176 @@
|
||||||
|
|
||||||
void KeyStatus::Init()
|
void KeyStatus::Init()
|
||||||
{
|
{
|
||||||
for (int pad = 0; pad < GAMEPAD_NUMBER; pad++) {
|
for (int pad = 0; pad < GAMEPAD_NUMBER; pad++) {
|
||||||
m_button[pad] = 0xFFFF;
|
m_button[pad] = 0xFFFF;
|
||||||
m_internal_button_kbd[pad] = 0xFFFF;
|
m_internal_button_kbd[pad] = 0xFFFF;
|
||||||
m_internal_button_joy[pad] = 0xFFFF;
|
m_internal_button_joy[pad] = 0xFFFF;
|
||||||
m_state_acces[pad] = false;
|
m_state_acces[pad] = false;
|
||||||
|
|
||||||
for (int index = 0; index < MAX_KEYS; index++) {
|
for (int index = 0; index < MAX_KEYS; index++) {
|
||||||
m_button_pressure[pad][index] = 0xFF;
|
m_button_pressure[pad][index] = 0xFF;
|
||||||
m_internal_button_pressure[pad][index] = 0xFF;
|
m_internal_button_pressure[pad][index] = 0xFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_analog[pad].lx = m_analog_released_val;
|
m_analog[pad].lx = m_analog_released_val;
|
||||||
m_analog[pad].ly = m_analog_released_val;
|
m_analog[pad].ly = m_analog_released_val;
|
||||||
m_analog[pad].rx = m_analog_released_val;
|
m_analog[pad].rx = m_analog_released_val;
|
||||||
m_analog[pad].ry = m_analog_released_val;
|
m_analog[pad].ry = m_analog_released_val;
|
||||||
m_internal_analog_kbd[pad].lx = m_analog_released_val;
|
m_internal_analog_kbd[pad].lx = m_analog_released_val;
|
||||||
m_internal_analog_kbd[pad].ly = m_analog_released_val;
|
m_internal_analog_kbd[pad].ly = m_analog_released_val;
|
||||||
m_internal_analog_kbd[pad].rx = m_analog_released_val;
|
m_internal_analog_kbd[pad].rx = m_analog_released_val;
|
||||||
m_internal_analog_kbd[pad].ry = m_analog_released_val;
|
m_internal_analog_kbd[pad].ry = m_analog_released_val;
|
||||||
m_internal_analog_joy[pad].lx = m_analog_released_val;
|
m_internal_analog_joy[pad].lx = m_analog_released_val;
|
||||||
m_internal_analog_joy[pad].ly = m_analog_released_val;
|
m_internal_analog_joy[pad].ly = m_analog_released_val;
|
||||||
m_internal_analog_joy[pad].rx = m_analog_released_val;
|
m_internal_analog_joy[pad].rx = m_analog_released_val;
|
||||||
m_internal_analog_joy[pad].ry = m_analog_released_val;
|
m_internal_analog_joy[pad].ry = m_analog_released_val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeyStatus::press(u32 pad, u32 index, s32 value)
|
void KeyStatus::press(u32 pad, u32 index, s32 value)
|
||||||
{
|
{
|
||||||
if (!IsAnalogKey(index)) {
|
if (!IsAnalogKey(index)) {
|
||||||
m_internal_button_pressure[pad][index] = value;
|
m_internal_button_pressure[pad][index] = value;
|
||||||
if (m_state_acces[pad])
|
if (m_state_acces[pad])
|
||||||
clear_bit(m_internal_button_kbd[pad], index);
|
clear_bit(m_internal_button_kbd[pad], index);
|
||||||
else
|
else
|
||||||
clear_bit(m_internal_button_joy[pad], index);
|
clear_bit(m_internal_button_joy[pad], index);
|
||||||
} else {
|
} else {
|
||||||
// clamp value
|
// clamp value
|
||||||
if (value > MAX_ANALOG_VALUE)
|
if (value > MAX_ANALOG_VALUE)
|
||||||
value = MAX_ANALOG_VALUE;
|
value = MAX_ANALOG_VALUE;
|
||||||
else if (value < -MAX_ANALOG_VALUE)
|
else if (value < -MAX_ANALOG_VALUE)
|
||||||
value = -MAX_ANALOG_VALUE;
|
value = -MAX_ANALOG_VALUE;
|
||||||
|
|
||||||
// Left -> -- -> Right
|
// Left -> -- -> Right
|
||||||
// Value range : FFFF8002 -> 0 -> 7FFE
|
// Value range : FFFF8002 -> 0 -> 7FFE
|
||||||
// Force range : 80 -> 0 -> 7F
|
// Force range : 80 -> 0 -> 7F
|
||||||
// Normal mode : expect value 0 -> 80 -> FF
|
// Normal mode : expect value 0 -> 80 -> FF
|
||||||
// Reverse mode: expect value FF -> 7F -> 0
|
// Reverse mode: expect value FF -> 7F -> 0
|
||||||
u8 force = (value / 256);
|
u8 force = (value / 256);
|
||||||
if (analog_is_reversed(pad,index))
|
if (analog_is_reversed(pad, index))
|
||||||
analog_set(pad, index, m_analog_released_val - force);
|
analog_set(pad, index, m_analog_released_val - force);
|
||||||
else
|
else
|
||||||
analog_set(pad, index, m_analog_released_val + force);
|
analog_set(pad, index, m_analog_released_val + force);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeyStatus::release(u32 pad, u32 index)
|
void KeyStatus::release(u32 pad, u32 index)
|
||||||
{
|
{
|
||||||
if (!IsAnalogKey(index)) {
|
if (!IsAnalogKey(index)) {
|
||||||
if (m_state_acces[pad])
|
if (m_state_acces[pad])
|
||||||
set_bit(m_internal_button_kbd[pad], index);
|
set_bit(m_internal_button_kbd[pad], index);
|
||||||
else
|
else
|
||||||
set_bit(m_internal_button_joy[pad], index);
|
set_bit(m_internal_button_joy[pad], index);
|
||||||
} else {
|
} else {
|
||||||
analog_set(pad, index, m_analog_released_val);
|
analog_set(pad, index, m_analog_released_val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
u16 KeyStatus::get(u32 pad)
|
u16 KeyStatus::get(u32 pad)
|
||||||
{
|
{
|
||||||
return m_button[pad];
|
return m_button[pad];
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeyStatus::analog_set(u32 pad, u32 index, u8 value)
|
void KeyStatus::analog_set(u32 pad, u32 index, u8 value)
|
||||||
{
|
{
|
||||||
PADAnalog* m_internal_analog_ref;
|
PADAnalog *m_internal_analog_ref;
|
||||||
if (m_state_acces[pad])
|
if (m_state_acces[pad])
|
||||||
m_internal_analog_ref = &m_internal_analog_kbd[pad];
|
m_internal_analog_ref = &m_internal_analog_kbd[pad];
|
||||||
else
|
else
|
||||||
m_internal_analog_ref = &m_internal_analog_joy[pad];
|
m_internal_analog_ref = &m_internal_analog_joy[pad];
|
||||||
|
|
||||||
switch (index)
|
switch (index) {
|
||||||
{
|
case PAD_R_LEFT:
|
||||||
case PAD_R_LEFT:
|
case PAD_R_RIGHT:
|
||||||
case PAD_R_RIGHT: m_internal_analog_ref->rx = value; break;
|
m_internal_analog_ref->rx = value;
|
||||||
|
break;
|
||||||
|
|
||||||
case PAD_R_DOWN:
|
case PAD_R_DOWN:
|
||||||
case PAD_R_UP: m_internal_analog_ref->ry = value; break;
|
case PAD_R_UP:
|
||||||
|
m_internal_analog_ref->ry = value;
|
||||||
|
break;
|
||||||
|
|
||||||
case PAD_L_LEFT:
|
case PAD_L_LEFT:
|
||||||
case PAD_L_RIGHT: m_internal_analog_ref->lx = value; break;
|
case PAD_L_RIGHT:
|
||||||
|
m_internal_analog_ref->lx = value;
|
||||||
|
break;
|
||||||
|
|
||||||
case PAD_L_DOWN:
|
case PAD_L_DOWN:
|
||||||
case PAD_L_UP: m_internal_analog_ref->ly = value; break;
|
case PAD_L_UP:
|
||||||
|
m_internal_analog_ref->ly = value;
|
||||||
|
break;
|
||||||
|
|
||||||
default: break;
|
default:
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KeyStatus::analog_is_reversed(u32 pad, u32 index)
|
bool KeyStatus::analog_is_reversed(u32 pad, u32 index)
|
||||||
{
|
{
|
||||||
switch (index)
|
switch (index) {
|
||||||
{
|
case PAD_L_RIGHT:
|
||||||
case PAD_L_RIGHT:
|
case PAD_L_LEFT:
|
||||||
case PAD_L_LEFT:
|
return (conf->pad_options[pad].reverse_lx);
|
||||||
return (conf->pad_options[pad].reverse_lx);
|
|
||||||
|
|
||||||
case PAD_R_LEFT:
|
case PAD_R_LEFT:
|
||||||
case PAD_R_RIGHT:
|
case PAD_R_RIGHT:
|
||||||
return (conf->pad_options[pad].reverse_rx);
|
return (conf->pad_options[pad].reverse_rx);
|
||||||
|
|
||||||
case PAD_L_UP:
|
case PAD_L_UP:
|
||||||
case PAD_L_DOWN:
|
case PAD_L_DOWN:
|
||||||
return (conf->pad_options[pad].reverse_ly);
|
return (conf->pad_options[pad].reverse_ly);
|
||||||
|
|
||||||
case PAD_R_DOWN:
|
case PAD_R_DOWN:
|
||||||
case PAD_R_UP:
|
case PAD_R_UP:
|
||||||
return (conf->pad_options[pad].reverse_ry);
|
return (conf->pad_options[pad].reverse_ry);
|
||||||
|
|
||||||
default: return false;
|
default:
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
u8 KeyStatus::get(u32 pad, u32 index)
|
u8 KeyStatus::get(u32 pad, u32 index)
|
||||||
{
|
{
|
||||||
switch (index)
|
switch (index) {
|
||||||
{
|
case PAD_R_LEFT:
|
||||||
case PAD_R_LEFT:
|
case PAD_R_RIGHT:
|
||||||
case PAD_R_RIGHT: return m_analog[pad].rx;
|
return m_analog[pad].rx;
|
||||||
|
|
||||||
case PAD_R_DOWN:
|
case PAD_R_DOWN:
|
||||||
case PAD_R_UP: return m_analog[pad].ry;
|
case PAD_R_UP:
|
||||||
|
return m_analog[pad].ry;
|
||||||
|
|
||||||
case PAD_L_LEFT:
|
case PAD_L_LEFT:
|
||||||
case PAD_L_RIGHT: return m_analog[pad].lx;
|
case PAD_L_RIGHT:
|
||||||
|
return m_analog[pad].lx;
|
||||||
|
|
||||||
case PAD_L_DOWN:
|
case PAD_L_DOWN:
|
||||||
case PAD_L_UP: return m_analog[pad].ly;
|
case PAD_L_UP:
|
||||||
|
return m_analog[pad].ly;
|
||||||
|
|
||||||
default: return m_button_pressure[pad][index];
|
default:
|
||||||
}
|
return m_button_pressure[pad][index];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
u8 KeyStatus::analog_merge(u8 kbd, u8 joy)
|
u8 KeyStatus::analog_merge(u8 kbd, u8 joy)
|
||||||
{
|
{
|
||||||
if (kbd != m_analog_released_val)
|
if (kbd != m_analog_released_val)
|
||||||
return kbd;
|
return kbd;
|
||||||
else
|
else
|
||||||
return joy;
|
return joy;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeyStatus::commit_status(u32 pad)
|
void KeyStatus::commit_status(u32 pad)
|
||||||
{
|
{
|
||||||
m_button[pad] = m_internal_button_kbd[pad] & m_internal_button_joy[pad];
|
m_button[pad] = m_internal_button_kbd[pad] & m_internal_button_joy[pad];
|
||||||
|
|
||||||
for (int index = 0; index < MAX_KEYS; index++)
|
for (int index = 0; index < MAX_KEYS; index++)
|
||||||
m_button_pressure[pad][index] = m_internal_button_pressure[pad][index];
|
m_button_pressure[pad][index] = m_internal_button_pressure[pad][index];
|
||||||
|
|
||||||
m_analog[pad].lx = analog_merge(m_internal_analog_kbd[pad].lx, m_internal_analog_joy[pad].lx);
|
m_analog[pad].lx = analog_merge(m_internal_analog_kbd[pad].lx, m_internal_analog_joy[pad].lx);
|
||||||
m_analog[pad].ly = analog_merge(m_internal_analog_kbd[pad].ly, m_internal_analog_joy[pad].ly);
|
m_analog[pad].ly = analog_merge(m_internal_analog_kbd[pad].ly, m_internal_analog_joy[pad].ly);
|
||||||
m_analog[pad].rx = analog_merge(m_internal_analog_kbd[pad].rx, m_internal_analog_joy[pad].rx);
|
m_analog[pad].rx = analog_merge(m_internal_analog_kbd[pad].rx, m_internal_analog_joy[pad].rx);
|
||||||
m_analog[pad].ry = analog_merge(m_internal_analog_kbd[pad].ry, m_internal_analog_joy[pad].ry);
|
m_analog[pad].ry = analog_merge(m_internal_analog_kbd[pad].ry, m_internal_analog_joy[pad].ry);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,51 +26,55 @@
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
u8 lx, ly;
|
u8 lx, ly;
|
||||||
u8 rx, ry;
|
u8 rx, ry;
|
||||||
} PADAnalog;
|
} PADAnalog;
|
||||||
|
|
||||||
#define MAX_ANALOG_VALUE 32766
|
#define MAX_ANALOG_VALUE 32766
|
||||||
|
|
||||||
class KeyStatus
|
class KeyStatus
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
const u8 m_analog_released_val;
|
const u8 m_analog_released_val;
|
||||||
|
|
||||||
u16 m_button[GAMEPAD_NUMBER];
|
u16 m_button[GAMEPAD_NUMBER];
|
||||||
u16 m_internal_button_kbd[GAMEPAD_NUMBER];
|
u16 m_internal_button_kbd[GAMEPAD_NUMBER];
|
||||||
u16 m_internal_button_joy[GAMEPAD_NUMBER];
|
u16 m_internal_button_joy[GAMEPAD_NUMBER];
|
||||||
|
|
||||||
u8 m_button_pressure[GAMEPAD_NUMBER][MAX_KEYS];
|
u8 m_button_pressure[GAMEPAD_NUMBER][MAX_KEYS];
|
||||||
u8 m_internal_button_pressure[GAMEPAD_NUMBER][MAX_KEYS];
|
u8 m_internal_button_pressure[GAMEPAD_NUMBER][MAX_KEYS];
|
||||||
|
|
||||||
bool m_state_acces[GAMEPAD_NUMBER];
|
bool m_state_acces[GAMEPAD_NUMBER];
|
||||||
|
|
||||||
PADAnalog m_analog[GAMEPAD_NUMBER];
|
PADAnalog m_analog[GAMEPAD_NUMBER];
|
||||||
PADAnalog m_internal_analog_kbd[GAMEPAD_NUMBER];
|
PADAnalog m_internal_analog_kbd[GAMEPAD_NUMBER];
|
||||||
PADAnalog m_internal_analog_joy[GAMEPAD_NUMBER];
|
PADAnalog m_internal_analog_joy[GAMEPAD_NUMBER];
|
||||||
|
|
||||||
void analog_set(u32 pad, u32 index, u8 value);
|
void analog_set(u32 pad, u32 index, u8 value);
|
||||||
bool analog_is_reversed(u32 pad, u32 index);
|
bool analog_is_reversed(u32 pad, u32 index);
|
||||||
u8 analog_merge(u8 kbd, u8 joy);
|
u8 analog_merge(u8 kbd, u8 joy);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
KeyStatus() : m_analog_released_val(0x7F) { Init(); }
|
KeyStatus()
|
||||||
void Init();
|
: m_analog_released_val(0x7F)
|
||||||
|
{
|
||||||
|
Init();
|
||||||
|
}
|
||||||
|
void Init();
|
||||||
|
|
||||||
void keyboard_state_acces(u32 pad) { m_state_acces[pad] = true; }
|
void keyboard_state_acces(u32 pad) { m_state_acces[pad] = true; }
|
||||||
void joystick_state_acces(u32 pad) { m_state_acces[pad] = false; }
|
void joystick_state_acces(u32 pad) { m_state_acces[pad] = false; }
|
||||||
|
|
||||||
void press(u32 pad, u32 index, s32 value = 0xFF);
|
void press(u32 pad, u32 index, s32 value = 0xFF);
|
||||||
void release(u32 pad, u32 index);
|
void release(u32 pad, u32 index);
|
||||||
|
|
||||||
u16 get(u32 pad);
|
u16 get(u32 pad);
|
||||||
u8 get(u32 pad, u32 index);
|
u8 get(u32 pad, u32 index);
|
||||||
|
|
||||||
|
|
||||||
void commit_status(u32 pad);
|
void commit_status(u32 pad);
|
||||||
};
|
};
|
||||||
|
|
||||||
extern KeyStatus* key_status;
|
extern KeyStatus *key_status;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -20,101 +20,101 @@
|
||||||
#include "GamepadConfiguration.h"
|
#include "GamepadConfiguration.h"
|
||||||
|
|
||||||
// Construtor of GamepadConfiguration
|
// Construtor of GamepadConfiguration
|
||||||
GamepadConfiguration::GamepadConfiguration(int pad, wxWindow *parent) : wxDialog(
|
GamepadConfiguration::GamepadConfiguration(int pad, wxWindow *parent)
|
||||||
parent, // Parent
|
: wxDialog(
|
||||||
wxID_ANY, // ID
|
parent, // Parent
|
||||||
_T("Gamepad configuration"), // Title
|
wxID_ANY, // ID
|
||||||
wxDefaultPosition, // Position
|
_T("Gamepad configuration"), // Title
|
||||||
wxSize(400, 230), // Width + Lenght
|
wxDefaultPosition, // Position
|
||||||
// Style
|
wxSize(400, 230), // Width + Lenght
|
||||||
wxSYSTEM_MENU |
|
// Style
|
||||||
wxCAPTION |
|
wxSYSTEM_MENU |
|
||||||
wxCLOSE_BOX |
|
wxCAPTION |
|
||||||
wxCLIP_CHILDREN
|
wxCLOSE_BOX |
|
||||||
)
|
wxCLIP_CHILDREN)
|
||||||
{
|
{
|
||||||
|
|
||||||
m_pad_id = pad;
|
m_pad_id = pad;
|
||||||
m_pan_gamepad_config = new wxPanel(
|
m_pan_gamepad_config = new wxPanel(
|
||||||
this, // Parent
|
this, // Parent
|
||||||
wxID_ANY, // ID
|
wxID_ANY, // ID
|
||||||
wxDefaultPosition, // Prosition
|
wxDefaultPosition, // Prosition
|
||||||
wxSize(300, 200) // Size
|
wxSize(300, 200) // Size
|
||||||
);
|
);
|
||||||
m_cb_rumble = new wxCheckBox(
|
m_cb_rumble = new wxCheckBox(
|
||||||
m_pan_gamepad_config, // Parent
|
m_pan_gamepad_config, // Parent
|
||||||
wxID_ANY, // ID
|
wxID_ANY, // ID
|
||||||
_T("&Enable rumble"), // Label
|
_T("&Enable rumble"), // Label
|
||||||
wxPoint(20, 20) // Position
|
wxPoint(20, 20) // Position
|
||||||
);
|
);
|
||||||
|
|
||||||
m_cb_hack_sixaxis_usb = new wxCheckBox(
|
m_cb_hack_sixaxis_usb = new wxCheckBox(
|
||||||
m_pan_gamepad_config, // Parent
|
m_pan_gamepad_config, // Parent
|
||||||
wxID_ANY, // ID
|
wxID_ANY, // ID
|
||||||
_T("&Hack: Sixaxis/DS3 plugged in USB"), // Label
|
_T("&Hack: Sixaxis/DS3 plugged in USB"), // Label
|
||||||
wxPoint(20, 40) // Position
|
wxPoint(20, 40) // Position
|
||||||
);
|
);
|
||||||
|
|
||||||
m_cb_hack_sixaxis_pressure = new wxCheckBox(
|
m_cb_hack_sixaxis_pressure = new wxCheckBox(
|
||||||
m_pan_gamepad_config, // Parent
|
m_pan_gamepad_config, // Parent
|
||||||
wxID_ANY, // ID
|
wxID_ANY, // ID
|
||||||
_T("&Hack: Sixaxis/DS3 pressure"), // Label
|
_T("&Hack: Sixaxis/DS3 pressure"), // Label
|
||||||
wxPoint(20, 60) // Position
|
wxPoint(20, 60) // Position
|
||||||
);
|
);
|
||||||
|
|
||||||
wxString txt_rumble = wxT("Rumble intensity");
|
wxString txt_rumble = wxT("Rumble intensity");
|
||||||
m_lbl_rumble_intensity = new wxStaticText(
|
m_lbl_rumble_intensity = new wxStaticText(
|
||||||
m_pan_gamepad_config, // Parent
|
m_pan_gamepad_config, // Parent
|
||||||
wxID_ANY, // ID
|
wxID_ANY, // ID
|
||||||
txt_rumble, // Text which must be displayed
|
txt_rumble, // Text which must be displayed
|
||||||
wxPoint(20, 90), // Position
|
wxPoint(20, 90), // Position
|
||||||
wxDefaultSize // Size
|
wxDefaultSize // Size
|
||||||
);
|
);
|
||||||
|
|
||||||
m_sl_rumble_intensity = new wxSlider(
|
m_sl_rumble_intensity = new wxSlider(
|
||||||
m_pan_gamepad_config, // Parent
|
m_pan_gamepad_config, // Parent
|
||||||
wxID_ANY, // ID
|
wxID_ANY, // ID
|
||||||
0, // value
|
0, // value
|
||||||
0, // min value 0x0000
|
0, // min value 0x0000
|
||||||
0x7FFF, // max value 0x7FFF
|
0x7FFF, // max value 0x7FFF
|
||||||
wxPoint(150, 83), // Position
|
wxPoint(150, 83), // Position
|
||||||
wxSize(200, 30) // Size
|
wxSize(200, 30) // Size
|
||||||
);
|
);
|
||||||
|
|
||||||
wxString txt_joystick = wxT("Joystick sensibility");
|
wxString txt_joystick = wxT("Joystick sensibility");
|
||||||
m_lbl_rumble_intensity = new wxStaticText(
|
m_lbl_rumble_intensity = new wxStaticText(
|
||||||
m_pan_gamepad_config, // Parent
|
m_pan_gamepad_config, // Parent
|
||||||
wxID_ANY, // ID
|
wxID_ANY, // ID
|
||||||
txt_joystick, // Text which must be displayed
|
txt_joystick, // Text which must be displayed
|
||||||
wxPoint(20, 120), // Position
|
wxPoint(20, 120), // Position
|
||||||
wxDefaultSize // Size
|
wxDefaultSize // Size
|
||||||
);
|
);
|
||||||
|
|
||||||
m_sl_joystick_sensibility = new wxSlider(
|
m_sl_joystick_sensibility = new wxSlider(
|
||||||
m_pan_gamepad_config, // Parent
|
m_pan_gamepad_config, // Parent
|
||||||
wxID_ANY, // ID
|
wxID_ANY, // ID
|
||||||
0, // value
|
0, // value
|
||||||
0, // min value
|
0, // min value
|
||||||
100, // max value
|
100, // max value
|
||||||
wxPoint(150, 113), // Position
|
wxPoint(150, 113), // Position
|
||||||
wxSize(200, 30) // Size
|
wxSize(200, 30) // Size
|
||||||
);
|
);
|
||||||
|
|
||||||
m_bt_ok = new wxButton(
|
m_bt_ok = new wxButton(
|
||||||
m_pan_gamepad_config, // Parent
|
m_pan_gamepad_config, // Parent
|
||||||
wxID_ANY, // ID
|
wxID_ANY, // ID
|
||||||
_T("&OK"), // Label
|
_T("&OK"), // Label
|
||||||
wxPoint(250, 160), // Position
|
wxPoint(250, 160), // Position
|
||||||
wxSize(60,25) // Size
|
wxSize(60, 25) // Size
|
||||||
);
|
);
|
||||||
|
|
||||||
m_bt_cancel = new wxButton(
|
m_bt_cancel = new wxButton(
|
||||||
m_pan_gamepad_config, // Parent
|
m_pan_gamepad_config, // Parent
|
||||||
wxID_ANY, // ID
|
wxID_ANY, // ID
|
||||||
_T("&Cancel"), // Label
|
_T("&Cancel"), // Label
|
||||||
wxPoint(320, 160), // Position
|
wxPoint(320, 160), // Position
|
||||||
wxSize(60,25) // Size
|
wxSize(60, 25) // Size
|
||||||
);
|
);
|
||||||
|
|
||||||
Bind(wxEVT_BUTTON, &GamepadConfiguration::OnButtonClicked, this);
|
Bind(wxEVT_BUTTON, &GamepadConfiguration::OnButtonClicked, this);
|
||||||
Bind(wxEVT_SCROLL_THUMBRELEASE, &GamepadConfiguration::OnSliderReleased, this);
|
Bind(wxEVT_SCROLL_THUMBRELEASE, &GamepadConfiguration::OnSliderReleased, this);
|
||||||
|
@ -130,34 +130,30 @@ GamepadConfiguration::GamepadConfiguration(int pad, wxWindow *parent) : wxDialog
|
||||||
*/
|
*/
|
||||||
void GamepadConfiguration::InitGamepadConfiguration()
|
void GamepadConfiguration::InitGamepadConfiguration()
|
||||||
{
|
{
|
||||||
repopulate(); // Set label and fit simulated key array
|
repopulate(); // Set label and fit simulated key array
|
||||||
/*
|
/*
|
||||||
* Check if there exist at least one pad available
|
* Check if there exist at least one pad available
|
||||||
* if the pad id is 0, you need at least 1 gamepad connected,
|
* if the pad id is 0, you need at least 1 gamepad connected,
|
||||||
* if the pad id is 1, you need at least 2 gamepad connected,
|
* if the pad id is 1, you need at least 2 gamepad connected,
|
||||||
* Prevent to use a none initialized value on s_vgamePad (core dump)
|
* Prevent to use a none initialized value on s_vgamePad (core dump)
|
||||||
*/
|
*/
|
||||||
if(s_vgamePad.size() >= m_pad_id+1)
|
if (s_vgamePad.size() >= m_pad_id + 1) {
|
||||||
{
|
|
||||||
/*
|
/*
|
||||||
* Determine if the device can use rumble
|
* Determine if the device can use rumble
|
||||||
* Use TestForce with a very low strength (can't be felt)
|
* Use TestForce with a very low strength (can't be felt)
|
||||||
* May be better to create a new function in order to check only that
|
* May be better to create a new function in order to check only that
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if(!s_vgamePad[m_pad_id]->TestForce(0.001f))
|
if (!s_vgamePad[m_pad_id]->TestForce(0.001f)) {
|
||||||
{
|
|
||||||
wxMessageBox(L"Rumble is not available for your device.");
|
wxMessageBox(L"Rumble is not available for your device.");
|
||||||
m_cb_rumble->Disable(); // disable the rumble checkbox
|
m_cb_rumble->Disable(); // disable the rumble checkbox
|
||||||
m_sl_rumble_intensity->Disable(); // disable the rumble intensity slider
|
m_sl_rumble_intensity->Disable(); // disable the rumble intensity slider
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
wxMessageBox(L"No gamepad detected.");
|
wxMessageBox(L"No gamepad detected.");
|
||||||
m_sl_joystick_sensibility->Disable(); // disable the joystick sensibility slider
|
m_sl_joystick_sensibility->Disable(); // disable the joystick sensibility slider
|
||||||
m_cb_rumble->Disable(); // disable the rumble checkbox
|
m_cb_rumble->Disable(); // disable the rumble checkbox
|
||||||
m_sl_rumble_intensity->Disable(); // disable the rumble intensity slider
|
m_sl_rumble_intensity->Disable(); // disable the rumble intensity slider
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,16 +167,13 @@ void GamepadConfiguration::InitGamepadConfiguration()
|
||||||
void GamepadConfiguration::OnButtonClicked(wxCommandEvent &event)
|
void GamepadConfiguration::OnButtonClicked(wxCommandEvent &event)
|
||||||
{
|
{
|
||||||
// Affichage d'un message à chaque clic sur le bouton
|
// Affichage d'un message à chaque clic sur le bouton
|
||||||
wxButton* bt_tmp = (wxButton*)event.GetEventObject(); // get the button object
|
wxButton *bt_tmp = (wxButton *)event.GetEventObject(); // get the button object
|
||||||
int bt_id = bt_tmp->GetId(); // get the real ID
|
int bt_id = bt_tmp->GetId(); // get the real ID
|
||||||
if(bt_id == m_bt_ok->GetId()) // If the button ID is equals to the Ok button ID
|
if (bt_id == m_bt_ok->GetId()) { // If the button ID is equals to the Ok button ID
|
||||||
{
|
Close(); // Close the window
|
||||||
Close(); // Close the window
|
} else if (bt_id == m_bt_cancel->GetId()) { // If the button ID is equals to the cancel button ID
|
||||||
}
|
reset(); // reinitialize the value of each parameters
|
||||||
else if(bt_id == m_bt_cancel->GetId()) // If the button ID is equals to the cancel button ID
|
Close(); // Close the window
|
||||||
{
|
|
||||||
reset(); // reinitialize the value of each parameters
|
|
||||||
Close(); // Close the window
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,13 +184,12 @@ void GamepadConfiguration::OnButtonClicked(wxCommandEvent &event)
|
||||||
*/
|
*/
|
||||||
void GamepadConfiguration::OnSliderReleased(wxCommandEvent &event)
|
void GamepadConfiguration::OnSliderReleased(wxCommandEvent &event)
|
||||||
{
|
{
|
||||||
wxSlider* sl_tmp = (wxSlider*)event.GetEventObject(); // get the slider object
|
wxSlider *sl_tmp = (wxSlider *)event.GetEventObject(); // get the slider object
|
||||||
int sl_id = sl_tmp->GetId(); // slider id
|
int sl_id = sl_tmp->GetId(); // slider id
|
||||||
if(sl_id == m_sl_rumble_intensity->GetId()) // if this is the rumble intensity slider
|
if (sl_id == m_sl_rumble_intensity->GetId()) { // if this is the rumble intensity slider
|
||||||
{
|
|
||||||
u32 intensity = m_sl_rumble_intensity->GetValue(); // get the new value
|
u32 intensity = m_sl_rumble_intensity->GetValue(); // get the new value
|
||||||
conf->set_ff_intensity(intensity); // and set the force feedback intensity value with it
|
conf->set_ff_intensity(intensity); // and set the force feedback intensity value with it
|
||||||
// get the rumble intensity
|
// get the rumble intensity
|
||||||
float strength = m_sl_rumble_intensity->GetValue();
|
float strength = m_sl_rumble_intensity->GetValue();
|
||||||
/*
|
/*
|
||||||
* convert in a float value between 0 and 1, and run rumble feedback
|
* convert in a float value between 0 and 1, and run rumble feedback
|
||||||
|
@ -210,42 +202,32 @@ void GamepadConfiguration::OnSliderReleased(wxCommandEvent &event)
|
||||||
* 0x7FFF : maximum intensity
|
* 0x7FFF : maximum intensity
|
||||||
* 1 : maximum value of the intensity for the sdl rumble test
|
* 1 : maximum value of the intensity for the sdl rumble test
|
||||||
*/
|
*/
|
||||||
s_vgamePad[m_pad_id]->TestForce(strength/0x7FFF);
|
s_vgamePad[m_pad_id]->TestForce(strength / 0x7FFF);
|
||||||
}
|
} else if (sl_id == m_sl_joystick_sensibility->GetId()) {
|
||||||
else if(sl_id == m_sl_joystick_sensibility->GetId())
|
u32 sensibility = m_sl_joystick_sensibility->GetValue(); // get the new value
|
||||||
{
|
conf->set_sensibility(sensibility); // and set the joystick sensibility
|
||||||
u32 sensibility = m_sl_joystick_sensibility->GetValue(); // get the new value
|
|
||||||
conf->set_sensibility(sensibility); // and set the joystick sensibility
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checkbox event, called when the value of the checkbox change
|
* Checkbox event, called when the value of the checkbox change
|
||||||
*/
|
*/
|
||||||
void GamepadConfiguration::OnCheckboxChange(wxCommandEvent& event)
|
void GamepadConfiguration::OnCheckboxChange(wxCommandEvent &event)
|
||||||
{
|
{
|
||||||
wxCheckBox* cb_tmp = (wxCheckBox*) event.GetEventObject(); // get the slider object
|
wxCheckBox *cb_tmp = (wxCheckBox *)event.GetEventObject(); // get the slider object
|
||||||
int cb_id = cb_tmp->GetId();
|
int cb_id = cb_tmp->GetId();
|
||||||
if(cb_id == m_cb_rumble->GetId())
|
if (cb_id == m_cb_rumble->GetId()) {
|
||||||
{
|
conf->pad_options[m_pad_id].forcefeedback = (m_cb_rumble->GetValue()) ? (u32)1 : (u32)0;
|
||||||
conf->pad_options[m_pad_id].forcefeedback = (m_cb_rumble->GetValue())?(u32)1:(u32)0;
|
if (m_cb_rumble->GetValue()) {
|
||||||
if(m_cb_rumble->GetValue())
|
|
||||||
{
|
|
||||||
s_vgamePad[m_pad_id]->TestForce();
|
s_vgamePad[m_pad_id]->TestForce();
|
||||||
m_sl_rumble_intensity->Enable();
|
m_sl_rumble_intensity->Enable();
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
m_sl_rumble_intensity->Disable();
|
m_sl_rumble_intensity->Disable();
|
||||||
}
|
}
|
||||||
}
|
} else if (cb_id == m_cb_hack_sixaxis_usb->GetId()) {
|
||||||
else if(cb_id == m_cb_hack_sixaxis_usb->GetId())
|
conf->pad_options[m_pad_id].sixaxis_usb = (m_cb_hack_sixaxis_usb->GetValue()) ? (u32)1 : (u32)0;
|
||||||
{
|
} else if (cb_id == m_cb_hack_sixaxis_pressure->GetId()) {
|
||||||
conf->pad_options[m_pad_id].sixaxis_usb = (m_cb_hack_sixaxis_usb->GetValue())?(u32)1:(u32)0;
|
conf->pad_options[m_pad_id].sixaxis_pressure = (m_cb_hack_sixaxis_pressure->GetValue()) ? (u32)1 : (u32)0;
|
||||||
}
|
|
||||||
else if(cb_id == m_cb_hack_sixaxis_pressure->GetId())
|
|
||||||
{
|
|
||||||
conf->pad_options[m_pad_id].sixaxis_pressure = (m_cb_hack_sixaxis_pressure->GetValue())?(u32)1:(u32)0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -283,8 +265,8 @@ void GamepadConfiguration::repopulate()
|
||||||
m_init_joystick_sensibility = tmp;
|
m_init_joystick_sensibility = tmp;
|
||||||
|
|
||||||
// enable rumble intensity slider if the checkbox is checked
|
// enable rumble intensity slider if the checkbox is checked
|
||||||
if(m_cb_rumble->GetValue())
|
if (m_cb_rumble->GetValue())
|
||||||
m_sl_rumble_intensity->Enable();
|
m_sl_rumble_intensity->Enable();
|
||||||
else // disable otherwise
|
else // disable otherwise
|
||||||
m_sl_rumble_intensity->Disable();
|
m_sl_rumble_intensity->Disable();
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
|
|
||||||
class GamepadConfiguration : public wxDialog
|
class GamepadConfiguration : public wxDialog
|
||||||
{
|
{
|
||||||
wxPanel* m_pan_gamepad_config;
|
wxPanel *m_pan_gamepad_config;
|
||||||
wxCheckBox *m_cb_rumble, *m_cb_hack_sixaxis_usb, *m_cb_hack_sixaxis_pressure;
|
wxCheckBox *m_cb_rumble, *m_cb_hack_sixaxis_usb, *m_cb_hack_sixaxis_pressure;
|
||||||
wxSlider *m_sl_rumble_intensity, *m_sl_joystick_sensibility;
|
wxSlider *m_sl_rumble_intensity, *m_sl_joystick_sensibility;
|
||||||
wxButton *m_bt_ok, *m_bt_cancel;
|
wxButton *m_bt_ok, *m_bt_cancel;
|
||||||
|
@ -48,13 +48,13 @@ class GamepadConfiguration : public wxDialog
|
||||||
void repopulate();
|
void repopulate();
|
||||||
void reset();
|
void reset();
|
||||||
// Events
|
// Events
|
||||||
void OnButtonClicked(wxCommandEvent&);
|
void OnButtonClicked(wxCommandEvent &);
|
||||||
void OnSliderReleased(wxCommandEvent&);
|
void OnSliderReleased(wxCommandEvent &);
|
||||||
void OnCheckboxChange(wxCommandEvent&);
|
void OnCheckboxChange(wxCommandEvent &);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GamepadConfiguration(int, wxWindow*);
|
GamepadConfiguration(int, wxWindow *);
|
||||||
void InitGamepadConfiguration();
|
void InitGamepadConfiguration();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __GAMEPADCONFIGURATION_H__
|
#endif // __GAMEPADCONFIGURATION_H__
|
||||||
|
|
|
@ -20,91 +20,88 @@
|
||||||
#include "JoystickConfiguration.h"
|
#include "JoystickConfiguration.h"
|
||||||
|
|
||||||
// Construtor of JoystickConfiguration
|
// Construtor of JoystickConfiguration
|
||||||
JoystickConfiguration::JoystickConfiguration(int pad, bool left, wxWindow *parent) : wxDialog(
|
JoystickConfiguration::JoystickConfiguration(int pad, bool left, wxWindow *parent)
|
||||||
parent, // Parent
|
: wxDialog(
|
||||||
wxID_ANY, // ID
|
parent, // Parent
|
||||||
_T("Gamepad configuration"), // Title
|
wxID_ANY, // ID
|
||||||
wxDefaultPosition, // Position
|
_T("Gamepad configuration"), // Title
|
||||||
wxSize(400, 200), // Width + Lenght
|
wxDefaultPosition, // Position
|
||||||
// Style
|
wxSize(400, 200), // Width + Lenght
|
||||||
wxSYSTEM_MENU |
|
// Style
|
||||||
wxCAPTION |
|
wxSYSTEM_MENU |
|
||||||
wxCLOSE_BOX |
|
wxCAPTION |
|
||||||
wxCLIP_CHILDREN
|
wxCLOSE_BOX |
|
||||||
)
|
wxCLIP_CHILDREN)
|
||||||
{
|
{
|
||||||
|
|
||||||
m_pad_id = pad;
|
m_pad_id = pad;
|
||||||
m_isForLeftJoystick = left;
|
m_isForLeftJoystick = left;
|
||||||
m_pan_joystick_config = new wxPanel(
|
m_pan_joystick_config = new wxPanel(
|
||||||
this, // Parent
|
this, // Parent
|
||||||
wxID_ANY, // ID
|
wxID_ANY, // ID
|
||||||
wxDefaultPosition, // Prosition
|
wxDefaultPosition, // Prosition
|
||||||
wxSize(300, 200) // Size
|
wxSize(300, 200) // Size
|
||||||
);
|
|
||||||
|
|
||||||
if(m_isForLeftJoystick)
|
|
||||||
{
|
|
||||||
m_cb_reverse_Lx = new wxCheckBox(
|
|
||||||
m_pan_joystick_config, // Parent
|
|
||||||
wxID_ANY, // ID
|
|
||||||
_T("Reverse Lx"), // Label
|
|
||||||
wxPoint(20, 20) // Position
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (m_isForLeftJoystick) {
|
||||||
|
m_cb_reverse_Lx = new wxCheckBox(
|
||||||
|
m_pan_joystick_config, // Parent
|
||||||
|
wxID_ANY, // ID
|
||||||
|
_T("Reverse Lx"), // Label
|
||||||
|
wxPoint(20, 20) // Position
|
||||||
|
);
|
||||||
|
|
||||||
m_cb_reverse_Ly = new wxCheckBox(
|
m_cb_reverse_Ly = new wxCheckBox(
|
||||||
m_pan_joystick_config, // Parent
|
m_pan_joystick_config, // Parent
|
||||||
wxID_ANY, // ID
|
wxID_ANY, // ID
|
||||||
_T("Reverse Ly"), // Label
|
_T("Reverse Ly"), // Label
|
||||||
wxPoint(20, 40) // Position
|
wxPoint(20, 40) // Position
|
||||||
);
|
);
|
||||||
|
|
||||||
m_cb_mouse_Ljoy = new wxCheckBox(
|
m_cb_mouse_Ljoy = new wxCheckBox(
|
||||||
m_pan_joystick_config, // Parent
|
m_pan_joystick_config, // Parent
|
||||||
wxID_ANY, // ID
|
wxID_ANY, // ID
|
||||||
_T("Use mouse for left analog joystick"), // Label
|
_T("Use mouse for left analog joystick"), // Label
|
||||||
wxPoint(20, 60) // Position
|
wxPoint(20, 60) // Position
|
||||||
);
|
);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
m_cb_reverse_Rx = new wxCheckBox(
|
m_cb_reverse_Rx = new wxCheckBox(
|
||||||
m_pan_joystick_config, // Parent
|
m_pan_joystick_config, // Parent
|
||||||
wxID_ANY, // ID
|
wxID_ANY, // ID
|
||||||
_T("Reverse Rx"), // Label
|
_T("Reverse Rx"), // Label
|
||||||
wxPoint(20, 20) // Position
|
wxPoint(20, 20) // Position
|
||||||
);
|
);
|
||||||
|
|
||||||
m_cb_reverse_Ry = new wxCheckBox(
|
m_cb_reverse_Ry = new wxCheckBox(
|
||||||
m_pan_joystick_config, // Parent
|
m_pan_joystick_config, // Parent
|
||||||
wxID_ANY, // ID
|
wxID_ANY, // ID
|
||||||
_T("Reverse Ry"), // Label
|
_T("Reverse Ry"), // Label
|
||||||
wxPoint(20, 40) // Position
|
wxPoint(20, 40) // Position
|
||||||
);
|
);
|
||||||
|
|
||||||
m_cb_mouse_Rjoy = new wxCheckBox(
|
m_cb_mouse_Rjoy = new wxCheckBox(
|
||||||
m_pan_joystick_config, // Parent
|
m_pan_joystick_config, // Parent
|
||||||
wxID_ANY, // ID
|
wxID_ANY, // ID
|
||||||
_T("Use mouse for right analog joystick"), // Label
|
_T("Use mouse for right analog joystick"), // Label
|
||||||
wxPoint(20, 60) // Position
|
wxPoint(20, 60) // Position
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_bt_ok = new wxButton(
|
m_bt_ok = new wxButton(
|
||||||
m_pan_joystick_config, // Parent
|
m_pan_joystick_config, // Parent
|
||||||
wxID_ANY, // ID
|
wxID_ANY, // ID
|
||||||
_T("&OK"), // Label
|
_T("&OK"), // Label
|
||||||
wxPoint(250, 130), // Position
|
wxPoint(250, 130), // Position
|
||||||
wxSize(60,25) // Size
|
wxSize(60, 25) // Size
|
||||||
);
|
);
|
||||||
|
|
||||||
m_bt_cancel = new wxButton(
|
m_bt_cancel = new wxButton(
|
||||||
m_pan_joystick_config, // Parent
|
m_pan_joystick_config, // Parent
|
||||||
wxID_ANY, // ID
|
wxID_ANY, // ID
|
||||||
_T("&Cancel"), // Label
|
_T("&Cancel"), // Label
|
||||||
wxPoint(320, 130), // Position
|
wxPoint(320, 130), // Position
|
||||||
wxSize(60,25) // Size
|
wxSize(60, 25) // Size
|
||||||
);
|
);
|
||||||
|
|
||||||
Bind(wxEVT_BUTTON, &JoystickConfiguration::OnButtonClicked, this);
|
Bind(wxEVT_BUTTON, &JoystickConfiguration::OnButtonClicked, this);
|
||||||
Bind(wxEVT_CHECKBOX, &JoystickConfiguration::OnCheckboxChange, this);
|
Bind(wxEVT_CHECKBOX, &JoystickConfiguration::OnCheckboxChange, this);
|
||||||
|
@ -116,24 +113,20 @@ JoystickConfiguration::JoystickConfiguration(int pad, bool left, wxWindow *paren
|
||||||
*/
|
*/
|
||||||
void JoystickConfiguration::InitJoystickConfiguration()
|
void JoystickConfiguration::InitJoystickConfiguration()
|
||||||
{
|
{
|
||||||
repopulate(); // Set label and fit simulated key array
|
repopulate(); // Set label and fit simulated key array
|
||||||
/*
|
/*
|
||||||
* Check if there exist at least one pad available
|
* Check if there exist at least one pad available
|
||||||
* if the pad id is 0, you need at least 1 gamepad connected,
|
* if the pad id is 0, you need at least 1 gamepad connected,
|
||||||
* if the pad id is 1, you need at least 2 gamepad connected,
|
* if the pad id is 1, you need at least 2 gamepad connected,
|
||||||
* Prevent to use a none initialized value on s_vgamePad (core dump)
|
* Prevent to use a none initialized value on s_vgamePad (core dump)
|
||||||
*/
|
*/
|
||||||
if(s_vgamePad.size() < m_pad_id+1)
|
if (s_vgamePad.size() < m_pad_id + 1) {
|
||||||
{
|
|
||||||
wxMessageBox(L"No gamepad detected.");
|
wxMessageBox(L"No gamepad detected.");
|
||||||
// disable all checkbox
|
// disable all checkbox
|
||||||
if(m_isForLeftJoystick)
|
if (m_isForLeftJoystick) {
|
||||||
{
|
|
||||||
m_cb_reverse_Lx->Disable();
|
m_cb_reverse_Lx->Disable();
|
||||||
m_cb_reverse_Ly->Disable();
|
m_cb_reverse_Ly->Disable();
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
m_cb_reverse_Rx->Disable();
|
m_cb_reverse_Rx->Disable();
|
||||||
m_cb_reverse_Ry->Disable();
|
m_cb_reverse_Ry->Disable();
|
||||||
}
|
}
|
||||||
|
@ -150,59 +143,43 @@ void JoystickConfiguration::InitJoystickConfiguration()
|
||||||
void JoystickConfiguration::OnButtonClicked(wxCommandEvent &event)
|
void JoystickConfiguration::OnButtonClicked(wxCommandEvent &event)
|
||||||
{
|
{
|
||||||
// Affichage d'un message à chaque clic sur le bouton
|
// Affichage d'un message à chaque clic sur le bouton
|
||||||
wxButton* bt_tmp = (wxButton*)event.GetEventObject(); // get the button object
|
wxButton *bt_tmp = (wxButton *)event.GetEventObject(); // get the button object
|
||||||
int bt_id = bt_tmp->GetId(); // get the real ID
|
int bt_id = bt_tmp->GetId(); // get the real ID
|
||||||
if(bt_id == m_bt_ok->GetId()) // If the button ID is equals to the Ok button ID
|
if (bt_id == m_bt_ok->GetId()) { // If the button ID is equals to the Ok button ID
|
||||||
{
|
Close(); // Close the window
|
||||||
Close(); // Close the window
|
} else if (bt_id == m_bt_cancel->GetId()) { // If the button ID is equals to the cancel button ID
|
||||||
}
|
reset(); // reinitialize the value of each parameters
|
||||||
else if(bt_id == m_bt_cancel->GetId()) // If the button ID is equals to the cancel button ID
|
Close(); // Close the window
|
||||||
{
|
|
||||||
reset(); // reinitialize the value of each parameters
|
|
||||||
Close(); // Close the window
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checkbox event, called when the value of the checkbox change
|
* Checkbox event, called when the value of the checkbox change
|
||||||
*/
|
*/
|
||||||
void JoystickConfiguration::OnCheckboxChange(wxCommandEvent& event)
|
void JoystickConfiguration::OnCheckboxChange(wxCommandEvent &event)
|
||||||
{
|
{
|
||||||
wxCheckBox* cb_tmp = (wxCheckBox*) event.GetEventObject(); // get the slider object
|
wxCheckBox *cb_tmp = (wxCheckBox *)event.GetEventObject(); // get the slider object
|
||||||
int cb_id = cb_tmp->GetId();
|
int cb_id = cb_tmp->GetId();
|
||||||
bool val;
|
bool val;
|
||||||
if(m_isForLeftJoystick)
|
if (m_isForLeftJoystick) {
|
||||||
{
|
if (cb_id == m_cb_reverse_Ly->GetId()) {
|
||||||
if(cb_id == m_cb_reverse_Ly->GetId())
|
|
||||||
{
|
|
||||||
val = m_cb_reverse_Ly->GetValue();
|
val = m_cb_reverse_Ly->GetValue();
|
||||||
conf->pad_options[m_pad_id].reverse_ly = val;
|
conf->pad_options[m_pad_id].reverse_ly = val;
|
||||||
}
|
} else if (cb_id == m_cb_reverse_Lx->GetId()) {
|
||||||
else if(cb_id == m_cb_reverse_Lx->GetId())
|
|
||||||
{
|
|
||||||
val = m_cb_reverse_Lx->GetValue();
|
val = m_cb_reverse_Lx->GetValue();
|
||||||
conf->pad_options[m_pad_id].reverse_lx = val;
|
conf->pad_options[m_pad_id].reverse_lx = val;
|
||||||
}
|
} else if (cb_id == m_cb_mouse_Ljoy->GetId()) {
|
||||||
else if(cb_id == m_cb_mouse_Ljoy->GetId())
|
|
||||||
{
|
|
||||||
val = m_cb_mouse_Ljoy->GetValue();
|
val = m_cb_mouse_Ljoy->GetValue();
|
||||||
conf->pad_options[m_pad_id].mouse_l = val;
|
conf->pad_options[m_pad_id].mouse_l = val;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
if (cb_id == m_cb_reverse_Ry->GetId()) {
|
||||||
{
|
|
||||||
if(cb_id == m_cb_reverse_Ry->GetId())
|
|
||||||
{
|
|
||||||
val = m_cb_reverse_Ry->GetValue();
|
val = m_cb_reverse_Ry->GetValue();
|
||||||
conf->pad_options[m_pad_id].reverse_ry = val;
|
conf->pad_options[m_pad_id].reverse_ry = val;
|
||||||
}
|
} else if (cb_id == m_cb_reverse_Rx->GetId()) {
|
||||||
else if(cb_id == m_cb_reverse_Rx->GetId())
|
|
||||||
{
|
|
||||||
val = m_cb_reverse_Rx->GetValue();
|
val = m_cb_reverse_Rx->GetValue();
|
||||||
conf->pad_options[m_pad_id].reverse_rx = val;
|
conf->pad_options[m_pad_id].reverse_rx = val;
|
||||||
}
|
} else if (cb_id == m_cb_mouse_Rjoy->GetId()) {
|
||||||
else if(cb_id == m_cb_mouse_Rjoy->GetId())
|
|
||||||
{
|
|
||||||
val = m_cb_mouse_Rjoy->GetValue();
|
val = m_cb_mouse_Rjoy->GetValue();
|
||||||
conf->pad_options[m_pad_id].mouse_r = val;
|
conf->pad_options[m_pad_id].mouse_r = val;
|
||||||
}
|
}
|
||||||
|
@ -216,14 +193,11 @@ void JoystickConfiguration::OnCheckboxChange(wxCommandEvent& event)
|
||||||
// Reset checkbox and slider values
|
// Reset checkbox and slider values
|
||||||
void JoystickConfiguration::reset()
|
void JoystickConfiguration::reset()
|
||||||
{
|
{
|
||||||
if(m_isForLeftJoystick)
|
if (m_isForLeftJoystick) {
|
||||||
{
|
|
||||||
m_cb_reverse_Lx->SetValue(m_init_reverse_Lx);
|
m_cb_reverse_Lx->SetValue(m_init_reverse_Lx);
|
||||||
m_cb_reverse_Ly->SetValue(m_init_reverse_Ly);
|
m_cb_reverse_Ly->SetValue(m_init_reverse_Ly);
|
||||||
m_cb_mouse_Ljoy->SetValue(m_init_mouse_Ljoy);
|
m_cb_mouse_Ljoy->SetValue(m_init_mouse_Ljoy);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
m_cb_reverse_Rx->SetValue(m_init_reverse_Rx);
|
m_cb_reverse_Rx->SetValue(m_init_reverse_Rx);
|
||||||
m_cb_reverse_Ry->SetValue(m_init_reverse_Ry);
|
m_cb_reverse_Ry->SetValue(m_init_reverse_Ry);
|
||||||
m_cb_mouse_Rjoy->SetValue(m_init_mouse_Rjoy);
|
m_cb_mouse_Rjoy->SetValue(m_init_mouse_Rjoy);
|
||||||
|
@ -234,8 +208,7 @@ void JoystickConfiguration::reset()
|
||||||
void JoystickConfiguration::repopulate()
|
void JoystickConfiguration::repopulate()
|
||||||
{
|
{
|
||||||
bool val;
|
bool val;
|
||||||
if(m_isForLeftJoystick)
|
if (m_isForLeftJoystick) {
|
||||||
{
|
|
||||||
val = conf->pad_options[m_pad_id].reverse_lx;
|
val = conf->pad_options[m_pad_id].reverse_lx;
|
||||||
m_init_reverse_Lx = val;
|
m_init_reverse_Lx = val;
|
||||||
m_cb_reverse_Lx->SetValue(val);
|
m_cb_reverse_Lx->SetValue(val);
|
||||||
|
@ -247,9 +220,7 @@ void JoystickConfiguration::repopulate()
|
||||||
val = conf->pad_options[m_pad_id].mouse_l;
|
val = conf->pad_options[m_pad_id].mouse_l;
|
||||||
m_init_mouse_Ljoy = val;
|
m_init_mouse_Ljoy = val;
|
||||||
m_cb_mouse_Ljoy->SetValue(val);
|
m_cb_mouse_Ljoy->SetValue(val);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
val = conf->pad_options[m_pad_id].reverse_rx;
|
val = conf->pad_options[m_pad_id].reverse_rx;
|
||||||
m_init_reverse_Rx = val;
|
m_init_reverse_Rx = val;
|
||||||
m_cb_reverse_Rx->SetValue(val);
|
m_cb_reverse_Rx->SetValue(val);
|
||||||
|
|
|
@ -34,10 +34,10 @@
|
||||||
|
|
||||||
class JoystickConfiguration : public wxDialog
|
class JoystickConfiguration : public wxDialog
|
||||||
{
|
{
|
||||||
wxPanel* m_pan_joystick_config;
|
wxPanel *m_pan_joystick_config;
|
||||||
wxCheckBox *m_cb_reverse_Lx, *m_cb_reverse_Ly, *m_cb_reverse_Rx, *m_cb_reverse_Ry,
|
wxCheckBox *m_cb_reverse_Lx, *m_cb_reverse_Ly, *m_cb_reverse_Rx, *m_cb_reverse_Ry,
|
||||||
*m_cb_mouse_Ljoy, // Use mouse for left joystick
|
*m_cb_mouse_Ljoy, // Use mouse for left joystick
|
||||||
*m_cb_mouse_Rjoy; // Use mouse for right joystick
|
*m_cb_mouse_Rjoy; // Use mouse for right joystick
|
||||||
wxButton *m_bt_ok, *m_bt_cancel;
|
wxButton *m_bt_ok, *m_bt_cancel;
|
||||||
|
|
||||||
u32 m_pad_id;
|
u32 m_pad_id;
|
||||||
|
@ -49,12 +49,12 @@ class JoystickConfiguration : public wxDialog
|
||||||
void repopulate();
|
void repopulate();
|
||||||
void reset();
|
void reset();
|
||||||
// Events
|
// Events
|
||||||
void OnButtonClicked(wxCommandEvent&);
|
void OnButtonClicked(wxCommandEvent &);
|
||||||
void OnCheckboxChange(wxCommandEvent&);
|
void OnCheckboxChange(wxCommandEvent &);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
JoystickConfiguration(int, bool, wxWindow*);
|
JoystickConfiguration(int, bool, wxWindow *);
|
||||||
void InitJoystickConfiguration();
|
void InitJoystickConfiguration();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __JOYSTICKCONFIGURATION_H__
|
#endif // __JOYSTICKCONFIGURATION_H__
|
||||||
|
|
|
@ -20,17 +20,17 @@
|
||||||
#include "dialog.h"
|
#include "dialog.h"
|
||||||
|
|
||||||
// Construtor of Dialog
|
// Construtor of Dialog
|
||||||
Dialog::Dialog() : wxDialog( NULL, // Parent
|
Dialog::Dialog()
|
||||||
wxID_ANY, // ID
|
: wxDialog(NULL, // Parent
|
||||||
_T("OnePad configuration"), // Title
|
wxID_ANY, // ID
|
||||||
wxDefaultPosition, // Position
|
_T("OnePad configuration"), // Title
|
||||||
wxSize(DEFAULT_WIDTH, DEFAULT_HEIGHT), // Width + Lenght
|
wxDefaultPosition, // Position
|
||||||
// Style
|
wxSize(DEFAULT_WIDTH, DEFAULT_HEIGHT), // Width + Lenght
|
||||||
wxSYSTEM_MENU |
|
// Style
|
||||||
wxCAPTION |
|
wxSYSTEM_MENU |
|
||||||
wxCLOSE_BOX |
|
wxCAPTION |
|
||||||
wxCLIP_CHILDREN
|
wxCLOSE_BOX |
|
||||||
)
|
wxCLIP_CHILDREN)
|
||||||
{
|
{
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -43,208 +43,206 @@ Dialog::Dialog() : wxDialog( NULL, // Parent
|
||||||
int padding[BUTTONS_LENGHT][4];
|
int padding[BUTTONS_LENGHT][4];
|
||||||
|
|
||||||
// L1
|
// L1
|
||||||
padding[PAD_L1][0] = 218; // Width
|
padding[PAD_L1][0] = 218; // Width
|
||||||
padding[PAD_L1][1] = 28; // Height
|
padding[PAD_L1][1] = 28; // Height
|
||||||
padding[PAD_L1][2] = 50; // X
|
padding[PAD_L1][2] = 50; // X
|
||||||
padding[PAD_L1][3] = 175; // Y
|
padding[PAD_L1][3] = 175; // Y
|
||||||
|
|
||||||
// L2
|
// L2
|
||||||
padding[PAD_L2][0] = 218; // Width
|
padding[PAD_L2][0] = 218; // Width
|
||||||
padding[PAD_L2][1] = 28; // Height
|
padding[PAD_L2][1] = 28; // Height
|
||||||
padding[PAD_L2][2] = 50; // X
|
padding[PAD_L2][2] = 50; // X
|
||||||
padding[PAD_L2][3] = 104; // Y
|
padding[PAD_L2][3] = 104; // Y
|
||||||
|
|
||||||
// R1
|
// R1
|
||||||
padding[PAD_R1][0] = 218; // Width
|
padding[PAD_R1][0] = 218; // Width
|
||||||
padding[PAD_R1][1] = 28; // Height
|
padding[PAD_R1][1] = 28; // Height
|
||||||
padding[PAD_R1][2] = 726; // X
|
padding[PAD_R1][2] = 726; // X
|
||||||
padding[PAD_R1][3] = 175; // Y
|
padding[PAD_R1][3] = 175; // Y
|
||||||
|
|
||||||
// R2
|
// R2
|
||||||
padding[PAD_R2][0] = 218; // Width
|
padding[PAD_R2][0] = 218; // Width
|
||||||
padding[PAD_R2][1] = 28; // Height
|
padding[PAD_R2][1] = 28; // Height
|
||||||
padding[PAD_R2][2] = 726; // X
|
padding[PAD_R2][2] = 726; // X
|
||||||
padding[PAD_R2][3] = 104; // Y
|
padding[PAD_R2][3] = 104; // Y
|
||||||
|
|
||||||
// Triangle
|
// Triangle
|
||||||
padding[PAD_TRIANGLE][0] = 218; // Width
|
padding[PAD_TRIANGLE][0] = 218; // Width
|
||||||
padding[PAD_TRIANGLE][1] = 28; // Height
|
padding[PAD_TRIANGLE][1] = 28; // Height
|
||||||
padding[PAD_TRIANGLE][2] = 726; // X
|
padding[PAD_TRIANGLE][2] = 726; // X
|
||||||
padding[PAD_TRIANGLE][3] = 246; // Y
|
padding[PAD_TRIANGLE][3] = 246; // Y
|
||||||
|
|
||||||
// Circle
|
// Circle
|
||||||
padding[PAD_CIRCLE][0] = 218; // Width
|
padding[PAD_CIRCLE][0] = 218; // Width
|
||||||
padding[PAD_CIRCLE][1] = 28; // Height
|
padding[PAD_CIRCLE][1] = 28; // Height
|
||||||
padding[PAD_CIRCLE][2] = 726; // X
|
padding[PAD_CIRCLE][2] = 726; // X
|
||||||
padding[PAD_CIRCLE][3] = 319; // Y
|
padding[PAD_CIRCLE][3] = 319; // Y
|
||||||
|
|
||||||
// Cross
|
// Cross
|
||||||
padding[PAD_CROSS][0] = 218; // Width
|
padding[PAD_CROSS][0] = 218; // Width
|
||||||
padding[PAD_CROSS][1] = 28; // Height
|
padding[PAD_CROSS][1] = 28; // Height
|
||||||
padding[PAD_CROSS][2] = 726; // X
|
padding[PAD_CROSS][2] = 726; // X
|
||||||
padding[PAD_CROSS][3] = 391; // Y
|
padding[PAD_CROSS][3] = 391; // Y
|
||||||
|
|
||||||
// Square
|
// Square
|
||||||
padding[PAD_SQUARE][0] = 218; // Width
|
padding[PAD_SQUARE][0] = 218; // Width
|
||||||
padding[PAD_SQUARE][1] = 28; // Height
|
padding[PAD_SQUARE][1] = 28; // Height
|
||||||
padding[PAD_SQUARE][2] = 726; // X
|
padding[PAD_SQUARE][2] = 726; // X
|
||||||
padding[PAD_SQUARE][3] = 463; // Y
|
padding[PAD_SQUARE][3] = 463; // Y
|
||||||
|
|
||||||
// Directional pad up
|
// Directional pad up
|
||||||
padding[PAD_UP][0] = 100; // Width
|
padding[PAD_UP][0] = 100; // Width
|
||||||
padding[PAD_UP][1] = 25; // Height
|
padding[PAD_UP][1] = 25; // Height
|
||||||
padding[PAD_UP][2] = 108; // X
|
padding[PAD_UP][2] = 108; // X
|
||||||
padding[PAD_UP][3] = 290; // Y
|
padding[PAD_UP][3] = 290; // Y
|
||||||
|
|
||||||
// Directional pad down
|
// Directional pad down
|
||||||
padding[PAD_DOWN][0] = 100; // Width
|
padding[PAD_DOWN][0] = 100; // Width
|
||||||
padding[PAD_DOWN][1] = 25; // Height
|
padding[PAD_DOWN][1] = 25; // Height
|
||||||
padding[PAD_DOWN][2] = 108; // X
|
padding[PAD_DOWN][2] = 108; // X
|
||||||
padding[PAD_DOWN][3] = 340; // Y
|
padding[PAD_DOWN][3] = 340; // Y
|
||||||
|
|
||||||
// Directional pad right
|
// Directional pad right
|
||||||
padding[PAD_RIGHT][0] = 109; // Width
|
padding[PAD_RIGHT][0] = 109; // Width
|
||||||
padding[PAD_RIGHT][1] = 25; // Height
|
padding[PAD_RIGHT][1] = 25; // Height
|
||||||
padding[PAD_RIGHT][2] = 159; // X
|
padding[PAD_RIGHT][2] = 159; // X
|
||||||
padding[PAD_RIGHT][3] = 315; // Y
|
padding[PAD_RIGHT][3] = 315; // Y
|
||||||
|
|
||||||
// Directional pad left
|
// Directional pad left
|
||||||
padding[PAD_LEFT][0] = 109; // Width
|
padding[PAD_LEFT][0] = 109; // Width
|
||||||
padding[PAD_LEFT][1] = 25; // Height
|
padding[PAD_LEFT][1] = 25; // Height
|
||||||
padding[PAD_LEFT][2] = 50; // X
|
padding[PAD_LEFT][2] = 50; // X
|
||||||
padding[PAD_LEFT][3] = 315; // Y
|
padding[PAD_LEFT][3] = 315; // Y
|
||||||
|
|
||||||
// Left Joystick up
|
// Left Joystick up
|
||||||
padding[PAD_L_UP][0] = 100; // Width
|
padding[PAD_L_UP][0] = 100; // Width
|
||||||
padding[PAD_L_UP][1] = 25; // Height
|
padding[PAD_L_UP][1] = 25; // Height
|
||||||
padding[PAD_L_UP][2] = 325; // X
|
padding[PAD_L_UP][2] = 325; // X
|
||||||
padding[PAD_L_UP][3] = 527; // Y
|
padding[PAD_L_UP][3] = 527; // Y
|
||||||
|
|
||||||
// Left Joystick down
|
// Left Joystick down
|
||||||
padding[PAD_L_DOWN][0] = 100; // Width
|
padding[PAD_L_DOWN][0] = 100; // Width
|
||||||
padding[PAD_L_DOWN][1] = 25; // Height
|
padding[PAD_L_DOWN][1] = 25; // Height
|
||||||
padding[PAD_L_DOWN][2] = 325; // X
|
padding[PAD_L_DOWN][2] = 325; // X
|
||||||
padding[PAD_L_DOWN][3] = 577; // Y
|
padding[PAD_L_DOWN][3] = 577; // Y
|
||||||
|
|
||||||
// Left Joystick right
|
// Left Joystick right
|
||||||
padding[PAD_L_RIGHT][0] = 109; // Width
|
padding[PAD_L_RIGHT][0] = 109; // Width
|
||||||
padding[PAD_L_RIGHT][1] = 25; // Height
|
padding[PAD_L_RIGHT][1] = 25; // Height
|
||||||
padding[PAD_L_RIGHT][2] = 377; // X
|
padding[PAD_L_RIGHT][2] = 377; // X
|
||||||
padding[PAD_L_RIGHT][3] = 552; // Y
|
padding[PAD_L_RIGHT][3] = 552; // Y
|
||||||
|
|
||||||
// Left Joystick left
|
// Left Joystick left
|
||||||
padding[PAD_L_LEFT][0] = 109; // Width
|
padding[PAD_L_LEFT][0] = 109; // Width
|
||||||
padding[PAD_L_LEFT][1] = 25; // Height
|
padding[PAD_L_LEFT][1] = 25; // Height
|
||||||
padding[PAD_L_LEFT][2] = 268; // X
|
padding[PAD_L_LEFT][2] = 268; // X
|
||||||
padding[PAD_L_LEFT][3] = 552; // Y
|
padding[PAD_L_LEFT][3] = 552; // Y
|
||||||
|
|
||||||
// L3
|
// L3
|
||||||
padding[PAD_L3][0] = 218; // Width
|
padding[PAD_L3][0] = 218; // Width
|
||||||
padding[PAD_L3][1] = 28; // Height
|
padding[PAD_L3][1] = 28; // Height
|
||||||
padding[PAD_L3][2] = 268; // X
|
padding[PAD_L3][2] = 268; // X
|
||||||
padding[PAD_L3][3] = 641; // Y
|
padding[PAD_L3][3] = 641; // Y
|
||||||
|
|
||||||
// Right Joystick up
|
// Right Joystick up
|
||||||
padding[PAD_R_UP][0] = 100; // Width
|
padding[PAD_R_UP][0] = 100; // Width
|
||||||
padding[PAD_R_UP][1] = 25; // Height
|
padding[PAD_R_UP][1] = 25; // Height
|
||||||
padding[PAD_R_UP][2] = 555; // X
|
padding[PAD_R_UP][2] = 555; // X
|
||||||
padding[PAD_R_UP][3] = 527; // Y
|
padding[PAD_R_UP][3] = 527; // Y
|
||||||
|
|
||||||
// Right Joystick down
|
// Right Joystick down
|
||||||
padding[PAD_R_DOWN][0] = 100; // Width
|
padding[PAD_R_DOWN][0] = 100; // Width
|
||||||
padding[PAD_R_DOWN][1] = 25; // Height
|
padding[PAD_R_DOWN][1] = 25; // Height
|
||||||
padding[PAD_R_DOWN][2] = 555; // X
|
padding[PAD_R_DOWN][2] = 555; // X
|
||||||
padding[PAD_R_DOWN][3] = 577; // Y
|
padding[PAD_R_DOWN][3] = 577; // Y
|
||||||
|
|
||||||
// Right Joystick right
|
// Right Joystick right
|
||||||
padding[PAD_R_RIGHT][0] = 109; // Width
|
padding[PAD_R_RIGHT][0] = 109; // Width
|
||||||
padding[PAD_R_RIGHT][1] = 25; // Height
|
padding[PAD_R_RIGHT][1] = 25; // Height
|
||||||
padding[PAD_R_RIGHT][2] = 607; // X
|
padding[PAD_R_RIGHT][2] = 607; // X
|
||||||
padding[PAD_R_RIGHT][3] = 552; // Y
|
padding[PAD_R_RIGHT][3] = 552; // Y
|
||||||
|
|
||||||
// Right Joystick left
|
// Right Joystick left
|
||||||
padding[PAD_R_LEFT][0] = 109; // Width
|
padding[PAD_R_LEFT][0] = 109; // Width
|
||||||
padding[PAD_R_LEFT][1] = 25; // Height
|
padding[PAD_R_LEFT][1] = 25; // Height
|
||||||
padding[PAD_R_LEFT][2] = 498; // X
|
padding[PAD_R_LEFT][2] = 498; // X
|
||||||
padding[PAD_R_LEFT][3] = 552; // Y
|
padding[PAD_R_LEFT][3] = 552; // Y
|
||||||
|
|
||||||
// R3
|
// R3
|
||||||
padding[PAD_R3][0] = 218; // Width
|
padding[PAD_R3][0] = 218; // Width
|
||||||
padding[PAD_R3][1] = 28; // Height
|
padding[PAD_R3][1] = 28; // Height
|
||||||
padding[PAD_R3][2] = 498; // X
|
padding[PAD_R3][2] = 498; // X
|
||||||
padding[PAD_R3][3] = 641; // Y
|
padding[PAD_R3][3] = 641; // Y
|
||||||
|
|
||||||
// Start
|
// Start
|
||||||
padding[PAD_START][0] = 218; // Width
|
padding[PAD_START][0] = 218; // Width
|
||||||
padding[PAD_START][1] = 28; // Height
|
padding[PAD_START][1] = 28; // Height
|
||||||
padding[PAD_START][2] = 503; // X
|
padding[PAD_START][2] = 503; // X
|
||||||
padding[PAD_START][3] = 34; // Y
|
padding[PAD_START][3] = 34; // Y
|
||||||
|
|
||||||
// Select
|
// Select
|
||||||
padding[PAD_SELECT][0] = 218; // Width
|
padding[PAD_SELECT][0] = 218; // Width
|
||||||
padding[PAD_SELECT][1] = 28; // Height
|
padding[PAD_SELECT][1] = 28; // Height
|
||||||
padding[PAD_SELECT][2] = 273; // X
|
padding[PAD_SELECT][2] = 273; // X
|
||||||
padding[PAD_SELECT][3] = 34; // Y
|
padding[PAD_SELECT][3] = 34; // Y
|
||||||
|
|
||||||
// Analog
|
// Analog
|
||||||
padding[Analog][0] = 218; // Width
|
padding[Analog][0] = 218; // Width
|
||||||
padding[Analog][1] = 28; // Height
|
padding[Analog][1] = 28; // Height
|
||||||
padding[Analog][2] = 50; // X
|
padding[Analog][2] = 50; // X
|
||||||
padding[Analog][3] = 452; // Y
|
padding[Analog][3] = 452; // Y
|
||||||
|
|
||||||
// Left Joystick Configuration
|
// Left Joystick Configuration
|
||||||
padding[JoyL_config][0] = 180; // Width
|
padding[JoyL_config][0] = 180; // Width
|
||||||
padding[JoyL_config][1] = 28; // Height
|
padding[JoyL_config][1] = 28; // Height
|
||||||
padding[JoyL_config][2] = 50; // X
|
padding[JoyL_config][2] = 50; // X
|
||||||
padding[JoyL_config][3] = 550; // Y
|
padding[JoyL_config][3] = 550; // Y
|
||||||
|
|
||||||
// Right Joystick Configuration
|
// Right Joystick Configuration
|
||||||
padding[JoyR_config][0] = 180; // Width
|
padding[JoyR_config][0] = 180; // Width
|
||||||
padding[JoyR_config][1] = 28; // Height
|
padding[JoyR_config][1] = 28; // Height
|
||||||
padding[JoyR_config][2] = 764; // X
|
padding[JoyR_config][2] = 764; // X
|
||||||
padding[JoyR_config][3] = 550; // Y
|
padding[JoyR_config][3] = 550; // Y
|
||||||
|
|
||||||
// Gamepad Configuration
|
// Gamepad Configuration
|
||||||
padding[Gamepad_config][0] = 180; // Width
|
padding[Gamepad_config][0] = 180; // Width
|
||||||
padding[Gamepad_config][1] = 28; // Height
|
padding[Gamepad_config][1] = 28; // Height
|
||||||
padding[Gamepad_config][2] = 50; // X
|
padding[Gamepad_config][2] = 50; // X
|
||||||
padding[Gamepad_config][3] = 585; // Y
|
padding[Gamepad_config][3] = 585; // Y
|
||||||
|
|
||||||
// Set All Buttons
|
// Set All Buttons
|
||||||
padding[Set_all][0] = 180; // Width
|
padding[Set_all][0] = 180; // Width
|
||||||
padding[Set_all][1] = 28; // Height
|
padding[Set_all][1] = 28; // Height
|
||||||
padding[Set_all][2] = 764; // X
|
padding[Set_all][2] = 764; // X
|
||||||
padding[Set_all][3] = 585; // Y
|
padding[Set_all][3] = 585; // Y
|
||||||
|
|
||||||
// Apply modifications without exit
|
// Apply modifications without exit
|
||||||
padding[Apply][0] = 70; // Width
|
padding[Apply][0] = 70; // Width
|
||||||
padding[Apply][1] = 28; // Height
|
padding[Apply][1] = 28; // Height
|
||||||
padding[Apply][2] = 833; // X
|
padding[Apply][2] = 833; // X
|
||||||
padding[Apply][3] = 642; // Y
|
padding[Apply][3] = 642; // Y
|
||||||
|
|
||||||
// Ok button
|
// Ok button
|
||||||
padding[Ok][0] = 70; // Width
|
padding[Ok][0] = 70; // Width
|
||||||
padding[Ok][1] = 28; // Height
|
padding[Ok][1] = 28; // Height
|
||||||
padding[Ok][2] = 913; // X
|
padding[Ok][2] = 913; // X
|
||||||
padding[Ok][3] = 642; // Y
|
padding[Ok][3] = 642; // Y
|
||||||
|
|
||||||
// Cancel button
|
// Cancel button
|
||||||
padding[Cancel][0] = 70; // Width
|
padding[Cancel][0] = 70; // Width
|
||||||
padding[Cancel][1] = 28; // Height
|
padding[Cancel][1] = 28; // Height
|
||||||
padding[Cancel][2] = 753; // X
|
padding[Cancel][2] = 753; // X
|
||||||
padding[Cancel][3] = 642; // Y
|
padding[Cancel][3] = 642; // Y
|
||||||
|
|
||||||
// create a new Notebook
|
// create a new Notebook
|
||||||
m_tab_gamepad = new wxNotebook(this, wxID_ANY);
|
m_tab_gamepad = new wxNotebook(this, wxID_ANY);
|
||||||
for(int i=0; i<GAMEPAD_NUMBER; ++i)
|
for (int i = 0; i < GAMEPAD_NUMBER; ++i) {
|
||||||
{
|
|
||||||
// Tabs panels
|
// Tabs panels
|
||||||
m_pan_tabs[i] = new opPanel(
|
m_pan_tabs[i] = new opPanel(
|
||||||
m_tab_gamepad,
|
m_tab_gamepad,
|
||||||
wxID_ANY,
|
wxID_ANY,
|
||||||
wxDefaultPosition,
|
wxDefaultPosition,
|
||||||
wxSize(DEFAULT_WIDTH, DEFAULT_HEIGHT)
|
wxSize(DEFAULT_WIDTH, DEFAULT_HEIGHT));
|
||||||
);
|
|
||||||
// Add new page
|
// Add new page
|
||||||
// Define label
|
// Define label
|
||||||
std::stringstream sstm;
|
std::stringstream sstm;
|
||||||
|
@ -252,20 +250,19 @@ Dialog::Dialog() : wxDialog( NULL, // Parent
|
||||||
sstm << label << i;
|
sstm << label << i;
|
||||||
// New page creation
|
// New page creation
|
||||||
m_tab_gamepad->AddPage(
|
m_tab_gamepad->AddPage(
|
||||||
m_pan_tabs[i], // Parent
|
m_pan_tabs[i], // Parent
|
||||||
wxString(sstm.str().c_str(), wxConvUTF8) // Title
|
wxString(sstm.str().c_str(), wxConvUTF8) // Title
|
||||||
);
|
);
|
||||||
|
|
||||||
for(int j=0; j<BUTTONS_LENGHT; ++j)
|
for (int j = 0; j < BUTTONS_LENGHT; ++j) {
|
||||||
{
|
|
||||||
// Gamepad buttons
|
// Gamepad buttons
|
||||||
m_bt_gamepad[i][j] = new wxButton(
|
m_bt_gamepad[i][j] = new wxButton(
|
||||||
m_pan_tabs[i], // Parent
|
m_pan_tabs[i], // Parent
|
||||||
wxID_HIGHEST+j+1, // ID
|
wxID_HIGHEST + j + 1, // ID
|
||||||
_T("Undefined"), // Label
|
_T("Undefined"), // Label
|
||||||
wxPoint(padding[j][2], padding[j][3]), // Position
|
wxPoint(padding[j][2], padding[j][3]), // Position
|
||||||
wxSize(padding[j][0], padding[j][1]) // Size
|
wxSize(padding[j][0], padding[j][1]) // Size
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// Redefine others gui buttons label
|
// Redefine others gui buttons label
|
||||||
m_bt_gamepad[i][JoyL_config]->SetLabel(_T("&Left Joystick Config"));
|
m_bt_gamepad[i][JoyL_config]->SetLabel(_T("&Left Joystick Config"));
|
||||||
|
@ -286,10 +283,8 @@ Dialog::Dialog() : wxDialog( NULL, // Parent
|
||||||
Bind(wxEVT_TIMER, &Dialog::JoystickEvent, this);
|
Bind(wxEVT_TIMER, &Dialog::JoystickEvent, this);
|
||||||
m_time_update_gui.Start(UPDATE_TIME, wxTIMER_CONTINUOUS);
|
m_time_update_gui.Start(UPDATE_TIME, wxTIMER_CONTINUOUS);
|
||||||
|
|
||||||
for(int i=0; i<GAMEPAD_NUMBER; ++i)
|
for (int i = 0; i < GAMEPAD_NUMBER; ++i) {
|
||||||
{
|
for (int j = 0; j < NB_IMG; ++j) {
|
||||||
for(int j=0; j<NB_IMG; ++j)
|
|
||||||
{
|
|
||||||
m_pressed[i][j] = false;
|
m_pressed[i][j] = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -297,9 +292,9 @@ Dialog::Dialog() : wxDialog( NULL, // Parent
|
||||||
|
|
||||||
void Dialog::InitDialog()
|
void Dialog::InitDialog()
|
||||||
{
|
{
|
||||||
GamePad::EnumerateGamePads(s_vgamePad); // activate gamepads
|
GamePad::EnumerateGamePads(s_vgamePad); // activate gamepads
|
||||||
LoadConfig(); // Load configuration from the ini file
|
LoadConfig(); // Load configuration from the ini file
|
||||||
repopulate(); // Set label and fit simulated key array
|
repopulate(); // Set label and fit simulated key array
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************/
|
/****************************************/
|
||||||
|
@ -309,65 +304,54 @@ void Dialog::InitDialog()
|
||||||
void Dialog::OnButtonClicked(wxCommandEvent &event)
|
void Dialog::OnButtonClicked(wxCommandEvent &event)
|
||||||
{
|
{
|
||||||
// Affichage d'un message à chaque clic sur le bouton
|
// Affichage d'un message à chaque clic sur le bouton
|
||||||
wxButton* bt_tmp = (wxButton*)event.GetEventObject(); // get the button object
|
wxButton *bt_tmp = (wxButton *)event.GetEventObject(); // get the button object
|
||||||
int bt_id = bt_tmp->GetId()-wxID_HIGHEST-1; // get the real ID
|
int bt_id = bt_tmp->GetId() - wxID_HIGHEST - 1; // get the real ID
|
||||||
int gamepad_id = m_tab_gamepad->GetSelection(); // get the tab ID (equivalent to the gamepad id)
|
int gamepad_id = m_tab_gamepad->GetSelection(); // get the tab ID (equivalent to the gamepad id)
|
||||||
if(bt_id >= 0 && bt_id <= PAD_R_LEFT) // if the button ID is a gamepad button
|
if (bt_id >= 0 && bt_id <= PAD_R_LEFT) { // if the button ID is a gamepad button
|
||||||
{
|
bt_tmp->Disable(); // switch the button state to "Disable"
|
||||||
bt_tmp->Disable(); // switch the button state to "Disable"
|
|
||||||
config_key(gamepad_id, bt_id);
|
config_key(gamepad_id, bt_id);
|
||||||
bt_tmp->Enable(); // switch the button state to "Enable"
|
bt_tmp->Enable(); // switch the button state to "Enable"
|
||||||
}
|
} else if (bt_id == Gamepad_config) { // If the button ID is equals to the Gamepad_config button ID
|
||||||
else if(bt_id == Gamepad_config) // If the button ID is equals to the Gamepad_config button ID
|
|
||||||
{
|
|
||||||
GamepadConfiguration gamepad_config(gamepad_id, this);
|
GamepadConfiguration gamepad_config(gamepad_id, this);
|
||||||
|
|
||||||
gamepad_config.InitGamepadConfiguration();
|
gamepad_config.InitGamepadConfiguration();
|
||||||
gamepad_config.ShowModal();
|
gamepad_config.ShowModal();
|
||||||
}
|
} else if (bt_id == JoyL_config) { // If the button ID is equals to the JoyL_config button ID
|
||||||
else if(bt_id == JoyL_config) // If the button ID is equals to the JoyL_config button ID
|
|
||||||
{
|
|
||||||
JoystickConfiguration joystick_config(gamepad_id, true, this);
|
JoystickConfiguration joystick_config(gamepad_id, true, this);
|
||||||
|
|
||||||
joystick_config.InitJoystickConfiguration();
|
joystick_config.InitJoystickConfiguration();
|
||||||
joystick_config.ShowModal();
|
joystick_config.ShowModal();
|
||||||
}
|
} else if (bt_id == JoyR_config) { // If the button ID is equals to the JoyR_config button ID
|
||||||
else if(bt_id == JoyR_config) // If the button ID is equals to the JoyR_config button ID
|
|
||||||
{
|
|
||||||
JoystickConfiguration joystick_config(gamepad_id, false, this);
|
JoystickConfiguration joystick_config(gamepad_id, false, this);
|
||||||
|
|
||||||
joystick_config.InitJoystickConfiguration();
|
joystick_config.InitJoystickConfiguration();
|
||||||
joystick_config.ShowModal();
|
joystick_config.ShowModal();
|
||||||
}
|
} else if (bt_id == Set_all) { // If the button ID is equals to the Set_all button ID
|
||||||
else if(bt_id == Set_all) // If the button ID is equals to the Set_all button ID
|
for (int i = 0; i < MAX_KEYS; ++i) {
|
||||||
{
|
|
||||||
for(int i=0; i<MAX_KEYS; ++i)
|
|
||||||
{
|
|
||||||
bt_tmp = m_bt_gamepad[gamepad_id][i];
|
bt_tmp = m_bt_gamepad[gamepad_id][i];
|
||||||
switch(i)
|
switch (i) {
|
||||||
{
|
case PAD_L_UP: // Left joystick (Up) ↑
|
||||||
case PAD_L_UP: // Left joystick (Up) ↑
|
|
||||||
m_pan_tabs[gamepad_id]->ShowImg(img_l_arrow_up);
|
m_pan_tabs[gamepad_id]->ShowImg(img_l_arrow_up);
|
||||||
break;
|
break;
|
||||||
case PAD_L_RIGHT: // Left joystick (Right) →
|
case PAD_L_RIGHT: // Left joystick (Right) →
|
||||||
m_pan_tabs[gamepad_id]->ShowImg(img_l_arrow_right);
|
m_pan_tabs[gamepad_id]->ShowImg(img_l_arrow_right);
|
||||||
break;
|
break;
|
||||||
case PAD_L_DOWN: // Left joystick (Down) ↓
|
case PAD_L_DOWN: // Left joystick (Down) ↓
|
||||||
m_pan_tabs[gamepad_id]->ShowImg(img_l_arrow_bottom);
|
m_pan_tabs[gamepad_id]->ShowImg(img_l_arrow_bottom);
|
||||||
break;
|
break;
|
||||||
case PAD_L_LEFT: // Left joystick (Left) ←
|
case PAD_L_LEFT: // Left joystick (Left) ←
|
||||||
m_pan_tabs[gamepad_id]->ShowImg(img_l_arrow_left);
|
m_pan_tabs[gamepad_id]->ShowImg(img_l_arrow_left);
|
||||||
break;
|
break;
|
||||||
case PAD_R_UP: // Right joystick (Up) ↑
|
case PAD_R_UP: // Right joystick (Up) ↑
|
||||||
m_pan_tabs[gamepad_id]->ShowImg(img_r_arrow_up);
|
m_pan_tabs[gamepad_id]->ShowImg(img_r_arrow_up);
|
||||||
break;
|
break;
|
||||||
case PAD_R_RIGHT: // Right joystick (Right) →
|
case PAD_R_RIGHT: // Right joystick (Right) →
|
||||||
m_pan_tabs[gamepad_id]->ShowImg(img_r_arrow_right);
|
m_pan_tabs[gamepad_id]->ShowImg(img_r_arrow_right);
|
||||||
break;
|
break;
|
||||||
case PAD_R_DOWN: // Right joystick (Down) ↓
|
case PAD_R_DOWN: // Right joystick (Down) ↓
|
||||||
m_pan_tabs[gamepad_id]->ShowImg(img_r_arrow_bottom);
|
m_pan_tabs[gamepad_id]->ShowImg(img_r_arrow_bottom);
|
||||||
break;
|
break;
|
||||||
case PAD_R_LEFT: // Right joystick (Left) ←
|
case PAD_R_LEFT: // Right joystick (Left) ←
|
||||||
m_pan_tabs[gamepad_id]->ShowImg(img_r_arrow_left);
|
m_pan_tabs[gamepad_id]->ShowImg(img_r_arrow_left);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -377,30 +361,29 @@ void Dialog::OnButtonClicked(wxCommandEvent &event)
|
||||||
m_pan_tabs[gamepad_id]->Refresh();
|
m_pan_tabs[gamepad_id]->Refresh();
|
||||||
m_pan_tabs[gamepad_id]->Update();
|
m_pan_tabs[gamepad_id]->Update();
|
||||||
config_key(gamepad_id, i);
|
config_key(gamepad_id, i);
|
||||||
switch(i)
|
switch (i) {
|
||||||
{
|
case PAD_L_UP: // Left joystick (Up) ↑
|
||||||
case PAD_L_UP: // Left joystick (Up) ↑
|
|
||||||
m_pan_tabs[gamepad_id]->HideImg(img_l_arrow_up);
|
m_pan_tabs[gamepad_id]->HideImg(img_l_arrow_up);
|
||||||
break;
|
break;
|
||||||
case PAD_L_RIGHT: // Left joystick (Right) →
|
case PAD_L_RIGHT: // Left joystick (Right) →
|
||||||
m_pan_tabs[gamepad_id]->HideImg(img_l_arrow_right);
|
m_pan_tabs[gamepad_id]->HideImg(img_l_arrow_right);
|
||||||
break;
|
break;
|
||||||
case PAD_L_DOWN: // Left joystick (Down) ↓
|
case PAD_L_DOWN: // Left joystick (Down) ↓
|
||||||
m_pan_tabs[gamepad_id]->HideImg(img_l_arrow_bottom);
|
m_pan_tabs[gamepad_id]->HideImg(img_l_arrow_bottom);
|
||||||
break;
|
break;
|
||||||
case PAD_L_LEFT: // Left joystick (Left) ←
|
case PAD_L_LEFT: // Left joystick (Left) ←
|
||||||
m_pan_tabs[gamepad_id]->HideImg(img_l_arrow_left);
|
m_pan_tabs[gamepad_id]->HideImg(img_l_arrow_left);
|
||||||
break;
|
break;
|
||||||
case PAD_R_UP: // Right joystick (Up) ↑
|
case PAD_R_UP: // Right joystick (Up) ↑
|
||||||
m_pan_tabs[gamepad_id]->HideImg(img_r_arrow_up);
|
m_pan_tabs[gamepad_id]->HideImg(img_r_arrow_up);
|
||||||
break;
|
break;
|
||||||
case PAD_R_RIGHT: // Right joystick (Right) →
|
case PAD_R_RIGHT: // Right joystick (Right) →
|
||||||
m_pan_tabs[gamepad_id]->HideImg(img_r_arrow_right);
|
m_pan_tabs[gamepad_id]->HideImg(img_r_arrow_right);
|
||||||
break;
|
break;
|
||||||
case PAD_R_DOWN: // Right joystick (Down) ↓
|
case PAD_R_DOWN: // Right joystick (Down) ↓
|
||||||
m_pan_tabs[gamepad_id]->HideImg(img_r_arrow_bottom);
|
m_pan_tabs[gamepad_id]->HideImg(img_r_arrow_bottom);
|
||||||
break;
|
break;
|
||||||
case PAD_R_LEFT: // Right joystick (Left) ←
|
case PAD_R_LEFT: // Right joystick (Left) ←
|
||||||
m_pan_tabs[gamepad_id]->HideImg(img_r_arrow_left);
|
m_pan_tabs[gamepad_id]->HideImg(img_r_arrow_left);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -409,84 +392,64 @@ void Dialog::OnButtonClicked(wxCommandEvent &event)
|
||||||
}
|
}
|
||||||
m_pan_tabs[gamepad_id]->Refresh();
|
m_pan_tabs[gamepad_id]->Refresh();
|
||||||
m_pan_tabs[gamepad_id]->Update();
|
m_pan_tabs[gamepad_id]->Update();
|
||||||
usleep(500000); // give enough time to the user to release the button
|
usleep(500000); // give enough time to the user to release the button
|
||||||
}
|
}
|
||||||
}
|
} else if (bt_id == Ok) { // If the button ID is equals to the Ok button ID
|
||||||
else if(bt_id == Ok) // If the button ID is equals to the Ok button ID
|
SaveConfig(); // Save the configuration
|
||||||
{
|
Close(); // Close the window
|
||||||
SaveConfig(); // Save the configuration
|
} else if (bt_id == Apply) { // If the button ID is equals to the Apply button ID
|
||||||
Close(); // Close the window
|
SaveConfig(); // Save the configuration
|
||||||
}
|
} else if (bt_id == Cancel) { // If the button ID is equals to the cancel button ID
|
||||||
else if(bt_id == Apply) // If the button ID is equals to the Apply button ID
|
Close(); // Close the window
|
||||||
{
|
|
||||||
SaveConfig(); // Save the configuration
|
|
||||||
}
|
|
||||||
else if(bt_id == Cancel) // If the button ID is equals to the cancel button ID
|
|
||||||
{
|
|
||||||
Close(); // Close the window
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dialog::JoystickEvent(wxTimerEvent& event)
|
void Dialog::JoystickEvent(wxTimerEvent &event)
|
||||||
{
|
{
|
||||||
#ifdef SDL_BUILD
|
#ifdef SDL_BUILD
|
||||||
u32 key;
|
u32 key;
|
||||||
int map;
|
int map;
|
||||||
std::map<u32,int>::iterator it;
|
std::map<u32, int>::iterator it;
|
||||||
std::map<u32,int>::iterator it2;
|
std::map<u32, int>::iterator it2;
|
||||||
SDL_JoystickEventState(SDL_ENABLE);
|
SDL_JoystickEventState(SDL_ENABLE);
|
||||||
SDL_Event events;
|
SDL_Event events;
|
||||||
while(SDL_PollEvent(&events))
|
while (SDL_PollEvent(&events)) {
|
||||||
{
|
switch (events.type) {
|
||||||
switch(events.type)
|
|
||||||
{
|
|
||||||
case SDL_KEYDOWN:
|
case SDL_KEYDOWN:
|
||||||
case SDL_KEYUP:
|
case SDL_KEYUP:
|
||||||
break;
|
break;
|
||||||
case SDL_JOYAXISMOTION:
|
case SDL_JOYAXISMOTION:
|
||||||
if(events.jaxis.which < GAMEPAD_NUMBER)
|
if (events.jaxis.which < GAMEPAD_NUMBER) {
|
||||||
{
|
key = axis_to_key(false, (events.jaxis.value < 0), events.jaxis.axis);
|
||||||
key = axis_to_key(false, (events.jaxis.value<0), events.jaxis.axis);
|
it = m_map_images[events.jaxis.which].find(key);
|
||||||
it=m_map_images[events.jaxis.which].find(key);
|
if (it != m_map_images[events.jaxis.which].end()) {
|
||||||
if(it != m_map_images[events.jaxis.which].end())
|
|
||||||
{
|
|
||||||
map = m_map_images[events.jaxis.which][key];
|
map = m_map_images[events.jaxis.which][key];
|
||||||
if(events.jaxis.value == 0)
|
if (events.jaxis.value == 0) {
|
||||||
{
|
if (map >= PAD_L_UP && map <= PAD_L_LEFT)
|
||||||
if(map >= PAD_L_UP && map <= PAD_L_LEFT)
|
|
||||||
m_pan_tabs[events.jaxis.which]->HideImg(img_left_cursor);
|
m_pan_tabs[events.jaxis.which]->HideImg(img_left_cursor);
|
||||||
else if(map >= PAD_R_UP && map <= PAD_R_LEFT)
|
else if (map >= PAD_R_UP && map <= PAD_R_LEFT)
|
||||||
m_pan_tabs[events.jaxis.which]->HideImg(img_right_cursor);
|
m_pan_tabs[events.jaxis.which]->HideImg(img_right_cursor);
|
||||||
else if(map < PAD_L_UP)
|
else if (map < PAD_L_UP)
|
||||||
m_pan_tabs[events.jaxis.which]->HideImg(map);
|
m_pan_tabs[events.jaxis.which]->HideImg(map);
|
||||||
}
|
} else {
|
||||||
else
|
if (map >= PAD_L_UP && map <= PAD_L_LEFT) {
|
||||||
{
|
|
||||||
if(map >= PAD_L_UP && map <= PAD_L_LEFT)
|
|
||||||
{
|
|
||||||
m_pan_tabs[events.jaxis.which]->MoveJoystick(events.jaxis.axis, events.jaxis.value);
|
m_pan_tabs[events.jaxis.which]->MoveJoystick(events.jaxis.axis, events.jaxis.value);
|
||||||
m_pan_tabs[events.jaxis.which]->ShowImg(img_left_cursor);
|
m_pan_tabs[events.jaxis.which]->ShowImg(img_left_cursor);
|
||||||
}
|
} else if (map >= PAD_R_UP && map <= PAD_R_LEFT) {
|
||||||
else if(map >= PAD_R_UP && map <= PAD_R_LEFT)
|
|
||||||
{
|
|
||||||
m_pan_tabs[events.jaxis.which]->MoveJoystick(events.jaxis.axis, events.jaxis.value);
|
m_pan_tabs[events.jaxis.which]->MoveJoystick(events.jaxis.axis, events.jaxis.value);
|
||||||
m_pan_tabs[events.jaxis.which]->ShowImg(img_right_cursor);
|
m_pan_tabs[events.jaxis.which]->ShowImg(img_right_cursor);
|
||||||
}
|
} else if (map < PAD_L_UP) { // if this is not a joystick
|
||||||
else if(map < PAD_L_UP) // if this is not a joystick
|
|
||||||
{
|
|
||||||
m_pan_tabs[events.jaxis.which]->ShowImg(map);
|
m_pan_tabs[events.jaxis.which]->ShowImg(map);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Hack Dualshock 4 (L2, R2)
|
// Hack Dualshock 4 (L2, R2)
|
||||||
key = axis_to_key(false, (events.jaxis.value>0), events.jaxis.axis);
|
key = axis_to_key(false, (events.jaxis.value > 0), events.jaxis.axis);
|
||||||
it2=m_map_images[events.jaxis.which].find(key);
|
it2 = m_map_images[events.jaxis.which].find(key);
|
||||||
if(it2 != m_map_images[events.jaxis.which].end())
|
if (it2 != m_map_images[events.jaxis.which].end()) {
|
||||||
{
|
|
||||||
map = m_map_images[events.jaxis.which][key];
|
map = m_map_images[events.jaxis.which][key];
|
||||||
if(map < PAD_L_UP) // if this is not a joystick
|
if (map < PAD_L_UP) { // if this is not a joystick
|
||||||
{
|
|
||||||
m_pan_tabs[events.jaxis.which]->HideImg(map);
|
m_pan_tabs[events.jaxis.which]->HideImg(map);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -494,63 +457,53 @@ void Dialog::JoystickEvent(wxTimerEvent& event)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SDL_JOYBUTTONDOWN:
|
case SDL_JOYBUTTONDOWN:
|
||||||
if(events.jbutton.which < GAMEPAD_NUMBER)
|
if (events.jbutton.which < GAMEPAD_NUMBER) {
|
||||||
{
|
|
||||||
key = button_to_key(events.jbutton.button);
|
key = button_to_key(events.jbutton.button);
|
||||||
it=m_map_images[events.jbutton.which].find(key);
|
it = m_map_images[events.jbutton.which].find(key);
|
||||||
if(it != m_map_images[events.jbutton.which].end())
|
if (it != m_map_images[events.jbutton.which].end()) {
|
||||||
{
|
|
||||||
map = m_map_images[events.jbutton.which][key];
|
map = m_map_images[events.jbutton.which][key];
|
||||||
m_pan_tabs[events.jbutton.which]->ShowImg(map);
|
m_pan_tabs[events.jbutton.which]->ShowImg(map);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SDL_JOYBUTTONUP:
|
case SDL_JOYBUTTONUP:
|
||||||
if(events.jbutton.which < GAMEPAD_NUMBER)
|
if (events.jbutton.which < GAMEPAD_NUMBER) {
|
||||||
{
|
|
||||||
key = button_to_key(events.jbutton.button);
|
key = button_to_key(events.jbutton.button);
|
||||||
it=m_map_images[events.jbutton.which].find(key);
|
it = m_map_images[events.jbutton.which].find(key);
|
||||||
if(it != m_map_images[events.jbutton.which].end())
|
if (it != m_map_images[events.jbutton.which].end()) {
|
||||||
{
|
|
||||||
map = m_map_images[events.jbutton.which][key];
|
map = m_map_images[events.jbutton.which][key];
|
||||||
m_pan_tabs[events.jbutton.which]->HideImg(map);
|
m_pan_tabs[events.jbutton.which]->HideImg(map);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SDL_JOYHATMOTION:
|
case SDL_JOYHATMOTION:
|
||||||
if(events.jhat.which < GAMEPAD_NUMBER)
|
if (events.jhat.which < GAMEPAD_NUMBER) {
|
||||||
{
|
switch (events.jhat.value) {
|
||||||
switch(events.jhat.value)
|
|
||||||
{
|
|
||||||
case SDL_HAT_UP:
|
case SDL_HAT_UP:
|
||||||
key = hat_to_key(events.jhat.value, events.jhat.hat);
|
key = hat_to_key(events.jhat.value, events.jhat.hat);
|
||||||
it=m_map_images[events.jhat.which].find(key);
|
it = m_map_images[events.jhat.which].find(key);
|
||||||
if(it != m_map_images[events.jhat.which].end())
|
if (it != m_map_images[events.jhat.which].end()) {
|
||||||
{
|
|
||||||
m_pan_tabs[events.jhat.which]->ShowImg(img_dp_up);
|
m_pan_tabs[events.jhat.which]->ShowImg(img_dp_up);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SDL_HAT_DOWN:
|
case SDL_HAT_DOWN:
|
||||||
key = hat_to_key(events.jhat.value, events.jhat.hat);
|
key = hat_to_key(events.jhat.value, events.jhat.hat);
|
||||||
it=m_map_images[events.jhat.which].find(key);
|
it = m_map_images[events.jhat.which].find(key);
|
||||||
if(it != m_map_images[events.jhat.which].end())
|
if (it != m_map_images[events.jhat.which].end()) {
|
||||||
{
|
|
||||||
m_pan_tabs[events.jhat.which]->ShowImg(img_dp_bottom);
|
m_pan_tabs[events.jhat.which]->ShowImg(img_dp_bottom);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SDL_HAT_RIGHT:
|
case SDL_HAT_RIGHT:
|
||||||
key = hat_to_key(events.jhat.value, events.jhat.hat);
|
key = hat_to_key(events.jhat.value, events.jhat.hat);
|
||||||
it=m_map_images[events.jhat.which].find(key);
|
it = m_map_images[events.jhat.which].find(key);
|
||||||
if(it != m_map_images[events.jhat.which].end())
|
if (it != m_map_images[events.jhat.which].end()) {
|
||||||
{
|
|
||||||
m_pan_tabs[events.jhat.which]->ShowImg(img_dp_right);
|
m_pan_tabs[events.jhat.which]->ShowImg(img_dp_right);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SDL_HAT_LEFT:
|
case SDL_HAT_LEFT:
|
||||||
key = hat_to_key(events.jhat.value, events.jhat.hat);
|
key = hat_to_key(events.jhat.value, events.jhat.hat);
|
||||||
it=m_map_images[events.jhat.which].find(key);
|
it = m_map_images[events.jhat.which].find(key);
|
||||||
if(it != m_map_images[events.jhat.which].end())
|
if (it != m_map_images[events.jhat.which].end()) {
|
||||||
{
|
|
||||||
m_pan_tabs[events.jhat.which]->ShowImg(img_dp_left);
|
m_pan_tabs[events.jhat.which]->ShowImg(img_dp_left);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -566,7 +519,7 @@ void Dialog::JoystickEvent(wxTimerEvent& event)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // SDL_BUILD
|
#endif // SDL_BUILD
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************/
|
/****************************************/
|
||||||
|
@ -575,62 +528,50 @@ void Dialog::JoystickEvent(wxTimerEvent& event)
|
||||||
|
|
||||||
void Dialog::config_key(int pad, int key)
|
void Dialog::config_key(int pad, int key)
|
||||||
{
|
{
|
||||||
bool captured = false;
|
bool captured = false;
|
||||||
u32 key_pressed = 0;
|
u32 key_pressed = 0;
|
||||||
|
|
||||||
// I don't have any guarantee that not-yet-pressed state is egual to released state
|
// I don't have any guarantee that not-yet-pressed state is egual to released state
|
||||||
GamePad::UpdateReleaseState();
|
GamePad::UpdateReleaseState();
|
||||||
while (!captured)
|
while (!captured) {
|
||||||
{
|
vector<GamePad *>::iterator itjoy;
|
||||||
vector<GamePad*>::iterator itjoy;
|
if (PollX11KeyboardMouseEvent(key_pressed)) {
|
||||||
if (PollX11KeyboardMouseEvent(key_pressed))
|
// special case for keyboard/mouse to handle multiple keys
|
||||||
{
|
// Note: key_pressed == 0 when ESC is hit to abort the capture
|
||||||
// special case for keyboard/mouse to handle multiple keys
|
if (key_pressed > 0) {
|
||||||
// Note: key_pressed == 0 when ESC is hit to abort the capture
|
|
||||||
if (key_pressed > 0)
|
|
||||||
{
|
|
||||||
clear_key(pad, key);
|
clear_key(pad, key);
|
||||||
set_keyboad_key(pad, key_pressed, key);
|
set_keyboad_key(pad, key_pressed, key);
|
||||||
m_simulatedKeys[pad][key] = key_pressed;
|
m_simulatedKeys[pad][key] = key_pressed;
|
||||||
m_map_images[pad][key_pressed] = key;
|
m_map_images[pad][key_pressed] = key;
|
||||||
}
|
}
|
||||||
captured = true;
|
captured = true;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
GamePad::UpdateGamePadState();
|
GamePad::UpdateGamePadState();
|
||||||
|
|
||||||
itjoy = s_vgamePad.begin();
|
itjoy = s_vgamePad.begin();
|
||||||
while ((itjoy != s_vgamePad.end()) && (!captured))
|
while ((itjoy != s_vgamePad.end()) && (!captured)) {
|
||||||
{
|
if ((*itjoy)->PollButtons(key_pressed)) {
|
||||||
if ((*itjoy)->PollButtons(key_pressed))
|
|
||||||
{
|
|
||||||
clear_key(pad, key);
|
clear_key(pad, key);
|
||||||
set_key(pad, key, key_pressed);
|
set_key(pad, key, key_pressed);
|
||||||
m_map_images[pad][key_pressed] = key;
|
m_map_images[pad][key_pressed] = key;
|
||||||
captured = true;
|
captured = true;
|
||||||
}
|
} else if ((*itjoy)->PollAxes(key_pressed)) {
|
||||||
else if((*itjoy)->PollAxes(key_pressed))
|
|
||||||
{
|
|
||||||
clear_key(pad, key);
|
clear_key(pad, key);
|
||||||
set_key(pad, key, key_pressed);
|
set_key(pad, key, key_pressed);
|
||||||
m_map_images[pad][key_pressed] = key;
|
m_map_images[pad][key_pressed] = key;
|
||||||
captured = true;
|
captured = true;
|
||||||
}
|
} else if ((*itjoy)->PollHats(key_pressed)) {
|
||||||
else if((*itjoy)->PollHats(key_pressed))
|
|
||||||
{
|
|
||||||
clear_key(pad, key);
|
clear_key(pad, key);
|
||||||
set_key(pad, key, key_pressed);
|
set_key(pad, key, key_pressed);
|
||||||
m_map_images[pad][key_pressed] = key;
|
m_map_images[pad][key_pressed] = key;
|
||||||
captured = true;
|
captured = true;
|
||||||
}
|
}
|
||||||
++itjoy;
|
++itjoy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_bt_gamepad[pad][key]->SetLabel(
|
m_bt_gamepad[pad][key]->SetLabel(
|
||||||
KeyName(pad, key, m_simulatedKeys[pad][key]).c_str()
|
KeyName(pad, key, m_simulatedKeys[pad][key]).c_str());
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dialog::clear_key(int pad, int key)
|
void Dialog::clear_key(int pad, int key)
|
||||||
|
@ -640,17 +581,16 @@ void Dialog::clear_key(int pad, int key)
|
||||||
m_simulatedKeys[pad][key] = 0;
|
m_simulatedKeys[pad][key] = 0;
|
||||||
|
|
||||||
// erase gamepad entry (keysim map)
|
// erase gamepad entry (keysim map)
|
||||||
std::map<u32,u32>::iterator it1;
|
std::map<u32, u32>::iterator it1;
|
||||||
it1=conf->keysym_map[pad].find(keysim);
|
it1 = conf->keysym_map[pad].find(keysim);
|
||||||
if(it1 != conf->keysym_map[pad].end())
|
if (it1 != conf->keysym_map[pad].end())
|
||||||
conf->keysym_map[pad].erase(it1);
|
conf->keysym_map[pad].erase(it1);
|
||||||
|
|
||||||
// erase gamepad entry (image map)
|
// erase gamepad entry (image map)
|
||||||
int val = get_key(pad, key);
|
int val = get_key(pad, key);
|
||||||
std::map<u32,int>::iterator it2;
|
std::map<u32, int>::iterator it2;
|
||||||
it2=m_map_images[pad].find(val);
|
it2 = m_map_images[pad].find(val);
|
||||||
if(it2 != m_map_images[pad].end())
|
if (it2 != m_map_images[pad].end()) {
|
||||||
{
|
|
||||||
m_map_images[pad].erase(it2);
|
m_map_images[pad].erase(it2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -664,31 +604,25 @@ void Dialog::clear_key(int pad, int key)
|
||||||
// Set button values
|
// Set button values
|
||||||
void Dialog::repopulate()
|
void Dialog::repopulate()
|
||||||
{
|
{
|
||||||
for(int gamepad_id=0; gamepad_id<GAMEPAD_NUMBER; ++gamepad_id)
|
for (int gamepad_id = 0; gamepad_id < GAMEPAD_NUMBER; ++gamepad_id) {
|
||||||
{
|
for (int key = 0; key < MAX_KEYS; key++) {
|
||||||
for (int key = 0; key < MAX_KEYS; key++)
|
if (get_key(gamepad_id, key) != 0) {
|
||||||
{
|
|
||||||
if (get_key(gamepad_id, key) != 0)
|
|
||||||
{
|
|
||||||
m_bt_gamepad[gamepad_id][key]->SetLabel(
|
m_bt_gamepad[gamepad_id][key]->SetLabel(
|
||||||
KeyName(gamepad_id, key).c_str()
|
KeyName(gamepad_id, key).c_str());
|
||||||
);
|
|
||||||
|
|
||||||
m_map_images[gamepad_id][get_key(gamepad_id, key)] = key;
|
m_map_images[gamepad_id][get_key(gamepad_id, key)] = key;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// keyboard/mouse key
|
// keyboard/mouse key
|
||||||
map<u32,u32>::iterator it;
|
map<u32, u32>::iterator it;
|
||||||
for (it = conf->keysym_map[gamepad_id].begin();
|
for (it = conf->keysym_map[gamepad_id].begin();
|
||||||
it != conf->keysym_map[gamepad_id].end(); ++it)
|
it != conf->keysym_map[gamepad_id].end(); ++it) {
|
||||||
{
|
|
||||||
int keysym = it->first;
|
int keysym = it->first;
|
||||||
int key = it->second;
|
int key = it->second;
|
||||||
|
|
||||||
m_bt_gamepad[gamepad_id][key]->SetLabel(
|
m_bt_gamepad[gamepad_id][key]->SetLabel(
|
||||||
KeyName(gamepad_id, key, keysym).c_str()
|
KeyName(gamepad_id, key, keysym).c_str());
|
||||||
);
|
|
||||||
|
|
||||||
m_simulatedKeys[gamepad_id][key] = keysym;
|
m_simulatedKeys[gamepad_id][key] = keysym;
|
||||||
m_map_images[gamepad_id][keysym] = key;
|
m_map_images[gamepad_id][keysym] = key;
|
||||||
|
|
|
@ -48,17 +48,17 @@
|
||||||
// see onepad.h for more details about gamepad button id
|
// see onepad.h for more details about gamepad button id
|
||||||
|
|
||||||
enum gui_buttons {
|
enum gui_buttons {
|
||||||
Analog = PAD_R_LEFT+1, // Analog button (not yet supported ?)
|
Analog = PAD_R_LEFT + 1, // Analog button (not yet supported ?)
|
||||||
JoyL_config, // Left Joystick Configuration
|
JoyL_config, // Left Joystick Configuration
|
||||||
JoyR_config, // Right Joystick Configuration
|
JoyR_config, // Right Joystick Configuration
|
||||||
Gamepad_config, // Gamepad Configuration
|
Gamepad_config, // Gamepad Configuration
|
||||||
Set_all, // Set all buttons
|
Set_all, // Set all buttons
|
||||||
Apply, // Apply modifications without exit
|
Apply, // Apply modifications without exit
|
||||||
Ok, // Apply modifications and exit
|
Ok, // Apply modifications and exit
|
||||||
Cancel // Exit without apply modificatons
|
Cancel // Exit without apply modificatons
|
||||||
};
|
};
|
||||||
|
|
||||||
#define BUTTONS_LENGHT 32 // numbers of buttons on the gamepad
|
#define BUTTONS_LENGHT 32 // numbers of buttons on the gamepad
|
||||||
#define UPDATE_TIME 5
|
#define UPDATE_TIME 5
|
||||||
#define DEFAULT_WIDTH 1000
|
#define DEFAULT_WIDTH 1000
|
||||||
#define DEFAULT_HEIGHT 740
|
#define DEFAULT_HEIGHT 740
|
||||||
|
@ -66,11 +66,11 @@ enum gui_buttons {
|
||||||
class Dialog : public wxDialog
|
class Dialog : public wxDialog
|
||||||
{
|
{
|
||||||
// Panels
|
// Panels
|
||||||
opPanel* m_pan_tabs[GAMEPAD_NUMBER]; // Gamepad Tabs box
|
opPanel *m_pan_tabs[GAMEPAD_NUMBER]; // Gamepad Tabs box
|
||||||
// Notebooks
|
// Notebooks
|
||||||
wxNotebook* m_tab_gamepad; // Joysticks Tabs
|
wxNotebook *m_tab_gamepad; // Joysticks Tabs
|
||||||
// Buttons
|
// Buttons
|
||||||
wxButton* m_bt_gamepad[GAMEPAD_NUMBER][BUTTONS_LENGHT]; // Joystick button use to modify the button mapping
|
wxButton *m_bt_gamepad[GAMEPAD_NUMBER][BUTTONS_LENGHT]; // Joystick button use to modify the button mapping
|
||||||
// Contain all simulated key
|
// Contain all simulated key
|
||||||
u32 m_simulatedKeys[GAMEPAD_NUMBER][MAX_KEYS];
|
u32 m_simulatedKeys[GAMEPAD_NUMBER][MAX_KEYS];
|
||||||
// Timer
|
// Timer
|
||||||
|
@ -78,7 +78,7 @@ class Dialog : public wxDialog
|
||||||
// Check if the gui must display feddback image
|
// Check if the gui must display feddback image
|
||||||
bool m_pressed[GAMEPAD_NUMBER][NB_IMG];
|
bool m_pressed[GAMEPAD_NUMBER][NB_IMG];
|
||||||
// Map the key pressed with the feedback image id
|
// Map the key pressed with the feedback image id
|
||||||
std::map<u32,int> m_map_images[GAMEPAD_NUMBER];
|
std::map<u32, int> m_map_images[GAMEPAD_NUMBER];
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
void config_key(int, int);
|
void config_key(int, int);
|
||||||
|
@ -86,8 +86,8 @@ class Dialog : public wxDialog
|
||||||
void repopulate();
|
void repopulate();
|
||||||
|
|
||||||
// Events
|
// Events
|
||||||
void OnButtonClicked(wxCommandEvent&);
|
void OnButtonClicked(wxCommandEvent &);
|
||||||
void JoystickEvent(wxTimerEvent&);
|
void JoystickEvent(wxTimerEvent &);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Dialog();
|
Dialog();
|
||||||
|
@ -95,6 +95,6 @@ public:
|
||||||
void show();
|
void show();
|
||||||
};
|
};
|
||||||
|
|
||||||
extern void DisplayDialog(); // Main function
|
extern void DisplayDialog(); // Main function
|
||||||
|
|
||||||
#endif // __DIALOG_H__
|
#endif // __DIALOG_H__
|
||||||
|
|
|
@ -30,181 +30,186 @@ extern std::string s_strIniPath;
|
||||||
|
|
||||||
string KeyName(int pad, int key, int keysym)
|
string KeyName(int pad, int key, int keysym)
|
||||||
{
|
{
|
||||||
string tmp;
|
string tmp;
|
||||||
tmp.resize(28);
|
tmp.resize(28);
|
||||||
|
|
||||||
if (keysym) {
|
if (keysym) {
|
||||||
if (keysym < 10) {
|
if (keysym < 10) {
|
||||||
// mouse
|
// mouse
|
||||||
switch (keysym) {
|
switch (keysym) {
|
||||||
case 1: sprintf(&tmp[0], "Mouse Left"); break;
|
case 1:
|
||||||
case 2: sprintf(&tmp[0], "Mouse Middle"); break;
|
sprintf(&tmp[0], "Mouse Left");
|
||||||
case 3: sprintf(&tmp[0], "Mouse Right"); break;
|
break;
|
||||||
default: // Use only number for extra button
|
case 2:
|
||||||
sprintf(&tmp[0], "Mouse %d", keysym);
|
sprintf(&tmp[0], "Mouse Middle");
|
||||||
}
|
break;
|
||||||
} else {
|
case 3:
|
||||||
// keyboard
|
sprintf(&tmp[0], "Mouse Right");
|
||||||
char* pstr = XKeysymToString(keysym);
|
break;
|
||||||
if (pstr != NULL) tmp = pstr;
|
default: // Use only number for extra button
|
||||||
}
|
sprintf(&tmp[0], "Mouse %d", keysym);
|
||||||
} else {
|
}
|
||||||
// joystick
|
} else {
|
||||||
KeyType k = type_of_joykey(pad, key);
|
// keyboard
|
||||||
switch (k)
|
char *pstr = XKeysymToString(keysym);
|
||||||
{
|
if (pstr != NULL)
|
||||||
case PAD_JOYBUTTONS:
|
tmp = pstr;
|
||||||
{
|
}
|
||||||
int button = key_to_button(pad, key);
|
} else {
|
||||||
sprintf(&tmp[0], "JBut %d", button);
|
// joystick
|
||||||
break;
|
KeyType k = type_of_joykey(pad, key);
|
||||||
}
|
switch (k) {
|
||||||
case PAD_AXIS:
|
case PAD_JOYBUTTONS: {
|
||||||
{
|
int button = key_to_button(pad, key);
|
||||||
if (key_to_axis_type(pad,key))
|
sprintf(&tmp[0], "JBut %d", button);
|
||||||
sprintf(&tmp[0], "JAxis %d Full", key_to_axis(pad, key));
|
break;
|
||||||
else
|
}
|
||||||
sprintf(&tmp[0], "JAxis %d Half%s", key_to_axis(pad, key), key_to_axis_sign(pad, key) ? "-" : "+");
|
case PAD_AXIS: {
|
||||||
break;
|
if (key_to_axis_type(pad, key))
|
||||||
}
|
sprintf(&tmp[0], "JAxis %d Full", key_to_axis(pad, key));
|
||||||
case PAD_HAT:
|
else
|
||||||
{
|
sprintf(&tmp[0], "JAxis %d Half%s", key_to_axis(pad, key), key_to_axis_sign(pad, key) ? "-" : "+");
|
||||||
int axis = key_to_axis(pad, key);
|
break;
|
||||||
switch(key_to_hat_dir(pad, key))
|
}
|
||||||
{
|
case PAD_HAT: {
|
||||||
case HAT_UP:
|
int axis = key_to_axis(pad, key);
|
||||||
sprintf(&tmp[0], "JPOVU-%d", axis);
|
switch (key_to_hat_dir(pad, key)) {
|
||||||
break;
|
case HAT_UP:
|
||||||
|
sprintf(&tmp[0], "JPOVU-%d", axis);
|
||||||
|
break;
|
||||||
|
|
||||||
case HAT_RIGHT:
|
case HAT_RIGHT:
|
||||||
sprintf(&tmp[0], "JPOVR-%d", axis);
|
sprintf(&tmp[0], "JPOVR-%d", axis);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HAT_DOWN:
|
case HAT_DOWN:
|
||||||
sprintf(&tmp[0], "JPOVD-%d", axis);
|
sprintf(&tmp[0], "JPOVD-%d", axis);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HAT_LEFT:
|
case HAT_LEFT:
|
||||||
sprintf(&tmp[0], "JPOVL-%d", axis);
|
sprintf(&tmp[0], "JPOVL-%d", axis);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: break;
|
default:
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DefaultKeyboardValues()
|
void DefaultKeyboardValues()
|
||||||
{
|
{
|
||||||
set_keyboad_key(0, XK_a, PAD_L2);
|
set_keyboad_key(0, XK_a, PAD_L2);
|
||||||
set_keyboad_key(0, XK_semicolon, PAD_R2);
|
set_keyboad_key(0, XK_semicolon, PAD_R2);
|
||||||
set_keyboad_key(0, XK_w, PAD_L1);
|
set_keyboad_key(0, XK_w, PAD_L1);
|
||||||
set_keyboad_key(0, XK_p, PAD_R1);
|
set_keyboad_key(0, XK_p, PAD_R1);
|
||||||
set_keyboad_key(0, XK_i, PAD_TRIANGLE);
|
set_keyboad_key(0, XK_i, PAD_TRIANGLE);
|
||||||
set_keyboad_key(0, XK_l, PAD_CIRCLE);
|
set_keyboad_key(0, XK_l, PAD_CIRCLE);
|
||||||
set_keyboad_key(0, XK_k, PAD_CROSS);
|
set_keyboad_key(0, XK_k, PAD_CROSS);
|
||||||
set_keyboad_key(0, XK_j, PAD_SQUARE);
|
set_keyboad_key(0, XK_j, PAD_SQUARE);
|
||||||
set_keyboad_key(0, XK_v, PAD_SELECT);
|
set_keyboad_key(0, XK_v, PAD_SELECT);
|
||||||
set_keyboad_key(0, XK_n, PAD_START);
|
set_keyboad_key(0, XK_n, PAD_START);
|
||||||
set_keyboad_key(0, XK_e, PAD_UP);
|
set_keyboad_key(0, XK_e, PAD_UP);
|
||||||
set_keyboad_key(0, XK_f, PAD_RIGHT);
|
set_keyboad_key(0, XK_f, PAD_RIGHT);
|
||||||
set_keyboad_key(0, XK_d, PAD_DOWN);
|
set_keyboad_key(0, XK_d, PAD_DOWN);
|
||||||
set_keyboad_key(0, XK_s, PAD_LEFT);
|
set_keyboad_key(0, XK_s, PAD_LEFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SaveConfig()
|
void SaveConfig()
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
|
||||||
const std::string iniFile(s_strIniPath + "OnePAD.ini");
|
const std::string iniFile(s_strIniPath + "OnePAD.ini");
|
||||||
f = fopen(iniFile.c_str(), "w");
|
f = fopen(iniFile.c_str(), "w");
|
||||||
if (f == NULL)
|
if (f == NULL) {
|
||||||
{
|
printf("OnePAD: failed to save ini %s\n", iniFile.c_str());
|
||||||
printf("OnePAD: failed to save ini %s\n", iniFile.c_str());
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fprintf(f, "log = %d\n", conf->log);
|
fprintf(f, "log = %d\n", conf->log);
|
||||||
fprintf(f, "options = %d\n", conf->packed_options);
|
fprintf(f, "options = %d\n", conf->packed_options);
|
||||||
fprintf(f, "mouse_sensibility = %d\n", conf->get_sensibility());
|
fprintf(f, "mouse_sensibility = %d\n", conf->get_sensibility());
|
||||||
fprintf(f, "joy_pad_map = %d\n", conf->joyid_map);
|
fprintf(f, "joy_pad_map = %d\n", conf->joyid_map);
|
||||||
fprintf(f, "ff_intensity = %d\n", conf->get_ff_intensity());
|
fprintf(f, "ff_intensity = %d\n", conf->get_ff_intensity());
|
||||||
|
|
||||||
for (int pad = 0; pad < GAMEPAD_NUMBER; pad++)
|
for (int pad = 0; pad < GAMEPAD_NUMBER; pad++) {
|
||||||
{
|
for (int key = 0; key < MAX_KEYS; key++) {
|
||||||
for (int key = 0; key < MAX_KEYS; key++)
|
fprintf(f, "[%d][%d] = 0x%x\n", pad, key, get_key(pad, key));
|
||||||
{
|
}
|
||||||
fprintf(f, "[%d][%d] = 0x%x\n", pad, key, get_key(pad,key));
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
map<u32,u32>::iterator it;
|
map<u32, u32>::iterator it;
|
||||||
for (int pad = 0; pad < GAMEPAD_NUMBER ; pad++)
|
for (int pad = 0; pad < GAMEPAD_NUMBER; pad++)
|
||||||
for (it = conf->keysym_map[pad].begin(); it != conf->keysym_map[pad].end(); ++it)
|
for (it = conf->keysym_map[pad].begin(); it != conf->keysym_map[pad].end(); ++it)
|
||||||
fprintf(f, "PAD %d:KEYSYM 0x%x = %d\n", pad, it->first, it->second);
|
fprintf(f, "PAD %d:KEYSYM 0x%x = %d\n", pad, it->first, it->second);
|
||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadConfig()
|
void LoadConfig()
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
char str[256];
|
char str[256];
|
||||||
bool have_user_setting = false;
|
bool have_user_setting = false;
|
||||||
|
|
||||||
if (!conf)
|
if (!conf)
|
||||||
conf = new PADconf;
|
conf = new PADconf;
|
||||||
|
|
||||||
conf->init();
|
conf->init();
|
||||||
|
|
||||||
const std::string iniFile(s_strIniPath + "OnePAD.ini");
|
const std::string iniFile(s_strIniPath + "OnePAD.ini");
|
||||||
f = fopen(iniFile.c_str(), "r");
|
f = fopen(iniFile.c_str(), "r");
|
||||||
if (f == NULL)
|
if (f == NULL) {
|
||||||
{
|
printf("OnePAD: failed to load ini %s\n", iniFile.c_str());
|
||||||
printf("OnePAD: failed to load ini %s\n", iniFile.c_str());
|
SaveConfig(); //save and return
|
||||||
SaveConfig(); //save and return
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
u32 value;
|
u32 value;
|
||||||
if (fscanf(f, "log = %u\n", &value) == 0) goto error;
|
if (fscanf(f, "log = %u\n", &value) == 0)
|
||||||
conf->log = value;
|
goto error;
|
||||||
if (fscanf(f, "options = %u\n", &value) == 0) goto error;
|
conf->log = value;
|
||||||
conf->packed_options = value;
|
if (fscanf(f, "options = %u\n", &value) == 0)
|
||||||
if (fscanf(f, "mouse_sensibility = %u\n", &value) == 0) goto error;
|
goto error;
|
||||||
conf->set_sensibility(value);
|
conf->packed_options = value;
|
||||||
if (fscanf(f, "joy_pad_map = %u\n", &value) == 0) goto error;
|
if (fscanf(f, "mouse_sensibility = %u\n", &value) == 0)
|
||||||
conf->joyid_map = value;
|
goto error;
|
||||||
if (fscanf(f, "ff_intensity = %u\n", &value) == 0) goto error;
|
conf->set_sensibility(value);
|
||||||
conf->set_ff_intensity(value);
|
if (fscanf(f, "joy_pad_map = %u\n", &value) == 0)
|
||||||
|
goto error;
|
||||||
|
conf->joyid_map = value;
|
||||||
|
if (fscanf(f, "ff_intensity = %u\n", &value) == 0)
|
||||||
|
goto error;
|
||||||
|
conf->set_ff_intensity(value);
|
||||||
|
|
||||||
for (int pad = 0; pad < GAMEPAD_NUMBER; pad++)
|
for (int pad = 0; pad < GAMEPAD_NUMBER; pad++) {
|
||||||
{
|
for (int key = 0; key < MAX_KEYS; key++) {
|
||||||
for (int key = 0; key < MAX_KEYS; key++)
|
sprintf(str, "[%d][%d] = 0x%%x\n", pad, key);
|
||||||
{
|
u32 temp = 0;
|
||||||
sprintf(str, "[%d][%d] = 0x%%x\n", pad, key);
|
|
||||||
u32 temp = 0;
|
|
||||||
|
|
||||||
if (fscanf(f, str, &temp) == 0) temp = 0;
|
if (fscanf(f, str, &temp) == 0)
|
||||||
set_key(pad, key, temp);
|
temp = 0;
|
||||||
if (temp && pad == 0) have_user_setting = true;
|
set_key(pad, key, temp);
|
||||||
}
|
if (temp && pad == 0)
|
||||||
}
|
have_user_setting = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
u32 pad;
|
u32 pad;
|
||||||
u32 keysym;
|
u32 keysym;
|
||||||
u32 index;
|
u32 index;
|
||||||
while( fscanf(f, "PAD %u:KEYSYM 0x%x = %u\n", &pad, &keysym, &index) != EOF ) {
|
while (fscanf(f, "PAD %u:KEYSYM 0x%x = %u\n", &pad, &keysym, &index) != EOF) {
|
||||||
set_keyboad_key(pad & 1, keysym, index);
|
set_keyboad_key(pad & 1, keysym, index);
|
||||||
if(pad == 0) have_user_setting = true;
|
if (pad == 0)
|
||||||
}
|
have_user_setting = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (!have_user_setting) DefaultKeyboardValues();
|
if (!have_user_setting)
|
||||||
|
DefaultKeyboardValues();
|
||||||
|
|
||||||
error:
|
error:
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue