diff --git a/cores/libretro-net-retropad/net_retropad_core.c b/cores/libretro-net-retropad/net_retropad_core.c index bedf072ad00..27e6d02f54f 100644 --- a/cores/libretro-net-retropad/net_retropad_core.c +++ b/cores/libretro-net-retropad/net_retropad_core.c @@ -85,6 +85,8 @@ static retro_input_state_t NETRETROPAD_CORE_PREFIX(input_state_cb); static uint16_t *frame_buf; +static unsigned input_state_validated = 0; + static struct descriptor joypad = { .device = RETRO_DEVICE_JOYPAD, .port_min = 0, @@ -338,7 +340,7 @@ void NETRETROPAD_CORE_PREFIX(retro_run)(void) { int i; unsigned rle; - unsigned input_state = 0; + uint32_t input_state = 0; uint16_t *pixel = frame_buf + 49 * 320 + 32; /* Update input states and send them if needed */ @@ -352,6 +354,32 @@ void NETRETROPAD_CORE_PREFIX(retro_run)(void) input_state |= 1 << i; } + for (i = analog.id_min; i <= analog.id_max; i++) + { + /* bitmap: x-- x- x+ x++ y-- y- y+ y++*/ + /* default analog deadzone: 0.0 - increased for convenience, default analog threshold: 0.5 */ + int offset = DESC_OFFSET(&analog, 0, RETRO_DEVICE_INDEX_ANALOG_LEFT, i); + if ( (int16_t)analog.value[offset] < -32766/2) + input_state |= 1 << (16 + i*8 + 0); + else if ((int16_t)analog.value[offset] < -3276) + input_state |= 1 << (16 + i*8 + 1); + else if ((int16_t)analog.value[offset] > 32768/2) + input_state |= 1 << (16 + i*8 + 3); + else if ((int16_t)analog.value[offset] > 3276) + input_state |= 1 << (16 + i*8 + 2); + + offset = DESC_OFFSET(&analog, 0, RETRO_DEVICE_INDEX_ANALOG_RIGHT, i); + if ( (int16_t)analog.value[offset] < -32766/2) + input_state |= 1 << (16 + i*8 + 4); + else if ((int16_t)analog.value[offset] < -3276) + input_state |= 1 << (16 + i*8 + 5); + else if ((int16_t)analog.value[offset] > 32768/2) + input_state |= 1 << (16 + i*8 + 7); + else if ((int16_t)analog.value[offset] > 3276) + input_state |= 1 << (16 + i*8 + 6); + + } + for (rle = 0; rle < sizeof(retropad_buttons); ) { unsigned runs; @@ -364,7 +392,20 @@ void NETRETROPAD_CORE_PREFIX(retro_run)(void) if (paint) { unsigned count; - uint16_t color = (input_state & button) ? 0x0500 : 0xffff; + uint16_t color; + + if (input_state & button) + { + color = 0xA000; + input_state_validated |= button; + } + else + { + if (input_state_validated & button ) + color = 0xbff7; + else + color = 0xffff; + } for (count = retropad_buttons[rle++]; count > 0; count--) *pixel++ = color; diff --git a/cores/libretro-net-retropad/remotepad.h b/cores/libretro-net-retropad/remotepad.h index 13bab172409..8a058d7ac50 100644 --- a/cores/libretro-net-retropad/remotepad.h +++ b/cores/libretro-net-retropad/remotepad.h @@ -149,6 +149,8 @@ static uint8_t body[] = /* sizeof( body ) = 721 */ +/* Run-length-encoded format, serialized. */ +/* Number of segments - initial empty space [ - button ID - size of button - empty space]* */ static uint8_t retropad_buttons[] = { /* 0 */ 5, 38, 12, 13, 154, 13, 13, 37, @@ -238,63 +240,63 @@ static uint8_t retropad_buttons[] = /* 84 */ 13, 24, 6, 14, 16, 7, 13, 30, 2, 14, 34, 3, 14, 20, 1, 18, 27, 8, 18, 13, /* 85 */ 9, 24, 6, 13, 18, 7, 12, 112, 1, 18, 27, 8, 17, 14, /* 86 */ 9, 24, 6, 12, 20, 7, 11, 113, 1, 17, 27, 8, 17, 14, - /* 87 */ 13, 24, 6, 11, 10, 5, 1, 11, 7, 10, 57, 16, 8, 48, 1, 16, 29, 8, 16, 14, - /* 88 */ 9, 44, 5, 3, 75, 16, 12, 47, 1, 14, 31, 8, 14, 15, - /* 89 */ 9, 43, 5, 5, 73, 16, 14, 47, 1, 12, 33, 8, 12, 16, - /* 90 */ 9, 42, 5, 7, 71, 16, 16, 48, 1, 9, 35, 8, 9, 18, - /* 91 */ 5, 41, 5, 9, 70, 16, 16, 119, - /* 92 */ 5, 40, 5, 11, 68, 16, 18, 118, - /* 93 */ 7, 39, 5, 13, 67, 16, 18, 70, 0, 7, 41, - /* 94 */ 7, 39, 5, 13, 67, 16, 18, 68, 0, 11, 39, - /* 95 */ 7, 39, 5, 13, 67, 16, 18, 67, 0, 13, 38, - /* 96 */ 7, 39, 5, 13, 67, 16, 18, 66, 0, 15, 37, - /* 97 */ 7, 39, 5, 13, 67, 16, 17, 66, 0, 17, 36, - /* 98 */ 7, 39, 5, 13, 68, 16, 16, 66, 0, 17, 36, - /* 99 */ 7, 39, 5, 13, 68, 16, 15, 66, 0, 18, 36, - /* 100 */ 7, 39, 5, 13, 69, 16, 13, 67, 0, 18, 36, - /* 101 */ 5, 123, 16, 10, 68, 0, 18, 36, - /* 102 */ 5, 125, 16, 5, 71, 0, 18, 36, + /* 87 */ 11, 24, 6, 11, 10, 5, 1, 11, 7, 10, 113, 1, 16, 29, 8, 16, 14, + /* 88 */ 7, 44, 5, 3, 134, 1, 14, 31, 8, 14, 15, + /* 89 */ 7, 43, 5, 5, 134, 1, 12, 33, 8, 12, 16, + /* 90 */ 7, 42, 5, 7, 135, 1, 9, 35, 8, 9, 18, + /* 91 */ 3, 41, 5, 9, 205, + /* 92 */ 3, 40, 5, 11, 204, + /* 93 */ 5, 39, 5, 13, 155, 0, 7, 41, + /* 94 */ 5, 39, 5, 13, 153, 0, 11, 39, + /* 95 */ 5, 39, 5, 13, 152, 0, 13, 38, + /* 96 */ 5, 39, 5, 13, 151, 0, 15, 37, + /* 97 */ 5, 39, 5, 13, 150, 0, 17, 36, + /* 98 */ 5, 39, 5, 13, 150, 0, 17, 36, + /* 99 */ 5, 39, 5, 13, 149, 0, 18, 36, + /* 100 */ 5, 39, 5, 13, 149, 0, 18, 36, + /* 101 */ 3, 201, 0, 18, 36, + /* 102 */ 3, 201, 0, 18, 36, /* 103 */ 3, 202, 0, 17, 36, - /* 104 */ 7, 82, 14, 9, 75, 15, 8, 28, 0, 17, 36, - /* 105 */ 7, 79, 14, 15, 69, 15, 14, 26, 0, 15, 37, - /* 106 */ 7, 77, 14, 19, 65, 15, 18, 25, 0, 13, 38, - /* 107 */ 7, 76, 14, 21, 62, 15, 22, 24, 0, 11, 39, - /* 108 */ 7, 75, 14, 23, 60, 15, 24, 25, 0, 7, 41, - /* 109 */ 5, 74, 14, 25, 58, 15, 26, 72, - /* 110 */ 5, 73, 14, 27, 56, 15, 28, 71, - /* 111 */ 5, 72, 14, 29, 55, 15, 28, 71, - /* 112 */ 5, 71, 14, 31, 53, 15, 30, 70, - /* 113 */ 5, 71, 14, 31, 52, 15, 32, 69, - /* 114 */ 5, 70, 14, 33, 51, 15, 32, 69, - /* 115 */ 5, 70, 14, 33, 50, 15, 34, 68, - /* 116 */ 5, 70, 14, 33, 50, 15, 34, 68, - /* 117 */ 5, 69, 14, 35, 49, 15, 34, 68, - /* 118 */ 5, 69, 14, 35, 49, 15, 34, 68, - /* 119 */ 5, 69, 14, 35, 49, 15, 34, 68, - /* 120 */ 5, 69, 14, 35, 48, 15, 36, 67, - /* 121 */ 5, 69, 14, 35, 48, 15, 36, 67, - /* 122 */ 5, 69, 14, 35, 48, 15, 36, 67, - /* 123 */ 5, 69, 14, 35, 49, 15, 34, 68, - /* 124 */ 5, 69, 14, 35, 49, 15, 34, 68, - /* 125 */ 5, 69, 14, 35, 49, 15, 34, 68, - /* 126 */ 5, 70, 14, 33, 50, 15, 34, 68, - /* 127 */ 5, 70, 14, 33, 50, 15, 34, 68, - /* 128 */ 5, 70, 14, 33, 51, 15, 32, 69, - /* 129 */ 5, 71, 14, 31, 52, 15, 32, 69, - /* 130 */ 5, 71, 14, 31, 53, 15, 30, 70, - /* 131 */ 5, 72, 14, 29, 55, 15, 28, 71, - /* 132 */ 5, 73, 14, 27, 56, 15, 28, 71, - /* 133 */ 5, 74, 14, 25, 58, 15, 26, 72, - /* 134 */ 5, 75, 14, 23, 60, 15, 24, 73, - /* 135 */ 5, 76, 14, 21, 62, 15, 22, 74, - /* 136 */ 5, 77, 14, 19, 65, 15, 18, 76, - /* 137 */ 5, 79, 14, 15, 69, 15, 14, 78, - /* 138 */ 5, 82, 14, 9, 75, 15, 8, 81, + /* 104 */ 7, 84, 24, 5, 78, 28, 5, 30, 0, 17, 36, + /* 105 */ 7, 82, 24, 9, 74, 28, 9, 29, 0, 15, 37, + /* 106 */ 7, 82, 24, 9, 74, 28, 9, 30, 0, 13, 38, + /* 107 */ 7, 82, 24, 9, 74, 28, 9, 31, 0, 11, 39, + /* 108 */ 11, 82, 24, 3, 3, 24, 3, 74, 28, 3, 3, 28, 3, 33, 0, 7, 41, + /* 109 */ 1, 255, + /* 110 */ 5, 84, 25, 5, 78, 29, 5, 83, + /* 111 */ 5, 82, 25, 9, 74, 29, 9, 81, + /* 112 */ 5, 82, 25, 9, 74, 29, 9, 81, + /* 113 */ 5, 82, 25, 9, 74, 29, 9, 81, + /* 114 */ 5, 82, 25, 9, 74, 29, 9, 81, + /* 115 */ 9, 82, 25, 3, 3, 25, 3, 74, 29, 3, 3, 29, 3, 81, + /* 116 */ 1, 255, + /* 117 */ 21, 70, 16, 4, 2, 17, 5, 3, 14, 5, 3, 18, 5, 2, 19, 4, 50, 20, 4, 2, 21, 5, 3, 15, 5, 3, 22, 5, 2, 23, 4, 69, + /* 118 */ 21, 70, 16, 4, 2, 17, 5, 2, 14, 7, 2, 18, 5, 2, 19, 4, 50, 20, 4, 2, 21, 5, 2, 15, 7, 2, 22, 5, 2, 23, 4, 69, + /* 119 */ 21, 69, 16, 5, 1, 17, 6, 1, 14, 9, 1, 18, 6, 1, 19, 5, 48, 20, 5, 1, 21, 6, 1, 15, 9, 1, 22, 6, 1, 23, 5, 68, + /* 120 */ 21, 69, 16, 4, 2, 17, 5, 2, 14, 9, 2, 18, 5, 2, 19, 4, 48, 20, 4, 2, 21, 5, 2, 15, 9, 2, 22, 5, 2, 23, 4, 68, + /* 121 */ 21, 69, 16, 4, 2, 17, 5, 2, 14, 9, 2, 18, 5, 2, 19, 4, 48, 20, 4, 2, 21, 5, 2, 15, 9, 2, 22, 5, 2, 23, 4, 68, + /* 122 */ 21, 69, 16, 4, 2, 17, 5, 2, 14, 9, 2, 18, 5, 2, 19, 4, 48, 20, 4, 2, 21, 5, 2, 15, 9, 2, 22, 5, 2, 23, 4, 68, + /* 123 */ 21, 69, 16, 5, 1, 17, 6, 1, 14, 9, 1, 18, 6, 1, 19, 5, 48, 20, 5, 1, 21, 6, 1, 15, 9, 1, 22, 6, 1, 23, 5, 68, + /* 124 */ 21, 70, 16, 4, 2, 17, 5, 2, 14, 7, 2, 18, 5, 2, 19, 4, 50, 20, 4, 2, 21, 5, 2, 15, 7, 2, 22, 5, 2, 23, 4, 69, + /* 125 */ 21, 70, 16, 4, 2, 17, 5, 3, 14, 5, 3, 18, 5, 2, 19, 4, 50, 20, 4, 2, 21, 5, 3, 15, 5, 3, 22, 5, 2, 23, 4, 69, + /* 126 */ 1, 255, + /* 127 */ 9, 82, 26, 3, 3, 26, 3, 74, 30, 3, 3, 30, 3, 81, + /* 128 */ 5, 82, 26, 9, 74, 30, 9, 81, + /* 129 */ 5, 82, 26, 9, 74, 30, 9, 81, + /* 130 */ 5, 82, 26, 9, 74, 30, 9, 81, + /* 131 */ 5, 82, 26, 9, 74, 30, 9, 81, + /* 132 */ 5, 84, 26, 5, 78, 30, 5, 83, + /* 133 */ 1, 255, + /* 134 */ 9, 82, 27, 3, 3, 27, 3, 74, 31, 3, 3, 31, 3, 81, + /* 135 */ 5, 82, 27, 9, 74, 31, 9, 81, + /* 136 */ 5, 82, 27, 9, 74, 31, 9, 81, + /* 137 */ 5, 82, 27, 9, 74, 31, 9, 81, + /* 138 */ 5, 84, 27, 5, 78, 31, 5, 83, /* 139 */ 1, 255, /* 140 */ 1, 255, /* 141 */ 1, 255, }; -/* sizeof( buttons ) = 1070 */ +/* sizeof( buttons ) = 1238 */ #endif /* REMOTEPAD_H */