2021-09-25 05:22:19 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include "ruamoko/qwaq/input-app.h"
|
|
|
|
#include "ruamoko/qwaq/ui/scrollbar.h"
|
|
|
|
#include "ruamoko/qwaq/ui/stringview.h"
|
|
|
|
#include "ruamoko/qwaq/ui/tableview.h"
|
|
|
|
#include "ruamoko/qwaq/ui/window.h"
|
|
|
|
#include "ruamoko/qwaq/device/axisdata.h"
|
|
|
|
#include "ruamoko/qwaq/device/device.h"
|
|
|
|
|
|
|
|
@implementation Device
|
|
|
|
|
|
|
|
-initWithDevice:(qwaq_devinfo_t *)device id:(int)devid
|
|
|
|
{
|
|
|
|
if (!(self = [super init])) {
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
self.device = device;
|
|
|
|
self.devid = devid;
|
|
|
|
|
|
|
|
window = [Window withRect:{{0, 0}, {40, 10}}];
|
|
|
|
[window setBackground: color_palette[064]];
|
|
|
|
[window setTitle: device.id];
|
|
|
|
|
|
|
|
[window insert:[StringView withRect:{{1, 1}, {38, 1}} string:device.name]];
|
|
|
|
axis_data = [[AxisData withDevice:device] retain];
|
|
|
|
axis_view = [TableView withRect:{{1, 2}, {38, 7}}];
|
|
|
|
[axis_view addColumn:[TableViewColumn named:"axis" width:3]];
|
|
|
|
[axis_view addColumn:[TableViewColumn named:"value" width:6]];
|
|
|
|
ScrollBar *sb = [ScrollBar vertical:7 at:{39, 2}];
|
|
|
|
[axis_view setVerticalScrollBar:sb];
|
|
|
|
[axis_view setDataSource:axis_data];
|
|
|
|
[window insertSelected: axis_view];
|
|
|
|
[window insert: sb];
|
|
|
|
[application addView: window];
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
+withDevice:(qwaq_devinfo_t *)device id:(int)devid
|
|
|
|
{
|
|
|
|
return [[[self alloc] initWithDevice:device id:devid] autorelease];
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)dealloc
|
|
|
|
{
|
2021-09-26 01:07:34 +00:00
|
|
|
[application removeView:window];
|
|
|
|
[axis_data release];
|
|
|
|
|
2021-09-25 05:22:19 +00:00
|
|
|
obj_free (device.axes);
|
|
|
|
obj_free (device.buttons);
|
|
|
|
str_free (device.name);
|
|
|
|
str_free (device.id);
|
|
|
|
obj_free (device);
|
2021-09-26 01:07:34 +00:00
|
|
|
[super dealloc];
|
2021-09-25 05:22:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-updateAxis:(int)axis value:(int)value
|
|
|
|
{
|
|
|
|
[axis_data updateAxis:axis value:value];
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
-updateButton:(int)button state:(int)state
|
|
|
|
{
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
-(int)devid
|
|
|
|
{
|
|
|
|
return devid;
|
|
|
|
}
|
|
|
|
|
2021-09-26 01:07:34 +00:00
|
|
|
-(string)name
|
|
|
|
{
|
|
|
|
return device.name;
|
|
|
|
}
|
|
|
|
|
|
|
|
-(string)id
|
|
|
|
{
|
|
|
|
return device.id;
|
|
|
|
}
|
|
|
|
|
2021-09-25 05:22:19 +00:00
|
|
|
-redraw
|
|
|
|
{
|
|
|
|
[axis_view redraw];
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|