1/* 2 * Copyright 1999-2009 Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Jeremy Friesner 7 */ 8#ifndef _KEY_COMMAND_MAP_H 9#define _KEY_COMMAND_MAP_H 10 11 12#include <List.h> 13#include <Locker.h> 14 15 16#include <Looper.h> 17#include <Messenger.h> 18#include <Message.h> 19#include <MessageFilter.h> 20#include <Node.h> 21 22 23// Maps BMessages to ShortcutsSpecs. 24// The thread here gets file update messages, and updates 25// the fSpecs list to match them (asynchronously). 26 27class KeyCommandMap : public BLooper { 28public: 29 KeyCommandMap(const char* watchFile); 30 virtual ~KeyCommandMap(); 31 32 // Called when a key is pressed or depressed, in the input_server thread. 33 // * keyMessage is the KEY_DOWN message given by the Input Server. 34 // * outList is a BList that additional BMessages can be added to (to insert 35 // events into the input stream.) 36 // * sendMessagesTo is the address of a queue to send command messages to, 37 // for async effects. 38 filter_result KeyEvent(const BMessage* keyMessage, 39 BList* outList, 40 const BMessenger& sendMessagesTo); 41 42 // Called whenever the a B_MOUSE_MOVED message is received. 43 void MouseMessageReceived(const BMessage* message); 44 virtual void MessageReceived(BMessage* message); 45 void DrainInjectedEvents(const BMessage* keyMessage, 46 BList* outList, 47 const BMessenger& sendMessagesTo); 48 49private: 50 void _PutMessageToPort(); 51 void _DeleteHKSList(BList* list); 52 53 port_id fPort; 54 char* fFileName; 55 node_ref fNodeRef; 56 BLocker fSyncSpecs; 57 // locks the lists below 58 BList fInjects; 59 BList* fSpecs; 60 BMessage fLastMouseMessage; 61}; 62 63 64#endif // _KEY_COMMAND_MAP_H 65