Use OneShot's fixed version of steamshim
This commit is contained in:
		
							parent
							
								
									46494766bd
								
							
						
					
					
						commit
						1445381756
					
				
					 2 changed files with 38 additions and 22 deletions
				
			
		| 
						 | 
					@ -9,7 +9,6 @@ typedef __int32 int32;
 | 
				
			||||||
typedef unsigned __int64 uint64;
 | 
					typedef unsigned __int64 uint64;
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
#include <stdio.h>
 | 
					#include <stdio.h>
 | 
				
			||||||
#include <stdlib.h>
 | 
					 | 
				
			||||||
#include <string.h>
 | 
					#include <string.h>
 | 
				
			||||||
#include <stdint.h>
 | 
					#include <stdint.h>
 | 
				
			||||||
#include <unistd.h>
 | 
					#include <unistd.h>
 | 
				
			||||||
| 
						 | 
					@ -22,16 +21,16 @@ typedef uint64_t uint64;
 | 
				
			||||||
typedef int PipeType;
 | 
					typedef int PipeType;
 | 
				
			||||||
#define NULLPIPE -1
 | 
					#define NULLPIPE -1
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					#include <stdlib.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <stdio.h>
 | 
					 | 
				
			||||||
#include <signal.h>
 | 
					 | 
				
			||||||
#include "steamshim_child.h"
 | 
					#include "steamshim_child.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define DEBUGPIPE 1
 | 
					#ifdef STEAMSHIM_DEBUG
 | 
				
			||||||
#if DEBUGPIPE
 | 
					 | 
				
			||||||
#define dbgpipe printf
 | 
					#define dbgpipe printf
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
static inline void dbgpipe(const char *fmt, ...) {}
 | 
					static inline void dbgpipe(const char *fmt, ...) {
 | 
				
			||||||
 | 
					    (void)fmt;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int writePipe(PipeType fd, const void *buf, const unsigned int _len);
 | 
					static int writePipe(PipeType fd, const void *buf, const unsigned int _len);
 | 
				
			||||||
| 
						 | 
					@ -68,12 +67,11 @@ static void closePipe(PipeType fd)
 | 
				
			||||||
    CloseHandle(fd);
 | 
					    CloseHandle(fd);
 | 
				
			||||||
} /* closePipe */
 | 
					} /* closePipe */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static char *getEnvVar(const char *key, char *buf, const size_t _buflen)
 | 
					static char *getEnvVar(const char *key, char *buf, const size_t buflen)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    const DWORD buflen = (DWORD) _buflen;
 | 
					 | 
				
			||||||
    const DWORD rc = GetEnvironmentVariableA(key, buf, buflen);
 | 
					    const DWORD rc = GetEnvironmentVariableA(key, buf, buflen);
 | 
				
			||||||
    /* rc doesn't count null char, hence "<". */
 | 
					    /* rc doesn't count null char, hence "<". */
 | 
				
			||||||
    return ((rc > 0) && (rc < buflen)) ? NULL : buf;
 | 
					    return ((rc > 0) && (rc < buflen)) ? buf : NULL;
 | 
				
			||||||
} /* getEnvVar */
 | 
					} /* getEnvVar */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
| 
						 | 
					@ -135,6 +133,8 @@ typedef enum ShimCmd
 | 
				
			||||||
    SHIMCMD_GETSTATI,
 | 
					    SHIMCMD_GETSTATI,
 | 
				
			||||||
    SHIMCMD_SETSTATF,
 | 
					    SHIMCMD_SETSTATF,
 | 
				
			||||||
    SHIMCMD_GETSTATF,
 | 
					    SHIMCMD_GETSTATF,
 | 
				
			||||||
 | 
					    SHIMCMD_GETPERSONANAME,
 | 
				
			||||||
 | 
					    SHIMCMD_GETCURRENTGAMELANGUAGE,
 | 
				
			||||||
} ShimCmd;
 | 
					} ShimCmd;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int write1ByteCmd(const uint8 b1)
 | 
					static int write1ByteCmd(const uint8 b1)
 | 
				
			||||||
| 
						 | 
					@ -158,22 +158,15 @@ static inline int writeBye(void)
 | 
				
			||||||
