mirror of
https://github.com/Ed94/HandmadeHero.git
synced 2024-12-21 22:14:43 -08:00
Removed old input code post-new design
This commit is contained in:
parent
467c2ee34b
commit
6ac57371e4
@ -69,11 +69,7 @@ Vec2 get_screen_center( OffscreenBuffer* back_buffer )
|
|||||||
internal
|
internal
|
||||||
void input_poll_engine_actions( InputState* input, EngineActions* actions )
|
void input_poll_engine_actions( InputState* input, EngineActions* actions )
|
||||||
{
|
{
|
||||||
#if NEW_INPUT_DESIGN
|
|
||||||
KeyboardState* keyboard = input->keyboard;
|
KeyboardState* keyboard = input->keyboard;
|
||||||
#else
|
|
||||||
KeyboardState* keyboard = input->controllers[0].keyboard;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// actions->move_right |= keyboard->D.EndedDown;
|
// actions->move_right |= keyboard->D.EndedDown;
|
||||||
// actions->move_left |= keyboard->A.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_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;
|
actions->loop_mode_engine |= pressed( keyboard->L ) && keyboard->right_shift.ended_down;
|
||||||
|
|
||||||
#if NEW_INPUT_DESIGN
|
|
||||||
MousesState* mouse = input->mouse;
|
MousesState* mouse = input->mouse;
|
||||||
#else
|
|
||||||
MousesState* mouse = input->controllers[0].mouse;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
actions->move_right = (mouse->horizontal_wheel.end > 0.f) * 20;
|
actions->move_right = (mouse->horizontal_wheel.end > 0.f) * 20;
|
||||||
actions->move_left = (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
|
// TODO(Ed) : Move to handmade module
|
||||||
internal
|
internal
|
||||||
void input_poll_player_actions(
|
void input_poll_player_actions( hh::ControllerState* controller, hh::PlayerActions* actions, b32 is_player_2 )
|
||||||
#if NEW_INPUT_DESIGN
|
|
||||||
hh::ControllerState* controller
|
|
||||||
#else
|
|
||||||
ControllerState* controller
|
|
||||||
#endif
|
|
||||||
, hh::PlayerActions* actions, b32 is_player_2 )
|
|
||||||
{
|
{
|
||||||
if ( controller->ds_pad )
|
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_blue = 0.3f;
|
||||||
|
|
||||||
f32 player_half_width = player->width / 2.f;
|
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 );
|
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 {};
|
||||||
hh::PlayerActions player_actions_2 {};
|
hh::PlayerActions player_actions_2 {};
|
||||||
|
|
||||||
#if NEW_INPUT_DESIGN
|
|
||||||
do_once()
|
do_once()
|
||||||
{
|
{
|
||||||
game_state->player_1.controller.keyboard = input->keyboard;
|
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 )
|
if ( game_state->player_1.controller.ds_pad == ds_pad || game_state->player_2.controller.ds_pad == ds_pad )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ( ds_pad && pressed( ds_pad->share ) )
|
if ( ds_pad && pressed( ds_pad->options ) )
|
||||||
{
|
{
|
||||||
if ( can_assign( player_1 ) )
|
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 )
|
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 );
|
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;
|
World* world = state->context.world;
|
||||||
TileMap* tile_map = world->tile_map;
|
TileMap* tile_map = world->tile_map;
|
||||||
@ -1375,10 +1360,8 @@ void update_and_render( f32 delta_time, InputState* input, OffscreenBuffer* back
|
|||||||
// Player Rendering
|
// Player Rendering
|
||||||
render_player( player, world, game_state, back_buffer );
|
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 )
|
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 );
|
render_player( & game_state->player_state_2, world, game_state, back_buffer );
|
||||||
#endif
|
|
||||||
|
|
||||||
// Snapshot Visual Aid
|
// Snapshot Visual Aid
|
||||||
#if Build_Development
|
#if Build_Development
|
||||||
@ -1410,17 +1393,10 @@ void update_and_render( f32 delta_time, InputState* input, OffscreenBuffer* back
|
|||||||
// Mouse Position
|
// Mouse Position
|
||||||
if ( 0 )
|
if ( 0 )
|
||||||
{
|
{
|
||||||
#if NEW_INPUT_DESIGN
|
|
||||||
draw_rectangle( back_buffer
|
draw_rectangle( back_buffer
|
||||||
, { (f32)input->mouse->X.end, (f32)input->mouse->Y.end }
|
, { (f32)input->mouse->X.end, (f32)input->mouse->Y.end }
|
||||||
, { (f32)input->mouse->X.end + 10.f, (f32)input->mouse->Y.end + 10.f }
|
, { (f32)input->mouse->X.end + 10.f, (f32)input->mouse->Y.end + 10.f }
|
||||||
, 1.f, 1.f, 0.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
|
// Mouse buttons test
|
||||||
|
@ -143,9 +143,6 @@ struct DualsensePadState
|
|||||||
};
|
};
|
||||||
using DualsensePadStates = DualsensePadState*[ Max_Controllers ];
|
using DualsensePadStates = DualsensePadState*[ Max_Controllers ];
|
||||||
|
|
||||||
#define NEW_INPUT_DESIGN 1
|
|
||||||
|
|
||||||
#if NEW_INPUT_DESIGN
|
|
||||||
struct InputStateSnapshot
|
struct InputStateSnapshot
|
||||||
{
|
{
|
||||||
KeyboardState keyboard;
|
KeyboardState keyboard;
|
||||||
@ -153,39 +150,13 @@ struct InputStateSnapshot
|
|||||||
XInputPadState xpads [ Max_Controllers ];
|
XInputPadState xpads [ Max_Controllers ];
|
||||||
DualsensePadState ds_pads[ 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
|
struct InputState
|
||||||
{
|
{
|
||||||
#if NEW_INPUT_DESIGN
|
|
||||||
KeyboardState* keyboard;
|
KeyboardState* keyboard;
|
||||||
MousesState* mouse;
|
MousesState* mouse;
|
||||||
XInputPadStates xpads;
|
XInputPadStates xpads;
|
||||||
DualsensePadStates ds_pads;
|
DualsensePadStates ds_pads;
|
||||||
#else
|
|
||||||
ControllerState controllers[4];
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
using InputBindCallback = void( void* );
|
using InputBindCallback = void( void* );
|
||||||
|
@ -106,7 +106,6 @@ void end_playback_input( Memory* memory, InputState* input, platform::ModuleAPI*
|
|||||||
|
|
||||||
InputStateSnapshot input_state_snapshot( InputState* input )
|
InputStateSnapshot input_state_snapshot( InputState* input )
|
||||||
{
|
{
|
||||||
#if NEW_INPUT_DESIGN
|
|
||||||
InputStateSnapshot snapshot = {};
|
InputStateSnapshot snapshot = {};
|
||||||
if ( input->keyboard )
|
if ( input->keyboard )
|
||||||
snapshot.keyboard = * input->keyboard;
|
snapshot.keyboard = * input->keyboard;
|
||||||
@ -125,28 +124,6 @@ InputStateSnapshot input_state_snapshot( InputState* input )
|
|||||||
snapshot.ds_pads[ idx ] = * ds_pad;
|
snapshot.ds_pads[ idx ] = * ds_pad;
|
||||||
}
|
}
|
||||||
return snapshot;
|
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
|
internal
|
||||||
@ -170,7 +147,6 @@ void play_input( SnapshotFn* load_snapshot, Memory* memory, InputState* input, p
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if NEW_INPUT_DESIGN
|
|
||||||
if ( input->keyboard )
|
if ( input->keyboard )
|
||||||
* input->keyboard = new_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 )
|
if ( ds_pad )
|
||||||
* ds_pad = new_input.ds_pads[ idx ];
|
* 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
|
void process_loop_mode( SnapshotFn* take_snapshot, SnapshotFn* load_snapshot
|
||||||
|
@ -61,7 +61,6 @@ struct ActionableMode
|
|||||||
Player : Controller, Actionables, ActionSets
|
Player : Controller, Actionables, ActionSets
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if NEW_INPUT_DESIGN
|
|
||||||
struct ControllerState
|
struct ControllerState
|
||||||
{
|
{
|
||||||
engine::KeyboardState* keyboard;
|
engine::KeyboardState* keyboard;
|
||||||
@ -69,7 +68,6 @@ struct ControllerState
|
|||||||
engine::XInputPadState* xpad;
|
engine::XInputPadState* xpad;
|
||||||
engine::DualsensePadState* ds_pad;
|
engine::DualsensePadState* ds_pad;
|
||||||
};
|
};
|
||||||
#endif
|
|
||||||
|
|
||||||
enum EHeroBitmapsDirection : u32
|
enum EHeroBitmapsDirection : u32
|
||||||
{
|
{
|
||||||
@ -120,14 +118,9 @@ struct PlayerActions
|
|||||||
|
|
||||||
struct Player
|
struct Player
|
||||||
{
|
{
|
||||||
#if NEW_INPUT_DESIGN
|
|
||||||
// So far just has an assigned controller.
|
// So far just has an assigned controller.
|
||||||
ControllerState controller;
|
ControllerState controller;
|
||||||
#else
|
PlayerState state;
|
||||||
engine::ControllerState* controller;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
PlayerState state;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct GameState
|
struct GameState
|
||||||
|
Loading…
Reference in New Issue
Block a user