From 7f004aee71fb49c00e7f823576e66f42cc245c40 Mon Sep 17 00:00:00 2001 From: radius Date: Sat, 30 Apr 2016 22:49:51 -0500 Subject: [PATCH] Complete basic implementation of retropad remote (windows only atm) --- cores/retropad/retropad.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/cores/retropad/retropad.c b/cores/retropad/retropad.c index 6c59da0155..900fb86805 100644 --- a/cores/retropad/retropad.c +++ b/cores/retropad/retropad.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2015 - Daniel De Matteis - * Copyright (C) 2012-2015 - Michael Lelli + * Copyright (C) 2016 - Andrés Suárez * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- @@ -15,6 +15,15 @@ * If not, see . */ +/* + * To-do: + * - Analog support + * - Some sort of connection control, it only sends packets + * but there is no acknoledgement of a connection o keepalives + * - Send player name + * - Render something on-screen +*/ + #include #include #include @@ -94,7 +103,6 @@ void retro_get_system_info( info->valid_extensions = ""; /* Nothing. */ } -/* Doesn't really matter, but need something sane. */ void retro_get_system_av_info( struct retro_system_av_info *info) { @@ -119,6 +127,14 @@ void update_input() { input_state = 0; input_poll_cb(); + if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B)) + input_state += 1; + if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A)) + input_state += 2; + if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT)) + input_state += pow(2, 2); + if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START)) + input_state += pow(2, 3); if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP)) input_state += pow(2, 4); if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN)) @@ -127,6 +143,14 @@ void update_input() input_state += pow(2, 6); if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT)) input_state += pow(2, 7); + if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_Y)) + input_state += pow(2, 8); + if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_X)) + input_state += pow(2, 9); + if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L)) + input_state += pow(2, 10); + if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R)) + input_state += pow(2, 11); } void retro_set_environment(retro_environment_t cb) @@ -187,7 +211,6 @@ void retro_run(void) video_cb(frame_buf, 320, 240, 640); } -/* This should never be called, it's only used as a placeholder. */ bool retro_load_game(const struct retro_game_info *info) { (void)info;