Skip to content

Commit

Permalink
Merge additional updates from upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
christianhaitian committed Jul 18, 2021
1 parent 2b80ce1 commit fab9e90
Show file tree
Hide file tree
Showing 8 changed files with 294 additions and 50 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# 351Files
A Single panel file Manager tailored for Anbernic 351 devices: RG351V and RG351P. Can be easily adapted to any Linux-based device.
A single panel file Manager tailored for Anbernic 351 devices: RG351V and RG351P. Can be easily adapted to any Linux-based device.

Based on DinguxCommander.
* Original page: http://beyondds.free.fr/index.php?Dingoo-dinguxcommander
Expand Down Expand Up @@ -45,6 +45,8 @@ Until then, you can install it manually with the following procedure:
* Restart EmulationStation. '351Files' should now be an entry in the 'ports' menu.

# Installation on ArkOS:
351Files should be integrated in ArkOS, in a future version.
Until then, you can install it manually with the following procedure:
* Download the latest release for your device (351Files-vx.x_<device>_ArkOS.tgz)
* Uncompress the .tgz file on your SD card in: /roms/ports
* Edit file /roms/ports/gamelist.xml, and add:
Expand Down Expand Up @@ -78,6 +80,7 @@ Text editor:
* A: open virtual keyboard / validate
* B: cancel / back
* X: open context menu
* Y + d-pad: select text
* R1/R2: page down
* L1/L2 : page up

Expand Down
8 changes: 7 additions & 1 deletion src/def.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
// Size of dialog border
#define DIALOG_BORDER 4

// Scroll speed in file and image viewer
// Scroll speed in image viewer
#define VIEWER_SCROLL_SPEED 20

// Button events
Expand All @@ -141,6 +141,7 @@
#define BUTTON_HELD_RIGHT SDL_JoystickGetHat(g_joystick, 0) == SDL_HAT_RIGHT
#define BUTTON_HELD_PAGEUP SDL_JoystickGetButton(g_joystick, 4) || SDL_JoystickGetButton(g_joystick, 10)
#define BUTTON_HELD_PAGEDOWN SDL_JoystickGetButton(g_joystick, 5) || SDL_JoystickGetButton(g_joystick, 11)
#define BUTTON_HELD_SELECT SDL_JoystickGetButton(g_joystick, 3)
#elif defined(DEVICE_RG351V)
#define BUTTON_PRESSED_UP event.type == SDL_JOYHATMOTION && event.jhat.value == SDL_HAT_UP
#define BUTTON_PRESSED_DOWN event.type == SDL_JOYHATMOTION && event.jhat.value == SDL_HAT_DOWN
Expand All @@ -158,6 +159,7 @@
#define BUTTON_HELD_RIGHT SDL_JoystickGetHat(g_joystick, 0) == SDL_HAT_RIGHT
#define BUTTON_HELD_PAGEUP SDL_JoystickGetButton(g_joystick, 4) || SDL_JoystickGetButton(g_joystick, 10)
#define BUTTON_HELD_PAGEDOWN SDL_JoystickGetButton(g_joystick, 5) || SDL_JoystickGetButton(g_joystick, 11)
#define BUTTON_HELD_SELECT SDL_JoystickGetButton(g_joystick, 3)
#elif defined(DEVICE_RGB10)
#define BUTTON_PRESSED_UP event.type == SDL_JOYBUTTONDOWN && event.jbutton.button == 8
#define BUTTON_PRESSED_DOWN event.type == SDL_JOYBUTTONDOWN && event.jbutton.button == 9
Expand All @@ -175,6 +177,7 @@
#define BUTTON_HELD_RIGHT SDL_JoystickGetButton(g_joystick, 11)
#define BUTTON_HELD_PAGEUP SDL_JoystickGetButton(g_joystick, 4) || SDL_JoystickGetButton(g_joystick, 14)
#define BUTTON_HELD_PAGEDOWN SDL_JoystickGetButton(g_joystick, 5) || SDL_JoystickGetButton(g_joystick, 15)
#define BUTTON_HELD_SELECT SDL_JoystickGetButton(g_joystick, 2)
#elif defined(DEVICE_RK2020)
#define BUTTON_PRESSED_UP event.type == SDL_JOYBUTTONDOWN && event.jbutton.button == 6
#define BUTTON_PRESSED_DOWN event.type == SDL_JOYBUTTONDOWN && event.jbutton.button == 7
Expand All @@ -192,6 +195,7 @@
#define BUTTON_HELD_RIGHT SDL_JoystickGetButton(g_joystick, 9)
#define BUTTON_HELD_PAGEUP SDL_JoystickGetButton(g_joystick, 4) || SDL_JoystickGetButton(g_joystick, 12)
#define BUTTON_HELD_PAGEDOWN SDL_JoystickGetButton(g_joystick, 5) || SDL_JoystickGetButton(g_joystick, 13)
#define BUTTON_HELD_SELECT SDL_JoystickGetButton(g_joystick, 2)
#elif defined(DEVICE_CHI)
#define BUTTON_PRESSED_UP event.type == SDL_JOYBUTTONDOWN && event.jbutton.button == 10
#define BUTTON_PRESSED_DOWN event.type == SDL_JOYBUTTONDOWN && event.jbutton.button == 11
Expand All @@ -209,6 +213,7 @@
#define BUTTON_HELD_RIGHT SDL_JoystickGetButton(g_joystick, 13)
#define BUTTON_HELD_PAGEUP SDL_JoystickGetButton(g_joystick, 4) || SDL_JoystickGetButton(g_joystick, 6)
#define BUTTON_HELD_PAGEDOWN SDL_JoystickGetButton(g_joystick, 5) || SDL_JoystickGetButton(g_joystick, 7)
#define BUTTON_HELD_SELECT SDL_JoystickGetButton(g_joystick, 2)
#else
#define BUTTON_PRESSED_UP event.type == SDL_KEYDOWN && event.key.repeat == 0 && event.key.keysym.sym == SDLK_UP
#define BUTTON_PRESSED_DOWN event.type == SDL_KEYDOWN && event.key.repeat == 0 && event.key.keysym.sym == SDLK_DOWN
Expand All @@ -226,6 +231,7 @@
#define BUTTON_HELD_RIGHT SDL_GetKeyboardState(NULL)[SDL_SCANCODE_RIGHT]
#define BUTTON_HELD_PAGEUP SDL_GetKeyboardState(NULL)[SDL_SCANCODE_PAGEUP]
#define BUTTON_HELD_PAGEDOWN SDL_GetKeyboardState(NULL)[SDL_SCANCODE_PAGEDOWN]
#define BUTTON_HELD_SELECT SDL_GetKeyboardState(NULL)[SDL_SCANCODE_INSERT]
#endif

