mirror of
https://github.com/Maschell/PushA_NX.git
synced 2024-11-25 01:06:53 +01:00
Added handheld controls
This commit is contained in:
parent
747ff207c0
commit
e71fac665b
@ -5,8 +5,6 @@ Based on: https://github.com/vgmoose/sdl-hello-world
|
|||||||
Back to the roots. Back in 2008 I started with writing homebrew on Wii. The first "game" I created was "Push A".
|
Back to the roots. Back in 2008 I started with writing homebrew on Wii. The first "game" I created was "Push A".
|
||||||
Now, almost 10 years later, I quickly wrote a new version for the Switch.
|
Now, almost 10 years later, I quickly wrote a new version for the Switch.
|
||||||
|
|
||||||
Maybe only works with detached Joy-Cons.
|
|
||||||
|
|
||||||
Have fun!
|
Have fun!
|
||||||
|
|
||||||
Huge thanks to vgmoose, based on his examples!.
|
Huge thanks to vgmoose, based on his examples!.
|
||||||
|
27
input.c
27
input.c
@ -9,16 +9,7 @@ void PADDestroy(){
|
|||||||
hid_finalize();
|
hid_finalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PADRead(struct PADData* data){
|
static void readInputInternal(struct PADData* data,hid_controller_state_entry_t ent ){
|
||||||
// reset buttons
|
|
||||||
data->btns_h = 0b00000000;
|
|
||||||
|
|
||||||
// scan for controller
|
|
||||||
hid_controller_t* num8 = hid_get_shared_memory()->controllers;
|
|
||||||
|
|
||||||
hid_controller_state_entry_t ent = num8->main.entries[num8->main.latest_idx];
|
|
||||||
|
|
||||||
// process inputs
|
|
||||||
data->btns_h |= ((ent.button_state & JOYPAD_A)? BUTTON_A : 0);
|
data->btns_h |= ((ent.button_state & JOYPAD_A)? BUTTON_A : 0);
|
||||||
data->btns_h |= ((ent.button_state & JOYPAD_B)? BUTTON_B : 0);
|
data->btns_h |= ((ent.button_state & JOYPAD_B)? BUTTON_B : 0);
|
||||||
data->btns_h |= ((ent.button_state & JOYPAD_UP)? BUTTON_UP : 0);
|
data->btns_h |= ((ent.button_state & JOYPAD_UP)? BUTTON_UP : 0);
|
||||||
@ -28,3 +19,19 @@ void PADRead(struct PADData* data){
|
|||||||
data->btns_h |= ((ent.button_state & JOYPAD_START)? BUTTON_PLUS : 0);
|
data->btns_h |= ((ent.button_state & JOYPAD_START)? BUTTON_PLUS : 0);
|
||||||
data->btns_h |= ((ent.button_state & JOYPAD_SELECT)? BUTTON_MINUS : 0);
|
data->btns_h |= ((ent.button_state & JOYPAD_SELECT)? BUTTON_MINUS : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PADRead(struct PADData* data){
|
||||||
|
// reset buttons
|
||||||
|
data->btns_h = 0b00000000;
|
||||||
|
|
||||||
|
// scan for controller
|
||||||
|
hid_controller_t* num = hid_get_shared_memory()->controllers;
|
||||||
|
hid_controller_t* num8 = hid_get_shared_memory()->controllers;
|
||||||
|
|
||||||
|
hid_controller_state_entry_t ent = num->main.entries[num->main.latest_idx];
|
||||||
|
hid_controller_state_entry_t ent8 = num8->main.entries[num8->main.latest_idx];
|
||||||
|
|
||||||
|
// process inputs
|
||||||
|
readInputInternal(data,ent);
|
||||||
|
readInputInternal(data,ent8);
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user