Artifact f3d0e406e6f853742092c3d36275d8599d446f4d6b95d2cd0a0a25792888ab10:
- File
src/hid/HIDGameController.m
— part of check-in
[39639cd987]
at
2024-06-02 21:24:25
on branch trunk
— Completely redesign and rewrite ObjFWHID
Right now only evdev is supported, support for others will be added back
later. (user: js, size: 2002) [annotate] [blame] [check-ins using]
/* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3.0 only, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * version 3.0 for more details. * * You should have received a copy of the GNU Lesser General Public License * version 3.0 along with this program. If not, see * <https://www.gnu.org/licenses/>. */ #include "config.h" #import "HIDGameController.h" #import "OFArray.h" #import "OFNumber.h" #import "OFSet.h" #if defined(OF_LINUX) && defined(OF_HAVE_FILES) # include "HIDEvdevGameController.h" #endif @implementation HIDGameController @dynamic name, buttons, axes; + (OFArray OF_GENERIC(HIDGameController *) *)controllers { #if defined(OF_LINUX) && defined(OF_HAVE_FILES) return [HIDEvdevGameController controllers]; #else return [OFArray array]; #endif } - (instancetype)init { if ([self isMemberOfClass: [HIDGameController class]]) { @try { [self doesNotRecognizeSelector: _cmd]; } @catch (id e) { [self release]; @throw e; } abort(); } return [super init]; } - (OFNumber *)vendorID { return nil; } - (OFNumber *)productID { return nil; } - (void)retrieveState { OF_UNRECOGNIZED_SELECTOR } - (OFString *)description { if (self.vendorID != nil && self.productID != nil) return [OFString stringWithFormat: @"<%@: %@ [%04X:%04X]>", self.class, self.name, self.vendorID.unsignedShortValue, self.productID.unsignedShortValue]; else return [OFString stringWithFormat: @"<%@: %@>", self.class, self.name]; } @end #if defined(OF_LINUX) && defined(OF_HAVE_FILES) # include "HIDEvdevGameController.m" #endif