Removed old input code post-new design

This commit is contained in:
Edward R. Gonzalez 2023-12-29 19:33:58 -05:00
parent 467c2ee34b
commit 6ac57371e4
4 changed files with 6 additions and 112 deletions

View File

@ -69,11 +69,7 @@ Vec2 get_screen_center( OffscreenBuffer* back_buffer )
internal
void input_poll_engine_actions( InputState* input, EngineActions* actions )
{
#if NEW_INPUT_DESIGN
KeyboardState* keyboard = input->keyboard;
#else
KeyboardState* keyboard = input->controllers[0].keyboard;
#endif
// actions->move_right |= keyboard->D.EndedDown;
// actions->move_left |= keyboard->A.EndedDown;
@ -100,11 +96,7 @@ void input_poll_engine_actions( InputState* input, EngineActions* actions )
actions->loop_mode_game |= pressed( keyboard->L ) && ! keyboard->right_shift.ended_down && ! keyboard->right_alt.ended_down;
actions->loop_mode_engine |= pressed( keyboard->L ) && keyboard->right_shift.ended_down;
#if NEW_INPUT_DESIGN
MousesState* mouse = input->mouse;
#else
MousesState* mouse = input->controllers[0].mouse;
#endif
actions->move_right = (mouse->horizontal_wheel.end > 0.f) * 20;
actions->move_left = (mouse->horizontal_wheel.end < 0.f) * 20;
@ -119,13 +111,7 @@ void input_poll_engine_actions( InputState* input, EngineActions* actions )
// TODO(Ed) : Move to handmade module
internal
void input_poll_player_actions(
#if NEW_INPUT_DESIGN
hh::ControllerState* controller
#else
ControllerState* controller
#endif
, hh::PlayerActions* actions, b32 is_player_2 )
void input_poll_player_actions( hh::ControllerState* controller, hh::PlayerActions* actions, b32 is_player_2 )
{
if ( controller->ds_pad )
{
@ -635,6 +621,9 @@ void render_player( hh::PlayerState* player, World* world, hh::GameState* game_s
f32 player_blue = 0.3f;
f32 player_half_width = player->width / 2.f;
if ( player->position.tile_z != game_state->camera_pos.tile_z )
return;
TileMapPos player_to_camera = subtract( player->position, game_state->camera_pos );
@ -1191,7 +1180,6 @@ void update_and_render( f32 delta_time, InputState* input, OffscreenBuffer* back
hh::PlayerActions player_actions {};
hh::PlayerActions player_actions_2 {};
#if NEW_INPUT_DESIGN
do_once()
{
game_state->player_1.controller.keyboard = input->keyboard;
@ -1222,7 +1210,7 @@ void update_and_render( f32 delta_time, InputState* input, OffscreenBuffer* back
if ( game_state->player_1.controller.ds_pad == ds_pad || game_state->player_2.controller.ds_pad == ds_pad )
continue;
if ( ds_pad && pressed( ds_pad->share ) )
if ( ds_pad && pressed( ds_pad->options ) )
{
if ( can_assign( player_1 ) )
{
@ -1240,9 +1228,6 @@ void update_and_render( f32 delta_time, InputState* input, OffscreenBuffer* back
if ( game_state->player_2.controller.xpad || game_state->player_2.controller.ds_pad )
input_poll_player_actions( & game_state->player_2.controller, & player_actions_2, 1 );
#else
input_poll_player_actions( & input->controllers[0], & player_actions, 0 );
#endif
World* world = state->context.world;
TileMap* tile_map = world->tile_map;
@ -1375,10 +1360,8 @@ void update_and_render( f32 delta_time, InputState* input, OffscreenBuffer* back
// Player Rendering
render_player( player, world, game_state, back_buffer );
#if NEW_INPUT_DESIGN
if ( game_state->player_2.controller.xpad || game_state->player_2.controller.ds_pad )
render_player( & game_state->player_state_2, world, game_state, back_buffer );
#endif
// Snapshot Visual Aid
#if Build_Development
@ -1410,17 +1393,10 @@ void update_and_render( f32 delta_time, InputState* input, OffscreenBuffer* back
// Mouse Position
if ( 0 )
{
#if NEW_INPUT_DESIGN
draw_rectangle( back_buffer
, { (f32)input->mouse->X.end, (f32)input->mouse->Y.end }
, { (f32)input->mouse->X.end + 10.f, (f32)input->mouse->Y.end + 10.f }
, 1.f, 1.f, 0.f );
#else
draw_rectangle( back_buffer
, { (f32)input->controllers[0].mouse->X.end, (f32)input->controllers[0].mouse->Y.end }
, { (f32)input->controllers[0].mouse->X.end + 10.f, (f32)input->controllers[0].mouse->Y.end + 10.f }
, 1.f, 1.f, 0.f );
#endif
}
// Mouse buttons test

View File

@ -143,9 +143,6 @@ struct DualsensePadState
};
using DualsensePadStates = DualsensePadState*[ Max_Controllers ];
#define NEW_INPUT_DESIGN 1
#if NEW_INPUT_DESIGN
struct InputStateSnapshot
{
KeyboardState keyboard;
@ -153,39 +150,13 @@ struct InputStateSnapshot
XInputPadState xpads [ Max_Controllers ];
DualsensePadState ds_pads[ Max_Controllers ];
};
#else
struct ControllerStateSnapshot
{
KeyboardState keyboard;
MousesState mouse;
XInputPadState xpad;
DualsensePadState ds_pad;
};
struct ControllerState
{
KeyboardState* keyboard;
MousesState* mouse;
XInputPadState* xpad;
DualsensePadState* ds_pad;
};
struct InputStateSnapshot
{
ControllerStateSnapshot controllers[4];
};
#endif
struct InputState
{
#if NEW_INPUT_DESIGN
KeyboardState* keyboard;
MousesState* mouse;
XInputPadStates xpads;
DualsensePadStates ds_pads;
#else
ControllerState controllers[4];
#endif
};
using InputBindCallback = void( void* );

View File

@ -106,7 +106,6 @@ void end_playback_input( Memory* memory, InputState* input, platform::ModuleAPI*
InputStateSnapshot input_state_snapshot( InputState* input )
{
#if NEW_INPUT_DESIGN
InputStateSnapshot snapshot = {};
if ( input->keyboard )
snapshot.keyboard = * input->keyboard;
@ -125,28 +124,6 @@ InputStateSnapshot input_state_snapshot( InputState* input )
snapshot.ds_pads[ idx ] = * ds_pad;
}
return snapshot;
#else
InputStateSnapshot snapshot = {};
for ( s32 idx = 0; idx < array_count( snapshot.controllers ); ++ idx )
{
ControllerState* controller = & input->controllers[idx];
if ( controller == nullptr )
continue;
if ( controller->ds_pad )
snapshot.controllers[idx].ds_pad = *controller->ds_pad;
if ( controller->xpad )
snapshot.controllers[idx].xpad = *controller->xpad;
if ( controller->keyboard )
snapshot.controllers[idx].keyboard = *controller->keyboard;
if ( controller->mouse )
snapshot.controllers[idx].mouse = *controller->mouse;
}
return snapshot;
#endif
}
internal
@ -170,7 +147,6 @@ void play_input( SnapshotFn* load_snapshot, Memory* memory, InputState* input, p
return;
}
#if NEW_INPUT_DESIGN
if ( input->keyboard )
* input->keyboard = new_input.keyboard;
@ -187,28 +163,6 @@ void play_input( SnapshotFn* load_snapshot, Memory* memory, InputState* input, p
if ( ds_pad )
* ds_pad = new_input.ds_pads[ idx ];
}
#else
for ( s32 idx = 0; idx < array_count( new_input.controllers ); ++ idx )
{
ControllerState* controller = & input->controllers[idx];
if ( controller == nullptr )
continue;
if ( controller->ds_pad )
*controller->ds_pad = new_input.controllers[idx].ds_pad;
if ( controller->xpad )
*controller->xpad = new_input.controllers[idx].xpad;
if ( controller->keyboard )
{
*controller->keyboard = new_input.controllers[idx].keyboard;
}
if ( controller->mouse )
*controller->mouse = new_input.controllers[idx].mouse;
}
#endif
}
void process_loop_mode( SnapshotFn* take_snapshot, SnapshotFn* load_snapshot

View File

@ -61,7 +61,6 @@ struct ActionableMode
Player : Controller, Actionables, ActionSets
*/
#if NEW_INPUT_DESIGN
struct ControllerState
{
engine::KeyboardState* keyboard;
@ -69,7 +68,6 @@ struct ControllerState
engine::XInputPadState* xpad;
engine::DualsensePadState* ds_pad;
};
#endif
enum EHeroBitmapsDirection : u32
{
@ -120,14 +118,9 @@ struct PlayerActions
struct Player
{
#if NEW_INPUT_DESIGN
// So far just has an assigned controller.
ControllerState controller;
#else
engine::ControllerState* controller;
#endif
PlayerState state;
PlayerState state;
};
struct GameState