Add few more members.

This commit is contained in:
2025-03-17 22:53:38 -04:00
parent 6b10887599
commit 5f308e7b23
3 changed files with 51 additions and 32 deletions

View File

@@ -63,7 +63,14 @@ bool jstick::Connected(int hwid) {
return js_connected && js_handle == hwid;
}
bool jstick::Connect(int hwid) {
std::string jstick::GetDeviceName(int hwid) {
char name_buf[128];
if (ioctl(hwid, JSIOCGNAME(sizeof(name_buf)), name_buf) < 0)
strncpy(name_buf, "Unknown", sizeof(name_buf));
return std::string(name_buf);
}
int jstick::Connect(int hwid) {
if (js_connected) {
std::cerr << "Joystick already connected! Support for multiple joysticks is in-progress!" << std::endl;
return false;
@@ -77,7 +84,7 @@ bool jstick::Connect(int hwid) {
js_connected = true;
JoystickConnected.Invoke(js_handle);
return true;
return js_handle;
}
bool jstick::Disconnect(int hwid) {