mirror of
https://github.com/CTCaer/RetroArch.git
synced 2025-02-12 06:51:16 +00:00
implement a very basic input driver, will need to be implemented
correctly later.
This commit is contained in:
parent
b8bd59ae06
commit
27bd10b21d
@ -279,7 +279,7 @@ static bool ctr_frame(void* data, const void* frame,
|
||||
}
|
||||
|
||||
hidScanInput();
|
||||
u32 kDown = hidKeysDown();
|
||||
u32 kDown = hidKeysHeld();
|
||||
if (kDown & KEY_START)
|
||||
{
|
||||
rarch_main_command(RARCH_CMD_QUIT);
|
||||
|
@ -13,20 +13,43 @@
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "3ds.h"
|
||||
|
||||
#include "../../general.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;
|
||||
}
|
||||
|
||||
static void ctrinput_input_poll(void *data)
|
||||
{
|
||||
static void ctr_input_poll(void *data)
|
||||
{
|
||||
(void)data;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
static int16_t ctrinput_input_state(void *data,
|
||||
static int16_t ctr_input_state(void *data,
|
||||
const struct retro_keybind **retro_keybinds, unsigned port,
|
||||
unsigned device, unsigned idx, unsigned id)
|
||||
{
|
||||
@ -37,23 +60,34 @@ static int16_t ctrinput_input_state(void *data,
|
||||
(void)idx;
|
||||
(void)id;
|
||||
|
||||
if (port > 0)
|
||||
return 0;
|
||||
|
||||
switch (device)
|
||||
{
|
||||
case RETRO_DEVICE_JOYPAD:
|
||||
return pad_state;
|
||||
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
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)key;
|
||||
|
||||
return false;
|
||||
return (pad_state & (1ULL << key));
|
||||
}
|
||||
|
||||
static void ctrinput_input_free_input(void *data)
|
||||
static void ctr_input_free_input(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;
|
||||
|
||||
@ -62,19 +96,19 @@ static uint64_t ctrinput_get_capabilities(void *data)
|
||||
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)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
static void ctrinput_grab_mouse(void *data, bool state)
|
||||
static void ctr_input_grab_mouse(void *data, bool state)
|
||||
{
|
||||
(void)data;
|
||||
(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)
|
||||
{
|
||||
(void)data;
|
||||
@ -86,15 +120,15 @@ static bool ctrinput_set_rumble(void *data, unsigned port,
|
||||
}
|
||||
|
||||
input_driver_t input_ctr = {
|
||||
ctrinput_input_init,
|
||||
ctrinput_input_poll,
|
||||
ctrinput_input_state,
|
||||
ctrinput_input_key_pressed,
|
||||
ctrinput_input_free_input,
|
||||
ctrinput_set_sensor_state,
|
||||
ctr_input_init,
|
||||
ctr_input_poll,
|
||||
ctr_input_state,
|
||||
ctr_input_key_pressed,
|
||||
ctr_input_free_input,
|
||||
ctr_input_set_sensor_state,
|
||||
NULL,
|
||||
ctrinput_get_capabilities,
|
||||
ctr_input_get_capabilities,
|
||||
"ctr",
|
||||
ctrinput_grab_mouse,
|
||||
ctrinput_set_rumble,
|
||||
ctr_input_grab_mouse,
|
||||
ctr_input_set_rumble,
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user