Пример #1
0
// 키를 누르거나 땔때 FN 및 LED등 을 컨트롤한다.
bool applyFN(uint8_t xKeyidx, uint8_t xCol, uint8_t xRow, bool xIsDown) {

    // DEBUG_PRINT(("applyFN  : %d xIsDown : %d\n", xKeyidx, xIsDown));
    applyKeyDownForFullLED(xKeyidx, xCol, xRow, xIsDown);

    if(isFnKey(xKeyidx)) return false; 

    setDualAction(xKeyidx, xIsDown);    

    // 듀얼액션 키의 기본 키를 가져온다.
    xKeyidx = getDualActionDefaultKey(xKeyidx);
    if(isFnKey(xKeyidx)) return false; 

    if(xIsDown) {

        if((xKeyidx ==  KEY_BEYOND_FN || xKeyidx == KEY_BEYOND_FN3)
        		|| (_isExtraFNDown && xKeyidx == BEYOND_FN_CANCEL_KEY)){ // beyond_fn을 활성화;
             if( xKeyidx == BEYOND_FN_CANCEL_KEY ) {    // 취소만 가능한 키 
                _beyondFnIndex = false;
             }else{
            	if(_beyondFnIndex == 0){
            		if(xKeyidx ==  KEY_BEYOND_FN){
            			_beyondFnIndex = LAYER_FN2;
            		}else{
            			_beyondFnIndex = LAYER_FN3;
            		}
            	}else{
            		if(xKeyidx ==  KEY_BEYOND_FN){
            			if(_beyondFnIndex ==  LAYER_FN2){
            				_beyondFnIndex = LAYER_NORMAL;
            			}else{
            				_beyondFnIndex = LAYER_FN2;
            			}
					}else if(xKeyidx ==  KEY_BEYOND_FN3){
            			if(_beyondFnIndex ==  LAYER_FN3){
            				_beyondFnIndex = LAYER_NORMAL;
            			}else{
            				_beyondFnIndex = LAYER_FN3;
            			}
					}
            	}
             }

#ifndef DISABLE_FN2_TOGGLE_LED_BLINK 
             if(isBeyondFnLedEnabled() == false){
                 if(_beyondFnIndex == 0){
                    blinkOnce(100);
                 }else{
                    blinkOnce(100);
                    _delay_ms(80);
                    blinkOnce(70);
                 }
             }
#endif

             if(isBeyondFnLedEnabled()){    
                setLed(LED_STATE_NUM, isBeyondFN());
             }

             return 0;
        }else if(_isQuickMacroDown && isEepromMacroKey(xKeyidx)){
            _quickMacroIndex = xKeyidx - KEY_MAC1; 
            _isReadyQuickMacro = true;
            return 0;
        }else if(xKeyidx == EXTRA_FN){
            _isExtraFNDown = true;
        }else if((_isExtraFNDown && xKeyidx == LED_KEY)){
        	uint8_t gModi = getModifierDownBuffer();
			if(gModi == 0x02 || gModi == 0x20){
				changeFullLedState(FULL_LED_MODE2);
			}else{
				changeFullLedState(FULL_LED_MODE1);
			}
            return 0;
        }else if(xKeyidx == KEY_LED){
			changeFullLedState(FULL_LED_MODE1);
			return 0;
        }else if(xKeyidx == KEY_LED2){
			changeFullLedState(FULL_LED_MODE2);
			return 0;
        }else if(xKeyidx == KEY_LED_UP){
        	uint8_t gModi = getModifierDownBuffer();
        	if(gModi == 0x02 || gModi == 0x20){
        		increaseLedBrightness(FULL_LED_MODE2);
        	}else{
        		increaseLedBrightness(FULL_LED_MODE1);
        	}
        	return 0;
        }else if(xKeyidx == KEY_LED_DOWN){
        	uint8_t gModi = getModifierDownBuffer();
        	if(gModi == 0x02 || gModi == 0x20){
        		reduceLedBrightness(FULL_LED_MODE2);
        	}else{
        		reduceLedBrightness(FULL_LED_MODE1);
        	}
            return 0;
        }else if(xKeyidx == KEY_LED_ON_OFF){
        	_ledOff ^= true;
        	if(_ledOff == false){
        		turnOnLedAll();
        	}else{
        		turnOffLedAll();
        	}
        }else if(xKeyidx == KEY_QUICK_MACRO){
            if(isQuickMacro()){
                stopQuickMacro();
            }else{
                _isQuickMacroDown = true;                
            }
            return 0;
        }

    }else{  // up 

        if(xKeyidx ==  KEY_BEYOND_FN){  // beyond_fn             
             return 0;
        }else if(xKeyidx == EXTRA_FN){
            _isExtraFNDown = false;
        }else if(xKeyidx == KEY_QUICK_MACRO){
            _isQuickMacroDown = false;
            return 0;
        }
    }

    return 1;
}
Пример #2
0
// 키를 누르거나 땔때 FN 및 LED등 을 컨트롤한다.
bool applyFN(uint8_t xKeyidx, uint8_t xCol, uint8_t xRow, bool xIsDown) {

    // dual action key를 기본키 (caps lock 등)으로 반환;
    xKeyidx = getDualActionDefaultKey(xKeyidx);

    if(isFnKey(xKeyidx)) return false;

    if(xIsDown) {

        if((xKeyidx ==  KEY_BEYOND_FN || xKeyidx == KEY_BEYOND_FN3)
        		|| (_isDownExtraFN && xKeyidx == BEYOND_FN_CANCEL_KEY)){ // beyond_fn을 활성화;
            _prevBeyondFnIndex = _beyondFnIndex;
             if( xKeyidx == BEYOND_FN_CANCEL_KEY ) {    // 취소만 가능한 키 
                _beyondFnIndex = LAYER_NORMAL;
             }else{
            	if(_beyondFnIndex == LAYER_NORMAL){
            		if(xKeyidx ==  KEY_BEYOND_FN){
            			_beyondFnIndex = LAYER_FN2;
            		}else{
            			_beyondFnIndex = LAYER_FN3;
            		}
            	}else{
            		if(xKeyidx ==  KEY_BEYOND_FN && !(_beyondFnIndex ==  LAYER_FN2)){
            			_beyondFnIndex = LAYER_FN2;
					}else if(xKeyidx ==  KEY_BEYOND_FN3 && !(_beyondFnIndex ==  LAYER_FN3)){
            			_beyondFnIndex = LAYER_FN3;
					}else{
        				_beyondFnIndex = LAYER_NORMAL;
					}
            	}
             }

             setLEDIndicate();
             _prevBeyondFnIndex = _beyondFnIndex;   // 더이상 변화가 없도록;


             if( xKeyidx == BEYOND_FN_CANCEL_KEY ) {    // 키가 작동하도록 1 리턴;
            	 return 1;
			  }
             return 0;
        }else if(_isDownQuickMacro && isEepromMacroKey(xKeyidx)){
            _quickMacroIndex = xKeyidx - KEY_MAC1; 
            _isReadyQuickMacro = true;
            return 0;
        }else if(xKeyidx == EXTRA_FN){
            _isDownExtraFN = true;
        }else if(xKeyidx == KEY_LED_ON_OFF){
        	_ledOff ^= true;
        	if(_ledOff == false){
        		turnOnLedAll();
        	}else{
        		turnOffLedAll();
        	}
        	return 0;
        }else if(xKeyidx == KEY_QUICK_MACRO){
            if(isQuickMacro()){
                stopQuickMacro();
            }else{
                _isDownQuickMacro = true;
            }
            return 0;
        }else{
        	return delegateFnControl(xKeyidx, _isDownExtraFN);
        }

    }else{  // up 

        if(xKeyidx ==  KEY_BEYOND_FN){  // beyond_fn             
             return 0;
        }else if(xKeyidx == EXTRA_FN){
            _isDownExtraFN = false;
        }else if(xKeyidx == KEY_QUICK_MACRO){
            _isDownQuickMacro = false;
            return 0;
        }
    }

    return 1;
}