mirror of
https://github.com/libretro/RetroArch
synced 2025-03-04 16:13:50 +00:00
Merge pull request #1562 from aliaspider/master
add basic input functionality to allow navigating the menu.
This commit is contained in:
commit
60763ded86
@ -278,26 +278,12 @@ static bool ctr_frame(void* data, const void* frame,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
hidScanInput();
|
|
||||||
u32 kDown = hidKeysDown();
|
|
||||||
if (kDown & KEY_START)
|
|
||||||
{
|
|
||||||
rarch_main_command(RARCH_CMD_QUIT);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
printf("frames: %i\r", frames++);fflush(stdout);
|
printf("frames: %i\r", frames++);fflush(stdout);
|
||||||
// gfxFlushBuffers();
|
// gfxFlushBuffers();
|
||||||
// gspWaitForEvent(GSPEVENT_VBlank0, true);
|
// gspWaitForEvent(GSPEVENT_VBlank0, true);
|
||||||
|
|
||||||
u32 backgroundColor = 0x00000000;
|
u32 backgroundColor = 0x00000000;
|
||||||
|
|
||||||
// hidScanInput();
|
|
||||||
// u32 kDown = hidKeysDown();
|
|
||||||
|
|
||||||
// if (kDown & KEY_START) rarch_main_command(RARCH_CMD_QUIT); // break in order to return to hbmenu
|
|
||||||
|
|
||||||
GPUCMD_SetBufferOffset(0);
|
GPUCMD_SetBufferOffset(0);
|
||||||
GPU_SetFloatUniform(GPU_VERTEX_SHADER,
|
GPU_SetFloatUniform(GPU_VERTEX_SHADER,
|
||||||
shaderInstanceGetUniformLocation(shader.vertexShader, "projection"),
|
shaderInstanceGetUniformLocation(shader.vertexShader, "projection"),
|
||||||
|
@ -13,20 +13,56 @@
|
|||||||
* If not, see <http://www.gnu.org/licenses/>.
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "3ds.h"
|
||||||
|
|
||||||
#include "../../general.h"
|
#include "../../general.h"
|
||||||
#include "../../driver.h"
|
#include "../../driver.h"
|
||||||
|
|
||||||
static void *ctrinput_input_init(void)
|
|
||||||
|
static uint32_t kDown;
|
||||||
|
static int16_t pad_state;
|
||||||
|
|
||||||
|
static void *ctr_input_init(void)
|
||||||
{
|
{
|
||||||
return (void*)-1;
|
return (void*)-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ctrinput_input_poll(void *data)
|
static void ctr_input_poll(void *data)
|
||||||
{
|
{
|
||||||
(void)data;
|
(void)data;
|
||||||
|
global_t *global = global_get_ptr();
|
||||||
|
uint64_t *lifecycle_state = (uint64_t*)&global->lifecycle_state;
|
||||||
|
|
||||||
|
hidScanInput();
|
||||||
|
kDown = hidKeysHeld();
|
||||||
|
|
||||||
|
pad_state = 0;
|
||||||
|
pad_state |= (kDown & KEY_DLEFT) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_LEFT) : 0;
|
||||||
|
pad_state |= (kDown & KEY_DDOWN) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_DOWN) : 0;
|
||||||
|
pad_state |= (kDown & KEY_DRIGHT) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_RIGHT) : 0;
|
||||||
|
pad_state |= (kDown & KEY_DUP) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_UP) : 0;
|
||||||
|
pad_state |= (kDown & KEY_START) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_START) : 0;
|
||||||
|
pad_state |= (kDown & KEY_SELECT) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_SELECT) : 0;
|
||||||
|
pad_state |= (kDown & KEY_X) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_X) : 0;
|
||||||
|
pad_state |= (kDown & KEY_Y) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_Y) : 0;
|
||||||
|
pad_state |= (kDown & KEY_B) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_B) : 0;
|
||||||
|
pad_state |= (kDown & KEY_A) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_A) : 0;
|
||||||
|
pad_state |= (kDown & KEY_R) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_R) : 0;
|
||||||
|
pad_state |= (kDown & KEY_L) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_L) : 0;
|
||||||
|
|
||||||
|
|
||||||
|
*lifecycle_state &= ~((1ULL << RARCH_MENU_TOGGLE));
|
||||||
|
|
||||||
|
if (
|
||||||
|
(pad_state & (1ULL << RETRO_DEVICE_ID_JOYPAD_L))
|
||||||
|
&& (pad_state & (1ULL << RETRO_DEVICE_ID_JOYPAD_R))
|
||||||
|
&& (pad_state & (1ULL << RETRO_DEVICE_ID_JOYPAD_SELECT))
|
||||||
|
&& (pad_state & (1ULL << RETRO_DEVICE_ID_JOYPAD_START))
|
||||||
|
)
|
||||||
|
*lifecycle_state |= (1ULL << RARCH_MENU_TOGGLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int16_t ctrinput_input_state(void *data,
|
static int16_t ctr_input_state(void *data,
|
||||||
const struct retro_keybind **retro_keybinds, unsigned port,
|
const struct retro_keybind **retro_keybinds, unsigned port,
|
||||||
unsigned device, unsigned idx, unsigned id)
|
unsigned device, unsigned idx, unsigned id)
|
||||||
{
|
{
|
||||||
@ -37,23 +73,36 @@ static int16_t ctrinput_input_state(void *data,
|
|||||||
(void)idx;
|
(void)idx;
|
||||||
(void)id;
|
(void)id;
|
||||||
|
|
||||||
|
if (port > 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
switch (device)
|
||||||
|
{
|
||||||
|
case RETRO_DEVICE_JOYPAD:
|
||||||
|
return pad_state;
|
||||||
|
|
||||||
|
case RETRO_DEVICE_ANALOG:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool ctrinput_input_key_pressed(void *data, int key)
|
static bool ctr_input_key_pressed(void *data, int key)
|
||||||
{
|
{
|
||||||
(void)data;
|
(void)data;
|
||||||
(void)key;
|
global_t *global = global_get_ptr();
|
||||||
|
|
||||||
return false;
|
return (global->lifecycle_state & (1ULL << key))||
|
||||||
|
(pad_state & (1ULL << key));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ctrinput_input_free_input(void *data)
|
static void ctr_input_free_input(void *data)
|
||||||
{
|
{
|
||||||
(void)data;
|
(void)data;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint64_t ctrinput_get_capabilities(void *data)
|
static uint64_t ctr_input_get_capabilities(void *data)
|
||||||
{
|
{
|
||||||
uint64_t caps = 0;
|
uint64_t caps = 0;
|
||||||
|
|
||||||
@ -62,19 +111,19 @@ static uint64_t ctrinput_get_capabilities(void *data)
|
|||||||
return caps;
|
return caps;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool ctrinput_set_sensor_state(void *data,
|
static bool ctr_input_set_sensor_state(void *data,
|
||||||
unsigned port, enum retro_sensor_action action, unsigned event_rate)
|
unsigned port, enum retro_sensor_action action, unsigned event_rate)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ctrinput_grab_mouse(void *data, bool state)
|
static void ctr_input_grab_mouse(void *data, bool state)
|
||||||
{
|
{
|
||||||
(void)data;
|
(void)data;
|
||||||
(void)state;
|
(void)state;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool ctrinput_set_rumble(void *data, unsigned port,
|
static bool ctr_input_set_rumble(void *data, unsigned port,
|
||||||
enum retro_rumble_effect effect, uint16_t strength)
|
enum retro_rumble_effect effect, uint16_t strength)
|
||||||
{
|
{
|
||||||
(void)data;
|
(void)data;
|
||||||
@ -86,15 +135,15 @@ static bool ctrinput_set_rumble(void *data, unsigned port,
|
|||||||
}
|
}
|
||||||
|
|
||||||
input_driver_t input_ctr = {
|
input_driver_t input_ctr = {
|
||||||
ctrinput_input_init,
|
ctr_input_init,
|
||||||
ctrinput_input_poll,
|
ctr_input_poll,
|
||||||
ctrinput_input_state,
|
ctr_input_state,
|
||||||
ctrinput_input_key_pressed,
|
ctr_input_key_pressed,
|
||||||
ctrinput_input_free_input,
|
ctr_input_free_input,
|
||||||
ctrinput_set_sensor_state,
|
ctr_input_set_sensor_state,
|
||||||
NULL,
|
NULL,
|
||||||
ctrinput_get_capabilities,
|
ctr_input_get_capabilities,
|
||||||
"ctr",
|
"ctr",
|
||||||
ctrinput_grab_mouse,
|
ctr_input_grab_mouse,
|
||||||
ctrinput_set_rumble,
|
ctr_input_set_rumble,
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user