summaryrefslogtreecommitdiff
path: root/macosx/plugins/DFInput/macsrc/ControllerList.m
diff options
context:
space:
mode:
authorSND\weimingzhi_cp <SND\weimingzhi_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97>2010-07-29 00:34:36 +0000
committerSND\weimingzhi_cp <SND\weimingzhi_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97>2010-07-29 00:34:36 +0000
commit8d4373b70d74ff5903c13780f397bdbaa5ad4991 (patch)
treea329eae7b9c41010d23dd41300a3b1317ccbca9f /macosx/plugins/DFInput/macsrc/ControllerList.m
parentdf065b4bf4205db561a5fe7d5652352f6046e40f (diff)
downloadpcsxr-8d4373b70d74ff5903c13780f397bdbaa5ad4991.tar.gz
implemented config dialog for DFInput on OSX, removed HIDInput.
git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@55259 e17a0e51-4ae3-4d35-97c3-1a29b211df97
Diffstat (limited to 'macosx/plugins/DFInput/macsrc/ControllerList.m')
-rw-r--r--macosx/plugins/DFInput/macsrc/ControllerList.m143
1 files changed, 143 insertions, 0 deletions
diff --git a/macosx/plugins/DFInput/macsrc/ControllerList.m b/macosx/plugins/DFInput/macsrc/ControllerList.m
new file mode 100644
index 00000000..5d67370a
--- /dev/null
+++ b/macosx/plugins/DFInput/macsrc/ControllerList.m
@@ -0,0 +1,143 @@
+/*
+ * 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