mirror of
https://github.com/Ed94/HandmadeHero.git
synced 2025-07-01 11:21:05 -07:00
Day 10 Complete
This commit is contained in:
@ -5,64 +5,46 @@
|
||||
/* Platform architecture */
|
||||
|
||||
#if defined( _WIN64 ) || defined( __x86_64__ ) || defined( _M_X64 ) || defined( __64BIT__ ) || defined( __powerpc64__ ) || defined( __ppc64__ ) || defined( __aarch64__ )
|
||||
# ifndef GEN_ARCH_64_BIT
|
||||
# define GEN_ARCH_64_BIT 1
|
||||
# ifndef ARCH_64_BIT
|
||||
# define ARCH_64_BIT 1
|
||||
# endif
|
||||
#else
|
||||
# ifndef GEN_ARCH_32_BItxt_StrCaT
|
||||
# define GEN_ARCH_32_BIT 1
|
||||
# endif
|
||||
# error A 32-bit architecture is not supported
|
||||
#endif
|
||||
|
||||
/* Platform OS */
|
||||
|
||||
#if defined( _WIN32 ) || defined( _WIN64 )
|
||||
# ifndef GEN_SYSTEM_WINDOWS
|
||||
# define GEN_SYSTEM_WINDOWS 1
|
||||
# ifndef SYSTEM_WINDOWS
|
||||
# define SYSTEM_WINDOWS 1
|
||||
# endif
|
||||
#elif defined( __APPLE__ ) && defined( __MACH__ )
|
||||
# ifndef GEN_SYSTEM_OSX
|
||||
# define GEN_SYSTEM_OSX 1
|
||||
# ifndef SYSTEM_OSX
|
||||
# define SYSTEM_OSX 1
|
||||
# endif
|
||||
# ifndef GEN_SYSTEM_MACOS
|
||||
# define GEN_SYSTEM_MACOS 1
|
||||
# ifndef SYSTEM_MACOS
|
||||
# define SYSTEM_MACOS 1
|
||||
# endif
|
||||
# include <TargetConditionals.h>
|
||||
# if TARGET_IPHONE_SIMULATOR == 1 || TARGET_OS_IPHONE == 1
|
||||
# ifndef GEN_SYSTEM_IOS
|
||||
# define GEN_SYSTEM_IOS 1
|
||||
# ifndef SYSTEM_IOS
|
||||
# define SYSTEM_IOS 1
|
||||
# endif
|
||||
# endif
|
||||
#elif defined( __unix__ )
|
||||
# ifndef GEN_SYSTEM_UNIX
|
||||
# ifndef SYSTEM_UNIX
|
||||
# define GEN_SYSTEM_UNIX 1
|
||||
# endif
|
||||
# if defined( ANDROID ) || defined( __ANDROID__ )
|
||||
# ifndef GEN_SYSTEM_ANDROID
|
||||
# define GEN_SYSTEM_ANDROID 1
|
||||
# ifndef SYSTEM_ANDROID
|
||||
# define SYSTEM_ANDROID 1
|
||||
# endif
|
||||
# ifndef GEN_SYSTEM_LINUX
|
||||
# define GEN_SYSTEM_LINUX 1
|
||||
# ifndef SYSTEM_LINUX
|
||||
# define SYSTEM_LINUX 1
|
||||
# endif
|
||||
# elif defined( __linux__ )
|
||||
# ifndef GEN_SYSTEM_LINUX
|
||||
# define GEN_SYSTEM_LINUX 1
|
||||
# endif
|
||||
# elif defined( __FreeBSD__ ) || defined( __FreeBSD_kernel__ )
|
||||
# ifndef GEN_SYSTEM_FREEBSD
|
||||
# define GEN_SYSTEM_FREEBSD 1
|
||||
# endif
|
||||
# elif defined( __OpenBSD__ )
|
||||
# ifndef GEN_SYSTEM_OPENBSD
|
||||
# define GEN_SYSTEM_OPENBSD 1
|
||||
# endif
|
||||
# elif defined( __EMSCRIPTEN__ )
|
||||
# ifndef GEN_SYSTEM_EMSCRIPTEN
|
||||
# define GEN_SYSTEM_EMSCRIPTEN 1
|
||||
# endif
|
||||
# elif defined( __CYGWIN__ )
|
||||
# ifndef GEN_SYSTEM_CYGWIN
|
||||
# define GEN_SYSTEM_CYGWIN 1
|
||||
# ifndef SYSTEM_LINUX
|
||||
# define SYSTEM_LINUX 1
|
||||
# endif
|
||||
# else
|
||||
# error This UNIX operating system is not supported
|
||||
@ -74,29 +56,17 @@
|
||||
/* Platform compiler */
|
||||
|
||||
#if defined( _MSC_VER )
|
||||
# define GEN_COMPILER_MSVC 1
|
||||
#elif defined( __GNUC__ )
|
||||
# define GEN_COMPILER_GCC 1
|
||||
# define COMPILER_MSVC 1
|
||||
#elif defined( __clang__ )
|
||||
# define GEN_COMPILER_CLANG 1
|
||||
#elif defined( __MINGW32__ )
|
||||
# define GEN_COMPILER_MINGW 1
|
||||
# define COMPILER_CLANG 1
|
||||
#else
|
||||
# error Unknown compiler
|
||||
#endif
|
||||
|
||||
#if defined( __has_attribute )
|
||||
# define GEN_HAS_ATTRIBUTE( attribute ) __has_attribute( attribute )
|
||||
# define HAS_ATTRIBUTE( attribute ) __has_attribute( attribute )
|
||||
#else
|
||||
# define GEN_HAS_ATTRIBUTE( attribute ) ( 0 )
|
||||
#endif
|
||||
|
||||
#if defined(GEN_GCC_VERSION_CHECK)
|
||||
# undef GEN_GCC_VERSION_CHECK
|
||||
#endif
|
||||
#if defined(GEN_GCC_VERSION)
|
||||
# define GEN_GCC_VERSION_CHECK(major,minor,patch) (GEN_GCC_VERSION >= GEN_VERSION_ENCODE(major, minor, patch))
|
||||
#else
|
||||
# define GEN_GCC_VERSION_CHECK(major,minor,patch) (0)
|
||||
# define HAS_ATTRIBUTE( attribute ) ( 0 )
|
||||
#endif
|
||||
|
||||
#pragma endregion Platform Detection
|
||||
@ -106,7 +76,7 @@
|
||||
# include <stdarg.h>
|
||||
# include <stddef.h>
|
||||
|
||||
# if defined( GEN_SYSTEM_WINDOWS )
|
||||
# if defined( SYSTEM_WINDOWS )
|
||||
# include <intrin.h>
|
||||
# endif
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
# define CONSTANTS
|
||||
#pragma once
|
||||
|
||||
# define EPSILON 1.19209290e-7f
|
||||
# define ZERO 0.0f
|
||||
# define ONE 1.0f
|
||||
|
@ -22,18 +22,13 @@
|
||||
#define I64_MIN ( -0x7fffffffffffffffll - 1 )
|
||||
#define I64_MAX 0x7fffffffffffffffll
|
||||
|
||||
#if defined( GEN_ARCH_32_BIT )
|
||||
# define USIZE_MIN GEN_U32_MIN
|
||||
# define USIZE_MAX GEN_U32_MAX
|
||||
# define ISIZE_MIN GEN_S32_MIN
|
||||
# define ISIZE_MAX GEN_S32_MAX
|
||||
#elif defined( GEN_ARCH_64_BIT )
|
||||
#if defined( ARCH_64_BIT )
|
||||
# define USIZE_MIN GEN_U64_MIN
|
||||
# define USIZE_MAX GEN_U64_MAX
|
||||
# define ISIZE_MIN GEN_I64_MIN
|
||||
# define ISIZE_MAX GEN_I64_MAX
|
||||
#else
|
||||
# error Unknown architecture size. This library only supports 32 bit and 64 bit architectures.
|
||||
# error Unknown architecture size. This library only supports 64 bit architectures.
|
||||
#endif
|
||||
|
||||
#define F32_MIN 1.17549435e-38f
|
||||
@ -41,7 +36,7 @@
|
||||
#define F64_MIN 2.2250738585072014e-308
|
||||
#define F64_MAX 1.7976931348623157e+308
|
||||
|
||||
#if defined( GEN_COMPILER_MSVC )
|
||||
#if defined( COMPILER_MSVC )
|
||||
# if _MSC_VER < 1300
|
||||
typedef unsigned char u8;
|
||||
typedef signed char s8;
|
||||
@ -87,21 +82,9 @@ typedef ptrdiff_t sw;
|
||||
|
||||
static_assert( sizeof( uw ) == sizeof( sw ), "sizeof(uw) != sizeof(sw)" );
|
||||
|
||||
// NOTE: (u)zpl_intptr is only here for semantic reasons really as this library will only support 32/64 bit OSes.
|
||||
#if defined( _WIN64 )
|
||||
typedef signed __int64 sptr;
|
||||
typedef unsigned __int64 uptr;
|
||||
#elif defined( _WIN32 )
|
||||
// NOTE; To mark types changing their size, e.g. zpl_intptr
|
||||
# ifndef _W64
|
||||
# if ! defined( __midl ) && ( defined( _X86_ ) || defined( _M_IX86 ) ) && _MSC_VER >= 1300
|
||||
# define _W64 __w64
|
||||
# else
|
||||
# define _W64
|
||||
# endif
|
||||
# endif
|
||||
typedef _W64 signed int sptr;
|
||||
typedef _W64 unsigned int uptr;
|
||||
#else
|
||||
typedef uintptr_t uptr;
|
||||
typedef intptr_t sptr;
|
||||
|
@ -1,6 +1,7 @@
|
||||
/*
|
||||
Alternative header for windows.h
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
@ -112,21 +113,25 @@ WIN_LIB_API DWORD WINAPI XInputGetState
|
||||
(
|
||||
DWORD dwUserIndex, // Index of the gamer associated with the device
|
||||
XINPUT_STATE* pState // Receives the current state
|
||||
) WIN_NOEXCEPT;
|
||||
);
|
||||
|
||||
WIN_LIB_API DWORD WINAPI XInputSetState
|
||||
(
|
||||
DWORD dwUserIndex, // Index of the gamer associated with the device
|
||||
XINPUT_VIBRATION* pVibration // The vibration information to send to the controller
|
||||
) WIN_NOEXCEPT;
|
||||
);
|
||||
|
||||
DWORD WINAPI xinput_get_state_stub( DWORD dwUserIndex, XINPUT_STATE* pVibration ) {
|
||||
OutputDebugStringA( "xinput_get_state stubbed!\n");
|
||||
do_once_start
|
||||
OutputDebugStringA( "xinput_get_state stubbed!\n");
|
||||
do_once_end
|
||||
return ERROR_DEVICE_NOT_CONNECTED;
|
||||
}
|
||||
|
||||
DWORD WINAPI xinput_set_state_stub( DWORD dwUserIndex, XINPUT_VIBRATION* pVibration ) {
|
||||
OutputDebugStringA( "xinput_set_state stubbed!\n");
|
||||
do_once_start
|
||||
OutputDebugStringA( "xinput_set_state stubbed!\n");
|
||||
do_once_end
|
||||
return ERROR_DEVICE_NOT_CONNECTED;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user