summaryrefslogtreecommitdiff
path: root/macosx/plugins/HIDInput/src
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/HIDInput/src
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/HIDInput/src')
-rw-r--r--macosx/plugins/HIDInput/src/ControllerList.h56
-rw-r--r--macosx/plugins/HIDInput/src/ControllerList.m245
-rw-r--r--macosx/plugins/HIDInput/src/ExtendedKeys.h23
-rw-r--r--macosx/plugins/HIDInput/src/KeyConfig.h60
-rw-r--r--macosx/plugins/HIDInput/src/KeyConfig.m535
-rw-r--r--macosx/plugins/HIDInput/src/MappingCell.h28
-rw-r--r--macosx/plugins/HIDInput/src/MappingCell.m95
-rw-r--r--macosx/plugins/HIDInput/src/PadController.h35
-rw-r--r--macosx/plugins/HIDInput/src/PadController.m139
-rw-r--r--macosx/plugins/HIDInput/src/PadView.h37
-rw-r--r--macosx/plugins/HIDInput/src/PadView.m113
-rw-r--r--macosx/plugins/HIDInput/src/PlugPAD.c453
-rw-r--r--macosx/plugins/HIDInput/src/PlugPAD.h35
13 files changed, 0 insertions, 1854 deletions
diff --git a/macosx/plugins/HIDInput/src/ControllerList.h b/macosx/plugins/HIDInput/src/ControllerList.h
deleted file mode 100644
index b6b4264f..00000000
--- a/macosx/plugins/HIDInput/src/ControllerList.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/***************************************************************************
- ControllerList.h
- HIDInput
-
- Created by Gil Pedersen on Mon May 03 2004.
- 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. See also the license.txt file for *
- * additional informations. *
- * *
- ***************************************************************************/
-
-#define ControllerList NetPcsxHIDInputPluginControllerList
-
-#import <Foundation/Foundation.h>
-#import <AppKit/NSTableView.h>
-#import "KeyConfig.h"
-
-@class KeyConfig;
-
-@interface ControllerList : NSObject {
- int currentController;
- KeyConfig *config;
- NSArray *plist;
- //NSArray *keys;
- NSArray *typeList;
- //NSString *type;
- //NSString *currentSet;
- //NSMutableDictionary *keyValues;
-}
-
-- (id)initWithConfig:(KeyConfig *)keyconfig;
-
-- (NSArray *)controllerTypes;
-
-- (NSDictionary *)dictForType:(NSString *)type;
-- (NSArray *)elementsForType:(NSString *)type;
-- (NSString *)elementNameAtIndex:(int)index type:(NSString *)type;
-- (int)elementCountForType:(NSString *)type;
-- (int)controllerTypeIdForType:(NSString *)type;
-- (int)buttonIdAtIndex:(int)index type:(NSString *)type;
-- (int)axisIdAtIndex:(int)index type:(NSString *)type;
-- (int)axisDirectionAtIndex:(int)index type:(NSString *)type;
-
-- (void)setCurrentController:(int)which;
-- (int)currentController;
-- (int)numberOfRowsInTableView:(NSTableView *)aTableView;
-- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex;
-
-@end
diff --git a/macosx/plugins/HIDInput/src/ControllerList.m b/macosx/plugins/HIDInput/src/ControllerList.m
deleted file mode 100644
index 21fc9acf..00000000
--- a/macosx/plugins/HIDInput/src/ControllerList.m
+++ /dev/null
@@ -1,245 +0,0 @@
-/***************************************************************************
- ControllerList.m
- HIDInput
-
- Created by Gil Pedersen on Mon May 03 2004.
- 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. See also the license.txt file for *
- * additional informations. *
- * *
- ***************************************************************************/
-
-#import "ControllerList.h"
-
-@implementation ControllerList
-
-- (id)initWithConfig:(KeyConfig *)keyconfig
-{
- if (!(self = [super init]) || nil == keyconfig)
- return nil;
-
- config = keyconfig;
-
- /* load keyinfo plist */
- NSString *path = [[NSBundle bundleWithIdentifier:@"net.pcsx.HIDInputPlugin"] pathForResource:@"psxKeys" ofType:@"plist"];
- NSData *plistData;
- NSString *error;
- int i;
-
- plistData = [NSData dataWithContentsOfFile:path];
- plist = [NSPropertyListSerialization propertyListFromData:plistData
- mutabilityOption:NSPropertyListImmutable
- format:nil
- errorDescription:&error];
- if(!plist)
- {
- NSLog(error);
- [error release];
- return nil;
- }
-
- [plist retain];
- //[plistData retain];
-
- /* build typelist */
- NSMutableArray *tmpList = [NSMutableArray arrayWithCapacity:[plist count]];
- for (i=0; i<[plist count]; i++) {
- id name = [plist objectAtIndex:i];
- if ([name isKindOfClass:[NSString class]]) {
- [tmpList addObject:name];
- }
- }
- typeList = [[NSArray alloc] initWithArray:tmpList];
-
- return self;
-}
-
-- (void)dealloc
-{
- [typeList release];
-
- //[plistData release];
- [plist release];
- //[currentSet release];
-}
-
-
-
-/*
-- (NSString *)typeDefaultKey
-{
- return [NSString stringWithFormat:@"TypeForPad%iSet%@", currentController, [[NSUserDefaults standardUserDefaults] stringForKey:@"CurrentPadSet"]];
-}
-
-- (void)setType:(NSString *)aType
-{
- if (type)
- [type release];
- if (keys)
- [keys release];
-
- type = aType ? [aType retain] : [typeList objectAtIndex:0];
- keys = [[plist objectForKey:type] objectForKey:@"Buttons"];
- if (keys)
- [keys retain];
-
- [[NSUserDefaults standardUserDefaults] setObject:type forKey:[self typeDefaultKey]];
-}
-*/
-- (NSArray *)controllerTypes
-{
- return typeList;
-}
-/*
-- (NSString *)controllerType
-{
- return type;
-}*/
-
-- (NSDictionary *)dictForType:(NSString *)type
-{
- int index = [plist indexOfObject:type];
- if (NSNotFound == index)
- return [NSDictionary dictionary];
-
- id dict = [plist objectAtIndex:index+1];
- if (![dict isKindOfClass:[NSDictionary class]])
- return [NSDictionary dictionary];
-
- return dict;
-}
-
-- (NSArray *)elementsForType:(NSString *)type
-{
- return [[self dictForType:type] objectForKey:@"Elements"];
-}
-
-- (NSString *)elementNameAtIndex:(int)index type:(NSString *)type
-{
- if (nil == type || index < 0)
- return @"";
-
- NSArray *list = [self elementsForType:type];
- if (index*2 >= [list count])
- return @"";
-
- return [list objectAtIndex:index*2];
-}
-
-- (int)elementCountForType:(NSString *)type
-{
- if (nil == type)
- return 0;
-
- return [[self elementsForType:type] count]/2;
-}
-
-- (int)controllerTypeIdForType:(NSString *)type
-{
- if (nil == type)
- return 0;
-
- NSNumber *number = [[self dictForType:type] objectForKey:@"Type ID"];
- if (nil == number)
- return 0;
-
- return [number intValue];
-}
-
-- (int)buttonIdAtIndex:(int)index type:(NSString *)type
-{
- if (nil == type || index < 0)
- return -1;
-
- NSDictionary *dict = [[self elementsForType:type] objectAtIndex:index*2+1];
- NSNumber *number = [dict objectForKey:@"Button"];
- if (nil == number)
- return -1;
-
- return [number intValue];
-}
-
-- (int)axisIdAtIndex:(int)index type:(NSString *)type
-{
- if (nil == type || index < 0)
- return -1;
-
- NSDictionary *dict = [[self elementsForType:type] objectAtIndex:index*2+1];
- NSNumber *number = [dict objectForKey:@"Axis"];
- if (nil == number)
- return -1;
-
- return [number intValue];
-}
-
-- (int)axisDirectionAtIndex:(int)index type:(NSString *)type
-{
- if (nil == type || index < 0)
- return -1;
-
- NSDictionary *dict = [[self elementsForType:type] objectAtIndex:index*2+1];
- NSNumber *number = [dict objectForKey:@"Axis-Positive"];
- if (nil == number)
- return 1;
-
- return [number boolValue] ? 1 : -1;
-}
-
-- (NSArray *)defaultMappingsAtIndex:(int)index type:(NSString *)type
-{
- if (nil == type || index < 0)
- return -1;
-
- NSDictionary *dict = [[self elementsForType:type] objectAtIndex:index*2+1];
- return [dict objectForKey:@"Default Mappings"];
-}
-
-
-/* sets current controller data returned by data source */
-- (void)setCurrentController:(int)which
-{
- currentController = which;
-}
-
-- (int)currentController
-{
- return currentController;
-}
-
-/* NSDataSource */
-- (int)numberOfRowsInTableView:(NSTableView *)aTableView
-{
- return [self elementCountForType:[config currentTypeForPlayer:currentController]];
-}
-
-- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn
- row:(int)rowIndex
-{
- NSString *type = [config currentTypeForPlayer:currentController];
- if (type) {
- NSString *name = [self elementNameAtIndex:rowIndex type:type];
-
- if ([((NSString *)[aTableColumn identifier]) isEqualToString:@"key"])
- return NSLocalizedString(name, @"");
- else {
- // actual keys
- NSString *mappingName = [config mappingNamesForElement:name player:currentController];
- if (nil == mappingName) {
- return @"";
- //return NSLocalizedString(@"Double-Click to Set", @"");
- }
- return mappingName;
- }
- }
-
- return @"";
-}
-
-@end
diff --git a/macosx/plugins/HIDInput/src/ExtendedKeys.h b/macosx/plugins/HIDInput/src/ExtendedKeys.h
deleted file mode 100644
index 1b6475b8..00000000
--- a/macosx/plugins/HIDInput/src/ExtendedKeys.h
+++ /dev/null
@@ -1,23 +0,0 @@
-
-#ifndef __EXTENDED_KEYS_H__
-#define __EXTENDED_KEYS_H__
-
-enum {
- PSX_FREEZE_KEY = 0xFFBE/*XK_F1*/,
- PSX_NEXT_FREEZE_SLOT_KEY = 0xFFBF/*XK_F2*/,
- PSX_DEFROST_KEY = 0xFFC0/*XK_F3*/,
- PSX_SHOW_FREEZE_PIC_KEY = 0xFFC1/*XK_F4*/,
- PSX_SIO_ALWAYS_ON_KEY = 0xFFC2/*XK_F5*/,
- PSX_BW_MDEC_KEY = 0xFFC3/*XK_F6*/,
- PSX_XA_AUDIO_ON_KEY = 0xFFC4/*XK_F7*/,
- PSX_SNAPSHOT_KEY = 0xFFC5/*XK_F8*/,
- PSX_OPEN_SHELL_KEY = 0xFFC6/*XK_F9*/,
- PSX_CLOSE_SHELL_KEY = 0xFFC7/*XK_F10*/,
-
- PSX_STOP_KEY = 0xFF1B/*XK_Escape*/,
-
- GPU_FULLSCREEN_KEY = 0x0100,
- GPU_FPS_DISPLAY_KEY = 0xFFFF/*XK_Delete*/
-};
-
-#endif //__EXTENDED_KEYS_H__
diff --git a/macosx/plugins/HIDInput/src/KeyConfig.h b/macosx/plugins/HIDInput/src/KeyConfig.h
deleted file mode 100644
index 426783f5..00000000
--- a/macosx/plugins/HIDInput/src/KeyConfig.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/***************************************************************************
- KeyConfig.h
- HIDInput
-
- Created by Gil Pedersen on Sat May 29 2004.
- 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. See also the license.txt file for *
- * additional informations. *
- * *
- ***************************************************************************/
-
-#define KeyConfig NetPcsxHIDInputPluginKeyConfig
-
-#import <Carbon/Carbon.h>
-#include <IOKit/hid/IOHIDUsageTables.h>
-#include "HID_Utilities_External.h"
-#import "ControllerList.h"
-
-@class ControllerList;
-
-@interface KeyConfig : NSObject {
- ControllerList *list;
- NSDictionary *keyValues;
-}
-
-- (id)init;
-- (void)dealloc;
-
-+ (KeyConfig *)current;
-
-+ (NSString *)mappingIdForElement:(pRecElement)element onDevice:(pRecDevice)device reverse:(BOOL)reverse;
-+ (BOOL)reverseMappingForId:(NSString *)mappingId outElement:(pRecElement *)element outDevice:(pRecDevice *)device;
-+ (NSString *)nameFromMapping:(NSString *)mappingId;
-+ (NSString *)deviceNameFromMapping:(NSString *)mappingId;
-
-- (ControllerList *)controllerList;
-- (void)setCurrentSet:(NSString *)name;
-- (NSString *)currentSet;
-- (NSDictionary *)players;
-- (NSDictionary *)typesForPlayer:(int)player;
-- (void)setCurrentType:(NSString *)type player:(int)player;
-- (NSString *)currentTypeForPlayer:(int)player;
-- (NSDictionary *)currentKeysForPlayer:(int)player;
-
-- (void)addMapping:(NSString *)mappingId forElement:(NSString *)name player:(int)player;
-- (void)removeMappingsForElement:(NSString *)name player:(int)player;
-- (NSArray *)currentMappingsForElement:(NSString *)name player:(int)player;
-- (NSString *)mappingNamesForElement:(NSString *)name player:(int)player;
-
-- (void)updateKeys;
-- (void)releaseKeys;
-
-@end
diff --git a/macosx/plugins/HIDInput/src/KeyConfig.m b/macosx/plugins/HIDInput/src/KeyConfig.m
deleted file mode 100644
index 82ecd18b..00000000
--- a/macosx/plugins/HIDInput/src/KeyConfig.m
+++ /dev/null
@@ -1,535 +0,0 @@
-/***************************************************************************
- KeyConfig.h
- HIDInput
-
- Created by Gil Pedersen on Sat May 29 2004.
- 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. See also the license.txt file for *
- * additional informations. *
- * *
- ***************************************************************************/
-
-#import "KeyConfig.h"
-#include "PlugPAD.h"
-
-
-/*
- <Set 1> - [Player 1] - [Current Type]
- - <Type 1 Keys>
- - <Type 2 Keys>
- - ...
-
- - [Player 2] - ...
-
- <Set 2> - ...
- ...
-*/
-
-static KeyConfig *sKeyconfig;
-
-int LoadConfig()
-{
- if (!sKeyconfig)
- sKeyconfig = [[KeyConfig alloc] init];
-
- return 0;
-}
-
-// get name of element for display in window;
-// try names first then default to more generic derived names if device does not provide explicit names
-static void GetDeviceElementNameString(pRecDevice pDevice, pRecElement pElement, char * cstr)
-{
- char cstrElement[256] = "----", cstrDevice[256] = "----";
-
- if (!HIDIsValidElement(pDevice, pElement))
- return;
-
- if (HIDGetElementNameFromVendorProductUsage (pDevice->vendorID, pDevice->productID, pElement->usagePage, pElement->usage, cstr))
- return;
-
- if (*(pDevice->product))
- BlockMoveData(pDevice->product, cstrDevice, 256);
- else
- {
- HIDGetUsageName(pDevice->usagePage, pDevice->usage, cstrDevice);
- if (!*cstrDevice) // if usage
- sprintf(cstrDevice, "Device");
- }
-
- if (*(pElement->name))
- BlockMoveData(pElement->name, cstrElement, 256);
- else // if no name
- {
- HIDGetUsageName(pElement->usagePage, pElement->usage, cstrElement);
- if (!*cstrElement) // if not usage
- sprintf(cstrElement, "Element");
- }
- sprintf(cstr, "%s: %s", cstrDevice, cstrElement);
-}
-
-@implementation KeyConfig
-
-- (id)init
-{
- if ((self = [super init]) == nil)
- return nil;
-
- /* Using the defaults system means that we will effectively piggy-back on
- the parent process' preferences. This behaviour is ok, since it allows
- for seperate preferences for each application that will use the plugin */
- NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
- [defaults registerDefaults:[NSDictionary dictionaryWithObjectsAndKeys:
- @"Default", @"net.pcsx.HIDInputPlugin Current Set",
- [[NSMutableDictionary alloc] initWithCapacity:1], @"net.pcsx.HIDInputPlugin Pad Settings",
- nil]];
-
- /* load from preferences */
- keyValues = [[defaults dictionaryForKey:@"net.pcsx.HIDInputPlugin Pad Settings"] retain];
-
- list = [[ControllerList alloc] initWithConfig:self];
-
- [self setCurrentSet:[self currentSet]];
- [self updateKeys];
-
- return self;
-}
-
-- (void)dealloc
-{
- [keyValues release];
- [list release];
-}
-
-+ (KeyConfig *)current
-{
- if (!sKeyconfig)
- LoadConfig();
-
- return sKeyconfig;
-}
-
-- (ControllerList *)controllerList
-{
- return list;
-}
-
-#if 0
-- (void)setDefaultMappingsWithType:(NSString *)type device:(NSString *)device player:(int)player
-{
- int len = [list elementCountForType:type];
- int i;
-
- for (i=0; i<len; i++) {
- NSArray *mappings = [list defaultMappingsAtIndex:i type:type];
-
- }
-}
-
-- (void)setDefaultMappingsInSet:(NSString *)name
-{
- NSArray *devices = [self systemDeviceList];
-
- /* assign all keyboards to player 1 */
- //if (
-
- /* assign the first joypad to player 1 */
-
- /* assign second joypad to player 2 */
-}
-#endif
-
-- (void)setCurrentSet:(NSString *)name
-{
- [[NSUserDefaults standardUserDefaults] setObject:name forKey:@"net.pcsx.HIDInputPlugin Current Set"];
-
- /* create the entry if neccesary */
- NSDictionary *dict = [keyValues objectForKey:name];
- if (nil == dict) {
- dict = [NSMutableDictionary dictionaryWithCapacity:2];
- if (![keyValues respondsToSelector:@selector(setObject)]) {
- [keyValues autorelease];
- keyValues = [[NSMutableDictionary alloc] initWithDictionary:keyValues];
- }
- [(NSMutableDictionary *)keyValues setObject:dict forKey:name];
- }
-}
-
-- (NSString *)currentSet
-{
- NSString *set = [[NSUserDefaults standardUserDefaults] stringForKey:@"net.pcsx.HIDInputPlugin Current Set"];
- if (nil == set) {
- //[self setDefaultMappingsInSet:@"Default"];
- return @"Default";
- }
-
- return set;
-}
-
-- (NSDictionary *)players
-{
- return [keyValues objectForKey:[self currentSet]];
-}
-- (NSMutableDictionary *)mutablePlayers
-{
- NSDictionary *players = [self players];
-
- if (![players respondsToSelector:@selector(setObject)]) {
- players = [NSMutableDictionary dictionaryWithDictionary:players];
- if (![keyValues respondsToSelector:@selector(setObject)]) {
- [keyValues autorelease];
- keyValues = [[NSMutableDictionary alloc] initWithDictionary:keyValues];
- }
- [(NSMutableDictionary *)keyValues setObject:players forKey:[self currentSet]];
- }
-
- return (NSMutableDictionary *)players;
-}
-
-
-- (NSDictionary *)typesForPlayer:(int)player
-{
- NSDictionary *types = [[self players] objectForKey:[NSString stringWithFormat:@"Player %i", player+1]];
- if (nil == types)
- return [NSDictionary dictionary];
-
- return types;
-}
-- (NSMutableDictionary *)mutableTypesForPlayer:(int)player
-{
- NSDictionary *types = [self typesForPlayer:player];
-
- if (![types respondsToSelector:@selector(setObject)]) {
- types = [NSMutableDictionary dictionaryWithDictionary:types];
- [[self mutablePlayers] setObject:types forKey:[NSString stringWithFormat:@"Player %i", player+1]];
- }
-
- return (NSMutableDictionary *)types;
-}
-
-- (void)setCurrentType:(NSString *)type player:(int)player
-{
-/* NSString *playerKey = [NSString stringWithFormat:@"Player %i", player+1];
- NSDictionary *types = [[self players] objectForKey:playerKey];
- if (nil == types) {
- types = [NSMutableDictionary dictionaryWithCapacity:2];
- [[self mutablePlayers] setObject:types forKey:playerKey];
- }*/
-
- if (![type isEqualToString:[self currentTypeForPlayer:player]]) {
- NSMutableDictionary *types = [self mutableTypesForPlayer:player];
-
- /* set the type */
- [types setObject:type forKey:@"Current Type"];
-
- /* make sure its dictionary is created */
- NSDictionary *keys = [types objectForKey:type];
- if (nil == keys) {
- keys = [NSMutableDictionary dictionaryWithCapacity:1];
- [types setObject:keys forKey:type];
- }
- }
-}
-
-- (NSString *)currentTypeForPlayer:(int)player
-{
- return [[self typesForPlayer:player] objectForKey:@"Current Type"];
-}
-
-
-- (NSDictionary*)currentKeysForPlayer:(int)player
-{
- NSString *typeKey = [self currentTypeForPlayer:player];
- if (nil == typeKey)
- return nil;
-
- return [[self typesForPlayer:player] objectForKey:typeKey];
-}
-- (NSMutableDictionary *)mutableKeysForPlayer:(int)player
-{
- NSDictionary *keys = [self currentKeysForPlayer:player];
-
- if (![keys respondsToSelector:@selector(setObject)]) {
- keys = [NSMutableDictionary dictionaryWithDictionary:keys];
- [[self mutableTypesForPlayer:player] setObject:keys forKey:[self currentTypeForPlayer:player]];
- }
-
- return (NSMutableDictionary *)keys;
-}
-
-
-- (void)addMapping:(NSString *)mappingId forElement:(NSString *)name player:(int)player
-{
- NSMutableDictionary *keys = [self mutableKeysForPlayer:player];
- NSMutableArray *mappings = [keys objectForKey:name];
- if (nil == mappings) {
- mappings = [NSMutableArray arrayWithCapacity:1];
- [keys setObject:mappings forKey:name];
- } else {
- /* check if it's new */
- int i;
- for (i=0; i<[mappings count]; i++) {
- if ([[mappings objectAtIndex:i] isEqualToString:mappingId])
- return;
- }
- }
- [mappings addObject:mappingId];
-}
-
-- (void)removeMappingsForElement:(NSString *)name player:(int)player
-{
- NSMutableDictionary *keys = [self mutableKeysForPlayer:player];
- [keys removeObjectForKey:name];
-}
-
-- (NSArray *)currentMappingsForElement:(NSString *)name player:(int)player
-{
- NSArray *mappings = [[self currentKeysForPlayer:player] objectForKey:name];
- if (nil == mappings)
- return [NSArray array];
-
- return mappings;
-}
-
-- (NSString *)mappingNamesForElement:(NSString *)name player:(int)player
-{
- NSMutableArray *mappings = [NSMutableArray arrayWithArray:[self currentMappingsForElement:name player:player]];
- NSMutableString *mappingName = [NSMutableString stringWithCapacity:256];
- int i;
-
- if (0 == [mappings count])
- return nil;
-
- while ([mappings count] > 0) {
- NSString *deviceName = [KeyConfig deviceNameFromMapping:[mappings objectAtIndex:0]];
- if (0 != [mappingName length])
- [mappingName appendString:@" and "];
-
- [mappingName appendString:deviceName];
- [mappingName appendString:@": "];
- [mappingName appendString:[KeyConfig nameFromMapping:[mappings objectAtIndex:0]]];
- [mappings removeObjectAtIndex:0];
-
- for (i=0; i<[mappings count]; i++) {
- if ([deviceName isEqualToString:[KeyConfig deviceNameFromMapping:[mappings objectAtIndex:0]]]) {
- [mappingName appendString:@", "];
- [mappingName appendString:[KeyConfig nameFromMapping:[mappings objectAtIndex:i]]];
- [mappings removeObjectAtIndex:i]; i--;
- }
- }
- }
-
- return [NSString stringWithString:mappingName];
-}
-
-+ (NSString *)mappingIdForElement:(pRecElement)element onDevice:(pRecDevice)device reverse:(BOOL)reverse
-{
- return [NSString stringWithFormat:@"d:{v:%ld, p:%ld, l:%ld, p:%ld, u:%ld}, e:{t:%ld, p:%ld, u:%ld, c:%ld, r:%ld}",
- device->vendorID, device->productID, device->locID, device->usagePage, device->usage,
- element->type, element->usagePage, element->usage, element->cookie, reverse];
-}
-
-+ (BOOL)reverseMappingForId:(NSString *)mappingId outElement:(pRecElement *)element outDevice:(pRecDevice *)device
-{
- recDevice searchDevice;
- recElement searchElement;
- long reverse;
- int count = sscanf([mappingId cString], "d:{v:%ld, p:%ld, l:%ld, p:%ld, u:%ld}, e:{t:%ld, p:%ld, u:%ld, c:%ld, r:%ld}",
- &searchDevice.vendorID, &searchDevice.productID, &searchDevice.locID, &searchDevice.usagePage, &searchDevice.usage,
- &searchElement.type, &searchElement.usagePage, &searchElement.usage, (long*)&searchElement.cookie, &reverse);
-
- if (9 == count || 10 == count) {
- if (HIDFindActionDeviceAndElement(&searchDevice, &searchElement,device, element)) {
- return YES;
- }
- }
-
- return NO;
-}
-
-+ (BOOL)mappingIsReverse:(NSString *)mappingId
-{
- recDevice searchDevice;
- recElement searchElement;
- long reverse;
- int count = sscanf([mappingId cString], "d:{v:%ld, p:%ld, l:%ld, p:%ld, u:%ld}, e:{t:%ld, p:%ld, u:%ld, c:%ld, r:%ld}",
- &searchDevice.vendorID, &searchDevice.productID, &searchDevice.locID, &searchDevice.usagePage, &searchDevice.usage,
- &searchElement.type, &searchElement.usagePage, &searchElement.usage, (long*)&searchElement.cookie, &reverse);
-
- if (10 == count) {
- return (reverse != 0);
- }
-
- return NO;
-}
-
-+ (NSString *)nameFromMapping:(NSString *)mappingId
-{
- pRecElement element;
- pRecDevice device;
-
- if ([self reverseMappingForId:mappingId outElement:&element outDevice:&device]) {
- if (device->usagePage == kHIDPage_GenericDesktop && device->usage == kHIDUsage_GD_Mouse) {
- if (element->usagePage == kHIDPage_Button) {
- return [NSString stringWithFormat:@"Button %i", element->usage];
- }
- } else if (element->usagePage == kHIDPage_KeyboardOrKeypad) {
- int key = element->usage;
- if (key >= kHIDUsage_KeyboardA && key <= kHIDUsage_KeyboardZ) {
- return [NSString stringWithFormat:@"%c", (key-kHIDUsage_KeyboardA)+'A'];
- } else if (key >= kHIDUsage_Keyboard1 && key <= kHIDUsage_Keyboard0) {
- if (key == kHIDUsage_Keyboard0)
- return [NSString stringWithFormat:@"%c", '0'];
-
- return [NSString stringWithFormat:@"%c", (key-kHIDUsage_Keyboard1)+'1'];
- } else if (key >= kHIDUsage_KeyboardF1 && key <= kHIDUsage_KeyboardF12) {
- return [NSString stringWithFormat:@"F%i", (key-kHIDUsage_KeyboardF1)+1];
- } else if (key >= kHIDUsage_Keypad1 && key <= kHIDUsage_Keypad9) {
- return [NSString stringWithFormat:@"Keypad %i", (key-kHIDUsage_Keypad1)+1];
- } else {
- NSString *s = nil;
- switch (key) {
- case kHIDUsage_KeyboardReturnOrEnter: s=@"Return"; break;
- case kHIDUsage_KeyboardEscape: s=@"Escape"; break;
- case kHIDUsage_KeyboardDeleteOrBackspace: s=@"Delete"; break;
- case kHIDUsage_KeyboardTab: s=@"Tab"; break;
- case kHIDUsage_KeyboardSpacebar: s=@"Space"; break;
- case kHIDUsage_KeyboardHyphen: s=@"-"; break;
- case kHIDUsage_KeyboardEqualSign: s=@"="; break;
- case kHIDUsage_KeyboardOpenBracket: s=@"["; break;
- case kHIDUsage_KeyboardCloseBracket: s=@"]"; break;
- case kHIDUsage_KeyboardBackslash: s=@"\\"; break;
- case kHIDUsage_KeyboardSemicolon: s=@";"; break;
- case kHIDUsage_KeyboardQuote: s=@"'"; break;
- case kHIDUsage_KeyboardGraveAccentAndTilde: s=@"ยด"; break;
- case kHIDUsage_KeyboardComma: s=@","; break;
- case kHIDUsage_KeyboardPeriod: s=@"."; break;
- case kHIDUsage_KeyboardSlash: s=@"/"; break;
-
- case kHIDUsage_KeyboardCapsLock: s=@"Caps Lock"; break;
- case kHIDUsage_KeyboardRightArrow: s=@"Right Arrow"; break;
- case kHIDUsage_KeyboardLeftArrow: s=@"Left Arrow"; break;
- case kHIDUsage_KeyboardDownArrow: s=@"Down Arrow"; break;
- case kHIDUsage_KeyboardUpArrow: s=@"Up Arrow"; break;
-
- case kHIDUsage_KeypadNumLock: s=@"NumLock"; break;
- case kHIDUsage_KeypadSlash: s=@"Keypad /"; break;
- case kHIDUsage_KeypadAsterisk: s=@"Keypad *"; break;
- case kHIDUsage_KeypadHyphen: s=@"Keypad -"; break;
- case kHIDUsage_KeypadPlus: s=@"Keypad +"; break;
- case kHIDUsage_KeypadEnter: s=@"Keypad Enter"; break;
- case kHIDUsage_Keypad0: s=@"Keypad 0"; break;
- case kHIDUsage_KeypadPeriod: s=@"Keypad ."; break;
- case kHIDUsage_KeypadEqualSign: s=@"Keypad ="; break;
-
- case kHIDUsage_KeyboardLeftControl: s=@"Left Control"; break;
- case kHIDUsage_KeyboardLeftShift: s=@"Left Shift"; break;
- case kHIDUsage_KeyboardLeftAlt: s=@"Left Option"; break;
- case kHIDUsage_KeyboardLeftGUI: s=@"Left Command"; break;
- case kHIDUsage_KeyboardRightControl: s=@"Right Control"; break;
- case kHIDUsage_KeyboardRightShift: s=@"Right Shift"; break;
- case kHIDUsage_KeyboardRightAlt: s=@"Right Option"; break;
- case kHIDUsage_KeyboardRightGUI: s=@"Right Command"; break;
- }
- if (s) {
- return s;
- }
- }
- }
-
- char name[256];
-
- if (HIDGetElementNameFromVendorProductUsage (device->vendorID, device->productID, element->usagePage, element->usage, name))
- return [NSString stringWithCString:name];
- return [NSString stringWithCString:element->name];
- } else {
- return NSLocalizedString(@"Unknown Key", @"");
- }
-}
-
-+ (NSString *)deviceNameFromMapping:(NSString *)mappingId
-{
- pRecElement element;
- pRecDevice device;
-
- if ([self reverseMappingForId:mappingId outElement:&element outDevice:&device]) {
- return [NSString stringWithCString:device->product];
- } else {
- return NSLocalizedString(@"Unknown Device", @"");
- }
-}
-
-/* called when ok is pressed */
-- (void)updateKeys
-{
- int i, j, k;
-
- /* transfer to working set */
- for (i=0; i<MAX_NUM_PADS; i++) {
- NSString *type = [self currentTypeForPlayer:i];
-
- gControllerType[i] = [list controllerTypeIdForType:type];
- gNumKeys[i] = gNumAxes[i] = 0;
-
- for (j=0; j<[list elementCountForType:type]; j++) {
- NSString *name = [list elementNameAtIndex:j type:type];
- NSArray *mappings = [self currentMappingsForElement:name player:i];
- int button = [list buttonIdAtIndex:j type:type];
-
- if (-1 == button) {
- int axis = [list axisIdAtIndex:j type:type];
- if (-1 != axis) {
- BOOL positive = ([list axisDirectionAtIndex:j type:type] >= 0);
-
- for (k=0; k<[mappings count]; k++) {
- NSString *mapId = [mappings objectAtIndex:k];
-
- if (gNumAxes[i] >= MAX_NUM_AXES)
- break;
-
- if ([KeyConfig reverseMappingForId:mapId outElement:&gAxes[i][gNumAxes[i]].element outDevice:&gAxes[i][gNumAxes[i]].device]) {
- gAxes[i][gNumAxes[i]].axis = axis;
- gAxes[i][gNumAxes[i]].reverse = [KeyConfig mappingIsReverse:mapId];
- gAxes[i][gNumAxes[i]].positive = positive;
- gAxes[i][gNumAxes[i]].lastValue = 127;
- gNumAxes[i]++;
- }
- }
- }
- } else {
- for (k=0; k<[mappings count]; k++) {
- NSString *mapId = [mappings objectAtIndex:k];
-
- if (gNumKeys[i] >= MAX_NUM_KEYS)
- break;
-
- if ([KeyConfig reverseMappingForId:mapId outElement:&gKeys[i][gNumKeys[i]].element outDevice:&gKeys[i][gNumKeys[i]].device]) {
- gKeys[i][gNumKeys[i]].button = button;
- gKeys[i][gNumKeys[i]].reverse = [KeyConfig mappingIsReverse:mapId];
- gNumKeys[i]++;
- }
- }
- }
- }
- }
-
- /* save to preferences */
- NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
- [defaults setObject:keyValues forKey:@"net.pcsx.HIDInputPlugin Pad Settings"];
- [defaults synchronize];
-}
-
-/* called when cancel button is pressed */
-- (void)releaseKeys
-{
- [keyValues release];
- keyValues = [[[NSUserDefaults standardUserDefaults] dictionaryForKey:@"net.pcsx.HIDInputPlugin Pad Settings"] retain];
-}
-
-@end
diff --git a/macosx/plugins/HIDInput/src/MappingCell.h b/macosx/plugins/HIDInput/src/MappingCell.h
deleted file mode 100644
index a649b81d..00000000
--- a/macosx/plugins/HIDInput/src/MappingCell.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/***************************************************************************
- MappingCell.h
- HIDInput
-
- Created by Gil Pedersen on Mon Jun 07 2004.
- 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. See also the license.txt file for *
- * additional informations. *
- * *
- ***************************************************************************/
-
-#define MappingCell NetPcsxHIDInputPluginMappingCell
-
-#import <AppKit/AppKit.h>
-
-
-@interface MappingCell : NSTextFieldCell {
-
-}
-
-@end
diff --git a/macosx/plugins/HIDInput/src/MappingCell.m b/macosx/plugins/HIDInput/src/MappingCell.m
deleted file mode 100644
index 8f62c72a..00000000
--- a/macosx/plugins/HIDInput/src/MappingCell.m
+++ /dev/null
@@ -1,95 +0,0 @@
-/***************************************************************************
- MappingCell.h
- HIDInput
-
- Created by Gil Pedersen on Mon Jun 07 2004.
- 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. See also the license.txt file for *
- * additional informations. *
- * *
- ***************************************************************************/
-
-#import "MappingCell.h"
-#import "Keyconfig.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];
-
- pRecDevice device;
- pRecElement element;
- NSEvent *endEvent;
- NSPoint where = {0.0, 0.0};
- ControllerList *controllerList = [[KeyConfig current] controllerList];
- int whichPad = [controllerList currentController];
- NSTableView *tableView = (NSTableView *)[self controlView];
- int i, direction;
-
- /* 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]];
-
- /* wait for 10 seconds for user to press a key */
- for (i=0;i<10;i++) {
- [NSApp runModalSession:session];
- direction = HIDConfigureAction(&device, &element, 1.0/* timeout */);
- if (0 != direction)
- break;
- }
- if (element) {
- if (element->usagePage == kHIDPage_KeyboardOrKeypad && element->usage == kHIDUsage_KeyboardEscape) {
- /* escape cancels */
- element = nil;
- } else {
- KeyConfig *config = [KeyConfig current];
- NSString *mappingId = [KeyConfig mappingIdForElement:element onDevice:device reverse:(direction < 0)];
- [config addMapping:mappingId
- forElement:[controllerList elementNameAtIndex:[tableView selectedRow] type:[config currentTypeForPlayer:whichPad]]
- player:whichPad];
- }
- /* 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];
- }
- [NSApp endModalSession:session];
-
- /* move selection to the next list element */
- [self endEditing:textObj];
- if (element) {
- int nextRow = [tableView selectedRow]+1;
- if (nextRow >= [tableView numberOfRows]) {
- [tableView deselectAll:self];
- return;
- }
- [tableView selectRow:nextRow byExtendingSelection:NO];
-
- // I wonder if it's a good idea to begin to edit the next element automatically - for now i think not
- //[tableView editColumn:[tableView columnWithIdentifier:@"button"] row:nextRow withEvent:nil select:YES];
- }
- [[tableView window] makeFirstResponder:tableView];
-}
-
-@end
diff --git a/macosx/plugins/HIDInput/src/PadController.h b/macosx/plugins/HIDInput/src/PadController.h
deleted file mode 100644
index c3101307..00000000
--- a/macosx/plugins/HIDInput/src/PadController.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/***************************************************************************
- PadController.h
- HIDInput
-
- Created by Gil Pedersen on Sun Mar 07 2004.
- 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. See also the license.txt file for *
- * additional informations. *
- * *
- ***************************************************************************/
-
-#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/HIDInput/src/PadController.m b/macosx/plugins/HIDInput/src/PadController.m
deleted file mode 100644
index ab41db0e..00000000
--- a/macosx/plugins/HIDInput/src/PadController.m
+++ /dev/null
@@ -1,139 +0,0 @@
-/***************************************************************************
- PadController.m
- HIDInput
-
- Created by Gil Pedersen on Sun Mar 07 2004.
- 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. See also the license.txt file for *
- * additional informations. *
- * *
- ***************************************************************************/
-
-#import <Cocoa/Cocoa.h>
-#import "PadController.h"
-#include "HID_Utilities_External.h"
-#include "PlugPAD.h"
-
-static NSWindow *padWindow;
-static PadController *padController;
-
-#define APP_ID @"net.pcsx.HIDInputPlugin"
-
-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()
-{
- 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
-{
- [self close];
-}
-
-- (IBAction)ok:(id)sender
-{
- [[KeyConfig current] updateKeys];
-
- [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
-{
- //int oldView = [[[KeyConfig current] controllerList] currentController];
- //int newView = [[notification object] isEqual:controllerView1] ? 0 : 1;
- 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]) {
- [[KeyConfig current] releaseKeys];
-
- [[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(windowBecameKey:)
- name:NSWindowDidBecomeKeyNotification object:[self window]];
- }
-}
-
-@end \ No newline at end of file
diff --git a/macosx/plugins/HIDInput/src/PadView.h b/macosx/plugins/HIDInput/src/PadView.h
deleted file mode 100644
index e9860091..00000000
--- a/macosx/plugins/HIDInput/src/PadView.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/***************************************************************************
- PadView.h
- HIDInput
-
- Created by Gil Pedersen on Thu May 27 2004.
- 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. See also the license.txt file for *
- * additional informations. *
- * *
- ***************************************************************************/
-
-#define PadView NetPcsxHIDInputPluginPadView
-
-#import <Cocoa/Cocoa.h>
-#import "ControllerList.h"
-
-@class ControllerList;
-
-@interface PadView : NSView
-{
- IBOutlet NSTableView *tableView;
- IBOutlet NSPopUpButton *typeMenu;
-
- ControllerList *controller;
-}
-- (IBAction)setType:(id)sender;
-
-- (void)setController:(int)which;
-
-@end
diff --git a/macosx/plugins/HIDInput/src/PadView.m b/macosx/plugins/HIDInput/src/PadView.m
deleted file mode 100644
index 4ab17ce1..00000000
--- a/macosx/plugins/HIDInput/src/PadView.m
+++ /dev/null
@@ -1,113 +0,0 @@
-/***************************************************************************
- PadView.m
- HIDInput
-
- Created by Gil Pedersen on Thu May 27 2004.
- 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. See also the license.txt file for *
- * additional informations. *
- * *
- ***************************************************************************/
-
-#import "PadView.h"
-
-@implementation PadView
-
-- (id)initWithFrame:(NSRect)frameRect
-{
- if ((self = [super initWithFrame:frameRect]) != nil) {
- // Add initialization code here
- //NSLog(@"rect: %f,%f;%f,%f\n", frameRect.origin.x, frameRect.origin.y, frameRect.size.width, frameRect.size.height);
- //controller = [[ControllerList alloc] initWithConfig];
- //setCurrentController:0];
- controller = [[[KeyConfig current] controllerList] retain];
- }
- return self;
-}
-
-- (void)dealloc
-{
- [controller release];
-
- [super dealloc];
-}
-
-- (void)drawRect:(NSRect)rect
-{
- //NSLog(@"drawRect: %f,%f;%f,%f\n", rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
-}
-
-- (IBAction)setType:(id)sender
-{
- [[KeyConfig current] setCurrentType:[[controller controllerTypes] objectAtIndex:[sender indexOfSelectedItem]]
- player:[controller currentController]];
- //[controller setType:[[controller controllerTypes] objectAtIndex:[sender indexOfSelectedItem]]];
- [tableView reloadData];
-}
-
-- (void)setController:(int)which
-{
- int i;
- [controller setCurrentController:which];
- [tableView setDataSource:controller];
-
- /* create type popup menu */
- [typeMenu removeAllItems];
- NSArray *typeList = [controller controllerTypes];
- NSString *current = [[KeyConfig current] currentTypeForPlayer:which];
-
- for (i=0; i<[typeList count]; i++) {
- NSString *name = [typeList objectAtIndex:i];
- if ([name isEqualToString:@"-"]) {
- [[typeMenu menu] addItem:[NSMenuItem separatorItem]];
- } else {
- [typeMenu addItemWithTitle:NSLocalizedString(name, @"")];
- if ([name isEqualToString:current])
- [typeMenu selectItemAtIndex:i];
- }
- if (0==i)
- [typeMenu selectItemAtIndex:0];
- }
- [self setType:typeMenu];
-
- //[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
- KeyConfig *config = [KeyConfig current];
- int player = [[config controllerList] currentController];
- NSString *name = [[config controllerList] elementNameAtIndex:[tableView selectedRow] type:[config currentTypeForPlayer:player]];
- [config removeMappingsForElement:name player:player];
- [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/HIDInput/src/PlugPAD.c b/macosx/plugins/HIDInput/src/PlugPAD.c
deleted file mode 100644
index 1cb87bb8..00000000
--- a/macosx/plugins/HIDInput/src/PlugPAD.c
+++ /dev/null
@@ -1,453 +0,0 @@
-
-#include <IOKit/hid/IOHIDUsageTables.h>
-#include "HID_Utilities_External.h"
-#include "PlugPAD.h"
-
-/////////////////////////////////////////////////////////
-typedef void* HWND;
-#include "psemu_plugin_defs.h"
-
-long DoConfiguration();
-void DoAbout();
-
-const char *LibName = "HIDInput";
-const int version = 0;
-const int revision = 1;
-const int build = 0;
-
-const char *PSEgetLibName(void) {
- return LibName;
-}
-
-unsigned long PSEgetLibType(void) {
- return PSE_LT_PAD;
-}
-
-unsigned long PSEgetLibVersion(void) {
- return version << 16 | revision << 8 | build;
-}
-/////////////////////////////////////////////////////////
-
-
-// FIXME: dynamically allocate this
-int gControllerType[MAX_NUM_PADS];
-int gNumKeys[MAX_NUM_PADS];
-keyEntry gKeys[MAX_NUM_PADS][MAX_NUM_KEYS];
-int gNumAxes[MAX_NUM_PADS];
-axisEntry gAxes[MAX_NUM_PADS][MAX_NUM_AXES];
-
-static long sPadFlags = 0;
-
-static unsigned char padid[2] = {0x41, 0x41};
-
-int LoadConfig();
-
-long PADinit(long flags) {
- sPadFlags |= flags;
-
- // kHIDPage_GenericDesktop,kHIDUsage_GD_GamePad
- if (!HIDHaveDeviceList()) {
- // List all HID devices
- HIDBuildDeviceList(kHIDPage_GenericDesktop, 0);
-
- if (HIDCountDevices() == 0) {
- // No devices found!
- HIDReleaseDeviceList();
- return PSE_PAD_ERR_INIT;
- }
-
- //HIDCloseReleaseInterface(
- }
-
- LoadConfig();
- padid[0] = 0x41;
- padid[1] = 0x41;
-
- return 0;
-}
-
-long PADshutdown(void) {
- sPadFlags = 0;
-
- //HIDReleaseAllDeviceQueues();
- HIDReleaseDeviceList();
-
- return 0;
-}
-
-long PADopen(unsigned long *Disp) {
- //printf("start PADopen()\n");
-
- /*HIDReleaseAllDeviceQueues();
-
- if (sPadFlags & PSE_PAD_USE_PORT1) {
- for (i=0; i<numKeys; i++) {
- HIDQueueElement();
- }
- }
- if (sPadFlags & PSE_PAD_USE_PORT2) {
- for (i=0; i<numKeys; i++) {
- HIDQueueElement();
- }
- }*/
-
- return 0;
-}
-
-long PADclose(void) {
- //HIDReleaseAllDeviceQueues();
-
- return 0;
-}
-
-long PADconfigure(void) {
- // make sure our previous configuration was loaded
- if (sPadFlags == 0) {
- //fprintf(stderr, "PADconfigure() called before PADinit()\n");
- if (!HIDHaveDeviceList()) {
- HIDBuildDeviceList(kHIDPage_GenericDesktop, 0);
- }
- }
-
- return DoConfiguration();
-}
-
-void PADabout(void) {
- DoAbout();
-}
-
-long _readPortX(PadDataS *data, int port) {
- unsigned short buttonState = 0xffff;
- keyEntry *keys = gKeys[port];
- axisEntry *axes = gAxes[port];
- int i;
-
- //pRecDevice device;
- //IOHIDEventStruct event;
-
- /*device = HIDGetFirstDevice();
- do {
- while (HIDGetEvent(device, &event)) {
- switch (event->type) {
- case kIOHIDElementTypeInput_Button:
- if (event->value) {
-
- }
- break;
- default:
- break;
- }
- }
- while (HIDGetNextDevice(device));*/
-
- for (i=0; i<gNumKeys[port]; i++) {
- long value = HIDGetElementValue(keys[i].device, keys[i].element);
-
- if (keys[i].element->usagePage == kHIDPage_GenericDesktop &&
- keys[i].element->usage >= kHIDUsage_GD_X && keys[i].element->usage <= kHIDUsage_GD_Rz) {
- /* axis input device */
- // value = HIDCalibrateValue(value, keys[i].element);
- value = HIDScaleValue(value, keys[i].element);
- if (keys[i].reverse) {
- if (value < 64)
- buttonState &= ~(1 << keys[i].button);
- } else {
- if (value > 191)
- buttonState &= ~(1 << keys[i].button);
- }
- } else {
- if (value)
- buttonState &= ~(1 << keys[i].button);
- }
- }
-
- for (i=0; i<gNumAxes[port]; i++) {
- long value = HIDGetElementValue(axes[i].device, axes[i].element);
-
- if (value != axes[i].lastValue) {
- axes[i].lastValue = value;
-
- if (axes[i].element->usagePage == kHIDPage_GenericDesktop &&
- axes[i].element->usage >= kHIDUsage_GD_X && axes[i].element->usage <= kHIDUsage_GD_Rz) {
- /* axis input device */
- // value = HIDCalibrateValue(value, axes[i].element);
- value = HIDScaleValue(value, axes[i].element);
- if (!axes[i].positive) value = 255-value;
-
- if (value >= 127) {
- if (axes[i].reverse) value = 255-value;
-
- switch (axes[i].axis) {
- case 0: data->rightJoyX = value; break;
- case 1: data->rightJoyY = value; break;
- case 2: data->leftJoyX = value; break;
- case 3: data->leftJoyY = value; break;
- }
- }
- }
- }
- }
-
- data->controllerType = gControllerType[port];
- data->buttonStatus = buttonState;
- return 0;
-}
-
-long PADreadPort1(PadDataS *data) {
- static unsigned char lastRightJoyX = 128;
- static unsigned char lastRightJoyY = 128;
- static unsigned char lastLeftJoyX = 128;
- static unsigned char lastLeftJoyY = 128;
-
- data->rightJoyX = lastRightJoyX;
- data->rightJoyY = lastRightJoyY;
- data->leftJoyX = lastLeftJoyX;
- data->leftJoyY = lastLeftJoyY;
-
- _readPortX(data, 0);
-
- lastRightJoyX = data->rightJoyX;
- lastRightJoyY = data->rightJoyY;
- lastLeftJoyX = data->leftJoyX;
- lastLeftJoyY = data->leftJoyY;
-
- return 0;
-}
-
-long PADreadPort2(PadDataS *data) {
- static unsigned char lastRightJoyX = 128;
- static unsigned char lastRightJoyY = 128;
- static unsigned char lastLeftJoyX = 128;
- static unsigned char lastLeftJoyY = 128;
-
- data->rightJoyX = lastRightJoyX;
- data->rightJoyY = lastRightJoyY;
- data->leftJoyX = lastLeftJoyX;
- data->leftJoyY = lastLeftJoyY;
-
- _readPortX(data, 1);
-
- lastRightJoyX = data->rightJoyX;
- lastRightJoyY = data->rightJoyY;
- lastLeftJoyX = data->leftJoyX;
- lastLeftJoyY = data->leftJoyY;
-
- return 0;
-}
-
-static unsigned char stdpar[2][8] = {
- {0xFF, 0x5A, 0xFF, 0xFF, 0x80, 0x80, 0x80, 0x80},
- {0xFF, 0x5A, 0xFF, 0xFF, 0x80, 0x80, 0x80, 0x80}
-};
-
-static unsigned char unk46[2][8] = {
- {0xFF, 0x5A, 0x00, 0x00, 0x01, 0x02, 0x00, 0x0A},
- {0xFF, 0x5A, 0x00, 0x00, 0x01, 0x02, 0x00, 0x0A}
-};
-
-static unsigned char unk47[2][8] = {
- {0xFF, 0x5A, 0x00, 0x00, 0x02, 0x00, 0x01, 0x00},
- {0xFF, 0x5A, 0x00, 0x00, 0x02, 0x00, 0x01, 0x00}
-};
-
-static unsigned char unk4c[2][8] = {
- {0xFF, 0x5A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
- {0xFF, 0x5A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
-};
-
-static unsigned char unk4d[2][8] = {
- {0xFF, 0x5A, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
- {0xFF, 0x5A, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}
-};
-
-static unsigned char stdcfg[2][8] = {
- {0xFF, 0x5A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
- {0xFF, 0x5A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
-};
-
-static unsigned char stdmode[2][8] = {
- {0xFF, 0x5A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
- {0xFF, 0x5A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
-};
-
-static unsigned char stdmodel[2][8] = {
- {0xFF,
- 0x5A,
- 0x01, // 03 - dualshock2, 01 - dualshock
- 0x02, // number of modes
- 0x01, // current mode: 01 - analog, 00 - digital
- 0x02,
- 0x01,
- 0x00},
- {0xFF,
- 0x5A,
- 0x01, // 03 - dualshock2, 01 - dualshock
- 0x02, // number of modes
- 0x01, // current mode: 01 - analog, 00 - digital
- 0x02,
- 0x01,
- 0x00}
-};
-
-static unsigned char CurPad = 0, CurByte = 0, CurCmd = 0, CmdLen = 0;
-
-enum {
- CMD_READ_DATA_AND_VIBRATE = 0x42,
- CMD_CONFIG_MODE = 0x43,
- CMD_SET_MODE_AND_LOCK = 0x44,
- CMD_QUERY_MODEL_AND_MODE = 0x45,
- CMD_QUERY_ACT = 0x46, // ??
- CMD_QUERY_COMB = 0x47, // ??
- CMD_QUERY_MODE = 0x4C, // QUERY_MODE ??
- CMD_VIBRATION_TOGGLE = 0x4D,
-};
-
-unsigned char PADstartPoll(int pad) {
- CurPad = pad - 1;
- CurByte = 0;
-
- return 0xFF;
-}
-
-unsigned char PADpoll(unsigned char value) {
- static unsigned char *buf = NULL;
- PadDataS data;
-
- if (CurByte == 0) {
- CurByte++;
-
- // Don't enable Analog/Vibration for a standard pad
- if (gControllerType[CurPad] != PSE_PAD_TYPE_ANALOGPAD) {
- CurCmd = CMD_READ_DATA_AND_VIBRATE;
- } else {
- CurCmd = value;
- }
-
- switch (CurCmd) {
- case CMD_CONFIG_MODE:
- CmdLen = 8;
- buf = stdcfg[CurPad];
- if (stdcfg[CurPad][3] == 0xFF) return 0xF3;
- else return padid[CurPad];
-
- case CMD_SET_MODE_AND_LOCK:
- CmdLen = 8;
- buf = stdmode[CurPad];
- return 0xF3;
-
- case CMD_QUERY_MODEL_AND_MODE:
- CmdLen = 8;
- buf = stdmodel[CurPad];
- buf[4] = (padid[CurPad] == 0x41 ? 0 : 1);
- return 0xF3;
-
- case CMD_QUERY_ACT:
- CmdLen = 8;
- buf = unk46[CurPad];
- return 0xF3;
-
- case CMD_QUERY_COMB:
- CmdLen = 8;
- buf = unk47[CurPad];
- return 0xF3;
-
- case CMD_QUERY_MODE:
- CmdLen = 8;
- buf = unk4c[CurPad];
- return 0xF3;
-
- case CMD_VIBRATION_TOGGLE:
- CmdLen = 8;
- buf = unk4d[CurPad];
- return 0xF3;
-
- case CMD_READ_DATA_AND_VIBRATE:
- default:
- if (CurPad == 0) {
- PADreadPort1(&data);
- } else {
- PADreadPort2(&data);
- }
-
- stdpar[CurPad][2] = data.buttonStatus & 0xFF;
- stdpar[CurPad][3] = data.buttonStatus >> 8;
-
- if (padid[CurPad] != 0x41) {
- CmdLen = 8;
-
- stdpar[CurPad][4] = data.rightJoyX;
- stdpar[CurPad][5] = data.rightJoyY;
- stdpar[CurPad][6] = data.leftJoyX;
- stdpar[CurPad][7] = data.leftJoyY;
- } else {
- CmdLen = 4;
- }
-
- buf = stdpar[CurPad];
- return padid[CurPad];
- }
- }
-
- switch (CurCmd) {
- case CMD_CONFIG_MODE:
- if (CurByte == 2) {
- switch (value) {
- case 0:
- buf[2] = 0;
- buf[3] = 0;
- break;
-
- case 1:
- buf[2] = 0xFF;
- buf[3] = 0xFF;
- break;
- }
- }
- break;
-
- case CMD_SET_MODE_AND_LOCK:
- if (CurByte == 2) {
- padid[CurPad] = value ? 0x73 : 0x41;
- }
- break;
-
- case CMD_QUERY_ACT:
- if (CurByte == 2) {
- switch (value) {
- case 0: // default
- buf[5] = 0x02;
- buf[6] = 0x00;
- buf[7] = 0x0A;
- break;
-
- case 1: // Param std conf change
- buf[5] = 0x01;
- buf[6] = 0x01;
- buf[7] = 0x14;
- break;
- }
- }
- break;
-
- case CMD_QUERY_MODE:
- if (CurByte == 2) {
- switch (value) {
- case 0: // mode 0 - digital mode
- buf[5] = PSE_PAD_TYPE_STANDARD;
- break;
-
- case 1: // mode 1 - analog mode
- buf[5] = PSE_PAD_TYPE_ANALOGPAD;
- break;
- }
- }
- break;
- }
-
- if (CurByte >= CmdLen) return 0;
- return buf[CurByte++];
-}
-
-long PADkeypressed() {
- return 0;
-}
diff --git a/macosx/plugins/HIDInput/src/PlugPAD.h b/macosx/plugins/HIDInput/src/PlugPAD.h
deleted file mode 100644
index 514f6474..00000000
--- a/macosx/plugins/HIDInput/src/PlugPAD.h
+++ /dev/null
@@ -1,35 +0,0 @@
-
-#ifndef __PLUG_PAD_H__
-#define __PLUG_PAD_H__
-
-#include <IOKit/hid/IOHIDUsageTables.h>
-
-#define MAX_NUM_PADS 2
-#define MAX_NUM_KEYS 64
-#define MAX_NUM_AXES 32
-
-typedef struct {
- unsigned long button;
- unsigned char reverse;
-
- pRecDevice device;
- pRecElement element;
-} keyEntry;
-
-typedef struct {
- unsigned long axis;
- unsigned char reverse;
- unsigned char positive;
- unsigned char lastValue;
-
- pRecDevice device;
- pRecElement element;
-} axisEntry;
-
-extern int gControllerType[MAX_NUM_PADS];
-extern int gNumKeys[MAX_NUM_PADS];
-extern keyEntry gKeys[MAX_NUM_PADS][MAX_NUM_KEYS];
-extern int gNumAxes[MAX_NUM_PADS];
-extern axisEntry gAxes[MAX_NUM_PADS][MAX_NUM_AXES];
-
-#endif //__PLUG_PAD_H__ \ No newline at end of file