mirror of
https://github.com/Ed94/HandmadeHero.git
synced 2024-11-10 03:44:53 -08:00
Some more dualsense shenanigans
This commit is contained in:
parent
97d3c7cb69
commit
7ddbc13bc5
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@ -29,7 +29,8 @@
|
|||||||
"vector": "cpp",
|
"vector": "cpp",
|
||||||
"list": "cpp",
|
"list": "cpp",
|
||||||
"xhash": "cpp",
|
"xhash": "cpp",
|
||||||
// "*.md.html":"markdown"
|
"shared_mutex": "cpp",
|
||||||
|
"mutex": "cpp"
|
||||||
},
|
},
|
||||||
"C_Cpp.intelliSenseEngineFallback": "disabled",
|
"C_Cpp.intelliSenseEngineFallback": "disabled",
|
||||||
"C_Cpp.errorSquiggles": "disabled", // This doesn't work well with how the headers are included.
|
"C_Cpp.errorSquiggles": "disabled", // This doesn't work well with how the headers are included.
|
||||||
|
@ -19,6 +19,20 @@
|
|||||||
// Using this to get dualsense controllers
|
// Using this to get dualsense controllers
|
||||||
#include "JoyShockLibrary/JoyShockLibrary.h"
|
#include "JoyShockLibrary/JoyShockLibrary.h"
|
||||||
|
|
||||||
|
#define congrats( message ) do { \
|
||||||
|
JslSetLightColour( 0, (255 << 16) | (215 << 8) ); \
|
||||||
|
JslSetRumble( 0, 0, 255 ); \
|
||||||
|
MessageBoxA( 0, message, "Congratulations!", MB_OK | MB_ICONEXCLAMATION ); \
|
||||||
|
JslSetLightColour( 0, (255 << 8 ) ); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define fatal(message) do { \
|
||||||
|
JslSetLightColour( 0, (255 << 16) ); \
|
||||||
|
JslSetRumble( 0, 0, 255 ); \
|
||||||
|
MessageBoxA( 0, message, "Fatal Error", MB_OK | MB_ICONERROR ); \
|
||||||
|
JslSetLightColour( 0, (255 << 8 ) ); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
NS_WIN32_BEGIN
|
NS_WIN32_BEGIN
|
||||||
|
|
||||||
@ -317,6 +331,18 @@ WinMain(
|
|||||||
OutputDebugStringA( "Error: JSLGetConnectedDeviceHandles didn't find as many as were stated with JslConnectDevices\n");
|
OutputDebugStringA( "Error: JSLGetConnectedDeviceHandles didn't find as many as were stated with JslConnectDevices\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( jsl_num_devices > 0 )
|
||||||
|
{
|
||||||
|
OutputDebugStringA( "JSL Connected Devices:\n" );
|
||||||
|
for ( u32 jsl_device_index = 0; jsl_device_index < jsl_num_devices; ++ jsl_device_index )
|
||||||
|
{
|
||||||
|
JslSetLightColour( device_handles[ jsl_device_index ], (255 << 8) );
|
||||||
|
do_once_start
|
||||||
|
congrats( "GOT THE CONTROLLER BOIS" );
|
||||||
|
do_once_end
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// MessageBox( 0, L"First message!", L"Handmade Hero", MB_Ok_Btn | MB_Icon_Information );
|
// MessageBox( 0, L"First message!", L"Handmade Hero", MB_Ok_Btn | MB_Icon_Information );
|
||||||
|
|
||||||
WNDCLASS window_class {};
|
WNDCLASS window_class {};
|
||||||
@ -356,6 +382,8 @@ WinMain(
|
|||||||
u32 x_offset = 0;
|
u32 x_offset = 0;
|
||||||
u32 y_offset = 0;
|
u32 y_offset = 0;
|
||||||
|
|
||||||
|
bool xinput_detected = false;
|
||||||
|
|
||||||
// Controller State
|
// Controller State
|
||||||
u8 dpad_up = false;
|
u8 dpad_up = false;
|
||||||
u8 dpad_down = false;
|
u8 dpad_down = false;
|
||||||
@ -385,7 +413,7 @@ WinMain(
|
|||||||
}
|
}
|
||||||
|
|
||||||
TranslateMessage( & msg_info );
|
TranslateMessage( & msg_info );
|
||||||
DispatchMessage( & msg_info );
|
DispatchMessageW( & msg_info );
|
||||||
}
|
}
|
||||||
|
|
||||||
// XInput Polling
|
// XInput Polling
|
||||||
@ -393,7 +421,8 @@ WinMain(
|
|||||||
for ( DWORD controller_index = 0; controller_index < XUSER_MAX_COUNT; ++ controller_index )
|
for ( DWORD controller_index = 0; controller_index < XUSER_MAX_COUNT; ++ controller_index )
|
||||||
{
|
{
|
||||||
XINPUT_STATE controller_state;
|
XINPUT_STATE controller_state;
|
||||||
if ( xinput_get_state( controller_index, & controller_state ) == XI_PluggedIn )
|
xinput_detected = xinput_get_state( controller_index, & controller_state ) == XI_PluggedIn;
|
||||||
|
if ( xinput_detected )
|
||||||
{
|
{
|
||||||
XINPUT_GAMEPAD* pad = & controller_state.Gamepad;
|
XINPUT_GAMEPAD* pad = & controller_state.Gamepad;
|
||||||
|
|
||||||
@ -453,17 +482,31 @@ WinMain(
|
|||||||
// y_offset += left_stick_y;
|
// y_offset += left_stick_y;
|
||||||
|
|
||||||
if ( start )
|
if ( start )
|
||||||
|
{
|
||||||
|
if ( xinput_detected )
|
||||||
{
|
{
|
||||||
XINPUT_VIBRATION vibration;
|
XINPUT_VIBRATION vibration;
|
||||||
vibration.wLeftMotorSpeed = 30000;
|
vibration.wLeftMotorSpeed = 30000;
|
||||||
xinput_set_state( 0, & vibration );
|
xinput_set_state( 0, & vibration );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
JslSetRumble( 0, 1, 0 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( xinput_detected )
|
||||||
{
|
{
|
||||||
XINPUT_VIBRATION vibration;
|
XINPUT_VIBRATION vibration;
|
||||||
vibration.wLeftMotorSpeed = 0;
|
vibration.wLeftMotorSpeed = 0;
|
||||||
xinput_set_state( 0, & vibration );
|
xinput_set_state( 0, & vibration );
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
JslSetRumble( 0, 0, 0 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
render_weird_graident( &BackBuffer, x_offset, y_offset );
|
render_weird_graident( &BackBuffer, x_offset, y_offset );
|
||||||
|
|
||||||
@ -484,5 +527,14 @@ WinMain(
|
|||||||
// TODO(Ed) : Logging
|
// TODO(Ed) : Logging
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( jsl_num_devices > 0 )
|
||||||
|
{
|
||||||
|
OutputDebugStringA( "JSL Connected Devices:\n" );
|
||||||
|
for ( u32 jsl_device_index = 0; jsl_device_index < jsl_num_devices; ++ jsl_device_index )
|
||||||
|
{
|
||||||
|
JslSetLightColour( device_handles[ jsl_device_index ], 0 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -14,3 +14,27 @@
|
|||||||
#define pcast( Type, Value ) ( * reinterpret_cast< Type* >( & ( Value ) ) )
|
#define pcast( Type, Value ) ( * reinterpret_cast< Type* >( & ( Value ) ) )
|
||||||
#define rcast( Type, Value ) reinterpret_cast< Type >( Value )
|
#define rcast( Type, Value ) reinterpret_cast< Type >( Value )
|
||||||
#define scast( Type, Value ) static_cast< Type >( Value )
|
#define scast( Type, Value ) static_cast< Type >( Value )
|
||||||
|
|
||||||
|
#define do_once() \
|
||||||
|
do \
|
||||||
|
{ \
|
||||||
|
static \
|
||||||
|
bool Done = false; \
|
||||||
|
if ( Done ) \
|
||||||
|
return; \
|
||||||
|
Done = true; \
|
||||||
|
} \
|
||||||
|
while(0)
|
||||||
|
|
||||||
|
#define do_once_start \
|
||||||
|
do \
|
||||||
|
{ \
|
||||||
|
static \
|
||||||
|
bool Done = false; \
|
||||||
|
if ( Done ) \
|
||||||
|
break; \
|
||||||
|
Done = true;
|
||||||
|
|
||||||
|
#define do_once_end \
|
||||||
|
} \
|
||||||
|
while(0);
|
@ -115,12 +115,12 @@ WIN_LIB_API DWORD WINAPI XInputSetState
|
|||||||
|
|
||||||
DWORD WINAPI xinput_get_state_stub( DWORD dwUserIndex, XINPUT_STATE* pVibration ) {
|
DWORD WINAPI xinput_get_state_stub( DWORD dwUserIndex, XINPUT_STATE* pVibration ) {
|
||||||
OutputDebugStringA( "xinput_get_state stubbed!\n");
|
OutputDebugStringA( "xinput_get_state stubbed!\n");
|
||||||
return 0;
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD WINAPI xinput_set_state_stub( DWORD dwUserIndex, XINPUT_VIBRATION* pVibration ) {
|
DWORD WINAPI xinput_set_state_stub( DWORD dwUserIndex, XINPUT_VIBRATION* pVibration ) {
|
||||||
OutputDebugStringA( "xinput_set_state stubbed!\n");
|
OutputDebugStringA( "xinput_set_state stubbed!\n");
|
||||||
return 0;
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
using XInputGetStateFn = DWORD WINAPI( DWORD dwUserIndex, XINPUT_STATE* pVibration );
|
using XInputGetStateFn = DWORD WINAPI( DWORD dwUserIndex, XINPUT_STATE* pVibration );
|
||||||
|
Loading…
Reference in New Issue
Block a user