event.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #include "platform/input/event.h"
  23. #include "core/module.h"
  24. #include "core/util/journal/process.h"
  25. #include "core/strings/stringFunctions.h"
  26. #include "core/stringTable.h"
  27. #include "platform/platformInput.h"
  28. #include "math/mQuat.h"
  29. #include "math/mAngAxis.h"
  30. MODULE_BEGIN( InputEventManager )
  31. MODULE_INIT_BEFORE( SIM )
  32. MODULE_SHUTDOWN_AFTER( SIM )
  33. MODULE_INIT
  34. {
  35. ManagedSingleton< InputEventManager >::createSingleton();
  36. }
  37. MODULE_SHUTDOWN
  38. {
  39. ManagedSingleton< InputEventManager >::deleteSingleton();
  40. }
  41. MODULE_END;
  42. InputEventManager::InputEventManager()
  43. {
  44. mNextDeviceTypeCode = INPUT_DEVICE_PLUGIN_DEVICES_START;
  45. mNextDeviceCode = INPUT_DEVICE_PLUGIN_CODES_START;
  46. buildVirtualMap();
  47. }
  48. InputEventManager::~InputEventManager()
  49. {
  50. }
  51. U32 InputEventManager::getNextDeviceType()
  52. {
  53. U32 code = mNextDeviceTypeCode;
  54. ++mNextDeviceTypeCode;
  55. return code;
  56. }
  57. U32 InputEventManager::getNextDeviceCode()
  58. {
  59. U32 code = mNextDeviceCode;
  60. ++mNextDeviceCode;
  61. return code;
  62. }
  63. void InputEventManager::registerDevice(IInputDevice* device)
  64. {
  65. // Make sure the device is not already registered
  66. for(U32 i=0; i<mDeviceList.size(); ++i)
  67. {
  68. if(mDeviceList[i] == device)
  69. return;
  70. }
  71. // Add the new device to the list
  72. mDeviceList.push_back(device);
  73. }
  74. void InputEventManager::unregisterDevice(IInputDevice* device)
  75. {
  76. // Remove the device from the list
  77. for(U32 i=0; i<mDeviceList.size(); ++i)
  78. {
  79. if(mDeviceList[i] == device)
  80. {
  81. mDeviceList.erase(i);
  82. return;
  83. }
  84. }
  85. }
  86. bool InputEventManager::isRegisteredDevice(const char* name)
  87. {
  88. for(Vector<IInputDevice*>::iterator itr = mDeviceList.begin(); itr != mDeviceList.end(); ++itr)
  89. {
  90. if((*itr)->isEnabled())
  91. {
  92. const char* deviceName = (*itr)->getDeviceName();
  93. if(dStrnicmp(name, deviceName, dStrlen(deviceName)) == 0)
  94. {
  95. return true;
  96. }
  97. }
  98. }
  99. return false;
  100. }
  101. bool InputEventManager::isRegisteredDevice(U32 type)
  102. {
  103. for(Vector<IInputDevice*>::iterator itr = mDeviceList.begin(); itr != mDeviceList.end(); ++itr)
  104. {
  105. if((*itr)->isEnabled())
  106. {
  107. U32 deviceType = (*itr)->getDeviceType();
  108. if(deviceType == type)
  109. {
  110. return true;
  111. }
  112. }
  113. }
  114. return false;
  115. }
  116. bool InputEventManager::isRegisteredDeviceWithAttributes(const char* name, U32& deviceType, U32&nameLen)
  117. {
  118. for(Vector<IInputDevice*>::iterator itr = mDeviceList.begin(); itr != mDeviceList.end(); ++itr)
  119. {
  120. if((*itr)->isEnabled())
  121. {
  122. const char* deviceName = (*itr)->getDeviceName();
  123. S32 length = dStrlen(deviceName);
  124. if(dStrnicmp(name, deviceName, length) == 0)
  125. {
  126. deviceType = (*itr)->getDeviceType();
  127. nameLen = length;
  128. return true;
  129. }
  130. }
  131. }
  132. return false;
  133. }
  134. const char* InputEventManager::getRegisteredDeviceName(U32 type)
  135. {
  136. for(Vector<IInputDevice*>::iterator itr = mDeviceList.begin(); itr != mDeviceList.end(); ++itr)
  137. {
  138. if((*itr)->isEnabled())
  139. {
  140. U32 deviceType = (*itr)->getDeviceType();
  141. if(deviceType == type)
  142. {
  143. return (*itr)->getDeviceName();
  144. }
  145. }
  146. }
  147. return NULL;
  148. }
  149. void InputEventManager::start()
  150. {
  151. Process::notify(this, &InputEventManager::process, PROCESS_INPUT_ORDER);
  152. }
  153. void InputEventManager::stop()
  154. {
  155. Process::remove(this, &InputEventManager::process);
  156. }
  157. void InputEventManager::process()
  158. {
  159. // Process each device
  160. for(Vector<IInputDevice*>::iterator itr = mDeviceList.begin(); itr != mDeviceList.end(); ++itr)
  161. {
  162. if((*itr)->isEnabled())
  163. {
  164. (*itr)->process();
  165. }
  166. }
  167. }
  168. // Used for the old virtual map table that was originally in actionMap.cpp
  169. struct CodeMapping
  170. {
  171. const char* pDescription;
  172. InputEventType type;
  173. InputObjectInstances code;
  174. };
  175. CodeMapping gVirtualMap[] =
  176. {
  177. //-------------------------------------- KEYBOARD EVENTS
  178. //
  179. { "backspace", SI_KEY, KEY_BACKSPACE },
  180. { "tab", SI_KEY, KEY_TAB },
  181. { "return", SI_KEY, KEY_RETURN },
  182. { "enter", SI_KEY, KEY_RETURN },
  183. { "shift", SI_KEY, KEY_SHIFT },
  184. { "ctrl", SI_KEY, KEY_CONTROL },
  185. { "alt", SI_KEY, KEY_ALT },
  186. { "pause", SI_KEY, KEY_PAUSE },
  187. { "capslock", SI_KEY, KEY_CAPSLOCK },
  188. { "escape", SI_KEY, KEY_ESCAPE },
  189. { "space", SI_KEY, KEY_SPACE },
  190. { "pagedown", SI_KEY, KEY_PAGE_DOWN },
  191. { "pageup", SI_KEY, KEY_PAGE_UP },
  192. { "end", SI_KEY, KEY_END },
  193. { "home", SI_KEY, KEY_HOME },
  194. { "left", SI_KEY, KEY_LEFT },
  195. { "up", SI_KEY, KEY_UP },
  196. { "right", SI_KEY, KEY_RIGHT },
  197. { "down", SI_KEY, KEY_DOWN },
  198. { "print", SI_KEY, KEY_PRINT },
  199. { "insert", SI_KEY, KEY_INSERT },
  200. { "delete", SI_KEY, KEY_DELETE },
  201. { "help", SI_KEY, KEY_HELP },
  202. { "win_lwindow", SI_KEY, KEY_WIN_LWINDOW },
  203. { "win_rwindow", SI_KEY, KEY_WIN_RWINDOW },
  204. { "win_apps", SI_KEY, KEY_WIN_APPS },
  205. { "cmd", SI_KEY, KEY_ALT },
  206. { "opt", SI_KEY, KEY_MAC_OPT },
  207. { "lopt", SI_KEY, KEY_MAC_LOPT },
  208. { "ropt", SI_KEY, KEY_MAC_ROPT },
  209. { "numpad0", SI_KEY, KEY_NUMPAD0 },
  210. { "numpad1", SI_KEY, KEY_NUMPAD1 },
  211. { "numpad2", SI_KEY, KEY_NUMPAD2 },
  212. { "numpad3", SI_KEY, KEY_NUMPAD3 },
  213. { "numpad4", SI_KEY, KEY_NUMPAD4 },
  214. { "numpad5", SI_KEY, KEY_NUMPAD5 },
  215. { "numpad6", SI_KEY, KEY_NUMPAD6 },
  216. { "numpad7", SI_KEY, KEY_NUMPAD7 },
  217. { "numpad8", SI_KEY, KEY_NUMPAD8 },
  218. { "numpad9", SI_KEY, KEY_NUMPAD9 },
  219. { "numpadmult", SI_KEY, KEY_MULTIPLY },
  220. { "numpadadd", SI_KEY, KEY_ADD },
  221. { "numpadsep", SI_KEY, KEY_SEPARATOR },
  222. { "numpadminus", SI_KEY, KEY_SUBTRACT },
  223. { "numpaddecimal", SI_KEY, KEY_DECIMAL },
  224. { "numpaddivide", SI_KEY, KEY_DIVIDE },
  225. { "numpadenter", SI_KEY, KEY_NUMPADENTER },
  226. { "f1", SI_KEY, KEY_F1 },
  227. { "f2", SI_KEY, KEY_F2 },
  228. { "f3", SI_KEY, KEY_F3 },
  229. { "f4", SI_KEY, KEY_F4 },
  230. { "f5", SI_KEY, KEY_F5 },
  231. { "f6", SI_KEY, KEY_F6 },
  232. { "f7", SI_KEY, KEY_F7 },
  233. { "f8", SI_KEY, KEY_F8 },
  234. { "f9", SI_KEY, KEY_F9 },
  235. { "f10", SI_KEY, KEY_F10 },
  236. { "f11", SI_KEY, KEY_F11 },
  237. { "f12", SI_KEY, KEY_F12 },
  238. { "f13", SI_KEY, KEY_F13 },
  239. { "f14", SI_KEY, KEY_F14 },
  240. { "f15", SI_KEY, KEY_F15 },
  241. { "f16", SI_KEY, KEY_F16 },
  242. { "f17", SI_KEY, KEY_F17 },
  243. { "f18", SI_KEY, KEY_F18 },
  244. { "f19", SI_KEY, KEY_F19 },
  245. { "f20", SI_KEY, KEY_F20 },
  246. { "f21", SI_KEY, KEY_F21 },
  247. { "f22", SI_KEY, KEY_F22 },
  248. { "f23", SI_KEY, KEY_F23 },
  249. { "f24", SI_KEY, KEY_F24 },
  250. { "numlock", SI_KEY, KEY_NUMLOCK },
  251. { "scrolllock", SI_KEY, KEY_SCROLLLOCK },
  252. { "lshift", SI_KEY, KEY_LSHIFT },
  253. { "rshift", SI_KEY, KEY_RSHIFT },
  254. { "lcontrol", SI_KEY, KEY_LCONTROL },
  255. { "rcontrol", SI_KEY, KEY_RCONTROL },
  256. { "lalt", SI_KEY, KEY_LALT },
  257. { "ralt", SI_KEY, KEY_RALT },
  258. { "tilde", SI_KEY, KEY_TILDE },
  259. { "minus", SI_KEY, KEY_MINUS },
  260. { "equals", SI_KEY, KEY_EQUALS },
  261. { "lbracket", SI_KEY, KEY_LBRACKET },
  262. { "rbracket", SI_KEY, KEY_RBRACKET },
  263. { "backslash", SI_KEY, KEY_BACKSLASH },
  264. { "semicolon", SI_KEY, KEY_SEMICOLON },
  265. { "apostrophe", SI_KEY, KEY_APOSTROPHE },
  266. { "comma", SI_KEY, KEY_COMMA },
  267. { "period", SI_KEY, KEY_PERIOD },
  268. { "slash", SI_KEY, KEY_SLASH },
  269. { "lessthan", SI_KEY, KEY_OEM_102 },
  270. //-------------------------------------- BUTTON EVENTS
  271. // Joystick/Mouse buttons
  272. { "button0", SI_BUTTON, KEY_BUTTON0 },
  273. { "button1", SI_BUTTON, KEY_BUTTON1 },
  274. { "button2", SI_BUTTON, KEY_BUTTON2 },
  275. { "button3", SI_BUTTON, KEY_BUTTON3 },
  276. { "button4", SI_BUTTON, KEY_BUTTON4 },
  277. { "button5", SI_BUTTON, KEY_BUTTON5 },
  278. { "button6", SI_BUTTON, KEY_BUTTON6 },
  279. { "button7", SI_BUTTON, KEY_BUTTON7 },
  280. { "button8", SI_BUTTON, KEY_BUTTON8 },
  281. { "button9", SI_BUTTON, KEY_BUTTON9 },
  282. { "button10", SI_BUTTON, KEY_BUTTON10 },
  283. { "button11", SI_BUTTON, KEY_BUTTON11 },
  284. { "button12", SI_BUTTON, KEY_BUTTON12 },
  285. { "button13", SI_BUTTON, KEY_BUTTON13 },
  286. { "button14", SI_BUTTON, KEY_BUTTON14 },
  287. { "button15", SI_BUTTON, KEY_BUTTON15 },
  288. { "button16", SI_BUTTON, KEY_BUTTON16 },
  289. { "button17", SI_BUTTON, KEY_BUTTON17 },
  290. { "button18", SI_BUTTON, KEY_BUTTON18 },
  291. { "button19", SI_BUTTON, KEY_BUTTON19 },
  292. { "button20", SI_BUTTON, KEY_BUTTON20 },
  293. { "button21", SI_BUTTON, KEY_BUTTON21 },
  294. { "button22", SI_BUTTON, KEY_BUTTON22 },
  295. { "button23", SI_BUTTON, KEY_BUTTON23 },
  296. { "button24", SI_BUTTON, KEY_BUTTON24 },
  297. { "button25", SI_BUTTON, KEY_BUTTON25 },
  298. { "button26", SI_BUTTON, KEY_BUTTON26 },
  299. { "button27", SI_BUTTON, KEY_BUTTON27 },
  300. { "button28", SI_BUTTON, KEY_BUTTON28 },
  301. { "button29", SI_BUTTON, KEY_BUTTON29 },
  302. { "button30", SI_BUTTON, KEY_BUTTON30 },
  303. { "button31", SI_BUTTON, KEY_BUTTON31 },
  304. { "button32", SI_BUTTON, KEY_BUTTON32 },
  305. { "button33", SI_BUTTON, KEY_BUTTON33 },
  306. { "button34", SI_BUTTON, KEY_BUTTON34 },
  307. { "button35", SI_BUTTON, KEY_BUTTON35 },
  308. { "button36", SI_BUTTON, KEY_BUTTON36 },
  309. { "button37", SI_BUTTON, KEY_BUTTON37 },
  310. { "button38", SI_BUTTON, KEY_BUTTON38 },
  311. { "button39", SI_BUTTON, KEY_BUTTON39 },
  312. { "button40", SI_BUTTON, KEY_BUTTON40 },
  313. { "button41", SI_BUTTON, KEY_BUTTON41 },
  314. { "button42", SI_BUTTON, KEY_BUTTON42 },
  315. { "button43", SI_BUTTON, KEY_BUTTON43 },
  316. { "button44", SI_BUTTON, KEY_BUTTON44 },
  317. { "button45", SI_BUTTON, KEY_BUTTON45 },
  318. { "button46", SI_BUTTON, KEY_BUTTON46 },
  319. { "button47", SI_BUTTON, KEY_BUTTON47 },
  320. //-------------------------------------- MOVE EVENTS
  321. // Mouse/Joystick axes:
  322. { "xaxis", SI_AXIS, SI_XAXIS },
  323. { "yaxis", SI_AXIS, SI_YAXIS },
  324. { "zaxis", SI_AXIS, SI_ZAXIS },
  325. { "rxaxis", SI_AXIS, SI_RXAXIS },
  326. { "ryaxis", SI_AXIS, SI_RYAXIS },
  327. { "rzaxis", SI_AXIS, SI_RZAXIS },
  328. { "slider", SI_AXIS, SI_SLIDER },
  329. //-------------------------------------- POV EVENTS
  330. // Joystick POV:
  331. { "xpov", SI_POV, SI_XPOV },
  332. { "ypov", SI_POV, SI_YPOV },
  333. { "upov", SI_POV, SI_UPOV },
  334. { "dpov", SI_POV, SI_DPOV },
  335. { "lpov", SI_POV, SI_LPOV },
  336. { "rpov", SI_POV, SI_RPOV },
  337. { "xpov2", SI_POV, SI_XPOV2 },
  338. { "ypov2", SI_POV, SI_YPOV2 },
  339. { "upov2", SI_POV, SI_UPOV2 },
  340. { "dpov2", SI_POV, SI_DPOV2 },
  341. { "lpov2", SI_POV, SI_LPOV2 },
  342. { "rpov2", SI_POV, SI_RPOV2 },
  343. //-------------------------------------- GAMEPAD EVENTS
  344. // Controller connect / disconnect:
  345. { "connect", SI_BUTTON, XI_CONNECT },
  346. // L & R Thumbsticks:
  347. { "thumblx", SI_AXIS, XI_THUMBLX },
  348. { "thumbly", SI_AXIS, XI_THUMBLY },
  349. { "thumbrx", SI_AXIS, XI_THUMBRX },
  350. { "thumbry", SI_AXIS, XI_THUMBRY },
  351. // L & R Triggers:
  352. { "triggerl", SI_AXIS, XI_LEFT_TRIGGER },
  353. { "triggerr", SI_AXIS, XI_RIGHT_TRIGGER },
  354. // DPAD Buttons:
  355. { "dpadu", SI_BUTTON, SI_UPOV },
  356. { "dpadd", SI_BUTTON, SI_DPOV },
  357. { "dpadl", SI_BUTTON, SI_LPOV },
  358. { "dpadr", SI_BUTTON, SI_RPOV },
  359. // START & BACK Buttons:
  360. { "btn_start", SI_BUTTON, XI_START },
  361. { "btn_back", SI_BUTTON, XI_BACK },
  362. // L & R Thumbstick Buttons:
  363. { "btn_lt", SI_BUTTON, XI_LEFT_THUMB },
  364. { "btn_rt", SI_BUTTON, XI_RIGHT_THUMB },
  365. // L & R Shoulder Buttons:
  366. { "btn_l", SI_BUTTON, XI_LEFT_SHOULDER },
  367. { "btn_r", SI_BUTTON, XI_RIGHT_SHOULDER },
  368. // Primary buttons:
  369. { "btn_a", SI_BUTTON, XI_A },
  370. { "btn_b", SI_BUTTON, XI_B },
  371. { "btn_x", SI_BUTTON, XI_X },
  372. { "btn_y", SI_BUTTON, XI_Y },
  373. //-------------------------------------- MISCELLANEOUS EVENTS
  374. //
  375. { "anykey", SI_KEY, KEY_ANYKEY },
  376. { "nomatch", SI_UNKNOWN, (InputObjectInstances)0xFFFFFFFF }
  377. };
  378. void InputEventManager::buildVirtualMap()
  379. {
  380. char desc[256];
  381. VirtualMapData* data;
  382. for (U32 j = 0; gVirtualMap[j].code != 0xFFFFFFFF; j++)
  383. {
  384. // Make sure the description is lower case
  385. desc[0] = 0;
  386. dStrncpy(desc, gVirtualMap[j].pDescription, 255);
  387. dStrlwr(desc);
  388. data = new VirtualMapData();
  389. data->type = gVirtualMap[j].type;
  390. data->code = gVirtualMap[j].code;
  391. data->desc = StringTable->insert(desc);
  392. mVirtualMap.insert(data, desc);
  393. mActionCodeMap.insertUnique(data->code, *data);
  394. }
  395. }
  396. void InputEventManager::addVirtualMap(const char* description, InputEventType type, InputObjectInstances code)
  397. {
  398. // Make sure the description is lower case
  399. char desc[256];
  400. desc[0] = 0;
  401. dStrncpy(desc, description, 255);
  402. dStrlwr(desc);
  403. VirtualMapData* data = new VirtualMapData();
  404. data->type = type;
  405. data->code = code;
  406. data->desc = StringTable->insert(desc);
  407. mVirtualMap.insert(data, desc);
  408. mActionCodeMap.insertUnique(data->code, *data);
  409. }
  410. InputEventManager::VirtualMapData* InputEventManager::findVirtualMap(const char* description)
  411. {
  412. char desc[256];
  413. desc[0] = 0;
  414. dStrncpy(desc, description, 255);
  415. dStrlwr(desc);
  416. return mVirtualMap.retreive(desc);
  417. }
  418. const char* InputEventManager::findVirtualMapDescFromCode(U32 code)
  419. {
  420. HashTable<U32, VirtualMapData>::Iterator itr = mActionCodeMap.find(code);
  421. if(itr != mActionCodeMap.end())
  422. return itr->value.desc;
  423. return NULL;
  424. }
  425. void InputEventManager::buildInputEvent(U32 deviceType, U32 deviceInst, InputEventType objType, InputObjectInstances objInst, InputActionType action, S32 iValue)
  426. {
  427. InputEventInfo newEvent;
  428. newEvent.deviceType = deviceType;
  429. newEvent.deviceInst = deviceInst;
  430. newEvent.objType = objType;
  431. newEvent.objInst = objInst;
  432. newEvent.action = action;
  433. newEvent.iValue = iValue;
  434. newEvent.postToSignal(Input::smInputEvent);
  435. }
  436. void InputEventManager::buildInputEvent(U32 deviceType, U32 deviceInst, InputEventType objType, InputObjectInstances objInst, InputActionType action, F32 fValue)
  437. {
  438. InputEventInfo newEvent;
  439. newEvent.deviceType = deviceType;
  440. newEvent.deviceInst = deviceInst;
  441. newEvent.objType = objType;
  442. newEvent.objInst = objInst;
  443. newEvent.action = action;
  444. newEvent.fValue = fValue;
  445. newEvent.postToSignal(Input::smInputEvent);
  446. }
  447. void InputEventManager::buildInputEvent(U32 deviceType, U32 deviceInst, InputEventType objType, InputObjectInstances objInst, InputActionType action, Point3F& pValue)
  448. {
  449. InputEventInfo newEvent;
  450. newEvent.deviceType = deviceType;
  451. newEvent.deviceInst = deviceInst;
  452. newEvent.objType = objType;
  453. newEvent.objInst = objInst;
  454. newEvent.action = action;
  455. newEvent.fValue = pValue.x;
  456. newEvent.fValue2 = pValue.y;
  457. newEvent.fValue3 = pValue.z;
  458. newEvent.postToSignal(Input::smInputEvent);
  459. }
  460. void InputEventManager::buildInputEvent(U32 deviceType, U32 deviceInst, InputEventType objType, InputObjectInstances objInst, InputActionType action, QuatF& qValue)
  461. {
  462. InputEventInfo newEvent;
  463. newEvent.deviceType = deviceType;
  464. newEvent.deviceInst = deviceInst;
  465. newEvent.objType = objType;
  466. newEvent.objInst = objInst;
  467. newEvent.action = action;
  468. newEvent.fValue = qValue.x;
  469. newEvent.fValue2 = qValue.y;
  470. newEvent.fValue3 = qValue.z;
  471. newEvent.fValue4 = qValue.w;
  472. newEvent.postToSignal(Input::smInputEvent);
  473. }
  474. void InputEventManager::buildInputEvent(U32 deviceType, U32 deviceInst, InputEventType objType, InputObjectInstances objInst, InputActionType action, AngAxisF& aValue)
  475. {
  476. InputEventInfo newEvent;
  477. newEvent.deviceType = deviceType;
  478. newEvent.deviceInst = deviceInst;
  479. newEvent.objType = objType;
  480. newEvent.objInst = objInst;
  481. newEvent.action = action;
  482. newEvent.fValue = aValue.axis.x;
  483. newEvent.fValue2 = aValue.axis.y;
  484. newEvent.fValue3 = aValue.axis.z;
  485. newEvent.fValue4 = aValue.angle;
  486. newEvent.postToSignal(Input::smInputEvent);
  487. }