2013-11-23 10:10:15 +01:00
|
|
|
// -*- objc -*-
|
|
|
|
|
|
|
|
#include "ebiten_content_view.h"
|
|
|
|
#include "input.h"
|
|
|
|
|
2013-12-15 17:13:18 +01:00
|
|
|
void ebiten_KeyDown(void* nativeWindow, int keyCode);
|
|
|
|
void ebiten_KeyUp(void* nativeWindow, int keyCode);
|
2013-12-15 15:41:33 +01:00
|
|
|
void ebiten_MouseStateUpdated(void* nativeWindow, InputType inputType, int x, int y);
|
2013-11-23 10:10:15 +01:00
|
|
|
|
|
|
|
@implementation EbitenContentView {
|
|
|
|
}
|
|
|
|
|
2013-12-15 15:41:33 +01:00
|
|
|
- (BOOL)acceptsFirstResponder {
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
2013-11-23 10:10:15 +01:00
|
|
|
- (BOOL)isFlipped {
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
2013-12-15 15:41:33 +01:00
|
|
|
- (void)keyDown:(NSEvent*)theEvent {
|
2013-12-15 17:13:18 +01:00
|
|
|
ebiten_KeyDown([self window], [theEvent keyCode]);
|
2013-12-15 15:41:33 +01:00
|
|
|
}
|
|
|
|
|
2013-12-15 17:13:18 +01:00
|
|
|
- (void)keyUp:(NSEvent*)theEvent {
|
|
|
|
ebiten_KeyUp([self window], [theEvent keyCode]);
|
2013-12-15 15:41:33 +01:00
|
|
|
}
|
|
|
|
|
2013-11-23 10:10:15 +01:00
|
|
|
- (void)mouseDown:(NSEvent*)theEvent {
|
|
|
|
NSPoint location = [self convertPoint:[theEvent locationInWindow]
|
|
|
|
fromView:nil];
|
|
|
|
int x = location.x;
|
|
|
|
int y = location.y;
|
2013-12-15 15:41:33 +01:00
|
|
|
ebiten_MouseStateUpdated([self window], InputTypeMouseDown, x, y);
|
2013-11-23 10:10:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)mouseUp:(NSEvent*)theEvent {
|
|
|
|
(void)theEvent;
|
|
|
|
NSPoint location = [self convertPoint:[theEvent locationInWindow]
|
|
|
|
fromView:nil];
|
|
|
|
int x = location.x;
|
|
|
|
int y = location.y;
|
2013-12-15 15:41:33 +01:00
|
|
|
ebiten_MouseStateUpdated([self window], InputTypeMouseUp, x, y);
|
2013-11-23 10:10:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)mouseDragged:(NSEvent*)theEvent {
|
|
|
|
NSPoint location = [self convertPoint:[theEvent locationInWindow]
|
|
|
|
fromView:nil];
|
|
|
|
int x = location.x;
|
|
|
|
int y = location.y;
|
2013-12-15 15:41:33 +01:00
|
|
|
ebiten_MouseStateUpdated([self window], InputTypeMouseDragged, x, y);
|
|
|
|
}
|
|
|
|
|
2013-11-23 10:10:15 +01:00
|
|
|
@end
|