Here is a pure Source for DBP without a DLL or plugin.
Example WiiMote Motion ...
hWii = WiiConnect()
if hWii = -1 then print "WiiMote not found!" : wait key : WiiDisconnect(hWii) : end
sync on : sync rate 0 : autocam off : color backdrop 0 : disable escapekey
make object box 1, 2, 2, 4 : position camera 0, 0, -5
WiiInit(hWii)
repeat
set cursor 0, 0 : print "FPS: ", screen fps()
WiiRead(hWii)
rotate object 1, curvevalue(WiiMotionY() * 2, object angle x(1), 100), 0, curvevalue(WiiMotionX(), object angle z(1), 100)
for i = 0 to 21
print hex$(PeekByte(RepData, i)), " ";
next i
sync
until WiiButtonA() and WiiButtonB()
WiiDisconnect(hWii)
end
Include Functions for DBP ...
function WiiConnect()
#constant HID = 253
#constant SETUPAPI = 254
#constant KERNEL32 = 255
load dll "hid.dll", HID
load dll "setupapi.dll", SETUPAPI
load dll "kernel32.dll", KERNEL32
global WiTimer
global RepTime
global RepSize : RepSize = make memory(4)
global RepData : RepData = make memory(22)
HidGuid = make memory(16)
HidAttrib = make memory(10) : *HidAttrib = 10
DevData = make memory(28) : *DevData = 28
DevDetail = make memory(260) : *DevDetail = 5
call dll HID, "HidD_GetHidGuid", HidGuid
DevInfo = call dll(SETUPAPI, "SetupDiGetClassDevsA", HidGuid, 0, 0, 18)
while call dll(SETUPAPI, "SetupDiEnumDeviceInterfaces", DevInfo, 0, HidGuid, Index, DevData)
call dll SETUPAPI, "SetupDiGetDeviceInterfaceDetailA", DevInfo, DevData, DevDetail, 255, 0, 0
DevPath$ = PeekStr(DevDetail, 4)
hDev = call dll(KERNEL32, "CreateFileA", DevPath$, 0xc0000000, 3, 0, 3, 0, 0)
if hDev <> -1
call dll HID, "HidD_GetAttributes", hDev, HidAttrib
if PeekWord(HidAttrib, 4) = 1406 and PeekWord(HidAttrib, 6) = 774 then exit
call dll KERNEL32, "CloseHandle", hDev
endif
inc Index
endwhile
call dll SETUPAPI, "SetupDiDestroyDeviceInfoList", DevInfo
delete memory HidGuid
delete memory HidAttrib
delete memory DevData
delete memory DevDetail
endfunction hDev
function WiiDisconnect(hWii)
if hWii <> -1 then call dll KERNEL32, "CloseHandle", hWii
delete memory RepSize
delete memory RepData
delete dll HID
delete dll SETUPAPI
delete dll KERNEL32
endfunction
function WiiInit(hWii)
WiiLED(hWii, %0001)
WiiRumble(hWii, 1)
wait 100
WiiWrite(hWii, "120431")
endfunction
function WiiBatterie(hWii)
WiiWrite(hWii, "1500") : WiiReadEx(hWii, 0x20)
r = PeekByte(RepData, 6) / 2
endfunction r
function WiiLED(hWii, n)
WiiWrite(hWii, "11" + hex$(n) + "0")
endfunction
function WiiRumble(hWii, n)
WiiWrite(hWii, "150" + hex$(n))
endfunction
function WiiMotionX()
r = 500 - (PeekByte(RepData, 3) << 2 || PeekByte(RepData, 1) >> 5 && %11)
endfunction r
function WiiMotionY()
r = (PeekByte(RepData, 4) << 1 || PeekByte(RepData, 2) >> 5 && %01) - 250
endfunction r
function WiiMotionZ()
r = (PeekByte(RepData, 5) << 1 || PeekByte(RepData, 2) >> 6 && %01) - 300
endfunction r
function WiiButtonA()
r = PeekByte(RepData, 2) >> 3 && 1
endfunction r
function WiiButtonB()
r = PeekByte(RepData, 2) >> 2 && 1
endfunction r
function WiiButtonMinus()
r = PeekByte(RepData, 2) >> 4 && 1
endfunction r
function WiiButtonPlus()
r = PeekByte(RepData, 1) >> 4 && 1
endfunction r
function WiiButtonHome()
r = PeekByte(RepData, 2) >> 7 && 1
endfunction r
function WiiButtonOne()
r = PeekByte(RepData, 2) >> 1 && 1
endfunction r
function WiiButtonTwo()
r = PeekByte(RepData, 2) && 1
endfunction r
function WiiPadLeft()
r = PeekByte(RepData, 1) && 1
endfunction r
function WiiPadRight()
r = PeekByte(RepData, 1) >> 1 && 1
endfunction r
function WiiPadDown()
r = PeekByte(RepData, 1) >> 2 && 1
endfunction r
function WiiPadUp()
r = PeekByte(RepData, 1) >> 3 && 1
endfunction r
function WiiReadEx(hWii, ID)
repeat
call dll KERNEL32, "ReadFile", hWii, RepData, 22, RepSize, 0
until PeekByte(RepData, 0) = ID
endfunction
function WiiRead(hWii)
if timer() > RepTime
call dll KERNEL32, "ReadFile", hWii, RepData, 22, RepSize, 0
RepTime = timer() + 10
endif
endfunction
function WiiWrite(hWii, d$)
p = RepData
for i = 1 to len(d$) step 2
h = asc(mid$(d$, i)) - 48 : l = asc(mid$(d$, i + 1)) - 48
b = (h - (h > 9) * 7) << 4 : *p = b + (l - (l > 9) * 7) : inc p
next i
call dll KERNEL32, "WriteFile", hWii, RepData, 22, RepSize, 0
endfunction
function PeekByte(p, o)
b as byte : inc p, o : b = *p
endfunction b
function PeekWord(p, o)
w as word : inc p, o : w = *p
endfunction w
function PeekStr(p, o)
inc p, o : repeat : s$ = s$ + chr$(*p) : inc p : until chr$(*p) = ""
endfunction s$
hWii = WiiConnect()
Handle for WiiMote.
WiiDisconnect(hWii)
Free all WiiMote stuff.
WiiInit(hWii)
Init befor main loop.
bat = WiiBatterie(hWii)
Batterie status in %.
WiiLED(hWii, n)
4 Bits for WiiMote LED's.
(Ex. WiiLED(hWii, %0001) turn the left LED on)
WiiRumble(hWii, n)
On = 1 or Off = 0.
X = WiiMotionX() / Y = WiiMotionY() / Z = WiiMotionz()
Value from X_(10bit): -512 to 512
Value from Y__(9bit): -256 to 256
Value from Z__(9bit): -256 to 256
B = WiiButton?()
All buttons give a TRUE(1) if pressed.
P = WiiPad?()
All Pads give a TRUE(1) if pressed.
WiiRead(hWii)
Fast read data report.
WiiReadEx(hWii, ID)
Read report and wait of request.
WiiWrite(hWii, d$)
Do nothing here, or you know wath to do.