mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-02-19 20:55:24 +01:00
byuu says: Updated to compile with all of the new hiro changes. My next step is to write up hiro API documentation, and move the API from alpha (constantly changing) to beta (rarely changing), in preparation for the first stable release (backward-compatible changes only.) Added "--fullscreen" command-line option. I like this over a configuration file option. Lets you use the emulator in both modes without having to modify the config file each time. Also enhanced the command-line game loading. You can now use any of these methods: higan /path/to/game-folder.sfc higan /path/to/game-folder.sfc/ higan /path/to/game-folder.sfc/program.rom The idea is to support launchers that insist on loading files only. Technically, the file can be any name (manifest.bml also works); the only criteria is that the file actually exists and is a file, and not a directory. This is a requirement to support the first version (a directory lacking the trailing / identifier), because I don't want my nall::string class to query the file system to determine if the string is an actual existing file or directory for its pathname() / dirname() functions. Anyway, every game folder I've made so far has program.rom, and that's very unlikely to change, so this should be fine. Now, of course, if you drop a regular "game.sfc" file on the emulator, it won't even try to load it, unless it's in a folder that ends in .fc, .sfc, etc. In which case, it'll bail out immediately by being unable to produce a manifest for what is obviously not really a game folder.
80 lines
2.4 KiB
C++
80 lines
2.4 KiB
C++
#if defined(Hiro_Keyboard)
|
|
|
|
Keyboard::State Keyboard::state;
|
|
|
|
const vector<string> Keyboard::keys = {
|
|
//physical keyboard buttons
|
|
"Escape", "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12",
|
|
"PrintScreen", "ScrollLock", "Pause",
|
|
"Insert", "Delete", "Home", "End", "PageUp", "PageDown",
|
|
"Up", "Down", "Left", "Right",
|
|
"Grave", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "Dash", "Equal", "Backspace",
|
|
"Tab", "CapsLock", "LeftEnter", "LeftShift", "RightShift",
|
|
"LeftControl", "RightControl", "LeftAlt", "RightAlt", "LeftSuper", "RightSuper", "Menu", "Space",
|
|
"OpenBracket", "CloseBracket", "Backslash", "Semicolon", "Apostrophe", "Comma", "Period", "Slash",
|
|
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M",
|
|
"N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z",
|
|
"NumLock", "Divide", "Multiply", "Subtract", "Add", "RightEnter", "Point",
|
|
"One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Zero",
|
|
|
|
//group aliases
|
|
"Shift", //"LeftShift" | "RightShift"
|
|
"Control", //"LeftControl" | "RightControl"
|
|
"Alt", //"LeftAlt" | "RightAlt"
|
|
"Super", //"LeftSuper" | "RightSuper"
|
|
"Enter", //"LeftEnter" | "RightEnter"
|
|
};
|
|
|
|
auto Keyboard::append(Hotkey hotkey) -> void {
|
|
state.hotkeys.append(hotkey);
|
|
}
|
|
|
|
auto Keyboard::hotkey(unsigned position) -> Hotkey {
|
|
if(position < hotkeyCount()) return state.hotkeys[position];
|
|
return {};
|
|
}
|
|
|
|
auto Keyboard::hotkeyCount() -> unsigned {
|
|
return state.hotkeys.size();
|
|
}
|
|
|
|
auto Keyboard::hotkeys() -> vector<Hotkey> {
|
|
return state.hotkeys;
|
|
}
|
|
|
|
auto Keyboard::poll() -> vector<bool> {
|
|
auto pressed = pKeyboard::poll();
|
|
|
|
for(auto& hotkey : state.hotkeys) {
|
|
bool active = hotkey.state->sequence.size() > 0;
|
|
for(auto& key : hotkey.state->keys) {
|
|
if(pressed[key]) continue;
|
|
active = false;
|
|
break;
|
|
}
|
|
if(hotkey.state->active != active) {
|
|
hotkey.state->active = active;
|
|
active ? hotkey.doPress() : hotkey.doRelease();
|
|
}
|
|
}
|
|
|
|
return pressed;
|
|
}
|
|
|
|
auto Keyboard::pressed(const string& key) -> bool {
|
|
if(auto code = keys.find(key)) return pKeyboard::pressed(*code);
|
|
return false;
|
|
}
|
|
|
|
auto Keyboard::released(const string& key) -> bool {
|
|
return !pressed(key);
|
|
}
|
|
|
|
auto Keyboard::remove(Hotkey hotkey) -> void {
|
|
if(auto offset = state.hotkeys.find(hotkey)) {
|
|
state.hotkeys.remove(*offset);
|
|
}
|
|
}
|
|
|
|
#endif
|