static int initPipes(void)
 | 
					static int initPipes(void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    char buf[64];
 | 
					    char buf[64];
 | 
				
			||||||
    unsigned long long val;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!getEnvVar("STEAMSHIM_READHANDLE", buf, sizeof (buf)))
 | 
					    if (!getEnvVar("STEAMSHIM_READHANDLE", buf, sizeof (buf)))
 | 
				
			||||||
        return 0;
 | 
					        return 0;
 | 
				
			||||||
    else if (sscanf(buf, "%llu", &val) != 1)
 | 
					    GPipeRead = (PipeType) strtoull(buf, 0, 10);
 | 
				
			||||||
        return 0;
 | 
					 | 
				
			||||||
    else
 | 
					 | 
				
			||||||
        GPipeRead = (PipeType) val;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!getEnvVar("STEAMSHIM_WRITEHANDLE", buf, sizeof (buf)))
 | 
					    if (!getEnvVar("STEAMSHIM_WRITEHANDLE", buf, sizeof (buf)))
 | 
				
			||||||
        return 0;
 | 
					        return 0;
 | 
				
			||||||
    else if (sscanf(buf, "%llu", &val) != 1)
 | 
					    GPipeWrite = (PipeType) strtoull(buf, 0, 10);
 | 
				
			||||||
        return 0;
 | 
					
 | 
				
			||||||
    else
 | 
					 | 
				
			||||||
        GPipeWrite = (PipeType) val;
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    return ((GPipeRead != NULLPIPE) && (GPipeWrite != NULLPIPE));
 | 
					    return ((GPipeRead != NULLPIPE) && (GPipeWrite != NULLPIPE));
 | 
				
			||||||
} /* initPipes */
 | 
					} /* initPipes */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -239,7 +232,7 @@ static const STEAMSHIM_Event *processEvent(const uint8 *buf, size_t buflen)
 | 
				
			||||||
    event.type = type;
 | 
					    event.type = type;
 | 
				
			||||||
    event.okay = 1;
 | 
					    event.okay = 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    #if DEBUGPIPE
 | 
					    #ifdef STEAMSHIM_DEBUG
 | 
				
			||||||
    if (0) {}
 | 
					    if (0) {}
 | 
				
			||||||
    #define PRINTGOTEVENT(x) else if (type == x) printf("Child got " #x ".\n")
 | 
					    #define PRINTGOTEVENT(x) else if (type == x) printf("Child got " #x ".\n")
 | 
				
			||||||
    PRINTGOTEVENT(SHIMEVENT_BYE);
 | 
					    PRINTGOTEVENT(SHIMEVENT_BYE);
 | 
				
			||||||
| 
						 | 
					@ -252,6 +245,8 @@ static const STEAMSHIM_Event *processEvent(const uint8 *buf, size_t buflen)
 | 
				
			||||||
    PRINTGOTEVENT(SHIMEVENT_GETSTATI);
 | 
					    PRINTGOTEVENT(SHIMEVENT_GETSTATI);
 | 
				
			||||||
    PRINTGOTEVENT(SHIMEVENT_SETSTATF);
 | 
					    PRINTGOTEVENT(SHIMEVENT_SETSTATF);
 | 
				
			||||||
    PRINTGOTEVENT(SHIMEVENT_GETSTATF);
 | 
					    PRINTGOTEVENT(SHIMEVENT_GETSTATF);
 | 
				
			||||||
 | 
					    PRINTGOTEVENT(SHIMEVENT_GETPERSONANAME);
 | 
				
			||||||
 | 
					    PRINTGOTEVENT(SHIMEVENT_GETCURRENTGAMELANGUAGE);
 | 
				
			||||||
    #undef PRINTGOTEVENT
 | 
					    #undef PRINTGOTEVENT
 | 
				
			||||||
    else printf("Child got unknown shimevent %d.\n", (int) type);
 | 
					    else printf("Child got unknown shimevent %d.\n", (int) type);
 | 
				
			||||||
    #endif
 | 
					    #endif
 | 
				
			||||||
| 
						 | 
					@ -306,6 +301,11 @@ static const STEAMSHIM_Event *processEvent(const uint8 *buf, size_t buflen)
 | 
				
			||||||
            strcpy(event.name, (const char *) buf);
 | 
					            strcpy(event.name, (const char *) buf);
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        case SHIMEVENT_GETPERSONANAME:
 | 
				
			||||||
 | 
					        case SHIMEVENT_GETCURRENTGAMELANGUAGE:
 | 
				
			||||||
 | 
					            strcpy(event.name, (const char *) buf);
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        default:  /* uh oh */
 | 
					        default:  /* uh oh */
 | 
				
			||||||
            return NULL;
 | 
					            return NULL;
 | 
				
			||||||
    } /* switch */
 | 
					    } /* switch */
 | 
				
			||||||
| 
						 | 
					@ -446,5 +446,18 @@ void STEAMSHIM_getStatF(const char *name)
 | 
				
			||||||
    writeStatThing(SHIMCMD_GETSTATF, name, NULL, 0);
 | 
					    writeStatThing(SHIMCMD_GETSTATF, name, NULL, 0);
 | 
				
			||||||
} /* STEAMSHIM_getStatF */
 | 
					} /* STEAMSHIM_getStatF */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* end of steamshim_child.c ... */
 | 
					void STEAMSHIM_getPersonaName()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    if (isDead()) return;
 | 
				
			||||||
 | 
					    dbgpipe("Child sending SHIMCMD_GETPERSONANAME().\n");
 | 
				
			||||||
 | 
					    write1ByteCmd(SHIMCMD_GETPERSONANAME);
 | 
				
			||||||
 | 
					} /* STEAMSHIM_getPersonaName */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void STEAMSHIM_getCurrentGameLanguage()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    if (isDead()) return;
 | 
				
			||||||
 | 
					    dbgpipe("Child sending SHIMCMD_GETCURRENTGAMELANGUAGE().\n");
 | 
				
			||||||
 | 
					    write1ByteCmd(SHIMCMD_GETCURRENTGAMELANGUAGE);
 | 
				
			||||||
 | 
					} /* STEAMSHIM_getCurrentGameLanguage */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* end of steamshim_child.c ... */
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -17,6 +17,8 @@ typedef enum STEAMSHIM_EventType
 | 
				
			||||||
    SHIMEVENT_GETSTATI,
 | 
					    SHIMEVENT_GETSTATI,
 | 
				
			||||||
    SHIMEVENT_SETSTATF,
 | 
					    SHIMEVENT_SETSTATF,
 | 
				
			||||||
    SHIMEVENT_GETSTATF,
 | 
					    SHIMEVENT_GETSTATF,
 | 
				
			||||||
 | 
					    SHIMEVENT_GETPERSONANAME,
 | 
				
			||||||
 | 
					    SHIMEVENT_GETCURRENTGAMELANGUAGE,
 | 
				
			||||||
} STEAMSHIM_EventType;
 | 
					} STEAMSHIM_EventType;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* not all of these fields make sense in a given event. */
 | 
					/* not all of these fields make sense in a given event. */
 | 
				
			||||||
| 
						 | 
					@ -43,6 +45,8 @@ void STEAMSHIM_setStatI(const char *name, const int _val);
 | 
				
			||||||
void STEAMSHIM_getStatI(const char *name);
 | 
					void STEAMSHIM_getStatI(const char *name);
 | 
				
			||||||
void STEAMSHIM_setStatF(const char *name, const float val);
 | 
					void STEAMSHIM_setStatF(const char *name, const float val);
 | 
				
			||||||
void STEAMSHIM_getStatF(const char *name);
 | 
					void STEAMSHIM_getStatF(const char *name);
 | 
				
			||||||
 | 
					void STEAMSHIM_getPersonaName();
 | 
				
			||||||
 | 
					void STEAMSHIM_getCurrentGameLanguage();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef __cplusplus
 | 
					#ifdef __cplusplus
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -51,4 +55,3 @@ void STEAMSHIM_getStatF(const char *name);
 | 
				
			||||||
#endif  /* include-once blocker */
 | 
					#endif  /* include-once blocker */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* end of steamshim_child.h ... */
 | 
					/* end of steamshim_child.h ... */
 | 
				
			||||||
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue