在網路上看到Objective Development這個奧地利公司的現成範例 ,使用的埋控是AVR的ATTiny45. 剛好2根電源,2根USB 信號, 另外4根腳可以來做熱舞墊最終版改裝的上下左右輸入. 有興趣的人可以先去看看.
實際做出來的範例可以看自製 USB HID搖桿
2007年9月27日 星期四
超簡單的USB電路
2007年9月24日 星期一
使用 wii遙控器來做PCB layout
前一篇有提到 ,本來興致勃勃地要拿wii控制器來玩全民打棒球 ,但是中間遇到了困難就再用google找有關線上遊戲擋外掛的資料.在過程中又激盪出一個特別的想法.
在我工作上因為人力很精簡 ,有時我要充個數去做PCB 的layout工作. 一做起碼就是一兩天跑不掉 ,整天就是左手掛在鍵盤上按快捷鍵 ,右手移動滑鼠. 如果把螢幕遮住還真跟打online game沒什麼兩樣咧 !一塊板子layout完也是腰酸背痛的. 正好在找資料的過程中看到了一盞明燈---手裡鍵
乍看之下 ,wii的控制器跟手裡鍵長得還 真像 啊 .在寫了一個glovePIE 的 script後稍微試了一下, 以後要再被抓去充數lay PCB時就可以舒服地靠在椅子上輕鬆lay囉!
另外還有一個理由跟手裡鍵的說明又是不謀而合 ,既然有了glovePIE可以寫腳本 ,那以後就不必再被PowerPCB這種很貴的商用軟體給綁住了 ,不論是用便宜的EAGLE甚至是gEDA裡的PCB ,只要改寫腳本檔都可以使用相同的方式來操作了 ,厲害吧 ?Protel 快降價吧 ,PowerPCB 快降價吧 !
// Code for using PADS PowerPCB 5.x
'debug = 'x '+ mouse.CursorPosX + 'y' + mouse.Cursorposy
'debug= 'pitch '+ wiimote.pitch
if var.init==0 then
var.init=1
var.width=10
endif
if wiimote.B==false then
key.Shift=wiimote.A
if wiimote.one then
var.xpos=mouse.CursorPosX
var.ypos=mouse.CursorPosy
key.Escape=true
wait (1ms)
key.Escape=false
mouse.CursorPos=[680, 472]
mouse.RightButton=true
wait (1ms)
mouse.RightButton=false
wait (1ms)
mouse.CursorPos=[731, 511]
mouse.LeftButton=true
wait (1ms)
mouse.LeftButton=false
mouse.CursorPos=[var.xpos,var.ypos]
wait (1s)
endif
if wiimote.two then
var.xpos=mouse.CursorPosX
var.ypos=mouse.CursorPosy
key.Escape=true
wait (1ms)
key.Escape=false
mouse.CursorPos=[680, 472]
mouse.RightButton=true
wait (1ms)
mouse.RightButton=false
wait (1ms)
mouse.CursorPos=[731, 623]
mouse.LeftButton=true
wait (1ms)
mouse.LeftButton=false
mouse.CursorPos=[var.xpos,var.ypos]
wait (1s)
endif
if wiimote.Left then
mouse.CursorPos=[14, 963]
mouse.LeftButton=true
wait (1ms)
mouse.LeftButton=false
wait (100ms)
endif
if wiimote.right then
mouse.CursorPos=[1250, 963]
mouse.LeftButton=true
wait (1ms)
mouse.LeftButton=false
wait (100ms)
endif
if wiimote.up then
mouse.CursorPos=[1265, 98]
mouse.LeftButton=true
wait (1ms)
mouse.LeftButton=false
wait (100ms)
endif
if wiimote.down then
mouse.CursorPos=[1265, 942]
mouse.LeftButton=true
wait (1ms)
mouse.LeftButton=false
wait (100ms)
endif
if wiimote.Minus then
var.width --
type 'w '+ var.width
key.Enter=true
wait (0.5ms)
key.Enter=false
wait (100ms)
endif
if wiimote.Plus then
var.width ++
type 'w '+ var.width
key.Enter=true
wait (0.5ms)
key.Enter=false
wait (100ms)
endif
else
if wiimote.a then
^Q=true
wait (1ms)
^Q=false
wait (0.5s)
end if
if wiimote.Roll > 50 then
^R=true
wait (1ms)
^R=false
wait (0.5s)
endif
if wiimote.Pitch > 50 then
type 'ss '
wait (0.5s)
endif
if wiimote.Minus then
var.width = var.width-5
type 'w '+ var.width
key.Enter=true
wait (0.5ms)
key.Enter=false
wait (1ms)
endif
if wiimote.Plus then
var.width =var.width+5
type 'w '+ var.width
key.Enter=true
wait (0.5ms)
key.Enter=false
wait (1ms)
endif
endif
if wiimote.home then
debug=' home'
type 'w '+ var.width
key.Enter=true
wait (0.5ms)
key.Enter=false
wait (0.5ms)
endif
if mouse.WheelDown then
'debug=' wheel down'
mouse.CursorPos=[640, 512]
^W=true
wait (0.5ms)
^W=false
mouse.RightButton=true
wait (0.5ms)
mouse.RightButton=false
wait (0.1s)
key.Escape=true
wait (0.1ms)
key.Escape=false
endif
if mouse.wheelup then
'debug=' wheel up'
mouse.CursorPos=[640, 512]
^W=true
wait (0.5ms)
^W=false
mouse.LeftButton=true
wait (0.5ms)
mouse.LeftButton=false
wait (0.1s)
key.Escape=true
wait (1ms)
key.Escape=false
endif
if mouse.MiddleButton
'debug=' middle'
^B=true
wait (0.5ms)
^B=false
endif
//
//
使用 wii 手把 來玩全民打棒球
平常總是以工作太忙為藉口而不運動
不過在任天堂wii的體感控制器推出後 ,藉口居然自己消失了
居然我也想寓運動於遊戲 ,第一個想到的當然是連結到現在很熱門的全民打棒球.這樣以後運動,娛樂,交友......一次到位
於是就用google找了一下使用wiimote控制PC的相關資料 ,之後便開始試著連結到全民打棒球的遊戲中.可惜 ,從未玩過線上遊戲的我涉事未深 ,不知道江湖的黑暗.線上遊戲公司為了防止作弊掛網洗錢洗寶物 ,都加上了防護程式來擋掉外掛程式, 當然網路上找到的方法也不通了.
還好 ,山不轉路轉. 通往目的地的路不是只有一條. 從台北到高雄可以走中山高也可以走福爾摩沙高, 甚至可以繞台2線和台9線走東部.
1/6/08 更新:低調增加一個連結.因已發現有人公開實做出來的程式,就不再刻意藏了.
用google可以查到在全民打棒球官網上的搖桿使用小教學提到了可以利用JoyToKey這程式來用搖桿玩, 所以我們只需另外開闢一條路把wiimote的信號用glovePIE和PPJoy模擬成搖桿就可以了.
目前測試出的方案為:
glovePIE -> PPJoy -> JoyToKey
4/19/08補充的各種藍芽驅動程式連線教學
貓星球提供的藍芽連接wiimote教學
GlovePIE 的簡易全民打棒球腳本
// Code for playing BBONLINE
ppjoy.Digital0=wiimote.A
ppjoy.Digital1=wiimote.b
ppjoy.Digital2=wiimote.Up
ppjoy.Digital3=wiimote.Down
ppjoy.Digital4=wiimote.Left
ppjoy.Digital5=wiimote.Right
ppjoy.Digital6=wiimote.One
ppjoy.Digital7=wiimote.Two
ppjoy.Digital8=wiimote.Plus
ppjoy.Digital9=wiimote.Minus
ppjoy.Digital10=wiimote.Home
if abs (wiimote.gz) > 3.5 then
ppjoy.Digital12=true
wait (5 ms)
ppjoy.Digital12=false
endif
//
//