aboutsummaryrefslogtreecommitdiff
path: root/macosx/plugins/DFInput/macsrc
diff options
context:
space:
mode:
Diffstat (limited to 'macosx/plugins/DFInput/macsrc')
-rw-r--r--macosx/plugins/DFInput/macsrc/ControllerList.h42
-rw-r--r--macosx/plugins/DFInput/macsrc/ControllerList.m143
-rw-r--r--macosx/plugins/DFInput/macsrc/MappingCell.h29
-rw-r--r--macosx/plugins/DFInput/macsrc/MappingCell.m89
-rw-r--r--macosx/plugins/DFInput/macsrc/PadController.h38
-rw-r--r--macosx/plugins/DFInput/macsrc/PadController.m138
-rw-r--r--macosx/plugins/DFInput/macsrc/PadView.h42
-rw-r--r--macosx/plugins/DFInput/macsrc/PadView.m110
-rw-r--r--macosx/plugins/DFInput/macsrc/cfg.c748
-rw-r--r--macosx/plugins/DFInput/macsrc/cfg.h30
-rw-r--r--macosx/plugins/DFInput/macsrc/xkb.c65
11 files changed, 0 insertions, 1474 deletions
diff --git a/macosx/plugins/DFInput/macsrc/ControllerList.h b/macosx/plugins/DFInput/macsrc/ControllerList.h
deleted file mode 100644
index 176d403..0000000
--- a/macosx/plugins/DFInput/macsrc/ControllerList.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2010, Wei Mingzhi <whistler@openoffice.org>.
- * All Rights Reserved.
- *
- * Based on HIDInput by Gil Pedersen.
- * Copyright (c) 2004, Gil Pedersen.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses>.
- */
-
-#define ControllerList NetPcsxHIDInputPluginControllerList
-
-#import <Foundation/Foundation.h>
-#import <AppKit/NSTableView.h>
-#include "cfg.h"
-
-@class KeyConfig;
-
-@interface ControllerList : NSObject {
-}
-
-- (id)initWithConfig;
-
-+ (void)setCurrentController:(int)which;
-+ (int)currentController;
-+ (int)getButtonOfRow:(int)row;
-- (int)numberOfRowsInTableView:(NSTableView *)aTableView;
-- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex;
-- (void)deleteRow:(int)which;
-
-@end
diff --git a/macosx/plugins/DFInput/macsrc/ControllerList.m b/macosx/plugins/DFInput/macsrc/ControllerList.m
deleted file mode 100644
index 5d67370..0000000
--- a/macosx/plugins/DFInput/macsrc/ControllerList.m
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Copyright (c) 2010, Wei Mingzhi <whistler@openoffice.org>.
- * All Rights Reserved.
- *
- * Based on HIDInput by Gil Pedersen.
- * Copyright (c) 2004, Gil Pedersen.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses>.
- */
-
-#import "ControllerList.h"
-#include "pad.h"
-#include "cfg.h"
-
-static int currentController;
-
-@implementation ControllerList
-
-- (id)initWithConfig
-{
- if (!(self = [super init])) return nil;
- return self;
-}
-
-- (void)dealloc
-{
- [super dealloc];
-}
-
-/* sets current controller data returned by data source */
-+ (void)setCurrentController:(int)which
-{
- currentController = which;
-}
-
-+ (int)currentController
-{
- return currentController;
-}
-
-/* NSDataSource */
-- (int)numberOfRowsInTableView:(NSTableView *)aTableView
-{
- return DKEY_TOTAL + (g.cfg.PadDef[currentController].Type == PSE_PAD_TYPE_ANALOGPAD ? 8 : -2);
-}
-
-static const NSString *LabelText[DKEY_TOTAL + 8] = {
- @"D-Pad Up",
- @"D-Pad Down",
- @"D-Pad Left",
- @"D-Pad Right",
- @"Cross",
- @"Circle",
- @"Square",
- @"Triangle",
- @"L1",
- @"R1",
- @"L2",
- @"R2",
- @"Select",
- @"Start",
- @"L3",
- @"R3",
- @"L-Stick Right",
- @"L-Stick Left",
- @"L-Stick Down",
- @"L-Stick Up",
- @"R-Stick Right",
- @"R-Stick Left",
- @"R-Stick Down",
- @"R-Stick Up"
-};
-
-static const int DPad[DKEY_TOTAL] = {
- DKEY_UP,
- DKEY_DOWN,
- DKEY_LEFT,
- DKEY_RIGHT,
- DKEY_CROSS,
- DKEY_CIRCLE,
- DKEY_SQUARE,
- DKEY_TRIANGLE,
- DKEY_L1,
- DKEY_R1,
- DKEY_L2,
- DKEY_R2,
- DKEY_SELECT,
- DKEY_START,
- DKEY_L3,
- DKEY_R3
-};
-
-+ (int)getButtonOfRow:(int)row
-{
- return DPad[row];
-}
-
-- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn
- row:(int)rowIndex
-{
- char buf[256];
-
- if ([((NSString *)[aTableColumn identifier]) isEqualToString:@"key"])
- return LabelText[rowIndex];
- else {
- // actual keys
- if (rowIndex < DKEY_TOTAL) {
- GetKeyDescription(buf, currentController, DPad[rowIndex]);
- } else {
- rowIndex -= DKEY_TOTAL;
- GetAnalogDescription(buf, currentController, rowIndex / 4, rowIndex % 4);
- }
-
- return [NSString stringWithUTF8String:buf];
- }
-}
-
-- (void)deleteRow:(int)which
-{
- if (which < DKEY_TOTAL) {
- g.cfg.PadDef[currentController].KeyDef[DPad[which]].Key = 0;
- g.cfg.PadDef[currentController].KeyDef[DPad[which]].JoyEvType = NONE;
- g.cfg.PadDef[currentController].KeyDef[DPad[which]].J.d = 0;
- } else {
- which -= DKEY_TOTAL;
- g.cfg.PadDef[currentController].AnalogDef[which / 4][which % 4].Key = 0;
- g.cfg.PadDef[currentController].AnalogDef[which / 4][which % 4].JoyEvType = NONE;
- g.cfg.PadDef[currentController].AnalogDef[which / 4][which % 4].J.d = 0;
- }
-}
-
-@end
diff --git a/macosx/plugins/DFInput/macsrc/MappingCell.h b/macosx/plugins/DFInput/macsrc/MappingCell.h
deleted file mode 100644
index f803696..0000000
--- a/macosx/plugins/DFInput/macsrc/MappingCell.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 2010, Wei Mingzhi <whistler@openoffice.org>.
- * All Rights Reserved.
- *
- * Based on: HIDInput by Gil Pedersen.
- * Copyright (c) 2004, Gil Pedersen.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses>.
- */
-
-#define MappingCell NetPcsxHIDInputPluginMappingCell
-
-#import <AppKit/AppKit.h>
-
-@interface MappingCell : NSTextFieldCell {
-}
-
-@end
diff --git a/macosx/plugins/DFInput/macsrc/MappingCell.m b/macosx/plugins/DFInput/macsrc/MappingCell.m
deleted file mode 100644
index 0fb43bd..0000000
--- a/macosx/plugins/DFInput/macsrc/MappingCell.m
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (c) 2010, Wei Mingzhi <whistler@openoffice.org>.
- * All Rights Reserved.
- *
- * Based on: HIDInput by Gil Pedersen.
- * Copyright (c) 2004, Gil Pedersen.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses>.
- */
-
-#import "MappingCell.h"
-#import "ControllerList.h"
-#import "cfg.h"
-
-@implementation MappingCell
-
-- (id)initTextCell:(NSString *)aString {
- self = [super initTextCell:aString];
- [self setEditable:NO];
- return self;
-}
-
-- (void)selectWithFrame:(NSRect)aRect inView:(NSView *)controlView editor:(NSText *)textObj delegate:(id)anObject start:(int)selStart length:(int)selLength
-{
- [super selectWithFrame:aRect inView:controlView editor:textObj delegate:anObject start:selStart length:selLength];
-
- int whichPad = [ControllerList currentController];
- NSTableView *tableView = (NSTableView *)[self controlView];
- int i, changed = 0, row;
- NSEvent *endEvent;
- NSPoint where = {0.0, 0.0};
-
- /* start a modal session */
- NSModalSession session = [NSApp beginModalSessionForWindow:[tableView window]];
- [NSApp runModalSession:session];
-
- /* delay for a little while to allow user to release the button pressed to activate the element */
- [NSThread sleepUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.15]];
-
- InitAxisPos(whichPad);
-
- /* wait for 10 seconds for user to press a key */
- for (i = 0; i < 10; i++) {
- [NSApp runModalSession:session];
- row = [tableView selectedRow];
- if (row < DKEY_TOTAL) {
- changed = ReadDKeyEvent(whichPad, [ControllerList getButtonOfRow:row]);
- } else {
- row -= DKEY_TOTAL;
- changed = ReadAnalogEvent(whichPad, row / 4, row % 4);
- }
-
- if (changed) break;
- }
-
- [NSApp endModalSession:session];
-
- /* move selection to the next list element */
- [self endEditing:textObj];
- if (changed == 1) {
- int nextRow = [tableView selectedRow] + 1;
- if (nextRow >= [tableView numberOfRows]) {
- [tableView deselectAll:self];
- return;
- }
- [tableView selectRow:nextRow byExtendingSelection:NO];
-
- /* discard any events we have received while waiting for the button press */
- endEvent = [NSEvent otherEventWithType:NSApplicationDefined location:where
- modifierFlags:0 timestamp:(NSTimeInterval)0
- windowNumber:0 context:[NSGraphicsContext currentContext] subtype:0 data1:0 data2:0];
- [NSApp postEvent:endEvent atStart:NO];
- [NSApp discardEventsMatchingMask:NSAnyEventMask beforeEvent:endEvent];
- }
- [[tableView window] makeFirstResponder:tableView];
-}
-
-@end
diff --git a/macosx/plugins/DFInput/macsrc/PadController.h b/macosx/plugins/DFInput/macsrc/PadController.h
deleted file mode 100644
index 26a5a15..0000000
--- a/macosx/plugins/DFInput/macsrc/PadController.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 2010, Wei Mingzhi <whistler@openoffice.org>.
- * All Rights Reserved.
- *
- * Based on: HIDInput by Gil Pedersen.
- * Copyright (c) 2004, Gil Pedersen.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses>.
- */
-
-#define PadController NetPcsxHIDInputPluginPadController
-
-#import <Cocoa/Cocoa.h>
-#import "PadView.h"
-
-@class PadView;
-
-@interface PadController : NSWindowController
-{
- IBOutlet PadView *controllerView;
- IBOutlet id controllerView1;
- IBOutlet id controllerView2;
-}
-
-- (IBAction)cancel:(id)sender;
-- (IBAction)ok:(id)sender;
-@end
diff --git a/macosx/plugins/DFInput/macsrc/PadController.m b/macosx/plugins/DFInput/macsrc/PadController.m
deleted file mode 100644
index 06bce2e..0000000
--- a/macosx/plugins/DFInput/macsrc/PadController.m
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Copyright (c) 2010, Wei Mingzhi <whistler@openoffice.org>.
- * All Rights Reserved.
- *
- * Based on: HIDInput by Gil Pedersen.
- * Copyright (c) 2004, Gil Pedersen.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses>.
- */
-
-#import <Cocoa/Cocoa.h>
-#import "PadController.h"
-#include "pad.h"
-
-static NSWindow *padWindow;
-static PadController *padController;
-
-#define APP_ID @"net.pcsx.DFInputPlugin"
-
-void DoAbout() {
- // Get parent application instance
- NSApplication *app = [NSApplication sharedApplication];
- NSBundle *bundle = [NSBundle bundleWithIdentifier:APP_ID];
-
- // Get Credits.rtf
- NSString *path = [bundle pathForResource:@"Credits" ofType:@"rtf"];
- NSAttributedString *credits;
- if (path) {
- credits = [[[NSAttributedString alloc] initWithPath: path
- documentAttributes:NULL] autorelease];
- } else {
- credits = [[[NSAttributedString alloc] initWithString:@""] autorelease];
- }
-
- // Get Application Icon
- NSImage *icon = [[NSWorkspace sharedWorkspace] iconForFile:[bundle bundlePath]];
- NSSize size = NSMakeSize(64, 64);
- [icon setSize:size];
-
- [app orderFrontStandardAboutPanelWithOptions:[NSDictionary dictionaryWithObjectsAndKeys:
- [bundle objectForInfoDictionaryKey:@"CFBundleName"], @"ApplicationName",
- icon, @"ApplicationIcon",
- [bundle objectForInfoDictionaryKey:@"CFBundleShortVersionString"], @"ApplicationVersion",
- [bundle objectForInfoDictionaryKey:@"CFBundleVersion"], @"Version",
- [bundle objectForInfoDictionaryKey:@"NSHumanReadableCopyright"], @"Copyright",
- credits, @"Credits", nil]];
-}
-
-long DoConfiguration() {
- SDL_Init(SDL_INIT_JOYSTICK | SDL_INIT_NOPARACHUTE);
- LoadPADConfig();
-
- if (padWindow == nil) {
- if (padController == nil) {
- padController = [[PadController alloc] initWithWindowNibName:@"NetPcsxHIDInputPluginMain"];
- }
- padWindow = [padController window];
- }
-
- [padWindow center];
- [padWindow makeKeyAndOrderFront:nil];
-
- return 0;
-}
-
-@implementation PadController
-
-- (IBAction)cancel:(id)sender
-{
- SDL_Quit();
- [self close];
-}
-
-- (IBAction)ok:(id)sender
-{
- SavePADConfig();
- SDL_Quit();
- [self close];
-}
-
-- (void)awakeFromNib
-{
- [[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(windowWillClose:)
- name:NSWindowWillCloseNotification object:[self window]];
-
- [controllerView1 addSubview: controllerView];
- [controllerView setController:0];
-}
-
-- (void)tabView:(NSTabView *)tabView didSelectTabViewItem:(NSTabViewItem *)tabViewItem
-{
- PadView *newView = nil;
- if ([[tabViewItem identifier] isEqualToString:@"pad1"])
- newView = controllerView1;
- else if ([[tabViewItem identifier] isEqualToString:@"pad2"])
- newView = controllerView2;
-
- if (nil != newView) {
- [controllerView removeFromSuperviewWithoutNeedingDisplay];
- [newView addSubview: controllerView];
- [controllerView setFrame:[newView frame]];
- [controllerView setController:[newView isEqual:controllerView1] ? 0 : 1];
- }
-}
-
-- (void)windowBecameKey:(NSNotification *)notification
-{
- if ([[controllerView1 subviews] count] > 0)
- [controllerView setController:0];
- else if ([[controllerView2 subviews] count] > 0)
- [controllerView setController:1];
-
- [[NSNotificationCenter defaultCenter] removeObserver:self
- name:NSWindowDidBecomeKeyNotification object:[self window]];
-}
-
-- (void)windowWillClose:(NSNotification *)aNotification
-{
- if ([aNotification object] == [self window]) {
- [[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(windowBecameKey:)
- name:NSWindowDidBecomeKeyNotification object:[self window]];
- }
-}
-
-@end \ No newline at end of file
diff --git a/macosx/plugins/DFInput/macsrc/PadView.h b/macosx/plugins/DFInput/macsrc/PadView.h
deleted file mode 100644
index f99686c..0000000
--- a/macosx/plugins/DFInput/macsrc/PadView.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2010, Wei Mingzhi <whistler@openoffice.org>.
- * All Rights Reserved.
- *
- * Based on: HIDInput by Gil Pedersen.
- * Copyright (c) 2004, Gil Pedersen.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses>.
- */
-
-#define PadView NetPcsxHIDInputPluginPadView
-
-#import <Cocoa/Cocoa.h>
-#import "ControllerList.h"
-
-@class ControllerList;
-
-@interface PadView : NSView
-{
- IBOutlet NSTableView *tableView;
- IBOutlet NSPopUpButton *typeMenu;
- IBOutlet NSPopUpButton *deviceMenu;
-
- ControllerList *controller;
-}
-- (IBAction)setType:(id)sender;
-- (IBAction)setDevice:(id)sender;
-
-- (void)setController:(int)which;
-
-@end
diff --git a/macosx/plugins/DFInput/macsrc/PadView.m b/macosx/plugins/DFInput/macsrc/PadView.m
deleted file mode 100644
index b0ed273..0000000
--- a/macosx/plugins/DFInput/macsrc/PadView.m
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright (c) 2010, Wei Mingzhi <whistler@openoffice.org>.
- * All Rights Reserved.
- *
- * Based on: HIDInput by Gil Pedersen.
- * Copyright (c) 2004, Gil Pedersen.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses>.
- */
-
-#import "PadView.h"
-#include "pad.h"
-
-@implementation PadView
-
-- (id)initWithFrame:(NSRect)frameRect
-{
- if ((self = [super initWithFrame:frameRect]) != nil) {
- controller = [[ControllerList alloc] initWithConfig];
- [self setController:0];
- }
- return self;
-}
-
-- (void)dealloc
-{
- [controller release];
- [super dealloc];
-}
-
-- (void)drawRect:(NSRect)rect
-{
-}
-
-- (IBAction)setType:(id)sender
-{
- g.cfg.PadDef[[ControllerList currentController]].Type =
- ([sender indexOfSelectedItem] > 0 ? PSE_PAD_TYPE_ANALOGPAD : PSE_PAD_TYPE_STANDARD);
-
- [tableView reloadData];
-}
-
-- (IBAction)setDevice:(id)sender
-{
- g.cfg.PadDef[[ControllerList currentController]].DevNum = (int)[sender indexOfSelectedItem] - 1;
-}
-
-- (void)setController:(int)which
-{
- int i;
-
- [ControllerList setCurrentController:which];
- [tableView setDataSource:controller];
-
- [deviceMenu removeAllItems];
- [deviceMenu addItemWithTitle:@"(Keyboard only)"];
-
- for (i = 0; i < SDL_NumJoysticks(); i++) {
- [deviceMenu addItemWithTitle:[NSString stringWithUTF8String:SDL_JoystickName(i)]];
- }
-
- if (g.cfg.PadDef[which].DevNum >= SDL_NumJoysticks()) {
- g.cfg.PadDef[which].DevNum = -1;
- }
-
- [deviceMenu selectItemAtIndex:g.cfg.PadDef[which].DevNum + 1];
- [typeMenu selectItemAtIndex:(g.cfg.PadDef[which].Type == PSE_PAD_TYPE_ANALOGPAD ? 1 : 0)];
-
- [tableView reloadData];
-}
-
-
-- (BOOL)control:(NSControl *)control textShouldBeginEditing:(NSText *)fieldEditor
-{
- return false;
-}
-
-/* handles key events on the pad list */
-- (void)keyDown:(NSEvent *)theEvent
-{
- int key = [theEvent keyCode];
-
- if ([[theEvent window] firstResponder] == tableView) {
- if (key == 51 || key == 117) {
- // delete keys - remove the mappings for the selected item
- [controller deleteRow:[tableView selectedRow]];
- [tableView reloadData];
- return;
- } else if (key == 36) {
- // return key - configure the selected item
- [tableView editColumn:[tableView columnWithIdentifier:@"button"] row:[tableView selectedRow] withEvent:nil select:YES];
- return;
- }
- }
-
- [super keyDown:theEvent];
-}
-
-@end
diff --git a/macosx/plugins/DFInput/macsrc/cfg.c b/macosx/plugins/DFInput/macsrc/cfg.c
deleted file mode 100644
index 9465426..0000000
--- a/macosx/plugins/DFInput/macsrc/cfg.c
+++ /dev/null
@@ -1,748 +0,0 @@
-/*
- * Copyright (c) 2010, Wei Mingzhi <whistler@openoffice.org>.
- * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses>.
- */
-
-#include "pad.h"
-
-GLOBALDATA g;
-
-long DoConfiguration();
-void DoAbout();
-
-static void SetDefaultConfig() {
- memset(&g.cfg, 0, sizeof(g.cfg));
-
- g.cfg.Threaded = 1;
-
- g.cfg.PadDef[0].DevNum = 0;
- g.cfg.PadDef[1].DevNum = 1;
-
- g.cfg.PadDef[0].Type = PSE_PAD_TYPE_STANDARD;
- g.cfg.PadDef[1].Type = PSE_PAD_TYPE_STANDARD;
-
- // Pad1 keyboard
- g.cfg.PadDef[0].KeyDef[DKEY_SELECT].Key = 9;
- g.cfg.PadDef[0].KeyDef[DKEY_START].Key = 10;
- g.cfg.PadDef[0].KeyDef[DKEY_UP].Key = 127;
- g.cfg.PadDef[0].KeyDef[DKEY_RIGHT].Key = 125;
- g.cfg.PadDef[0].KeyDef[DKEY_DOWN].Key = 126;
- g.cfg.PadDef[0].KeyDef[DKEY_LEFT].Key = 124;
- g.cfg.PadDef[0].KeyDef[DKEY_L2].Key = 16;
- g.cfg.PadDef[0].KeyDef[DKEY_R2].Key = 18;
- g.cfg.PadDef[0].KeyDef[DKEY_L1].Key = 14;
- g.cfg.PadDef[0].KeyDef[DKEY_R1].Key = 15;
- g.cfg.PadDef[0].KeyDef[DKEY_TRIANGLE].Key = 3;
- g.cfg.PadDef[0].KeyDef[DKEY_CIRCLE].Key = 8;
- g.cfg.PadDef[0].KeyDef[DKEY_CROSS].Key = 7;
- g.cfg.PadDef[0].KeyDef[DKEY_SQUARE].Key = 2;
-
- // Pad1 joystick
- g.cfg.PadDef[0].KeyDef[DKEY_SELECT].JoyEvType = BUTTON;
- g.cfg.PadDef[0].KeyDef[DKEY_SELECT].J.Button = 8;
- g.cfg.PadDef[0].KeyDef[DKEY_START].JoyEvType = BUTTON;
- g.cfg.PadDef[0].KeyDef[DKEY_START].J.Button = 9;
- g.cfg.PadDef[0].KeyDef[DKEY_UP].JoyEvType = AXIS;
- g.cfg.PadDef[0].KeyDef[DKEY_UP].J.Axis = -2;
- g.cfg.PadDef[0].KeyDef[DKEY_RIGHT].JoyEvType = AXIS;
- g.cfg.PadDef[0].KeyDef[DKEY_RIGHT].J.Axis = 1;
- g.cfg.PadDef[0].KeyDef[DKEY_DOWN].JoyEvType = AXIS;
- g.cfg.PadDef[0].KeyDef[DKEY_DOWN].J.Axis = 2;
- g.cfg.PadDef[0].KeyDef[DKEY_LEFT].JoyEvType = AXIS;
- g.cfg.PadDef[0].KeyDef[DKEY_LEFT].J.Axis = -1;
- g.cfg.PadDef[0].KeyDef[DKEY_L2].JoyEvType = BUTTON;
- g.cfg.PadDef[0].KeyDef[DKEY_L2].J.Button = 4;
- g.cfg.PadDef[0].KeyDef[DKEY_L1].JoyEvType = BUTTON;
- g.cfg.PadDef[0].KeyDef[DKEY_L1].J.Button = 6;
- g.cfg.PadDef[0].KeyDef[DKEY_R2].JoyEvType = BUTTON;
- g.cfg.PadDef[0].KeyDef[DKEY_R2].J.Button = 5;
- g.cfg.PadDef[0].KeyDef[DKEY_R1].JoyEvType = BUTTON;
- g.cfg.PadDef[0].KeyDef[DKEY_R1].J.Button = 7;
- g.cfg.PadDef[0].KeyDef[DKEY_TRIANGLE].JoyEvType = BUTTON;
- g.cfg.PadDef[0].KeyDef[DKEY_TRIANGLE].J.Button = 0;
- g.cfg.PadDef[0].KeyDef[DKEY_CIRCLE].JoyEvType = BUTTON;
- g.cfg.PadDef[0].KeyDef[DKEY_CIRCLE].J.Button = 1;
- g.cfg.PadDef[0].KeyDef[DKEY_CROSS].JoyEvType = BUTTON;
- g.cfg.PadDef[0].KeyDef[DKEY_CROSS].J.Button = 2;
- g.cfg.PadDef[0].KeyDef[DKEY_SQUARE].JoyEvType = BUTTON;
- g.cfg.PadDef[0].KeyDef[DKEY_SQUARE].J.Button = 3;
-
- // Pad2 joystick
- g.cfg.PadDef[1].KeyDef[DKEY_SELECT].JoyEvType = BUTTON;
- g.cfg.PadDef[1].KeyDef[DKEY_SELECT].J.Button = 8;
- g.cfg.PadDef[1].KeyDef[DKEY_START].JoyEvType = BUTTON;
- g.cfg.PadDef[1].KeyDef[DKEY_START].J.Button = 9;
- g.cfg.PadDef[1].KeyDef[DKEY_UP].JoyEvType = AXIS;
- g.cfg.PadDef[1].KeyDef[DKEY_UP].J.Axis = -2;
- g.cfg.PadDef[1].KeyDef[DKEY_RIGHT].JoyEvType = AXIS;
- g.cfg.PadDef[1].KeyDef[DKEY_RIGHT].J.Axis = 1;
- g.cfg.PadDef[1].KeyDef[DKEY_DOWN].JoyEvType = AXIS;
- g.cfg.PadDef[1].KeyDef[DKEY_DOWN].J.Axis = 2;
- g.cfg.PadDef[1].KeyDef[DKEY_LEFT].JoyEvType = AXIS;
- g.cfg.PadDef[1].KeyDef[DKEY_LEFT].J.Axis = -1;
- g.cfg.PadDef[1].KeyDef[DKEY_L2].JoyEvType = BUTTON;
- g.cfg.PadDef[1].KeyDef[DKEY_L2].J.Button = 4;
- g.cfg.PadDef[1].KeyDef[DKEY_L1].JoyEvType = BUTTON;
- g.cfg.PadDef[1].KeyDef[DKEY_L1].J.Button = 6;
- g.cfg.PadDef[1].KeyDef[DKEY_R2].JoyEvType = BUTTON;
- g.cfg.PadDef[1].KeyDef[DKEY_R2].J.Button = 5;
- g.cfg.PadDef[1].KeyDef[DKEY_R1].JoyEvType = BUTTON;
- g.cfg.PadDef[1].KeyDef[DKEY_R1].J.Button = 7;
- g.cfg.PadDef[1].KeyDef[DKEY_TRIANGLE].JoyEvType = BUTTON;
- g.cfg.PadDef[1].KeyDef[DKEY_TRIANGLE].J.Button = 0;
- g.cfg.PadDef[1].KeyDef[DKEY_CIRCLE].JoyEvType = BUTTON;
- g.cfg.PadDef[1].KeyDef[DKEY_CIRCLE].J.Button = 1;
- g.cfg.PadDef[1].KeyDef[DKEY_CROSS].JoyEvType = BUTTON;
- g.cfg.PadDef[1].KeyDef[DKEY_CROSS].J.Button = 2;
- g.cfg.PadDef[1].KeyDef[DKEY_SQUARE].JoyEvType = BUTTON;
- g.cfg.PadDef[1].KeyDef[DKEY_SQUARE].J.Button = 3;
-}
-
-void LoadPADConfig() {
- FILE *fp;
- char buf[256];
- int current, a, b, c;
-
- SetDefaultConfig();
-
- sprintf(buf, "%s/Library/Preferences/net.pcsx.DFInput.plist", getenv("HOME"));
-
- fp = fopen(buf, "r");
- if (fp == NULL) {
- return;
- }
-
- current = 0;
-
- while (fgets(buf, 256, fp) != NULL) {
- if (strncmp(buf, "Threaded=", 9) == 0) {
- g.cfg.Threaded = atoi(&buf[9]);
- } else if (strncmp(buf, "[PAD", 4) == 0) {
- current = atoi(&buf[4]) - 1;
- if (current < 0) {
- current = 0;
- } else if (current > 1) {
- current = 1;
- }
- } else if (strncmp(buf, "DevNum=", 7) == 0) {
- g.cfg.PadDef[current].DevNum = atoi(&buf[7]);
- } else if (strncmp(buf, "Type=", 5) == 0) {
- g.cfg.PadDef[current].Type = atoi(&buf[5]);
- } else if (strncmp(buf, "Select=", 7) == 0) {
- sscanf(buf, "Select=%d,%d,%d", &a, &b, &c);
- g.cfg.PadDef[current].KeyDef[DKEY_SELECT].Key = a;
- g.cfg.PadDef[current].KeyDef[DKEY_SELECT].JoyEvType = b;
- g.cfg.PadDef[current].KeyDef[DKEY_SELECT].J.d = c;
- } else if (strncmp(buf, "L3=", 3) == 0) {
- sscanf(buf, "L3=%d,%d,%d", &a, &b, &c);
- g.cfg.PadDef[current].KeyDef[DKEY_L3].Key = a;
- g.cfg.PadDef[current].KeyDef[DKEY_L3].JoyEvType = b;
- g.cfg.PadDef[current].KeyDef[DKEY_L3].J.d = c;
- } else if (strncmp(buf, "R3=", 3) == 0) {
- sscanf(buf, "R3=%d,%d,%d", &a, &b, &c);
- g.cfg.PadDef[current].KeyDef[DKEY_R3].Key = a;
- g.cfg.PadDef[current].KeyDef[DKEY_R3].JoyEvType = b;
- g.cfg.PadDef[current].KeyDef[DKEY_R3].J.d = c;
- } else if (strncmp(buf, "Start=", 6) == 0) {
- sscanf(buf, "Start=%d,%d,%d", &a, &b, &c);
- g.cfg.PadDef[current].KeyDef[DKEY_START].Key = a;
- g.cfg.PadDef[current].KeyDef[DKEY_START].JoyEvType = b;
- g.cfg.PadDef[current].KeyDef[DKEY_START].J.d = c;
- } else if (strncmp(buf, "Up=", 3) == 0) {
- sscanf(buf, "Up=%d,%d,%d", &a, &b, &c);
- g.cfg.PadDef[current].KeyDef[DKEY_UP].Key = a;
- g.cfg.PadDef[current].KeyDef[DKEY_UP].JoyEvType = b;
- g.cfg.PadDef[current].KeyDef[DKEY_UP].J.d = c;
- } else if (strncmp(buf, "Right=", 6) == 0) {
- sscanf(buf, "Right=%d,%d,%d", &a, &b, &c);
- g.cfg.PadDef[current].KeyDef[DKEY_RIGHT].Key = a;
- g.cfg.PadDef[current].KeyDef[DKEY_RIGHT].JoyEvType = b;
- g.cfg.PadDef[current].KeyDef[DKEY_RIGHT].J.d = c;
- } else if (strncmp(buf, "Down=", 5) == 0) {
- sscanf(buf, "Down=%d,%d,%d", &a, &b, &c);
- g.cfg.PadDef[current].KeyDef[DKEY_DOWN].Key = a;
- g.cfg.PadDef[current].KeyDef[DKEY_DOWN].JoyEvType = b;
- g.cfg.PadDef[current].KeyDef[DKEY_DOWN].J.d = c;
- } else if (strncmp(buf, "Left=", 5) == 0) {
- sscanf(buf, "Left=%d,%d,%d", &a, &b, &c);
- g.cfg.PadDef[current].KeyDef[DKEY_LEFT].Key = a;
- g.cfg.PadDef[current].KeyDef[DKEY_LEFT].JoyEvType = b;
- g.cfg.PadDef[current].KeyDef[DKEY_LEFT].J.d = c;
- } else if (strncmp(buf, "L2=", 3) == 0) {
- sscanf(buf, "L2=%d,%d,%d", &a, &b, &c);
- g.cfg.PadDef[current].KeyDef[DKEY_L2].Key = a;
- g.cfg.PadDef[current].KeyDef[DKEY_L2].JoyEvType = b;
- g.cfg.PadDef[current].KeyDef[DKEY_L2].J.d = c;
- } else if (strncmp(buf, "R2=", 3) == 0) {
- sscanf(buf, "R2=%d,%d,%d", &a, &b, &c);
- g.cfg.PadDef[current].KeyDef[DKEY_R2].Key = a;
- g.cfg.PadDef[current].KeyDef[DKEY_R2].JoyEvType = b;
- g.cfg.PadDef[current].KeyDef[DKEY_R2].J.d = c;
- } else if (strncmp(buf, "L1=", 3) == 0) {
- sscanf(buf, "L1=%d,%d,%d", &a, &b, &c);
- g.cfg.PadDef[current].KeyDef[DKEY_L1].Key = a;
- g.cfg.PadDef[current].KeyDef[DKEY_L1].JoyEvType = b;
- g.cfg.PadDef[current].KeyDef[DKEY_L1].J.d = c;
- } else if (strncmp(buf, "R1=", 3) == 0) {
- sscanf(buf, "R1=%d,%d,%d", &a, &b, &c);
- g.cfg.PadDef[current].KeyDef[DKEY_R1].Key = a;
- g.cfg.PadDef[current].KeyDef[DKEY_R1].JoyEvType = b;
- g.cfg.PadDef[current].KeyDef[DKEY_R1].J.d = c;
- } else if (strncmp(buf, "Triangle=", 9) == 0) {
- sscanf(buf, "Triangle=%d,%d,%d", &a, &b, &c);
- g.cfg.PadDef[current].KeyDef[DKEY_TRIANGLE].Key = a;
- g.cfg.PadDef[current].KeyDef[DKEY_TRIANGLE].JoyEvType = b;
- g.cfg.PadDef[current].KeyDef[DKEY_TRIANGLE].J.d = c;
- } else if (strncmp(buf, "Circle=", 7) == 0) {
- sscanf(buf, "Circle=%d,%d,%d", &a, &b, &c);
- g.cfg.PadDef[current].KeyDef[DKEY_CIRCLE].Key = a;
- g.cfg.PadDef[current].KeyDef[DKEY_CIRCLE].JoyEvType = b;
- g.cfg.PadDef[current].KeyDef[DKEY_CIRCLE].J.d = c;
- } else if (strncmp(buf, "Cross=", 6) == 0) {
- sscanf(buf, "Cross=%d,%d,%d", &a, &b, &c);
- g.cfg.PadDef[current].KeyDef[DKEY_CROSS].Key = a;
- g.cfg.PadDef[current].KeyDef[DKEY_CROSS].JoyEvType = b;
- g.cfg.PadDef[current].KeyDef[DKEY_CROSS].J.d = c;
- } else if (strncmp(buf, "Square=", 7) == 0) {
- sscanf(buf, "Square=%d,%d,%d", &a, &b, &c);
- g.cfg.PadDef[current].KeyDef[DKEY_SQUARE].Key = a;
- g.cfg.PadDef[current].KeyDef[DKEY_SQUARE].JoyEvType = b;
- g.cfg.PadDef[current].KeyDef[DKEY_SQUARE].J.d = c;
- } else if (strncmp(buf, "LeftAnalogXP=", 13) == 0) {
- sscanf(buf, "LeftAnalogXP=%d,%d,%d", &a, &b, &c);
- g.cfg.PadDef[current].AnalogDef[ANALOG_LEFT][ANALOG_XP].Key = a;
- g.cfg.PadDef[current].AnalogDef[ANALOG_LEFT][ANALOG_XP].JoyEvType = b;
- g.cfg.PadDef[current].AnalogDef[ANALOG_LEFT][ANALOG_XP].J.d = c;
- } else if (strncmp(buf, "LeftAnalogXM=", 13) == 0) {
- sscanf(buf, "LeftAnalogXM=%d,%d,%d", &a, &b, &c);
- g.cfg.PadDef[current].AnalogDef[ANALOG_LEFT][ANALOG_XM].Key = a;
- g.cfg.PadDef[current].AnalogDef[ANALOG_LEFT][ANALOG_XM].JoyEvType = b;
- g.cfg.PadDef[current].AnalogDef[ANALOG_LEFT][ANALOG_XM].J.d = c;
- } else if (strncmp(buf, "LeftAnalogYP=", 13) == 0) {
- sscanf(buf, "LeftAnalogYP=%d,%d,%d", &a, &b, &c);
- g.cfg.PadDef[current].AnalogDef[ANALOG_LEFT][ANALOG_YP].Key = a;
- g.cfg.PadDef[current].AnalogDef[ANALOG_LEFT][ANALOG_YP].JoyEvType = b;
- g.cfg.PadDef[current].AnalogDef[ANALOG_LEFT][ANALOG_YP].J.d = c;
- } else if (strncmp(buf, "LeftAnalogYM=", 13) == 0) {
- sscanf(buf, "LeftAnalogYM=%d,%d,%d", &a, &b, &c);
- g.cfg.PadDef[current].AnalogDef[ANALOG_LEFT][ANALOG_YM].Key = a;
- g.cfg.PadDef[current].AnalogDef[ANALOG_LEFT][ANALOG_YM].JoyEvType = b;
- g.cfg.PadDef[current].AnalogDef[ANALOG_LEFT][ANALOG_YM].J.d = c;
- } else if (strncmp(buf, "RightAnalogXP=", 14) == 0) {
- sscanf(buf, "RightAnalogXP=%d,%d,%d", &a, &b, &c);
- g.cfg.PadDef[current].AnalogDef[ANALOG_RIGHT][ANALOG_XP].Key = a;
- g.cfg.PadDef[current].AnalogDef[ANALOG_RIGHT][ANALOG_XP].JoyEvType = b;
- g.cfg.PadDef[current].AnalogDef[ANALOG_RIGHT][ANALOG_XP].J.d = c;
- } else if (strncmp(buf, "RightAnalogXM=", 14) == 0) {
- sscanf(buf, "RightAnalogXM=%d,%d,%d", &a, &b, &c);
- g.cfg.PadDef[current].AnalogDef[ANALOG_RIGHT][ANALOG_XM].Key = a;
- g.cfg.PadDef[current].AnalogDef[ANALOG_RIGHT][ANALOG_XM].JoyEvType = b;
- g.cfg.PadDef[current].AnalogDef[ANALOG_RIGHT][ANALOG_XM].J.d = c;
- } else if (strncmp(buf, "RightAnalogYP=", 14) == 0) {
- sscanf(buf, "RightAnalogYP=%d,%d,%d", &a, &b, &c);
- g.cfg.PadDef[current].AnalogDef[ANALOG_RIGHT][ANALOG_YP].Key = a;
- g.cfg.PadDef[current].AnalogDef[ANALOG_RIGHT][ANALOG_YP].JoyEvType = b;
- g.cfg.PadDef[current].AnalogDef[ANALOG_RIGHT][ANALOG_YP].J.d = c;
- } else if (strncmp(buf, "RightAnalogYM=", 14) == 0) {
- sscanf(buf, "RightAnalogYM=%d,%d,%d", &a, &b, &c);
- g.cfg.PadDef[current].AnalogDef[ANALOG_RIGHT][ANALOG_YM].Key = a;
- g.cfg.PadDef[current].AnalogDef[ANALOG_RIGHT][ANALOG_YM].JoyEvType = b;
- g.cfg.PadDef[current].AnalogDef[ANALOG_RIGHT][ANALOG_YM].J.d = c;
- }
- }
-
- fclose(fp);
-}
-
-void SavePADConfig() {
- FILE *fp;
- int i;
- char buf[256];
-
- sprintf(buf, "%s/Library/Preferences/net.pcsx.DFInput.plist", getenv("HOME"));
-
- fp = fopen(buf, "w");
- if (fp == NULL) {
- return;
- }
-
- fprintf(fp, "[CONFIG]\n");
- fprintf(fp, "Threaded=%d\n", g.cfg.Threaded);
- fprintf(fp, "\n");
-
- for (i = 0; i < 2; i++) {
- fprintf(fp, "[PAD%d]\n", i + 1);
- fprintf(fp, "DevNum=%d\n", g.cfg.PadDef[i].DevNum);
- fprintf(fp, "Type=%d\n", g.cfg.PadDef[i].Type);
-
- fprintf(fp, "Select=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_SELECT].Key,
- g.cfg.PadDef[i].KeyDef[DKEY_SELECT].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_SELECT].J.d);
- fprintf(fp, "L3=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_L3].Key,
- g.cfg.PadDef[i].KeyDef[DKEY_L3].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_L3].J.d);
- fprintf(fp, "R3=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_R3].Key,
- g.cfg.PadDef[i].KeyDef[DKEY_R3].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_R3].J.d);
- fprintf(fp, "Start=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_START].Key,
- g.cfg.PadDef[i].KeyDef[DKEY_START].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_START].J.d);
- fprintf(fp, "Up=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_UP].Key,
- g.cfg.PadDef[i].KeyDef[DKEY_UP].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_UP].J.d);
- fprintf(fp, "Right=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_RIGHT].Key,
- g.cfg.PadDef[i].KeyDef[DKEY_RIGHT].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_RIGHT].J.d);
- fprintf(fp, "Down=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_DOWN].Key,
- g.cfg.PadDef[i].KeyDef[DKEY_DOWN].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_DOWN].J.d);
- fprintf(fp, "Left=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_LEFT].Key,
- g.cfg.PadDef[i].KeyDef[DKEY_LEFT].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_LEFT].J.d);
- fprintf(fp, "L2=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_L2].Key,
- g.cfg.PadDef[i].KeyDef[DKEY_L2].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_L2].J.d);
- fprintf(fp, "R2=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_R2].Key,
- g.cfg.PadDef[i].KeyDef[DKEY_R2].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_R2].J.d);
- fprintf(fp, "L1=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_L1].Key,
- g.cfg.PadDef[i].KeyDef[DKEY_L1].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_L1].J.d);
- fprintf(fp, "R1=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_R1].Key,
- g.cfg.PadDef[i].KeyDef[DKEY_R1].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_R1].J.d);
- fprintf(fp, "Triangle=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_TRIANGLE].Key,
- g.cfg.PadDef[i].KeyDef[DKEY_TRIANGLE].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_TRIANGLE].J.d);
- fprintf(fp, "Circle=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_CIRCLE].Key,
- g.cfg.PadDef[i].KeyDef[DKEY_CIRCLE].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_CIRCLE].J.d);
- fprintf(fp, "Cross=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_CROSS].Key,
- g.cfg.PadDef[i].KeyDef[DKEY_CROSS].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_CROSS].J.d);
- fprintf(fp, "Square=%d,%d,%d\n", g.cfg.PadDef[i].KeyDef[DKEY_SQUARE].Key,
- g.cfg.PadDef[i].KeyDef[DKEY_SQUARE].JoyEvType, g.cfg.PadDef[i].KeyDef[DKEY_SQUARE].J.d);
- fprintf(fp, "LeftAnalogXP=%d,%d,%d\n", g.cfg.PadDef[i].AnalogDef[ANALOG_LEFT][ANALOG_XP].Key,
- g.cfg.PadDef[i].AnalogDef[ANALOG_LEFT][ANALOG_XP].JoyEvType,
- g.cfg.PadDef[i].AnalogDef[ANALOG_LEFT][ANALOG_XP].J.d);
- fprintf(fp, "LeftAnalogXM=%d,%d,%d\n", g.cfg.PadDef[i].AnalogDef[ANALOG_LEFT][ANALOG_XM].Key,
- g.cfg.PadDef[i].AnalogDef[ANALOG_LEFT][ANALOG_XM].JoyEvType,
- g.cfg.PadDef[i].AnalogDef[ANALOG_LEFT][ANALOG_XM].J.d);
- fprintf(fp, "LeftAnalogYP=%d,%d,%d\n", g.cfg.PadDef[i].AnalogDef[ANALOG_LEFT][ANALOG_YP].Key,
- g.cfg.PadDef[i].AnalogDef[ANALOG_LEFT][ANALOG_YP].JoyEvType,
- g.cfg.PadDef[i].AnalogDef[ANALOG_LEFT][ANALOG_YP].J.d);
- fprintf(fp, "LeftAnalogYM=%d,%d,%d\n", g.cfg.PadDef[i].AnalogDef[ANALOG_LEFT][ANALOG_YM].Key,
- g.cfg.PadDef[i].AnalogDef[ANALOG_LEFT][ANALOG_YM].JoyEvType,
- g.cfg.PadDef[i].AnalogDef[ANALOG_LEFT][ANALOG_YM].J.d);
- fprintf(fp, "RightAnalogXP=%d,%d,%d\n", g.cfg.PadDef[i].AnalogDef[ANALOG_RIGHT][ANALOG_XP].Key,
- g.cfg.PadDef[i].AnalogDef[ANALOG_RIGHT][ANALOG_XP].JoyEvType,
- g.cfg.PadDef[i].AnalogDef[ANALOG_RIGHT][ANALOG_XP].J.d);
- fprintf(fp, "RightAnalogXM=%d,%d,%d\n", g.cfg.PadDef[i].AnalogDef[ANALOG_RIGHT][ANALOG_XM].Key,
- g.cfg.PadDef[i].AnalogDef[ANALOG_RIGHT][ANALOG_XM].JoyEvType,
- g.cfg.PadDef[i].AnalogDef[ANALOG_RIGHT][ANALOG_XM].J.d);
- fprintf(fp, "RightAnalogYP=%d,%d,%d\n", g.cfg.PadDef[i].AnalogDef[ANALOG_RIGHT][ANALOG_YP].Key,
- g.cfg.PadDef[i].AnalogDef[ANALOG_RIGHT][ANALOG_YP].JoyEvType,
- g.cfg.PadDef[i].AnalogDef[ANALOG_RIGHT][ANALOG_YP].J.d);
- fprintf(fp, "RightAnalogYM=%d,%d,%d\n", g.cfg.PadDef[i].AnalogDef[ANALOG_RIGHT][ANALOG_YM].Key,
- g.cfg.PadDef[i].AnalogDef[ANALOG_RIGHT][ANALOG_YM].JoyEvType,
- g.cfg.PadDef[i].AnalogDef[ANALOG_RIGHT][ANALOG_YM].J.d);
-
- fprintf(fp, "\n");
- }
-
- fclose(fp);
-}
-
-long PADconfigure(void) {
- if (SDL_WasInit(SDL_INIT_JOYSTICK)) return -1; // cannot change settings on the fly
-
- DoConfiguration();
- LoadPADConfig();
- return 0;
-}
-
-void PADabout(void) {
- DoAbout();
-}
-
-struct {
- uint16_t code;
- const char *desc;
-} KeyString[] = {
- { 0x01, "A" },
- { 0x0C, "B" },
- { 0x09, "C" },
- { 0x03, "D" },
- { 0x0F, "E" },
- { 0x04, "F" },
- { 0x06, "G" },
- { 0x05, "H" },
- { 0x23, "I" },
- { 0x27, "J" },
- { 0x29, "K" },
- { 0x26, "L" },
- { 0x2F, "M" },
- { 0x2E, "N" },
- { 0x20, "O" },
- { 0x24, "P" },
- { 0x0D, "Q" },
- { 0x10, "R" },
- { 0x02, "S" },
- { 0x12, "T" },
- { 0x21, "U" },
- { 0x0A, "V" },
- { 0x0E, "W" },
- { 0x08, "X" },
- { 0x11, "Y" },
- { 0x07, "Z" },
- { 0x22, "[" },
- { 0x1F, "]" },
- { 0x2A, ";" },
- { 0x28, "'" },
- { 0x2C, "," },
- { 0x30, "." },
- { 0x2D, "/" },
- { 0x33, "`" },
- { 0x13, "1" },
- { 0x14, "2" },
- { 0x15, "3" },
- { 0x16, "4" },
- { 0x18, "5" },
- { 0x17, "6" },
- { 0x1B, "7" },
- { 0x1D, "8" },
- { 0x1A, "9" },
- { 0x1E, "0" },
- { 0x1C, "-" },
- { 0x19, "=" },
- { 0x2B, "\\" },
- { 0x31, "Tab" },
- { 0x39, "Shift" },
- { 0x3C, "Control" },
- { 0x38, "Command" },
- { 0x32, "Spacebar" },
- { 0x34, "Backspace" },
- { 0x25, "Enter" },
- { 0x7F, "Up" },
- { 0x7E, "Down" },
- { 0x7C, "Left" },
- { 0x7D, "Right" },
- { 0x73, "Insert" },
- { 0x76, "Delete" },
- { 0x74, "Home" },
- { 0x78, "End" },
- { 0x75, "Page Up" },
- { 0x7A, "Page Down" },
- { 0x48, "Num Lock" },
- { 0x4C, "Keypad /" },
- { 0x44, "Keypad *" },
- { 0x4F, "Keypad -" },
- { 0x46, "Keypad +" },
- { 0x4D, "Keypad Enter" },
- { 0x53, "Keypad 0" },
- { 0x54, "Keypad 1" },
- { 0x55, "Keypad 2" },
- { 0x56, "Keypad 3" },
- { 0x57, "Keypad 4" },
- { 0x58, "Keypad 5" },
- { 0x59, "Keypad 6" },
- { 0x5A, "Keypad 7" },
- { 0x5C, "Keypad 8" },
- { 0x5D, "Keypad 9" },
- { 0x42, "Keypad ." },
- { 0x00, NULL }
-};
-
-static const char *XKeysymToString(uint16_t key) {
- static char buf[64];
- int i = 0;
-
- while (KeyString[i].code != 0) {
- if (KeyString[i].code == key) {
- strcpy(buf, KeyString[i].desc);
- return buf;
- }
- i++;
- }
-
- sprintf(buf, "0x%.2X", key);
- return buf;
-}
-
-void GetKeyDescription(char *buf, int joynum, int key) {
- const char *hatname[16] = {"Centered", "Up", "Right", "Rightup",
- "Down", "", "Rightdown", "", "Left", "Leftup", "", "",
- "Leftdown", "", "", ""};
-
- switch (g.cfg.PadDef[joynum].KeyDef[key].JoyEvType) {
- case BUTTON:
- sprintf(buf, "Joystick: Button %d", g.cfg.PadDef[joynum].KeyDef[key].J.Button);
- break;
-
- case AXIS:
- sprintf(buf, "Joystick: Axis %d%c", abs(g.cfg.PadDef[joynum].KeyDef[key].J.Axis) - 1,
- g.cfg.PadDef[joynum].KeyDef[key].J.Axis > 0 ? '+' : '-');
- break;
-
- case HAT:
- sprintf(buf, "Joystick: Hat %d %s", (g.cfg.PadDef[joynum].KeyDef[key].J.Hat >> 8),
- hatname[g.cfg.PadDef[joynum].KeyDef[key].J.Hat & 0x0F]);
- break;
-
- case NONE:
- default:
- buf[0] = '\0';
- break;
- }
-
- if (g.cfg.PadDef[joynum].KeyDef[key].Key != 0) {
- if (buf[0] != '\0') {
- strcat(buf, " / ");
- }
-
- strcat(buf, "Keyboard:");
- strcat(buf, " ");
- strcat(buf, XKeysymToString(g.cfg.PadDef[joynum].KeyDef[key].Key));
- }
-}
-
-void GetAnalogDescription(char *buf, int joynum, int analognum, int dir) {
- const char *hatname[16] = {"Centered", "Up", "Right", "Rightup",
- "Down", "", "Rightdown", "", "Left", "Leftup", "", "",
- "Leftdown", "", "", ""};
-
- switch (g.cfg.PadDef[joynum].AnalogDef[analognum][dir].JoyEvType) {
- case BUTTON:
- sprintf(buf, "Joystick: Button %d", g.cfg.PadDef[joynum].AnalogDef[analognum][dir].J.Button);
- break;
-
- case AXIS:
- sprintf(buf, "Joystick: Axis %d%c", abs(g.cfg.PadDef[joynum].AnalogDef[analognum][dir].J.Axis) - 1,
- g.cfg.PadDef[joynum].AnalogDef[analognum][dir].J.Axis > 0 ? '+' : '-');
- break;
-
- case HAT:
- sprintf(buf, "Joystick: Hat %d %s", (g.cfg.PadDef[joynum].AnalogDef[analognum][dir].J.Hat >> 8),
- hatname[g.cfg.PadDef[joynum].AnalogDef[analognum][dir].J.Hat & 0x0F]);
- break;
-
- case NONE:
- default:
- buf[0] = '\0';
- break;
- }
-
- if (g.cfg.PadDef[joynum].AnalogDef[analognum][dir].Key != 0) {
- if (buf[0] != '\0') {
- strcat(buf, " / ");
- }
-
- strcat(buf, "Keyboard:");
- strcat(buf, " ");
- strcat(buf, XKeysymToString(g.cfg.PadDef[joynum].AnalogDef[analognum][dir].Key));
- }
-}
-
-int CheckKeyDown() {
- KeyMap theKeys;
- unsigned char *keybytes;
- int i;
-
- GetKeys(theKeys);
- keybytes = (unsigned char *) theKeys;
-
- for (i = 0; i < 128; i++) {
- if (i == 0x3A) continue; // Ignore capslock
-
- if (keybytes[i >> 3] & (1 << (i & 7)))
- return i + 1;
- }
-
- return 0;
-}
-
-static Sint16 InitialAxisPos[256], PrevAxisPos[256];
-
-#define NUM_AXES(js) (SDL_JoystickNumAxes(js) > 256 ? 256 : SDL_JoystickNumAxes(js))
-
-void InitAxisPos(int padnum) {
- int i;
- SDL_Joystick *js;
-
- if (g.cfg.PadDef[padnum].DevNum >= 0) {
- js = SDL_JoystickOpen(g.cfg.PadDef[padnum].DevNum);
- SDL_JoystickEventState(SDL_IGNORE);
- } else return;
-
- SDL_JoystickUpdate();
-
- for (i = 0; i < NUM_AXES(js); i++) {
- InitialAxisPos[i] = PrevAxisPos[i] = SDL_JoystickGetAxis(js, i);
- }
-
- SDL_JoystickClose(js);
-}
-
-int ReadDKeyEvent(int padnum, int key) {
- SDL_Joystick *js;
- int i, changed = 0, t;
- Sint16 axis;
-
- if (g.cfg.PadDef[padnum].DevNum >= 0) {
- js = SDL_JoystickOpen(g.cfg.PadDef[padnum].DevNum);
- SDL_JoystickEventState(SDL_IGNORE);
- } else {
- js = NULL;
- }
-
- for (t = 0; t < 1000000 / 1000; t++) {
- // check joystick events
- if (js != NULL) {
- SDL_JoystickUpdate();
-
- for (i = 0; i < SDL_JoystickNumButtons(js); i++) {
- if (SDL_JoystickGetButton(js, i)) {
- g.cfg.PadDef[padnum].KeyDef[key].JoyEvType = BUTTON;
- g.cfg.PadDef[padnum].KeyDef[key].J.Button = i;
- changed = 1;
- goto end;
- }
- }
-
- for (i = 0; i < NUM_AXES(js); i++) {
- axis = SDL_JoystickGetAxis(js, i);
- if (abs(axis) > 16383 && (abs(axis - PrevAxisPos[i]) > 4096 || abs(axis - InitialAxisPos[i]) > 4096)) {
- g.cfg.PadDef[padnum].KeyDef[key].JoyEvType = AXIS;
- g.cfg.PadDef[padnum].KeyDef[key].J.Axis = (i + 1) * (axis > 0 ? 1 : -1);
- changed = 1;
- goto end;
- }
- PrevAxisPos[i] = axis;
- }
-
- for (i = 0; i < SDL_JoystickNumHats(js); i++) {
- axis = SDL_JoystickGetHat(js, i);
- if (axis != SDL_HAT_CENTERED) {
- g.cfg.PadDef[padnum].KeyDef[key].JoyEvType = HAT;
-
- if (axis & SDL_HAT_UP) {
- g.cfg.PadDef[padnum].KeyDef[key].J.Hat = ((i << 8) | SDL_HAT_UP);
- } else if (axis & SDL_HAT_DOWN) {
- g.cfg.PadDef[padnum].KeyDef[key].J.Hat = ((i << 8) | SDL_HAT_DOWN);
- } else if (axis & SDL_HAT_LEFT) {
- g.cfg.PadDef[padnum].KeyDef[key].J.Hat = ((i << 8) | SDL_HAT_LEFT);
- } else if (axis & SDL_HAT_RIGHT) {
- g.cfg.PadDef[padnum].KeyDef[key].J.Hat = ((i << 8) | SDL_HAT_RIGHT);
- }
-
- changed = 1;
- goto end;
- }
- }
- }
-
- // check keyboard events
- i = CheckKeyDown();
- if (i != 0) {
- if (i != 0x36) g.cfg.PadDef[padnum].KeyDef[key].Key = i;
- changed = 1;
- goto end;
- }
-
- // check mouse events
- if (Button()) {
- changed = 2;
- goto end;
- }
-
- usleep(1000);
- }
-
-end:
- if (js != NULL) {
- SDL_JoystickClose(js);
- }
-
- return changed;
-}
-
-int ReadAnalogEvent(int padnum, int analognum, int analogdir) {
- SDL_Joystick *js;
- int i, changed = 0, t;
- Sint16 axis;
-
- if (g.cfg.PadDef[padnum].DevNum >= 0) {
- js = SDL_JoystickOpen(g.cfg.PadDef[padnum].DevNum);
- SDL_JoystickEventState(SDL_IGNORE);
- } else {
- js = NULL;
- }
-
- for (t = 0; t < 1000000 / 1000; t++) {
- // check joystick events
- if (js != NULL) {
- SDL_JoystickUpdate();
-
- for (i = 0; i < SDL_JoystickNumButtons(js); i++) {
- if (SDL_JoystickGetButton(js, i)) {
- g.cfg.PadDef[padnum].AnalogDef[analognum][analogdir].JoyEvType = BUTTON;
- g.cfg.PadDef[padnum].AnalogDef[analognum][analogdir].J.Button = i;
- changed = 1;
- goto end;
- }
- }
-
- for (i = 0; i < NUM_AXES(js); i++) {
- axis = SDL_JoystickGetAxis(js, i);
- if (abs(axis) > 16383 && (abs(axis - PrevAxisPos[i]) > 4096 || abs(axis - InitialAxisPos[i]) > 4096)) {
- g.cfg.PadDef[padnum].AnalogDef[analognum][analogdir].JoyEvType = AXIS;
- g.cfg.PadDef[padnum].AnalogDef[analognum][analogdir].J.Axis = (i + 1) * (axis > 0 ? 1 : -1);
- changed = 1;
- goto end;
- }
- PrevAxisPos[i] = axis;
- }
-
- for (i = 0; i < SDL_JoystickNumHats(js); i++) {
- axis = SDL_JoystickGetHat(js, i);
- if (axis != SDL_HAT_CENTERED) {
- g.cfg.PadDef[padnum].AnalogDef[analognum][analogdir].JoyEvType = HAT;
-
- if (axis & SDL_HAT_UP) {
- g.cfg.PadDef[padnum].AnalogDef[analognum][analogdir].J.Hat = ((i << 8) | SDL_HAT_UP);
- } else if (axis & SDL_HAT_DOWN) {
- g.cfg.PadDef[padnum].AnalogDef[analognum][analogdir].J.Hat = ((i << 8) | SDL_HAT_DOWN);
- } else if (axis & SDL_HAT_LEFT) {
- g.cfg.PadDef[padnum].AnalogDef[analognum][analogdir].J.Hat = ((i << 8) | SDL_HAT_LEFT);
- } else if (axis & SDL_HAT_RIGHT) {
- g.cfg.PadDef[padnum].AnalogDef[analognum][analogdir].J.Hat = ((i << 8) | SDL_HAT_RIGHT);
- }
-
- changed = 1;
- goto end;
- }
- }
- }
-
- // check keyboard events
- i = CheckKeyDown();
- if (i != 0) {
- if (i != 0x36) g.cfg.PadDef[padnum].AnalogDef[analognum][analogdir].Key = i;
- changed = 1;
- goto end;
- }
-
- // check mouse events
- if (Button()) {
- changed = 2;
- goto end;
- }
-
- usleep(1000);
- }
-
-end:
- if (js != NULL) {
- SDL_JoystickClose(js);
- }
-
- return changed;
-}
diff --git a/macosx/plugins/DFInput/macsrc/cfg.h b/macosx/plugins/DFInput/macsrc/cfg.h
deleted file mode 100644
index 99bc103..0000000
--- a/macosx/plugins/DFInput/macsrc/cfg.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2010, Wei Mingzhi <whistler@openoffice.org>.
- * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses>.
- */
-
-#ifndef CFG_H
-#define CFG_H
-
-#include "pad.h"
-
-void GetKeyDescription(char *buf, int joynum, int key);
-void GetAnalogDescription(char *buf, int joynum, int analognum, int dir);
-void InitAxisPos(int padnum);
-int ReadDKeyEvent(int padnum, int key);
-int ReadAnalogEvent(int padnum, int analognum, int analogdir);
-
-#endif
diff --git a/macosx/plugins/DFInput/macsrc/xkb.c b/macosx/plugins/DFInput/macsrc/xkb.c
deleted file mode 100644
index e9345c2..0000000
--- a/macosx/plugins/DFInput/macsrc/xkb.c
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (c) 2010, Wei Mingzhi <whistler@openoffice.org>.
- * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses>.
- */
-
-#include "pad.h"
-
-void InitKeyboard() {
- g.PadState[0].KeyStatus = 0xFFFF;
- g.PadState[1].KeyStatus = 0xFFFF;
-}
-
-void DestroyKeyboard() {
-}
-
-void CheckKeyboard() {
- int i, j, k;
- uint16_t key;
-
- union {
- KeyMap km;
- KeyMapByteArray k;
- } keyState;
-
- g.PadState[0].KeyStatus = 0xFFFF;
- g.PadState[1].KeyStatus = 0xFFFF;
-
- GetKeys(keyState.km);
-
-#define KeyDown(X) \
- (keyState.k[((X) - 1) >> 3] & (1 << (((X) - 1) & 7)))
-
- for (i = 0; i < 2; i++) {
- for (j = 0; j < DKEY_TOTAL; j++) {
- key = g.cfg.PadDef[i].KeyDef[j].Key;
- if (key == 0) continue;
-
- if (KeyDown(key)) g.PadState[i].KeyStatus &= ~(1 << j);
- }
-
- if (g.cfg.PadDef[i].Type != PSE_PAD_TYPE_ANALOGPAD) continue;
-
- for (j = 0; j < ANALOG_TOTAL; j++) {
- for (k = 0; k < 4; k++) {
- key = g.cfg.PadDef[i].AnalogDef[j][k].Key;
- if (key == 0) continue;
-
- g.PadState[i].AnalogKeyStatus[j][k] = (KeyDown(key) ? 1 : 0);
- }
- }
- }
-}