Added procontroll for joypad usage.

This commit is contained in:
Sandy Noble 2013-03-31 02:01:55 +01:00
parent 33f5642fa9
commit f81386f61c
5 changed files with 81 additions and 9 deletions

View File

@ -124,6 +124,14 @@ void button_mode_liveCaptureFromLive()
{
webcam_captureCurrentImage();
}
void button_mode_liveClearCapture()
{
captureShape = null;
}
void button_mode_liveAddCaption()
{
}
void button_mode_liveConfirmDraw()
{
@ -131,13 +139,6 @@ void button_mode_liveConfirmDraw()
float scaling = getDisplayMachine().inMM(getDisplayMachine().getPictureFrame().getWidth()) / captureShape.getWidth();
PVector position = new PVector(getDisplayMachine().inMM(getDisplayMachine().getPictureFrame().getPosition().x), getDisplayMachine().inMM(getDisplayMachine().getPictureFrame().getPosition().y) + (captureShape.getHeight() * scaling));
// float scaling = getDisplayMachine().getPictureFrame().getWidth() / captureShape.getWidth();
// println("Scaling: " + scaling);
//
// PVector position = getDisplayMachine().getPictureFrame().getPosition();
//
// println("CApture shape: " + captureShape);
sendVectorShapes(captureShape, scaling, position);
}

View File

@ -703,6 +703,8 @@ List<String> getControlNamesForWebcamPanel()
controlNames.add(MODE_LIVE_SIMPLIFICATION_VALUE);
controlNames.add(MODE_LIVE_POSTERISE_VALUE);
controlNames.add(MODE_LIVE_CAPTURE_FROM_LIVE);
controlNames.add(MODE_LIVE_CANCEL_CAPTURE);
controlNames.add(MODE_LIVE_ADD_CAPTION);
controlNames.add(MODE_LIVE_CONFIRM_DRAW);
return controlNames;
}
@ -906,6 +908,8 @@ Map<String, String> buildControlLabels()
result.put(MODE_LIVE_POSTERISE_VALUE, "Posterise");
result.put(MODE_LIVE_CAPTURE_FROM_LIVE, "Capture");
result.put(MODE_LIVE_CONFIRM_DRAW, "Draw capture");
result.put(MODE_LIVE_CANCEL_CAPTURE, "Cancel capture");
result.put(MODE_LIVE_ADD_CAPTION, "Add caption");
return result;
@ -1037,6 +1041,8 @@ Set<String> buildControlNames()
result.add(MODE_LIVE_POSTERISE_VALUE);
result.add(MODE_LIVE_CAPTURE_FROM_LIVE);
result.add(MODE_LIVE_CONFIRM_DRAW);
result.add(MODE_LIVE_CANCEL_CAPTURE);
result.add(MODE_LIVE_ADD_CAPTION);
return result;
}

31
gamepad.pde Normal file
View File

@ -0,0 +1,31 @@
ControllIO controllIO;
ControllDevice joypad;
ControllCoolieHat cooliehat;
ControllStick leftStick;
ControllStick rightStick;
ControllButton buttonA;
ControllButton buttonB;
ControllButton buttonX;
ControllButton buttonY;
void gamepad_init()
{
controllIO = ControllIO.getInstance(this);
joypad = controllIO.getDevice("Controller (Xbox 360 Wireless Receiver for Windows)");
joypad.printButtons();
buttonA = joypad.getButton("Button 0");
buttonB = joypad.getButton("Button 1");
buttonX = joypad.getButton("Button 2");
buttonY = joypad.getButton("Button 3");
buttonA.plug(this, "buttonARelease", ControllIO.ON_RELEASE);
}
void buttonARelease()
{
button_mode_liveCaptureFromLive();
}

View File

@ -8,6 +8,9 @@ import org.apache.batik.svggen.font.table.*;
import org.apache.batik.svggen.font.*;
import java.util.zip.CRC32;
import procontroll.*;
//import net.java.games.input.*;
// for OSX
import java.text.*;
import java.util.*;
@ -310,6 +313,8 @@ static final String MODE_LIVE_BLUR_VALUE = "numberbox_mode_liveBlurValue";
static final String MODE_LIVE_SIMPLIFICATION_VALUE = "numberbox_mode_liveSimplificationValue";
static final String MODE_LIVE_POSTERISE_VALUE = "numberbox_mode_livePosteriseValue";
static final String MODE_LIVE_CAPTURE_FROM_LIVE = "button_mode_liveCaptureFromLive";
static final String MODE_LIVE_CANCEL_CAPTURE = "button_mode_liveClearCapture";
static final String MODE_LIVE_ADD_CAPTION = "button_mode_liveAddCaption";
static final String MODE_LIVE_CONFIRM_DRAW = "button_mode_liveConfirmDraw";
@ -451,6 +456,7 @@ public boolean useWindowedConsole = false;
static boolean drawingLiveVideo = false;
static boolean drawingWebcamShape = true;
static boolean flipWebcamImage = true;
static PImage liveImage = null;
static PImage processedLiveImage = null;
@ -537,6 +543,7 @@ void setup()
addEventListeners();
gamepad_init();
liveCamera = new JMyron();
liveCamera.start(640,480);
@ -809,7 +816,7 @@ void drawWebcamPage()
if (displayingInfoTextOnInputPage)
showText(250,45);
drawStatusText((int)statusTextPosition.x, (int)statusTextPosition.y);
showCommandQueue((int) getDisplayMachine().getOutline().getRight()+6, 20);
showCommandQueue((int) width-200, 20);
}

View File

@ -4,6 +4,33 @@ public PImage webcam_buildLiveImage()
PImage pimg = createImage(640,480, RGB);
pimg.loadPixels();
pimg.pixels = liveCamera.image();
// flip the image left to right
if (flipWebcamImage)
{
List<int[]> list = new ArrayList<int[]>(480);
for (int r=0; r<pimg.pixels.length; r+=640)
{
int[] temp = new int[640];
for (int c=0; c<640; c++)
{
temp[c] = pimg.pixels[r+c];
}
list.add(temp);
}
// reverse the list
Collections.reverse(list);
for (int r=0; r<list.size(); r++)
{
for (int c=0; c<640; c++)
{
pimg.pixels[(r*640)+c] = list.get(r)[c];
}
}
}
pimg.updatePixels();
return pimg;
}