// Globals
Expand Down
2 changes: 1 addition & 1 deletion src/fileUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,5 +375,5 @@ bool FileUtils::fileIsText(const std::string &p_path)
while (fgets(buffer, sizeof(buffer), pipe) != NULL);
pclose(pipe);
line = buffer;
return line.substr(0, 4) == "text";
return (line.substr(0, 4) == "text" && line.find("charset=us-ascii") != std::string::npos);
}
57 changes: 34 additions & 23 deletions src/keyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ Keyboard::Keyboard(IWindow *p_parent, const bool p_quitOnEnter):
{
m_cursorLoop = true;
m_keyLabel[0] = "qwertyuiop asdfghjkl zxcvbnm_.";
m_keyLabel[1] = "QWERTYUIOP ASDFGHJKL ZXCVBNM_.";
m_keyLabel[2] = "1234567890 @#%&*-+=' ()[]<>;:,";
m_keyLabel[1] = "QWERTYUIOP ASDFGHJKL ZXCVBNM-,";
m_keyLabel[2] = "1234567890 .,:!?/\\\"' ()[]<>_;$";
m_keyLabel[3] = "1234567890 ()[]{}~|^ @#%&*-+=`";
m_texShiftEmpty = SDLUtils::loadTexture(std::string(RES_PATH) + "/keyboard_shift_empty.png");
m_texShiftFull = SDLUtils::loadTexture(std::string(RES_PATH) + "/keyboard_shift_full.png");
m_texEnter = SDLUtils::loadTexture(std::string(RES_PATH) + "/keyboard_enter.png");
Expand Down Expand Up @@ -74,7 +75,7 @@ void Keyboard::render(const bool p_focus)
SDLUtils::renderTexture(m_texArrow, m_keyboard.x + m_key[34].x + m_key[34].w / 2, m_keyboard.y + m_key[34].y + m_key[34].h / 2, SDLUtils::T_ALIGN_CENTER, SDLUtils::T_ALIGN_MIDDLE);
SDLUtils::renderTexture(m_texArrow, m_keyboard.x + m_key[35].x + m_key[35].w / 2, m_keyboard.y + m_key[35].y + m_key[35].h / 2, SDLUtils::T_ALIGN_CENTER, SDLUtils::T_ALIGN_MIDDLE, SDL_FLIP_HORIZONTAL);
// Number / symbols
SDLUtils::renderText(m_keyLabelCurrent == 2 ? "abc" : "&123", g_font, m_keyboard.x + m_key[32].x + m_key[32].w / 2, m_keyboard.y + m_key[32].y + m_key[32].h / 2, {COLOR_TEXT_NORMAL}, getBackgroundColor(32, p_focus), SDLUtils::T_ALIGN_CENTER, SDLUtils::T_ALIGN_MIDDLE);
SDLUtils::renderText(m_keyLabelCurrent == 3 ? "abc" : "&123", g_font, m_keyboard.x + m_key[32].x + m_key[32].w / 2, m_keyboard.y + m_key[32].y + m_key[32].h / 2, {COLOR_TEXT_NORMAL}, getBackgroundColor(32, p_focus), SDLUtils::T_ALIGN_CENTER, SDLUtils::T_ALIGN_MIDDLE);
}

