#ifndef _IOKIT_IOHIDUPSClass_H
#define _IOKIT_IOHIDUPSClass_H
#include <IOKit/ps/IOUPSPlugIn.h>
#include <IOKit/hid/IOHIDLib.h>
#include "IOHIDIUnknown.h"
struct UPSHIDElement {
SInt32 currentValue;
SInt32 usagePage;
SInt32 usage;
SInt32 unit;
SInt8 unitExponent;
bool isCommand;
bool isDesiredCollection;
bool isDesiredType;
bool shouldPoll;
double multiplier;
IOHIDElementType type;
IOHIDElementCookie cookie;
IOReturn lastReturn;
};
#define kIOHIDUnitVolt 0xf0d121
#define kIOHIDUnitAmp 0x100001
#define kIOHIDUnitAmpSec 0x101001
#define kIOHIDUnitKelvin 0x10001
#define kIOHIDUnitExponentVolt 7
class IOHIDUPSClass : public IOHIDIUnknown
{
private:
IOHIDUPSClass(IOHIDUPSClass &src);
void operator =(IOHIDUPSClass &src);
protected:
IOHIDUPSClass();
virtual ~IOHIDUPSClass();
static IOCFPlugInInterface sIOCFPlugInInterfaceV1;
static IOUPSPlugInInterface_v140 sUPSPlugInInterface_v140;
struct InterfaceMap _upsDevice;
io_service_t _service;
CFTypeRef _timerEventSource;
CFTypeRef _asyncEventSource;
IOHIDDeviceInterface122 ** _hidDeviceInterface;
IOHIDQueueInterface ** _hidQueueInterface;
IOHIDOutputTransactionInterface ** _hidTransactionInterface;
CFMutableDictionaryRef _hidProperties;
CFMutableDictionaryRef _hidElements;
CFMutableDictionaryRef _upsElements;
CFMutableDictionaryRef _upsEvent;
CFMutableDictionaryRef _upsProperties;
CFSetRef _upsCapabilities;
IOUPSEventCallbackFunction _eventCallback;
void * _eventTarget;
void * _eventRefcon;
bool _isACPresent;
static inline IOHIDUPSClass *getThis(void *self)
{ return (IOHIDUPSClass *) ((InterfaceMap *) self)->obj; };
static IOReturn _probe(void *self,
CFDictionaryRef propertyTable,
io_service_t service, SInt32 *order);
static IOReturn _start(void *self,
CFDictionaryRef propertyTable,
io_service_t service);
static IOReturn _stop(void *self);
static IOReturn _getProperties(
void * self,
CFDictionaryRef * properties);
static IOReturn _getCapabilities(
void * self,
CFSetRef * capabilities);
static IOReturn _getEvent(
void * self,
CFDictionaryRef * event);
static IOReturn _setEventCallback(
void * self,
IOUPSEventCallbackFunction callback,
void * target,
void * refcon);
static IOReturn _sendCommand(
void * self,
CFDictionaryRef command);
static IOReturn _createAsyncEventSource(
void * self,
CFTypeRef * eventSource);
static void _queueCallbackFunction(
void * target,
IOReturn result,
void * refcon,
void * sender);
static void _timerCallbackFunction(
CFRunLoopTimerRef timer,
void * refCon);
bool findElements();
void storeUPSElement(CFStringRef psKey, UPSHIDElement * newElementRef);
bool updateElementValue(UPSHIDElement * tempHIDElement, IOReturn * error);
bool setupQueue();
bool processEvent(UPSHIDElement * hidElement);
public:
static IOCFPlugInInterface **alloc();
virtual HRESULT queryInterface(REFIID iid, void **ppv);
virtual IOReturn probe(
CFDictionaryRef propertyTable,
io_service_t service,
SInt32 * order);
virtual IOReturn start(
CFDictionaryRef propertyTable,
io_service_t service);
virtual IOReturn stop();
virtual IOReturn getProperties(
CFDictionaryRef * properties);
virtual IOReturn getCapabilities(
CFSetRef * capabilities);
virtual IOReturn getEvent(
CFDictionaryRef * event,
bool * changed = NULL);
virtual void getEventProcess(
UPSHIDElement * elementRef,
CFStringRef psKey,
bool * changed);
virtual IOReturn setEventCallback(
IOUPSEventCallbackFunction callback,
void * target,
void * refcon);
virtual IOReturn sendCommand(
CFDictionaryRef command);
virtual void sendCommandProcess(
UPSHIDElement * elementRef,
SInt32 value);
virtual IOReturn createAsyncEventSource(
CFTypeRef * eventSource);
};
#endif