--(void) load {
- id jsaction = [joystickController selectedAction];
- currentJsaction = jsaction;
- if(!jsaction) {
- [self setEnabled: NO];
- [title setStringValue: @""];
- return;
- } else {
- [self setEnabled: YES];
- }
- Target* target = [[configsController currentConfig] getTargetForAction: jsaction];
-
- id act = jsaction;
- NSString* actFullName = [act name];
- while([act base]) {
- act = [act base];
- actFullName = [[NSString alloc] initWithFormat: @"%@ > %@", [act name], actFullName];
- }
- [title setStringValue: [[NSString alloc] initWithFormat: @"%@ > %@", [[configsController currentConfig] name], actFullName]];
-
- if(!target) {
- // already reset
- } else if([target isKindOfClass: [TargetKeyboard class]]) {
- [radioButtons setState:1 atRow: 1 column: 0];
- [keyInput setVk: [(TargetKeyboard*)target vk]];
- } else if([target isKindOfClass: [TargetConfig class]]) {
- [radioButtons setState:1 atRow: 2 column: 0];
- [configPopup selectItemAtIndex: [[configsController configs] indexOfObject: [(TargetConfig*)target config]]];
- } else if ([target isKindOfClass: [TargetMouseMove class]]) {
- if ([(TargetMouseMove *)target dir] == 0)
- [radioButtons setState:1 atRow: 3 column: 0];
- else
- [radioButtons setState:1 atRow: 4 column: 0];
- } else {
- [NSException raise:@"Unknown target subclass" format:@"Unknown target subclass"];
- }
+- (void)load {
+ JSAction *act = joystickController.selectedAction;
+ if (!act) {
+ self.enabled = NO;
+ title.stringValue = @"";
+ return;
+ } else {
+ self.enabled = YES;
+ }
+
+ Target *target = [self currentTarget];
+ NSString *actFullName = act.name;
+ for (JSAction *cur = act.base; cur; cur = cur.base) {
+ actFullName = [[NSString alloc] initWithFormat:@"%@ > %@", cur.name, actFullName];
+ }
+ title.stringValue = [[NSString alloc] initWithFormat:@"%@ > %@", configsController.currentConfig.name, actFullName];
+
+ if ([target isKindOfClass:[TargetKeyboard class]]) {
+ [radioButtons setState:1 atRow:1 column:0];
+ keyInput.vk = [(TargetKeyboard*)target vk];
+ } else if ([target isKindOfClass:[TargetConfig class]]) {
+ [radioButtons setState:1 atRow:2 column:0];
+ [configPopup selectItemAtIndex:[configsController.configs
+ indexOfObject:[(TargetConfig *)target config]]];
+ }
+ else if ([target isKindOfClass:[TargetMouseMove class]]) {
+ [radioButtons setState:1 atRow:3 column:0];
+ [mouseDirSelect setSelectedSegment:[(TargetMouseMove *)target dir]];
+ }
+ else if ([target isKindOfClass:[TargetMouseBtn class]]) {
+ [radioButtons setState:1 atRow:4 column:0];
+ mouseBtnSelect.selectedSegment = [(TargetMouseBtn *)target which] == kCGMouseButtonLeft ? 0 : 1;
+ }
+ else if ([target isKindOfClass:[TargetMouseScroll class]]) {
+ [radioButtons setState:1 atRow:5 column:0];
+ scrollDirSelect.selectedSegment = [(TargetMouseScroll *)target howMuch] > 0;
+ }
+ else if ([target isKindOfClass:[TargetToggleMouseScope class]]) {
+ [radioButtons setState:1 atRow:6 column:0];
+ } else {
+ [radioButtons setState:1 atRow:0 column:0];
+ }