gameskunk advance specific input system
This commit is contained in:
parent
131031a4f9
commit
a67fd544a6
|
@ -26,10 +26,8 @@ void init() {
|
||||||
void tick() {
|
void tick() {
|
||||||
i32 x, y;
|
i32 x, y;
|
||||||
|
|
||||||
x = sw_gamepads[0].button_down[SW_GAMEPAD_BUTTON_DPAD_LEFT] -
|
x = input.down.dpad_left - input.down.dpad_right;
|
||||||
sw_gamepads[0].button_down[SW_GAMEPAD_BUTTON_DPAD_RIGHT];
|
y = input.down.dpad_up - input.down.dpad_down;
|
||||||
y = sw_gamepads[0].button_down[SW_GAMEPAD_BUTTON_DPAD_UP] -
|
|
||||||
sw_gamepads[0].button_down[SW_GAMEPAD_BUTTON_DPAD_DOWN];
|
|
||||||
|
|
||||||
maps[0].scrollx -= x;
|
maps[0].scrollx -= x;
|
||||||
maps[0].scrolly -= y;
|
maps[0].scrolly -= y;
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include "embed_gfx.h"
|
#include "embed_gfx.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "gsa_input.h"
|
||||||
#include "skunkworks.h"
|
#include "skunkworks.h"
|
||||||
#include "vec2i.h"
|
#include "vec2i.h"
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
#ifndef GUARD_E847906A380863BFA9BE2CD8BC8943DA
|
||||||
|
#define GUARD_E847906A380863BFA9BE2CD8BC8943DA
|
||||||
|
|
||||||
|
#include "types.h"
|
||||||
|
|
||||||
|
struct _gsa_input_set {
|
||||||
|
bool dpad_up, dpad_down, dpad_left, dpad_right, face_up, face_down,
|
||||||
|
face_left, face_right, l, r, start, select;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct gsa_input {
|
||||||
|
struct _gsa_input_set down, pressed;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern struct gsa_input input;
|
||||||
|
|
||||||
|
void _gsa_input_tick();
|
||||||
|
|
||||||
|
#endif /* GUARD_E847906A380863BFA9BE2CD8BC8943DA */
|
|
@ -46,6 +46,7 @@ skunk_sources = [
|
||||||
'src/framebuffer.c',
|
'src/framebuffer.c',
|
||||||
'src/gamepad.c',
|
'src/gamepad.c',
|
||||||
'src/gsa.c',
|
'src/gsa.c',
|
||||||
|
'src/gsa_input.c',
|
||||||
'src/image32.c',
|
'src/image32.c',
|
||||||
'src/image8.c',
|
'src/image8.c',
|
||||||
'src/scaler.c',
|
'src/scaler.c',
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#define GSA_NOMAIN
|
#define GSA_NOMAIN
|
||||||
#include "gsa.h"
|
#include "gsa.h"
|
||||||
|
#include "gsa_input.h"
|
||||||
|
|
||||||
struct gsa_sprite sprites[256];
|
struct gsa_sprite sprites[256];
|
||||||
struct gsa_map maps[MAX_TILEMAPS];
|
struct gsa_map maps[MAX_TILEMAPS];
|
||||||
|
@ -166,6 +167,8 @@ static void update_palette_gl() {
|
||||||
void _gsa_tick() {
|
void _gsa_tick() {
|
||||||
i32 i, x, y, startx, starty, endx, endy;
|
i32 i, x, y, startx, starty, endx, endy;
|
||||||
|
|
||||||
|
_gsa_input_tick();
|
||||||
|
|
||||||
tick();
|
tick();
|
||||||
|
|
||||||
next_render_vert = 0;
|
next_render_vert = 0;
|
||||||
|
|
|
@ -0,0 +1,58 @@
|
||||||
|
#include "gsa_input.h"
|
||||||
|
#include "gamepad.h"
|
||||||
|
|
||||||
|
struct gsa_input input;
|
||||||
|
|
||||||
|
void _gsa_input_tick() {
|
||||||
|
u8 gamepad = 0;
|
||||||
|
|
||||||
|
input.pressed.dpad_down =
|
||||||
|
sw_gamepads[gamepad].button_pressed[SW_GAMEPAD_BUTTON_DPAD_DOWN];
|
||||||
|
input.pressed.dpad_up =
|
||||||
|
sw_gamepads[gamepad].button_pressed[SW_GAMEPAD_BUTTON_DPAD_UP];
|
||||||
|
input.pressed.dpad_left =
|
||||||
|
sw_gamepads[gamepad].button_pressed[SW_GAMEPAD_BUTTON_DPAD_LEFT];
|
||||||
|
input.pressed.dpad_right =
|
||||||
|
sw_gamepads[gamepad].button_pressed[SW_GAMEPAD_BUTTON_DPAD_RIGHT];
|
||||||
|
input.pressed.face_down =
|
||||||
|
sw_gamepads[gamepad].button_pressed[SW_GAMEPAD_BUTTON_FACE_DOWN];
|
||||||
|
input.pressed.face_up =
|
||||||
|
sw_gamepads[gamepad].button_pressed[SW_GAMEPAD_BUTTON_FACE_UP];
|
||||||
|
input.pressed.face_left =
|
||||||
|
sw_gamepads[gamepad].button_pressed[SW_GAMEPAD_BUTTON_FACE_LEFT];
|
||||||
|
input.pressed.face_right =
|
||||||
|
sw_gamepads[gamepad].button_pressed[SW_GAMEPAD_BUTTON_FACE_RIGHT];
|
||||||
|
input.pressed.l =
|
||||||
|
sw_gamepads[gamepad].button_pressed[SW_GAMEPAD_BUTTON_LEFT_SHOULDER];
|
||||||
|
input.pressed.r =
|
||||||
|
sw_gamepads[gamepad].button_pressed[SW_GAMEPAD_BUTTON_RIGHT_SHOULDER];
|
||||||
|
input.pressed.select =
|
||||||
|
sw_gamepads[gamepad].button_pressed[SW_GAMEPAD_BUTTON_BACK];
|
||||||
|
input.pressed.start =
|
||||||
|
sw_gamepads[gamepad].button_pressed[SW_GAMEPAD_BUTTON_START];
|
||||||
|
|
||||||
|
input.down.dpad_down =
|
||||||
|
sw_gamepads[gamepad].button_down[SW_GAMEPAD_BUTTON_DPAD_DOWN];
|
||||||
|
input.down.dpad_up =
|
||||||
|
sw_gamepads[gamepad].button_down[SW_GAMEPAD_BUTTON_DPAD_UP];
|
||||||
|
input.down.dpad_left =
|
||||||
|
sw_gamepads[gamepad].button_down[SW_GAMEPAD_BUTTON_DPAD_LEFT];
|
||||||
|
input.down.dpad_right =
|
||||||
|
sw_gamepads[gamepad].button_down[SW_GAMEPAD_BUTTON_DPAD_RIGHT];
|
||||||
|
input.down.face_down =
|
||||||
|
sw_gamepads[gamepad].button_down[SW_GAMEPAD_BUTTON_FACE_DOWN];
|
||||||
|
input.down.face_up =
|
||||||
|
sw_gamepads[gamepad].button_down[SW_GAMEPAD_BUTTON_FACE_UP];
|
||||||
|
input.down.face_left =
|
||||||
|
sw_gamepads[gamepad].button_down[SW_GAMEPAD_BUTTON_FACE_LEFT];
|
||||||
|
input.down.face_right =
|
||||||
|
sw_gamepads[gamepad].button_down[SW_GAMEPAD_BUTTON_FACE_RIGHT];
|
||||||
|
input.down.l =
|
||||||
|
sw_gamepads[gamepad].button_down[SW_GAMEPAD_BUTTON_LEFT_SHOULDER];
|
||||||
|
input.down.r =
|
||||||
|
sw_gamepads[gamepad].button_down[SW_GAMEPAD_BUTTON_RIGHT_SHOULDER];
|
||||||
|
input.down.select =
|
||||||
|
sw_gamepads[gamepad].button_down[SW_GAMEPAD_BUTTON_BACK];
|
||||||
|
input.down.start =
|
||||||
|
sw_gamepads[gamepad].button_down[SW_GAMEPAD_BUTTON_START];
|
||||||
|
}
|
Loading…
Reference in New Issue