Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- gLastX = deviceaxis(deviceHandle, 0); // 0 = X axis (left/right)
- gLastY = deviceaxis(deviceHandle, 1); // 1 = Y axis (up/down)
- gLastZ = deviceaxis(deviceHandle, 2); // 2 = Z axis (in/out)
- gSendW = inputsender(KEY_W);
- gSendA = inputsender(KEY_A);
- gSendS = inputsender(KEY_S);
- gSendD = inputsender(KEY_D);
- function HapticsThink (deviceHandle)
- {
- local currentX = deviceaxis(deviceHandle, 0); // 0 = X axis (left/right)
- local currentY = deviceaxis(deviceHandle, 1); // 1 = Y axis (up/down)
- local currentZ = deviceaxis(deviceHandle, 2); // 2 = Z axis (in/out)
- // Just crossed left edge
- if (gLastX > -100 && currentX <= -100)
- {
- gSendA.press();
- }
- else if (gLastX <= -100 && currentX > -100) //uncrossed left edge
- {
- gSendA.release();
- }
- // Just crossed right edge
- if (gLastX < 100 && currentX >= 100)
- {
- gSendD.press();
- }
- else if (gLastX >= 100 && currentX < 100) //uncrossed right edge
- {
- gSendD.release();
- }
- // Just crossed top edge
- if (gLastY < 100 && currentY >= 100)
- {
- gSendW.press();
- }
- else if (gLastY >= 100 && currentY < 100) //uncrossed top edge
- {
- gSendW.release();
- }
- // Just crossed bottom edge
- if (gLastY > -100 && currentY <= -100)
- {
- gSendS.press();
- }
- else if (gLastY <= -100 && currentY > -100) //uncrossed bottom edge
- {
- gSendS.release();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement