Moved Number key checking code to inputmapping
This commit is contained in:
parent
b809e3e70b
commit
8fe97363e7
4 changed files with 78 additions and 33 deletions
|
@ -45,21 +45,6 @@ extern void CheckAutoMountImage(EXIT_TYPE reset_reason , FileBrowser* fileBrowse
|
||||||
|
|
||||||
unsigned char FileBrowser::LSTBuffer[FileBrowser::LSTBuffer_size];
|
unsigned char FileBrowser::LSTBuffer[FileBrowser::LSTBuffer_size];
|
||||||
|
|
||||||
const unsigned FileBrowser::SwapKeys[33] =
|
|
||||||
{
|
|
||||||
KEY_F1, KEY_KP1, KEY_1,
|
|
||||||
KEY_F2, KEY_KP2, KEY_2,
|
|
||||||
KEY_F3, KEY_KP3, KEY_3,
|
|
||||||
KEY_F4, KEY_KP4, KEY_4,
|
|
||||||
KEY_F5, KEY_KP5, KEY_5,
|
|
||||||
KEY_F6, KEY_KP6, KEY_6,
|
|
||||||
KEY_F7, KEY_KP7, KEY_7,
|
|
||||||
KEY_F8, KEY_KP8, KEY_8,
|
|
||||||
KEY_F9, KEY_KP9, KEY_9,
|
|
||||||
KEY_F10, KEY_KP0, KEY_0,
|
|
||||||
KEY_F11, KEY_KPMINUS, KEY_MINUS
|
|
||||||
};
|
|
||||||
|
|
||||||
static const u32 palette[] =
|
static const u32 palette[] =
|
||||||
{
|
{
|
||||||
RGBA(0x00, 0x00, 0x00, 0xFF),
|
RGBA(0x00, 0x00, 0x00, 0xFF),
|
||||||
|
@ -379,6 +364,28 @@ FileBrowser::BrowsableList::Entry* FileBrowser::BrowsableList::FindEntry(const c
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FileBrowser::BrowsableList::Entry* FileBrowser::BrowsableList::FindNextPartialEntry(const char* name, int match_len)
|
||||||
|
{
|
||||||
|
int index;
|
||||||
|
int len = (int)entries.size();
|
||||||
|
|
||||||
|
for (index = 0; index < len; ++index)
|
||||||
|
{
|
||||||
|
Entry* entry = &entries[index];
|
||||||
|
if (match_len) // partial match
|
||||||
|
{
|
||||||
|
if (strncasecmp(name, entry->filImage.fname, match_len) == 0)
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
else // full match
|
||||||
|
{
|
||||||
|
if (strcasecmp(name, entry->filImage.fname) == 0)
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
FileBrowser::FileBrowser(DiskCaddy* diskCaddy, ROMs* roms, u8* deviceID, bool displayPNGIcons, ScreenBase* screenMain, ScreenBase* screenLCD, float scrollHighlightRate)
|
FileBrowser::FileBrowser(DiskCaddy* diskCaddy, ROMs* roms, u8* deviceID, bool displayPNGIcons, ScreenBase* screenMain, ScreenBase* screenLCD, float scrollHighlightRate)
|
||||||
: state(State_Folders)
|
: state(State_Folders)
|
||||||
, diskCaddy(diskCaddy)
|
, diskCaddy(diskCaddy)
|
||||||
|
@ -980,14 +987,11 @@ void FileBrowser::UpdateInputFolders()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// check for number keys for ROM and Drive Number changes
|
// check for number keys for ROM and Drive Number changes
|
||||||
unsigned keySetIndex;
|
if (inputMappings->BrowseNumber()
|
||||||
for (keySetIndex = 0; keySetIndex < 11; ++keySetIndex)
|
&& inputMappings->getKeyboardNumber() >= 0
|
||||||
|
&& inputMappings->getKeyboardNumber() < 11 )
|
||||||
{
|
{
|
||||||
unsigned keySetIndexBase = keySetIndex * 3;
|
SelectROMOrDevice(inputMappings->getKeyboardNumber());
|
||||||
if (keyboard->KeyPressed(FileBrowser::SwapKeys[keySetIndexBase])
|
|
||||||
|| keyboard->KeyPressed(FileBrowser::SwapKeys[keySetIndexBase + 1])
|
|
||||||
|| keyboard->KeyPressed(FileBrowser::SwapKeys[keySetIndexBase + 2]))
|
|
||||||
SelectROMOrDevice(keySetIndex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for keys a-z
|
// check for keys a-z
|
||||||
|
|
|
@ -151,6 +151,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
Entry* FindEntry(const char* name);
|
Entry* FindEntry(const char* name);
|
||||||
|
Entry* FindNextPartialEntry(const char* name, int match_len);
|
||||||
int FindNextAutoName(char* basename);
|
int FindNextAutoName(char* basename);
|
||||||
|
|
||||||
void RefreshViews();
|
void RefreshViews();
|
||||||
|
@ -191,8 +192,6 @@ public:
|
||||||
static const long int LSTBuffer_size = 1024 * 8;
|
static const long int LSTBuffer_size = 1024 * 8;
|
||||||
static unsigned char LSTBuffer[];
|
static unsigned char LSTBuffer[];
|
||||||
|
|
||||||
static const unsigned SwapKeys[];
|
|
||||||
|
|
||||||
static u32 Colour(int index);
|
static u32 Colour(int index);
|
||||||
|
|
||||||
bool SelectLST(const char* filenameLST);
|
bool SelectLST(const char* filenameLST);
|
||||||
|
|
|
@ -191,16 +191,28 @@ bool InputMappings::CheckKeyboardBrowseMode()
|
||||||
SetKeyboardFlag(AUTOLOAD_FLAG);
|
SetKeyboardFlag(AUTOLOAD_FLAG);
|
||||||
else if (keyboard->KeyHeld(KEY_R) && keyboard->KeyEitherAlt() )
|
else if (keyboard->KeyHeld(KEY_R) && keyboard->KeyEitherAlt() )
|
||||||
SetKeyboardFlag(FAKERESET_FLAG);
|
SetKeyboardFlag(FAKERESET_FLAG);
|
||||||
else if (keyboard->KeyHeld(KEY_W) && keyboard->KeyEitherAlt())
|
else if (keyboard->KeyHeld(KEY_W) && keyboard->KeyEitherAlt() )
|
||||||
SetKeyboardFlag(WRITEPROTECT_FLAG);
|
SetKeyboardFlag(WRITEPROTECT_FLAG);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
unsigned index;
|
unsigned index;
|
||||||
for (index = 0; index < 11; ++index)
|
for (index = 0; index < sizeof(NumberKeys)/sizeof(NumberKeys[0]); index+=3)
|
||||||
{
|
{
|
||||||
unsigned keySetIndexBase = index * 3;
|
if (keyboard->KeyHeld(NumberKeys[index])
|
||||||
if (keyboard->KeyHeld(FileBrowser::SwapKeys[keySetIndexBase]) || keyboard->KeyHeld(FileBrowser::SwapKeys[keySetIndexBase + 1]) || keyboard->KeyHeld(FileBrowser::SwapKeys[keySetIndexBase + 2]))
|
|| keyboard->KeyHeld(NumberKeys[index + 1])
|
||||||
keyboardFlags |= NUMBER_FLAG;
|
|| keyboard->KeyHeld(NumberKeys[index + 2]) )
|
||||||
|
{
|
||||||
|
SetKeyboardFlag(NUMBER_FLAG);
|
||||||
|
keyboardNumber = index/3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (index = KEY_A; index <= KEY_Z; ++index)
|
||||||
|
{
|
||||||
|
if (keyboard->KeyHeld(index))
|
||||||
|
{
|
||||||
|
SetKeyboardFlag(AtoZ_FLAG);
|
||||||
|
keyboardNumber = index-KEY_A+1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,12 +239,14 @@ void InputMappings::CheckKeyboardEmulationMode(unsigned numberOfImages, unsigned
|
||||||
else if (numberOfImages > 1)
|
else if (numberOfImages > 1)
|
||||||
{
|
{
|
||||||
unsigned index;
|
unsigned index;
|
||||||
for (index = 0; index < numberOfImagesMax; ++index)
|
for (index = 0; index < sizeof(NumberKeys)/sizeof(NumberKeys[0]); index+=3)
|
||||||
{
|
{
|
||||||
unsigned keySetIndexBase = index * 3;
|
if (keyboard->KeyHeld(NumberKeys[index])
|
||||||
if (keyboard->KeyHeld(FileBrowser::SwapKeys[keySetIndexBase]) || keyboard->KeyHeld(FileBrowser::SwapKeys[keySetIndexBase + 1]) || keyboard->KeyHeld(FileBrowser::SwapKeys[keySetIndexBase + 2]))
|
|| keyboard->KeyHeld(NumberKeys[index + 1])
|
||||||
directDiskSwapRequest |= (1 << index);
|
|| keyboard->KeyHeld(NumberKeys[index + 2]) )
|
||||||
|
directDiskSwapRequest |= (1 << index/3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,8 +41,24 @@
|
||||||
#define AUTOLOAD_FLAG (1 << 15)
|
#define AUTOLOAD_FLAG (1 << 15)
|
||||||
#define FAKERESET_FLAG (1 << 16)
|
#define FAKERESET_FLAG (1 << 16)
|
||||||
#define WRITEPROTECT_FLAG (1 << 17)
|
#define WRITEPROTECT_FLAG (1 << 17)
|
||||||
|
#define AtoZ_FLAG (1 << 18)
|
||||||
// dont exceed 32!!
|
// dont exceed 32!!
|
||||||
|
|
||||||
|
const unsigned NumberKeys[33] =
|
||||||
|
{
|
||||||
|
KEY_F1, KEY_KP1, KEY_1,
|
||||||
|
KEY_F2, KEY_KP2, KEY_2,
|
||||||
|
KEY_F3, KEY_KP3, KEY_3,
|
||||||
|
KEY_F4, KEY_KP4, KEY_4,
|
||||||
|
KEY_F5, KEY_KP5, KEY_5,
|
||||||
|
KEY_F6, KEY_KP6, KEY_6,
|
||||||
|
KEY_F7, KEY_KP7, KEY_7,
|
||||||
|
KEY_F8, KEY_KP8, KEY_8,
|
||||||
|
KEY_F9, KEY_KP9, KEY_9,
|
||||||
|
KEY_F10, KEY_KP0, KEY_0,
|
||||||
|
KEY_F11, KEY_KPMINUS, KEY_MINUS
|
||||||
|
};
|
||||||
|
|
||||||
class InputMappings : public Singleton<InputMappings>
|
class InputMappings : public Singleton<InputMappings>
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
@ -59,6 +75,9 @@ protected:
|
||||||
bool enterButtonPressedPrev;
|
bool enterButtonPressedPrev;
|
||||||
bool enterButtonPressed;
|
bool enterButtonPressed;
|
||||||
|
|
||||||
|
unsigned keyboardNumber;
|
||||||
|
unsigned keyboardLetter;
|
||||||
|
|
||||||
//inline void SetUartFlag(unsigned flag) { uartFlags |= flag; }
|
//inline void SetUartFlag(unsigned flag) { uartFlags |= flag; }
|
||||||
//inline bool UartFlag(unsigned flag) { return (uartFlags & flag) != 0; }
|
//inline bool UartFlag(unsigned flag) { return (uartFlags & flag) != 0; }
|
||||||
inline void SetKeyboardFlag(unsigned flag) { keyboardFlags |= flag; }
|
inline void SetKeyboardFlag(unsigned flag) { keyboardFlags |= flag; }
|
||||||
|
@ -179,6 +198,14 @@ public:
|
||||||
return KeyboardFlag(WRITEPROTECT_FLAG);
|
return KeyboardFlag(WRITEPROTECT_FLAG);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool BrowseNumber()
|
||||||
|
{
|
||||||
|
return KeyboardFlag(NUMBER_FLAG);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline unsigned getKeyboardNumber() { return keyboardNumber; }
|
||||||
|
inline unsigned getKeyboardLetter() { return keyboardLetter; }
|
||||||
|
|
||||||
// Used by the 2 cores so need to be volatile
|
// Used by the 2 cores so need to be volatile
|
||||||
//volatile static unsigned directDiskSwapRequest;
|
//volatile static unsigned directDiskSwapRequest;
|
||||||
static unsigned directDiskSwapRequest;
|
static unsigned directDiskSwapRequest;
|
||||||
|
@ -187,3 +214,4 @@ public:
|
||||||
// static unsigned escapeSequenceIndex;
|
// static unsigned escapeSequenceIndex;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue