inputtype::button renamed to inputtype::mouse

This commit is contained in:
MihailRis
2023-11-20 06:39:42 +03:00
parent 3eb6e82631
commit e04abe79d8
4 changed files with 7 additions and 7 deletions
+1 -1
View File
@@ -179,7 +179,7 @@ void InputBindBox::drawBackground(Batch2D* batch, Assets* assets) {
} }
void InputBindBox::clicked(GUI*, int button) { void InputBindBox::clicked(GUI*, int button) {
binding.type = inputtype::button; binding.type = inputtype::mouse;
binding.code = button; binding.code = button;
defocus(); defocus();
} }
+3 -3
View File
@@ -49,7 +49,7 @@ std::string write_controls() {
json::JObject* jentry = new json::JObject(); json::JObject* jentry = new json::JObject();
switch (binding.type) { switch (binding.type) {
case inputtype::keyboard: jentry->put("type", "keyboard"); break; case inputtype::keyboard: jentry->put("type", "keyboard"); break;
case inputtype::button: jentry->put("type", "button"); break; case inputtype::mouse: jentry->put("type", "mouse"); break;
default: throw std::runtime_error("unsupported control type"); default: throw std::runtime_error("unsupported control type");
} }
jentry->put("code", binding.code); jentry->put("code", binding.code);
@@ -72,8 +72,8 @@ void load_controls(std::string filename, std::string source) {
if (typestr == "keyboard") { if (typestr == "keyboard") {
type = inputtype::keyboard; type = inputtype::keyboard;
} else if (typestr == "button") { } else if (typestr == "mouse") {
type = inputtype::button; type = inputtype::mouse;
} else { } else {
std::cerr << "unknown input type '" << typestr << "'" << std::endl; std::cerr << "unknown input type '" << typestr << "'" << std::endl;
continue; continue;
+1 -1
View File
@@ -73,7 +73,7 @@ void Events::pullEvents(){
bool newstate = false; bool newstate = false;
switch (binding.type) { switch (binding.type) {
case inputtype::keyboard: newstate = pressed(binding.code); break; case inputtype::keyboard: newstate = pressed(binding.code); break;
case inputtype::button: newstate = clicked(binding.code); break; case inputtype::mouse: newstate = clicked(binding.code); break;
} }
if (newstate) { if (newstate) {
+2 -2
View File
@@ -80,7 +80,7 @@ namespace mousecode {
enum class inputtype { enum class inputtype {
keyboard, keyboard,
button, mouse,
}; };
struct Binding { struct Binding {
@@ -100,7 +100,7 @@ struct Binding {
const char* text() const { const char* text() const {
switch (type) { switch (type) {
case inputtype::keyboard: return keycode::name(code); case inputtype::keyboard: return keycode::name(code);
case inputtype::button: return mousecode::name(code); case inputtype::mouse: return mousecode::name(code);
} }
return "<unknown input type>"; return "<unknown input type>";
} }