mse.c
来自「一个比较好用的TW2835音视频芯片开发板的程序,」· C语言 代码 · 共 631 行 · 第 1/2 页
C
631 行
ClearBit(_bnd_,0xf0);
}
}
}
else{
if(b_mse_stts_crsr == CRSR_SML){
b_mse_stts_crsr = CRSR_BIG;
// if(BitClear(mse_flg,MSE_STTS_CRSR)){//b_mse_status_cur == BIG){
// SetBit(mse_flg,MSE_STTS_CRSR);
SetMseCrsr(CRSR_BIG); // big mouse pointer
SetMseLyr(ON);
ClearBit(_bnd_,0xf0);
}
}
}
else{
_chnl_ = (mse_ch & 0x0f);
_bnd_ = (mse_ch & 0xf0);
}
// }
return _bnd_|_chnl_;
}
// */
//==================================================================================
//*
U8 GetMseMaskX(U8 _dvc, U8 _ch, U16 _crsr_pos_x)
{
U16 _pic_;
U8 _hw_, _x_;
_pic_ = ReadAsicByte(_dvc,DVC_PG1,0x30+(_ch<<2));
_pic_ = (_pic_<<1)+2; //... +2 -> ???
_hw_ = ReadAsicByte(_dvc,DVC_PG2,0x63+(_ch<<3));
_x_ = (U8)((_crsr_pos_x - _pic_)/(_hw_+1)); //... +1 -> 2D ary box boundary
if(_crsr_pos_x > 1){
if(_x_ > 0x0f) _x_ = 0x0f;
}
else _x_ = 0x00;
return _x_;
}
//==================================================================================
U8 GetMseMaskY(U8 _dvc, U8 _ch, U16 _crsr_pos_y)
{
U16 _pic_;
U8 _vw_, _y_;
_pic_ = ReadAsicByte(_dvc,DVC_PG1,0x32+(_ch<<2));
_pic_ = (_pic_<<1)+1; //... +1 -> ???
_vw_ = ReadAsicByte(_dvc,DVC_PG2,0x65+(_ch<<3));
_y_ = (U8)((_crsr_pos_y - _pic_)/(_vw_+1)); //... +1 -> 2D ary box boundary
if(_crsr_pos_y > 0){
if(_y_ > 0x0b) _y_ = 0x0b;
}
else _y_ = 0x00;
return _y_;
}
// */
//==================================================================================
U8 GetMseOSDX(U16 _pos_x)
{ // var_XPOINT / 8 = INDEX_H : (8 x 10 font)
return (U8)(_pos_x/8); // O
}
//==================================================================================
U8 GetMseOSDY(U16 _pos_y)
{
// var_YPOINT / 11 = INDEX_Y : (8 x 10 font) & VSPACE==1 & VDELAY == 4
if(reg_crsr_pos_y < OSD_DLY_V) return 0;
else return (U8)((_pos_y-OSD_DLY_V)/10);
}
//==================================================================================
void SetMseMvmnt(void) //... set mouse movement
{
// signed int _mv_x_, _mv_y_, _mse_nxt_ptr_;
S16 _mv_x_, _mv_y_, _mse_nxt_ptr_;
// U8 t_mse_rd0
// if((mse_rdata & 0xff) == 0xfa)
if(mse_rdata[0] == 0xfa)
{
//... mse_rdata[31:24],[23:16],[15:8],[7:0] is each read data packet
// if(BitSet((mse_rdata>>8)&0xff, BIT4)) _mv_x_ = 0xffffff00|((mse_rdata>>16)&0xff);
// else _mv_x_ = 0x00000000|((mse_rdata>>16)&0xff);
// if(BitSet((mse_rdata>>8)&0xff, BIT5)) _mv_y_ = 0xffffff00|((mse_rdata>>24)&0xff);
// else _mv_y_ = 0x00000000|((mse_rdata>>24)&0xff);
if(BitSet(mse_rdata[1], BIT4)) _mv_x_ = 0xff00|(U16)mse_rdata[2];
else _mv_x_ = 0x0000|(U16)mse_rdata[2];
if(BitSet(mse_rdata[1], BIT5)) _mv_y_ = 0xff00|(U16)mse_rdata[3];
else _mv_y_ = 0x0000|(U16)mse_rdata[3];
if((_mv_x_ != 0)||(_mv_y_ != 0))
{
b_mse_no_mvng = OFF;
// ClearBit(mse_flg,MSE_NO_MVNG);
_mse_nxt_ptr_ = reg_crsr_pos_x + _mv_x_;
if(_mse_nxt_ptr_ < 0) reg_crsr_pos_x = 0;
else if(_mse_nxt_ptr_ > 360) reg_crsr_pos_x = 360;
else reg_crsr_pos_x = _mse_nxt_ptr_;
_mse_nxt_ptr_ = reg_crsr_pos_y - _mv_y_;
if(_mse_nxt_ptr_ < 0) reg_crsr_pos_y = 0;
else if(_mse_nxt_ptr_ > (cmn_bot<<1)) reg_crsr_pos_y = cmn_bot<<1;
else reg_crsr_pos_y = _mse_nxt_ptr_;
}
else b_mse_no_mvng = ON;
// else SetBit(mse_flg,MSE_NO_MVNG);
}
}
//==================================================================================
void SetMseBtn(void) //... set mouse button
{
U8 _mse_btn_;
_mse_btn_ = mse_rdata[1]&(RIGHT_BTN|LEFT_BTN);
if(_mse_btn_ != (mse_flg&(RIGHT_BTN|LEFT_BTN))){
b_mse_no_btn = OFF;
// ClearBit(mse_flg,MSE_NO_BTN);
mse_flg = (mse_flg & ~(RIGHT_BTN|LEFT_BTN))|_mse_btn_;
// if(BitClear(mse_flg,MSE_BTN_L)){ //... detecting low to high(button up) transition.
// SetBit(mse_flg,MSE_RLSE_LB);
// if(BitSet(mse_flg,MSE_PSHD_LB)) SetBit(mse_flg,MSE_CLK_LB);
// ClearBit(mse_flg,MSE_PSHD_LB);
// ClearBit(mse_flg,MSE_PSHNG_LB);
// }
// else{ //... detecting high to low(button down) transition.
// if(BitClear(mse_flg,MSE_PSHD_LB)&&BitClear(mse_flg,MSE_PSHNG_LB)){
// SetBit(mse_flg,MSE_PSHD_LB);
// ClearBit(mse_flg,MSE_RLSE_LB);
// SetBit(mse_flg,MSE_BTN_DWN_LB);
//
// if(BitClear(mse_flg,MSE_PSHD_RB)||BitSet(mse_flg,MSE_PSHNG_RB)){
// mse_btn_pshng_cnt = MSE_BTN_CNT_CHTR; //... default
// }
// }
// }
if(b_mse_btn_l == 0){ //... detecting low to high(button up) transition.
b_mse_rlse_lb = 1;
if(b_mse_pshd_lb == 1) b_mse_clk_lb = 1;
b_mse_pshd_lb = 0;
b_mse_pshng_lb = 0;
}
else{ //... detecting high to low(button down) transition.
if((b_mse_pshd_lb == 0)&&(b_mse_pshng_lb == 0)){
b_mse_pshd_lb = 1;
b_mse_rlse_lb = 0;
b_mse_btn_dwn_lb = 1;
if((b_mse_pshd_rb == 0)||(b_mse_pshng_rb == 1)){
mse_btn_pshng_cnt = MSE_BTN_CNT_CHTR; //... default
}
}
}
// if(BitClear(mse_flg,MSE_BTN_R)){ //... detecting low to high(button up) transition.
// SetBit(mse_flg,MSE_RLSE_RB);
// if(BitSet(mse_flg,MSE_PSHD_RB)) SetBit(mse_flg,MSE_CLK_RB);
// ClearBit(mse_flg,MSE_PSHD_RB);
// ClearBit(mse_flg,MSE_PSHNG_RB);
// }
// else{ //... detecting high to low(button down) transition.
// if(BitClear(mse_flg,MSE_PSHD_RB)&&BitClear(mse_flg,MSE_PSHNG_RB)){
// SetBit(mse_flg,MSE_PSHD_RB);
// ClearBit(mse_flg,MSE_RLSE_RB);
// SetBit(mse_flg,MSE_BTN_DWN_RB);
//
// if(BitClear(mse_flg,MSE_PSHD_LB)||BitSet(mse_flg,MSE_PSHNG_LB)){
// mse_btn_pshng_cnt = MSE_BTN_CNT_CHTR; //... default
// }
// }
// }
if(b_mse_btn_r == 0){ //... detecting low to high(button up) transition.
b_mse_rlse_rb = 1;
if(b_mse_pshd_rb == 1) b_mse_clk_rb = 1;
b_mse_pshd_rb = 0;
b_mse_pshng_rb = 0;
}
else{ //... detecting high to low(button down) transition.
if((b_mse_pshd_rb == 0)&&(b_mse_pshng_rb == 0)){
b_mse_pshd_rb = 1;
b_mse_rlse_rb = 0;
b_mse_btn_dwn_rb = 1;
if((b_mse_pshd_lb == 0)||(b_mse_pshng_lb == 1)){
mse_btn_pshng_cnt = MSE_BTN_CNT_CHTR; //... default
}
}
}
}
else{
if((b_mse_rlse_rb == 1)&&(b_mse_rlse_lb == 1)) b_mse_no_btn = ON;
// if(BitSet(mse_flg,MSE_RLSE_RB)&&BitSet(mse_flg,MSE_RLSE_LB)) SetBit(mse_flg,MSE_NO_BTN);
// if(BitSet(mse_flg,MSE_PSHD_LB)){
// if(mse_btn_pshng_cnt > 0) mse_btn_pshng_cnt--;
// else{
// if(BitClear(mse_flg,MSE_PSHNG_LB)){
// SetBit(mse_flg,MSE_PSHNG_LB); // pushing button checking
// }
// else{
// SetBit(mse_flg,MSE_PSHNG_CLK_LB); // continuous button checking
// }
//
//// mse_btn_pshng_cnt = MSE_BTN_CNT_CHTR>>3; //... default
// mse_btn_pshng_cnt = MSE_BTN_DLY_CNTNS; //... default
// }
// }
//
// if(BitSet(mse_flg,MSE_PSHD_RB)){
// if(mse_btn_pshng_cnt > 0) mse_btn_pshng_cnt--;
// else{
// if(BitClear(mse_flg,MSE_PSHNG_RB)){
// SetBit(mse_flg,MSE_PSHNG_RB); // pushing button checking
// }
// else{
// SetBit(mse_flg,MSE_PSHNG_CLK_RB); // continuous button checking
// }
//
//// mse_btn_pshng_cnt = MSE_BTN_CNT_CHTR>>3; //... default
// mse_btn_pshng_cnt = MSE_BTN_DLY_CNTNS; //... default
// }
// }
if(b_mse_pshd_lb == 1){
if(mse_btn_pshng_cnt > 0) mse_btn_pshng_cnt--;
else{
if(b_mse_pshng_lb == 0){
b_mse_pshng_lb = 1; // pushing button checking
}
else{
b_mse_pshng_clk_lb = 1; // continuous button checking
}
// mse_btn_pshng_cnt = MSE_BTN_CNT_CHTR>>3; //... default
mse_btn_pshng_cnt = MSE_BTN_DLY_CNTNS; //... default
}
}
if(b_mse_pshd_rb == 1){
if(mse_btn_pshng_cnt > 0) mse_btn_pshng_cnt--;
else{
if(b_mse_pshng_rb == 0){
b_mse_pshng_rb = 1; // pushing button checking
}
else{
b_mse_pshng_clk_rb = 1; // continuous button checking
}
// mse_btn_pshng_cnt = MSE_BTN_CNT_CHTR>>3; //... default
mse_btn_pshng_cnt = MSE_BTN_DLY_CNTNS; //... default
}
}
}
}
//==================================================================================
void RunMseOnOSDH(U8 _pth_prp, U8 _osd_pos_x, U8 _osd_pos_y, U8 _pos_x_l, U8 _pos_x_r, U8 _pos_y, U8 _pos_flg)
{
U8 _pth_, _prp_;
U8 _t1_;
_pth_ = _pth_prp&0x0f;//0xf0;
_prp_ = _pth_prp&0xf0;//0x0f;
if(((_osd_pos_x == _pos_x_l)||(_osd_pos_x == _pos_x_r))&&(_osd_pos_y == _pos_y)){
if(BitClear(mse_flg_on_osd,_pos_flg)){
SetBit(mse_flg_on_osd,_pos_flg);
if(_osd_pos_x == _pos_x_l) _t1_ = OSD_ARW_L_BIG;//OSD_MINUS_SML;
else _t1_ = OSD_ARW_R_BIG;//OSD_PLUS_SML;
WriteOSDFnt(_pth_,MASTER,_osd_pos_x,_osd_pos_y,OSD_MIX|1,_t1_);
}
}
else{
if(BitSet(mse_flg_on_osd,_pos_flg)){
ClearBit(mse_flg_on_osd,_pos_flg);
WriteOSDFnt(_pth_,MASTER,_pos_x_l,_pos_y,_prp_,OSD_ARW_L_SML);
WriteOSDFnt(_pth_,MASTER,_pos_x_r,_pos_y,_prp_,OSD_ARW_R_SML);
}
}
}
//==================================================================================
void RunMseOnOSDV(U8 _pth_prp, U8 _osd_pos_x, U8 _osd_pos_y, U8 _pos_x, U8 _pos_y_t, U8 _pos_y_b, U8 _pos_flg)
{
U8 _pth_, _prp_;
U8 _t1_;
_pth_ = _pth_prp&0x0f;//0xf0;
_prp_ = _pth_prp&0xf0;//0x0f;
if((_osd_pos_x == _pos_x)&&((_osd_pos_y == _pos_y_t)||(_osd_pos_y == _pos_y_b))){
if(BitClear(mse_flg_on_osd,_pos_flg)){
SetBit(mse_flg_on_osd,_pos_flg);
if(_osd_pos_y == _pos_y_t) _t1_ = OSD_ARW_U_BIG;//OSD_MINUS_SML;
else _t1_ = OSD_ARW_D_BIG;//OSD_PLUS_SML;
WriteOSDFnt(_pth_,MASTER,_osd_pos_x,_osd_pos_y,OSD_MIX|1,_t1_);
}
}
else{
if(BitSet(mse_flg_on_osd,_pos_flg)){
ClearBit(mse_flg_on_osd,_pos_flg);
WriteOSDFnt(_pth_,MASTER,_pos_x,_pos_y_t,_prp_,OSD_ARW_U_SML);
WriteOSDFnt(_pth_,MASTER,_pos_x,_pos_y_b,_prp_,OSD_ARW_D_SML);
}
}
}
//==================================================================================
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?