//------------------------------------------------------------------------------
Expand Down Expand Up @@ -117,20 +118,12 @@ void Keyboard::keyPressed(const SDL_Event &event)
// Shift
else if (m_cursor == 21 || m_cursor == 31)
{
if (m_keyLabelCurrent == 1)
m_keyLabelCurrent = 0;
else
m_keyLabelCurrent = 1;
g_hasChanged = true;
keyPressedShift();
}
// Symbol
else if (m_cursor == 32)
{
if (m_keyLabelCurrent == 2)
m_keyLabelCurrent = 0;
else
m_keyLabelCurrent = 2;
g_hasChanged = true;
keyPressedSymbol();
}
// Left arrow
else if (m_cursor == 34)
Expand Down Expand Up @@ -258,11 +251,7 @@ void Keyboard::moveCursorUp(const int p_step, bool p_loop)
// Page up => symbol button
if (p_step > 1)
{
if (m_keyLabelCurrent == 2)
m_keyLabelCurrent = 0;
else
m_keyLabelCurrent = 2;
g_hasChanged = true;
keyPressedSymbol();
return;
}
// 1st line
Expand Down Expand Up @@ -305,11 +294,7 @@ void Keyboard::moveCursorDown(const int p_step, bool p_loop)
// Page down => shift button
if (p_step > 1)
{
if (m_keyLabelCurrent == 1)
m_keyLabelCurrent = 0;
else
m_keyLabelCurrent = 1;
g_hasChanged = true;
keyPressedShift();
return;
}
// 1st line
Expand Down Expand Up @@ -414,3 +399,29 @@ int Keyboard::getKeyboardH(void)
{
return 2*KEYBOARD_MARGIN + 3*KEYBOARD_KEY_SPACING + 4*getKeyH();
}

//------------------------------------------------------------------------------

// Press symbol button
void Keyboard::keyPressedSymbol(void)
{
switch (m_keyLabelCurrent)
{
case 2: m_keyLabelCurrent = 3; break;
case 3: m_keyLabelCurrent = 0; break;
default: m_keyLabelCurrent = 2; break;
}
g_hasChanged = true;
}

//------------------------------------------------------------------------------

// Press shift button
void Keyboard::keyPressedShift(void)
{
if (m_keyLabelCurrent == 1)
m_keyLabelCurrent = 0;
else
m_keyLabelCurrent = 1;
g_hasChanged = true;
}
8 changes: 7 additions & 1 deletion src/keyboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ class Keyboard : public IWindow
// Get background color for the item at the given index
virtual SDL_Color getBackgroundColor(const int p_i, const bool p_focus) const;

// Press symbol button
void keyPressedSymbol(void);

// Press shift button
void keyPressedShift(void);

// Parent window
IWindow *m_parent;

Expand All @@ -56,7 +62,7 @@ class Keyboard : public IWindow
SDL_Rect m_key[36];

// Labels for the keys
std::string m_keyLabel[3];
std::string m_keyLabel[4];
int m_keyLabelCurrent;

// Size and coordinates of the keyboard
Expand Down
Loading

0 comments on commit fab9e90

Please sign in to comment.