Default resolution is now 352x288

It Can be changed through the preferences panel (WIP)
(started implementation for a screen-keyboard-listener
 to capture keystrokes acting like cocoa-based keyboard
 controller)
This commit is contained in:
Xant
2009-08-22 15:36:53 +02:00
parent 3c7b237062
commit 9f867ed63b
11 changed files with 231 additions and 52 deletions
+2 -2
View File
@@ -11,8 +11,8 @@
#import <CFreej.h>
#import <CVLayer.h>
#define DEFAULT_FREEJ_WIDTH 512
#define DEFAULT_FREEJ_HEIGHT 384
#define DEFAULT_FREEJ_WIDTH 352
#define DEFAULT_FREEJ_HEIGHT 288
@implementation CFreej
+1 -3
View File
@@ -21,12 +21,10 @@
- (IBAction)stop:(id)sender;
@end;
class CVF0rLayer : public GenF0rLayer, public CVLayer
class CVF0rLayer : public CVLayer, public GenF0rLayer
{
public:
CVF0rLayer(CVLayerView *view, char *generatorName, Context *freej);
~CVF0rLayer();
void *feed();
void start();
void stop();
};
+5 -17
View File
@@ -110,10 +110,10 @@
CVLayer *toDelete;
if (layer) {
[lock lock];
toDelete = layer;
toDelete = (CVLayer *)layer;
layer = NULL;
toDelete->stop();
[lock unlock];
toDelete->stop();
delete toDelete;
}
}
@@ -173,9 +173,9 @@ CVF0rLayer::CVF0rLayer(CVLayerView *view, char *generatorName, Context *_freej)
CVF0rLayer::~CVF0rLayer()
{
CVLayer *layerPersonality = (CVLayer *)this;
layerPersonality->buffer = NULL; // XXX
//if (swap_buffer)
//free(swap_buffer);
swap_buffer = NULL;
}
void *
@@ -186,15 +186,3 @@ CVF0rLayer::feed()
return swap_buffer;
}
void
CVF0rLayer::start()
{
((GenF0rLayer *)this)->start();
}
void
CVF0rLayer::stop()
{
GenF0rLayer *f0rPersonality = (GenF0rLayer *)this;
f0rPersonality->stop();
}
+6 -5
View File
@@ -26,9 +26,8 @@
currentFrame = nil;
currentPts = 0;
previousPts = 0;
Context *ctx = [freej getContext];
width = ctx->screen->w;
height = ctx->screen->h;
width = 352;
height = 288;
lock = [[NSRecursiveLock alloc] init];
}
return self;
@@ -72,9 +71,11 @@
NSError *o_returnedError;
Context *ctx = [freej getContext];
width = ctx->screen->w;
height = ctx->screen->h;
/* Hack - using ma resolution seems to lower cpu consuption for some reason */
int h = (ctx->screen->h < CV_GRABBER_HEIGHT_MAX)?ctx->screen->h:CV_GRABBER_HEIGHT_MAX;
int w = (ctx->screen->w < CV_GRABBER_WIDTH_MAX)?ctx->screen->w:CV_GRABBER_WIDTH_MAX;
int h = (height < CV_GRABBER_HEIGHT_MAX)?height:CV_GRABBER_HEIGHT_MAX;
int w = (width < CV_GRABBER_WIDTH_MAX)?width:CV_GRABBER_WIDTH_MAX;
device = [QTCaptureDevice defaultInputDeviceWithMediaType: QTMediaTypeVideo];
if( !device )
+7
View File
@@ -82,6 +82,13 @@ class CVScreen;
- (IBAction)stopExport:(id)sender;
- (IBAction)setExportFile:(id)sender;
@end
@interface CVScreenController : NSWindowController {
}
@end
#else
class CVScreenView;
#endif // __cocoa
+28
View File
@@ -720,6 +720,34 @@ bail:
@end
@implementation CVScreenController
// handle keystrokes
- (void)keyDown:(NSEvent *)event
{
// NSLog(@"Keypress (%hu, modifier flags: 0x%x) %@\n", [event keyCode], [event modifierFlags], [event charactersIgnoringModifiers]);
NSString *modifier = nil;
switch ([event modifierFlags]) {
case NSShiftKeyMask:
modifier = [NSString stringWithUTF8String:"shift_"];
break;
case NSControlKeyMask:
modifier = [NSString stringWithUTF8String:"control_"];
break;
case NSAlternateKeyMask:
modifier = [NSString stringWithUTF8String:"alt_"];
break;
case NSCommandKeyMask:
modifier = [NSString stringWithUTF8String:"cmd_"];
break;
case NSFunctionKeyMask:
modifier = [NSString stringWithUTF8String:"fn_"];
break;
}
}
@end
CVScreen::CVScreen(int w, int h)
: ViewPort(w, h) {
init(w, h);
+123 -25
View File
@@ -8,12 +8,12 @@
<string key="IBDocument.HIToolboxVersion">353.00</string>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="57"/>
<integer value="2737"/>
<integer value="2212"/>
<integer value="1887"/>
<integer value="2738"/>
<integer value="1575"/>
<integer value="966"/>
<integer value="2788"/>
<integer value="1887"/>
<integer value="2212"/>
<integer value="57"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -2102,7 +2102,7 @@ ARcABAAAAAEAAAACARwAAwAAAAEAAQAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA</bytes>
<object class="NSWindowTemplate" id="201200383">
<int key="NSWindowStyleMask">257</int>
<int key="NSWindowBacking">2</int>
<string key="NSWindowRect">{{22, 376}, {512, 384}}</string>
<string key="NSWindowRect">{{22, 472}, {352, 288}}</string>
<int key="NSWTFlags">1677722624</int>
<string key="NSWindowTitle">Output</string>
<string key="NSWindowClass">NSWindow</string>
@@ -2117,7 +2117,7 @@ ARcABAAAAAEAAAACARwAAwAAAAEAAQAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA</bytes>
<reference key="NSNextResponder" ref="546438216"/>
<int key="NSvFlags">1298</int>
<object class="NSPSMatrix" key="NSDrawMatrix"/>
<string key="NSFrameSize">{512, 384}</string>
<string key="NSFrameSize">{352, 288}</string>
<reference key="NSSuperview" ref="546438216"/>
<object class="NSOpenGLPixelFormat" key="NSPixelFormat">
<object class="NSMutableData" key="NSPixelAttributes">
@@ -2126,7 +2126,7 @@ ARcABAAAAAEAAAACARwAAwAAAAEAAQAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA</bytes>
</object>
</object>
</object>
<string key="NSFrameSize">{512, 384}</string>
<string key="NSFrameSize">{352, 288}</string>
<reference key="NSSuperview"/>
</object>
<string key="NSScreenRect">{{0, 0}, {1280, 778}}</string>
@@ -3286,11 +3286,11 @@ ARcABAAAAAEAAAACARwAAwAAAAEAAQAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA</bytes>
<string key="NSContents"/>
<reference key="NSSupport" ref="471700364"/>
<reference key="NSControlView" ref="694022042"/>
<double key="NSMaxValue">3.000000e+00</double>
<double key="NSMaxValue">4.000000e+00</double>
<double key="NSMinValue">1.000000e+00</double>
<double key="NSValue">2.000000e+00</double>
<double key="NSAltIncValue">0.000000e+00</double>
<int key="NSNumberOfTickMarks">3</int>
<int key="NSNumberOfTickMarks">4</int>
<int key="NSTickMarkPosition">1</int>
<bool key="NSAllowsTickMarkValuesOnly">YES</bool>
<bool key="NSVertical">NO</bool>
@@ -3363,7 +3363,7 @@ ARcABAAAAAEAAAACARwAAwAAAAEAAQAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA</bytes>
<object class="NSTextField" id="81294487">
<reference key="NSNextResponder" ref="481198432"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{221, 169}, {44, 11}}</string>
<string key="NSFrame">{{250, 169}, {44, 11}}</string>
<reference key="NSSuperview" ref="481198432"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="787918391">
@@ -3380,6 +3380,22 @@ ARcABAAAAAEAAAACARwAAwAAAAEAAQAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA</bytes>
<reference key="NSTextColor" ref="382279749"/>
</object>
</object>
<object class="NSTextField" id="891666784">
<reference key="NSNextResponder" ref="481198432"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{192, 169}, {44, 11}}</string>
<reference key="NSSuperview" ref="481198432"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="1072323581">
<int key="NSCellFlags">68288064</int>
<int key="NSCellFlags2">272892928</int>
<string key="NSContents">352x288</string>
<reference key="NSSupport" ref="22"/>
<reference key="NSControlView" ref="891666784"/>
<reference key="NSBackgroundColor" ref="285277074"/>
<reference key="NSTextColor" ref="382279749"/>
</object>
</object>
<object class="NSTextField" id="666830879">
<reference key="NSNextResponder" ref="481198432"/>
<int key="NSvFlags">268</int>
@@ -153327,6 +153343,9 @@ AAgAAQABAAEAAQ</bytes>
<string key="NSScreenRect">{{0, 0}, {1440, 878}}</string>
<string key="NSMaxSize">{3.40282e+38, 3.40282e+38}</string>
</object>
<object class="NSCustomObject" id="953869446">
<string key="NSClassName">CVScreenController</string>
</object>
</object>
<object class="IBObjectContainer" key="IBDocument.Objects">
<object class="NSMutableArray" key="connectionRecords">
@@ -154435,6 +154454,54 @@ AAgAAQABAAEAAQ</bytes>
</object>
<int key="connectionID">2810</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">filterPanel</string>
<reference key="source" ref="170901569"/>
<reference key="destination" ref="567669164"/>
</object>
<int key="connectionID">2811</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">freej</string>
<reference key="source" ref="170901569"/>
<reference key="destination" ref="42434134"/>
</object>
<int key="connectionID">2812</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">startText:</string>
<reference key="source" ref="170901569"/>
<reference key="destination" ref="989851546"/>
</object>
<int key="connectionID">2813</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">textView</string>
<reference key="source" ref="170901569"/>
<reference key="destination" ref="889516969"/>
</object>
<int key="connectionID">2814</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">window</string>
<reference key="source" ref="953869446"/>
<reference key="destination" ref="201200383"/>
</object>
<int key="connectionID">2816</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">delegate</string>
<reference key="source" ref="201200383"/>
<reference key="destination" ref="953869446"/>
</object>
<int key="connectionID">2817</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -156284,13 +156351,14 @@ AAgAAQABAAEAAQ</bytes>
<reference ref="878251599"/>
<reference ref="421145245"/>
<reference ref="429033246"/>
<reference ref="81294487"/>
<reference ref="666830879"/>
<reference ref="378746645"/>
<reference ref="1039567716"/>
<reference ref="999639276"/>
<reference ref="71980753"/>
<reference ref="126998261"/>
<reference ref="81294487"/>
<reference ref="891666784"/>
</object>
<reference key="parent" ref="904903445"/>
</object>
@@ -156601,6 +156669,25 @@ AAgAAQABAAEAAQ</bytes>
<reference key="object" ref="755626167"/>
<reference key="parent" ref="886151302"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">2815</int>
<reference key="object" ref="953869446"/>
<reference key="parent" ref="1049"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">2818</int>
<reference key="object" ref="891666784"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="1072323581"/>
</object>
<reference key="parent" ref="481198432"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">2819</int>
<reference key="object" ref="1072323581"/>
<reference key="parent" ref="891666784"/>
</object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
@@ -157024,6 +157111,9 @@ AAgAAQABAAEAAQ</bytes>
<string>2801.IBPluginDependency</string>
<string>2802.IBPluginDependency</string>
<string>2803.IBPluginDependency</string>
<string>2815.IBPluginDependency</string>
<string>2818.IBPluginDependency</string>
<string>2819.IBPluginDependency</string>
<string>29.IBEditorWindowLastContentRect</string>
<string>29.IBPluginDependency</string>
<string>29.ImportedFromIB2</string>
@@ -157167,8 +157257,8 @@ AAgAAQABAAEAAQ</bytes>
<reference ref="9"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
<string>{{50, 250}, {512, 384}}</string>
<string>{{50, 250}, {512, 384}}</string>
<string>{{88, 495}, {352, 288}}</string>
<string>{{88, 495}, {352, 288}}</string>
<reference ref="9"/>
<string>{{169, 165}, {507, 404}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -157282,8 +157372,8 @@ AAgAAQABAAEAAQ</bytes>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
<string>{{608, 612}, {241, 103}}</string>
<string>{{676, 270}, {215, 560}}</string>
<string>{{676, 270}, {215, 560}}</string>
<string>{{360, 270}, {215, 560}}</string>
<string>{{360, 270}, {215, 560}}</string>
<reference ref="9"/>
<string>{{488, 170}, {215, 560}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -157589,8 +157679,8 @@ AAgAAQABAAEAAQ</bytes>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{486, 280}, {370, 200}}</string>
<string>{{486, 280}, {370, 200}}</string>
<string>{{602, 520}, {370, 200}}</string>
<string>{{602, 520}, {370, 200}}</string>
<boolean value="NO"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -157650,6 +157740,9 @@ AAgAAQABAAEAAQ</bytes>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{87, 736}, {478, 20}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
@@ -157683,8 +157776,8 @@ AAgAAQABAAEAAQ</bytes>
<object class="NSAttributedString">
<string key="NSString"/>
</object>
<string>{{294, 93}, {645, 666}}</string>
<string>{{294, 93}, {645, 666}}</string>
<string>{{91, 117}, {645, 666}}</string>
<string>{{91, 117}, {645, 666}}</string>
<reference ref="9"/>
<string>{{437, 135}, {451, 576}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -157750,7 +157843,7 @@ AAgAAQABAAEAAQ</bytes>
</object>
</object>
<nil key="sourceID"/>
<int key="maxID">2810</int>
<int key="maxID">2819</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -158032,6 +158125,14 @@ AAgAAQABAAEAAQ</bytes>
<string key="minorKey">CVPreview.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">CVScreenController</string>
<string key="superclassName">NSWindowController</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier" id="244197910">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">CVScreen.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">CVScreenView</string>
<string key="superclassName">NSOpenGLView</string>
@@ -158071,10 +158172,7 @@ AAgAAQABAAEAAQ</bytes>
<string>NSWindow</string>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">CVScreen.h</string>
</object>
<reference key="sourceIdentifier" ref="244197910"/>
</object>
<object class="IBPartialClassDescription">
<string key="className">CVTextLayer</string>
Binary file not shown.
+22
View File
@@ -0,0 +1,22 @@
//
// PreferencesPanel.h
// freej
//
// Created by xant on 8/20/09.
// Copyright 2009 dyne.org. All rights reserved.
//
#import <Cocoa/Cocoa.h>
#import "CFreej.h"
@interface PreferencesPanel : NSWindow {
IBOutlet CFreej *freej;
IBOutlet CVScreenView *mainScreen;
}
- (IBAction)setScreenSize:(id)sender;
- (IBAction)setExportQuality:(id)sender;
- (IBAction)setPluginsPath:(id)sender;
- (IBAction)setJScriptsPath:(id)sender;
@end
+31
View File
@@ -0,0 +1,31 @@
//
// PreferencesPanel.m
// freej
//
// Created by xant on 8/20/09.
// Copyright 2009 dyne.org. All rights reserved.
//
#import "PreferencesPanel.h"
static struct {
int w;
int h;
} allowedScreenSizes[4] =
{
{ 320, 240 },
{ 352, 288 },
{ 512, 384 },
{ 640, 480 }
};
@implementation PreferencesPanel
- (IBAction)setScreenSize:(id)sender
{
int idx = [sender integerValue]-1;
[mainScreen setSizeWidth:allowedScreenSizes[idx].w Height:allowedScreenSizes[idx].h];
}
@end
+6
View File
@@ -165,6 +165,7 @@
AAD0A4E10FDEC20100968886 /* libSDL_gfx.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = AAD0A4E00FDEC20100968886 /* libSDL_gfx.dylib */; };
AAD0A4E30FDEC2A200968886 /* libsndfile.1.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = AAD0A4E20FDEC2A200968886 /* libsndfile.1.dylib */; };
AADF7A000FD7F84500167F57 /* ipernav.icns in Resources */ = {isa = PBXBuildFile; fileRef = AADF79FF0FD7F84500167F57 /* ipernav.icns */; };
AAE2C270103FDCDC00D62E4F /* kbd_ctrl_js.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AAE2C26F103FDCDC00D62E4F /* kbd_ctrl_js.cpp */; };
AAEE68940FC8906B007FB46B /* webcam.png in Resources */ = {isa = PBXBuildFile; fileRef = AAEE68930FC8906B007FB46B /* webcam.png */; };
AAEE689F0FC893BC007FB46B /* frei0r.png in Resources */ = {isa = PBXBuildFile; fileRef = AAEE689E0FC893BC007FB46B /* frei0r.png */; };
/* End PBXBuildFile section */
@@ -495,6 +496,8 @@
AAD0A4E00FDEC20100968886 /* libSDL_gfx.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libSDL_gfx.dylib; path = /opt/local/lib/libSDL_gfx.dylib; sourceTree = "<absolute>"; };
AAD0A4E20FDEC2A200968886 /* libsndfile.1.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libsndfile.1.dylib; path = /opt/local/lib/libsndfile.1.dylib; sourceTree = "<absolute>"; };
AADF79FF0FD7F84500167F57 /* ipernav.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = ipernav.icns; sourceTree = "<group>"; };
AAE2C26F103FDCDC00D62E4F /* kbd_ctrl_js.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = kbd_ctrl_js.cpp; sourceTree = "<group>"; };
AAE2C2B7103FE2AE00D62E4F /* factory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = factory.h; path = include/factory.h; sourceTree = "<group>"; };
AAEE68930FC8906B007FB46B /* webcam.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = webcam.png; sourceTree = "<group>"; };
AAEE689E0FC893BC007FB46B /* frei0r.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = frei0r.png; sourceTree = "<group>"; };
/* End PBXFileReference section */
@@ -766,6 +769,7 @@
AA9337EF0FD7FDEB002B760B /* include */ = {
isa = PBXGroup;
children = (
AAE2C2B7103FE2AE00D62E4F /* factory.h */,
AA8C41B50F90FF8800B39710 /* console_calls_ctrl.h */,
AA8C41B60F90FF8800B39710 /* console_ctrl.h */,
AA8C41B70F90FF8800B39710 /* console_readline_ctrl.h */,
@@ -1175,6 +1179,7 @@
AA3C452E0F3EEBE0007C7E8B /* v4l_layer_js.cpp */,
AA3C45320F3EEBE0007C7E8B /* video_encoder_js.cpp */,
AA3C45360F3EEBE0007C7E8B /* video_layer_js.cpp */,
AAE2C26F103FDCDC00D62E4F /* kbd_ctrl_js.cpp */,
);
name = javascript;
sourceTree = "<group>";
@@ -1499,6 +1504,7 @@
AA71AE030FE58838002FFD23 /* CVInternalLayer.mm in Sources */,
AA63CF8E102DAED400FDA024 /* QTExporter.mm in Sources */,
AAC9DB37103D2C7F00A0111E /* PreferencesPanel.mm in Sources */,
AAE2C270103FDCDC00D62E4F /* kbd_ctrl_js.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};