人気ブログランキング | 話題のタグを見る

ぬるぽを見かけたら 全力でぶっ叩くのみ


by Denullpo Smasher Hammerson
カレンダー
S M T W T F S
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31

右手にトラックボールを、左手にG13を

奮発してこんなもん買ってしまったわけですが
[ケンジントン ExpertMouse (OpticalBlack) (USB/PS2)]

これ、使い勝手はいいんですが4ボタンというのが難点。
左上のがホイールボタンで右上のが拡張ボタン1という変態的な配置。
なので、Explorerやwebブラウザでの戻る/進む的な動作を期待してるとハマる。
(ここらへん、素直にドライバ入れときゃ解決なんだろうけど)

そんなわけで、拡張ボタンはG13側で操作することにした。
Gキーの20と22を拡張ボタンに割り当て。ついでに、間のG21もマウスカーソル操作
として使えるようにしてみた。単体で押すとカーソルが画面中央に移動で、
カーソルを動かしながらだとその方向の画面端に移動。
Orchisとか画面端起動なランチャとのコンボが強力で素敵。

あと、G13のスティックは1ドット単位で動かせるように改良してます。
Mキーでスクリプト/マウス/ジョイスティックを切り替えるようにしたので、
押した時間で移動量変えるとか変態的な機能はグッバイということで。





-- init --------------------
key={}
key[1]={};
key[2]={};
key[3]={};
for i=1,19 do
    key[1][i]=-1;
    key[2][i]=-1;
    key[3][i]=-1;
end

scr_w=1280;
scr_h=1024;
curdx=(65536+(scr_w/2))/scr_w;
curdy=(65536+(scr_h/2))/scr_h;

lastcurx=0;
lastcury=0;

-- key definition ----------
-- ここで、 key[M番号][G番号]=キーコード という具合に設定 --

function PressG(arg)
    if arg==23 then
        PressMouseButton(1);
    elseif arg==25 then
        PressMouseButton(2);
    elseif arg==24 then
        PressMouseButton(3);
    elseif arg==20 then
        PressMouseButton(4);
    elseif arg==22 then
        PressMouseButton(5);
    elseif arg==21 then
        lastcurx,lastcury=GetMousePosition();
    elseif arg==26 then
    elseif arg==27 then
    elseif arg==28 then
    elseif arg==29 then
    else
        m=GetMKeyState();
        k=key[m][arg];
        if k>=0 then
            PressKey(k);
        end
    end
end

function ReleaseG(arg)
    if arg==23 then
        ReleaseMouseButton(1);
    elseif arg==25 then
        ReleaseMouseButton(2);
    elseif arg==24 then
        ReleaseMouseButton(3);
    elseif arg==20 then
        ReleaseMouseButton(4);
    elseif arg==22 then
        ReleaseMouseButton(5);
    elseif arg==21 then
        x,y=GetMousePosition();
        x=x-lastcurx;
        y=y-lastcury;
        if x==0 and y==0 then
            MoveMouseToVirtual(32768,32768);
        elseif math.abs(x)>math.abs(y) then
            if x<0 then
                MoveMouseToVirtual(0,lastcury);
            elseif x>0 then
                MoveMouseToVirtual(65535,lastcury);
            end
        else
            if y<0 then
                MoveMouseToVirtual(lastcurx,0);
            elseif y>0 then
                MoveMouseToVirtual(lastcurx,65535);
            end
        end
    elseif arg==26 then
        x,y=GetMousePosition();
        MoveMouseToVirtual(x,y-curdy);
    elseif arg==27 then
        x,y=GetMousePosition();
        MoveMouseToVirtual(x+curdx,y);
    elseif arg==28 then
        x,y=GetMousePosition();
        MoveMouseToVirtual(x,y+curdy);
    elseif arg==29 then
        x,y=GetMousePosition();
        MoveMouseToVirtual(x-curdx,y);
    else
        m=GetMKeyState();
        k=key[m][arg];
        if k>=0 then
            ReleaseKey(k);
        end
    end
end

function OnEvent(event, arg)
    if event=="G_PRESSED" then
        PressG(arg);
    elseif event=="G_RELEASED" then
        ReleaseG(arg);
    else
        OutputLogMessage("event = %s, arg = %s\n", event, arg);
    end
end

相変わらず行末に余計なセミコロン付いてますが気にしない
by denullpo | 2011-02-27 00:16 | こっち関係