#import "CDHotkey.h"
#import "DummyClass.h"
#import "DirectController.h"

@implementation CDHotkey

-(id)init{
    [super initWithNum:CD_HOTKEY_NUM];
    
    _hotkeyMethod[0]=@selector(play);
    _hotkeyMethod[1]=@selector(stop);
    _hotkeyMethod[2]=@selector(sk_up);
    _hotkeyMethod[3]=@selector(sk_dn);
    _hotkeyMethod[4]=@selector(search);
    _hotkeyMethod[5]=@selector(ff);
    _hotkeyMethod[6]=@selector(fb);
    _hotkeyMethod[7]=@selector(repeat);
    _hotkeyMethod[8]=@selector(random);
    _hotkeyMethod[9]=@selector(eject);
    
    ffing=NO;
    fbing=NO;
    
    return self;
}

-(void)awakeFromNib{
    _fld[0]=_fld0;
    _fld[1]=_fld1;
    _fld[2]=_fld2;
    _fld[3]=_fld3;
    _fld[4]=_fld4;
    _fld[5]=_fld5;
    _fld[6]=_fld6;
    _fld[7]=_fld7;
    _fld[8]=_fld8;
    _fld[9]=_fld9;
}

-(void)play{
    [_directCtrl cd:[DummyClass dummyWithTag:playcdM]];
}

-(void)stop{
    [_directCtrl cd:[DummyClass dummyWithTag:stopcdM]];
}

-(void)sk_up{
    [_directCtrl cd:[DummyClass dummyWithTag:nextcdM]];
}

-(void)sk_dn{
    [_directCtrl cd:[DummyClass dummyWithTag:prevcdM]];
}

-(void)search{
    [_directCtrl cd:[DummyClass dummyWithTag:searchcdM]];
}

-(void)ff{
    if(ffing){
        [_directCtrl cd:[DummyClass dummyWithTag:searchcdM]];
        ffing=NO;
    }else{
        [_directCtrl cd:[DummyClass dummyWithTag:ffcdM]];
        ffing=YES;
    }
    fbing=NO;
}

-(void)fb{
    if(fbing){
        [_directCtrl cd:[DummyClass dummyWithTag:searchcdM]];
        fbing=NO;
    }else{
        [_directCtrl cd:[DummyClass dummyWithTag:fbcdM]];
        fbing=YES;
    }
    ffing=NO;
}

-(void)repeat{
    [_directCtrl cd:[DummyClass dummyWithTag:repcdM]];
}

-(void)random{
    [_directCtrl cd:[DummyClass dummyWithTag:randcdM]];
}

-(void)eject{
    [_directCtrl cd:[DummyClass dummyWithTag:ejectcdM]];
}

@end
