rockbox/firmware/target/hosted/anbernic/button-rgnano.c
Hairo R. Carela 48392bab94 New port: Anbernic RG Nano
A bit of context, this device is a clone of the FunKey-S with a different form factor, hardware is mostly identical, the relevant difference is it has audio out (via usb-c, adapter to 3.5mm is included), this is the reason why the FunKey-SDK is needed for bulding.

This port is based on the old SDL 1.2 code because the device doesn't have SDL2 support. Alongside what was supported in the SDL 1.2 builds this port supports battery level, charging status and backlight control.

Change-Id: I7fcb85be62748644b667c0efebabf59d6e9c5ade
2025-07-29 21:01:53 -04:00

73 lines
2 KiB
C

/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2025 Hairo R. Carela
*
* This program 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 Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************9*************************/
#include <stdio.h>
#include <SDL.h>
#include "button.h"
#include "button-target.h"
int key_to_button(int keyboard_key)
{
int new_btn = BUTTON_NONE;
switch (keyboard_key)
{
case SDLK_s:
new_btn = BUTTON_START;
break;
case SDLK_k:
new_btn = BUTTON_FN;
break;
case SDLK_a:
new_btn = BUTTON_A;
break;
case SDLK_b:
new_btn = BUTTON_B;
break;
case SDLK_x:
new_btn = BUTTON_X;
break;
case SDLK_y:
new_btn = BUTTON_Y;
break;
case SDLK_m:
new_btn = BUTTON_L;
break;
case SDLK_n:
new_btn = BUTTON_R;
break;
case SDLK_u:
new_btn = BUTTON_UP;
break;
case SDLK_d:
new_btn = BUTTON_DOWN;
break;
case SDLK_l:
new_btn = BUTTON_LEFT;
break;
case SDLK_r:
new_btn = BUTTON_RIGHT;
break;
default:
break;
}
return new_btn;
}